Skip to content

Commit

Permalink
Standardise use of static LockableLootTileEntity::setTable. (#338)
Browse files Browse the repository at this point in the history
This changes nothing, as the code for the static method checks for an
instance of LockableLootTileEntity first. Likewise, while it does affect
sarcophagus blocks, etc, that will have no interaction with Lootr as
those blocks aren't set to be replaced (hopefully).
  • Loading branch information
noobanidus committed Aug 28, 2021
1 parent 9ff739e commit f3d2a31
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.teammetallurgy.atum.init.AtumStructurePieces;
import net.minecraft.block.Blocks;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.LockableLootTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Mirror;
import net.minecraft.util.ResourceLocation;
Expand Down Expand Up @@ -59,30 +60,21 @@ protected void handleDataMarker(@Nonnull String function, @Nonnull BlockPos pos,
if (rand.nextDouble() <= 0.15D) {
world.setBlockState(pos, ChestBaseBlock.correctFacing(world, pos, AtumBlocks.DEADWOOD_CRATE.getDefaultState(), AtumBlocks.DEADWOOD_CRATE), 2);

TileEntity tileEntity = world.getTileEntity(pos);
if (tileEntity instanceof CrateTileEntity) {
((CrateTileEntity) tileEntity).setLootTable(AtumLootTables.CRATE, rand.nextLong());
}
LockableLootTileEntity.setLootTable(world, rand, pos, AtumLootTables.CRATE);
} else {
world.setBlockState(pos, Blocks.AIR.getDefaultState(), 2);
}
}
} else if (function.equals("GirafiSarcophagus")) {
BlockPos posDown = pos.down();
if (box.isVecInside(posDown)) {
TileEntity tileentity = world.getTileEntity(posDown);
if (tileentity instanceof SarcophagusTileEntity) {
((SarcophagusTileEntity) tileentity).setLootTable(AtumLootTables.GIRAFI_TOMB, rand.nextLong());
}
LockableLootTileEntity.setLootTable(world, rand, posDown, AtumLootTables.GIRAFI_TOMB);
world.setBlockState(pos, Blocks.AIR.getDefaultState(), 2);
}
} else if (function.equals("Sarcophagus")) {
BlockPos posDown = pos.down();
if (box.isVecInside(posDown)) {
TileEntity tileentity = world.getTileEntity(posDown);
if (tileentity instanceof SarcophagusTileEntity) {
((SarcophagusTileEntity) tileentity).setLootTable(AtumLootTables.PHARAOH, rand.nextLong());
}
LockableLootTileEntity.setLootTable(world, rand, posDown, AtumLootTables.PHARAOH);
world.setBlockState(pos, Blocks.AIR.getDefaultState(), 2);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import net.minecraft.block.LadderBlock;
import net.minecraft.entity.EntityType;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.LockableLootTileEntity;
import net.minecraft.tileentity.MobSpawnerTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
Expand Down Expand Up @@ -193,31 +194,21 @@ protected void handleDataMarker(@Nonnull String function, @Nonnull BlockPos pos,
if (box.isVecInside(pos)) {
if (rand.nextDouble() <= 0.2D) {
world.setBlockState(pos, ChestBaseBlock.correctFacing(world, pos, AtumBlocks.DEADWOOD_CRATE.getDefaultState(), AtumBlocks.DEADWOOD_CRATE), 2);

TileEntity tileEntity = world.getTileEntity(pos);
if (tileEntity instanceof CrateTileEntity) {
((CrateTileEntity) tileEntity).setLootTable(AtumLootTables.CRATE, rand.nextLong());
}
LockableLootTileEntity.setLootTable(world, rand, pos, AtumLootTables.CRATE);
} else {
world.setBlockState(pos, Blocks.AIR.getDefaultState(), 2);
}
}
} else if (function.equals("Chest")) {
BlockPos posDown = pos.down();
if (box.isVecInside(posDown)) {
TileEntity tileentity = world.getTileEntity(posDown);
if (tileentity instanceof LimestoneChestTileEntity) {
((LimestoneChestTileEntity) tileentity).setLootTable(AtumLootTables.PYRAMID_CHEST, rand.nextLong());
}
LockableLootTileEntity.setLootTable(world, rand, posDown, AtumLootTables.PYRAMID_CHEST);
}
world.setBlockState(pos, Blocks.AIR.getDefaultState(), 2);
} else if (function.equals("Sarcophagus")) {
BlockPos posDown = pos.down();
if (box.isVecInside(posDown)) {
TileEntity tileentity = world.getTileEntity(posDown);
if (tileentity instanceof SarcophagusTileEntity) {
((SarcophagusTileEntity) tileentity).setLootTable(AtumLootTables.PHARAOH, rand.nextLong());
}
LockableLootTileEntity.setLootTable(world, rand, posDown, AtumLootTables.PHARAOH);
}
world.setBlockState(pos, Blocks.AIR.getDefaultState(), 2);
} else if (function.equals("NebuTorch")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.minecraft.block.Blocks;
import net.minecraft.entity.EntityType;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.LockableLootTileEntity;
import net.minecraft.tileentity.MobSpawnerTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
Expand Down Expand Up @@ -82,11 +83,7 @@ protected void handleDataMarker(@Nonnull String function, @Nonnull BlockPos pos,
if (box.isVecInside(pos)) {
if (rand.nextDouble() <= 0.15D) {
world.setBlockState(pos, ChestBaseBlock.correctFacing(world, pos, AtumBlocks.DEADWOOD_CRATE.getDefaultState(), AtumBlocks.DEADWOOD_CRATE), 2);

TileEntity tileEntity = world.getTileEntity(pos);
if (tileEntity instanceof CrateTileEntity) {
((CrateTileEntity) tileEntity).setLootTable(AtumLootTables.CRATE, rand.nextLong());
}
LockableLootTileEntity.setLootTable(world, rand, pos, AtumLootTables.CRATE);
} else {
world.setBlockState(pos, Blocks.AIR.getDefaultState(), 2);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.teammetallurgy.atum.world.gen.structure.ruins.RuinPieces;
import net.minecraft.block.Blocks;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.LockableLootTileEntity;
import net.minecraft.tileentity.MobSpawnerTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Mirror;
Expand Down Expand Up @@ -71,21 +72,15 @@ protected void handleDataMarker(@Nonnull String function, @Nonnull BlockPos pos,
if (rand.nextDouble() < 0.2D) {
world.setBlockState(pos, Blocks.AIR.getDefaultState(), 2); //Set structure block to air, to remove its TE
world.setBlockState(pos, ChestBaseBlock.correctFacing(world, pos, AtumBlocks.DEADWOOD_CRATE.getDefaultState(), AtumBlocks.DEADWOOD_CRATE), 2);
TileEntity tileEntity = world.getTileEntity(pos);
if (tileEntity instanceof CrateTileEntity) {
((CrateTileEntity) tileEntity).setLootTable(AtumLootTables.CRATE, rand.nextLong());
}
LockableLootTileEntity.setLootTable(world, rand, pos, AtumLootTables.CRATE);
} else {
world.setBlockState(pos, Blocks.AIR.getDefaultState(), 2);
}
}
} else if (function.equals("Chest")) {
BlockPos posDown = pos.down();
if (box.isVecInside(posDown)) {
TileEntity tileentity = world.getTileEntity(posDown);
if (tileentity instanceof LimestoneChestTileEntity) {
((LimestoneChestTileEntity) tileentity).setLootTable(AtumLootTables.TOMB_CHEST, rand.nextLong());
}
LockableLootTileEntity.setLootTable(world, rand, posDown, AtumLootTables.TOMB_CHEST);
}
world.setBlockState(pos, Blocks.AIR.getDefaultState(), 2);
}
Expand Down

0 comments on commit f3d2a31

Please sign in to comment.