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;
}
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());
}
}
}
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;
}
}
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;
}
}
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;
}
Aggregations