Eastonium Posted April 10, 2016 Share Posted April 10, 2016 I have a tank implemented on my tile entity, but the client isn't getting updated when I remove fluid from the tank bit by bit, but it does work when I fill the tank completely from being empty. Here's my update function from my TileEntity/TileInventory class. @Override public void update(){ boolean hasLava = this.hasLava(); int lavaAmount = this.tank.getFluidAmount(); boolean needsUpdate = false; //When I print out "lavaAmount" here, I get either 0/1000 (empty/full) when run by the client, but the actual amount when run by the server /*if(this.burnTimeRemaining > 0){ --this.burnTimeRemaining; }*/ if(!this.worldObj.isRemote){ if(!hasLava && this.forgeItemstacks[FIRST_FUEL_SLOT] != null && this.forgeItemstacks[FIRST_FUEL_SLOT].getItem() == Items.lava_bucket){//TODO Change to include all items that hold fluids this.fill(null, new FluidStack(FluidRegistry.LAVA, FluidContainerRegistry.BUCKET_VOLUME), true); this.forgeItemstacks[FIRST_FUEL_SLOT] = this.forgeItemstacks[FIRST_FUEL_SLOT].getItem().getContainerItem(forgeItemstacks[FIRST_FUEL_SLOT]); } if(/*this.secondsOfFuelRemaining() > 0*/ hasLava && this.canSmelt()){ this.tank.drain(5, true); ++this.cookTime; if(this.cookTime == COOK_TIME_FOR_COMPLETION){ this.cookTime = 0; this.smeltItem(); needsUpdate = true; } } if (lavaAmount != this.tank.getFluidAmount()){ needsUpdate = true; //TODO BlockMaskForge.updateFurnaceBlockState(this.isBurning(), this.worldObj, this.pos.getX(), this.pos.getY(), this.pos.getX()); } } if (needsUpdate){ this.markDirty(); } } Is there something I'm missing here? I'm sure you'll probably need more information to help me solve this, just let me know what you need. EDIT: Solved it myself. Turns out when I was updating the IInventory setFeild() function, I was always adding fluid rather than adding/removing depending on what it should be. So I changed this: @Override public void setField(int id, int value){ if(id == COOK_FIELD_ID){ cookTime = (short)value; }else if(id == FUEL_AMOUNT_FIELD_ID){ this.fill(null, new FluidStack(FluidRegistry.LAVA, value), true); }else{ System.err.println("Invalid field ID in TileInventorySmelting.setField:" + id); } } To this: @Override public void setField(int id, int value){ if(id == COOK_FIELD_ID){ cookTime = (short)value; }else if(id == FUEL_AMOUNT_FIELD_ID){ FluidStack flStack = new FluidStack(FluidRegistry.LAVA, Math.abs(this.tank.getFluidAmount() - value)); if(value > this.tank.getFluidAmount()){ this.fill(null, flStack, true); }else if(value < this.tank.getFluidAmount()){ this.drain(null, flStack, true); } }else{ System.err.println("Invalid field ID in TileInventorySmelting.setField:" + id); } } Quote Link to comment Share on other sites More sharing options...
shadowfacts Posted April 10, 2016 Share Posted April 10, 2016 Of course it doesn't think there's any fluid present on the client side, your code that updates the lava tank is only run on the server side because of the !isRemote check. The game doesn't automatically sync your TileEntities to the client side, you need to do that yourself. Quote Don't make mods if you don't know Java. Check out my website: http://shadowfacts.net Developer of many mods Link to comment Share on other sites More sharing options...
Eastonium Posted April 11, 2016 Author Share Posted April 11, 2016 Did you read all of my post? It does show changes on clientside, but only in one circumstance. Quote Link to comment Share on other sites More sharing options...
Draco18s Posted April 11, 2016 Share Posted April 11, 2016 Did you read all of my post? It does show changes on clientside, but only in one circumstance. Your update function still bypasses the change that doesn't get tracked on the client, on the client. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given. Link to comment Share on other sites More sharing options...
Eastonium Posted April 11, 2016 Author Share Posted April 11, 2016 But both of the changes I make to the tank both happen within the !isRemote section. Am I just missing something really obvious? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.