use of micdoodle8.mods.galacticraft.api.tile.IColorable in project Galacticraft by micdoodle8.
the class BlockFluidPipe method onBlockActivated.
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ) {
final TileEntityFluidPipe tileEntity = (TileEntityFluidPipe) worldIn.getTileEntity(pos);
if (super.onBlockActivated(worldIn, pos, state, playerIn, side, hitX, hitY, hitZ)) {
return true;
}
if (!worldIn.isRemote) {
final ItemStack stack = playerIn.inventory.getCurrentItem();
if (stack != null) {
if (stack.getItem() instanceof ItemDye) {
final int dyeColor = playerIn.inventory.getCurrentItem().getItemDamage();
final byte colorBefore = tileEntity.getColor(state);
tileEntity.onColorUpdate();
worldIn.setBlockState(pos, state.withProperty(COLOR, EnumDyeColor.byDyeDamage(dyeColor)));
GalacticraftCore.packetPipeline.sendToAllAround(new PacketSimple(PacketSimple.EnumSimplePacket.C_RECOLOR_PIPE, GCCoreUtil.getDimensionID(worldIn), new Object[] { pos }), new NetworkRegistry.TargetPoint(GCCoreUtil.getDimensionID(worldIn), pos.getX(), pos.getY(), pos.getZ(), 40.0));
if (colorBefore != (byte) dyeColor && !playerIn.capabilities.isCreativeMode && --playerIn.inventory.getCurrentItem().stackSize == 0) {
playerIn.inventory.mainInventory[playerIn.inventory.currentItem] = null;
}
if (colorBefore != (byte) dyeColor && colorBefore != 15) {
spawnItem(worldIn, pos, colorBefore);
}
// GCCorePacketManager.sendPacketToClients(GCCorePacketManager.getPacket(GalacticraftCore.CHANNELENTITIES, tileEntity, tileEntity.getColor(), (byte) -1)); TODO Fix pipe color
BlockPos tileVec = tileEntity.getPos();
for (final EnumFacing dir : EnumFacing.VALUES) {
final TileEntity tileAt = worldIn.getTileEntity(tileVec.offset(dir));
if (tileAt != null && tileAt instanceof IColorable) {
((IColorable) tileAt).onAdjacentColorChanged(dir);
}
}
return true;
}
}
}
return false;
}
use of micdoodle8.mods.galacticraft.api.tile.IColorable in project Galacticraft by micdoodle8.
the class TileEntityFluidPipe method canConnect.
@Override
public boolean canConnect(EnumFacing direction, NetworkType type) {
TileEntity adjacentTile = new BlockVec3(this).getTileEntityOnSide(this.worldObj, direction);
if (type == NetworkType.FLUID) {
if (adjacentTile instanceof IColorable) {
IBlockState state = this.worldObj.getBlockState(this.getPos());
IBlockState adjacentTileState = adjacentTile.getWorld().getBlockState(adjacentTile.getPos());
byte thisCol = this.getColor(state);
byte otherCol = ((IColorable) adjacentTile).getColor(adjacentTileState);
return thisCol == otherCol || thisCol == EnumDyeColor.WHITE.getDyeDamage() || otherCol == EnumDyeColor.WHITE.getDyeDamage();
}
return true;
}
return false;
}
Aggregations