Search in sources :

Example 6 with TileEntityMulti

use of micdoodle8.mods.galacticraft.core.tile.TileEntityMulti in project Galacticraft by micdoodle8.

the class TileEntityCargoLoader method checkForCargoEntity.

public void checkForCargoEntity() {
    boolean foundFuelable = false;
    BlockVec3 thisVec = new BlockVec3(this);
    for (final EnumFacing dir : EnumFacing.VALUES) {
        final TileEntity pad = thisVec.getTileEntityOnSide(this.worldObj, dir);
        if (pad != null && pad instanceof TileEntityMulti) {
            final TileEntity mainTile = ((TileEntityMulti) pad).getMainBlockTile();
            if (mainTile instanceof ICargoEntity) {
                this.attachedFuelable = (ICargoEntity) mainTile;
                foundFuelable = true;
                break;
            }
        } else if (pad != null && pad instanceof ICargoEntity) {
            this.attachedFuelable = (ICargoEntity) pad;
            foundFuelable = true;
            break;
        }
    }
    if (!foundFuelable) {
        this.attachedFuelable = null;
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ICargoEntity(micdoodle8.mods.galacticraft.api.entity.ICargoEntity) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Example 7 with TileEntityMulti

use of micdoodle8.mods.galacticraft.core.tile.TileEntityMulti in project Galacticraft by micdoodle8.

the class TileEntityFuelLoader method update.

@Override
public void update() {
    super.update();
    if (!this.worldObj.isRemote) {
        this.loadedFuelLastTick = false;
        final FluidStack liquidContained = FluidUtil.getFluidContained(this.containingItems[1]);
        if (FluidUtil.isFuel(liquidContained)) {
            FluidUtil.loadFromContainer(this.fuelTank, GCFluids.fluidFuel, this.containingItems, 1, liquidContained.amount);
        }
        if (this.ticks % 100 == 0) {
            this.attachedFuelable = null;
            BlockVec3 thisVec = new BlockVec3(this);
            for (final EnumFacing dir : EnumFacing.VALUES) {
                final TileEntity pad = thisVec.getTileEntityOnSide(this.worldObj, dir);
                if (pad instanceof TileEntityMulti) {
                    final TileEntity mainTile = ((TileEntityMulti) pad).getMainBlockTile();
                    if (mainTile instanceof IFuelable) {
                        this.attachedFuelable = (IFuelable) mainTile;
                        break;
                    }
                } else if (pad instanceof IFuelable) {
                    this.attachedFuelable = (IFuelable) pad;
                    break;
                }
            }
        }
        if (this.fuelTank != null && this.fuelTank.getFluid() != null && this.fuelTank.getFluid().amount > 0) {
            final FluidStack liquid = new FluidStack(GCFluids.fluidFuel, 2);
            if (this.attachedFuelable != null && this.hasEnoughEnergyToRun && !this.disabled) {
                int filled = this.attachedFuelable.addFuel(liquid, true);
                this.loadedFuelLastTick = filled > 0;
                this.fuelTank.drain(filled, true);
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EnumFacing(net.minecraft.util.EnumFacing) IFuelable(micdoodle8.mods.galacticraft.api.entity.IFuelable) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Example 8 with TileEntityMulti

use of micdoodle8.mods.galacticraft.core.tile.TileEntityMulti in project Galacticraft by micdoodle8.

the class EventHandlerMars method orientCamera.

@SideOnly(Side.CLIENT)
@SubscribeEvent
public void orientCamera(OrientCameraEvent event) {
    EntityPlayer entity = Minecraft.getMinecraft().thePlayer;
    if (entity != null) {
        int x = MathHelper.floor_double(entity.posX);
        int y = MathHelper.floor_double(entity.posY);
        int z = MathHelper.floor_double(entity.posZ);
        TileEntity tile = Minecraft.getMinecraft().theWorld.getTileEntity(new BlockPos(x, y - 1, z));
        if (tile instanceof TileEntityMulti) {
            tile = ((TileEntityMulti) tile).getMainBlockTile();
        }
        if (tile instanceof TileEntityCryogenicChamber) {
            GL11.glRotatef(180, 0.0F, 1.0F, 0.0F);
            switch(tile.getBlockMetadata() & 3) {
                case 0:
                    GL11.glTranslatef(-0.4F, -0.5F, 4.1F);
                    break;
                case 1:
                    GL11.glTranslatef(0, -0.5F, 4.1F);
                    break;
                case 2:
                    GL11.glTranslatef(0, -0.5F, 4.1F);
                    break;
                case 3:
                    GL11.glTranslatef(0.0F, -0.5F, 4.1F);
                    break;
            }
            GL11.glRotatef(-180, 0.0F, 1.0F, 0.0F);
            GL11.glRotatef(FMLClientHandler.instance().getClientPlayerEntity().sleepTimer - 50, 0.0F, 1.0F, 0.0F);
            GL11.glTranslatef(0.0F, 0.3F, 0.0F);
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityCryogenicChamber(micdoodle8.mods.galacticraft.planets.mars.tile.TileEntityCryogenicChamber) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.BlockPos) TileEntityMulti(micdoodle8.mods.galacticraft.core.tile.TileEntityMulti) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 9 with TileEntityMulti

use of micdoodle8.mods.galacticraft.core.tile.TileEntityMulti in project Galacticraft by micdoodle8.

the class TileEntityMulti method initialiseMultiTiles.

protected boolean initialiseMultiTiles(BlockPos pos, World world) {
    IMultiBlock thisTile = (IMultiBlock) this;
    // Client can create its own fake blocks and tiles - no need for networking in 1.8+
    if (world.isRemote) {
        thisTile.onCreate(world, pos);
    }
    List<BlockPos> positions = new ArrayList<>();
    thisTile.getPositions(pos, positions);
    boolean result = true;
    for (BlockPos vecToAdd : positions) {
        TileEntity tile = world.getTileEntity(vecToAdd);
        if (tile instanceof TileEntityMulti) {
            ((TileEntityMulti) tile).mainBlockPosition = pos;
        } else if (tile == null) {
            Block b = world.getBlockState(vecToAdd).getBlock();
            if (!(b instanceof BlockMulti)) {
                world.setBlockState(vecToAdd, GCBlocks.fakeBlock.getDefaultState().withProperty(BlockMulti.MULTI_TYPE, thisTile.getMultiType()), 2);
            }
            world.setTileEntity(vecToAdd, new TileEntityMulti(pos));
        } else {
            result = false;
        }
    }
    if (result == false && !world.isRemote) {
    // //Try again to create all the multiblocks - currently disabled because making new tiles here interferes with server->client tileEntity sync during worldgen (Abandoned Base)
    // thisTile.onCreate(world, pos);
    }
    return result;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ArrayList(java.util.ArrayList) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.BlockPos) BlockMulti(micdoodle8.mods.galacticraft.core.blocks.BlockMulti)

Example 10 with TileEntityMulti

use of micdoodle8.mods.galacticraft.core.tile.TileEntityMulti in project Galacticraft by micdoodle8.

the class ItemAstroMiner method onItemUse.

@Override
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
    TileEntity tile = null;
    if (worldIn.isRemote || playerIn == null) {
        return false;
    } else {
        final Block id = worldIn.getBlockState(pos).getBlock();
        if (id == GCBlocks.fakeBlock) {
            tile = worldIn.getTileEntity(pos);
            if (tile instanceof TileEntityMulti) {
                tile = ((TileEntityMulti) tile).getMainBlockTile();
            }
        }
        if (id == AsteroidBlocks.minerBaseFull) {
            tile = worldIn.getTileEntity(pos);
        }
        if (tile instanceof TileEntityMinerBase) {
            if (worldIn.provider instanceof WorldProviderSpaceStation) {
                playerIn.addChatMessage(new ChatComponentText(GCCoreUtil.translate("gui.message.astro_miner7.fail")));
                return false;
            }
            if (((TileEntityMinerBase) tile).getLinkedMiner() != null) {
                playerIn.addChatMessage(new ChatComponentText(GCCoreUtil.translate("gui.message.astro_miner.fail")));
                return false;
            }
            // Gives a chance for any loaded Astro Miner to link itself
            if (((TileEntityMinerBase) tile).ticks < 15L) {
                return false;
            }
            EntityPlayerMP playerMP = (EntityPlayerMP) playerIn;
            GCPlayerStats stats = GCPlayerStats.get(playerIn);
            int astroCount = stats.getAstroMinerCount();
            if (astroCount >= ConfigManagerAsteroids.astroMinerMax && (!playerIn.capabilities.isCreativeMode)) {
                playerIn.addChatMessage(new ChatComponentText(GCCoreUtil.translate("gui.message.astro_miner2.fail")));
                return false;
            }
            if (!((TileEntityMinerBase) tile).spawnMiner(playerMP)) {
                playerIn.addChatMessage(new ChatComponentText(GCCoreUtil.translate("gui.message.astro_miner1.fail") + " " + GCCoreUtil.translate(EntityAstroMiner.blockingBlock.toString())));
                return false;
            }
            if (!playerIn.capabilities.isCreativeMode) {
                stats.setAstroMinerCount(stats.getAstroMinerCount() + 1);
                --stack.stackSize;
            }
            return true;
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) WorldProviderSpaceStation(micdoodle8.mods.galacticraft.core.dimension.WorldProviderSpaceStation) GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) Block(net.minecraft.block.Block) TileEntityMinerBase(micdoodle8.mods.galacticraft.planets.asteroids.tile.TileEntityMinerBase) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) TileEntityMulti(micdoodle8.mods.galacticraft.core.tile.TileEntityMulti) ChatComponentText(net.minecraft.util.ChatComponentText)

Aggregations

TileEntity (net.minecraft.tileentity.TileEntity)11 TileEntityMulti (micdoodle8.mods.galacticraft.core.tile.TileEntityMulti)10 IBlockState (net.minecraft.block.state.IBlockState)4 BlockVec3 (micdoodle8.mods.galacticraft.api.vector.BlockVec3)3 BlockPos (net.minecraft.util.BlockPos)3 ICargoEntity (micdoodle8.mods.galacticraft.api.entity.ICargoEntity)2 Block (net.minecraft.block.Block)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 EnumFacing (net.minecraft.util.EnumFacing)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 ArrayList (java.util.ArrayList)1 ICameraZoomEntity (micdoodle8.mods.galacticraft.api.entity.ICameraZoomEntity)1 IFuelable (micdoodle8.mods.galacticraft.api.entity.IFuelable)1 BlockMulti (micdoodle8.mods.galacticraft.core.blocks.BlockMulti)1 WorldProviderSpaceStation (micdoodle8.mods.galacticraft.core.dimension.WorldProviderSpaceStation)1 GCPlayerStats (micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats)1 TileEntityMinerBase (micdoodle8.mods.galacticraft.planets.asteroids.tile.TileEntityMinerBase)1 TileEntityCryogenicChamber (micdoodle8.mods.galacticraft.planets.mars.tile.TileEntityCryogenicChamber)1 RendererLivingEntity (net.minecraft.client.renderer.entity.RendererLivingEntity)1