Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.12.2]Problem with tile entity


tt36999
 Share

Recommended Posts

My tileentity have two fluid tank and i want fill one of tanks when right click this block with fluid bucket.

But when i test my tileentity, the sever side(when world.isRemote == flase)tank always null when block actived, client side working properly

@Override
    public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
        ItemStack itemHeld = playerIn.getHeldItem(hand);
        IFluidHandlerItem handlerItem = FluidUtil.getFluidHandler(itemHeld);
        if (handlerItem != null) {
            TileEntityPurifier purifier = (TileEntityPurifier) worldIn.getTileEntity(pos);// BreakPoint 1 in this line server side tileentity's tank always empty
            IItemHandler iItemHandler = new InvWrapper(playerIn.inventory);
            FluidActionResult emptyResult = FluidUtil.tryEmptyContainerAndStow(itemHeld, purifier.tank, iItemHandler, purifier.tank.getCapacity(), playerIn, true);//I break this line , idea show me fluid has filled into tileentity, both side fluid amoount changed
            if (emptyResult.isSuccess()) {
                playerIn.setHeldItem(hand, emptyResult.getResult());
                worldIn.markChunkDirty(pos, purifier);
                return true;
            }
            FluidActionResult fillResultOut = FluidUtil.tryFillContainerAndStow(itemHeld, purifier.outputTank, iItemHandler, purifier.outputTank.getFluidAmount(), playerIn, true);
            if (fillResultOut.isSuccess()) {
                playerIn.setHeldItem(hand, fillResultOut.getResult());
                worldIn.markChunkDirty(pos, purifier);
                return true;
            }
            FluidActionResult fillResult = FluidUtil.tryFillContainerAndStow(itemHeld, purifier.outputTank, iItemHandler, purifier.tank.getFluidAmount(), playerIn, true);
            if (fillResult.isSuccess()) {
                playerIn.setHeldItem(hand, fillResult.getResult());
                worldIn.markChunkDirty(pos, purifier);
                return true;
            }
        } else {
            BrewingCraft.openGui(playerIn, getGui(), worldIn, pos.getX(), pos.getY(), pos.getZ());
            return true;
        }
        return false;
    }

any idea to fix this?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.