This will never be true. == compares object identity. You want equals.
I would also refrain from using the name item for this scope variable, as it looks like it refers to an Item (due to the nearby Block newItemBlock = newItem.getBlock();line) but is in fact a BlockPos. I would use pos, loc, location, or point, or similar.
Solved! Thanks for your clarification and help. I will also look at the IBlockState Interface. Also, it's working!
@SubscribeEvent
public void onPlayerTickEvent(PlayerTickEvent event) {
if(event.player instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.player;
BlockPos playerUPos = player.getPosition().down();
IBlockState playerUState = player.world.getBlockState(playerUPos);
if (player.onGround && player.world.getBlockState(playerUPos).getBlock() == Blocks.GRASS) {
player.world.setBlockState(playerUPos, Blocks.STONE.getDefaultState());
}
}
}
Yes, that is the general idea. There is actually a PlayerTickEvent which is a bit more specific, which I prefer because it is a bit wasteful to call your method for every living entity, but since you test immediately for player it probably isn't a bit deal.
I don't think your methods for checking the block and setting the block are quite right. It looks like you're trying to directly cast the position into the block state. Instead you should use the player world (player.world) and use the getBlockState() method.
Also generally shouldn't compare to the default state. It would work for grass because I think it doesn't have any properties, but I'd probably do it like this:
if (player.onGround && player.world.getBlockState(playerUPos).getBlock() == Blocks.GRASS))
and to set the block something like:
player.world.setBlockState(Blocks.STONE.getDefaultState())