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