use of mods.railcraft.common.blocks.machine.TileMultiBlock in project Railcraft by Railcraft.
the class TileTankIronValve method update.
@Override
public void update() {
super.update();
if (Game.isClient(worldObj))
return;
decrementFilling();
if (isMaster) {
TileEntity tileBelow = tileCache.getTileOnSide(EnumFacing.DOWN);
TileTankIronValve valveBelow = null;
if (tileBelow instanceof TileTankIronValve) {
valveBelow = (TileTankIronValve) tileBelow;
if (valveBelow.isStructureValid() && valveBelow.getPatternMarker() == 'T') {
//noinspection ConstantConditions
StandardTank tankBelow = valveBelow.getTankManager().get(0);
assert tankBelow != null;
FluidStack liquid = tankBelow.getFluid();
if (liquid != null && liquid.amount >= tankBelow.getCapacity() - FluidTools.BUCKET_VOLUME) {
valveBelow = null;
FluidStack fillStack = liquid.copy();
fillStack.amount = FluidTools.BUCKET_VOLUME - (tankBelow.getCapacity() - liquid.amount);
if (fillStack.amount > 0) {
int used = tank.fill(fillStack, false);
if (used > 0) {
fillStack = tankBelow.drain(used, true);
tank.fill(fillStack, true);
}
}
}
} else
valveBelow = null;
}
if (valveBelow != null) {
FluidStack available = tankManager.drain(0, FluidTools.BUCKET_VOLUME, false);
if (available != null && available.amount > 0) {
int used = valveBelow.fill(available, true);
tankManager.drain(0, used, true);
}
}
}
if (getPatternPosition().getY() - getPattern().getMasterOffset().getY() == 0) {
TankManager tMan = getTankManager();
if (tMan != null)
tMan.push(tileCache, Predicates.notInstanceOf(TileTankBase.class), FLUID_OUTPUTS, 0, FLOW_RATE);
}
TileMultiBlock masterBlock = getMasterBlock();
if (masterBlock instanceof TileTankBase) {
TileTankBase masterTileTankBase = (TileTankBase) masterBlock;
int compValue = masterTileTankBase.getComparatorValue();
if (previousComparatorValue != compValue) {
previousComparatorValue = compValue;
getWorld().notifyNeighborsOfStateChange(getPos(), null);
}
}
if (previousStructureValidity != isStructureValid())
getWorld().notifyNeighborsOfStateChange(getPos(), null);
previousStructureValidity = isStructureValid();
}
use of mods.railcraft.common.blocks.machine.TileMultiBlock in project Railcraft by Railcraft.
the class TileTankBase method isMapPositionValid.
@Override
protected boolean isMapPositionValid(BlockPos pos, char mapPos) {
IBlockState state = WorldPlugin.getBlockState(worldObj, getPos());
Block block = state.getBlock();
int meta = block.getMetaFromState(state);
switch(mapPos) {
case // Other
'O':
{
if (block == getBlockType()) {
if (getTankType().isTankBlock(meta))
return false;
}
return true;
}
case // Gauge or Valve
'W':
{
return block == getBlockType() && getTankType().isTankBlock(meta);
}
case // Block
'B':
{
return block == getBlockType() && getTankType().isWallBlock(meta);
}
// Master
case 'M':
case // Top Block
'T':
{
if (block != getBlockType())
return false;
if (!getTankType().isTankBlock(meta))
return false;
TileEntity tile = worldObj.getTileEntity(getPos());
if (!(tile instanceof TileMultiBlock)) {
worldObj.removeTileEntity(getPos());
return true;
}
return !((TileMultiBlock) tile).isStructureValid();
}
case // Air
'A':
{
return worldObj.isAirBlock(getPos());
}
}
return true;
}
use of mods.railcraft.common.blocks.machine.TileMultiBlock in project Railcraft by Railcraft.
the class ItemMagnifyingGlass method onItemUseFirst.
@Override
public EnumActionResult onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
if (Game.isClient(world))
return EnumActionResult.PASS;
TileEntity t = world.getTileEntity(pos);
EnumActionResult returnValue = EnumActionResult.PASS;
if (t instanceof IOwnable) {
IOwnable ownable = (IOwnable) t;
ChatPlugin.sendLocalizedChatFromServer(player, "gui.railcraft.mag.glass.placedby", ownable.getDisplayName(), ownable.getOwner());
returnValue = EnumActionResult.SUCCESS;
}
if (t instanceof TileMultiBlock) {
TileMultiBlock tile = (TileMultiBlock) t;
if (tile.isStructureValid())
ChatPlugin.sendLocalizedChatFromServer(player, "railcraft.multiblock.state.valid");
else
for (MultiBlockStateReturn returnState : EnumSet.complementOf(EnumSet.of(MultiBlockStateReturn.VALID))) {
List<Integer> pats = tile.patternStates.get(returnState);
if (!pats.isEmpty())
ChatPlugin.sendLocalizedChatFromServer(player, returnState.message, pats.toString());
}
returnValue = EnumActionResult.SUCCESS;
}
if (t instanceof IDualHeadSignal) {
IDualHeadSignal signal = (IDualHeadSignal) t;
SignalAspect top = signal.getSignalAspect(DualLamp.TOP);
SignalAspect bottom = signal.getSignalAspect(DualLamp.BOTTOM);
ChatPlugin.sendLocalizedChatFromServer(player, "gui.railcraft.mag.glass.aspect.dual", top.getLocalizationTag(), bottom.getLocalizationTag());
returnValue = EnumActionResult.SUCCESS;
} else if (t instanceof TileSignalBase) {
ChatPlugin.sendLocalizedChatFromServer(player, "gui.railcraft.mag.glass.aspect", ((TileSignalBase) t).getSignalAspect().getLocalizationTag());
returnValue = EnumActionResult.SUCCESS;
}
return returnValue;
}
Aggregations