Search in sources :

Example 11 with TileEntityChestMP

use of stevekung.mods.moreplanets.utils.tileentity.TileEntityChestMP in project MorePlanets by SteveKunG.

the class RoomChestNibiru method addComponentParts.

@Override
public boolean addComponentParts(World world, Random rand, StructureBoundingBox boundingBox) {
    if (super.addComponentParts(world, rand, boundingBox)) {
        int chestX = this.sizeX / 2;
        int chestY = 1;
        int chestZ = this.sizeZ / 2;
        this.setBlockState(world, this.configuration.getAncientChestBlock().withProperty(BlockStateProperty.FACING_HORIZON, this.getDirection().getOpposite()), chestX, chestY, chestZ, boundingBox);
        BlockPos blockpos = new BlockPos(this.getXWithOffset(chestX, chestZ), this.getYWithOffset(chestY), this.getZWithOffset(chestX, chestZ));
        TileEntityChestMP chest = (TileEntityChestMP) world.getTileEntity(blockpos);
        if (chest != null) {
            chest.setLootTable(MPLootTables.COMMON_SPACE_DUNGEON, rand.nextLong());
        }
        return true;
    }
    return false;
}
Also used : TileEntityChestMP(stevekung.mods.moreplanets.utils.tileentity.TileEntityChestMP) BlockPos(net.minecraft.util.math.BlockPos)

Example 12 with TileEntityChestMP

use of stevekung.mods.moreplanets.utils.tileentity.TileEntityChestMP in project MorePlanets by SteveKunG.

the class BlockChestMP method onBlockPlacedBy.

@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack heldStack) {
    EnumFacing facing = EnumFacing.byHorizontalIndex(MathHelper.floor(placer.rotationYaw * 4.0F / 360.0F + 0.5D) & 3).getOpposite();
    state = state.withProperty(BlockStateProperty.FACING_HORIZON, facing);
    BlockPos blockpos = pos.north();
    BlockPos blockpos1 = pos.south();
    BlockPos blockpos2 = pos.west();
    BlockPos blockpos3 = pos.east();
    boolean flag = this == world.getBlockState(blockpos).getBlock();
    boolean flag1 = this == world.getBlockState(blockpos1).getBlock();
    boolean flag2 = this == world.getBlockState(blockpos2).getBlock();
    boolean flag3 = this == world.getBlockState(blockpos3).getBlock();
    if (!flag && !flag1 && !flag2 && !flag3) {
        world.setBlockState(pos, state, 3);
    } else if (facing.getAxis() != EnumFacing.Axis.X || !flag && !flag1) {
        if (facing.getAxis() == EnumFacing.Axis.Z && (flag2 || flag3)) {
            if (flag2) {
                world.setBlockState(blockpos2, state, 3);
            } else {
                world.setBlockState(blockpos3, state, 3);
            }
            world.setBlockState(pos, state, 3);
        }
    } else {
        if (flag) {
            world.setBlockState(blockpos, state, 3);
        } else {
            world.setBlockState(blockpos1, state, 3);
        }
        world.setBlockState(pos, state, 3);
    }
    if (heldStack.hasDisplayName()) {
        TileEntity tile = world.getTileEntity(pos);
        if (tile instanceof TileEntityChestMP) {
            ((TileEntityChestMP) tile).setCustomName(heldStack.getDisplayName());
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityChestMP(stevekung.mods.moreplanets.utils.tileentity.TileEntityChestMP) BlockPos(net.minecraft.util.math.BlockPos)

Example 13 with TileEntityChestMP

use of stevekung.mods.moreplanets.utils.tileentity.TileEntityChestMP in project MorePlanets by SteveKunG.

the class StructureNibiruPyramidPieces method generateChest.

@Override
protected boolean generateChest(World world, StructureBoundingBox box, Random randomIn, int x, int y, int z, ResourceLocation loot) {
    BlockPos blockpos = new BlockPos(this.getXWithOffset(x, z), this.getYWithOffset(y), this.getZWithOffset(x, z));
    if (box.isVecInside(blockpos) && world.getBlockState(blockpos).getBlock() != MPBlocks.INFECTED_CHEST) {
        IBlockState iblockstate = MPBlocks.INFECTED_CHEST.getDefaultState();
        world.setBlockState(blockpos, MPBlocks.INFECTED_CHEST.correctFacing(world, blockpos, iblockstate), 2);
        TileEntity tileentity = world.getTileEntity(blockpos);
        if (tileentity instanceof TileEntityChestMP) {
            ((TileEntityChestMP) tileentity).setLootTable(loot, randomIn.nextLong());
        }
        return true;
    } else {
        return false;
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) TileEntityChestMP(stevekung.mods.moreplanets.utils.tileentity.TileEntityChestMP) BlockPos(net.minecraft.util.math.BlockPos)

Example 14 with TileEntityChestMP

use of stevekung.mods.moreplanets.utils.tileentity.TileEntityChestMP in project MorePlanets by SteveKunG.

the class StructureAbandonedSatellitePieces method addComponentParts.

@Override
public boolean addComponentParts(World world, Random rand, StructureBoundingBox structureBoundingBox) {
    if (!this.offsetToAverageGroundLevel(world, structureBoundingBox, -1)) {
        return false;
    } else {
        StructureBoundingBox box = this.getBoundingBox();
        BlockPos pos = new BlockPos(box.minX, box.minY, box.minZ);
        Rotation[] arotation = CachedEnum.rotationValues;
        Rotation rotation = arotation[rand.nextInt(arotation.length)];
        MinecraftServer server = world.getMinecraftServer();
        TemplateManager manager = world.getSaveHandler().getStructureTemplateManager();
        PlacementSettings settings = new PlacementSettings().setRotation(rotation).setReplacedBlock(Blocks.STRUCTURE_VOID).setBoundingBox(box);
        settings.setIntegrity(0.85F);
        Template template = manager.getTemplate(server, SATELLITE_BASE_ID);
        Template template1 = manager.getTemplate(server, SATELLITE_DISH_BASE_ID);
        Template template2 = manager.getTemplate(server, SATELLITE_DISH_ID);
        this.addBlocksToWorldChunk(template, world, pos, settings);
        BlockPos blockpos1 = template.calculateConnectedPos(settings, new BlockPos(0, 4, 0), settings, new BlockPos(-1, 0, -1));
        this.addBlocksToWorldChunk(template1, world, pos.add(blockpos1), settings);
        BlockPos blockpos4 = pos.add(template.calculateConnectedPos(settings, new BlockPos(0, 8, 0), settings, new BlockPos(0, 0, 4)));
        this.addBlocksToWorldChunk(template2, world, blockpos4, settings);
        Map<BlockPos, String> map = template.getDataBlocks(pos, settings);
        for (Map.Entry<BlockPos, String> entry : map.entrySet()) {
            if ("laser_turret".equals(entry.getValue())) {
                BlockPos blockpos2 = entry.getKey();
                world.setBlockState(blockpos2, VenusBlocks.laserTurret.getDefaultState().withProperty(BlockLaserTurret.FACING, rotation.rotate(EnumFacing.NORTH)), 3);
                TileEntity tile = world.getTileEntity(blockpos2);
                if (tile instanceof TileEntityLaserTurret) {
                    TileEntityLaserTurret turret = (TileEntityLaserTurret) tile;
                    turret.setOwnerUUID(UUID.randomUUID());
                    turret.addPlayer("");
                    turret.targetMeteors = false;
                    turret.getPositions(blockpos2, new ArrayList<>());
                    turret.onCreate(world, blockpos2);
                }
            } else if ("chest_and_wire".equals(entry.getValue())) {
                BlockPos blockpos2 = entry.getKey();
                world.setBlockState(blockpos2, GCBlocks.sealableBlock.getDefaultState().withProperty(BlockEnclosed.TYPE, BlockEnclosed.EnumEnclosedBlockType.ALUMINUM_WIRE_HEAVY), 3);
                TileEntity tile = world.getTileEntity(blockpos2.down());
                if (tile instanceof TileEntityChestMP) {
                    ((TileEntityChestMP) tile).setLootTable(MPLootTables.CRASHED_ALIEN_PROBE, rand.nextLong());
                }
            } else if ("energy_storage".equals(entry.getValue())) {
                BlockPos blockpos2 = entry.getKey();
                world.setBlockState(blockpos2, GCBlocks.machineTiered.getDefaultState().withProperty(BlockMachineTiered.TYPE, BlockMachineTiered.EnumTieredMachineType.STORAGE_MODULE).withProperty(BlockMachineBase.FACING, rotation.rotate(EnumFacing.SOUTH)), 3);
                TileEntity tile = world.getTileEntity(blockpos2);
                if (tile instanceof TileEntityEnergyStorageModule) {
                    TileEntityEnergyStorageModule module = (TileEntityEnergyStorageModule) tile;
                    module.storage.setEnergyStored(500000.0F);
                    module.setInventorySlotContents(1, new ItemStack(VenusItems.atomicBattery));
                }
            }
        }
        return true;
    }
}
Also used : StructureBoundingBox(net.minecraft.world.gen.structure.StructureBoundingBox) TileEntityChestMP(stevekung.mods.moreplanets.utils.tileentity.TileEntityChestMP) TileEntityEnergyStorageModule(micdoodle8.mods.galacticraft.core.tile.TileEntityEnergyStorageModule) TileEntityLaserTurret(micdoodle8.mods.galacticraft.planets.venus.tile.TileEntityLaserTurret) PlacementSettings(net.minecraft.world.gen.structure.template.PlacementSettings) Rotation(net.minecraft.util.Rotation) MinecraftServer(net.minecraft.server.MinecraftServer) Template(net.minecraft.world.gen.structure.template.Template) TileEntity(net.minecraft.tileentity.TileEntity) TemplateManager(net.minecraft.world.gen.structure.template.TemplateManager) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) Map(java.util.Map)

Example 15 with TileEntityChestMP

use of stevekung.mods.moreplanets.utils.tileentity.TileEntityChestMP in project MorePlanets by SteveKunG.

the class RoomChestMP method addComponentParts.

@Override
public boolean addComponentParts(World world, Random rand, StructureBoundingBox boundingBox) {
    if (super.addComponentParts(world, rand, boundingBox)) {
        int chestX = this.sizeX / 2;
        int chestY = 1;
        int chestZ = this.sizeZ / 2;
        this.setBlockState(world, this.configuration.getAncientChestBlock().withProperty(BlockStateProperty.FACING_HORIZON, this.getDirection().getOpposite()), chestX, chestY, chestZ, boundingBox);
        BlockPos blockpos = new BlockPos(this.getXWithOffset(chestX, chestZ), this.getYWithOffset(chestY), this.getZWithOffset(chestX, chestZ));
        TileEntityChestMP chest = (TileEntityChestMP) world.getTileEntity(blockpos);
        if (chest != null) {
            chest.setLootTable(MPLootTables.COMMON_SPACE_DUNGEON, rand.nextLong());
        }
        return true;
    }
    return false;
}
Also used : TileEntityChestMP(stevekung.mods.moreplanets.utils.tileentity.TileEntityChestMP) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

TileEntityChestMP (stevekung.mods.moreplanets.utils.tileentity.TileEntityChestMP)15 BlockPos (net.minecraft.util.math.BlockPos)10 TileEntity (net.minecraft.tileentity.TileEntity)8 Nonnull (javax.annotation.Nonnull)3 ItemStack (net.minecraft.item.ItemStack)3 Map (java.util.Map)2 IBlockState (net.minecraft.block.state.IBlockState)2 MinecraftServer (net.minecraft.server.MinecraftServer)2 EnumFacing (net.minecraft.util.EnumFacing)2 Rotation (net.minecraft.util.Rotation)2 StructureBoundingBox (net.minecraft.world.gen.structure.StructureBoundingBox)2 PlacementSettings (net.minecraft.world.gen.structure.template.PlacementSettings)2 Template (net.minecraft.world.gen.structure.template.Template)2 TemplateManager (net.minecraft.world.gen.structure.template.TemplateManager)2 Method (java.lang.reflect.Method)1 Nullable (javax.annotation.Nullable)1 TileEntityAirLockController (micdoodle8.mods.galacticraft.core.tile.TileEntityAirLockController)1 TileEntityEnergyStorageModule (micdoodle8.mods.galacticraft.core.tile.TileEntityEnergyStorageModule)1 TileEntityFallenMeteor (micdoodle8.mods.galacticraft.core.tile.TileEntityFallenMeteor)1 TileEntityLaserTurret (micdoodle8.mods.galacticraft.planets.venus.tile.TileEntityLaserTurret)1