net.minecraft.block.HopperBlock Java Examples
The following examples show how to use
net.minecraft.block.HopperBlock.
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: 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 #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().renderGuiItemIcon(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().renderGuiItem(i, x, y); mc.getItemRenderer().renderGuiItemOverlay(mc.textRenderer, i, x, y, i.getCount() > 1 ? i.getCount() + "" : ""); count++; } }
Example #4
Source File: HopperBlockEntityMixin.java From fabric-carpet with MIT License | 6 votes |
@Inject(method = "insert", at = @At("HEAD"), cancellable = true) private void onInsert(CallbackInfoReturnable<Boolean> cir) { if (CarpetSettings.hopperCounters) { DyeColor wool_color = WoolTool.getWoolColorAtPosition( getWorld(), new BlockPos(getHopperX(), getHopperY(), getHopperZ()).offset(this.getCachedState().get(HopperBlock.FACING))); if (wool_color != null) { for (int i = 0; i < this.getInvSize(); ++i) { if (!this.getInvStack(i).isEmpty()) { ItemStack itemstack = this.getInvStack(i);//.copy(); HopperCounter.COUNTERS.get(wool_color).add(this.getWorld().getServer(), itemstack); this.setInvStack(i, ItemStack.EMPTY); } } cir.setReturnValue(true); } } }
Example #5
Source File: MixinHopperBlockEntity.java From Sandbox with GNU Lesser General Public License v3.0 | 5 votes |
@Inject(method = "insert", at = @At("HEAD"), cancellable = true) public void insert(CallbackInfoReturnable<Boolean> info) { World world = (World) this.getWorld(); Position position = (Position) getPos(); if (world == null) { info.setReturnValue(false); return; } BlockState state = (BlockState) getCachedState(); Direction direction = WrappingUtil.convert(getCachedState().get(HopperBlock.FACING)); Inventory hopperInventory = state.getComponent(world, position, Components.INVENTORY_COMPONENT).orElse(null); if (hopperInventory != null) { Position offset = position.offset(direction); BlockState other = world.getBlockState(offset); Mono<Inventory> mono = other.getComponent(world, offset, Components.INVENTORY_COMPONENT, direction.getOppositeDirection()); if (mono.isPresent()) { Inventory inputInv = mono.get(); for (int slot : hopperInventory) { ItemStack input = hopperInventory.extract(slot, 1, true); if (!input.isEmpty()) { if (inputInv.insert(input, true).isEmpty()) { inputInv.insert(hopperInventory.extract(slot, 1)); info.setReturnValue(true); return; } } } info.setReturnValue(false); } } }
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: Peek.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
@SubscribeEvent public void onGuiDraw(GuiScreenEvent.DrawScreenEvent.Post event) { if (!(event.getGui() instanceof ContainerScreen<?>)) return; ContainerScreen<?> screen = (ContainerScreen<?>) event.getGui(); if (screen.getSlotUnderMouse() == null) return; if (!(screen.getSlotUnderMouse().getStack().getItem() instanceof BlockItem)) return; if (!(((BlockItem) screen.getSlotUnderMouse().getStack().getItem()).getBlock() instanceof ContainerBlock)) return; NonNullList<ItemStack> items = NonNullList.withSize(27, new ItemStack(Items.AIR)); CompoundNBT nbt = screen.getSlotUnderMouse().getStack().getTag(); if (nbt != null && nbt.contains("BlockEntityTag")) { CompoundNBT itemnbt = nbt.getCompound("BlockEntityTag"); if (itemnbt.contains("Items")) ItemStackHelper.loadAllItems(itemnbt, items); } GlStateManager.translatef(0.0F, 0.0F, 500.0F); Block block = ((BlockItem) screen.getSlotUnderMouse().getStack().getItem()).getBlock(); int count = block instanceof HopperBlock || block instanceof DispenserBlock ? 18 : 0; for (ItemStack i: items) { if (count > 26) break; int x = event.getMouseX() + 8 + (17 * (count % 9)); int y = event.getMouseY() - 68 + (17 * (count / 9)); if (i.getItem() != Items.AIR) { Screen.fill(x, y, x+17, y+17, 0x90000000); Screen.fill(x, y, x+17, y+1, 0xff000000); Screen.fill(x, y+1, x+1, y+17, 0xff000000); Screen.fill(x+16, y+1, x+17, y+17, 0xff000000); Screen.fill(x+1, y+16, x+17, y+17, 0xff000000); } mc.getItemRenderer().renderItemAndEffectIntoGUI(i, x, y); mc.getItemRenderer().renderItemOverlayIntoGUI(mc.fontRenderer, i, x, y, i.getCount() > 1 ? i.getCount() + "" : ""); count++; } }
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); 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 #9
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 #10
Source File: BlockRotator.java From fabric-carpet with MIT License | 4 votes |
public static boolean flip_block(BlockState state, World world, PlayerEntity player, Hand hand, BlockHitResult hit) { Block block = state.getBlock(); BlockPos pos = hit.getBlockPos(); Vec3d hitVec = hit.getPos().subtract(pos.getX(), pos.getY(), pos.getZ()); Direction facing = hit.getSide(); BlockState newState = null; if ( (block instanceof GlazedTerracottaBlock) || (block instanceof AbstractRedstoneGateBlock) || (block instanceof RailBlock) || (block instanceof TrapdoorBlock) || (block instanceof LeverBlock) || (block instanceof FenceGateBlock)) { newState = state.rotate(BlockRotation.CLOCKWISE_90); } else if ((block instanceof ObserverBlock) || (block instanceof EndRodBlock)) { newState = state.with(FacingBlock.FACING, (Direction) state.get(FacingBlock.FACING).getOpposite()); } else if (block instanceof DispenserBlock) { newState = state.with(DispenserBlock.FACING, state.get(DispenserBlock.FACING).getOpposite()); } else if (block instanceof PistonBlock) { if (!(state.get(PistonBlock.EXTENDED))) newState = state.with(FacingBlock.FACING, state.get(FacingBlock.FACING).getOpposite()); } else if (block instanceof SlabBlock) { if (((SlabBlock) block).hasSidedTransparency(state)) { newState = state.with(SlabBlock.TYPE, state.get(SlabBlock.TYPE) == SlabType.TOP ? SlabType.BOTTOM : SlabType.TOP); } } else if (block instanceof HopperBlock) { if ((Direction)state.get(HopperBlock.FACING) != Direction.DOWN) { newState = state.with(HopperBlock.FACING, state.get(HopperBlock.FACING).rotateYClockwise()); } } else if (block instanceof StairsBlock) { //LOG.error(String.format("hit with facing: %s, at side %.1fX, X %.1fY, Y %.1fZ",facing, hitX, hitY, hitZ)); if ((facing == Direction.UP && hitVec.y == 1.0f) || (facing == Direction.DOWN && hitVec.y == 0.0f)) { newState = state.with(StairsBlock.HALF, state.get(StairsBlock.HALF) == BlockHalf.TOP ? BlockHalf.BOTTOM : BlockHalf.TOP ); } else { boolean turn_right; if (facing == Direction.NORTH) { turn_right = (hitVec.x <= 0.5); } else if (facing == Direction.SOUTH) { turn_right = !(hitVec.x <= 0.5); } else if (facing == Direction.EAST) { turn_right = (hitVec.z <= 0.5); } else if (facing == Direction.WEST) { turn_right = !(hitVec.z <= 0.5); } else { return false; } if (turn_right) { newState = state.rotate(BlockRotation.COUNTERCLOCKWISE_90); } else { newState = state.rotate(BlockRotation.CLOCKWISE_90); } } } else { return false; } if (newState != null) { world.setBlockState(pos, newState, 2 | 1024); world.checkBlockRerender(pos, state, newState); return true; } return false; }