diff --git a/src/main/java/com/joshiegemfinder/betweenlandsredstone/blocks/BlockCrafter.java b/src/main/java/com/joshiegemfinder/betweenlandsredstone/blocks/BlockCrafter.java index 20fca97..c7f2382 100644 --- a/src/main/java/com/joshiegemfinder/betweenlandsredstone/blocks/BlockCrafter.java +++ b/src/main/java/com/joshiegemfinder/betweenlandsredstone/blocks/BlockCrafter.java @@ -244,7 +244,7 @@ public IBlockState withMirror(IBlockState state, Mirror mirrorIn) @Override public boolean eventReceived(IBlockState state, World world, BlockPos pos, int id, int param) { - if(id == 9002) { + if(id == 92) { EnumFacing facing = world.getBlockState(pos).getValue(FACING); shootParticles(facing, world, pos); return true; diff --git a/src/main/java/com/joshiegemfinder/betweenlandsredstone/blocks/BlockScabystObserver.java b/src/main/java/com/joshiegemfinder/betweenlandsredstone/blocks/BlockScabystObserver.java index 62ed3c0..d56a3e1 100644 --- a/src/main/java/com/joshiegemfinder/betweenlandsredstone/blocks/BlockScabystObserver.java +++ b/src/main/java/com/joshiegemfinder/betweenlandsredstone/blocks/BlockScabystObserver.java @@ -1,10 +1,16 @@ package com.joshiegemfinder.betweenlandsredstone.blocks; +import java.util.Random; + import com.joshiegemfinder.betweenlandsredstone.BetweenlandsRedstone; import com.joshiegemfinder.betweenlandsredstone.ModBlocks; import net.minecraft.block.BlockObserver; +import net.minecraft.block.state.IBlockState; +import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; public class BlockScabystObserver extends BlockObserver { @@ -15,7 +21,32 @@ public BlockScabystObserver(String name) { this.setUnlocalizedName(name); this.setRegistryName(new ResourceLocation(BetweenlandsRedstone.MODID, name)); + if(this.getDefaultState().getBlock() != this) { + this.setDefaultState(this.getBlockState().getBaseState().withProperty(FACING, EnumFacing.SOUTH).withProperty(POWERED, Boolean.valueOf(false))); + } ModBlocks.BLOCKS.add(this); } + + @Override + public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) + { + super.updateTick(worldIn, pos, state, rand); + + // Neighbour updates could've changed the block + IBlockState newState = worldIn.getBlockState(pos); + if(newState.getBlock() == this) + worldIn.addBlockEvent(pos, this, 93, newState.getValue(POWERED).booleanValue() ? 1 : 0); + } + // HACK: For no apparent reason, scabyst observers won't render updates on dedicated servers, so I had to hack together an event to manually inform the client. + @SuppressWarnings("deprecation") + @Override + public boolean eventReceived(IBlockState state, World worldIn, BlockPos pos, int id, int param) { + if(id == 93) { + if(!worldIn.isRemote) return true; + worldIn.setBlockState(pos, worldIn.getBlockState(pos).withProperty(POWERED, param != 0), 2); + return true; + } + return super.eventReceived(state, worldIn, pos, id, param); + } } diff --git a/src/main/java/com/joshiegemfinder/betweenlandsredstone/blocks/TileEntityCrafter.java b/src/main/java/com/joshiegemfinder/betweenlandsredstone/blocks/TileEntityCrafter.java index f74efdf..e6adb45 100644 --- a/src/main/java/com/joshiegemfinder/betweenlandsredstone/blocks/TileEntityCrafter.java +++ b/src/main/java/com/joshiegemfinder/betweenlandsredstone/blocks/TileEntityCrafter.java @@ -326,8 +326,8 @@ public void tryToCraft() { this.world.setBlockState(pos, newState, 3); if(playEjectParticles && !world.isRemote) { - this.world.addBlockEvent(pos, this.getBlockType(), 9002, 0); -// this.world.getMinecraftServer().getPlayerList().sendToAllNearExcept((EntityPlayer)null, (double)pos.getX(), (double)pos.getY(), (double)pos.getZ(), 64.0D, this.world.provider.getDimension(), new SPacketBlockAction(pos, this.getBlockType(), 9002, 0)); + this.world.addBlockEvent(pos, this.getBlockType(), 92, 0); +// this.world.getMinecraftServer().getPlayerList().sendToAllNearExcept((EntityPlayer)null, (double)pos.getX(), (double)pos.getY(), (double)pos.getZ(), 64.0D, this.world.provider.getDimension(), new SPacketBlockAction(pos, this.getBlockType(), 92, 0)); } this.onCraftMatrixChanged();