use of com.cjm721.overloaded.util.BlockItemUseContextPublic in project Overloaded by CJ-MC-Mods.
the class RenderMultiToolAssist method renderWorldLastEvent.
@SubscribeEvent
public static void renderWorldLastEvent(RenderWorldLastEvent event) {
float partialTick = Minecraft.getInstance().getFrameTime();
PlayerEntity player = Minecraft.getInstance().player;
if (player.getMainHandItem().getItem() != ModItems.multiTool)
return;
RayTraceResult resultPick = player.pick(OverloadedConfig.INSTANCE.multiToolConfig.reach, partialTick, false);
if (resultPick.getType() == RayTraceResult.Type.MISS || !(resultPick instanceof BlockRayTraceResult)) {
return;
}
BlockRayTraceResult result = ((BlockRayTraceResult) resultPick);
ItemStack stack = ModItems.multiTool.getSelectedBlockItemStack(player.getMainHandItem());
BlockState state;
if (stack.getItem() instanceof BlockItem) {
state = ((BlockItem) stack.getItem()).getBlock().defaultBlockState();
state = state.getStateAtViewpoint(player.getCommandSenderWorld(), result.getBlockPos(), player.getEyePosition(partialTick));
state = state.getBlock().getStateForPlacement(new BlockItemUseContextPublic(player.getCommandSenderWorld(), player, Hand.MAIN_HAND, stack, result));
} else {
state = Blocks.COBBLESTONE.defaultBlockState();
}
switch(getAssistMode()) {
case PLACE_PREVIEW:
if (!stack.isEmpty() && state != null)
renderBlockPreview(event, result, state);
break;
case REMOVE_PREVIEW:
renderRemovePreview(event, result);
break;
case BOTH_PREVIEW:
renderRemovePreview(event, result);
if (!stack.isEmpty() && state != null)
renderBlockPreview(event, result, state);
}
}
Aggregations