Files
CatServer/patches/net/minecraft/block/BlockRedstoneComparator.java.patch
2019-02-24 22:29:41 +08:00

107 lines
5.8 KiB
Diff

--- ../src-base/minecraft/net/minecraft/block/BlockRedstoneComparator.java
+++ ../src-work/minecraft/net/minecraft/block/BlockRedstoneComparator.java
@@ -36,12 +36,12 @@
public class BlockRedstoneComparator extends BlockRedstoneDiode implements ITileEntityProvider
{
public static final PropertyBool POWERED = PropertyBool.create("powered");
- public static final PropertyEnum<BlockRedstoneComparator.Mode> MODE = PropertyEnum.<BlockRedstoneComparator.Mode>create("mode", BlockRedstoneComparator.Mode.class);
+ public static final PropertyEnum<Mode> MODE = PropertyEnum.<Mode>create("mode", Mode.class);
public BlockRedstoneComparator(boolean powered)
{
super(powered);
- this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(POWERED, Boolean.valueOf(false)).withProperty(MODE, BlockRedstoneComparator.Mode.COMPARE));
+ this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(POWERED, Boolean.valueOf(false)).withProperty(MODE, Mode.COMPARE));
this.hasTileEntity = true;
}
@@ -68,7 +68,7 @@
protected IBlockState getPoweredState(IBlockState unpoweredState)
{
Boolean obool = (Boolean)unpoweredState.getValue(POWERED);
- BlockRedstoneComparator.Mode blockredstonecomparator$mode = (BlockRedstoneComparator.Mode)unpoweredState.getValue(MODE);
+ Mode blockredstonecomparator$mode = (Mode)unpoweredState.getValue(MODE);
EnumFacing enumfacing = (EnumFacing)unpoweredState.getValue(FACING);
return Blocks.POWERED_COMPARATOR.getDefaultState().withProperty(FACING, enumfacing).withProperty(POWERED, obool).withProperty(MODE, blockredstonecomparator$mode);
}
@@ -76,7 +76,7 @@
protected IBlockState getUnpoweredState(IBlockState poweredState)
{
Boolean obool = (Boolean)poweredState.getValue(POWERED);
- BlockRedstoneComparator.Mode blockredstonecomparator$mode = (BlockRedstoneComparator.Mode)poweredState.getValue(MODE);
+ Mode blockredstonecomparator$mode = (Mode)poweredState.getValue(MODE);
EnumFacing enumfacing = (EnumFacing)poweredState.getValue(FACING);
return Blocks.UNPOWERED_COMPARATOR.getDefaultState().withProperty(FACING, enumfacing).withProperty(POWERED, obool).withProperty(MODE, blockredstonecomparator$mode);
}
@@ -94,7 +94,7 @@
private int calculateOutput(World worldIn, BlockPos pos, IBlockState state)
{
- return state.getValue(MODE) == BlockRedstoneComparator.Mode.SUBTRACT ? Math.max(this.calculateInputStrength(worldIn, pos, state) - this.getPowerOnSides(worldIn, pos, state), 0) : this.calculateInputStrength(worldIn, pos, state);
+ return state.getValue(MODE) == Mode.SUBTRACT ? Math.max(this.calculateInputStrength(worldIn, pos, state) - this.getPowerOnSides(worldIn, pos, state), 0) : this.calculateInputStrength(worldIn, pos, state);
}
protected boolean shouldBePowered(World worldIn, BlockPos pos, IBlockState state)
@@ -180,7 +180,7 @@
else
{
state = state.cycleProperty(MODE);
- float f = state.getValue(MODE) == BlockRedstoneComparator.Mode.SUBTRACT ? 0.55F : 0.5F;
+ float f = state.getValue(MODE) == Mode.SUBTRACT ? 0.55F : 0.5F;
worldIn.playSound(playerIn, pos, SoundEvents.BLOCK_COMPARATOR_CLICK, SoundCategory.BLOCKS, 0.3F, f);
worldIn.setBlockState(pos, state, 2);
this.onStateChange(worldIn, pos, state);
@@ -223,7 +223,7 @@
tileentitycomparator.setOutputSignal(i);
}
- if (j != i || state.getValue(MODE) == BlockRedstoneComparator.Mode.COMPARE)
+ if (j != i || state.getValue(MODE) == Mode.COMPARE)
{
boolean flag1 = this.shouldBePowered(worldIn, pos, state);
boolean flag = this.isPowered(state);
@@ -278,7 +278,7 @@
public IBlockState getStateFromMeta(int meta)
{
- return this.getDefaultState().withProperty(FACING, EnumFacing.getHorizontal(meta)).withProperty(POWERED, Boolean.valueOf((meta & 8) > 0)).withProperty(MODE, (meta & 4) > 0 ? BlockRedstoneComparator.Mode.SUBTRACT : BlockRedstoneComparator.Mode.COMPARE);
+ return this.getDefaultState().withProperty(FACING, EnumFacing.getHorizontal(meta)).withProperty(POWERED, Boolean.valueOf((meta & 8) > 0)).withProperty(MODE, (meta & 4) > 0 ? Mode.SUBTRACT : Mode.COMPARE);
}
public int getMetaFromState(IBlockState state)
@@ -291,7 +291,7 @@
i |= 8;
}
- if (state.getValue(MODE) == BlockRedstoneComparator.Mode.SUBTRACT)
+ if (state.getValue(MODE) == Mode.SUBTRACT)
{
i |= 4;
}
@@ -316,9 +316,24 @@
public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
- return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()).withProperty(POWERED, Boolean.valueOf(false)).withProperty(MODE, BlockRedstoneComparator.Mode.COMPARE);
+ return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()).withProperty(POWERED, Boolean.valueOf(false)).withProperty(MODE, Mode.COMPARE);
}
+ @Override
+ public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos neighbor)
+ {
+ if (pos.getY() == neighbor.getY() && world instanceof World && !((World) world).isRemote)
+ {
+ neighborChanged(world.getBlockState(pos), (World)world, pos, world.getBlockState(neighbor).getBlock(), neighbor);
+ }
+ }
+
+ @Override
+ public boolean getWeakChanges(IBlockAccess world, BlockPos pos)
+ {
+ return true;
+ }
+
public static enum Mode implements IStringSerializable
{
COMPARE("compare"),