use of pneumaticCraft.common.block.tubes.TubeModule in project PneumaticCraft by MineMaarten.
the class BlockPressureTube method randomDisplayTick.
@Override
@SideOnly(Side.CLIENT)
public /**
* A randomly called display update to be able to add particles or other items for display
*/
void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) {
TileEntity te = par1World.getTileEntity(par2, par3, par4);
if (te instanceof TileEntityPressureTube) {
TileEntityPressureTube tePt = (TileEntityPressureTube) te;
int l = 0;
for (TubeModule module : tePt.modules) if (module != null)
l = Math.max(l, module.getRedstoneLevel());
if (l > 0) {
// for(int i = 0; i < 4; i++){
double d0 = par2 + 0.5D + (par5Random.nextFloat() - 0.5D) * 0.5D;
double d1 = par3 + 0.5D + (par5Random.nextFloat() - 0.5D) * 0.5D;
double d2 = par4 + 0.5D + (par5Random.nextFloat() - 0.5D) * 0.5D;
float f = l / 15.0F;
float f1 = f * 0.6F + 0.4F;
float f2 = f * f * 0.7F - 0.5F;
float f3 = f * f * 0.6F - 0.7F;
if (f2 < 0.0F) {
f2 = 0.0F;
}
if (f3 < 0.0F) {
f3 = 0.0F;
}
// PacketDispatcher.sendPacketToAllPlayers(PacketHandlerPneumaticCraft.spawnParticle("reddust",
// d0, d1, d2, (double)f1, (double)f2, (double)f3));
par1World.spawnParticle("reddust", d0, d1, d2, f1, f2, f3);
// }
}
}
}
use of pneumaticCraft.common.block.tubes.TubeModule in project PneumaticCraft by MineMaarten.
the class BlockPressureTube method rotateBlock.
@Override
public boolean rotateBlock(World world, EntityPlayer player, int x, int y, int z, ForgeDirection side) {
TileEntityPressureTube tube = ModInteractionUtils.getInstance().getTube(world.getTileEntity(x, y, z));
if (player.isSneaking()) {
TubeModule module = getLookedModule(world, x, y, z, player);
if (module != null) {
if (!player.capabilities.isCreativeMode) {
List<ItemStack> drops = module.getDrops();
for (ItemStack drop : drops) {
EntityItem entity = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5);
entity.setEntityItemStack(drop);
world.spawnEntityInWorld(entity);
entity.onCollideWithPlayer(player);
}
}
tube.setModule(null, module.getDirection());
onNeighborBlockChange(world, x, y, z, this);
world.notifyBlocksOfNeighborChange(x, y, z, this, module.getDirection().getOpposite().ordinal());
return true;
}
if (!player.capabilities.isCreativeMode) {
EntityItem entity = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(tube.maxPressure <= PneumaticValues.MAX_PRESSURE_PRESSURE_TUBE ? Blockss.pressureTube : Blockss.advancedPressureTube));
world.spawnEntityInWorld(entity);
entity.onCollideWithPlayer(player);
}
ModInteractionUtils.getInstance().removeTube(world.getTileEntity(x, y, z));
return true;
} else {
return super.rotateBlock(world, player, x, y, z, side);
}
}
use of pneumaticCraft.common.block.tubes.TubeModule in project PneumaticCraft by MineMaarten.
the class ItemTubeModule method addInformation.
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
super.addInformation(par1ItemStack, par2EntityPlayer, par3List, par4);
TubeModule module = ModuleRegistrator.getModule(moduleName);
module.addItemDescription(par3List);
par3List.add(EnumChatFormatting.DARK_GRAY + "In line: " + (module.isInline() ? "Yes" : "No"));
}
use of pneumaticCraft.common.block.tubes.TubeModule in project PneumaticCraft by MineMaarten.
the class TileEntityPressureTube method readFromPacket.
@Override
public void readFromPacket(NBTTagCompound tag) {
super.readFromPacket(tag);
modules = new TubeModule[6];
NBTTagList moduleList = tag.getTagList("modules", 10);
for (int i = 0; i < moduleList.tagCount(); i++) {
NBTTagCompound moduleTag = moduleList.getCompoundTagAt(i);
TubeModule module = ModuleRegistrator.getModule(moduleTag.getString("type"));
module.readFromNBT(moduleTag);
setModule(module, ForgeDirection.getOrientation(moduleTag.getInteger("side")));
}
if (worldObj != null && worldObj.isRemote) {
rerenderChunk();
}
}
use of pneumaticCraft.common.block.tubes.TubeModule in project PneumaticCraft by MineMaarten.
the class TileEntityPressureTube method updateEntity.
@Override
public void updateEntity() {
super.updateEntity();
for (TubeModule module : modules) {
if (module != null) {
module.shouldDrop = true;
module.update();
}
}
List<Pair<ForgeDirection, IAirHandler>> teList = getConnectedPneumatics();
boolean hasModules = false;
for (TubeModule module : modules) {
if (module != null) {
hasModules = true;
break;
}
}
if (!hasModules && teList.size() - specialConnectedHandlers.size() == 1 && !worldObj.isRemote) {
for (Pair<ForgeDirection, IAirHandler> entry : teList) {
if (entry.getKey() != ForgeDirection.UNKNOWN && modules[entry.getKey().getOpposite().ordinal()] == null && isConnectedTo(entry.getKey().getOpposite()))
airLeak(entry.getKey().getOpposite());
}
}
}
Aggregations