mirror of
https://github.com/barkeser2002/CatServer.git
synced 2026-09-25 01:39:52 +03:00
80 lines
3.4 KiB
Diff
80 lines
3.4 KiB
Diff
--- ../src-base/minecraft/net/minecraft/block/BlockRedstoneDiode.java
|
|
+++ ../src-work/minecraft/net/minecraft/block/BlockRedstoneDiode.java
|
|
@@ -15,6 +15,7 @@
|
|
import net.minecraft.world.World;
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
|
|
public abstract class BlockRedstoneDiode extends BlockHorizontal
|
|
{
|
|
@@ -39,12 +40,14 @@
|
|
|
|
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
|
|
{
|
|
- return worldIn.getBlockState(pos.down()).isTopSolid() ? super.canPlaceBlockAt(worldIn, pos) : false;
|
|
+ IBlockState downState = worldIn.getBlockState(pos.down());
|
|
+ return (downState.isTopSolid() || downState.getBlockFaceShape(worldIn, pos.down(), EnumFacing.UP) == BlockFaceShape.SOLID) ? super.canPlaceBlockAt(worldIn, pos) : false;
|
|
}
|
|
|
|
public boolean canBlockStay(World worldIn, BlockPos pos)
|
|
{
|
|
- return worldIn.getBlockState(pos.down()).isTopSolid();
|
|
+ IBlockState downState = worldIn.getBlockState(pos.down());
|
|
+ return downState.isTopSolid() || downState.getBlockFaceShape(worldIn, pos.down(), EnumFacing.UP) == BlockFaceShape.SOLID;
|
|
}
|
|
|
|
public void randomTick(World worldIn, BlockPos pos, IBlockState state, Random random)
|
|
@@ -59,10 +62,16 @@
|
|
|
|
if (this.isRepeaterPowered && !flag)
|
|
{
|
|
+ if (CraftEventFactory.callRedstoneChange(worldIn, pos.getX(), pos.getY(), pos.getZ(), 15, 0).getNewCurrent() != 0) {
|
|
+ return;
|
|
+ }
|
|
worldIn.setBlockState(pos, this.getUnpoweredState(state), 2);
|
|
}
|
|
else if (!this.isRepeaterPowered)
|
|
{
|
|
+ if (CraftEventFactory.callRedstoneChange(worldIn, pos.getX(), pos.getY(), pos.getZ(), 0, 15).getNewCurrent() != 15) {
|
|
+ return;
|
|
+ }
|
|
worldIn.setBlockState(pos, this.getPoweredState(state), 2);
|
|
|
|
if (!flag)
|
|
@@ -227,6 +236,8 @@
|
|
{
|
|
EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
|
|
BlockPos blockpos = pos.offset(enumfacing.getOpposite());
|
|
+ if(net.minecraftforge.event.ForgeEventFactory.onNeighborNotify(worldIn, pos, worldIn.getBlockState(pos), java.util.EnumSet.of(enumfacing.getOpposite()), false).isCanceled())
|
|
+ return;
|
|
worldIn.neighborChanged(blockpos, this, pos);
|
|
worldIn.notifyNeighborsOfStateExcept(blockpos, this, enumfacing);
|
|
}
|
|
@@ -307,6 +318,25 @@
|
|
return BlockRenderLayer.CUTOUT;
|
|
}
|
|
|
|
+ /* ======================================== FORGE START =====================================*/
|
|
+ @Override
|
|
+ public boolean rotateBlock(World world, BlockPos pos, EnumFacing axis)
|
|
+ {
|
|
+ if (super.rotateBlock(world, pos, axis))
|
|
+ {
|
|
+ IBlockState state = world.getBlockState(pos);
|
|
+ state = getUnpoweredState(state);
|
|
+ world.setBlockState(pos, state);
|
|
+
|
|
+ if (shouldBePowered(world, pos, state))
|
|
+ {
|
|
+ world.scheduleUpdate(pos, this, 1);
|
|
+ }
|
|
+ return true;
|
|
+ }
|
|
+ return false;
|
|
+ }
|
|
+
|
|
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face)
|
|
{
|
|
return face == EnumFacing.DOWN ? BlockFaceShape.SOLID : BlockFaceShape.UNDEFINED;
|