mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-19 19:59:36 +00:00
Switch a bunch of world.getblockstate calls in te's to self getblockstate
This commit is contained in:
1 parent
4079187457
commit
a35da8e163
25 files changed
+46
-50
No files matched your search
@@ -51,6 +51,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class TileAlfPortal extends TileMod implements ITickableTileEntity {
|
||||
|
||||
@@ -91,12 +92,11 @@ public class TileAlfPortal extends TileMod implements ITickableTileEntity {
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
BlockState iBlockState = world.getBlockState(getPos());
|
||||
if(iBlockState.get(BotaniaStateProps.ALFPORTAL_STATE) == AlfPortalState.OFF) {
|
||||
if(getBlockState().get(BotaniaStateProps.ALFPORTAL_STATE) == AlfPortalState.OFF) {
|
||||
ticksOpen = 0;
|
||||
return;
|
||||
}
|
||||
AlfPortalState state = iBlockState.get(BotaniaStateProps.ALFPORTAL_STATE);
|
||||
AlfPortalState state = getBlockState().get(BotaniaStateProps.ALFPORTAL_STATE);
|
||||
AlfPortalState newState = getValidState();
|
||||
|
||||
ticksOpen++;
|
||||
@@ -151,7 +151,7 @@ public class TileAlfPortal extends TileMod implements ITickableTileEntity {
|
||||
if(newState == AlfPortalState.OFF)
|
||||
for(int i = 0; i < 36; i++)
|
||||
blockParticle(state);
|
||||
world.setBlockState(getPos(), world.getBlockState(getPos()).with(BotaniaStateProps.ALFPORTAL_STATE, newState), 1 | 2);
|
||||
world.setBlockState(getPos(), getBlockState().with(BotaniaStateProps.ALFPORTAL_STATE, newState), 1 | 2);
|
||||
} else if(explode) {
|
||||
world.createExplosion(null, pos.getX() + .5, pos.getY() + 2.0, pos.getZ() + .5,
|
||||
3f, Explosion.Mode.DESTROY);
|
||||
@@ -208,11 +208,11 @@ public class TileAlfPortal extends TileMod implements ITickableTileEntity {
|
||||
}
|
||||
|
||||
public boolean onWanded() {
|
||||
AlfPortalState state = world.getBlockState(getPos()).get(BotaniaStateProps.ALFPORTAL_STATE);
|
||||
AlfPortalState state = getBlockState().get(BotaniaStateProps.ALFPORTAL_STATE);
|
||||
if(state == AlfPortalState.OFF) {
|
||||
AlfPortalState newState = getValidState();
|
||||
if(newState != AlfPortalState.OFF) {
|
||||
world.setBlockState(getPos(), world.getBlockState(getPos()).with(BotaniaStateProps.ALFPORTAL_STATE, newState), 1 | 2);
|
||||
world.setBlockState(getPos(), getBlockState().with(BotaniaStateProps.ALFPORTAL_STATE, newState), 1 | 2);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -222,7 +222,7 @@ public class TileAlfPortal extends TileMod implements ITickableTileEntity {
|
||||
|
||||
private AxisAlignedBB getPortalAABB() {
|
||||
AxisAlignedBB aabb = new AxisAlignedBB(pos.add(-1, 1, 0), pos.add(2, 4, 1));
|
||||
if(world.getBlockState(getPos()).get(BotaniaStateProps.ALFPORTAL_STATE) == AlfPortalState.ON_X)
|
||||
if(getBlockState().get(BotaniaStateProps.ALFPORTAL_STATE) == AlfPortalState.ON_X)
|
||||
aabb = new AxisAlignedBB(pos.add(0, 1, -1), pos.add(1, 4, 2));
|
||||
|
||||
return aabb;
|
||||
@@ -317,20 +317,15 @@ public class TileAlfPortal extends TileMod implements ITickableTileEntity {
|
||||
}
|
||||
|
||||
public List<BlockPos> locatePylons() {
|
||||
List<BlockPos> list = new ArrayList<>();
|
||||
int range = 5;
|
||||
|
||||
BlockState pylonState = ModBlocks.naturaPylon.getDefaultState();
|
||||
|
||||
for(int i = -range; i < range + 1; i++)
|
||||
for(int j = -range; j < range + 1; j++)
|
||||
for(int k = -range; k < range + 1; k++) {
|
||||
BlockPos pos = getPos().add(i, j, k);
|
||||
if(world.getBlockState(pos) == pylonState && world.getBlockState(pos.down()).getBlock() instanceof BlockPool)
|
||||
list.add(pos);
|
||||
}
|
||||
|
||||
return list;
|
||||
return BlockPos.getAllInBox(getPos().add(-range, -range, -range), getPos().add(range, range, range))
|
||||
.filter(world::isBlockLoaded)
|
||||
.filter(p -> world.getBlockState(p) == pylonState && world.getBlockState(p.down()).getBlock() instanceof BlockPool)
|
||||
.map(BlockPos::toImmutable)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public void lightPylons() {
|
||||
|
||||
@@ -123,13 +123,13 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary,
|
||||
|
||||
if(!drainWater.isEmpty() && drainWater.getFluid() == Fluids.WATER && drainWater.getAmount() == FluidAttributes.BUCKET_VOLUME) {
|
||||
setFluid(Fluids.WATER);
|
||||
world.updateComparatorOutputLevel(pos, world.getBlockState(pos).getBlock());
|
||||
world.updateComparatorOutputLevel(pos, getBlockState().getBlock());
|
||||
fluidHandler.drain(new FluidStack(Fluids.WATER, FluidAttributes.BUCKET_VOLUME), IFluidHandler.FluidAction.EXECUTE);
|
||||
item.setItem(fluidHandler.getContainer());
|
||||
return true;
|
||||
} else if(!drainLava.isEmpty() && drainLava.getFluid() == Fluids.LAVA && drainLava.getAmount() == FluidAttributes.BUCKET_VOLUME) {
|
||||
setFluid(Fluids.LAVA);
|
||||
world.updateComparatorOutputLevel(pos, world.getBlockState(pos).getBlock());
|
||||
world.updateComparatorOutputLevel(pos, getBlockState().getBlock());
|
||||
fluidHandler.drain(new FluidStack(Fluids.LAVA, FluidAttributes.BUCKET_VOLUME), IFluidHandler.FluidAction.EXECUTE);
|
||||
item.setItem(fluidHandler.getContainer());
|
||||
return true;
|
||||
@@ -160,7 +160,7 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary,
|
||||
world.addEntity(outputItem);
|
||||
|
||||
setFluid(Fluids.EMPTY);
|
||||
world.updateComparatorOutputLevel(pos, world.getBlockState(pos).getBlock());
|
||||
world.updateComparatorOutputLevel(pos, getBlockState().getBlock());
|
||||
|
||||
world.addBlockEvent(getPos(), getBlockState().getBlock(), CRAFT_EFFECT_EVENT, 0);
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ public class TileAvatar extends TileSimpleInventory implements IAvatarTile, ITic
|
||||
|
||||
@Override
|
||||
public Direction getAvatarFacing() {
|
||||
return world.getBlockState(getPos()).get(BotaniaStateProps.CARDINALS);
|
||||
return getBlockState().get(BotaniaStateProps.CARDINALS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -159,7 +159,7 @@ public class TileBrewery extends TileSimpleInventory implements IManaReceiver, I
|
||||
|
||||
if(newSignal != signal) {
|
||||
signal = newSignal;
|
||||
world.updateComparatorOutputLevel(pos, world.getBlockState(pos).getBlock());
|
||||
world.updateComparatorOutputLevel(pos, getBlockState().getBlock());
|
||||
}
|
||||
|
||||
manaLastTick = mana;
|
||||
|
||||
@@ -85,7 +85,8 @@ public class TileCocoon extends TileMod implements ITickableTileEntity{
|
||||
for (Direction d : Direction.values()) {
|
||||
if (d != Direction.UP) {
|
||||
BlockPos blockPos = pos.offset(d);
|
||||
if (world.getBlockState(blockPos).getBlock() == Blocks.WATER) {
|
||||
if (world.isBlockLoaded(blockPos)
|
||||
&& world.getBlockState(blockPos).getBlock() == Blocks.WATER) {
|
||||
validWater.add(blockPos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ public class TileCraftCrate extends TileOpenCrate {
|
||||
|
||||
if(newSignal != signal) {
|
||||
signal = newSignal;
|
||||
world.updateComparatorOutputLevel(pos, world.getBlockState(pos).getBlock());
|
||||
world.updateComparatorOutputLevel(pos, getBlockState().getBlock());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -241,7 +241,7 @@ public class TileEnchanter extends TileMod implements ISparkAttachable, ITickabl
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
BlockState state = world.getBlockState(getPos());
|
||||
BlockState state = getBlockState();
|
||||
Direction.Axis axis = state.get(BotaniaStateProps.ENCHANTER_DIRECTION);
|
||||
|
||||
for(BlockPos pylon : PYLON_LOCATIONS.get(axis)) {
|
||||
|
||||
@@ -42,7 +42,7 @@ public class TileEnderEye extends TileMod implements ITickableTileEntity {
|
||||
if (world.isRemote)
|
||||
return;
|
||||
|
||||
boolean wasLooking = world.getBlockState(getPos()).get(BotaniaStateProps.POWERED);
|
||||
boolean wasLooking = getBlockState().get(BotaniaStateProps.POWERED);
|
||||
int range = 80;
|
||||
List<PlayerEntity> players = world.getEntitiesWithinAABB(PlayerEntity.class, new AxisAlignedBB(pos.add(-range, -range, -range), pos.add(range, range, range)));
|
||||
|
||||
@@ -60,7 +60,7 @@ public class TileEnderEye extends TileMod implements ITickableTileEntity {
|
||||
}
|
||||
|
||||
if(looking != wasLooking)
|
||||
world.setBlockState(getPos(), world.getBlockState(getPos()).with(BotaniaStateProps.POWERED, looking), 1 | 2);
|
||||
world.setBlockState(getPos(), getBlockState().with(BotaniaStateProps.POWERED, looking), 1 | 2);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -36,7 +36,7 @@ public class TileForestEye extends TileMod implements ITickableTileEntity {
|
||||
int entityCount = world.getEntitiesWithinAABB(AnimalEntity.class, new AxisAlignedBB(pos.add(-range, -range, -range), pos.add(range + 1, range + 1, range + 1))).size();
|
||||
if(entityCount != entities) {
|
||||
entities = entityCount;
|
||||
world.updateComparatorOutputLevel(pos, world.getBlockState(pos).getBlock());
|
||||
world.updateComparatorOutputLevel(pos, getBlockState().getBlock());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ public class TileHourglass extends TileSimpleInventory implements ITickableTileE
|
||||
flip = !flip;
|
||||
flipTicks = 4;
|
||||
if(!world.isRemote) {
|
||||
world.setBlockState(getPos(), world.getBlockState(getPos()).with(BotaniaStateProps.POWERED, true), 1);
|
||||
world.setBlockState(getPos(), getBlockState().with(BotaniaStateProps.POWERED, true), 1);
|
||||
world.getPendingBlockTicks().scheduleTick(pos, getBlockState().getBlock(), getBlockState().getBlock().tickRate(world));
|
||||
}
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ public class TileLightRelay extends TileMod implements ITickableTileEntity, IWan
|
||||
BlockPos endpoint = getEndpoint();
|
||||
|
||||
if(endpoint != null) {
|
||||
AxisAlignedBB aabb = world.getBlockState(pos).getShape(world, pos).getBoundingBox().offset(pos);
|
||||
AxisAlignedBB aabb = getBlockState().getShape(world, pos).getBoundingBox().offset(pos);
|
||||
float range = 0.5F;
|
||||
List<EnderPearlEntity> enderPearls = world.getEntitiesWithinAABB(EnderPearlEntity.class, aabb.grow(range));
|
||||
for(EnderPearlEntity pearl : enderPearls) {
|
||||
@@ -183,7 +183,7 @@ public class TileLightRelay extends TileMod implements ITickableTileEntity, IWan
|
||||
}
|
||||
|
||||
public BlockPos getNextDestination() {
|
||||
BlockState state = world.getBlockState(pos);
|
||||
BlockState state = getBlockState();
|
||||
if(state.getBlock() == ModBlocks.lightRelayToggle && state.get(BotaniaStateProps.POWERED))
|
||||
return null;
|
||||
else if(state.getBlock() == ModBlocks.lightRelayFork) {
|
||||
|
||||
@@ -71,7 +71,7 @@ public class TilePlatform extends TileMod {
|
||||
|
||||
private void swap(TilePlatform tile, boolean empty) {
|
||||
tile.camoState = empty ? null : camoState;
|
||||
world.notifyBlockUpdate(tile.getPos(), world.getBlockState(tile.getPos()), world.getBlockState(tile.getPos()), 3);
|
||||
world.notifyBlockUpdate(tile.getPos(), tile.getBlockState(), tile.getBlockState(), 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -159,7 +159,7 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver,
|
||||
|
||||
if(newSignal != signal) {
|
||||
signal = newSignal;
|
||||
world.updateComparatorOutputLevel(pos, world.getBlockState(pos).getBlock());
|
||||
world.updateComparatorOutputLevel(pos, getBlockState().getBlock());
|
||||
}
|
||||
|
||||
updateRecipe();
|
||||
|
||||
@@ -68,7 +68,7 @@ public class TileSparkChanger extends TileSimpleInventory {
|
||||
if(transfers != null)
|
||||
transfers.clear();
|
||||
itemHandler.setStackInSlot(0, sparkStack);
|
||||
world.updateComparatorOutputLevel(pos, world.getBlockState(pos).getBlock());
|
||||
world.updateComparatorOutputLevel(pos, getBlockState().getBlock());
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ public class TileTerraPlate extends TileMod implements ISparkAttachable, ITickab
|
||||
else item.setItem(new ItemStack(ModItems.terrasteel));
|
||||
world.playSound(null, item.posX, item.posY, item.posZ, ModSounds.terrasteelCraft, SoundCategory.BLOCKS, 1, 1);
|
||||
mana = 0;
|
||||
world.updateComparatorOutputLevel(pos, world.getBlockState(pos).getBlock());
|
||||
world.updateComparatorOutputLevel(pos, getBlockState().getBlock());
|
||||
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos);
|
||||
}
|
||||
}
|
||||
@@ -167,7 +167,7 @@ public class TileTerraPlate extends TileMod implements ISparkAttachable, ITickab
|
||||
@Override
|
||||
public void recieveMana(int mana) {
|
||||
this.mana = Math.max(0, Math.min(MAX_MANA, this.mana + mana));
|
||||
world.updateComparatorOutputLevel(pos, world.getBlockState(pos).getBlock());
|
||||
world.updateComparatorOutputLevel(pos, getBlockState().getBlock());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -38,7 +38,7 @@ public class TileTeruTeruBozu extends TileMod implements ITickableTileEntity {
|
||||
}
|
||||
|
||||
if(wasRaining != isRaining)
|
||||
world.updateComparatorOutputLevel(pos, world.getBlockState(pos).getBlock());
|
||||
world.updateComparatorOutputLevel(pos, getBlockState().getBlock());
|
||||
wasRaining = isRaining;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -104,7 +104,7 @@ public class TileCorporeaCrystalCube extends TileCorporeaBase implements ICorpor
|
||||
int oldCompValue = compValue;
|
||||
compValue = CorporeaHelper.signalStrengthForRequestSize(itemCount);
|
||||
if(compValue != oldCompValue)
|
||||
world.updateComparatorOutputLevel(pos, world.getBlockState(pos).getBlock());
|
||||
world.updateComparatorOutputLevel(pos, getBlockState().getBlock());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -49,8 +49,8 @@ public class TileCorporeaInterceptor extends TileCorporeaBase implements ICorpor
|
||||
for(ItemStack stack_ : stacks)
|
||||
missing -= stack_.getCount();
|
||||
|
||||
if(missing > 0 && !world.getBlockState(getPos()).get(BotaniaStateProps.POWERED)) {
|
||||
world.setBlockState(getPos(), world.getBlockState(getPos()).with(BotaniaStateProps.POWERED, true));
|
||||
if(missing > 0 && !getBlockState().get(BotaniaStateProps.POWERED)) {
|
||||
world.setBlockState(getPos(), getBlockState().with(BotaniaStateProps.POWERED, true));
|
||||
world.getPendingBlockTicks().scheduleTick(getPos(), getBlockState().getBlock(), getBlockState().getBlock().tickRate(world));
|
||||
|
||||
TileEntity requestor = source.getSparkInventory().world.getTileEntity(source.getSparkInventory().pos);
|
||||
|
||||
@@ -68,7 +68,7 @@ public class TileCorporeaRetainer extends TileMod {
|
||||
this.requestCount = requestCount;
|
||||
|
||||
compValue = CorporeaHelper.signalStrengthForRequestSize(requestCount);
|
||||
world.updateComparatorOutputLevel(getPos(), world.getBlockState(getPos()).getBlock());
|
||||
world.updateComparatorOutputLevel(getPos(), getBlockState().getBlock());
|
||||
}
|
||||
|
||||
public int getComparatorValue() {
|
||||
@@ -93,7 +93,7 @@ public class TileCorporeaRetainer extends TileMod {
|
||||
request = null;
|
||||
requestCount = 0;
|
||||
compValue = 0;
|
||||
world.updateComparatorOutputLevel(getPos(), world.getBlockState(getPos()).getBlock());
|
||||
world.updateComparatorOutputLevel(getPos(), getBlockState().getBlock());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ public class TileBellows extends TileMod implements ITickableTileEntity {
|
||||
}
|
||||
|
||||
public TileEntity getLinkedTile() {
|
||||
Direction side = world.getBlockState(getPos()).get(BotaniaStateProps.CARDINALS);
|
||||
Direction side = getBlockState().get(BotaniaStateProps.CARDINALS);
|
||||
return world.getTileEntity(getPos().offset(side));
|
||||
}
|
||||
|
||||
|
||||
@@ -33,10 +33,10 @@ public class TileManaDetector extends TileMod implements ITickableTileEntity {
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
boolean state = world.getBlockState(getPos()).get(BotaniaStateProps.POWERED);
|
||||
boolean state = getBlockState().get(BotaniaStateProps.POWERED);
|
||||
boolean expectedState = world.getEntitiesWithinAABB(ThrowableEntity.class, new AxisAlignedBB(pos, pos.add(1, 1, 1)), Predicates.instanceOf(IManaBurst.class)).size() != 0;
|
||||
if(state != expectedState && !world.isRemote)
|
||||
world.setBlockState(getPos(), world.getBlockState(getPos()).with(BotaniaStateProps.POWERED, expectedState));
|
||||
world.setBlockState(getPos(), getBlockState().with(BotaniaStateProps.POWERED, expectedState));
|
||||
|
||||
if(expectedState)
|
||||
for(int i = 0; i < 4; i++) {
|
||||
|
||||
@@ -123,7 +123,7 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt
|
||||
this.mana = Math.max(0, Math.min(getCurrentMana() + mana, manaCap));
|
||||
if(old != this.mana) {
|
||||
markDirty();
|
||||
world.updateComparatorOutputLevel(pos, world.getBlockState(pos).getBlock());
|
||||
world.updateComparatorOutputLevel(pos, getBlockState().getBlock());
|
||||
markDispatchable();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class TilePrism extends TileSimpleInventory {
|
||||
|
||||
public void onBurstCollision(IManaBurst burst) {
|
||||
ItemStack lens = itemHandler.getStackInSlot(0);
|
||||
boolean active = !world.getBlockState(getPos()).get(BotaniaStateProps.POWERED);
|
||||
boolean active = !getBlockState().get(BotaniaStateProps.POWERED);
|
||||
boolean valid = !lens.isEmpty() && lens.getItem() instanceof ILens && (!(lens.getItem() instanceof ITinyPlanetExcempt) || ((ITinyPlanetExcempt) lens.getItem()).shouldPull(lens));
|
||||
|
||||
if(active) {
|
||||
@@ -87,7 +87,7 @@ public class TilePrism extends TileSimpleInventory {
|
||||
super.markDirty();
|
||||
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this);
|
||||
if(world != null && !world.isRemote) {
|
||||
BlockState state = world.getBlockState(pos);
|
||||
BlockState state = getBlockState();
|
||||
boolean hasLens = !itemHandler.getStackInSlot(0).isEmpty();
|
||||
if (state.getBlock() != ModBlocks.prism || state.get(BotaniaStateProps.HAS_LENS) != hasLens) {
|
||||
BlockState base = state.getBlock() == ModBlocks.prism ? state : ModBlocks.prism.getDefaultState();
|
||||
|
||||
@@ -97,7 +97,7 @@ public class TilePump extends TileMod implements ITickableTileEntity {
|
||||
hasCartOnTop = false;
|
||||
|
||||
if(comparator != lastComparator)
|
||||
world.updateComparatorOutputLevel(pos, world.getBlockState(pos).getBlock());
|
||||
world.updateComparatorOutputLevel(pos, getBlockState().getBlock());
|
||||
lastComparator = comparator;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ public class TileRedStringComparator extends TileRedString {
|
||||
} else comparatorValue = 0;
|
||||
|
||||
if(origVal != comparatorValue)
|
||||
world.updateComparatorOutputLevel(pos, world.getBlockState(pos).getBlock());
|
||||
world.updateComparatorOutputLevel(pos, getBlockState().getBlock());
|
||||
}
|
||||
|
||||
public int getComparatorValue() {
|
||||
|
||||
Reference in new issue
Block a user