-
Posts
22 -
Joined
-
Last visited
Recent Profile Visitors
1489 profile views
Def Daemon's Achievements

Tree Puncher (2/8)
0
Reputation
-
[SOLVED] Redstone Signal and Block Properties
Def Daemon replied to Def Daemon's topic in Modder Support
Well changed the code into this and it works like a charm....thnx m8.... up to the fun part (BlockEntity) @Override public void neighborChanged(BlockState pState, Level pLevel, BlockPos pPos, Block pBlock, BlockPos pFromPos, boolean pIsMoving) { if (!pLevel.isClientSide) { boolean flag = pState.getValue(POWERED); if (flag != pLevel.hasNeighborSignal(pPos)) { if (flag) { pLevel.scheduleTick(pPos, this, 4); } else { pLevel.setBlock(pPos, pState.cycle(POWERED), 2); } } } UpdateCurrentState(pLevel, pState, pPos); } private void UpdateCurrentState(Level pLevel, BlockState pState, BlockPos pPos) { if(!pLevel.hasNeighborSignal(pPos)) { pState.setValue(LIT, false); } } public void tick(BlockState pState, ServerLevel pLevel, BlockPos pPos, Random pRand) { if (pState.getValue(POWERED) && !pLevel.hasNeighborSignal(pPos)) { pLevel.setBlock(pPos, pState.cycle(POWERED), 2); } UpdateCurrentState(pLevel, pState, pPos); } -
[SOLVED] Redstone Signal and Block Properties
Def Daemon replied to Def Daemon's topic in Modder Support
My code is now at https://github.com/DefDaemon/Extreme_Survival -
[SOLVED] Redstone Signal and Block Properties
Def Daemon replied to Def Daemon's topic in Modder Support
Well I added the following code, it doesn't change anything... What does cycle() actually do? public void tick(BlockState pState, ServerLevel pLevel, BlockPos pPos, Random pRand) { if (pState.getValue(POWERED) && !pLevel.hasNeighborSignal(pPos)) { pLevel.setBlock(pPos, pState.cycle(POWERED), 2); } } -
Hallo all I'm trying to create a machine that works on redstone signal. The basis block contains three properties; FACING, LIT and POWERED. The idea is that this machine can only work when connected to a redstone signal so I'm using hasNeighborSignal() (in the NeighborChanged() method) to find out if there's a redstone signal. I'm using the code found in the RedstoneLampBlock class (changed LIT into POWERED of course), but the POWERED property won't change. 1. What am I doing wrong? 2. Can anyone explain the pState.cycle() method? No idea what it really does. Here's my code: public class AlloyMixerBlock extends BaseEntityBlock { public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING; public static final BooleanProperty POWERED = BlockStateProperties.POWERED; public static final BooleanProperty LIT = BlockStateProperties.LIT; public AlloyMixerBlock(Properties properties) { super(properties); this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(POWERED, Boolean.valueOf(false)).setValue(LIT, Boolean.valueOf(false))); } @Override public InteractionResult use(BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer, InteractionHand pHand, BlockHitResult pHit) { if (!pLevel.isClientSide()) { BlockEntity entity = pLevel.getBlockEntity(pPos); if(entity instanceof AlloyMixerBlockEntity) { NetworkHooks.openGui(((ServerPlayer)pPlayer), (AlloyMixerBlockEntity)entity, pPos); } else { throw new IllegalStateException("Our Container provider is missing!"); } } return InteractionResult.sidedSuccess(pLevel.isClientSide()); } @Override public BlockState getStateForPlacement(BlockPlaceContext pContext) { return this.defaultBlockState().setValue(POWERED, Boolean.valueOf(pContext.getLevel().hasNeighborSignal(pContext.getClickedPos()))).setValue(FACING, pContext.getHorizontalDirection().getOpposite()).setValue(LIT, Boolean.valueOf(false)); } @Override public BlockState rotate(BlockState pState, Rotation pRotation) { return pState.setValue(FACING, pRotation.rotate(pState.getValue(FACING))); } @Override public BlockState mirror(BlockState pState, Mirror pMirror) { return pState.rotate(pMirror.getRotation(pState.getValue(FACING))); } @Override protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> pBuilder) { pBuilder.add(FACING, POWERED, LIT); } @Override public RenderShape getRenderShape(BlockState pState) { return RenderShape.MODEL; } @Override public void onRemove(BlockState pState, Level pLevel, BlockPos pPos, BlockState pNewState, boolean pIsMoving) { if (pState.getBlock() != pNewState.getBlock()) { BlockEntity blockEntity = pLevel.getBlockEntity(pPos); if (blockEntity instanceof AlloyMixerBlockEntity) { ((AlloyMixerBlockEntity) blockEntity).drops(); } } super.onRemove(pState, pLevel, pPos, pNewState, pIsMoving); } @Nullable @Override public BlockEntity newBlockEntity(BlockPos pPos, BlockState pState) { return new AlloyMixerBlockEntity(pPos, pState); } @Override public void neighborChanged(BlockState pState, Level pLevel, BlockPos pPos, Block pBlock, BlockPos pFromPos, boolean pIsMoving) { ShowCurrentState("Before NeighborChanged:", pLevel, pState, pPos); if (!pLevel.isClientSide) { boolean flag = pState.getValue(POWERED); if (flag != pLevel.hasNeighborSignal(pPos)) { if (flag) { Extreme_Survival.LOGGER.info("Flag != hasNeighborSignal and Flag = true"); pLevel.scheduleTick(pPos, this, 4); } else { Extreme_Survival.LOGGER.info("Flag != hasNeighborSignal and Flag = false"); pLevel.setBlock(pPos, pState.cycle(POWERED), 2); } } else { Extreme_Survival.LOGGER.info("Flag equals pState"); } } else { Extreme_Survival.LOGGER.info("Clientside!!!"); } ShowCurrentState("After NeighborChanged:", pLevel, pState, pPos); } // Just for debugging! private void ShowCurrentState(String title, Level pLevel, BlockState pState, BlockPos pPos) { Extreme_Survival.LOGGER.info(title); Extreme_Survival.LOGGER.info("======================================"); Extreme_Survival.LOGGER.info("hasSignal: " + pLevel.hasNeighborSignal(pPos)); Extreme_Survival.LOGGER.info("POWERED : " + pState.getValue(POWERED)); Extreme_Survival.LOGGER.info("LIT : " + pState.getValue(LIT)); Extreme_Survival.LOGGER.info("--------------------------------------"); if (!pState.getValue(POWERED)) { pLevel.setBlock(pPos, pState.setValue(LIT, Boolean.valueOf(false)), 2); } Extreme_Survival.LOGGER.info("hasSignal: " + pLevel.hasNeighborSignal(pPos)); Extreme_Survival.LOGGER.info("POWERED : " + pState.getValue(POWERED)); Extreme_Survival.LOGGER.info("LIT : " + pState.getValue(LIT)); Extreme_Survival.LOGGER.info("======================================"); } }
-
Ah....this is exactly what I need..... thank you very much 😄
-
Okay got that, but what about other events? What if I want to check if a player is entering a new biome? Should I use Player TickEvent to compare the old biome value with current biome value (if there is even such a thing)? Thnx for helping me out but I need in depth information about MC and Forge events
-
Hello For my mod I need to get more familiar with events (which events are supported by MC and Forge) and time management (how day and night are working, are there events which I can use etc.) in MC. Can anyone point out a good tutorial for me? thnx
-
Works great....thnx m8
-
I want to strip custom logs in MC 1.17.1. In version 1.16.5 I did use an accesstransformer to set the BLOCK_STRIPPING_MAP to public and non-final. In version 1.17.1 the accesstransformer doesn't work. Anyone got a solution for this issue? This is the accesstransformer: public-f net.minecraft.world.item.AxeItem field_203176_a #STRIPPABLES
-
[SOLVED] 1.17.1 Player SendBreakAnimation
Def Daemon replied to Def Daemon's topic in Modder Support
Works great....thnx m8 -
[1.17.1]Problem with rendering semi-transparent items
Def Daemon replied to Piinut's topic in Modder Support
Well...actually you have to use ItemBlockRenderTypes! -
In order to use stack.hurtAndBreak() I need a consumer so I tried a 1.16.5 one: (player) -> player.SendBreakAnimation(context.getHand())); but apperently SendBreakAnimation doesn't exist anymore in version 1.17.1. Can anyone point me into the right direction?
-
Well that did the trick...thnx m8
-
Hi guys Can anyone translate this piece of 1.15 code into 1.16.5 code? I'm wanna use this to generate custom bushes randomly in the overworld, but I can't figure this part out. biome.addFeature(DecorationStage.Decoration.VEGETAL_DECORATION, Feature.RANDOM_PATCH.withConfiguration(FeatureInit.BUSH_CONFIG).withPlacement(Placement.COUNT_MULTILAYER.configured(new FrequencyConfig(10))));
-
1. Fixed the registration for WoodenStake class...works fine now 2. Forgot to create a private variable for the soundstring. Also working fine now. thnx a lot m8