mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-27 23:47:38 +01:00
Instanced rope pulleys
This commit is contained in:
parent
3a52fa573f
commit
40bdbc7048
2 changed files with 16 additions and 10 deletions
|
@ -66,13 +66,16 @@ public class PulleyInstance extends ShaftInstance implements IDynamicInstance, L
|
||||||
|
|
||||||
coil.setRotation(rotationAxis.getDegreesQuaternion(offset * 180));
|
coil.setRotation(rotationAxis.getDegreesQuaternion(offset * 180));
|
||||||
magnet.update().get().ifPresent(data ->
|
magnet.update().get().ifPresent(data ->
|
||||||
data.setPosition(getInstancePosition())
|
{
|
||||||
.nudge(0, -offset, 0)
|
int index = Math.max(0, MathHelper.floor(offset));
|
||||||
.setBlockLight(bLight[bLight.length - 1])
|
data.setPosition(getInstancePosition())
|
||||||
.setSkyLight(sLight[sLight.length - 1])
|
.nudge(0, -offset, 0)
|
||||||
|
.setBlockLight(bLight[index])
|
||||||
|
.setSkyLight(sLight[index]);
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
halfRope.check().get().ifPresent(rope -> {
|
halfRope.update().get().ifPresent(rope -> {
|
||||||
float f = offset % 1;
|
float f = offset % 1;
|
||||||
float halfRopeNudge = f > .75f ? f - 1 : f;
|
float halfRopeNudge = f > .75f ? f - 1 : f;
|
||||||
|
|
||||||
|
@ -82,8 +85,8 @@ public class PulleyInstance extends ShaftInstance implements IDynamicInstance, L
|
||||||
.setSkyLight(sLight[0]);
|
.setSkyLight(sLight[0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
resizeRope();
|
||||||
if (isRunning()) {
|
if (isRunning()) {
|
||||||
resizeRope();
|
|
||||||
int size = rope.size();
|
int size = rope.size();
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
rope.get(i)
|
rope.get(i)
|
||||||
|
@ -142,9 +145,12 @@ public class PulleyInstance extends ShaftInstance implements IDynamicInstance, L
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void resizeRope() {
|
protected void resizeRope() {
|
||||||
if (rope.resize(getNeededRopeCount())) {
|
int neededRopeCount = getNeededRopeCount();
|
||||||
|
rope.resize(neededRopeCount);
|
||||||
|
|
||||||
int length = MathHelper.ceil(offset);
|
int length = MathHelper.ceil(offset);
|
||||||
|
|
||||||
|
if (volume == null || bLight.length < length + 1) {
|
||||||
volume = GridAlignedBB.from(pos.down(length), pos);
|
volume = GridAlignedBB.from(pos.down(length), pos);
|
||||||
volume.fixMinMax();
|
volume.fixMinMax();
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ public class ConditionalInstance<D extends InstanceData> {
|
||||||
this.model = model;
|
this.model = model;
|
||||||
this.condition = condition;
|
this.condition = condition;
|
||||||
|
|
||||||
check();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConditionalInstance<D> setCondition(Condition condition) {
|
public ConditionalInstance<D> setCondition(Condition condition) {
|
||||||
|
@ -25,7 +25,7 @@ public class ConditionalInstance<D extends InstanceData> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConditionalInstance<D> check() {
|
public ConditionalInstance<D> update() {
|
||||||
boolean shouldShow = condition.shouldShow();
|
boolean shouldShow = condition.shouldShow();
|
||||||
if (shouldShow && instance == null) {
|
if (shouldShow && instance == null) {
|
||||||
instance = model.createInstance();
|
instance = model.createInstance();
|
||||||
|
|
Loading…
Reference in a new issue