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.

matt1999rd

Members
  • Joined

  • Last visited

Everything posted by matt1999rd

  1. I'm checking the name of the property to know what will be the next state of the block.
  2. I will give the full definition of this : protected static EnumProperty<Corners> SWITCH_POSITION ; static { SWITCH_POSITION = EnumProperty.create("switch_position",Corners.class,(corner)-> { return (corner == Corners.STRAIGHT || corner == Corners.TURN); }); } here is the definition of my EnumProperty It use the class enum called Corners as used in the BlockStateProperty And here is the Corners class : public enum Corners implements IStringSerializable { TURN(0,"turn"), STRAIGHT(1,"straight"), TURN_LEFT(2,"turn_left"), TURN_RIGHT(3,"turn_right"); private final int meta ; private final String name; private Corners(int meta, String name) { this.meta=meta; this.name=name; } @Override public String getName() { return this.name; } }
  3. I'm new in this forum and of what I know item is something that exist in only one material like cobblestone or iron_bar. The tag is specified for blocks like planks that has variants on oak_wood, dark_oak_wood, and so on... If you look at barrel.json in the recipe directory you will see that tag is specified for planks and wooden_slab this mean that you can use any wooden_slab or any plnks to craft it hope you've understand..
  4. Thanks for advice I've corrected my code and here is the new method updatePoweredState : public void updatePoweredState(World world, BlockState state, BlockPos pos, int flags) { if (world.isRemote){ boolean isPowered = state.get(SWITCH_POSITION).getName().equals("turn"); System.out.println(isPowered); if (isPowered){ world.setBlockState(pos,state.with(SWITCH_POSITION,Corners.TURN)); }else { world.setBlockState(pos,state.with(SWITCH_POSITION,Corners.STRAIGHT)); } System.out.println(state.get(SWITCH_POSITION)); } } I'm using a proper EnumProperty for my block based on enum called Corners which contains these two attributes. But it's unfortunately not working because every time I use my item to change the blockstate from Corners.STRAIGHT to Corners.TURN something is changing to Corners.STRAIGHT again one tick after and I don't know where I can block this action. Another strange action is when some block are nearby this actually change the RailShape properties.
  5. Hello everyone, For a 1.14 mod, I try to create an item that change the state of a block. To do that I'm using setBlockState method of World object. The code for doing this use a variable that confirmed that the rest of the code is working well. As I search into setBlockState method I find these lines : /** * Sets a block state into this world.Flags are as follows: * 1 will cause a block update. * 2 will send the change to clients. * 4 will prevent the block from being re-rendered. * 8 will force any re-renders to run on the main thread instead * 16 will prevent neighbor reactions (e.g. fences connecting, observers pulsing). * 32 will prevent neighbor reactions from spawning drops. * 64 will signify the block is being moved. * Flags can be OR-ed */ I think this may change the behaviour but I try for the flag that match the best what I wanted and I trye for 7 and 11 but none of them changes the behaviour. Here is the method where I use the method setBlockState : private void updatePoweredState(World world, BlockState state,BlockPos pos,BlockState oldState) { isPowered = !isPowered; if (isPowered){ System.out.println("etat du block : turn"); world.setBlockState(pos,state.with(SWITCH_POSITION,Corners.TURN),flags); }else { System.out.println("etat du block : straight"); world.setBlockState(pos,state.with(SWITCH_POSITION,Corners.STRAIGHT),flags); } } flags has the value 7 or 11. what the code is doing is changing the state switchposition and then almost instantly changing the state to the previous one.

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.