FREyebeans2506 Posted December 14, 2021 Posted December 14, 2021 i have tried several things to get it to change when the day changes to night i can only get it to be lit up if i place it at night package com.freyebeans2506.faltthethe.contentfeatures.blocks; import net.minecraft.block.BedBlock; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.fluid.Fluids; import net.minecraft.item.BlockItemUseContext; import net.minecraft.state.BooleanProperty; import net.minecraft.state.StateContainer; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IWorld; import net.minecraft.world.LightType; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; import javax.annotation.Nullable; import java.util.Random; public class ABBlock extends Block { public static final BooleanProperty LIT = BlockStateProperties.LIT; public ABBlock(Properties properties) { super(properties); this.registerDefaultState(this.stateDefinition.any().setValue(LIT, Boolean.valueOf(false))); } @Nullable public BlockState getStateForPlacement(BlockItemUseContext p_196258_1_) { return this.defaultBlockState().setValue(LIT, Boolean.valueOf(p_196258_1_.getLevel().isNight())); } protected void createBlockStateDefinition(StateContainer.Builder<Block, BlockState> p_206840_1_) { p_206840_1_.add(LIT); } } this has been causing me pain for the past 3 hours Quote
Luis_ST Posted December 14, 2021 Posted December 14, 2021 you need to update the Block, since you only set the State when you place it Quote
Draco18s Posted December 14, 2021 Posted December 14, 2021 Hint: take a look at the daylight sensor. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
FREyebeans2506 Posted December 15, 2021 Author Posted December 15, 2021 21 hours ago, Draco18s said: Hint: take a look at the daylight sensor. could you elaborate Quote
Draco18s Posted December 15, 2021 Posted December 15, 2021 This block surely has code you can look at, yeah? Go look at it. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
American2050 Posted December 15, 2021 Posted December 15, 2021 10 hours ago, FREyebeans2506 said: could you elaborate On your IDE you probably have a folder called "External Libraries" on your project tree. In there you can find among a whole lot of other things, one folder that in particular may come handy. For example for 1.17.1 (Should be similar if not the same for 1.16.5) Gradle: net.minecraftforge:forge:1.17.1:37.1.1_mapped_official_1.17.1 (For 1.16.5 the name will change a little bit of course) When you open this tree you will find net > minecraft > level > world > block > DaylightDetectorBlock In there you can take a look at it's code to see what this block is doing in order to detect when it's daylight and when it's not. Haven't been doing MC modding in a time, but I guess this block been that it extends an entity block, it "ticks" and so has this method where the "magic" happens. tickEntity Quote
American2050 Posted December 15, 2021 Posted December 15, 2021 1 minute ago, diesieben07 said: Or... you know... Use the "go to class" feature that any IDE has. I need to learn all those shortcuts. Will take a look at that, didn't know what it was called, but yes, for sure comes way more handy that trying to figure out where a class exists. Quote
Draco18s Posted December 15, 2021 Posted December 15, 2021 I tend to forget that one, but do remember F4, which opens the type hierarchy for a focused Type, and if I know that I'm looking for a block (or PlayerEvent, or whatever), I can quickly make a variable and F4 it and browse. 1 Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
FREyebeans2506 Posted January 4, 2022 Author Posted January 4, 2022 On 12/14/2021 at 9:17 PM, Draco18s said: This block surely has code you can look at, yeah? Go look at it. thank you it worked Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.