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.

Featured Replies

Posted

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"));

 

...

  • Author

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

 

...

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...

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.