Search in sources :

Example 1 with TubeModule

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);
        // }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TubeModule(pneumaticCraft.common.block.tubes.TubeModule) ItemTubeModule(pneumaticCraft.common.item.ItemTubeModule) TileEntityPressureTube(pneumaticCraft.common.tileentity.TileEntityPressureTube) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 2 with TubeModule

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);
    }
}
Also used : TubeModule(pneumaticCraft.common.block.tubes.TubeModule) ItemTubeModule(pneumaticCraft.common.item.ItemTubeModule) TileEntityPressureTube(pneumaticCraft.common.tileentity.TileEntityPressureTube) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem)

Example 3 with TubeModule

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"));
}
Also used : TubeModule(pneumaticCraft.common.block.tubes.TubeModule) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 4 with TubeModule

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();
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) TubeModule(pneumaticCraft.common.block.tubes.TubeModule)

Example 5 with TubeModule

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());
        }
    }
}
Also used : IAirHandler(pneumaticCraft.api.tileentity.IAirHandler) TubeModule(pneumaticCraft.common.block.tubes.TubeModule) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) Pair(org.apache.commons.lang3.tuple.Pair)

Aggregations

TubeModule (pneumaticCraft.common.block.tubes.TubeModule)13 TileEntityPressureTube (pneumaticCraft.common.tileentity.TileEntityPressureTube)5 ItemTubeModule (pneumaticCraft.common.item.ItemTubeModule)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 SideOnly (cpw.mods.fml.relauncher.SideOnly)2 NBTTagList (net.minecraft.nbt.NBTTagList)2 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)2 EntityItem (net.minecraft.entity.item.EntityItem)1 Item (net.minecraft.item.Item)1 ItemStack (net.minecraft.item.ItemStack)1 TileEntity (net.minecraft.tileentity.TileEntity)1 AxisAlignedBB (net.minecraft.util.AxisAlignedBB)1 MovingObjectPosition (net.minecraft.util.MovingObjectPosition)1 Pair (org.apache.commons.lang3.tuple.Pair)1 IAirHandler (pneumaticCraft.api.tileentity.IAirHandler)1 RenderItemTubeModule (pneumaticCraft.client.render.itemblock.RenderItemTubeModule)1