net.minecraft.item.BlockItem Java Examples
The following examples show how to use
net.minecraft.item.BlockItem.
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: FlowerPotBlockMixin.java From carpet-extra with GNU Lesser General Public License v3.0 | 6 votes |
@Inject(method = "onUse", at = @At("HEAD")) private void onActivate(BlockState blockState_1, World world_1, BlockPos blockPos_1, PlayerEntity playerEntity_1, Hand hand_1, BlockHitResult blockHitResult_1, CallbackInfoReturnable<Boolean> cir) { if (CarpetExtraSettings.flowerPotChunkLoading && world_1.getServer() != null && !world_1.isClient) { ItemStack stack = playerEntity_1.getStackInHand(hand_1); Item item = stack.getItem(); Block block = item instanceof BlockItem ? (Block) CONTENT_TO_POTTED.getOrDefault(((BlockItem) item).getBlock(), Blocks.AIR) : Blocks.AIR; boolean boolean_1 = block == Blocks.AIR; boolean boolean_2 = this.content == Blocks.AIR; ServerWorld serverWorld = world_1.getServer().getWorld(world_1.getDimension().getType()); if (boolean_1 != boolean_2 && (block == Blocks.POTTED_WITHER_ROSE || this.content == Blocks.WITHER_ROSE)) { // System.out.println("Chunk load status = " + boolean_2); serverWorld.setChunkForced(blockPos_1.getX() >> 4, blockPos_1.getZ() >> 4, boolean_2); } } }
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: TunnellerHack.java From Wurst7 with GNU General Public License v3.0 | 6 votes |
private boolean equipTorch() { for(int slot = 0; slot < 9; slot++) { // filter out non-block items ItemStack stack = MC.player.inventory.getStack(slot); if(stack.isEmpty() || !(stack.getItem() instanceof BlockItem)) continue; // filter out non-torch blocks Block block = Block.getBlockFromItem(stack.getItem()); if(!(block instanceof TorchBlock)) continue; MC.player.inventory.selectedSlot = slot; return true; } return false; }
Example #5
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 #6
Source File: RenderUtilsLiving.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
public static void drawItem(double x, double y, double z, double offX, double offY, double scale, ItemStack item) { glSetup(x, y, z); GL11.glScaled(0.4*scale, 0.4*scale, 0); GL11.glTranslated(offX, offY, 0); if (item.getItem() instanceof BlockItem) GL11.glRotatef(180F, 1F, 180F, 10F); mc.getItemRenderer().renderItem(new ItemStack( item.getItem()), Mode.GUI, 0, 0, new MatrixStack(), mc.getBufferBuilders().getEntityVertexConsumers()); if (item.getItem() instanceof BlockItem) GL11.glRotatef(-180F, -1F, -180F, -10F); GL11.glDisable(GL11.GL_LIGHTING); GL11.glScalef(-0.05F, -0.05F, 0); if (item.getCount() > 0) { int w = mc.textRenderer.getWidth("x" + item.getCount()) / 2; mc.textRenderer.drawWithShadow(new MatrixStack(), "x" + item.getCount(), 7 - w, 5, 0xffffff); } GL11.glScalef(0.85F, 0.85F, 0.85F); int c = 0; for (Entry<Enchantment, Integer> m: EnchantmentHelper.get(item).entrySet()) { int w1 = mc.textRenderer.getWidth(I18n.translate(m.getKey().getName(2).asString()).substring(0, 2) + m.getValue()) / 2; mc.textRenderer.drawWithShadow(new MatrixStack(), I18n.translate(m.getKey().getName(2).asString()).substring(0, 2) + m.getValue(), -4 - w1, c*10-1, m.getKey() == Enchantments.VANISHING_CURSE || m.getKey() == Enchantments.BINDING_CURSE ? 0xff5050 : 0xffb0e0); c--; } GL11.glScalef(0.6F, 0.6F, 0.6F); String dur = item.getMaxDamage() - item.getDamage() + ""; int color = 0x000000; try{ color = MathHelper.hsvToRgb(((float) (item.getMaxDamage() - item.getDamage()) / item.getMaxDamage()) / 3.0F, 1.0F, 1.0F); } catch (Exception e) {} if (item.isDamageable()) mc.textRenderer.drawWithShadow(new MatrixStack(), dur, -8 - dur.length() * 3, 15, new Color(color >> 16 & 255, color >> 8 & 255, color & 255).getRGB()); glCleanup(); }
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); 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 #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.getCurrentItem(); if (!(item.getItem() instanceof BlockItem)) { BleachLogger.errorMessage("Must be holding a containter to peek."); return; } if (!(((BlockItem) item.getItem()).getBlock() instanceof ContainerBlock)) { BleachLogger.errorMessage("Must be holding a containter to peek."); return; } NonNullList<ItemStack> items = NonNullList.withSize(27, new ItemStack(Items.AIR)); CompoundNBT nbt = item.getTag(); if (nbt != null && nbt.contains("BlockEntityTag")) { CompoundNBT itemnbt = nbt.getCompound("BlockEntityTag"); if (itemnbt.contains("Items")) ItemStackHelper.loadAllItems(itemnbt, items); } Inventory inv = new Inventory(items.toArray(new ItemStack[27])); BleachQueue.queue.add(() -> { mc.displayGuiScreen(new ShulkerBoxScreen( new ShulkerBoxContainer(420, mc.player.inventory, inv), mc.player.inventory, item.getDisplayName())); }); }
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); 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 #10
Source File: RenderUtilsLiving.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
public static void drawItem(double x, double y, double z, double offX, double offY, double scale, ItemStack item) { glSetup(x, y, z); GL11.glScaled(0.4*scale, 0.4*scale, 0); GL11.glTranslated(offX, offY, 0); if (item.getItem() instanceof BlockItem) GL11.glRotatef(180F, 1F, 180F, 10F); mc.getItemRenderer().renderItem(new ItemStack(item.getItem()), ItemCameraTransforms.TransformType.GUI); if (item.getItem() instanceof BlockItem) GL11.glRotatef(-180F, -1F, -180F, -10F); GL11.glDisable(GL11.GL_LIGHTING); GL11.glScalef(-0.05F, -0.05F, 0); if (item.getCount() > 0) { int w = mc.fontRenderer.getStringWidth("x" + item.getCount()) / 2; mc.fontRenderer.drawStringWithShadow("x" + item.getCount(), 7 - w, 5, 0xffffff); } GL11.glScalef(0.85F, 0.85F, 0.85F); int c = 0; for (Entry<Enchantment, Integer> m: EnchantmentHelper.getEnchantments(item).entrySet()) { int w1 = mc.fontRenderer.getStringWidth(I18n.format(m.getKey().getName()).substring(0, 2) + m.getValue()) / 2; mc.fontRenderer.drawStringWithShadow( I18n.format(m.getKey().getName()).substring(0, 2) + m.getValue(), -4 - w1, c*10-1, m.getKey() == Enchantments.VANISHING_CURSE || m.getKey() == Enchantments.BINDING_CURSE ? 0xff5050 : 0xffb0e0); c--; } glCleanup(); }
Example #11
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 #12
Source File: Scaffold.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
public void onUpdate() { if (this.isToggled()) { HashMap<BlockPos, Integer> tempMap = new HashMap<>(); for (Entry<BlockPos, Integer> e: lastPlaced.entrySet()) { if (e.getValue() > 0) tempMap.put(e.getKey(), e.getValue() - 1); } lastPlaced.clear(); lastPlaced.putAll(tempMap); if (!(mc.player.inventory.getCurrentItem().getItem() instanceof BlockItem)) return; double range = getSettings().get(0).toSlider().getValue(); for (int r = 0; r < 5; r++) { Vec3d r1 = new Vec3d(0,-0.85,0); if (r == 1) r1 = r1.add(range, 0, 0); if (r == 2) r1 = r1.add(-range, 0, 0); if (r == 3) r1 = r1.add(0, 0, range); if (r == 4) r1 = r1.add(0, 0, -range); if (WorldUtils.NONSOLID_BLOCKS.contains( mc.world.getBlockState(new BlockPos(mc.player.getPositionVec().add(r1))).getBlock())) { placeBlockAuto(new BlockPos(mc.player.getPositionVec().add(r1))); return; } } } }
Example #13
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 #14
Source File: RenderUtilsLiving.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
public static void drawItem(double x, double y, double z, double offX, double offY, double scale, ItemStack item) { glSetup(x, y, z); GL11.glScaled(0.4*scale, 0.4*scale, 0); GL11.glTranslated(offX, offY, 0); if (item.getItem() instanceof BlockItem) GL11.glRotatef(180F, 1F, 180F, 10F); mc.getItemRenderer().renderItem(new ItemStack(item.getItem()), Type.GUI); if (item.getItem() instanceof BlockItem) GL11.glRotatef(-180F, -1F, -180F, -10F); GL11.glDisable(GL11.GL_LIGHTING); GL11.glScalef(-0.05F, -0.05F, 0); if (item.getCount() > 0) { int w = mc.textRenderer.getStringWidth("x" + item.getCount()) / 2; mc.textRenderer.drawWithShadow("x" + item.getCount(), 7 - w, 5, 0xffffff); } GL11.glScalef(0.85F, 0.85F, 0.85F); int c = 0; for (Entry<Enchantment, Integer> m: EnchantmentHelper.getEnchantments(item).entrySet()) { int w1 = mc.textRenderer.getStringWidth(I18n.translate(m.getKey().getName(2).asString()).substring(0, 2) + m.getValue()) / 2; mc.textRenderer.drawWithShadow( I18n.translate(m.getKey().getName(2).asString()).substring(0, 2) + m.getValue(), -4 - w1, c*10-1, m.getKey() == Enchantments.VANISHING_CURSE || m.getKey() == Enchantments.BINDING_CURSE ? 0xff5050 : 0xffb0e0); c--; } GL11.glScalef(0.6F, 0.6F, 0.6F); String dur = item.getMaxDamage() - item.getDamage() + ""; int color = 0x000000; try{ color = MathHelper.hsvToRgb(((float) (item.getMaxDamage() - item.getDamage()) / item.getMaxDamage()) / 3.0F, 1.0F, 1.0F); } catch (Exception e) {} if (item.isDamageable()) mc.textRenderer.drawWithShadow(dur, -8 - dur.length() * 3, 15, new Color(color >> 16 & 255, color >> 8 & 255, color & 255).getRGB()); glCleanup(); }
Example #15
Source File: RenderUtilsLiving.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
public static void drawItem(double x, double y, double z, double offX, double offY, double scale, ItemStack item) { glSetup(x, y, z); GL11.glScaled(0.4*scale, 0.4*scale, 0); GL11.glTranslated(offX, offY, 0); if (item.getItem() instanceof BlockItem) GL11.glRotatef(180F, 1F, 180F, 10F); mc.getItemRenderer().renderItem(new ItemStack( item.getItem()), Mode.GUI, 0, 0, new MatrixStack(), mc.getBufferBuilders().getEntityVertexConsumers()); if (item.getItem() instanceof BlockItem) GL11.glRotatef(-180F, -1F, -180F, -10F); GL11.glDisable(GL11.GL_LIGHTING); GL11.glScalef(-0.05F, -0.05F, 0); if (item.getCount() > 0) { int w = mc.textRenderer.getStringWidth("x" + item.getCount()) / 2; mc.textRenderer.drawWithShadow("x" + item.getCount(), 7 - w, 5, 0xffffff); } GL11.glScalef(0.85F, 0.85F, 0.85F); int c = 0; for (Entry<Enchantment, Integer> m: EnchantmentHelper.getEnchantments(item).entrySet()) { int w1 = mc.textRenderer.getStringWidth(I18n.translate(m.getKey().getName(2).asString()).substring(0, 2) + m.getValue()) / 2; mc.textRenderer.drawWithShadow( I18n.translate(m.getKey().getName(2).asString()).substring(0, 2) + m.getValue(), -4 - w1, c*10-1, m.getKey() == Enchantments.VANISHING_CURSE || m.getKey() == Enchantments.BINDING_CURSE ? 0xff5050 : 0xffb0e0); c--; } GL11.glScalef(0.6F, 0.6F, 0.6F); String dur = item.getMaxDamage() - item.getDamage() + ""; int color = 0x000000; try{ color = MathHelper.hsvToRgb(((float) (item.getMaxDamage() - item.getDamage()) / item.getMaxDamage()) / 3.0F, 1.0F, 1.0F); } catch (Exception e) {} if (item.isDamageable()) mc.textRenderer.drawWithShadow(dur, -8 - dur.length() * 3, 15, new Color(color >> 16 & 255, color >> 8 & 255, color & 255).getRGB()); glCleanup(); }
Example #16
Source File: LibGuiTest.java From LibGui with MIT License | 5 votes |
@Override public void onInitialize() { Registry.register(Registry.ITEM, new Identifier(MODID, "client_gui"), new GuiItem()); GUI_BLOCK = new GuiBlock(); Registry.register(Registry.BLOCK, new Identifier(MODID, "gui"), GUI_BLOCK); GUI_BLOCK_ITEM = new BlockItem(GUI_BLOCK, new Item.Settings().group(ItemGroup.MISC)); Registry.register(Registry.ITEM, new Identifier(MODID, "gui"), GUI_BLOCK_ITEM); GUI_BLOCKENTITY_TYPE = BlockEntityType.Builder.create(GuiBlockEntity::new, GUI_BLOCK).build(null); Registry.register(Registry.BLOCK_ENTITY_TYPE, new Identifier(MODID, "gui"), GUI_BLOCKENTITY_TYPE); GUI_SCREEN_HANDLER_TYPE = ScreenHandlerRegistry.registerSimple(new Identifier(MODID, "gui"), (int syncId, PlayerInventory inventory) -> { return new TestDescription(GUI_SCREEN_HANDLER_TYPE, syncId, inventory, ScreenHandlerContext.EMPTY); }); Optional<ModContainer> containerOpt = FabricLoader.getInstance().getModContainer("jankson"); if (containerOpt.isPresent()) { ModContainer jankson = containerOpt.get(); System.out.println("Jankson root path: "+jankson.getRootPath()); try { Files.list(jankson.getRootPath()).forEach((path)->{ path.getFileSystem().getFileStores().forEach((store)->{ System.out.println(" Filestore: "+store.name()); }); System.out.println(" "+path.toAbsolutePath()); }); } catch (IOException e) { e.printStackTrace(); } Path modJson = jankson.getPath("/fabric.mod.json"); System.out.println("Jankson fabric.mod.json path: "+modJson); System.out.println(Files.exists(modJson) ? "Exists" : "Does Not Exist"); } else { System.out.println("Container isn't present!"); } }
Example #17
Source File: MixinSimpleRegistry.java From Sandbox with GNU Lesser General Public License v3.0 | 5 votes |
@Inject(method = "set", at = @At(value = "HEAD"), cancellable = true) public <V extends T> void set(int i, Identifier identifier, V object, CallbackInfoReturnable<V> ci) { if (hasStored) { identifiers.add(identifier); if (object instanceof BlockItem) { ((BlockItem) object).appendBlocks(Item.BLOCK_ITEMS, (BlockItem) object); } if (object instanceof Block) { ((Block) object).getStateManager().getStates().forEach(Block.STATE_IDS::add); //TODO: Also need to reset the state ids } } }
Example #18
Source File: BlockRotator.java From fabric-carpet with MIT License | 5 votes |
public static boolean flippinEligibility(Entity entity) { if (CarpetSettings.flippinCactus && (entity instanceof PlayerEntity)) { PlayerEntity player = (PlayerEntity)entity; return (!player.getOffHandStack().isEmpty() && player.getOffHandStack().getItem() instanceof BlockItem && ((BlockItem) (player.getOffHandStack().getItem())).getBlock() == Blocks.CACTUS); } return false; }
Example #19
Source File: CarpetDispenserBehaviours.java From carpet-extra with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected ItemStack dispenseSilently(BlockPointer source, ItemStack stack) { BlockPos pos = source.getBlockPos().offset((Direction) source.getBlockState().get(DispenserBlock.FACING)); List<AnimalEntity> list = source.getWorld().getEntities(AnimalEntity.class, new Box(pos),null); boolean failure = false; for(AnimalEntity mob : list) { if(!mob.isBreedingItem(stack)) continue; if(mob.getBreedingAge() != 0 || mob.isInLove()) { failure = true; continue; } stack.decrement(1); mob.lovePlayer(null); return stack; } if(failure) return stack; // fix here for now - if problem shows up next time, will need to fix it one level above. if( CarpetExtraSettings.dispenserPlacesBlocks && stack.getItem() instanceof BlockItem && PlaceBlockDispenserBehavior.canPlace(((BlockItem) stack.getItem()).getBlock()) ) { return PlaceBlockDispenserBehavior.getInstance().dispenseSilently(source, stack); } else { return super.dispenseSilently(source, stack); } }
Example #20
Source File: Protocol_1_11_2.java From multiconnect with MIT License | 5 votes |
@Override public List<RecipeInfo<?>> getCraftingRecipes() { List<RecipeInfo<?>> recipes = super.getCraftingRecipes(); recipes.removeIf(recipe -> { if (recipe.getOutput().getItem() instanceof BlockItem && ((BlockItem) recipe.getOutput().getItem()).getBlock() instanceof ConcretePowderBlock) { return true; } return false; }); return recipes; }
Example #21
Source File: Protocol_1_10.java From multiconnect with MIT License | 5 votes |
@Override public List<RecipeInfo<?>> getCraftingRecipes() { List<RecipeInfo<?>> recipes = super.getCraftingRecipes(); recipes.removeIf(recipe -> recipe.getOutput().getItem() instanceof BlockItem && ((BlockItem) recipe.getOutput().getItem()).getBlock() instanceof ShulkerBoxBlock); recipes.removeIf(recipe -> recipe.getOutput().getItem() == Items.OBSERVER); return recipes; }
Example #22
Source File: ItemEntityMixin.java From fabric-carpet with MIT License | 5 votes |
@Inject(method="<init>(Lnet/minecraft/world/World;DDDLnet/minecraft/item/ItemStack;)V", at = @At("RETURN")) private void removeEmptyShulkerBoxTags(World worldIn, double x, double y, double z, ItemStack stack, CallbackInfo ci) { if (CarpetSettings.stackableShulkerBoxes && stack.getItem() instanceof BlockItem && ((BlockItem)stack.getItem()).getBlock() instanceof ShulkerBoxBlock) { if (InventoryHelper.cleanUpShulkerBoxTag(stack)) { ((ItemEntity) (Object) this).setStack(stack); } } }
Example #23
Source File: BuildRandomHack.java From Wurst7 with GNU General Public License v3.0 | 5 votes |
private boolean checkHeldItem() { if(!checkItem.isChecked()) return true; ItemStack stack = MC.player.inventory.getMainHandStack(); return !stack.isEmpty() && stack.getItem() instanceof BlockItem; }
Example #24
Source File: TunnellerHack.java From Wurst7 with GNU General Public License v3.0 | 5 votes |
private boolean equipSolidBlock(BlockPos pos) { for(int slot = 0; slot < 9; slot++) { // filter out non-block items ItemStack stack = MC.player.inventory.getStack(slot); if(stack.isEmpty() || !(stack.getItem() instanceof BlockItem)) continue; Block block = Block.getBlockFromItem(stack.getItem()); // filter out non-solid blocks BlockState state = block.getDefaultState(); if(!state.isFullCube(EmptyBlockView.INSTANCE, BlockPos.ORIGIN)) continue; // filter out blocks that would fall if(block instanceof FallingBlock && FallingBlock .canFallThrough(BlockUtils.getState(pos.down()))) continue; MC.player.inventory.selectedSlot = slot; return true; } return false; }
Example #25
Source File: ItemEntityMixin.java From fabric-carpet with MIT License | 5 votes |
@Redirect( method = "canMerge", at = @At( value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;getMaxCount()I" ) ) private int getItemStackMaxAmount(ItemStack stack) { if (CarpetSettings.stackableShulkerBoxes && stack.getItem() instanceof BlockItem && ((BlockItem)stack.getItem()).getBlock() instanceof ShulkerBoxBlock) return SHULKERBOX_MAX_STACK_AMOUNT; return stack.getMaxCount(); }
Example #26
Source File: HallowedBlocks.java From the-hallow with MIT License | 5 votes |
static <T extends Block> T register(String name, T block, BlockItem item) { T b = Registry.register(Registry.BLOCK, TheHallow.id(name), block); if (item != null) { HallowedItems.register(name, item); } return b; }
Example #27
Source File: ItemEntityMixin.java From fabric-carpet with MIT License | 5 votes |
@Inject( method = "tryMerge(Lnet/minecraft/entity/ItemEntity;)V", at = @At("HEAD"), cancellable = true ) private void tryStackShulkerBoxes(ItemEntity other, CallbackInfo ci) { ItemEntity self = (ItemEntity)(Object)this; ItemStack selfStack = self.getStack(); if (!CarpetSettings.stackableShulkerBoxes || !(selfStack.getItem() instanceof BlockItem) || !(((BlockItem)selfStack.getItem()).getBlock() instanceof ShulkerBoxBlock)) { return; } ItemStack otherStack = other.getStack(); if (selfStack.getItem() == otherStack.getItem() && !InventoryHelper.shulkerBoxHasItems(selfStack) && !InventoryHelper.shulkerBoxHasItems(otherStack) && selfStack.hasTag() == otherStack.hasTag() && selfStack.getCount() + otherStack.getCount() <= SHULKERBOX_MAX_STACK_AMOUNT) { int amount = Math.min(otherStack.getCount(), SHULKERBOX_MAX_STACK_AMOUNT - selfStack.getCount()); selfStack.increment(amount); self.setStack(selfStack); this.pickupDelay = Math.max(((ItemEntityInterface)other).getPickupDelayCM(), this.pickupDelay); this.age = Math.min(((ItemEntityInterface)other).getAgeCM(), this.age); otherStack.decrement(amount); if (otherStack.isEmpty()) { other.remove(); } else { other.setStack(otherStack); } ci.cancel(); } }
Example #28
Source File: SkullFeature.java From MineLittlePony with MIT License | 5 votes |
@Override public void render(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, T entity, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) { ItemStack itemstack = entity.getEquippedStack(EquipmentSlot.HEAD); if (!itemstack.isEmpty()) { M model = getContext().getModelWrapper().getBody(); Item item = itemstack.getItem(); stack.push(); model.transform(BodyPart.HEAD, stack); model.getHead().rotate(stack); if (model instanceof AbstractPonyModel) { stack.translate(0, 0.225F, 0); } else { stack.translate(0, 0, 0.15F); } if (item instanceof BlockItem && ((BlockItem) item).getBlock() instanceof AbstractSkullBlock) { boolean isVillager = entity instanceof VillagerDataContainer; renderSkull(stack, renderContext, itemstack, isVillager, limbDistance, lightUv); } else if (!(item instanceof ArmorItem) || ((ArmorItem)item).getSlotType() != EquipmentSlot.HEAD) { renderBlock(stack, renderContext, entity, itemstack, lightUv); } stack.pop(); } }
Example #29
Source File: TorchFireEventHandling.java From Survivalist with BSD 3-Clause "New" or "Revised" License | 5 votes |
@SubscribeEvent public void onAttackEntity(AttackEntityEvent ev) { if (!ConfigManager.SERVER.enableTorchFire.get()) return; if (!ev.getTarget().func_230279_az_() && !ev.getTarget().world.isRemote) { PlayerEntity player = ev.getPlayer(); ItemStack stack = player.getHeldItem(Hand.MAIN_HAND); if (stack.getCount() > 0 && stack.getItem() instanceof BlockItem) { BlockItem b = (BlockItem) stack.getItem(); Block bl = b.getBlock(); if (bl == Blocks.TORCH) { ev.getTarget().setFire(2); if (!ev.getPlayer().isCreative() && rnd.nextFloat() > 0.25) { stack.grow(-1); if (stack.getCount() <= 0) { player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemStack.EMPTY); } } } } } }
Example #30
Source File: RegSitter.java From Survivalist with BSD 3-Clause "New" or "Revised" License | 4 votes |
public MiniBlock<T> withItem(Item.Properties properties) { return withItem((block) -> new BlockItem(block.get(), properties)); }