Jump to content

Zodsmar

Members
  • Posts

    52
  • Joined

  • Last visited

Everything posted by Zodsmar

  1. Is there any github repos which are using this new functionality which I could look at to understand better?
  2. Caused by: java.lang.ClassCastException: com.koopamillion.tile_entity.TileEntityMatter cannot be cast to com.koopamillion.tile_entity.TileEntityMT at com.koopamillion.inventory.ContainerMT.<init>(ContainerMT.java:30) ~[ContainerMT.class:?] It is saying that the cast error is happening on line 30. But like 30 is blanks... so I am at a loss. DO you have the TileEntityMatter class? Can you show it please
  3. Okay but in my case how should I be doing slots tho. Like for this: public FabTabSlot(EntityPlayer par1EntityPlayer, InventoryCrafting craftResult, IInventory iinv, int par4, int par5, int par6) { super(par1EntityPlayer, craftResult, iinv, par4, par5, par6); this.thePlayer = par1EntityPlayer; this.craftMatrix = craftResult; } I cannot change it to IItemHandler because then it errors since I am extending SlotCrafting
  4. Okay now I am a little confused. I am looking at the gui code for hoppers and so on and I still see IInventory everywhere.
  5. Okay so for my class fabTabSlot I figure why it was null pointering thank you Choonster for that. But Here: fabTabSlot = new FabTabSlot(playerInv.player, craftMatrix, fabTile, 0, 143, 36); addSlotToContainer(fabTabSlot); And I pass in this: public FabTabSlot(EntityPlayer par1EntityPlayer, InventoryCrafting craftResult, IInventory iinv, int par4, int par5, int par6) { super(par1EntityPlayer, craftResult, iinv, par4, par5, par6); this.thePlayer = par1EntityPlayer; this.craftMatrix = craftResult; } Before I had craftmatrix being put into an IInventory and the craft fabTile into an InventoryCrafting. Now that line does not null pointer however I feel like I may have found the cause to my problem but because TileEntities and IInventory is kinda newer to me I am not sure. So here it goes with the explanation. When I create my Container I pass in a Tile, InventoryPlayer, World, and 3 int. But when I create slots I am using the Tile, which I passed in, as the IInventory. Is that right? Can my Tile Entity hold the IInventory. Like is that what it is suppose to do or did I royally mess up and need a new variable or something LOL
  6. Why are you casting a block to a block? Item.getItemFromBlock((Block) blockRedstoneAnvil); That may be your issue. Other than that I am looking at this code and it looks fine.
  7. Ikr like same. Normally after starring at the code something jumps out but fucken nothing. Like even if I comment it out. Then I get the null pointer on saveCraftingMatrix(); finally if I comment that then I get this null pointer..... Description: Unexpected error java.lang.NullPointerException: Unexpected error at net.minecraft.inventory.Slot.getStack(Slot.java:81) at net.minecraft.inventory.Container.detectAndSendChanges(Container.java:84) at net.minecraft.inventory.Container.onCraftMatrixChanged(Container.java:567) at com.zodsmar.entities.ContainerFabTable.<init>(ContainerFabTable.java:69) at com.zodsmar.entities.FabTableGui.<init>(FabTableGui.java:21) at com.zodsmar.entities.GuiHandler.getClientGuiElement(GuiHandler.java:27) at net.minecraftforge.fml.common.network.NetworkRegistry.getLocalGuiContainer(NetworkRegistry.java:266) at net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:102) at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2694) at com.zodsmar.blocks.FabricationTable.onBlockActivated(FabricationTable.java:36) at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClickBlock(PlayerControllerMP.java:425) at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1597) at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2268) at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2052) at net.minecraft.client.Minecraft.runTick(Minecraft.java:1840) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1114) at net.minecraft.client.Minecraft.run(Minecraft.java:401) at net.minecraft.client.main.Main.main(Main.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:26) ITS LITERALLY NULL POINTERING ON at net.minecraft.inventory.Slot.getStack(Slot.java:81); HOW LIKE WHAT AM I MISSING HERE...... Jeez I love programming to death but things like this just get to me LOL <3
  8. I am aware of that. Using VANILLA Command blocks (which work on a server) you can make text appear on the players HUD... this should not be new info to you. Please
  9. So the idea is with commands, you can set an area, then if you are within this area have a specific text display on screen, which you would set when inside that space. Question. Why make a FORGE mod for this. You can easily (well easily enough) do this in vanilla with command blocks..... and if u really want a server mod for this make it bukkit. Just saying
  10. Here: public class ContainerFabTable extends Container implements ISlotChanged { private World worldObj; public TileEntityFabTable tileEntity; FabTabSlot FabSlot; private int posX; private int posY; private int posZ; /** The crafting matrix inventory (3x3). */ // container, width, length public InventoryCrafting craftMatrix = new InventoryCrafting(this, 3, 3); private FabTabSlot fabTabSlot; public ContainerFabTable(TileEntityFabTable fabTile, InventoryPlayer playerInv, World world, int x, int y, int z) { worldObj = world; tileEntity = fabTile; //ERROR HERE posX = x; posY = y; posZ = z; fabTabSlot = new FabTabSlot(playerInv.player, this.craftMatrix, tileEntity.craftResult, 0, 143, 36); addSlotToContainer(fabTabSlot); int row; int col; updateCraftingMatrix(); for (row = 0; row < 3; ++row) { for (col = 0; col < 3; ++col) { this.addSlotToContainer(new Slot(this.craftMatrix, col + row * 3, 48 + col * 18, 18 + row * 18)); } } for (int row1 = 0; row1 < 2; row1++) { for (int col1 = 0; col1 < 9; col1++) this.addSlotToContainer(new Slot(tileEntity, col1 + row1 * 9, 8 + col1 * 18, 90 + row1 * 18)); } this.addSlotToContainer(new SlotStartsWith(tileEntity, "fabUpgrade", 28, 16, 10).setSlotChange(tileEntity)); this.addSlotToContainer(new SlotStartsWith(tileEntity, "fabUpgrade", 29, 16, 36).setSlotChange(tileEntity)); this.addSlotToContainer(new SlotStartsWith(tileEntity, "fabUpgrade", 30, 16, 62).setSlotChange(tileEntity)); this.addSlotToContainer(new SlotStartsWith(tileEntity, "fabPlan", 31, 143, 10).setSlotChange(this)); for (int row2 = 0; row2 < 3; row2++) { for (int col2 = 0; col2 < 9; col2++) this.addSlotToContainer(new Slot(playerInv, col2 + row2 * 9 + 9, 8 + col2 * 18, 140 + row2 * 18)); } for (row = 0; row < 9; ++row) { this.addSlotToContainer(new Slot(playerInv, row, 8 + row * 18, 198)); } this.onCraftMatrixChanged(this.craftMatrix); // addSlotToContainer(new Slot(playerInv, 36, 17, 36)); } private void updateCraftingMatrix() { for (int i = 0; i < craftMatrix.getSizeInventory(); i++) { craftMatrix.setInventorySlotContents(i, tileEntity.craftMatrixInventory[i]); } } @Override public void onContainerClosed(EntityPlayer par1EntityPlayer) { super.onContainerClosed(par1EntityPlayer); saveCraftingMatrix(); } private void saveCraftingMatrix() { for (int i = 0; i < craftMatrix.getSizeInventory(); i++) { tileEntity.craftMatrixInventory[i] = craftMatrix.getStackInSlot(i); } } @Override public void onCraftMatrixChanged(IInventory IInv) { tileEntity.craftResult.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(this.craftMatrix, this.worldObj)); } @Override public boolean canInteractWith(EntityPlayer entityPlayer) { return tileEntity.isUseableByPlayer(entityPlayer); } @Override public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int par2) { ItemStack itemstack = null; Slot slot = (Slot) this.inventorySlots.get(par2); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); if (par2 == 0) { if (!this.mergeItemStack(itemstack1, 32, 67, false)) { if (itemstack1.stackSize == 0) { slot.putStack((ItemStack) null); } else { slot.onSlotChanged(); } return null; } else { slot.putStack((ItemStack) null); } fabTabSlot.onPickupFromSlot(entityPlayer, itemstack); this.onCraftMatrixChanged(this.craftMatrix); return itemstack; } else if (par2 >= 32 && par2 <= 67) { if (itemstack1.getUnlocalizedName().startsWith("fabUpgrade")) { return null; } else if (!this.mergeItemStack(itemstack1, 10, 27, false)) { if (itemstack1.stackSize == 0) { slot.putStack((ItemStack) null); } else { slot.onSlotChanged(); } return null; } } else if (par2 >= 10 && par2 <= 27 || par2 <= 9 || par2 >= 28 && par2 <= 31) { if (!this.mergeItemStack(itemstack1, 32, 67, false)) { if (itemstack1.stackSize == 0) { slot.putStack((ItemStack) null); } else { slot.onSlotChanged(); } return null; } } } return itemstack; } @Override public void onSlotChange(Slot slot, int id, ItemStack itemStack) { System.out.println("Plans changed"); }
  11. Well your right. That is where the Errors occur. If I comment out the slots, and leave the crafting matrix here is the error: java.lang.NullPointerException: Unexpected error at com.zodsmar.entities.ContainerFabTable.updateCraftingMatrix(ContainerFabTable.java:76) at com.zodsmar.entities.ContainerFabTable.<init>(ContainerFabTable.java:39) at com.zodsmar.entities.FabTableGui.<init>(FabTableGui.java:21) at com.zodsmar.entities.GuiHandler.getClientGuiElement(GuiHandler.java:27) at net.minecraftforge.fml.common.network.NetworkRegistry.getLocalGuiContainer(NetworkRegistry.java:266) at net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:102) at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2694) at com.zodsmar.blocks.FabricationTable.onBlockActivated(FabricationTable.java:36) at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClickBlock(PlayerControllerMP.java:425) at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1597) at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2268) at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2052) at net.minecraft.client.Minecraft.runTick(Minecraft.java:1840) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1114) at net.minecraft.client.Minecraft.run(Minecraft.java:401) at net.minecraft.client.main.Main.main(Main.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:26) The thing is I do not understand what I would be doing wrong. Here is the code: /** The craft matrix inventory linked to this result slot. */ private final IInventory craftMatrix; /** The player that is using the GUI where this slot resides. */ private EntityPlayer thePlayer; /** * The number of items that have been crafted so far. Gets passed to ItemStack.onCrafting before being reset. */ private int amountCrafted; public FabTabSlot(EntityPlayer par1EntityPlayer, InventoryCrafting par2IInventory, InventoryCraftResult craftResult, int par4, int par5, int par6) { super(par1EntityPlayer, par2IInventory, craftResult, par4, par5, par6); this.thePlayer = par1EntityPlayer; this.craftMatrix = par2IInventory; } /** * Check if the stack is a valid item for this slot. Always true beside for the armor slots. */ @Override public boolean isItemValid(ItemStack par1ItemStack) { return false; } /** * Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new * stack. */ @Override public ItemStack decrStackSize(int par1) { if (this.getHasStack()) { this.amountCrafted += Math.min(par1, this.getStack().stackSize); } return super.decrStackSize(par1); } /** * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. Typically increases an * internal count then calls onCrafting(item). */ @Override protected void onCrafting(ItemStack par1ItemStack, int par2) { this.amountCrafted += par2; this.onCrafting(par1ItemStack); } and the crafting matrix: private void updateCraftingMatrix() { for (int i = 0; i < craftMatrix.getSizeInventory(); i++) { craftMatrix.setInventorySlotContents(i, tileEntity.craftMatrixInventory[i]); } } @Override public void onContainerClosed(EntityPlayer par1EntityPlayer) { super.onContainerClosed(par1EntityPlayer); saveCraftingMatrix(); } private void saveCraftingMatrix() { for (int i = 0; i < craftMatrix.getSizeInventory(); i++) { tileEntity.craftMatrixInventory[i] = craftMatrix.getStackInSlot(i); } } @Override public void onCraftMatrixChanged(IInventory IInv) { tileEntity.craftResult.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(this.craftMatrix, this.worldObj)); }
  12. If I don't tho then I get A ticking Player error. Or it starts to null pointer everywhere which makes no sense what so ever.
  13. Okay so everything is working now and all I had to do was change one thing. As to how this makes sense I am unsure but now I do not think that my methods in my tile entity class are being called. Here is what I changed: public ContainerFabTable(TileEntityFabTable fabTile, InventoryPlayer playerInv, World world, int x, int y, int z) { worldObj = world; tileEntity = new TileEntityFabTable(); Before it was: tileEntity = fabTile; can someone explain why that makes sense. Also now in the tile entity class the NBT data for saving items when the gui is closed, does not work. Here is the code for the NBT Tags? Am I not calling them right or? @Override public void readFromNBT(NBTTagCompound nbtTagCompound) { super.readFromNBT(nbtTagCompound); // Read in the ItemStacks in the inventory from NBT NBTTagList tagList = nbtTagCompound.getTagList("Items", 18); inventory = new ItemStack[this.getSizeInventory()]; for (int i = 0; i < tagList.tagCount(); ++i) { NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); byte slot = tagCompound.getByte("Slot"); if (slot >= 0 && slot < inventory.length) { inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound); } } // Read in the Crafting Matrix from NBT NBTTagList craftingTag = nbtTagCompound.getTagList("CraftingMatrix", 9); craftMatrixInventory = new ItemStack[9]; // TODO: magic number for (int i = 0; i < craftingTag.tagCount(); ++i) { NBTTagCompound tagCompound = (NBTTagCompound) craftingTag.getCompoundTagAt(i); byte slot = tagCompound.getByte("Slot"); if (slot >= 0 && slot < craftMatrixInventory.length) { craftMatrixInventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound); } } // Read craftingResult from NBT NBTTagCompound tagCraftResult = nbtTagCompound.getCompoundTag("CraftingResult"); craftResult.setInventorySlotContents(0, ItemStack.loadItemStackFromNBT(tagCraftResult)); } @Override public void writeToNBT(NBTTagCompound nbtTagCompound) { super.writeToNBT(nbtTagCompound); // Write the ItemStacks in the inventory to NBT NBTTagList tagList = new NBTTagList(); for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) { if (inventory[currentIndex] != null) { NBTTagCompound tagCompound = new NBTTagCompound(); tagCompound.setByte("Slot", (byte) currentIndex); inventory[currentIndex].writeToNBT(tagCompound); tagList.appendTag(tagCompound); } } nbtTagCompound.setTag("Items", tagList); // Write Crafting Matrix to NBT NBTTagList craftingTag = new NBTTagList(); for (int currentIndex = 0; currentIndex < craftMatrixInventory.length; ++currentIndex) { if (craftMatrixInventory[currentIndex] != null) { NBTTagCompound tagCompound = new NBTTagCompound(); tagCompound.setByte("Slot", (byte) currentIndex); craftMatrixInventory[currentIndex].writeToNBT(tagCompound); craftingTag.appendTag(tagCompound); } } nbtTagCompound.setTag("CraftingMatrix", craftingTag); // Write craftingResult to NBT if (craftResult.getStackInSlot(0) != null) nbtTagCompound.setTag("CraftingResult", craftResult.getStackInSlot(0).writeToNBT(new NBTTagCompound())); }
  14. Okay so in regards to the GUI not opening it works now kinda. My issue was @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) I was using the wrong method so essentially right clicking did nothing. Now it works and I am getting errors in this class only pretty much Even by commenting most of it out I get this error: [23:55:33] [server thread/FATAL]: Error executing task java.util.concurrent.ExecutionException: java.lang.NullPointerException at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:1.7.0_79] at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:1.7.0_79] at net.minecraft.util.Util.runTask(Util.java:24) [util.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:738) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:683) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:155) [integratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:532) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.7.0_79] Caused by: java.lang.NullPointerException at net.minecraft.inventory.Slot.getStack(Slot.java:81) ~[slot.class:?] at net.minecraft.inventory.Container.getInventory(Container.java:62) ~[Container.class:?] at net.minecraft.inventory.Container.onCraftGuiOpened(Container.java:51) ~[Container.class:?] at net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:93) ~[FMLNetworkHandler.class:?] at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2694) ~[EntityPlayer.class:?] at com.zodsmar.blocks.FabricationTable.onBlockActivated(FabricationTable.java:36) ~[FabricationTable.class:?] at net.minecraft.server.management.PlayerInteractionManager.processRightClickBlock(PlayerInteractionManager.java:455) ~[PlayerInteractionManager.class:?] at net.minecraft.network.NetHandlerPlayServer.processRightClickBlock(NetHandlerPlayServer.java:706) ~[NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.CPacketPlayerTryUseItem.processPacket(CPacketPlayerTryUseItem.java:68) ~[CPacketPlayerTryUseItem.class:?] at net.minecraft.network.play.client.CPacketPlayerTryUseItem.processPacket(CPacketPlayerTryUseItem.java:13) ~[CPacketPlayerTryUseItem.class:?] at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:15) ~[PacketThreadUtil$1.class:?] at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.7.0_79] at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.7.0_79] at net.minecraft.util.Util.runTask(Util.java:23) ~[util.class:?] ... 5 more [23:55:33] [server thread/ERROR]: Encountered an unexpected exception net.minecraft.util.ReportedException: Ticking player at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:785) ~[MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:683) ~[MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:155) ~[integratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:532) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.7.0_79] Caused by: java.lang.NullPointerException at net.minecraft.inventory.Slot.getStack(Slot.java:81) ~[slot.class:?] at net.minecraft.inventory.Container.detectAndSendChanges(Container.java:84) ~[Container.class:?] at net.minecraft.entity.player.EntityPlayerMP.onUpdate(EntityPlayerMP.java:290) ~[EntityPlayerMP.class:?] at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2086) ~[World.class:?] at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:864) ~[WorldServer.class:?] at net.minecraft.world.World.updateEntity(World.java:2051) ~[World.class:?] at net.minecraft.world.WorldServer.tickPlayers(WorldServer.java:666) ~[WorldServer.class:?] at net.minecraft.world.World.updateEntities(World.java:1858) ~[World.class:?] at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:637) ~[WorldServer.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:779) ~[MinecraftServer.class:?] ... 4 more By trying code I have come to the conclusion that it is happening for 2 reasons. One it is something to do with the way I am dealing with slots. And second is: @Override public boolean canInteractWith(EntityPlayer entityPlayer) { return tileEntity.isUseableByPlayer(entityPlayer); } The Ticking Player is erroring. Even if I comment out everything and leave only the fundamentals and important stuff (pretty much no Slot stuff) it works but crashes on Ticking Player so yeah? Any thoughts guys? Oh also at the end of the error was this no idea what it means tho and if its important. [23:55:33] [server thread/INFO] [FML]: The state engine was in incorrect state SERVER_STOPPING and forced into state SERVER_STOPPED. Errors may have been discarded.
  15. Okay new problems <3 Love you guys btw for all the help and Like most of the time it isnt even a solution you just say stuff that makes me think of ways to fix it. So honestly any input is nice <3 So here it goes I am trying to make my gui open when I right click the block. As of right now there is no error and no errors in the code so I do not understand why it does not open or work. Here are the classes: Main Class Registers: GuiHandler: FabTableGui: Container: (Pretty sure this one isnt that important for actually making the gui open. Rn all I want is the actual gui to open) TileEntityFabTable: The actual Block Class itself: And now for Completeness here is the Registering of the block also. AKA blocks Class LOL
  16. So I figured it out. This probably should have been easier than I thought but for anyone wanting to see the code here: /** * * @param block * (ex. Blocks.log) * @param starting * (starting metadata) * @param ending * (ending metadata) */ public static void HRL(Block block, int starting, int ending) { int meta1 = -1; int meta2; if (meta1 < 0) { meta1 = starting; } for (int i = meta1; i <= ending; i++) { meta2 = meta1 + 1; addRecipe(new HammerRecipe(block, meta1), new HammerRecipe(block, meta2)); meta1 = meta2; if (i == ending) { addRecipe(new HammerRecipe(block, meta1), new HammerRecipe(block, starting)); } } } /** * * @param block * (ex. Blocks.log) * @param starting * (starting metadata) * @param ending * (ending metadata) * @param startingForTransform * (in case you only want certain blocks not craftable in * crafting table) * @param shouldAddLastRecipeBack (Simply if you want a last recipe from max back to min) */ public static void HrlADV(Block block, int starting, int ending, int startingForTransform, boolean shouldAddLastRecipeBack) { int meta1 = -1; int meta2; if (meta1 < 0) { meta1 = starting; } for (int i = meta1; i <= ending; i++) { meta2 = meta1 + 1; if (i >= startingForTransform) { addRecipeT(new HammerRecipe(block, meta1), new HammerRecipe(block, meta2)); } else { addRecipe(new HammerRecipe(block, meta1), new HammerRecipe(block, meta2)); } meta1 = meta2; if (i == startingForTransform && shouldAddLastRecipeBack == true) { addRecipe(new HammerRecipe(block, startingForTransform), new HammerRecipe(block, starting)); } if (i >= ending && meta1 <= startingForTransform && shouldAddLastRecipeBack == true) { addRecipe(new HammerRecipe(block, meta1), new HammerRecipe(block, starting)); } if (i >= ending && meta1 >= startingForTransform && shouldAddLastRecipeBack == true) { addRecipeT(new HammerRecipe(block, meta1), new HammerRecipe(block, starting)); } } }
  17. Hammer Recipe is the class which handles my own Recipe. I pass to Hammer Recipes because the first one is the input. And the second is the output. So addRecipe(new HammerRecipe(Blocks.log, 0), new HammerRecipe(Blocks.log, 1)); Blocks.log, 0 is the input (BASICALLY when I right click ingame. If I click on Block.log, 1, which is Oak) it will then look at the second HammerRecipe which in this case is Blocks.log, 1 or Spruce and will replace Oak to spruce. So when I have 15 meta data's I need 15 lines of code to iterate threw. Does this make sense. Like I don't know how much easier I can explain this.....
  18. In plain English: The hammer is a tool which allows a player to right click a block and based on recipes, that block will change and durability will be given to then hammer. However, all recipes which are "clickable" in the world can also be done in a crafting table. So the hammer is a tool which takes durability based on crafting. Now the part I want to change for the hammer is right now to lets say craft from Oak log to Spruce Log the recipe is addRecipe(new HammerRecipe(Blocks.log, 0), new HammerRecipe(Blocks.log, 1)); however there is 15 metadata available so to be able to go from lets say oak to jungle (because crafting is mainly click based) it has to increment up. So for the 15 different block states for logs this is the code: addRecipe(new HammerRecipe(Blocks.log, 0), new HammerRecipe(Blocks.log, 1)); addRecipe(new HammerRecipe(Blocks.log, 1), new HammerRecipe(Blocks.log, 2)); addRecipe(new HammerRecipe(Blocks.log, 2), new HammerRecipe(Blocks.log, 3)); addRecipeT(new HammerRecipe(Blocks.log, 3), new HammerRecipe(Blocks.log, 4)); addRecipeT(new HammerRecipe(Blocks.log, 4), new HammerRecipe(Blocks.log, 5)); addRecipeT(new HammerRecipe(Blocks.log, 5), new HammerRecipe(Blocks.log, 6)); addRecipeT(new HammerRecipe(Blocks.log, 6), new HammerRecipe(Blocks.log, 7)); addRecipeT(new HammerRecipe(Blocks.log, 7), new HammerRecipe(Blocks.log, ); addRecipeT(new HammerRecipe(Blocks.log, , new HammerRecipe(Blocks.log, 9)); addRecipeT(new HammerRecipe(Blocks.log, 9), new HammerRecipe(Blocks.log, 10)); addRecipeT(new HammerRecipe(Blocks.log, 10), new HammerRecipe(Blocks.log, 11)); addRecipeT(new HammerRecipe(Blocks.log, 11), new HammerRecipe(Blocks.log, 12)); addRecipeT(new HammerRecipe(Blocks.log, 12), new HammerRecipe(Blocks.log, 13)); addRecipeT(new HammerRecipe(Blocks.log, 13), new HammerRecipe(Blocks.log, 14)); addRecipeT(new HammerRecipe(Blocks.log, 14), new HammerRecipe(Blocks.log, 15)); addRecipeT(new HammerRecipe(Blocks.log, 15), new HammerRecipe(Blocks.log, 0)); The thing I am trying to change is to bring down the amount of lines of code. I want to set up one recipe that will encapsulate all 15 meta's and increment in one line of code so something like: addRecipe(new HammerRecipe(Blocks.log, OreDictionary.WILDCARD), new HammerRecipe(Blocks.log, OreDictionary.WILDCARD + 1)); Now I know this does not work but I am trying to basically for loop the recipes. Do you see what I am trying to do now? (Plain enough english) -Zods
  19. If you read my question that does not really help. I am aware what ore dictionary does and how it works just integrating it is the issue.
  20. Did you even look if another thread existed with your problem and how to solve it? Because from what you described here: http://www.minecraftforge.net/forum/index.php/topic,38347.0.html (Btw its legit like 6 threads below yours so yeah......)
  21. Yes, but to my knowledge doesn't OreDictionary just look to see if that block exists with a meta, and the meta does not matter to the recipe? In my case I wanna increment up the by one each time. I tried Oredictionary.WILDCARD for the input and OreDictionary.WILDCARD + 1 for the output which I was sure was not gonna work but yeah.
  22. Whats the error specifically. Its hard to help when we do not even know what is erroring.....
  23. So I am curious if this is possible but I am not sure because I am not quite sure how minecraft handles recipes. Right now for crafting I have it set up that it takes an input and an output. So for "Scrolling in a sense" through lets say all the metadata like so: addRecipe(new HammerRecipe(Blocks.carpet, 0), new HammerRecipe(Blocks.carpet, 1)); addRecipe(new HammerRecipe(Blocks.carpet, 1), new HammerRecipe(Blocks.carpet, 2)); addRecipe(new HammerRecipe(Blocks.carpet, 2), new HammerRecipe(Blocks.carpet, 3)); addRecipe(new HammerRecipe(Blocks.carpet, 3), new HammerRecipe(Blocks.carpet, 4)); addRecipe(new HammerRecipe(Blocks.carpet, 4), new HammerRecipe(Blocks.carpet, 5)); addRecipe(new HammerRecipe(Blocks.carpet, 5), new HammerRecipe(Blocks.carpet, 6)); addRecipe(new HammerRecipe(Blocks.carpet, 6), new HammerRecipe(Blocks.carpet, 7)); addRecipe(new HammerRecipe(Blocks.carpet, 7), new HammerRecipe(Blocks.carpet, ); addRecipe(new HammerRecipe(Blocks.carpet, , new HammerRecipe(Blocks.carpet, 9)); addRecipe(new HammerRecipe(Blocks.carpet, 9), new HammerRecipe(Blocks.carpet, 10)); addRecipe(new HammerRecipe(Blocks.carpet, 10), new HammerRecipe(Blocks.carpet, 11)); addRecipe(new HammerRecipe(Blocks.carpet, 11), new HammerRecipe(Blocks.carpet, 12)); addRecipe(new HammerRecipe(Blocks.carpet, 12), new HammerRecipe(Blocks.carpet, 13)); addRecipe(new HammerRecipe(Blocks.carpet, 13), new HammerRecipe(Blocks.carpet, 14)); addRecipe(new HammerRecipe(Blocks.carpet, 14), new HammerRecipe(Blocks.carpet, 15)); addRecipe(new HammerRecipe(Blocks.carpet, 15), new HammerRecipe(Blocks.carpet, 0)); I need to essentially create a recipe for each craft. Is there a way to condense this. What I am trying to do is set it so that the input, in this case would be Blocks.carpet, 15 (15 would be the max meta possible so for blocks with lower meta it can be changed) and the output, would be the starting meta which is almost always zero. So what I wanna then do is pass it through a loop like I am doing here: public static void addRecipeLOOP(HammerRecipe input, HammerRecipe output) { for(int i = 0; i < input.meta; i++){ input.meta = i; output.meta = input.meta + 1; if (!input.isItems && !output.isItems) transformBlocks.put(input, new ItemStack(output.id, 1, output.meta)); } Only the way that minecraft handles recipes is it possible to create recipes via a loop? And you guys understand what I am trying to accomplish. Now this is not that important but like it gets rid of the hundreds of unnecessary lines of code for just simple meta jumping. Think about logs, and sand, and hardened clay and so on. Its a lot of stupid and repetitive code which if I can condense would be amazing and a lot easier to write then lol Thanks Zods
  24. Okay so I got a new question. On rightclick I want to spawn a bolt of lightning where I am looking. However if its a block that can be converted via a recipe then do not do lightning but the recipe. Here is my code from 1.6 but I am un sure because Vec3 does not exist anymore. public ItemStack onItemRightClick(ItemStack itemstack, World worldObj, EntityPlayer entityplayer) { if(itemstack.getItemDamage() >= 0){ float f = 1.0F; float f1 = entityplayer.prevRotationPitch + (entityplayer.rotationPitch - entityplayer.prevRotationPitch) * f; float f2 = entityplayer.prevRotationYaw + (entityplayer.rotationYaw - entityplayer.prevRotationYaw) * f; double d = entityplayer.prevPosX + (entityplayer.posX - entityplayer.prevPosX) * (double)f; double d1 = (entityplayer.prevPosY + (entityplayer.posY - entityplayer.prevPosY) * (double)f + 1.6200000000000001D) - (double)entityplayer.yOffset; double d2 = entityplayer.prevPosZ + (entityplayer.posZ - entityplayer.prevPosZ) * (double)f; Vec3 vec3d = Vec3.createVectorHelper(d, d1, d2); float f3 = MathHelper.cos(-f2 * 0.01745329F - 3.141593F); float f4 = MathHelper.sin(-f2 * 0.01745329F - 3.141593F); float f5 = -MathHelper.cos(-f1 * 0.01745329F); float f6 = MathHelper.sin(-f1 * 0.01745329F); float f7 = f4 * f5; float f8 = f6; float f9 = f3 * f5; double d3 = 5000D; Vec3 vec3d1 = vec3d.addVector((double)f7 * d3, (double)f8 * d3 + 1, (double)f9 * d3); MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks_do_do(vec3d, vec3d1, false, true); if (movingobjectposition == null) { return itemstack; } if (movingobjectposition.typeOfHit == EnumMovingObjectType.TILE) { int i = movingobjectposition.blockX; int j = movingobjectposition.blockY; int k = movingobjectposition.blockZ; world.spawnEntityInWorld(new EntityLightningBolt(world, i, j, k)); } itemstack.setItemDamage(0); } return itemstack; }
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.