mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-16 06:51:56 +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.Pair;
|
||||
|
||||
import com.jozufozu.flywheel.util.box.GridAlignedBB;
|
||||
import com.jozufozu.flywheel.util.box.ImmutableBox;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.AllInteractionBehaviours;
|
||||
import com.simibubi.create.AllMovementBehaviours;
|
||||
|
@ -1178,21 +1176,25 @@ public abstract class Contraption {
|
|||
|
||||
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) {
|
||||
betterBounds.setMaxX(contraptionBounds.getMaxX());
|
||||
betterBounds.setMinX(contraptionBounds.getMinX());
|
||||
maxX = (int) bounds.maxX;
|
||||
minX = (int) bounds.minX;
|
||||
} else if (axis == Direction.Axis.Y) {
|
||||
betterBounds.setMaxY(contraptionBounds.getMaxY());
|
||||
betterBounds.setMinY(contraptionBounds.getMinY());
|
||||
maxY = (int) bounds.maxY;
|
||||
minY = (int) bounds.minY;
|
||||
} else if (axis == Direction.Axis.Z) {
|
||||
betterBounds.setMaxZ(contraptionBounds.getMaxZ());
|
||||
betterBounds.setMinZ(contraptionBounds.getMinZ());
|
||||
maxZ = (int) bounds.maxZ;
|
||||
minZ = (int) bounds.minZ;
|
||||
}
|
||||
|
||||
bounds = betterBounds.toAABB();
|
||||
bounds = new AABB(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
}
|
||||
|
||||
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 net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
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) {
|
||||
int segment = (int) Math.floor(beltPos) * 2;
|
||||
if (controller.lighter.light == null || segment >= controller.lighter.light.length || segment < 0)
|
||||
int segment = (int) Math.floor(beltPos);
|
||||
if (controller.lighter == null || segment >= controller.lighter.lightSegments() || segment < 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.utility.NBTHelper;
|
||||
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
|
@ -544,8 +545,7 @@ public class BeltTileEntity extends KineticTileEntity {
|
|||
*/
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
class BeltLighter implements LightListener {
|
||||
// client
|
||||
public byte[] light;
|
||||
private byte[] light;
|
||||
|
||||
public BeltLighter() {
|
||||
initializeLight();
|
||||
|
@ -553,6 +553,23 @@ public class BeltTileEntity extends KineticTileEntity {
|
|||
.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
|
||||
public GridAlignedBB getVolume() {
|
||||
BlockPos endPos = BeltHelper.getPositionForOffset(BeltTileEntity.this, beltLength - 1);
|
||||
|
|
Loading…
Reference in a new issue