MCreator 2020.2 need help emitting redstone power from NBT tag

Started by Cancerous Cactus on

Topic category: Help with Minecraft modding (Java Edition)

Joined May 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
MCreator 2020.2 need help emitting redstone power from NBT tag

I am making a redstone mod, and in this mod, I have a block (floating redstone) that needs to be able to emit a redstone signal according to an NBT tag. Keep in mind, I am making this for Minecraft 1.12.2, so I am using Mcreator version 2020.2. I have found code on a different MCreator forum (https://mcreator.net/forum/70799/i-need-some-java-code-make-my-block-emit-redstone) that gives Java that is said to do this. After putting this into my block class, I have fixed multiple errors in the code; however, the block does not emit redstone. I have checked, the NBT tag is not the problem. Here is the code that I added to my block:

public int getWeakPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos) {
           TileEntity _tileEntity = world.getTileEntity(pos);
           int _powerLevel = 0;
           if(_tileEntity != null) {
               _powerLevel = Math.round((int) _tileEntity.getTileData().getDouble("spreadPower"));
           }
           return _powerLevel;
        }
        public boolean canProvidePower() {
            return true;
        }

Any help is very much appreciated.