Cranking out fixes

- Fix hand crank not deleting its rotatingModel
- Fix exception setting up pulley lightcache
- Bump flywheel build to fix garbage models
This commit is contained in:
Jozufozu 2024-07-27 18:30:40 -07:00
parent 5be92fcde8
commit eae8cd467b
3 changed files with 21 additions and 9 deletions

View file

@ -23,7 +23,7 @@ use_parchment = true
# dependency versions
registrate_version = MC1.20-1.3.3
flywheel_minecraft_version = 1.20.1
flywheel_version = 1.0.0-beta-103
flywheel_version = 1.0.0-beta-104
jei_minecraft_version = 1.20.1
jei_version = 15.2.0.22
curios_minecraft_version = 1.20.1

View file

@ -36,7 +36,7 @@ public abstract class AbstractPulleyVisual<T extends KineticBlockEntity> extends
protected final Direction rotatingAbout;
protected final Axis rotationAxis;
private final LightCache lightCache = new LightCache(1);
private final LightCache lightCache = new LightCache();
private float offset;
@ -60,6 +60,12 @@ public abstract class AbstractPulleyVisual<T extends KineticBlockEntity> extends
updateOffset(partialTick);
}
@Override
public void setSectionCollector(SectionCollector sectionCollector) {
super.setSectionCollector(sectionCollector);
lightCache.updateSections();
}
protected abstract Instancer<OrientedInstance> getRopeModel();
protected abstract Instancer<OrientedInstance> getMagnetModel();
@ -172,16 +178,11 @@ public abstract class AbstractPulleyVisual<T extends KineticBlockEntity> extends
}
private class LightCache {
private final ByteList data;
private final ByteList data = new ByteArrayList();
private final LongSet sections = new LongOpenHashSet();
private final BlockPos.MutableBlockPos mutablePos = new BlockPos.MutableBlockPos();
private int sectionCount;
public LightCache(int initialSize) {
data = new ByteArrayList(initialSize);
setSize(initialSize);
}
public void setSize(int size) {
if (size != data.size()) {
data.size(size);
@ -196,11 +197,18 @@ public abstract class AbstractPulleyVisual<T extends KineticBlockEntity> extends
for (int i = 0; i < sectionCount; i++) {
sections.add(SectionPos.asLong(sectionX, sectionY - i, sectionZ));
}
lightSections.sections(sections);
// Will be null during initialization
if (lightSections != null) {
updateSections();
}
}
}
}
public void updateSections() {
lightSections.sections(sections);
}
public void update() {
mutablePos.set(pos);

View file

@ -59,6 +59,10 @@ public class HandCrankVisual extends KineticBlockEntityVisual<HandCrankBlockEnti
@Override
protected void _delete() {
crank.delete();
if (rotatingModel != null) {
rotatingModel.delete();
}
}
@Override