matt1999rd
-
Posts
133 -
Joined
-
Last visited
Posts posted by matt1999rd
-
-
11 minutes ago, diesieben07 said:
You are now checking for client-side.
What on earth is this?
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; } }
-
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..
-
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.
-
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.
creating item that change the state of a block
in Modder Support
Posted
I'm checking the name of the property to know what will be the next state of the block.