Fix redstone behavior for covers
Tested with Machine Controller and Energy Detector, should work for the rest too.
This commit is contained in:
parent
29465ae392
commit
bd274f64b8
4 changed files with 31 additions and 7 deletions
|
@ -34,4 +34,10 @@ public interface IRedstoneEmitter extends IHasWorldObjectAndCoords {
|
|||
* Gets the Output for the comparator on the given Side
|
||||
*/
|
||||
byte getComparatorValue(byte aSide);
|
||||
|
||||
/**
|
||||
* Return whether the TileEntity can output redstone to the given side. Used to visually connect
|
||||
* vanilla redstone wires.
|
||||
*/
|
||||
boolean canOutputRedstone(byte aSide);
|
||||
}
|
|
@ -293,7 +293,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
|
|||
}
|
||||
|
||||
if (mNeedsBlockUpdate) {
|
||||
worldObj.notifyBlockOfStateChange(getPos(), getBlockType());
|
||||
worldObj.notifyNeighborsOfStateChange(getPos(), getBlockType());
|
||||
mNeedsBlockUpdate = false;
|
||||
}
|
||||
}
|
||||
|
@ -494,6 +494,12 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
|
|||
return getInternalInputRedstoneSignal(aSide) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canOutputRedstone(byte aSide) {
|
||||
return (getCoverBehaviorAtSide(aSide).manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this)
|
||||
|| getCoverBehaviorAtSide(aSide).letsRedstoneGoOut(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this));
|
||||
}
|
||||
|
||||
public ITexture getCoverTexture(byte aSide) {
|
||||
return GregTech_API.sCovers.get(getCoverIDAtSide(aSide));
|
||||
}
|
||||
|
@ -1017,7 +1023,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
|
|||
|
||||
@Override
|
||||
public byte getInputRedstoneSignal(byte aSide) {
|
||||
return (byte) (worldObj.getRedstonePower(getPos(), EnumFacing.VALUES[aSide]) & 15);
|
||||
return (byte) (worldObj.getRedstonePower(getPos().offset(EnumFacing.VALUES[aSide]), EnumFacing.VALUES[aSide]) & 15);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -557,7 +557,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
|
|||
}
|
||||
|
||||
if (mNeedsBlockUpdate) {
|
||||
worldObj.notifyBlockOfStateChange(getPos(), getBlockOffset(0, 0, 0));
|
||||
worldObj.notifyNeighborsOfStateChange(getPos(), getBlockOffset(0, 0, 0));
|
||||
mNeedsBlockUpdate = false;
|
||||
}
|
||||
}
|
||||
|
@ -734,6 +734,12 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
|
|||
return getInternalInputRedstoneSignal(aSide) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canOutputRedstone(byte aSide) {
|
||||
return (getCoverBehaviorAtSide(aSide).manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this)
|
||||
|| getCoverBehaviorAtSide(aSide).letsRedstoneGoOut(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this));
|
||||
}
|
||||
|
||||
public ITexture getCoverTexture(byte aSide) {
|
||||
return GregTech_API.sCovers.get(getCoverIDAtSide(aSide));
|
||||
}
|
||||
|
@ -1437,7 +1443,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
|
|||
|
||||
@Override
|
||||
public byte getInputRedstoneSignal(byte aSide) {
|
||||
return (byte) (worldObj.getRedstonePower(getPos(), EnumFacing.VALUES[aSide]) & 15);
|
||||
return (byte) (worldObj.getRedstonePower(getPos().offset(EnumFacing.VALUES[aSide]), EnumFacing.VALUES[aSide]) & 15);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -137,9 +137,15 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* NB: Vanilla redstone behavior is that wires will connect to redstone emitters but not consumers.
|
||||
* Thus we only say we can connect if we are an emitter. (This is usually delegated to a cover behavior.)
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public boolean canConnectRedstone(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) {
|
||||
return true;
|
||||
IGregTechTileEntity gregTechTileEntity = getGregTile(world, pos);
|
||||
return gregTechTileEntity != null && gregTechTileEntity.canOutputRedstone((byte) side.getOpposite().getIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -356,7 +362,7 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo
|
|||
public int getWeakPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
|
||||
IGregTechTileEntity gregTechTileEntity = getGregTile(blockAccess, pos);
|
||||
if(gregTechTileEntity != null) {
|
||||
gregTechTileEntity.getOutputRedstoneSignal((byte) side.getIndex());
|
||||
return gregTechTileEntity.getOutputRedstoneSignal((byte) side.getOpposite().getIndex());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -365,7 +371,7 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo
|
|||
public int getStrongPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
|
||||
IGregTechTileEntity gregTechTileEntity = getGregTile(blockAccess, pos);
|
||||
if(gregTechTileEntity != null) {
|
||||
gregTechTileEntity.getStrongOutputRedstoneSignal((byte) side.getIndex());
|
||||
return gregTechTileEntity.getStrongOutputRedstoneSignal((byte) side.getOpposite().getIndex());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue