Jump to content

[1.15.2] IBlockColor handler not sending update


Haydenman2

Recommended Posts

Hello.

I have a basin TileEntity that stores a liquid, and when two items from a crafting recipe are placed in the block, the block changes states to allow the fluid to tint according to the recipe JSON as specified. This tint is working appropriately and the state is updating immediately (as seen in F3) however the actual visual tint won't take effect until a block near the basin is broken. Any advice on how to force the client to update their IBlockColor?

entity.output = crafting.getRecipeOutput().copy();
entity.stirsRemaining = crafting.getStirs();
entity.fluidColor = crafting.getColor();
world.setBlockState(pos, state.with(STATUS, BathStatus.success), 3);
entity.sendUpdates();

 

	public TileEntityALMBase(TileEntityType<?> tileEntityTypeIn) {
		super(tileEntityTypeIn);
	}

	@Override
	public SUpdateTileEntityPacket getUpdatePacket() {
		return new SUpdateTileEntityPacket(this.pos, -1, this.getUpdateTag());
	}
	
	@Override
	public CompoundNBT getUpdateTag() {
		return write(new CompoundNBT());
	}
	
	@Override
	public void onDataPacket(NetworkManager net, SUpdateTileEntityPacket pkt) {
		super.onDataPacket(net, pkt);
		handleUpdateTag(pkt.getNbtCompound());
	}
	
	
	public void sendUpdates() {
		world.markBlockRangeForRenderUpdate(pos, getBlockState(), getBlockState());
		world.notifyBlockUpdate(pos, getBlockState(), getBlockState(), 2);
		markDirty();
	}

 

event.getBlockColors().register(new IBlockColor() {
			
			@Override
			public int getColor(BlockState state, ILightReader reader, BlockPos pos, int tint) {
				if(reader != null && pos != null) {
					
					
					if(state.get(BlockFluidBath.STATUS) == BathStatus.success) {
						
						TileEntity te = reader.getTileEntity(pos);
						if(te != null && te instanceof TEFluidBath) {
							TEFluidBath tef = (TEFluidBath) te;
							return tef.getFluidColor();
						}
					}else {
						if(state.get(BlockFluidBath.FLUID) == BathFluid.lava) {
							return 0xcb3d07;
						}else {
							return BiomeColors.getWaterColor(reader, pos);
						}
					}
					
				}
				
				return 0xffffff;
			}
		}, getBlock("fluid_bath"));

 

...

Link to comment
Share on other sites

I've confirmed the client is receiving the data packet containing the color code as expected and at the correct time, however it is not being translated to the color of the water in the basin.

@Override
		public void onDataPacket(NetworkManager net, SUpdateTileEntityPacket pkt) {
			super.onDataPacket(net, pkt);
			System.out.println("[DEBUG] Received data packet: " + pkt.getNbtCompound().getInt("assemblylinemachines:fluidcolor"));
			handleUpdateTag(pkt.getNbtCompound());
		}
[m[32m[20:59:08] [Render thread/INFO] [STDOUT/]: [me.haydenb.assemblylinemachines.block.BlockFluidBath$TEFluidBath:onDataPacket:300]: [DEBUG] Received data packet: 11597296

 

...

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.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



×
×
  • Create New...

Important Information

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