Attempt to fix the Redstone block implementation
This commit is contained in:
parent
7bbafe58fe
commit
29245e45cf
3 changed files with 24 additions and 4 deletions
|
@ -53,7 +53,7 @@ mod_name=Zontreck's Library Mod
|
|||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||
mod_license=GPLv3
|
||||
# The mod version. See https://semver.org/
|
||||
mod_version=1201.13.043024.0139
|
||||
mod_version=1201.13.043024.0247
|
||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
||||
# This should match the base package used for the mod sources.
|
||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
|
|
|
@ -7,8 +7,6 @@ import net.minecraft.world.level.BlockGetter;
|
|||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.DiodeBlock;
|
||||
import net.minecraft.world.level.block.PoweredBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||
|
@ -59,6 +57,15 @@ public abstract class RedstoneBlock extends RotatableBlock
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void neighborChanged(BlockState state, Level level, BlockPos pos, Block block, BlockPos other, boolean unknown) {
|
||||
onRedstone(level, pos, redstoneIsActivated(level, pos));
|
||||
state.setValue(INPUT_POWER, redstoneIsActivated(level, pos));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onPlace(BlockState state, Level level, BlockPos pos, BlockState p_60569_, boolean p_60570_) {
|
||||
onRedstone(level, pos, redstoneIsActivated(level, pos));
|
||||
state.setValue(INPUT_POWER, redstoneIsActivated(level, pos));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ package dev.zontreck.libzontreck.blocks;
|
|||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
|
||||
import net.minecraft.world.level.block.Mirror;
|
||||
import net.minecraft.world.level.block.Rotation;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
|
||||
|
@ -19,6 +21,17 @@ public class RotatableBlock extends HorizontalDirectionalBlock
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BlockState rotate(BlockState p_55115_, Rotation p_55116_) {
|
||||
return p_55115_.setValue(FACING, p_55116_.rotate(p_55115_.getValue(FACING)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState mirror(BlockState p_55112_, Mirror p_55113_) {
|
||||
return p_55112_.rotate(p_55113_.getRotation(p_55112_.getValue(FACING)));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext pContext) {
|
||||
return defaultBlockState().setValue(FACING, pContext.getHorizontalDirection());
|
||||
|
|
Reference in a new issue