diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPhantom.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPhantom.java index 67a3035d6..6bde56158 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPhantom.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPhantom.java @@ -17,6 +17,8 @@ import de.ellpeck.actuallyadditions.mod.tile.*; import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.PosUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil; +import de.ellpeck.actuallyadditions.mod.util.WorldUtil; +import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; @@ -34,6 +36,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; import net.minecraft.util.text.TextFormatting; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -51,6 +54,33 @@ public class BlockPhantom extends BlockContainerBase implements IHudDisplay{ this.setSoundType(SoundType.STONE); } + @Override + public boolean canProvidePower(IBlockState state){ + return this.type == Type.REDSTONEFACE; + } + + @Override + public int getWeakPower(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side){ + if(this.type == Type.REDSTONEFACE){ + TileEntity tile = world.getTileEntity(pos); + if(tile instanceof TileEntityPhantomRedstoneface){ + return ((TileEntityPhantomRedstoneface)tile).providesWeak[side.ordinal()]; + } + } + return super.getWeakPower(state, world, pos, side); + } + + @Override + public int getStrongPower(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side){ + if(this.type == Type.REDSTONEFACE){ + TileEntity tile = world.getTileEntity(pos); + if(tile instanceof TileEntityPhantomRedstoneface){ + return ((TileEntityPhantomRedstoneface)tile).providesStrong[side.ordinal()]; + } + } + return super.getStrongPower(state, world, pos, side); + } + @Override public void breakBlock(World world, BlockPos pos, IBlockState state){ if(this.type == Type.PLACER || this.type == Type.BREAKER){ @@ -70,6 +100,8 @@ public class BlockPhantom extends BlockContainerBase implements IHudDisplay{ return new TileEntityPhantomLiquiface(); case ENERGYFACE: return new TileEntityPhantomEnergyface(); + case REDSTONEFACE: + return new TileEntityPhantomRedstoneface(); default: return new TileEntityPhantomItemface(); } @@ -127,6 +159,7 @@ public class BlockPhantom extends BlockContainerBase implements IHudDisplay{ PLACER, BREAKER, LIQUIFACE, - ENERGYFACE + ENERGYFACE, + REDSTONEFACE } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/InitBlocks.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/InitBlocks.java index 03c5e14d1..caa146106 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/InitBlocks.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/InitBlocks.java @@ -56,6 +56,7 @@ public class InitBlocks{ public static Block blockPhantomBreaker; public static Block blockPhantomLiquiface; public static Block blockPhantomEnergyface; + public static Block blockPhantomRedstoneface; public static Block blockFluidPlacer; public static Block blockFluidCollector; @@ -144,6 +145,7 @@ public class InitBlocks{ blockPhantomPlacer = new BlockPhantom(BlockPhantom.Type.PLACER, "blockPhantomPlacer"); blockPhantomLiquiface = new BlockPhantom(BlockPhantom.Type.LIQUIFACE, "blockPhantomLiquiface"); blockPhantomEnergyface = new BlockPhantom(BlockPhantom.Type.ENERGYFACE, "blockPhantomEnergyface"); + blockPhantomRedstoneface = new BlockPhantom(BlockPhantom.Type.REDSTONEFACE, "blockPhantomRedstoneface"); blockPhantomBreaker = new BlockPhantom(BlockPhantom.Type.BREAKER, "blockPhantomBreaker"); blockCoalGenerator = new BlockCoalGenerator("blockCoalGenerator"); blockOilGenerator = new BlockOilGenerator("blockOilGenerator"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/creative/CreativeTab.java b/src/main/java/de/ellpeck/actuallyadditions/mod/creative/CreativeTab.java index ef8826037..bbe32fa5e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/creative/CreativeTab.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/creative/CreativeTab.java @@ -56,6 +56,7 @@ public class CreativeTab extends CreativeTabs{ this.add(InitBlocks.blockPhantomface); this.add(InitBlocks.blockPhantomEnergyface); this.add(InitBlocks.blockPhantomLiquiface); + this.add(InitBlocks.blockPhantomRedstoneface); this.add(InitBlocks.blockPhantomPlacer); this.add(InitBlocks.blockPhantomBreaker); this.add(InitBlocks.blockInputter); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBase.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBase.java index 33c10e249..fc082c81a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBase.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBase.java @@ -75,6 +75,7 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{ GameRegistry.registerTileEntity(TileEntityAtomicReconstructor.class, ModUtil.MOD_ID+":tileEntityAtomicReconstructor"); GameRegistry.registerTileEntity(TileEntityMiner.class, ModUtil.MOD_ID+":tileEntityMiner"); GameRegistry.registerTileEntity(TileEntityFireworkBox.class, ModUtil.MOD_ID+":tileEntityFireworkBox"); + GameRegistry.registerTileEntity(TileEntityPhantomRedstoneface.class, ModUtil.MOD_ID+":tileEntityPhantomRedstoneface"); } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomRedstoneface.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomRedstoneface.java new file mode 100644 index 000000000..17004796d --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomRedstoneface.java @@ -0,0 +1,49 @@ +package de.ellpeck.actuallyadditions.mod.tile; + +import de.ellpeck.actuallyadditions.mod.util.PosUtil; +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.util.EnumFacing; + +import java.util.Arrays; + +public class TileEntityPhantomRedstoneface extends TileEntityPhantomface{ + + public int[] providesStrong = new int[EnumFacing.values().length]; + public int[] providesWeak = new int[EnumFacing.values().length]; + + private int[] lastProvidesStrong = new int[this.providesStrong.length]; + private int[] lastProvidesWeak = new int[this.providesWeak.length]; + + public TileEntityPhantomRedstoneface(){ + super("redstoneface"); + } + + @Override + public void updateEntity(){ + super.updateEntity(); + + if(!this.worldObj.isRemote){ + if(this.isBoundThingInRange()){ + IBlockState boundState = this.worldObj.getBlockState(this.boundPosition); + if(boundState != null){ + Block boundBlock = boundState.getBlock(); + if(boundBlock != null){ + for(int i = 0; i < EnumFacing.values().length; i++){ + EnumFacing facing = EnumFacing.values()[i]; + this.providesWeak[i] = boundBlock.getWeakPower(boundState, this.worldObj, this.boundPosition, facing); + this.providesStrong[i] = boundBlock.getStrongPower(boundState, this.worldObj, this.boundPosition, facing); + } + } + } + } + + if(!Arrays.equals(this.providesStrong, this.lastProvidesStrong) || !Arrays.equals(this.providesWeak, this.lastProvidesWeak)){ + System.arraycopy(this.providesWeak, 0, this.lastProvidesWeak, 0, this.providesWeak.length); + System.arraycopy(this.providesStrong, 0, this.lastProvidesStrong, 0, this.providesStrong.length); + + this.worldObj.notifyNeighborsOfStateChange(this.pos, PosUtil.getBlock(this.pos, this.worldObj)); + } + } + } +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomface.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomface.java index 1e45ae82a..0ac068edf 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomface.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomface.java @@ -95,8 +95,7 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP this.boundPosBefore = this.boundPosition; this.boundBlockBefore = this.boundPosition == null ? null : PosUtil.getBlock(this.boundPosition, this.worldObj); - IBlockState myState = this.worldObj.getBlockState(this.pos); - this.worldObj.notifyBlockUpdate(this.pos, myState, myState, 3); + this.worldObj.notifyNeighborsOfStateChange(this.pos, PosUtil.getBlock(this.pos, this.worldObj)); this.sendUpdate(); this.markDirty(); diff --git a/src/main/resources/assets/actuallyadditions/blockstates/blockPhantomRedstoneface.json b/src/main/resources/assets/actuallyadditions/blockstates/blockPhantomRedstoneface.json new file mode 100644 index 000000000..9030482ce --- /dev/null +++ b/src/main/resources/assets/actuallyadditions/blockstates/blockPhantomRedstoneface.json @@ -0,0 +1,14 @@ +{ + "forge_marker": 1, + "defaults": { + "model": "minecraft:cube_all", + "textures": { + "all": "actuallyadditions:blocks/blockPhantomRedstoneface" + }, + "transform": "forge:default-block" + }, + "variants": { + "normal": [{}], + "inventory": [{}] + } +} \ No newline at end of file diff --git a/src/main/resources/assets/actuallyadditions/lang/en_US.lang b/src/main/resources/assets/actuallyadditions/lang/en_US.lang index 401fd2ebc..4f3ac7243 100644 --- a/src/main/resources/assets/actuallyadditions/lang/en_US.lang +++ b/src/main/resources/assets/actuallyadditions/lang/en_US.lang @@ -73,6 +73,7 @@ tile.actuallyadditions.blockColoredLampCyan.name=Cyan Lamp tile.actuallyadditions.blockColoredLampPurple.name=Purple Lamp tile.actuallyadditions.blockPhantomface.name=Phantomface tile.actuallyadditions.blockPhantomEnergyface.name=Phantom Energyface +tile.actuallyadditions.blockPhantomRedstoneface.name=Phantom Redstoneface tile.actuallyadditions.blockPhantomLiquiface.name=Phantom Liquiface tile.actuallyadditions.blockPhantomPlacer.name=Phantom Placer tile.actuallyadditions.blockPhantomBreaker.name=Phantom Breaker diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockPhantomRedstoneface.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockPhantomRedstoneface.png new file mode 100644 index 000000000..31cf7d4d3 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockPhantomRedstoneface.png differ