use of stevekung.mods.moreplanets.utils.tileentity.TileEntityChestMP in project MorePlanets by SteveKunG.
the class StructureNibiruJungleTemplePieces method generateChest.
@Override
protected boolean generateChest(World world, StructureBoundingBox box, Random rand, 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, rand.nextLong());
}
return true;
} else {
return false;
}
}
use of stevekung.mods.moreplanets.utils.tileentity.TileEntityChestMP in project MorePlanets by SteveKunG.
the class ComponentCrashedAlienShipPieces method replaceDataBlocks2.
@SuppressWarnings("deprecation")
private static void replaceDataBlocks2(World world, Random rand, Rotation rotation, Template template, BlockPos pos, PlacementSettings settings) {
Map<BlockPos, String> map = template.getDataBlocks(pos, settings);
for (Map.Entry<BlockPos, String> entry : map.entrySet()) {
String dataName = entry.getValue();
BlockPos dataPos = entry.getKey();
if ("airlock".equals(dataName)) {
world.setBlockState(dataPos, GCBlocks.airLockFrame.getStateFromMeta(1), 3);
TileEntity tile = world.getTileEntity(dataPos);
if (tile instanceof TileEntityAirLockController) {
((TileEntityAirLockController) tile).playerDistanceSelection = 1;
}
} else if ("chest_or_crystals".equals(dataName)) {
if (rand.nextFloat() > 0.95F) {
world.setBlockState(dataPos, MPBlocks.ALIEN_CHEST.getDefaultState().withRotation(rotation), 3);
TileEntity tile = world.getTileEntity(dataPos);
if (tile instanceof TileEntityChestMP) {
((TileEntityChestMP) tile).setLootTable(MPLootTables.CRASHED_ALIEN_SHIP, rand.nextLong());
}
} else if (rand.nextFloat() > 0.75F) {
world.setBlockState(dataPos, GCBlocks.fallenMeteor.getDefaultState(), 3);
TileEntity tile = world.getTileEntity(dataPos);
if (tile instanceof TileEntityFallenMeteor) {
((TileEntityFallenMeteor) tile).heatLevel = 0;
}
} else {
world.setBlockState(dataPos, MPBlocks.INFECTED_PURLONITE_CRYSTAL.getDefaultState(), 3);
}
} else if ("arclamp_west".equals(dataName)) {
world.setBlockState(dataPos, GCBlocks.brightLamp.getDefaultState().withProperty(BlockBrightLamp.FACING, rotation.rotate(EnumFacing.WEST)), 3);
} else if ("arclamp_east".equals(dataName)) {
world.setBlockState(dataPos, GCBlocks.brightLamp.getDefaultState().withProperty(BlockBrightLamp.FACING, rotation.rotate(EnumFacing.EAST)), 3);
}
}
}
use of stevekung.mods.moreplanets.utils.tileentity.TileEntityChestMP in project MorePlanets by SteveKunG.
the class DoubleChestItemHandlerMP method getStackInSlot.
@Override
@Nonnull
public ItemStack getStackInSlot(int slot) {
boolean accessingUpperChest = slot < 27;
int targetSlot = accessingUpperChest ? slot : slot - 27;
TileEntityChestMP chest = this.getChest(accessingUpperChest);
return chest != null ? chest.getStackInSlot(targetSlot) : ItemStack.EMPTY;
}
use of stevekung.mods.moreplanets.utils.tileentity.TileEntityChestMP in project MorePlanets by SteveKunG.
the class DoubleChestItemHandlerMP method insertItem.
@Override
@Nonnull
public ItemStack insertItem(int slot, @Nonnull ItemStack itemStack, boolean simulate) {
boolean accessingUpperChest = slot < 27;
int targetSlot = accessingUpperChest ? slot : slot - 27;
TileEntityChestMP chest = this.getChest(accessingUpperChest);
if (chest == null) {
return itemStack;
}
int starting = itemStack.getCount();
ItemStack ret = chest.getSingleChestHandler().insertItem(targetSlot, itemStack, simulate);
if (ret.getCount() != starting && !simulate) {
chest = this.getChest(!accessingUpperChest);
if (chest != null) {
chest.markDirty();
}
}
return ret;
}
use of stevekung.mods.moreplanets.utils.tileentity.TileEntityChestMP in project MorePlanets by SteveKunG.
the class DoubleChestItemHandlerMP method equals.
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || this.getClass() != o.getClass()) {
return false;
}
DoubleChestItemHandlerMP that = (DoubleChestItemHandlerMP) o;
if (this.hashCode != that.hashCode) {
return false;
}
final TileEntityChestMP otherChest = this.getOtherChest();
if (this.mainChestIsUpper == that.mainChestIsUpper) {
return Objects.equal(this.mainChest, that.mainChest) && Objects.equal(otherChest, that.getOtherChest());
} else {
return Objects.equal(this.mainChest, that.getOtherChest()) && Objects.equal(otherChest, that.mainChest);
}
}
Aggregations