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.

kpGamer

Members
  • Joined

  • Last visited

  1. @Draco18s thanks for the quick response. I posted more code below. It is not a subclass of powered rail. It is an a separate item that extends Item. public class TestModItem extends Item { // shape of a powered rail, which cannot turn public static final EnumProperty<RailShape> POWERSHAPE = EnumProperty.<RailShape>create("shape", RailShape.class, new Predicate<RailShape>() { public boolean apply(RailShape p_apply_1_) { return p_apply_1_ != RailShape.NORTH_EAST && p_apply_1_ != RailShape.NORTH_WEST && p_apply_1_ != RailShape.SOUTH_EAST && p_apply_1_ != RailShape.SOUTH_WEST; } }); // powered boolean property public static final BooleanProperty POWERED = BooleanProperty.create("powered"); public TestModItem() { super(new Item.Properties().group(ModItemGroups.TestMod_GROUP)); } @Override public ActionResultType onItemUse(ItemUseContext context) { // get context World worldIn = context.getWorld(); BlockPos pos = context.getPos(); PlayerEntity player = context.getPlayer(); if(!worldIn.isRemote) { if (worldIn.getBlockState(pos).getBlock().getRegistryName().toString().equals("minecraft:powered_rail")){ BlockState blockState = worldIn.getBlockState(pos); TestMod.LOGGER.debug("** Properties:"); TestMod.LOGGER.debug(" old POWERED: " + blockState.get(POWERED)); TestMod.LOGGER.debug(" old POWERSHAPE: " + blockState.get(POWERSHAPE)); blockState = blockState.with(POWERED, true).with(POWERSHAPE, RailShape.NORTH_SOUTH); worldIn.getWorld().setBlockState(pos, blockState); worldIn.notifyBlockUpdate(pos, blockState, blockState, 3); blockState = worldIn.getWorld().getBlockState(pos); TestMod.LOGGER.debug(" new block state POWERED: " + blockState.get(POWERED)); TestMod.LOGGER.debug(" new block state POWERSHAPE: " + blockState.get(POWERSHAPE)); } return ActionResultType.PASS; } }
  2. Hello modders. I can't seem to update a boolean property on the server. I confirmed that I can update another property (enum type) for the same block. I also confirmed that I can update the block state object with the correct property before attempting to update the server. After I run setBlockState on the world object, the boolean property does not change, but the enum property does change. Can someone please tell me what I'm missing in the code below? // enum property public static final EnumProperty<RailShape> POWERSHAPE = EnumProperty.<RailShape>create("shape", RailShape.class, new Predicate<RailShape>() { public boolean apply(RailShape p_apply_1_) { return p_apply_1_ != RailShape.NORTH_EAST && p_apply_1_ != RailShape.NORTH_WEST && p_apply_1_ != RailShape.SOUTH_EAST && p_apply_1_ != RailShape.SOUTH_WEST; } }); // boolean property public static final BooleanProperty POWERED = BooleanProperty.create("powered"); @Override public ActionResultType onItemUse(ItemUseContext context) { // get context World worldIn = context.getWorld(); BlockPos pos = context.getPos(); PlayerEntity player = context.getPlayer(); if(!worldIn.isRemote) { if (worldIn.getBlockState(pos).getBlock().getRegistryName().toString().equals("minecraft:powered_rail")){ BlockState blockState = worldIn.getBlockState(pos); TestMod.LOGGER.debug("** Properties:"); TestMod.LOGGER.debug(" old POWERED: " + blockState.get(POWERED)); TestMod.LOGGER.debug(" old POWERSHAPE: " + blockState.get(POWERSHAPE)); blockState = blockState.with(POWERED, true).with(POWERSHAPE, RailShape.NORTH_SOUTH); worldIn.getWorld().setBlockState(pos, blockState); worldIn.notifyBlockUpdate(pos, blockState, blockState, 3); // check for the update blockState = worldIn.getWorld().getBlockState(pos); // Enum property is updated (POWERSHAPE), but bolean property (POWERED) was not TestMod.LOGGER.debug(" new block state POWERED: " + blockState.get(POWERED)); TestMod.LOGGER.debug(" new block state POWERSHAPE: " + blockState.get(POWERSHAPE)); } return ActionResultType.PASS; }

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.