mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-28 16:06:48 +01:00
Towards client-only flywheel
- Fix nullpointer with belt lighter - Remove references to GridAlignedBB and ImmutableBox in Contraption
This commit is contained in:
parent
5910ad5a03
commit
2cdbdfa218
3 changed files with 35 additions and 17 deletions
|
@ -25,8 +25,6 @@ import javax.annotation.Nullable;
|
||||||
import org.apache.commons.lang3.tuple.MutablePair;
|
import org.apache.commons.lang3.tuple.MutablePair;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.util.box.GridAlignedBB;
|
|
||||||
import com.jozufozu.flywheel.util.box.ImmutableBox;
|
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.AllInteractionBehaviours;
|
import com.simibubi.create.AllInteractionBehaviours;
|
||||||
import com.simibubi.create.AllMovementBehaviours;
|
import com.simibubi.create.AllMovementBehaviours;
|
||||||
|
@ -1178,21 +1176,25 @@ public abstract class Contraption {
|
||||||
|
|
||||||
int radius = (int) (Math.ceil(Math.sqrt(getRadius(blocks, axis))));
|
int radius = (int) (Math.ceil(Math.sqrt(getRadius(blocks, axis))));
|
||||||
|
|
||||||
GridAlignedBB betterBounds = GridAlignedBB.ofRadius(radius);
|
int maxX = radius + 2;
|
||||||
|
int maxY = radius + 2;
|
||||||
|
int maxZ = radius + 2;
|
||||||
|
int minX = -radius - 1;
|
||||||
|
int minY = -radius - 1;
|
||||||
|
int minZ = -radius - 1;
|
||||||
|
|
||||||
ImmutableBox contraptionBounds = GridAlignedBB.from(bounds);
|
|
||||||
if (axis == Direction.Axis.X) {
|
if (axis == Direction.Axis.X) {
|
||||||
betterBounds.setMaxX(contraptionBounds.getMaxX());
|
maxX = (int) bounds.maxX;
|
||||||
betterBounds.setMinX(contraptionBounds.getMinX());
|
minX = (int) bounds.minX;
|
||||||
} else if (axis == Direction.Axis.Y) {
|
} else if (axis == Direction.Axis.Y) {
|
||||||
betterBounds.setMaxY(contraptionBounds.getMaxY());
|
maxY = (int) bounds.maxY;
|
||||||
betterBounds.setMinY(contraptionBounds.getMinY());
|
minY = (int) bounds.minY;
|
||||||
} else if (axis == Direction.Axis.Z) {
|
} else if (axis == Direction.Axis.Z) {
|
||||||
betterBounds.setMaxZ(contraptionBounds.getMaxZ());
|
maxZ = (int) bounds.maxZ;
|
||||||
betterBounds.setMinZ(contraptionBounds.getMinZ());
|
minZ = (int) bounds.minZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bounds = betterBounds.toAABB();
|
bounds = new AABB(minX, minY, minZ, maxX, maxY, maxZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addExtraInventories(Entity entity) {}
|
public void addExtraInventories(Entity entity) {}
|
||||||
|
|
|
@ -25,7 +25,6 @@ import com.simibubi.create.foundation.utility.Iterate;
|
||||||
import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld;
|
import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.LightTexture;
|
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
|
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
|
||||||
|
@ -308,11 +307,11 @@ public class BeltRenderer extends SafeTileEntityRenderer<BeltTileEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getPackedLight(BeltTileEntity controller, float beltPos) {
|
protected int getPackedLight(BeltTileEntity controller, float beltPos) {
|
||||||
int segment = (int) Math.floor(beltPos) * 2;
|
int segment = (int) Math.floor(beltPos);
|
||||||
if (controller.lighter.light == null || segment >= controller.lighter.light.length || segment < 0)
|
if (controller.lighter == null || segment >= controller.lighter.lightSegments() || segment < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return LightTexture.pack(controller.lighter.light[segment], controller.lighter.light[segment + 1]);
|
return controller.lighter.getPackedLight(segment);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemS
|
||||||
import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour.TransportedResult;
|
import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour.TransportedResult;
|
||||||
import com.simibubi.create.foundation.utility.NBTHelper;
|
import com.simibubi.create.foundation.utility.NBTHelper;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.LightTexture;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
|
@ -544,8 +545,7 @@ public class BeltTileEntity extends KineticTileEntity {
|
||||||
*/
|
*/
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
class BeltLighter implements LightListener {
|
class BeltLighter implements LightListener {
|
||||||
// client
|
private byte[] light;
|
||||||
public byte[] light;
|
|
||||||
|
|
||||||
public BeltLighter() {
|
public BeltLighter() {
|
||||||
initializeLight();
|
initializeLight();
|
||||||
|
@ -553,6 +553,23 @@ public class BeltTileEntity extends KineticTileEntity {
|
||||||
.addListener(this);
|
.addListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the number of belt segments represented by the lighter.
|
||||||
|
* @return The number of segments.
|
||||||
|
*/
|
||||||
|
public int lightSegments() {
|
||||||
|
return light == null ? 0 : light.length / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the light value for a given segment.
|
||||||
|
* @param segment The segment to get the light value for.
|
||||||
|
* @return The light value.
|
||||||
|
*/
|
||||||
|
public int getPackedLight(int segment) {
|
||||||
|
return light == null ? 0 : LightTexture.pack(light[segment * 2], light[segment * 2 + 1]);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GridAlignedBB getVolume() {
|
public GridAlignedBB getVolume() {
|
||||||
BlockPos endPos = BeltHelper.getPositionForOffset(BeltTileEntity.this, beltLength - 1);
|
BlockPos endPos = BeltHelper.getPositionForOffset(BeltTileEntity.this, beltLength - 1);
|
||||||
|
|
Loading…
Reference in a new issue