Jump to content

zalasz

Members
  • Posts

    9
  • Joined

  • Last visited

Recent Profile Visitors

1737 profile views

zalasz's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. I found the problem and actually it was totally my fault, the tick method has been working the entire time but because it was static and i was declaring the variables inside of it, my if statement was always false. int i = 0, k = 0; if(i >= 60){ Log.getLogger().info(level.isClientSide ? "Client Says " : "Server Says " + Integer.toString(k++)); i = 0; } i++; That's why i wasn't getting any output from the Logger. I do apologize for the inconvenience as this was due to my lack of attention and improper testing on my behalf.
  2. Good evening, sorry for the delay but thanks to your comment i was able to confirm that the method getTicker is returning the correct thing which is my TileRitualBlock::tick. However the problem still persists, I am assuming it's because of the Generics of my tick method but im not sure. Also i found a solution for this using a lambda expression rather than the method reference but i really don't know why it does not work with the method reference.
  3. Hello, the title is pretty much self explanatory i have two classes one for the block and the other for my block entity, like mentioned in here (Forge docs). My block class has the following method @Nullable @Override public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> type) { return type == TileInit.RITUAL_BLOCK_TILE.get() ? TileRitualBlock::tick : null; } And my block entity public static <T> void tick(Level level, BlockPos pos, BlockState state, T blockEntity) { int i = 0, k = 0; if(i >= 60){ Log.getLogger().info(level.isClientSide ? "Client Says " : "Server Says " + Integer.toString(k++)); i = 0; } i++; } The getTicker is correctly referencing my static tick method inside my block entity as far as i know but i can't understand why this is not working, the code is exactly the same as in forge docs. Thanks in advance
  4. Bruh, nevermind i am just dumb because when i did the verification for some reason my brain completely erased the fact that "p_60954_" was a parameter for the lambda expression being the reason why nothing was working. Well i appreciate alot your patience, really, thank you.
  5. I have tried that before but my problem is that because my class constructor will always be called first i don't know how would i be returning different values with the blockstate from use(). I have tried the following, but obviously it would never work public static final BooleanProperty LIT = BlockStateProperties.LIT; private static int LightUp = 15; public AerialLight(Properties properties){ super(properties.sound(SoundType.WOOL).noCollission().lightLevel((p_60954_) -> { return LightUp; })); this.registerDefaultState(this.stateDefinition.any().setValue(LIT, Boolean.valueOf(true))); } @Override public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit){ if(state.getValue(LIT)){ level.setBlock(pos, state.setValue(LIT, Boolean.valueOf(false)), 3); LightUp = 0; return InteractionResult.SUCCESS; }else{ LightUp = 15; level.setBlock(pos, state.setValue(LIT, Boolean.valueOf(true)), 3); return InteractionResult.SUCCESS; } } I even tried with a verification inside lightLevel as it is a function
  6. But that would be in my block class constructor. I was wondering if i could update the lightLevel after defining it in the constructor for example: public AerialLight(Properties properties){ super(properties.sound(SoundType.WOOL).noCollission().lightLevel((p_60954_) -> { return 15; })); this.registerDefaultState(this.stateDefinition.any().setValue(LIT, Boolean.valueOf(true))); } public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit){ //Update the lightLevel here for 0 return InteractionResult.SUCCESS; } I don't know if I explained myself well😅 but is it possible?
  7. Got it, that was really confusing me haha but how do i update my block lightlevel?
  8. I thought LIT would actually light my block but apparently is just a way to verify its state my bad haha, but if lightlevel is defined in the constructor how would i then turn it off with use()? Becaus right now i can change my block state with LIT but not the lightlevel.
  9. Hi, recently i started with minecraft mod development and i was trying to lit my block but for some reason it does not seem to work. I might have forgot something but im pretty sure it was suppose to work with the piece of code below right? I know that for some of you this might seem a dumb post but i really would appreciate if someone could help me. Thanks in advance. public class AerialLight extends Block { public static final BooleanProperty LIT = BlockStateProperties.LIT; public AerialLight(Properties properties){ super(properties.sound(SoundType.WOOL).noCollission()); this.registerDefaultState(this.stateDefinition.any().setValue(LIT, Boolean.valueOf(true))); } public void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> p_48928_) { p_48928_.add(LIT); } }
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.