Search in sources :

Example 1 with TileEntityTreasureChest

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

the class BlockTier1TreasureChest method isProvidingWeakPower.

public int isProvidingWeakPower(IBlockAccess worldIn, BlockPos pos, IBlockState state, EnumFacing side) {
    if (!this.canProvidePower()) {
        return 0;
    } else {
        int i = 0;
        TileEntity tileentity = worldIn.getTileEntity(pos);
        if (tileentity instanceof TileEntityTreasureChest) {
            i = ((TileEntityTreasureChest) tileentity).numPlayersUsing;
        }
        return MathHelper.clamp_int(i, 0, 15);
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityTreasureChest(micdoodle8.mods.galacticraft.core.tile.TileEntityTreasureChest)

Example 2 with TileEntityTreasureChest

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

the class BlockTier1TreasureChest method onBlockPlacedBy.

@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
    EnumFacing enumfacing = EnumFacing.getHorizontal(MathHelper.floor_double((double) (placer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3).getOpposite();
    state = state.withProperty(FACING, enumfacing);
    BlockPos blockpos1 = pos.north();
    BlockPos blockpos2 = pos.south();
    BlockPos blockpos3 = pos.west();
    BlockPos blockpos4 = pos.east();
    boolean flag = this == worldIn.getBlockState(blockpos1).getBlock();
    boolean flag1 = this == worldIn.getBlockState(blockpos2).getBlock();
    boolean flag2 = this == worldIn.getBlockState(blockpos3).getBlock();
    boolean flag3 = this == worldIn.getBlockState(blockpos4).getBlock();
    if (!flag && !flag1 && !flag2 && !flag3) {
        worldIn.setBlockState(pos, state, 3);
    } else if (enumfacing.getAxis() == EnumFacing.Axis.X && (flag || flag1)) {
        if (flag) {
            worldIn.setBlockState(blockpos1, state, 3);
        } else {
            worldIn.setBlockState(blockpos2, state, 3);
        }
        worldIn.setBlockState(pos, state, 3);
    } else if (enumfacing.getAxis() == EnumFacing.Axis.Z && (flag2 || flag3)) {
        if (flag2) {
            worldIn.setBlockState(blockpos3, state, 3);
        } else {
            worldIn.setBlockState(blockpos4, state, 3);
        }
        worldIn.setBlockState(pos, state, 3);
    }
    if (stack.hasDisplayName()) {
        TileEntity tileentity = worldIn.getTileEntity(pos);
        if (tileentity instanceof TileEntityTreasureChest) {
            ((TileEntityTreasureChest) tileentity).setCustomName(stack.getDisplayName());
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EnumFacing(net.minecraft.util.EnumFacing) TileEntityTreasureChest(micdoodle8.mods.galacticraft.core.tile.TileEntityTreasureChest) BlockPos(net.minecraft.util.BlockPos)

Example 3 with TileEntityTreasureChest

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

the class EntityBossBase method onDeathUpdate.

@Override
protected void onDeathUpdate() {
    ++this.deathTicks;
    if (this.deathTicks >= 180 && this.deathTicks <= 200) {
        final float x = (this.rand.nextFloat() - 0.5F) * this.width;
        final float y = (this.rand.nextFloat() - 0.5F) * (this.height / 2.0F);
        final float z = (this.rand.nextFloat() - 0.5F) * this.width;
        this.worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, this.posX + x, this.posY + 2.0D + y, this.posZ + z, 0.0D, 0.0D, 0.0D);
    }
    int i;
    int j;
    if (!this.worldObj.isRemote) {
        if (this.deathTicks >= 180 && this.deathTicks % 5 == 0) {
            GalacticraftCore.packetPipeline.sendToAllAround(new PacketSimple(PacketSimple.EnumSimplePacket.C_PLAY_SOUND_EXPLODE, GCCoreUtil.getDimensionID(this.worldObj), new Object[] {}), new NetworkRegistry.TargetPoint(GCCoreUtil.getDimensionID(this.worldObj), this.posX, this.posY, this.posZ, 40.0D));
        }
        if (this.deathTicks > 150 && this.deathTicks % 5 == 0) {
            i = 30;
            while (i > 0) {
                j = EntityXPOrb.getXPSplit(i);
                i -= j;
                this.worldObj.spawnEntityInWorld(new EntityXPOrb(this.worldObj, this.posX, this.posY, this.posZ, j));
            }
        }
    }
    if (this.deathTicks == 200 && !this.worldObj.isRemote) {
        i = 20;
        while (i > 0) {
            j = EntityXPOrb.getXPSplit(i);
            i -= j;
            this.worldObj.spawnEntityInWorld(new EntityXPOrb(this.worldObj, this.posX, this.posY, this.posZ, j));
        }
        TileEntityTreasureChest chest = null;
        if (this.spawner != null && this.spawner.getChestPos() != null) {
            TileEntity chestTest = this.worldObj.getTileEntity(this.spawner.getChestPos());
            if (chestTest != null && chestTest instanceof TileEntityTreasureChest) {
                chest = (TileEntityTreasureChest) chestTest;
            }
        }
        if (chest == null) {
            // Fallback to finding closest chest
            chest = TileEntityTreasureChest.findClosest(this, this.getChestTier());
        }
        if (chest != null) {
            double dist = this.getDistanceSq(chest.getPos().getX() + 0.5, chest.getPos().getY() + 0.5, chest.getPos().getZ() + 0.5);
            if (dist < 1000 * 1000) {
                if (!chest.locked) {
                    chest.locked = true;
                }
                for (int k = 0; k < chest.getSizeInventory(); k++) {
                    chest.setInventorySlotContents(k, null);
                }
                String chesttype = RoomChest.MOONCHEST;
                if (this.worldObj.provider instanceof IGalacticraftWorldProvider) {
                    chesttype = ((IGalacticraftWorldProvider) this.worldObj.provider).getDungeonChestType();
                }
                ChestGenHooks info = ChestGenHooks.getInfo(chesttype);
                // Generate twice, since it's an extra special chest
                WeightedRandomChestContent.generateChestContents(this.rand, info.getItems(this.rand), chest, info.getCount(this.rand));
                WeightedRandomChestContent.generateChestContents(this.rand, info.getItems(this.rand), chest, info.getCount(this.rand));
                ItemStack schematic = this.getGuaranteedLoot(this.rand);
                int slot = this.rand.nextInt(chest.getSizeInventory());
                chest.setInventorySlotContents(slot, schematic);
            }
        }
        this.dropKey();
        super.setDead();
        if (this.spawner != null) {
            // Note: spawner.isBossDefeated is true, so it's properly dead
            this.spawner.isBossDefeated = true;
            this.spawner.boss = null;
            this.spawner.spawned = false;
            if (!this.worldObj.isRemote) {
                this.spawner.lastKillTime = MinecraftServer.getCurrentTimeMillis();
            }
        }
    }
}
Also used : IGalacticraftWorldProvider(micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider) PacketSimple(micdoodle8.mods.galacticraft.core.network.PacketSimple) TileEntity(net.minecraft.tileentity.TileEntity) NetworkRegistry(net.minecraftforge.fml.common.network.NetworkRegistry) TileEntityTreasureChest(micdoodle8.mods.galacticraft.core.tile.TileEntityTreasureChest) ChestGenHooks(net.minecraftforge.common.ChestGenHooks) ItemStack(net.minecraft.item.ItemStack) EntityXPOrb(net.minecraft.entity.item.EntityXPOrb)

Example 4 with TileEntityTreasureChest

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

the class BlockTier1TreasureChest method onNeighborBlockChange.

@Override
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock) {
    super.onNeighborBlockChange(worldIn, pos, state, neighborBlock);
    TileEntity tileentity = worldIn.getTileEntity(pos);
    if (tileentity instanceof TileEntityTreasureChest) {
        tileentity.updateContainingBlockInfo();
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityTreasureChest(micdoodle8.mods.galacticraft.core.tile.TileEntityTreasureChest)

Example 5 with TileEntityTreasureChest

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

the class TileEntityTreasureChestRenderer method renderTileEntityAt.

/**
 * Renders the TileEntity for the chest at a position.
 */
@Override
public void renderTileEntityAt(TileEntityTreasureChest chest, double par2, double par4, double par6, float partialTickTime, int par9) {
    int var9;
    if (!chest.hasWorldObj()) {
        var9 = 0;
    } else {
        var9 = chest.getBlockMetadata();
    }
    ModelTreasureChest var14 = null;
    ModelTreasureChestLarge var14b = null;
    var14 = this.chestModel;
    this.bindTexture(TileEntityTreasureChestRenderer.treasureChestTexture);
    GL11.glPushMatrix();
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glTranslatef((float) par2, (float) par4 + 1.0F, (float) par6 + 1.0F);
    GL11.glScalef(1.0F, -1.0F, -1.0F);
    GL11.glTranslatef(0.5F, 0.5F, 0.5F);
    short var11 = 0;
    if (var9 == 2) {
        var11 = 180;
    }
    if (var9 == 3) {
        var11 = 0;
    }
    if (var9 == 4) {
        var11 = 90;
    }
    if (var9 == 5) {
        var11 = -90;
    }
    GL11.glRotatef(var11, 0.0F, 1.0F, 0.0F);
    GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
    float var12 = chest.prevLidAngle + (chest.lidAngle - chest.prevLidAngle) * partialTickTime;
    float var13;
    var12 = 1.0F - var12;
    var12 = 1.0F - var12 * var12 * var12;
    if (var14 != null) {
        var14.chestLid.rotateAngleX = -(var12 * (float) Math.PI / 4.0F);
        var14.renderAll(!chest.locked);
    }
    if (var14b != null) {
        var14b.chestLid.rotateAngleX = -(var12 * (float) Math.PI / 4.0F);
        var14b.renderAll(!chest.locked);
    }
    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    GL11.glPopMatrix();
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
}
Also used : ModelTreasureChestLarge(micdoodle8.mods.galacticraft.core.client.model.block.ModelTreasureChestLarge) ModelTreasureChest(micdoodle8.mods.galacticraft.core.client.model.block.ModelTreasureChest)

Aggregations

TileEntityTreasureChest (micdoodle8.mods.galacticraft.core.tile.TileEntityTreasureChest)4 TileEntity (net.minecraft.tileentity.TileEntity)4 IGalacticraftWorldProvider (micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider)1 ModelTreasureChest (micdoodle8.mods.galacticraft.core.client.model.block.ModelTreasureChest)1 ModelTreasureChestLarge (micdoodle8.mods.galacticraft.core.client.model.block.ModelTreasureChestLarge)1 PacketSimple (micdoodle8.mods.galacticraft.core.network.PacketSimple)1 EntityXPOrb (net.minecraft.entity.item.EntityXPOrb)1 ItemStack (net.minecraft.item.ItemStack)1 BlockPos (net.minecraft.util.BlockPos)1 EnumFacing (net.minecraft.util.EnumFacing)1 ChestGenHooks (net.minecraftforge.common.ChestGenHooks)1 NetworkRegistry (net.minecraftforge.fml.common.network.NetworkRegistry)1