ssbbpeople
Members-
Posts
14 -
Joined
-
Last visited
Everything posted by ssbbpeople
-
I understand that. I'm sort of in a time crunch, so I figured going for tutorials would be the fastest way, for now. In the future/now I'll study more on java
-
I'm starting to learn Java, I made the mistake of going to modding tutorials first
-
Oh okay. So I rearranged it like this: if (this.canSmeltItem()) { if (this.smeltTime >= this.maxSmeltTime) { return; } The bug occurs, but its under the if statement canSmeltItem
-
Okay, I inserted the code: private void trySmeltItem(){ if (this.smeltTime >= this.maxSmeltTime) { return; } ... And the bug still remains :-/
-
How can I check that in the trySmeltItem if there's no boolean? I thought I already checked that with boolean isItemValid method
-
Yes, sorry I forgot to link my GitHub. Here's the link: https://github.com/SpookyBarca/Metallurgy All my Grinder files are in the same package.
-
Thank you! I got the onBlockActivated method functioning correctly. Now I just have two smelting bugs... it instantly smelts items, even when there's no fuel
-
Hi, I've recently finished the classes for my BlockGrinder, but onBlockActivated seems to not be firing when I right-click the block. When I right-click it, absolutely nothing happens. Here's the code: //When right-clicked @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if(worldIn.isRemote) { return true; } final TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileGrinder) { playerIn.openGui(Main.instance, ModGuiHandler.MOD_GRINDER, worldIn, pos.getX(), pos.getY(), pos.getZ()); playerIn.addStat(StatList.FURNACE_INTERACTION); } return true; } I used the BlockFurnace class as reference for this method, but it doesn't open the GUI nor make the player right-click animation for the block
-
Hi, I've recently been working on my mod for Minecraft, I was able to run the Client on Eclipse up until recently when I keep getting this crash: xception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl64 in java.library.path at java.lang.ClassLoader.loadLibrary(Unknown Source) at java.lang.Runtime.loadLibrary0(Unknown Source) at java.lang.System.loadLibrary(Unknown Source) at org.lwjgl.Sys$1.run(Sys.java:72) at java.security.AccessController.doPrivileged(Native Method) at org.lwjgl.Sys.doLoadLibrary(Sys.java:66) at org.lwjgl.Sys.loadLibrary(Sys.java:87) at org.lwjgl.Sys.<clinit>(Sys.java:117) at net.minecraft.client.Minecraft.getSystemTime(Minecraft.java:3159) at net.minecraft.client.main.Main.main(Main.java:42) Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release I've tried to designate the native build location to my lwjgl-2.9.4-nightly.jar and similar jars for my native library location in the JRE System Library, but no solutions were made. Any help is appreciated, thank you!
-
Hi, My Minecraft client keeps crashing every time I try to open up my Grinder block. I assume it's a Container GUI bug, but I don't know why the NPE is throwing Ticking Player . Here's the crash log: ---- Minecraft Crash Report ---- // Why did you do that? Time: 7/22/19 4:57 AM Description: Ticking player java.lang.NullPointerException: Ticking player at net.minecraft.inventory.Slot.getStack(Slot.java:81) at net.minecraft.inventory.Container.detectAndSendChanges(Container.java:97) at com.ssbbpeople.metallurgy.blocks.grinder.ContainerGrinder.detectAndSendChanges(ContainerGrinder.java:65) at net.minecraft.entity.player.EntityPlayerMP.onUpdate(EntityPlayerMP.java:365) at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2171) at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:871) at net.minecraft.world.World.updateEntity(World.java:2130) at net.minecraft.world.WorldServer.tickPlayers(WorldServer.java:672) at net.minecraft.world.World.updateEntities(World.java:1906) at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:643) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:842) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:743) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:592) at java.lang.Thread.run(Unknown Source) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Server thread Stacktrace: at net.minecraft.inventory.Slot.getStack(Slot.java:81) at net.minecraft.inventory.Container.detectAndSendChanges(Container.java:97) at com.ssbbpeople.metallurgy.blocks.grinder.ContainerGrinder.detectAndSendChanges(ContainerGrinder.java:65) at net.minecraft.entity.player.EntityPlayerMP.onUpdate(EntityPlayerMP.java:365) at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2171) at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:871) at net.minecraft.world.World.updateEntity(World.java:2130) -- Player being ticked -- Details: Entity Type: null (net.minecraft.entity.player.EntityPlayerMP) Entity ID: 0 Entity Name: Player127 Entity's Exact location: -1486.50, 4.00, 122.50 Entity's Block location: World: (-1487,4,122), Chunk: (at 1,0,10 in -93,7; contains blocks -1488,0,112 to -1473,255,127), Region: (-3,0; contains chunks -96,0 to -65,31, blocks -1536,0,0 to -1025,255,511) Entity's Momentum: 0.00, -0.08, 0.00 Entity's Passengers: [] Entity's Vehicle: ~~ERROR~~ NullPointerException: null Stacktrace: at net.minecraft.world.WorldServer.tickPlayers(WorldServer.java:672) at net.minecraft.world.World.updateEntities(World.java:1906) at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:643) -- Affected level -- Details: Level name: Test World - 7B All players: 1 total; [EntityPlayerMP['Player127'/0, l='Test World - 7B', x=-1486.50, y=4.00, z=122.50]] Chunk stats: ServerChunkCache: 625 Drop: 0 Level seed: -1413871684550780093 Level generator: ID 01 - flat, ver 0. Features enabled: true Level generator options: Level spawn location: World: (-1487,4,118), Chunk: (at 1,0,6 in -93,7; contains blocks -1488,0,112 to -1473,255,127), Region: (-3,0; contains chunks -96,0 to -65,31, blocks -1536,0,0 to -1025,255,511) Level time: 219 game time, 219 day time Level dimension: 0 Level storage version: 0x04ABD - Anvil Level weather: Rain time: 112927 (now: false), thunder time: 171545 (now: false) Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true Stacktrace: at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:842) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:743) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:592) at java.lang.Thread.run(Unknown Source) -- System Details -- Details: Minecraft Version: 1.12.2 Operating System: Windows 7 (amd64) version 6.1 Java Version: 1.8.0_221, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 844942440 bytes (805 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP 9.42 Powered by Forge 14.23.5.2838 5 mods loaded, 5 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored | State | ID | Version | Source | Signature | |:------ |:--------- |:------------ |:-------------------------------- |:--------- | | LCHIJA | minecraft | 1.12.2 | minecraft.jar | None | | LCHIJA | mcp | 9.42 | minecraft.jar | None | | LCHIJA | FML | 8.0.99.99 | forgeSrc-1.12.2-14.23.5.2838.jar | None | | LCHIJA | forge | 14.23.5.2838 | forgeSrc-1.12.2-14.23.5.2838.jar | None | | LCHIJA | mm | 1.0 | bin | None | Loaded coremods (and transformers): GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread. Profiler Position: N/A (disabled) Player Count: 1 / 8; [EntityPlayerMP['Player127'/0, l='Test World - 7B', x=-1486.50, y=4.00, z=122.50]] Type: Integrated Server (map_client.txt) Is Modded: Definitely; Client brand changed to 'fml,forge' Here's my ContainerGrinder class: package com.ssbbpeople.metallurgy.blocks.grinder; import com.ssbbpeople.metallurgy.blocks.grinder.slots.SlotGrinderFuel; import com.ssbbpeople.metallurgy.blocks.grinder.slots.SlotGrinderOutput; import com.ssbbpeople.metallurgy.blocks.tileentities.TileEntityGrinder; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.inventory.*; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.SlotItemHandler; public class ContainerGrinder extends Container { private IInventory TileEntityGrinder; GrinderTileEntity tileentity; private IItemHandler InvHandler; private final IInventory tileFurnace; private int cookTime, totalCookTime, ovenBurnTime, currentItemBurnTime; public ContainerGrinder(InventoryPlayer playerInventory, IInventory furnaceInventory, GrinderTileEntity containerTileEntity) { this.tileentity = containerTileEntity; this.tileFurnace = furnaceInventory; this.addSlotToContainer(new Slot(furnaceInventory, 0, 56, 17)); this.addSlotToContainer(new SlotGrinderFuel(furnaceInventory, 1, 56, 53)); this.addSlotToContainer(new SlotGrinderOutput(playerInventory.player, furnaceInventory, 2, 116, 35)); for(int i = 0; i < 3; i++) { for(int j = 0; j < 9; ++j) { this.addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } } for(int k = 0; k < 9; k++) { this.addSlotToContainer(new Slot(playerInventory, k, 8 + k * 18, 142)); } } public ContainerGrinder(IInventory playerInventory, IInventory furnaceInventory, GrinderTileEntity containerTileEntity) { this.tileentity = containerTileEntity; this.tileFurnace = furnaceInventory; this.InvHandler = ((ICapabilityProvider) tileentity).getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); } @Override public void addListener(IContainerListener listener) { super.addListener(listener); listener.sendAllWindowProperties(this, this.TileEntityGrinder); } @Override public void detectAndSendChanges() { super.detectAndSendChanges(); for (int i = 0; i < this.listeners.size(); ++i) { IContainerListener icontainerlistener = this.listeners.get(i); if (this.cookTime != this.TileEntityGrinder.getField(2)) { icontainerlistener.sendWindowProperty(this, 2, this.TileEntityGrinder.getField(2)); } if (this.ovenBurnTime != this.TileEntityGrinder.getField(0)) { icontainerlistener.sendWindowProperty(this, 0, this.TileEntityGrinder.getField(0)); } if (this.currentItemBurnTime != this.TileEntityGrinder.getField(1)) { icontainerlistener.sendWindowProperty(this, 1, this.TileEntityGrinder.getField(1)); } if (this.totalCookTime != this.TileEntityGrinder.getField(3)) { icontainerlistener.sendWindowProperty(this, 3, this.TileEntityGrinder.getField(3)); } } this.cookTime = this.TileEntityGrinder.getField(2); this.ovenBurnTime = this.TileEntityGrinder.getField(0); this.currentItemBurnTime = this.TileEntityGrinder.getField(1); this.totalCookTime = this.TileEntityGrinder.getField(3); } @Override public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) { ItemStack itemstack = ItemStack.EMPTY; Slot slot = this.inventorySlots.get(index); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); if (index == 2) { if (!this.mergeItemStack(itemstack1, 3, 39, true)) { return ItemStack.EMPTY; } slot.onSlotChange(itemstack1, itemstack); } else if (index != 1 && index != 0) { if (!GrinderRecipes.instance().getCookingResult(itemstack1).isEmpty()) { if (!this.mergeItemStack(itemstack1, 0, 1, false)) { return ItemStack.EMPTY; } } else if (ContainerGrinder.isItemFuel(itemstack1)) { if (!this.mergeItemStack(itemstack1, 1, 2, false)) { return ItemStack.EMPTY; } } else if (index >= 3 && index < 30) { if (!this.mergeItemStack(itemstack1, 30, 39, false)) { return ItemStack.EMPTY; } } else if (index >= 30 && index < 39 && !this.mergeItemStack(itemstack1, 3, 30, false)) { return ItemStack.EMPTY; } } else if (!this.mergeItemStack(itemstack1, 3, 39, false)) { return ItemStack.EMPTY; } if (itemstack1.isEmpty()) { slot.putStack(ItemStack.EMPTY); } else { slot.onSlotChanged(); } if (itemstack1.getCount() == itemstack.getCount()) { return ItemStack.EMPTY; } slot.onTake(playerIn, itemstack1); } return itemstack; } public static int getItemBurnTime(ItemStack stack) { if (stack.isEmpty()) { return 0; } else { int burnTime = net.minecraftforge.event.ForgeEventFactory.getItemBurnTime(stack); if (burnTime >= 0) return burnTime; Item item = stack.getItem(); if (item == Items.REDSTONE) { return 300; } else if (item ==Item.getItemFromBlock(Blocks.REDSTONE_BLOCK)) { return 4000; } } return 300; } public static boolean isItemFuel(ItemStack stack) { return getItemBurnTime(stack) > 0; } public ContainerGrinder(InventoryPlayer playerInventory, IInventory furnaceInventory) { this.TileEntityGrinder = furnaceInventory; this.tileFurnace = furnaceInventory; this.addSlotToContainer(new Slot(furnaceInventory, 0, 56, 17)); this.addSlotToContainer(new SlotGrinderFuel(furnaceInventory, 1, 56, 53)); this.addSlotToContainer(new SlotGrinderOutput(playerInventory.player, furnaceInventory, 2, 116, 35)); for(int i = 0; i < 3; i++) { for(int j = 0; j < 9; ++j) { this.addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } } for(int k = 0; k < 9; k++) { this.addSlotToContainer(new Slot(playerInventory, k, 8 + k * 18, 142)); } } //Tile Entities @Override public void updateProgressBar(int id, int data) { this.TileEntityGrinder.setField(id, data); } @Override public boolean canInteractWith(EntityPlayer playerIn) { return this.TileEntityGrinder.isUsableByPlayer(playerIn); } } And my TileEntityGrinder class: package com.ssbbpeople.metallurgy.blocks.tileentities; import javax.annotation.Nullable; import com.ssbbpeople.metallurgy.blocks.grinder.ContainerGrinder; import com.ssbbpeople.metallurgy.blocks.grinder.Grinder; import com.ssbbpeople.metallurgy.blocks.grinder.GrinderRecipes; import com.ssbbpeople.metallurgy.blocks.grinder.slots.SlotGrinderFuel; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.inventory.ItemStackHelper; import net.minecraft.item.Item; import net.minecraft.item.ItemBoat; import net.minecraft.item.ItemDoor; import net.minecraft.item.ItemHoe; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; import net.minecraft.item.ItemTool; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityLockable; import net.minecraft.util.EnumFacing; import net.minecraft.util.ITickable; import net.minecraft.util.NonNullList; import net.minecraft.util.datafix.DataFixer; import net.minecraft.util.datafix.FixTypes; import net.minecraft.util.datafix.walkers.ItemStackDataLists; import net.minecraft.util.math.MathHelper; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.ItemStackHandler; public class TileEntityGrinder extends TileEntity implements IInventory, ISidedInventory { private static final int[] SLOTS_TOP = new int[] {0}; private static final int[] SLOTS_BOTTOM = new int[] {2, 1}; private static final int[] SLOTS_SIDES = new int[] {1}; private NonNullList<ItemStack> furnaceItemStacks = NonNullList.<ItemStack>withSize(3, ItemStack.EMPTY); private int furnaceBurnTime; private int currentItemBurnTime; private static int cookTime; private int totalCookTime; private String furnaceCustomName; @Override public int getSizeInventory() { return this.furnaceItemStacks.size(); } @Override public boolean isEmpty() { for(ItemStack stack : this.furnaceItemStacks) { if(!stack.isEmpty()) { return false; } } return true; } @Override public ItemStack getStackInSlot(int index) { return this.furnaceItemStacks.get(index); } @Override public ItemStack decrStackSize(int index, int count) { return ItemStackHelper.getAndSplit(furnaceItemStacks, index, count); } @Override public ItemStack removeStackFromSlot(int index) { return ItemStackHelper.getAndRemove(furnaceItemStacks, index); } @Override public void setInventorySlotContents(int index, ItemStack stack) { ItemStack itemStack = this.furnaceItemStacks.get(index); boolean flag = !stack.isEmpty() && stack.isItemEqual(itemStack) && ItemStack.areItemStackShareTagsEqual(stack, itemStack); this.furnaceItemStacks.set(index, stack); if(stack.getCount() > this.getInventoryStackLimit()) { stack.setCount(this.getInventoryStackLimit()); } if(index == 0 && !flag) { this.totalCookTime = this.getCookTime(stack); this.cookTime = 0; this.markDirty(); } } @Override public String getName() { return this.hasCustomName() ? this.furnaceCustomName : "container.grinder"; } @Override public boolean hasCustomName() { return this.furnaceCustomName != null && !this.furnaceCustomName.isEmpty(); } public void setCustomInventoryName(String furnaceCustomName) { this.furnaceCustomName = furnaceCustomName; } public static void registerFixesFurnace(DataFixer fixer) { fixer.registerWalker(FixTypes.BLOCK_ENTITY, new ItemStackDataLists(TileEntityGrinder.class, new String[] {"Items"})); } @Override public int getInventoryStackLimit() { return 64; } public boolean isBurning() { return this.furnaceBurnTime > 0; } @SideOnly(Side.CLIENT) public static boolean isBurning(IInventory inventory) { return inventory.getField(0) > 0; } public void update() { boolean flag = this.isBurning(); boolean flag1 = false; if (this.isBurning()) { --this.furnaceBurnTime; } if (!this.world.isRemote) { ItemStack itemstack = this.furnaceItemStacks.get(1); if (this.isBurning() || !itemstack.isEmpty() && !((ItemStack)this.furnaceItemStacks.get(0)).isEmpty()) { if (!this.isBurning() && this.canSmelt()) { this.furnaceBurnTime = getItemBurnTime(itemstack); this.currentItemBurnTime = this.furnaceBurnTime; if (this.isBurning()) { flag1 = true; if (!itemstack.isEmpty()) { Item item = itemstack.getItem(); itemstack.shrink(1); if (itemstack.isEmpty()) { ItemStack item1 = item.getContainerItem(itemstack); this.furnaceItemStacks.set(1, item1); } } } } if (this.isBurning() && this.canSmelt()) { ++this.cookTime; if (this.cookTime == this.totalCookTime) { this.cookTime = 0; this.totalCookTime = this.getCookTime(this.furnaceItemStacks.get(0)); this.smeltItem(); flag1 = true; } } else { this.cookTime = 0; } } else if (!this.isBurning() && this.cookTime > 0) { this.cookTime = MathHelper.clamp(this.cookTime - 2, 0, this.totalCookTime); } } if (flag1) { this.markDirty(); } } public int getCookTime(ItemStack stack) { return 10; } private boolean canSmelt() { if (((ItemStack)this.furnaceItemStacks.get(0)).isEmpty()) { return false; } else { ItemStack itemstack = GrinderRecipes.instance().getCookingResult(this.furnaceItemStacks.get(0)); if (itemstack.isEmpty()) { return false; } else { ItemStack itemstack1 = this.furnaceItemStacks.get(2); if (itemstack1.isEmpty()) { return true; } else if (!itemstack1.isItemEqual(itemstack)) { return false; } else if (itemstack1.getCount() + itemstack.getCount() <= this.getInventoryStackLimit() && itemstack1.getCount() + itemstack.getCount() <= itemstack1.getMaxStackSize()) { return true; } else { return itemstack1.getCount() + itemstack.getCount() <= itemstack.getMaxStackSize(); } } } } public void smeltItem() { if (this.canSmelt()) { ItemStack itemstack = this.furnaceItemStacks.get(0); ItemStack itemstack1 = GrinderRecipes.instance().getCookingResult(itemstack); ItemStack itemstack2 = this.furnaceItemStacks.get(2); if (itemstack2.isEmpty()) { this.furnaceItemStacks.set(2, itemstack1.copy()); } else if (itemstack2.getItem() == itemstack1.getItem()) { itemstack2.grow(itemstack1.getCount()); } if (itemstack.getItem() == Item.getItemFromBlock(Blocks.SPONGE) && itemstack.getMetadata() == 1 && !((ItemStack)this.furnaceItemStacks.get(1)).isEmpty() && ((ItemStack)this.furnaceItemStacks.get(1)).getItem() == Items.BUCKET) { this.furnaceItemStacks.set(1, new ItemStack(Items.WATER_BUCKET)); } itemstack.shrink(1); } } public static int getItemBurnTime(ItemStack stack) { if (stack.isEmpty()) { return 0; } else { int burnTime = net.minecraftforge.event.ForgeEventFactory.getItemBurnTime(stack); if (burnTime >= 0) return burnTime; Item item = stack.getItem(); if (item == Item.getItemFromBlock(Blocks.WOODEN_SLAB)) { return 150; } else if (item == Item.getItemFromBlock(Blocks.WOOL)) { return 100; } } return cookTime; } public static boolean isItemFuel(ItemStack stack) { return getItemBurnTime(stack) > 0; } @Override public boolean isUsableByPlayer(EntityPlayer player) { if(this.world.getTileEntity(this.pos) != this) { return false; } else { return player.getDistanceSq((double)this.pos.getX() + 0.5D, (double)this.pos.getY() + 0.5D, (double)this.pos.getZ() + 0.5D) <= 64.0D; } } public void openInventory(EntityPlayer player) { } public void closeInventory(EntityPlayer player) { } @Override public boolean isItemValidForSlot(int index, ItemStack stack) { if(index == 2) { return false; } else if(index != 1) { return true; } else { ItemStack itemStack = this.furnaceItemStacks.get(1); return isItemFuel(stack) || SlotGrinderFuel.isBucket(stack) && itemStack.getItem() != Items.BUCKET; } } public int[] getSlotsForFace(EnumFacing side) { if(side == EnumFacing.DOWN) { return SLOTS_BOTTOM; } else { return side == EnumFacing.UP ? SLOTS_TOP : SLOTS_SIDES; } } public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) { return this.isItemValidForSlot(index, itemStackIn); } public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) { if(direction == EnumFacing.DOWN && index == 1) { Item item = stack.getItem(); if(item != Items.WATER_BUCKET && item != Items.BUCKET) { return false; } } return true; } public String getGuiID() { return "mm:grinder"; } public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn) { return new ContainerGrinder(playerInventory, this); } public int getField(int id) { switch (id) { case 0: return this.furnaceBurnTime; case 1: return this.currentItemBurnTime; case 2: return this.cookTime; case 3: return this.totalCookTime; default: return 0; } } public void setField(int id, int value) { switch (id) { case 0: this.furnaceBurnTime = value; break; case 1: this.currentItemBurnTime = value; break; case 2: this.cookTime = value; break; case 3: this.totalCookTime = value; } } @Override public int getFieldCount() { return 4; } @Override public void clear() { this.furnaceItemStacks.clear(); } net.minecraftforge.items.IItemHandler handlerTop = new net.minecraftforge.items.wrapper.SidedInvWrapper(this, net.minecraft.util.EnumFacing.UP); net.minecraftforge.items.IItemHandler handlerBottom = new net.minecraftforge.items.wrapper.SidedInvWrapper(this, net.minecraft.util.EnumFacing.DOWN); net.minecraftforge.items.IItemHandler handlerSide = new net.minecraftforge.items.wrapper.SidedInvWrapper(this, net.minecraft.util.EnumFacing.WEST); @Override @javax.annotation.Nullable public <T> T getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, @javax.annotation.Nullable net.minecraft.util.EnumFacing facing) { if (facing != null && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) if (facing == EnumFacing.DOWN) return (T) handlerBottom; else if (facing == EnumFacing.UP) return (T) handlerTop; else return (T) handlerSide; return super.getCapability(capability, facing); } //NBT Tags private ItemStackHandler inventory = new ItemStackHandler(1); @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { compound.setTag("inventory", inventory.serializeNBT()); return super.writeToNBT(compound); } @Override public void readFromNBT(NBTTagCompound compound) { inventory.deserializeNBT(compound.getCompoundTag("inventory")); super.readFromNBT(compound); } } Here's my GitHub: https://github.com/SpookyBarca/Metallurgy Any help is appreciated, thank you!
-
Hi, I have a block that has a Custom Gui, but every time I right-click the block it won't appear. I know that the TileEntities are working because I wrote a debug line that "checks" if it's working. This is the error that's shown in the console when I right-click: [06:37:34] [Server thread/FATAL] [minecraft/MinecraftServer]: Error executing task java.util.concurrent.ExecutionException: java.lang.NullPointerException This is the onBlockActivated boolean in my Block: //BLOCK RIGHT-CLICKED (Opens GUI and Debug) @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if (!world.isRemote) { //Sends a message in chat stating "Grinder Clicked" player.sendMessage(new TextComponentString("Grinder Clicked")); //Opens GUI player.openGui(Main.instance, ModGuiHandler.GRINDER, world, pos.getX(), pos.getY(), pos.getZ()); } return true; } I've also tried putting player.openGui outside of the if function, but that results in a crash. The ModGuiHandler is registered correctly as well, for NetworkRegistry.INSTANCE. Additional Info: I followed ShadowFacts tutorial for onBlockActivated Any help is appreciated, thank you.
-
[1.12.2] Deprecated registerTileEntity Problem
ssbbpeople replied to ssbbpeople's topic in Modder Support
Fixed! I'm getting no deprecated error. However, I'm still getting the "TileEntityGrinder is missing a mapping!" bug. I'm unsure how to create a mapping for the registry and TileEntity... -
[1.12.2] Deprecated registerTileEntity Problem
ssbbpeople replied to ssbbpeople's topic in Modder Support
None of them show how to register a TileEntity for displaying GUI -
Hello! So I'm trying to register my TileEntity for my Block Class in order to get the custom GUI showing. I tried using the registerTileEntity, with the name and ResourceLocation, but it's deprecated. I'm unsure how to work around this issue to help register my TileEntity... My GitHub: https://github.com/SpookyBarca/MetallurgyMod Thank you!