use of net.minecraft.util.EnumHand in project baritone by cabaletta.
the class BlockPlaceHelper method tick.
public void tick(boolean rightClickRequested) {
if (rightClickTimer > 0) {
rightClickTimer--;
return;
}
RayTraceResult mouseOver = ctx.objectMouseOver();
if (!rightClickRequested || ctx.player().isRowingBoat() || mouseOver == null || mouseOver.getBlockPos() == null || mouseOver.typeOfHit != RayTraceResult.Type.BLOCK) {
return;
}
rightClickTimer = Baritone.settings().rightClickSpeed.value;
for (EnumHand hand : EnumHand.values()) {
if (ctx.playerController().processRightClickBlock(ctx.player(), ctx.world(), mouseOver.getBlockPos(), mouseOver.sideHit, mouseOver.hitVec, hand) == EnumActionResult.SUCCESS) {
ctx.player().swingArm(hand);
return;
}
if (!ctx.player().getHeldItem(hand).isEmpty() && ctx.playerController().processRightClick(ctx.player(), ctx.world(), hand) == EnumActionResult.SUCCESS) {
return;
}
}
}
use of net.minecraft.util.EnumHand in project nebula by Sxmurai.
the class SelfFill method onActivated.
@Override
protected void onActivated() {
BlockPos pos = new BlockPos(mc.player.posX, mc.player.posY, mc.player.posZ);
// if we are already burrowed
if (!mc.world.getCollisionBoxes(mc.player, new AxisAlignedBB(pos)).isEmpty()) {
disable();
return;
}
int slot = InventoryUtil.getSlot(InventorySpace.HOTBAR, (s) -> s.getItem() instanceof ItemBlock && ((ItemBlock) s.getItem()).getBlock().equals(mode.getValue().block));
if (slot == -1) {
disable();
return;
}
EnumHand hand = slot == InventoryUtil.OFFHAND_SLOT ? EnumHand.OFF_HAND : EnumHand.MAIN_HAND;
int oldSlot = -1;
if (hand.equals(EnumHand.MAIN_HAND)) {
oldSlot = mc.player.inventory.currentItem;
getNebula().getHotbarManager().sendSlotChange(slot, swap.getValue());
}
for (double offset : FAKE_JUMP) {
mc.player.connection.sendPacket(new Position(mc.player.posX, pos.getY() + offset, mc.player.posZ, false));
}
getNebula().getInteractionManager().placeBlock(pos, hand, rotate.getValue(), swing.getValue());
if (flag.getValue()) {
mc.player.connection.sendPacket(new Position(mc.player.posX, pos.getY() + 2.3, mc.player.posZ, false));
} else {
if (!mc.world.getBlockState(pos).getMaterial().isReplaceable()) {
mc.player.setPosition(pos.getX(), pos.getY() + 1.0, pos.getZ());
}
}
if (oldSlot != -1) {
getNebula().getHotbarManager().sendSlotChange(oldSlot, swap.getValue());
}
disable();
}
use of net.minecraft.util.EnumHand in project GregTech by GregTechCEu.
the class PlayerInventoryUIFactory method readHolderFromSyncData.
@Override
@SideOnly(Side.CLIENT)
protected PlayerInventoryHolder readHolderFromSyncData(PacketBuffer syncData) {
EntityPlayer entityPlayer = Minecraft.getMinecraft().player;
EnumHand enumHand = EnumHand.values()[syncData.readByte()];
ItemStack itemStack;
try {
itemStack = syncData.readItemStack();
} catch (IOException exception) {
throw new RuntimeException(exception);
}
return new PlayerInventoryHolder(entityPlayer, enumHand, itemStack);
}
use of net.minecraft.util.EnumHand in project Lands-of-Icaria by Axanthic-Game-Studios.
the class LOIItemStackRenderer method renderByItem.
public void renderByItem(ItemStack stack, float partialTicks) {
Item item = stack.getItem();
if (item instanceof ItemBlockMobHead) {
if (TileEntitySpecialRendererMobHead.instance != null) {
GlStateManager.pushMatrix();
GlStateManager.disableCull();
TileEntitySpecialRendererMobHead.instance.renderSkull(0.0F, 0.1F, 0.0F, EnumFacing.DOWN, 0.0F, ((BlockMobHead) ((ItemBlock) item).getBlock()).name, -1, 1.6F);
GlStateManager.enableCull();
GlStateManager.popMatrix();
}
}
if (item instanceof ItemSaltedFood) {
GlStateManager.pushMatrix();
GlStateManager.translate(0.5F, 0.5F, 0.5F);
if (stack.hasTagCompound()) {
ItemStack foodStack = ItemSaltedFood.getContainedItem(stack.getTagCompound());
if (!foodStack.isEmpty())
Minecraft.getMinecraft().getRenderItem().renderItem(foodStack, ItemCameraTransforms.TransformType.NONE);
}
Minecraft.getMinecraft().getRenderItem().renderItem(saltOverlay, ItemCameraTransforms.TransformType.NONE);
GlStateManager.popMatrix();
}
if (item instanceof ItemBlock && ((ItemBlock) item).getBlock() instanceof BlockGrinder) {
if (TileEntitySpecialRendererGrinder.instance != null) {
GlStateManager.pushMatrix();
GlStateManager.disableCull();
TileEntitySpecialRendererGrinder.instance.renderInventory();
GlStateManager.enableCull();
GlStateManager.popMatrix();
}
}
if (item instanceof ItemScroll) {
ItemScroll scroll = ((ItemScroll) item);
if (!Minecraft.getMinecraft().player.isInvisible()) {
EnumHand rightHand = EnumHand.MAIN_HAND;
EnumHand leftHand = EnumHand.OFF_HAND;
if (Minecraft.getMinecraft().player.getPrimaryHand() == EnumHandSide.LEFT) {
rightHand = EnumHand.OFF_HAND;
leftHand = EnumHand.MAIN_HAND;
}
// render player arms
if (BakedModelScroll.transform == TransformType.FIRST_PERSON_RIGHT_HAND) {
GlStateManager.translate(((float) Minecraft.getMinecraft().displayWidth) / ((float) Minecraft.getMinecraft().displayHeight) * 0.5F, 0.9F, 0.4F);
GlStateManager.disableCull();
GlStateManager.pushMatrix();
GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F);
if (Minecraft.getMinecraft().player.getHeldItem(leftHand).isEmpty() && rightHand != EnumHand.OFF_HAND)
renderArm(EnumHandSide.LEFT);
GlStateManager.translate(0.0F, 0.3F, -0.7F);
GlStateManager.rotate(-60.0F, 1.0F, 0.0F, 0.0F);
renderArm(EnumHandSide.RIGHT);
GlStateManager.popMatrix();
GlStateManager.enableCull();
}
if (BakedModelScroll.transform == TransformType.FIRST_PERSON_LEFT_HAND) {
GlStateManager.translate(((float) Minecraft.getMinecraft().displayWidth) / ((float) Minecraft.getMinecraft().displayHeight) * -0.5F + 1.68F, 0.9F, 0.4F);
GlStateManager.disableCull();
GlStateManager.pushMatrix();
GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F);
GlStateManager.translate(-0.1F, 0.03F, -0.7F);
if (Minecraft.getMinecraft().player.getHeldItem(rightHand).isEmpty() && leftHand != EnumHand.OFF_HAND)
renderArm(EnumHandSide.RIGHT);
GlStateManager.translate(0.1F, 0.27F, 0.7F);
GlStateManager.rotate(60.0F, 1.0F, 0.0F, 0.0F);
renderArm(EnumHandSide.LEFT);
GlStateManager.popMatrix();
GlStateManager.enableCull();
}
}
// render scroll background
GlStateManager.scale(0.76F, 0.76F, 0.76F);
GlStateManager.disableLighting();
Minecraft.getMinecraft().getTextureManager().bindTexture(RES_SCROLL_BACKGROUND);
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuffer();
GlStateManager.translate(-1.0F, -0.6F, -0.2F);
GlStateManager.scale(0.0078125F, 0.0078125F, 0.0078125F);
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
bufferbuilder.pos(0.0D, 0.0D, 0.0D).tex(0.0D, 1.0D).endVertex();
bufferbuilder.pos(142.0D, 0.0D, 0.0D).tex(1.0D, 1.0D).endVertex();
bufferbuilder.pos(142.0D, 142.0D, 0.0D).tex(1.0D, 0.0D).endVertex();
bufferbuilder.pos(0.0D, 142.0D, 0.0D).tex(0.0D, 0.0D).endVertex();
tessellator.draw();
GlStateManager.translate(71.0F, 44.5F, 0.01F);
// render scroll title
GlStateManager.pushMatrix();
GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F);
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
String title = I18n.translateToLocal("spell." + scroll.getName() + ".name");
fontRenderer.drawString(title, -fontRenderer.getStringWidth(title) / 2, -60, 0x82735A);
GlStateManager.popMatrix();
GlStateManager.scale(25.0F, 25.0F, 0.001F);
// render ingredients
Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
GlStateManager.pushMatrix();
GlStateManager.scale(0.6F, 0.6F, 1.0F);
GlStateManager.translate(0.55F - scroll.getRecipe().order.size() * 0.55F, 2.5F, 0.0F);
for (int i = 0; i < scroll.getRecipe().order.size(); ++i) {
Minecraft.getMinecraft().getRenderItem().renderItem(scroll.getRecipe().getInputs().get(scroll.getRecipe().order.get(i)).getMatchingStacks()[0], ItemCameraTransforms.TransformType.GUI);
GlStateManager.translate(1.1F, 0.0F, 0.0F);
}
GlStateManager.popMatrix();
// render result
Minecraft.getMinecraft().getRenderItem().renderItem(scroll.getRecipe().recipeOutput, ItemCameraTransforms.TransformType.GUI);
GlStateManager.enableLighting();
}
}
use of net.minecraft.util.EnumHand in project ProjectE by sinkillerj.
the class GuiHandler method getClientGuiElement.
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
TileEntity tile = !ITEM_IDS.contains(ID) ? world.getTileEntity(new BlockPos(x, y, z)) : null;
// if not a TE, x will hold which hand it came from. 1 for off, 0 otherwise
EnumHand hand = ITEM_IDS.contains(ID) ? (x == 1 ? EnumHand.OFF_HAND : EnumHand.MAIN_HAND) : null;
switch(ID) {
case Constants.ALCH_CHEST_GUI:
if (tile != null && tile instanceof AlchChestTile)
return new GUIAlchChest(player.inventory, (AlchChestTile) tile);
break;
case Constants.ALCH_BAG_GUI:
{
EnumDyeColor color = EnumDyeColor.byMetadata(player.getHeldItem(hand).getItemDamage());
IItemHandlerModifiable inventory = (IItemHandlerModifiable) player.getCapability(ProjectEAPI.ALCH_BAG_CAPABILITY, null).getBag(color);
return new GUIAlchChest(player.inventory, hand, inventory);
}
case Constants.CONDENSER_GUI:
if (tile != null && tile instanceof CondenserTile)
return new GUICondenser(player.inventory, (CondenserTile) tile);
break;
case Constants.TRANSMUTE_STONE_GUI:
return new GUITransmutation(player.inventory, new TransmutationInventory(player), null);
case Constants.RM_FURNACE_GUI:
if (tile != null && tile instanceof RMFurnaceTile)
return new GUIRMFurnace(player.inventory, (RMFurnaceTile) tile);
break;
case Constants.DM_FURNACE_GUI:
if (tile != null && tile instanceof DMFurnaceTile)
return new GUIDMFurnace(player.inventory, (DMFurnaceTile) tile);
break;
case Constants.COLLECTOR1_GUI:
if (tile != null && tile instanceof CollectorMK1Tile)
return new GUICollectorMK1(player.inventory, (CollectorMK1Tile) tile);
break;
case Constants.COLLECTOR2_GUI:
if (tile != null && tile instanceof CollectorMK2Tile)
return new GUICollectorMK2(player.inventory, (CollectorMK2Tile) tile);
break;
case Constants.COLLECTOR3_GUI:
if (tile != null && tile instanceof CollectorMK3Tile)
return new GUICollectorMK3(player.inventory, (CollectorMK3Tile) tile);
break;
case Constants.RELAY1_GUI:
if (tile != null && tile instanceof RelayMK1Tile)
return new GUIRelayMK1(player.inventory, (RelayMK1Tile) tile);
break;
case Constants.RELAY2_GUI:
if (tile != null && tile instanceof RelayMK2Tile)
return new GUIRelayMK2(player.inventory, (RelayMK2Tile) tile);
break;
case Constants.RELAY3_GUI:
if (tile != null && tile instanceof RelayMK3Tile)
return new GUIRelayMK3(player.inventory, (RelayMK3Tile) tile);
break;
case Constants.MERCURIAL_GUI:
return new GUIMercurialEye(player.inventory, new MercurialEyeInventory(player.getHeldItem(hand)));
case Constants.PHILOS_STONE_GUI:
return new GUIPhilosStone(player.inventory);
case Constants.TRANSMUTATION_GUI:
return new GUITransmutation(player.inventory, new TransmutationInventory(player), hand);
case Constants.ETERNAL_DENSITY_GUI:
return new GUIEternalDensity(player.inventory, new EternalDensityInventory(player.getHeldItem(hand), player));
case Constants.CONDENSER_MK2_GUI:
return new GUICondenserMK2(player.inventory, (CondenserMK2Tile) tile);
}
return null;
}
Aggregations