net.minecraft.block.ChestBlock Java Examples
The following examples show how to use
net.minecraft.block.ChestBlock.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MixinBlockItem.java From multiconnect with MIT License | 6 votes |
@Inject(method = "canPlace", at = @At("HEAD"), cancellable = true) private void onCanPlace(ItemPlacementContext context, BlockState state, CallbackInfoReturnable<Boolean> ci) { if (ConnectionInfo.protocolVersion <= Protocols.V1_12_2) { Block block = state.getBlock(); if (block == Blocks.CHEST || block == Blocks.TRAPPED_CHEST) { World world = context.getWorld(); BlockPos pos = context.getBlockPos(); boolean foundAdjChest = false; for (Direction dir : Direction.Type.HORIZONTAL) { BlockState otherState = world.getBlockState(pos.offset(dir)); if (otherState.getBlock() == block) { if (foundAdjChest) { ci.setReturnValue(false); return; } foundAdjChest = true; if (otherState.get(ChestBlock.CHEST_TYPE) != ChestType.SINGLE) { ci.setReturnValue(false); return; } } } } } }
Example #2
Source File: Peek.java From bleachhack-1.14 with GNU General Public License v3.0 | 6 votes |
public void drawShulkerToolTip(Slot slot, int mX, int mY) { if (!(slot.getStack().getItem() instanceof BlockItem)) return; if (!(((BlockItem) slot.getStack().getItem()).getBlock() instanceof ShulkerBoxBlock) && !(((BlockItem) slot.getStack().getItem()).getBlock() instanceof ChestBlock) && !(((BlockItem) slot.getStack().getItem()).getBlock() instanceof DispenserBlock) && !(((BlockItem) slot.getStack().getItem()).getBlock() instanceof HopperBlock)) return; List<ItemStack> items = ItemContentUtils.getItemsInContainer(slot.getStack()); Block block = ((BlockItem) slot.getStack().getItem()).getBlock(); int count = block instanceof HopperBlock || block instanceof DispenserBlock ? 18 : 0; if (block instanceof HopperBlock) renderTooltipBox(mX, mY - 21, 13, 82, true); else if (block instanceof DispenserBlock) renderTooltipBox(mX, mY - 21, 13, 150, true); else renderTooltipBox(mX, mY - 55, 47, 150, true); for (ItemStack i: items) { if (count > 26) break; int x = mX + 10 + (17 * (count % 9)); int y = mY - 69 + (17 * (count / 9)); mc.getItemRenderer().renderGuiItem(i, x, y); mc.getItemRenderer().renderGuiItemOverlay(mc.textRenderer, i, x, y, i.getCount() > 1 ? i.getCount() + "" : ""); count++; } }
Example #3
Source File: Peek.java From bleachhack-1.14 with GNU General Public License v3.0 | 6 votes |
public void drawShulkerToolTip(Slot slot, int mX, int mY) { if (!(slot.getStack().getItem() instanceof BlockItem)) return; if (!(((BlockItem) slot.getStack().getItem()).getBlock() instanceof ShulkerBoxBlock) && !(((BlockItem) slot.getStack().getItem()).getBlock() instanceof ChestBlock) && !(((BlockItem) slot.getStack().getItem()).getBlock() instanceof DispenserBlock) && !(((BlockItem) slot.getStack().getItem()).getBlock() instanceof HopperBlock)) return; List<ItemStack> items = ItemContentUtils.getItemsInContainer(slot.getStack()); Block block = ((BlockItem) slot.getStack().getItem()).getBlock(); int count = block instanceof HopperBlock || block instanceof DispenserBlock ? 18 : 0; if (block instanceof HopperBlock) renderTooltipBox(mX, mY - 21, 13, 82, true); else if (block instanceof DispenserBlock) renderTooltipBox(mX, mY - 21, 13, 150, true); else renderTooltipBox(mX, mY - 55, 47, 150, true); for (ItemStack i: items) { if (count > 26) break; int x = mX + 10 + (17 * (count % 9)); int y = mY - 69 + (17 * (count / 9)); mc.getItemRenderer().renderGuiItemIcon(i, x, y); mc.getItemRenderer().renderGuiItemOverlay(mc.textRenderer, i, x, y, i.getCount() > 1 ? i.getCount() + "" : ""); count++; } }
Example #4
Source File: Peek.java From bleachhack-1.14 with GNU General Public License v3.0 | 6 votes |
public void drawShulkerToolTip(Slot slot, int mX, int mY) { if (!(slot.getStack().getItem() instanceof BlockItem)) return; if (!(((BlockItem) slot.getStack().getItem()).getBlock() instanceof ShulkerBoxBlock) && !(((BlockItem) slot.getStack().getItem()).getBlock() instanceof ChestBlock) && !(((BlockItem) slot.getStack().getItem()).getBlock() instanceof DispenserBlock) && !(((BlockItem) slot.getStack().getItem()).getBlock() instanceof HopperBlock)) return; List<ItemStack> items = ItemContentUtils.getItemsInContainer(slot.getStack()); Block block = ((BlockItem) slot.getStack().getItem()).getBlock(); int count = block instanceof HopperBlock || block instanceof DispenserBlock ? 18 : 0; if (block instanceof HopperBlock) renderTooltipBox(mX, mY - 21, 13, 82, true); else if (block instanceof DispenserBlock) renderTooltipBox(mX, mY - 21, 13, 150, true); else renderTooltipBox(mX, mY - 55, 47, 150, true); for (ItemStack i: items) { if (count > 26) break; int x = mX + 10 + (17 * (count % 9)); int y = mY - 69 + (17 * (count / 9)); mc.getItemRenderer().renderGuiItem(i, x, y); mc.getItemRenderer().renderGuiItemOverlay(mc.textRenderer, i, x, y, i.getCount() > 1 ? i.getCount() + "" : ""); count++; } }
Example #5
Source File: ChestEspHack.java From Wurst7 with GNU General Public License v3.0 | 5 votes |
private Box getBoxFromChest(ChestBlockEntity chestBE) { BlockState state = chestBE.getCachedState(); if(!state.contains(ChestBlock.CHEST_TYPE)) return null; ChestType chestType = state.get(ChestBlock.CHEST_TYPE); // ignore other block in double chest if(chestType == ChestType.LEFT) return null; BlockPos pos = chestBE.getPos(); if(!BlockUtils.canBeClicked(pos)) return null; Box box = BlockUtils.getBoundingBox(pos); // larger box for double chest if(chestType != ChestType.SINGLE) { BlockPos pos2 = pos.offset(ChestBlock.getFacing(state)); if(BlockUtils.canBeClicked(pos2)) { Box box2 = BlockUtils.getBoundingBox(pos2); box = box.union(box2); } } return box; }
Example #6
Source File: CmdPeek.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
@Override public void onCommand(String command, String[] args) throws Exception { ItemStack item = mc.player.inventory.getMainHandStack(); if (!(item.getItem() instanceof BlockItem)) { BleachLogger.errorMessage("Must be holding a containter to peek."); return; } if (!(((BlockItem) item.getItem()).getBlock() instanceof ShulkerBoxBlock) && !(((BlockItem) item.getItem()).getBlock() instanceof ChestBlock) && !(((BlockItem) item.getItem()).getBlock() instanceof DispenserBlock) && !(((BlockItem) item.getItem()).getBlock() instanceof HopperBlock)) { BleachLogger.errorMessage("Must be holding a containter to peek."); return; } List<ItemStack> items = ItemContentUtils.getItemsInContainer(item); BasicInventory inv = new BasicInventory(items.toArray(new ItemStack[27])); BleachQueue.queue.add(() -> { mc.openScreen(new ShulkerBoxScreen( new ShulkerBoxContainer(420, mc.player.inventory, inv), mc.player.inventory, item.getName())); }); }
Example #7
Source File: CmdPeek.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
@Override public void onCommand(String command, String[] args) throws Exception { ItemStack item = mc.player.inventory.getMainHandStack(); if (!(item.getItem() instanceof BlockItem)) { BleachLogger.errorMessage("Must be holding a containter to peek."); return; } if (!(((BlockItem) item.getItem()).getBlock() instanceof ShulkerBoxBlock) && !(((BlockItem) item.getItem()).getBlock() instanceof ChestBlock) && !(((BlockItem) item.getItem()).getBlock() instanceof DispenserBlock) && !(((BlockItem) item.getItem()).getBlock() instanceof HopperBlock)) { BleachLogger.errorMessage("Must be holding a containter to peek."); return; } List<ItemStack> items = ItemContentUtils.getItemsInContainer(item); SimpleInventory inv = new SimpleInventory(items.toArray(new ItemStack[27])); BleachQueue.queue.add(() -> { mc.openScreen(new ShulkerBoxScreen( new ShulkerBoxScreenHandler(420, mc.player.inventory, inv), mc.player.inventory, item.getName())); }); }
Example #8
Source File: CmdPeek.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
@Override public void onCommand(String command, String[] args) throws Exception { ItemStack item = mc.player.inventory.getMainHandStack(); if (!(item.getItem() instanceof BlockItem)) { BleachLogger.errorMessage("Must be holding a containter to peek."); return; } if (!(((BlockItem) item.getItem()).getBlock() instanceof ShulkerBoxBlock) && !(((BlockItem) item.getItem()).getBlock() instanceof ChestBlock) && !(((BlockItem) item.getItem()).getBlock() instanceof DispenserBlock) && !(((BlockItem) item.getItem()).getBlock() instanceof HopperBlock)) { BleachLogger.errorMessage("Must be holding a containter to peek."); return; } List<ItemStack> items = ItemContentUtils.getItemsInContainer(item); BasicInventory inv = new BasicInventory(items.toArray(new ItemStack[27])); BleachQueue.queue.add(() -> { mc.openScreen(new ShulkerBoxScreen( new ShulkerBoxContainer(420, mc.player.inventory, inv), mc.player.inventory, item.getName())); }); }
Example #9
Source File: PistonHandler_movableTEMixin.java From fabric-carpet with MIT License | 5 votes |
/** * @param blockState blockState of one double chest half block * @return Direction towards the other block of the double chest, null if the blockState is not a double chest * @author 2No2Name */ private Direction getDirectionToOtherChestHalf(BlockState blockState){ ChestType chestType; try{ chestType = blockState.get(ChestBlock.CHEST_TYPE); }catch(IllegalArgumentException e){return null;} if(chestType == ChestType.SINGLE) return null; return ChestBlock.getFacing(blockState); }