mirror of
https://github.com/barkeser2002/CatServer.git
synced 2026-09-25 02:20:01 +03:00
159 lines
9.0 KiB
Diff
159 lines
9.0 KiB
Diff
--- ../src-base/minecraft/net/minecraft/block/BlockRedstoneWire.java
|
|
+++ ../src-work/minecraft/net/minecraft/block/BlockRedstoneWire.java
|
|
@@ -31,13 +31,14 @@
|
|
import net.minecraft.world.World;
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
+import org.bukkit.event.block.BlockRedstoneEvent;
|
|
|
|
public class BlockRedstoneWire extends Block
|
|
{
|
|
- public static final PropertyEnum<BlockRedstoneWire.EnumAttachPosition> NORTH = PropertyEnum.<BlockRedstoneWire.EnumAttachPosition>create("north", BlockRedstoneWire.EnumAttachPosition.class);
|
|
- public static final PropertyEnum<BlockRedstoneWire.EnumAttachPosition> EAST = PropertyEnum.<BlockRedstoneWire.EnumAttachPosition>create("east", BlockRedstoneWire.EnumAttachPosition.class);
|
|
- public static final PropertyEnum<BlockRedstoneWire.EnumAttachPosition> SOUTH = PropertyEnum.<BlockRedstoneWire.EnumAttachPosition>create("south", BlockRedstoneWire.EnumAttachPosition.class);
|
|
- public static final PropertyEnum<BlockRedstoneWire.EnumAttachPosition> WEST = PropertyEnum.<BlockRedstoneWire.EnumAttachPosition>create("west", BlockRedstoneWire.EnumAttachPosition.class);
|
|
+ public static final PropertyEnum<EnumAttachPosition> NORTH = PropertyEnum.<EnumAttachPosition>create("north", EnumAttachPosition.class);
|
|
+ public static final PropertyEnum<EnumAttachPosition> EAST = PropertyEnum.<EnumAttachPosition>create("east", EnumAttachPosition.class);
|
|
+ public static final PropertyEnum<EnumAttachPosition> SOUTH = PropertyEnum.<EnumAttachPosition>create("south", EnumAttachPosition.class);
|
|
+ public static final PropertyEnum<EnumAttachPosition> WEST = PropertyEnum.<EnumAttachPosition>create("west", EnumAttachPosition.class);
|
|
public static final PropertyInteger POWER = PropertyInteger.create("power", 0, 15);
|
|
protected static final AxisAlignedBB[] REDSTONE_WIRE_AABB = new AxisAlignedBB[] {new AxisAlignedBB(0.1875D, 0.0D, 0.1875D, 0.8125D, 0.0625D, 0.8125D), new AxisAlignedBB(0.1875D, 0.0D, 0.1875D, 0.8125D, 0.0625D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.1875D, 0.8125D, 0.0625D, 0.8125D), new AxisAlignedBB(0.0D, 0.0D, 0.1875D, 0.8125D, 0.0625D, 1.0D), new AxisAlignedBB(0.1875D, 0.0D, 0.0D, 0.8125D, 0.0625D, 0.8125D), new AxisAlignedBB(0.1875D, 0.0D, 0.0D, 0.8125D, 0.0625D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.8125D, 0.0625D, 0.8125D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.8125D, 0.0625D, 1.0D), new AxisAlignedBB(0.1875D, 0.0D, 0.1875D, 1.0D, 0.0625D, 0.8125D), new AxisAlignedBB(0.1875D, 0.0D, 0.1875D, 1.0D, 0.0625D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.1875D, 1.0D, 0.0625D, 0.8125D), new AxisAlignedBB(0.0D, 0.0D, 0.1875D, 1.0D, 0.0625D, 1.0D), new AxisAlignedBB(0.1875D, 0.0D, 0.0D, 1.0D, 0.0625D, 0.8125D), new AxisAlignedBB(0.1875D, 0.0D, 0.0D, 1.0D, 0.0625D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.0625D, 0.8125D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.0625D, 1.0D)};
|
|
private boolean canProvidePower = true;
|
|
@@ -46,7 +47,7 @@
|
|
public BlockRedstoneWire()
|
|
{
|
|
super(Material.CIRCUITS);
|
|
- this.setDefaultState(this.blockState.getBaseState().withProperty(NORTH, BlockRedstoneWire.EnumAttachPosition.NONE).withProperty(EAST, BlockRedstoneWire.EnumAttachPosition.NONE).withProperty(SOUTH, BlockRedstoneWire.EnumAttachPosition.NONE).withProperty(WEST, BlockRedstoneWire.EnumAttachPosition.NONE).withProperty(POWER, Integer.valueOf(0)));
|
|
+ this.setDefaultState(this.blockState.getBaseState().withProperty(NORTH, EnumAttachPosition.NONE).withProperty(EAST, EnumAttachPosition.NONE).withProperty(SOUTH, EnumAttachPosition.NONE).withProperty(WEST, EnumAttachPosition.NONE).withProperty(POWER, Integer.valueOf(0)));
|
|
}
|
|
|
|
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
|
|
@@ -57,10 +58,10 @@
|
|
private static int getAABBIndex(IBlockState state)
|
|
{
|
|
int i = 0;
|
|
- boolean flag = state.getValue(NORTH) != BlockRedstoneWire.EnumAttachPosition.NONE;
|
|
- boolean flag1 = state.getValue(EAST) != BlockRedstoneWire.EnumAttachPosition.NONE;
|
|
- boolean flag2 = state.getValue(SOUTH) != BlockRedstoneWire.EnumAttachPosition.NONE;
|
|
- boolean flag3 = state.getValue(WEST) != BlockRedstoneWire.EnumAttachPosition.NONE;
|
|
+ boolean flag = state.getValue(NORTH) != EnumAttachPosition.NONE;
|
|
+ boolean flag1 = state.getValue(EAST) != EnumAttachPosition.NONE;
|
|
+ boolean flag2 = state.getValue(SOUTH) != EnumAttachPosition.NONE;
|
|
+ boolean flag3 = state.getValue(WEST) != EnumAttachPosition.NONE;
|
|
|
|
if (flag || flag2 && !flag && !flag1 && !flag3)
|
|
{
|
|
@@ -94,35 +95,35 @@
|
|
return state;
|
|
}
|
|
|
|
- private BlockRedstoneWire.EnumAttachPosition getAttachPosition(IBlockAccess worldIn, BlockPos pos, EnumFacing direction)
|
|
+ private EnumAttachPosition getAttachPosition(IBlockAccess worldIn, BlockPos pos, EnumFacing direction)
|
|
{
|
|
BlockPos blockpos = pos.offset(direction);
|
|
IBlockState iblockstate = worldIn.getBlockState(pos.offset(direction));
|
|
|
|
- if (!canConnectTo(worldIn.getBlockState(blockpos), direction) && (iblockstate.isNormalCube() || !canConnectUpwardsTo(worldIn.getBlockState(blockpos.down()))))
|
|
+ if (!canConnectTo(worldIn.getBlockState(blockpos), direction, worldIn, blockpos) && (iblockstate.isNormalCube() || !canConnectUpwardsTo(worldIn, blockpos.down())))
|
|
{
|
|
IBlockState iblockstate1 = worldIn.getBlockState(pos.up());
|
|
|
|
if (!iblockstate1.isNormalCube())
|
|
{
|
|
- boolean flag = worldIn.getBlockState(blockpos).isTopSolid() || worldIn.getBlockState(blockpos).getBlock() == Blocks.GLOWSTONE;
|
|
+ boolean flag = worldIn.getBlockState(blockpos).isSideSolid(worldIn, blockpos, EnumFacing.UP) || worldIn.getBlockState(blockpos).getBlock() == Blocks.GLOWSTONE;
|
|
|
|
- if (flag && canConnectUpwardsTo(worldIn.getBlockState(blockpos.up())))
|
|
+ if (flag && canConnectUpwardsTo(worldIn, blockpos.up()))
|
|
{
|
|
if (iblockstate.isBlockNormalCube())
|
|
{
|
|
- return BlockRedstoneWire.EnumAttachPosition.UP;
|
|
+ return EnumAttachPosition.UP;
|
|
}
|
|
|
|
- return BlockRedstoneWire.EnumAttachPosition.SIDE;
|
|
+ return EnumAttachPosition.SIDE;
|
|
}
|
|
}
|
|
|
|
- return BlockRedstoneWire.EnumAttachPosition.NONE;
|
|
+ return EnumAttachPosition.NONE;
|
|
}
|
|
else
|
|
{
|
|
- return BlockRedstoneWire.EnumAttachPosition.SIDE;
|
|
+ return EnumAttachPosition.SIDE;
|
|
}
|
|
}
|
|
|
|
@@ -144,7 +145,8 @@
|
|
|
|
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
|
|
{
|
|
- return worldIn.getBlockState(pos.down()).isTopSolid() || worldIn.getBlockState(pos.down()).getBlock() == Blocks.GLOWSTONE;
|
|
+ IBlockState downState = worldIn.getBlockState(pos.down());
|
|
+ return downState.isTopSolid() || downState.getBlockFaceShape(worldIn, pos.down(), EnumFacing.UP) == BlockFaceShape.SOLID || worldIn.getBlockState(pos.down()).getBlock() == Blocks.GLOWSTONE;
|
|
}
|
|
|
|
private IBlockState updateSurroundingRedstone(World worldIn, BlockPos pos, IBlockState state)
|
|
@@ -219,6 +221,12 @@
|
|
j = k;
|
|
}
|
|
|
|
+ if (i != j) {
|
|
+ BlockRedstoneEvent event = new BlockRedstoneEvent(worldIn.getWorld().getBlockAt(pos1.getX(), pos1.getY(), pos1.getZ()), i, j);
|
|
+ worldIn.getServer().getPluginManager().callEvent(event);
|
|
+ j = event.getNewCurrent();
|
|
+ }
|
|
+
|
|
if (i != j)
|
|
{
|
|
state = state.withProperty(POWER, Integer.valueOf(j));
|
|
@@ -318,7 +326,7 @@
|
|
}
|
|
}
|
|
|
|
- private int getMaxCurrentStrength(World worldIn, BlockPos pos, int strength)
|
|
+ public int getMaxCurrentStrength(World worldIn, BlockPos pos, int strength)
|
|
{
|
|
if (worldIn.getBlockState(pos).getBlock() != this)
|
|
{
|
|
@@ -414,7 +422,7 @@
|
|
{
|
|
return true;
|
|
}
|
|
- else if (canConnectTo(iblockstate, side))
|
|
+ else if (canConnectTo(iblockstate, side, worldIn, pos))
|
|
{
|
|
return true;
|
|
}
|
|
@@ -430,16 +438,11 @@
|
|
|
|
protected static boolean canConnectUpwardsTo(IBlockAccess worldIn, BlockPos pos)
|
|
{
|
|
- return canConnectUpwardsTo(worldIn.getBlockState(pos));
|
|
+ return canConnectTo(worldIn.getBlockState(pos), null, worldIn, pos);
|
|
}
|
|
|
|
- protected static boolean canConnectUpwardsTo(IBlockState state)
|
|
+ protected static boolean canConnectTo(IBlockState blockState, @Nullable EnumFacing side, IBlockAccess world, BlockPos pos)
|
|
{
|
|
- return canConnectTo(state, (EnumFacing)null);
|
|
- }
|
|
-
|
|
- protected static boolean canConnectTo(IBlockState blockState, @Nullable EnumFacing side)
|
|
- {
|
|
Block block = blockState.getBlock();
|
|
|
|
if (block == Blocks.REDSTONE_WIRE)
|
|
@@ -457,7 +460,7 @@
|
|
}
|
|
else
|
|
{
|
|
- return blockState.canProvidePower() && side != null;
|
|
+ return blockState.getBlock().canConnectRedstone(blockState, world, pos, side);
|
|
}
|
|
}
|
|
|