Posted September 13, 20187 yr Hello, how I can update the current light level?...This is my code: @SubscribeEvent public void NearUraniumEvent(PlayerEvent event) { int blockX = event.entityPlayer.getPosition().getX(); int blockY = event.entityPlayer.getPosition().down().getY(); int blockZ = event.entityPlayer.getPosition().getZ(); BlockPos pos = new BlockPos(blockX, blockY, blockZ); Block block = event.entityPlayer.worldObj.getBlockState(pos).getBlock(); if(block == NukeMod.uranium_grass) { System.out.println("Uranium_grass down!"); event.entityPlayer.worldObj.getBlockState(pos).getBlock().setLightLevel(1.0F); }else { event.entityPlayer.worldObj.getBlockState(pos).getBlock().setLightLevel(0.0F); } int light = event.entityPlayer.worldObj.getBlockState(pos).getBlock().getLightValue(); System.out.println("Light: " + light); } The light value changes correctly (There is the print in console...), but I don't know hoe to refresh the block Help me please.
September 14, 20187 yr that you cannot, is one thing. first, let me explain what you tried to do. (later we'll see what you may have wanted to do.) getBlock() returns a Block - but not an individual instance (as seen by player). object that you have there represents all blocks in the world of the same type (including variations, for example wooden log orientation and before 1.13 wood types). now if you change its hardness, resistance, light level (if you manage to), inside the game that would affect ALL blocks of the same type, anywhere in the world. in other words, not what you want. i hope. but what is it that you want to do? different blockstates of the same block can have different light intensities. if that is what you want, just do SetBlockState() to change your block to the correct/new state. for the last parameter put 3 (or was it 11? can't remember. let's go with 3), one of those two flags (inside "3") tells the game to update what the players see).
September 14, 20187 yr Author OK, so I will use setBlockState, but it requiers an IBlockState, that must have the Block state ( setBlockState(pos, IBlockState, 3); ) ...how can I set Light Level by using this? Edited September 14, 20187 yr by progamergalil
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.