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

View file

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