Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

CJLetsGame

Forge Modder
  • Joined

  • Last visited

Everything posted by CJLetsGame

  1. nvm.. Just opened the code. It wasnt doing what I thought it was. You could always try switching them and seeing if it works.
  2. Nope that makes sense. It tells the Tile to save its data onto a NBT tag and then makes the IFluidTank read that data. Thats how forge syncs them. If you post your TileEntity code and packet handing code, we might be able to help you track down your problem.
  3. The forge wiki has a bunch of tutorials... http://www.minecraftforge.net/wiki/Tutorials Most of them are fairly up to date.
  4. @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float f, float g, float t) { EntityItem ei = new EntityItem(world, x, y + 1, z, 'Your ItemStack Here'); world.spawnEntityInWorld(ei); return true; }
  5. Sorry missed that, I keep mine separate so its easier to read.
  6. If you want meta for direction and icon, use Bitwise operators. Lets say the first 2 bits are direction, and the last 2 are icon. Direction = Meta >> 2 IconIndex = Meta & 3 Meta = Direction << 2 | IconIndex So if Direction is 1 and IconIndex is 3 in Meta, it looks like: 0111 To get direction we shift the bits to the left 2 places. 0001 = 1 IconIndex is the last 2 bits so we AND the meta to 3 (0011) 0111 AND 0011 = 0011 = 3 Thats a quick run through, hope it made a little sense.
  7. Can I see your Container code and GuiHandler?
  8. You might want to set ServerSideRequired to true. On to the current problem though, which line is the error occuring on? at ModPack.ModPack.load(ModPack.java:67) Click on "ModPack.java:67" and tell us the line.
  9. Grass is rendered by renderStandardBlockWithColorMultiplier
  10. Why don't you just use the color multiplier method from the BlockGrass? A quick copy and paste.
  11. Fixed it myself. I guess in my sleep deprivation, I thought it was a good idea to store the player inventory in a separate field in the container. I have no idea why I did this as I didnt do it for any other container in my mod. Everything seems to work fine now that I fixed that.
  12. The ItemPage isnt useless because you can only access one page of the chest at a time. The container doesnt have access to every ItemStack at once. GuiHandler public class GuiHandler implements IGuiHandler{ @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity tile_entity = world.getBlockTileEntity(x, y, z); int BlockID = world.getBlockId(x, y, z); int Meta = world.getBlockMetadata(x, y, z); if (BlockID == Blocks.blockEnderNetTerminal.blockID) { if (Meta == 1) { return new ContainerEnderNetItemTerminal(player, new EnderNetItemPage((TileEntityEnderNetTerminal) tile_entity, 0)); } } return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity tile_entity = world.getBlockTileEntity(x, y, z); int BlockID = world.getBlockId(x, y, z); int Meta = world.getBlockMetadata(x, y, z); if (BlockID == Blocks.blockEnderNetTerminal.blockID) { if (Meta == 1) return new guiENetItemTerminal(player, (TileEntityEnderNetTerminal) tile_entity, 0); } return null; } }
  13. Update: Im almost 100% sure this is a sync issue between the server and client. The problem only occurs when re-opening the gui/container. I checked the inventory of the player when the client gui element is opened, this was the correct inventory. However, the container element didnt have the updated player inventory. How do I ensure the inventory gets synced? I assumed Packet5PlayerInventory would work, then I realized Mojang doesnt handle it.
  14. Try This @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { if (player.isSneaking()) return false; ItemStack test = player.getCurrentEquippedItem(); if (test != null && test.getItem() instanceof ItemBlock) { Block b = Block.blocksList[test.itemID]; if ((b.getRenderType() == 0 || b.getRenderType() == 16 || b.getRenderType() == 31 || b.getRenderType() == 39) && b.getBlockBoundsMinX() == 0F && b.getBlockBoundsMinY() == 0F && b.getBlockBoundsMinZ() == 0F && b.getBlockBoundsMaxX() == 1F && b.getBlockBoundsMaxY() == 1F && b.getBlockBoundsMaxZ() == 1F) { TileEntityMiniatureBlock tile = (TileEntityMiniatureBlock) world.getBlockTileEntity(x, y, z); tile.blockID = test.itemID; tile.damage = test.getItemDamage(); world.markBlockForUpdate(x, y, z); world.notifyBlocksOfNeighborChange(x, y, z, blockID); world.notifyBlocksOfNeighborChange(x + 1, y, z, blockID); world.notifyBlocksOfNeighborChange(x - 1, y, z, blockID); world.notifyBlocksOfNeighborChange(x, y + 1, z, blockID); world.notifyBlocksOfNeighborChange(x, y - 1, z, blockID); world.notifyBlocksOfNeighborChange(x, y, z + 1, blockID); world.notifyBlocksOfNeighborChange(x, y, z - 1, blockID); world.markBlockForRenderUpdate(x, y, z); System.out.println(world.isRemote ? "Client: " : "Server: " + world.getBlockLightValue(x, y, z)); } } return true; } Not entirely sure why you are changing the block ID and damage only on one side. I rearranged your code so it notifies blocks of an update first, then marks it for a lighting update.
  15. I have a multipage chest container. When I shift-click items out of the chest, they flash briefly in my inventory and then disappear. Normal clicking and moving keeps the items until I reopen the container and then they disappear. Shift-clink only does this with full stacks it seems. It should be noted the inventory of the pages is a shared inventory like the Ender Chest. ChestPage package CJTech.inventory; import java.util.logging.Level; import java.util.logging.Logger; import CJTech.tileentity.TileEntityEnderNetTerminal; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; public class EnderNetItemPage implements IInventory{ private TileEntityEnderNetTerminal terminal; private int page; public EnderNetItemPage(TileEntityEnderNetTerminal terminal, int page) { this.terminal = terminal; this.page = page; } @Override public int getSizeInventory() {return 117;} @Override public ItemStack getStackInSlot(int i) { return terminal.GetStackInSlot((page * 117) + i); } @Override public ItemStack decrStackSize(int i, int j) { return terminal.decrStack((page * 117) + i, j); } @Override public ItemStack getStackInSlotOnClosing(int i) {return null;} @Override public void setInventorySlotContents(int i, ItemStack itemstack) { //Treat as AddStack //Logger.getLogger("CJTECH").log(Level.INFO, "Adding: " + itemstack.stackSize); if (itemstack != null) if(CJTech.CJTech.instance.isSimulating()) //server handled by actual EnderNet { terminal.AddStack(itemstack); } else { } } @Override public String getInvName() {return "Ender Net";} @Override public boolean isInvNameLocalized() {return true;} @Override public int getInventoryStackLimit() {return 64;} @Override public void onInventoryChanged() {} @Override public boolean isUseableByPlayer(EntityPlayer entityplayer) {return true;} @Override public void openChest() {} @Override public void closeChest() {} @Override public boolean isItemValidForSlot(int i, ItemStack itemstack) {return true;} } Chest Container package CJTech.inventory; import java.util.List; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; public class ContainerEnderNetItemTerminal extends Container{ public EnderNetItemPage itemPages; public ContainerEnderNetItemTerminal(IInventory invPlayer, EnderNetItemPage itemPages) { this.itemPages = itemPages; for(int row = 0; row < 9; row++) { for(int col = 0; col < 13; col++) { addSlotToContainer(new Slot(itemPages, col + row * 13, 12 + col * 18, 8 + row * 18)); } } for(int invPlayerRow = 0; invPlayerRow < 3; invPlayerRow++) { for(int invPlayerCol = 0; invPlayerCol < 9; invPlayerCol++) { addSlotToContainer(new Slot(invPlayer, (invPlayerCol + invPlayerRow * 9) + 9, 48 + invPlayerCol * 18, 174 + invPlayerRow * 18)); } } for(int hotbatSlot = 0; hotbatSlot < 9; hotbatSlot++) { addSlotToContainer(new Slot(invPlayer, hotbatSlot, 48 + hotbatSlot * 18, 232)); } // ItemStorage = new IInventory(); // addSlotToContainer(new Slot(ItemStorage, 0, 228, 232)); //this.inventoryItemStacks.clear(); } @Override public boolean canInteractWith(EntityPlayer entityplayer) { return true; } public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, 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 < 117) { if (!this.mergeItemStack(itemstack1, 117, this.inventorySlots.size(), true)) { return null; } } else if (!this.mergeItemStack(itemstack1, 0, 117, false)) { return null; } if (itemstack1.stackSize == 0) { slot.putStack((ItemStack)null); } else { slot.onSlotChanged(); } } return itemstack; } } Class used to sync inventory package CJTech.endernet; import java.io.*; import java.util.*; import java.util.logging.Level; import java.util.logging.Logger; import CJTech.power.IPowerSink; import CJTech.util.CJTechFileIO; import CJTech.util.DebugLogger; import net.minecraft.client.Minecraft; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; public class EnderNet implements IPowerSink{ String SaveDir; public List<ItemStack> stacks = new ArrayList<ItemStack>(); public long Power = 0; public final long MaxPower = Long.MAX_VALUE; public boolean isLoaded = false; @Override public long RecievePower(long Power, boolean Sim) { this.Power += Power; return 0; } @Override public boolean canRecievePower() { return true; } /** * Removes power from the EnderNet * @param Amount Amount of power to drain/remove */ public void RemovePower(long Amount) { Power -= Amount; if (Power < 0) Power = 0; } /** * Checks if EnderNet has the ItemStack with ID, Meta, and at least a certain stack size * @param stack * @return */ protected boolean ContainsItemStack(ItemStack stack) { for (int f = 0; f < stacks.size(); f++) { if (stacks.get(f).itemID == stack.itemID) { if (stacks.get(f).getItemDamage() == stack.getItemDamage()) { if (stacks.get(f).stackSize >= stack.stackSize) { return true; } } } } return false; } protected int IndexOfStack(ItemStack stack) { if (stack == null) return -1; for (int f = 0; f < stacks.size(); f++) { if (stacks.get(f).itemID == stack.itemID) { if (stacks.get(f).getItemDamage() == stack.getItemDamage()) { return f; } } } return -1; } public ItemStack RetrieveStack(ItemStack stack) { int index = IndexOfStack(stack); if (index == -1) return null; ItemStack R = stacks.get(index).splitStack(stack.stackSize); if (stacks.get(index).stackSize <= 0) stacks.remove(index); return R; //return null; } public ItemStack RetrieveStack(int Slot, int Amount) { if (Slot >= stacks.size()) return null; if (Slot == -1) return null; if (!CJTech.CJTech.instance.isSimulating()) //Client return new ItemStack(stacks.get(Slot).itemID, Amount, stacks.get(Slot).getItemDamage()); else //Server { stacks.get(Slot).stackSize -= Amount; if (stacks.get(Slot).stackSize <= 0) stacks.remove(Slot); return null; } //return null; } public void AddStack(ItemStack stack) { boolean Server = CJTech.CJTech.instance.isSimulating(); DebugLogger.log("ENet Stack Size: " + stack.stackSize); if (stacks.size() == 0) { stacks.add(stack); DebugLogger.log("ENet Stack Added as new Stack, size was 0"); return; } //Try Merging Stacks for (int f = 0; f < stacks.size(); f++) { if (stacks.get(f).itemID == stack.itemID & stacks.get(f).getItemDamage() == stack.getItemDamage()) { if (stacks.get(f).stackSize + stack.stackSize <= stacks.get(f).getMaxStackSize()) { DebugLogger.log("ENet Stack Can Merge...: " + stack.stackSize + "|" + stacks.get(f).stackSize); stacks.get(f).stackSize += stack.stackSize; return; } else { int ToAdd = stacks.get(f).getMaxStackSize() - stacks.get(f).stackSize; DebugLogger.log("ENet Adding: " + ToAdd + " to stack."); stacks.get(f).stackSize += ToAdd; stack.stackSize -= ToAdd; //DebugLogger.log("ENet Putting rest in new stack"); //stacks.add(new ItemStack(stack.itemID, stack.stackSize - ToAdd, stack.getItemDamage())); //return; } } if (stack.stackSize <= 0) return; } //Add New Stack stacks.add(stack); } public ItemStack getStackInSlot(int i) { if (i < stacks.size()) return stacks.get(i); else return null; } public List getInventory() { return stacks; } }
  16. I was just checking it was the right channel. Wow... I just checked. In my block i had some older packet code. Removed it, now things work. Thanks, I feel kinda dumb now lol.
  17. I dont know if it helps but Im currently coding with Minecraft 1.5.2. Forge Crash Log
  18. When I shift click to open the GUI, it opens and then immediately after, my server gets a packet on the channel CJTECH and gets an EOF error. It shouldnt be getting any packets though from opening the Gui should it? Packet Handler Class GUI which should be the only thing sending a packet on that channel

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.