Everything posted by CJLetsGame
-
Possible bug in TileFluidHandler
nvm.. Just opened the code. It wasnt doing what I thought it was. You could always try switching them and seeing if it works.
-
Possible bug in TileFluidHandler
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.
-
Useful Tutorial?
The forge wiki has a bunch of tutorials... http://www.minecraftforge.net/wiki/Tutorials Most of them are fairly up to date.
-
Spawning Items Around Block When right Clicked
@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; }
-
Problem with FluidTanks
Sorry missed that, I keep mine separate so its easier to read.
-
Textures change in hand but not in world?
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.
-
Problem with FluidTanks
Can I see your Container code and GuiHandler?
-
can't find out why it isnt loading my texture.
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.
-
[Unsolved] Where are the grass block texture overlays rendered? [1.6.4]
Grass is rendered by renderStandardBlockWithColorMultiplier
-
[Unsolved] Where are the grass block texture overlays rendered? [1.6.4]
Why don't you just use the color multiplier method from the BlockGrass? A quick copy and paste.
-
Disappearing Container Items
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.
-
Disappearing Container Items
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; } }
-
Disappearing Container Items
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.
-
Forced light update?
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.
-
Disappearing Container Items
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; } }
-
Packet Handler EOF
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.
-
Packet Handler EOF
I dont know if it helps but Im currently coding with Minecraft 1.5.2. Forge Crash Log
-
Packet Handler EOF
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
IPS spam blocked by CleanTalk.