Search in sources :

Example 1 with TileEntityMulti

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

the class EventHandlerMars method onPlayerRotate.

@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onPlayerRotate(RenderPlayerGC.RotatePlayerEvent event) {
    BlockPos blockPos = event.entityPlayer.playerLocation;
    IBlockState state = event.entityPlayer.worldObj.getBlockState(blockPos);
    if (state.getBlock() == GCBlocks.fakeBlock && state.getValue(BlockMulti.MULTI_TYPE) == BlockMulti.EnumBlockMultiType.CRYO_CHAMBER) {
        TileEntity tile = event.entityPlayer.worldObj.getTileEntity(blockPos);
        if (tile instanceof TileEntityMulti) {
            state = event.entityPlayer.worldObj.getBlockState(((TileEntityMulti) tile).mainBlockPosition);
        }
    }
    if (state.getBlock() == MarsBlocks.machine && state.getValue(BlockMachineMars.TYPE) == BlockMachineMars.EnumMachineType.CRYOGENIC_CHAMBER) {
        event.shouldRotate = true;
        event.vanillaOverride = true;
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) 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 2 with TileEntityMulti

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

the class RenderPlayerGC method rotateCorpse.

@Override
protected void rotateCorpse(AbstractClientPlayer abstractClientPlayer, float par2, float par3, float par4) {
    if (abstractClientPlayer.isEntityAlive() && abstractClientPlayer.isPlayerSleeping()) {
        RotatePlayerEvent event = new RotatePlayerEvent(abstractClientPlayer);
        MinecraftForge.EVENT_BUS.post(event);
        if (!event.vanillaOverride) {
            super.rotateCorpse(abstractClientPlayer, par2, par3, par4);
        } else if (event.shouldRotate == null) {
            GL11.glRotatef(abstractClientPlayer.getBedOrientationInDegrees(), 0.0F, 1.0F, 0.0F);
        } else if (event.shouldRotate) {
            float rotation = 0.0F;
            if (abstractClientPlayer.playerLocation != null) {
                IBlockState bed = abstractClientPlayer.worldObj.getBlockState(abstractClientPlayer.playerLocation);
                if (bed.getBlock().isBed(abstractClientPlayer.worldObj, abstractClientPlayer.playerLocation, abstractClientPlayer)) {
                    if (bed.getBlock() == GCBlocks.fakeBlock && bed.getValue(BlockMulti.MULTI_TYPE) == BlockMulti.EnumBlockMultiType.CRYO_CHAMBER) {
                        TileEntity tile = event.entityPlayer.worldObj.getTileEntity(abstractClientPlayer.playerLocation);
                        if (tile instanceof TileEntityMulti) {
                            bed = event.entityPlayer.worldObj.getBlockState(((TileEntityMulti) tile).mainBlockPosition);
                        }
                    }
                    if (bed.getBlock() == MarsBlocks.machine && bed.getValue(BlockMachineMars.TYPE) == BlockMachineMars.EnumMachineType.CRYOGENIC_CHAMBER) {
                        switch(bed.getValue(BlockMachineMars.FACING)) {
                            case NORTH:
                                rotation = 0.0F;
                                break;
                            case EAST:
                                rotation = 270.0F;
                                break;
                            case SOUTH:
                                rotation = 180.0F;
                                break;
                            case WEST:
                                rotation = 90.0F;
                                break;
                        }
                    }
                }
            }
            GL11.glRotatef(rotation, 0.0F, 1.0F, 0.0F);
        }
    } else {
        if (Minecraft.getMinecraft().gameSettings.thirdPersonView != 0) {
            final EntityPlayer player = (EntityPlayer) abstractClientPlayer;
            if (player.ridingEntity instanceof ICameraZoomEntity) {
                Entity rocket = player.ridingEntity;
                float rotateOffset = ((ICameraZoomEntity) rocket).getRotateOffset();
                if (rotateOffset > -10F) {
                    GL11.glTranslatef(0, -rotateOffset, 0);
                    float anglePitch = rocket.prevRotationPitch;
                    float angleYaw = rocket.prevRotationYaw;
                    GL11.glRotatef(-angleYaw, 0.0F, 1.0F, 0.0F);
                    GL11.glRotatef(anglePitch, 0.0F, 0.0F, 1.0F);
                    GL11.glTranslatef(0, rotateOffset, 0);
                }
            }
        }
        super.rotateCorpse(abstractClientPlayer, par2, par3, par4);
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ICameraZoomEntity(micdoodle8.mods.galacticraft.api.entity.ICameraZoomEntity) Entity(net.minecraft.entity.Entity) RendererLivingEntity(net.minecraft.client.renderer.entity.RendererLivingEntity) TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ICameraZoomEntity(micdoodle8.mods.galacticraft.api.entity.ICameraZoomEntity) TileEntityMulti(micdoodle8.mods.galacticraft.core.tile.TileEntityMulti)

Example 3 with TileEntityMulti

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

the class BlockMulti method getActualState.

@Override
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
    EnumBlockMultiType type = state.getValue(MULTI_TYPE);
    int renderType = 0;
    switch(type) {
        case CRYO_CHAMBER:
            IBlockState stateAbove = worldIn.getBlockState(pos.up());
            TileEntityMulti tile = (TileEntityMulti) worldIn.getTileEntity(pos);
            if (stateAbove.getBlock() == this && (stateAbove.getValue(MULTI_TYPE)) == EnumBlockMultiType.CRYO_CHAMBER) {
                renderType = 0;
            } else {
                renderType = 4;
            }
            if (tile != null && tile.mainBlockPosition != null && GalacticraftCore.isPlanetsLoaded) {
                IBlockState stateMain = worldIn.getBlockState(tile.mainBlockPosition);
                if (stateMain.getBlock() == MarsBlocks.machine && stateMain.getValue(BlockMachineMars.TYPE) == BlockMachineMars.EnumMachineType.CRYOGENIC_CHAMBER) {
                    EnumFacing dir = stateMain.getValue(BlockMachineMars.FACING);
                    renderType += dir.getHorizontalIndex();
                }
            }
            break;
        default:
            break;
    }
    return state.withProperty(RENDER_TYPE, renderType);
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) TileEntityMulti(micdoodle8.mods.galacticraft.core.tile.TileEntityMulti)

Example 4 with TileEntityMulti

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

the class BlockMulti method makeFakeBlock.

public void makeFakeBlock(World worldObj, BlockPos pos, BlockPos mainBlock, int meta) {
    worldObj.setBlockState(pos, GCBlocks.fakeBlock.getStateFromMeta(meta), meta == 5 ? 3 : 0);
    worldObj.setTileEntity(pos, new TileEntityMulti(mainBlock));
}
Also used : TileEntityMulti(micdoodle8.mods.galacticraft.core.tile.TileEntityMulti)

Example 5 with TileEntityMulti

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

the class TileEntityCargoUnloader 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) EnumFacing(net.minecraft.util.EnumFacing) ICargoEntity(micdoodle8.mods.galacticraft.api.entity.ICargoEntity) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

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