mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-23 03:49:22 +01:00
Added Phantom Redstoneface
This commit is contained in:
parent
9a8d38f5da
commit
b6a02d8189
9 changed files with 103 additions and 3 deletions
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"forge_marker": 1,
|
||||
"defaults": {
|
||||
"model": "minecraft:cube_all",
|
||||
"textures": {
|
||||
"all": "actuallyadditions:blocks/blockPhantomRedstoneface"
|
||||
},
|
||||
"transform": "forge:default-block"
|
||||
},
|
||||
"variants": {
|
||||
"normal": [{}],
|
||||
"inventory": [{}]
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 732 B |
Loading…
Reference in a new issue