mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-16 09:13:42 +01:00
cache KTEs' renderBoundingBox
This commit is contained in:
parent
b1905ddfd4
commit
0ad6db4bf7
15 changed files with 71 additions and 32 deletions
|
@ -26,10 +26,12 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Direction.AxisDirection;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -464,7 +466,7 @@ public abstract class KineticTileEntity extends SmartTileEntity
|
|||
|
||||
@Override
|
||||
public double getMaxRenderDistanceSquared() {
|
||||
return 16384.0D; // TODO: make this a config option
|
||||
return super.getMaxRenderDistanceSquared();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -492,4 +494,17 @@ public abstract class KineticTileEntity extends SmartTileEntity
|
|||
public void onChunkLightUpdate() {
|
||||
CreateClient.kineticRenderer.onLightUpdate(this);
|
||||
}
|
||||
|
||||
protected AxisAlignedBB cachedBoundingBox;
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public AxisAlignedBB getRenderBoundingBox() {
|
||||
if (cachedBoundingBox == null) {
|
||||
cachedBoundingBox = makeRenderBoundingBox();
|
||||
}
|
||||
return cachedBoundingBox;
|
||||
}
|
||||
|
||||
protected AxisAlignedBB makeRenderBoundingBox() {
|
||||
return super.getRenderBoundingBox();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,10 +100,14 @@ public abstract class PortableStorageInterfaceTileEntity extends SmartTileEntity
|
|||
return powered;
|
||||
}
|
||||
|
||||
protected AxisAlignedBB cachedBoundingBox;
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public AxisAlignedBB getRenderBoundingBox() {
|
||||
return super.getRenderBoundingBox().grow(2);
|
||||
if (cachedBoundingBox == null) {
|
||||
cachedBoundingBox = super.getRenderBoundingBox().grow(2);
|
||||
}
|
||||
return cachedBoundingBox;
|
||||
}
|
||||
|
||||
public boolean isTransferring() {
|
||||
|
|
|
@ -36,7 +36,7 @@ public class CrushingWheelTileEntity extends KineticTileEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getRenderBoundingBox() {
|
||||
public AxisAlignedBB makeRenderBoundingBox() {
|
||||
return new AxisAlignedBB(pos).grow(1);
|
||||
}
|
||||
|
||||
|
|
|
@ -341,8 +341,8 @@ public class DeployerTileEntity extends KineticTileEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getRenderBoundingBox() {
|
||||
return super.getRenderBoundingBox().grow(3);
|
||||
public AxisAlignedBB makeRenderBoundingBox() {
|
||||
return super.makeRenderBoundingBox().grow(3);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -47,8 +47,8 @@ public class FlywheelTileEntity extends GeneratingKineticTileEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getRenderBoundingBox() {
|
||||
return super.getRenderBoundingBox().grow(2);
|
||||
public AxisAlignedBB makeRenderBoundingBox() {
|
||||
return super.makeRenderBoundingBox().grow(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -14,6 +14,8 @@ import net.minecraft.tileentity.TileEntityType;
|
|||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
public class EngineTileEntity extends SmartTileEntity {
|
||||
|
||||
|
@ -34,9 +36,14 @@ public class EngineTileEntity extends SmartTileEntity {
|
|||
return true;
|
||||
}
|
||||
|
||||
protected AxisAlignedBB cachedBoundingBox;
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public AxisAlignedBB getRenderBoundingBox() {
|
||||
return super.getRenderBoundingBox().grow(1.5f);
|
||||
if (cachedBoundingBox == null) {
|
||||
cachedBoundingBox = super.getRenderBoundingBox().grow(1.5f);
|
||||
}
|
||||
return cachedBoundingBox;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -80,7 +80,7 @@ public class MechanicalMixerTileEntity extends BasinOperatingTileEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getRenderBoundingBox() {
|
||||
public AxisAlignedBB makeRenderBoundingBox() {
|
||||
return new AxisAlignedBB(pos).expand(0, -1.5, 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getRenderBoundingBox() {
|
||||
public AxisAlignedBB makeRenderBoundingBox() {
|
||||
return new AxisAlignedBB(pos).expand(0, -1.5, 0)
|
||||
.expand(0, 1, 0);
|
||||
}
|
||||
|
|
|
@ -32,8 +32,8 @@ public class PulleyTileEntity extends LinearActuatorTileEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getRenderBoundingBox() {
|
||||
return super.getRenderBoundingBox().expand(0, -offset, 0);
|
||||
public AxisAlignedBB makeRenderBoundingBox() {
|
||||
return super.makeRenderBoundingBox().expand(0, -offset, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -36,7 +36,7 @@ public class WaterWheelTileEntity extends GeneratingKineticTileEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getRenderBoundingBox() {
|
||||
public AxisAlignedBB makeRenderBoundingBox() {
|
||||
return new AxisAlignedBB(pos).grow(1);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,8 @@ import net.minecraft.tileentity.TileEntityType;
|
|||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
@ -49,9 +51,14 @@ public class SpoutTileEntity extends SmartTileEntity {
|
|||
processingTicks = -1;
|
||||
}
|
||||
|
||||
protected AxisAlignedBB cachedBoundingBox;
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public AxisAlignedBB getRenderBoundingBox() {
|
||||
return super.getRenderBoundingBox().expand(0, -2, 0);
|
||||
if (cachedBoundingBox == null) {
|
||||
cachedBoundingBox = super.getRenderBoundingBox().expand(0, -2, 0);
|
||||
}
|
||||
return cachedBoundingBox;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -104,7 +104,10 @@ public class FluidTankTileEntity extends SmartTileEntity {
|
|||
}
|
||||
|
||||
public boolean isController() {
|
||||
return controller == null || controller.equals(pos);
|
||||
return controller == null ||
|
||||
pos.getX() == controller.getX() &&
|
||||
pos.getY() == controller.getY() &&
|
||||
pos.getZ() == controller.getZ();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -281,12 +284,17 @@ public class FluidTankTileEntity extends SmartTileEntity {
|
|||
return isController() ? pos : controller;
|
||||
}
|
||||
|
||||
private AxisAlignedBB cachedBoundingBox;
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public AxisAlignedBB getRenderBoundingBox() {
|
||||
if (isController())
|
||||
return super.getRenderBoundingBox().expand(width - 1, height - 1, width - 1);
|
||||
return super.getRenderBoundingBox();
|
||||
if (cachedBoundingBox == null) {
|
||||
if (isController())
|
||||
cachedBoundingBox = super.getRenderBoundingBox().expand(width - 1, height - 1, width - 1);
|
||||
else
|
||||
cachedBoundingBox = super.getRenderBoundingBox();
|
||||
}
|
||||
return cachedBoundingBox;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -137,17 +137,12 @@ public class BeltTileEntity extends KineticTileEntity {
|
|||
return super.calculateStressApplied();
|
||||
}
|
||||
|
||||
private AxisAlignedBB cachedBoundingBox;
|
||||
@Override
|
||||
public AxisAlignedBB getRenderBoundingBox() {
|
||||
if (cachedBoundingBox == null) {
|
||||
if (!isController())
|
||||
cachedBoundingBox = super.getRenderBoundingBox();
|
||||
else
|
||||
cachedBoundingBox = super.getRenderBoundingBox().grow(beltLength + 1);
|
||||
}
|
||||
|
||||
return cachedBoundingBox;
|
||||
public AxisAlignedBB makeRenderBoundingBox() {
|
||||
if (!isController())
|
||||
return super.makeRenderBoundingBox();
|
||||
else
|
||||
return super.makeRenderBoundingBox().grow(beltLength + 1);
|
||||
}
|
||||
|
||||
protected void initializeItemHandler() {
|
||||
|
@ -275,7 +270,10 @@ public class BeltTileEntity extends KineticTileEntity {
|
|||
}
|
||||
|
||||
public boolean isController() {
|
||||
return pos.equals(controller);
|
||||
return controller != null &&
|
||||
pos.getX() == controller.getX() &&
|
||||
pos.getY() == controller.getY() &&
|
||||
pos.getZ() == controller.getZ();
|
||||
}
|
||||
|
||||
public float getBeltMovementSpeed() {
|
||||
|
|
|
@ -24,7 +24,7 @@ public class SimpleKineticTileEntity extends KineticTileEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getRenderBoundingBox() {
|
||||
public AxisAlignedBB makeRenderBoundingBox() {
|
||||
return new AxisAlignedBB(pos).grow(1);
|
||||
}
|
||||
|
||||
|
|
|
@ -139,8 +139,8 @@ public class ArmTileEntity extends KineticTileEntity {
|
|||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public AxisAlignedBB getRenderBoundingBox() {
|
||||
return super.getRenderBoundingBox().grow(3);
|
||||
public AxisAlignedBB makeRenderBoundingBox() {
|
||||
return super.makeRenderBoundingBox().grow(3);
|
||||
}
|
||||
|
||||
private boolean checkForMusicAmong(List<ArmInteractionPoint> list) {
|
||||
|
|
Loading…
Reference in a new issue