mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-02-06 10:25:00 +01:00
This is breaking but I want to save this work
This commit is contained in:
parent
008111a846
commit
e1816ec8fe
1 changed files with 40 additions and 36 deletions
|
@ -38,7 +38,7 @@ public class PressingBehaviour extends BeltProcessingBehaviour {
|
||||||
public int prevRunningTicks;
|
public int prevRunningTicks;
|
||||||
public int runningTicks;
|
public int runningTicks;
|
||||||
public boolean running;
|
public boolean running;
|
||||||
public boolean finished;
|
public boolean wentDown;
|
||||||
public Mode mode;
|
public Mode mode;
|
||||||
|
|
||||||
int entityScanCooldown;
|
int entityScanCooldown;
|
||||||
|
@ -72,7 +72,7 @@ public class PressingBehaviour extends BeltProcessingBehaviour {
|
||||||
public void read(CompoundTag compound, boolean clientPacket) {
|
public void read(CompoundTag compound, boolean clientPacket) {
|
||||||
running = compound.getBoolean("Running");
|
running = compound.getBoolean("Running");
|
||||||
mode = Mode.values()[compound.getInt("Mode")];
|
mode = Mode.values()[compound.getInt("Mode")];
|
||||||
finished = compound.getBoolean("Finished");
|
wentDown = compound.getBoolean("WentDown");
|
||||||
prevRunningTicks = runningTicks = compound.getInt("Ticks");
|
prevRunningTicks = runningTicks = compound.getInt("Ticks");
|
||||||
super.read(compound, clientPacket);
|
super.read(compound, clientPacket);
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ public class PressingBehaviour extends BeltProcessingBehaviour {
|
||||||
public void write(CompoundTag compound, boolean clientPacket) {
|
public void write(CompoundTag compound, boolean clientPacket) {
|
||||||
compound.putBoolean("Running", running);
|
compound.putBoolean("Running", running);
|
||||||
compound.putInt("Mode", mode.ordinal());
|
compound.putInt("Mode", mode.ordinal());
|
||||||
compound.putBoolean("Finished", finished);
|
compound.putBoolean("WentDown", wentDown);
|
||||||
compound.putInt("Ticks", runningTicks);
|
compound.putInt("Ticks", runningTicks);
|
||||||
super.write(compound, clientPacket);
|
super.write(compound, clientPacket);
|
||||||
|
|
||||||
|
@ -110,6 +110,7 @@ public class PressingBehaviour extends BeltProcessingBehaviour {
|
||||||
public void start(Mode mode) {
|
public void start(Mode mode) {
|
||||||
this.mode = mode;
|
this.mode = mode;
|
||||||
running = true;
|
running = true;
|
||||||
|
wentDown = false;
|
||||||
prevRunningTicks = 0;
|
prevRunningTicks = 0;
|
||||||
runningTicks = 0;
|
runningTicks = 0;
|
||||||
particleItems.clear();
|
particleItems.clear();
|
||||||
|
@ -128,17 +129,21 @@ public class PressingBehaviour extends BeltProcessingBehaviour {
|
||||||
public void tick() {
|
public void tick() {
|
||||||
super.tick();
|
super.tick();
|
||||||
|
|
||||||
finished = false;
|
|
||||||
if (specifics.getKineticSpeed() == 0) {
|
if (specifics.getKineticSpeed() == 0) {
|
||||||
running = false;
|
running = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Level level = getWorld();
|
Level level = getWorld();
|
||||||
|
|
||||||
|
if (level == null)
|
||||||
|
return;
|
||||||
|
|
||||||
BlockPos worldPosition = getPos();
|
BlockPos worldPosition = getPos();
|
||||||
|
|
||||||
if (!running || level == null) {
|
if (!running) {
|
||||||
if (level != null && !level.isClientSide) {
|
if (level.isClientSide)
|
||||||
|
return;
|
||||||
|
|
||||||
if (entityScanCooldown > 0)
|
if (entityScanCooldown > 0)
|
||||||
entityScanCooldown--;
|
entityScanCooldown--;
|
||||||
|
@ -151,8 +156,7 @@ public class PressingBehaviour extends BeltProcessingBehaviour {
|
||||||
if (BasinBlock.isBasin(level, worldPosition.below(2)))
|
if (BasinBlock.isBasin(level, worldPosition.below(2)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (ItemEntity itemEntity : level.getEntitiesOfClass(ItemEntity.class,
|
for (ItemEntity itemEntity : level.getEntitiesOfClass(ItemEntity.class, new AABB(worldPosition.below()).deflate(.125f))) {
|
||||||
new AABB(worldPosition.below()).deflate(.125f))) {
|
|
||||||
if (!itemEntity.isAlive() || !itemEntity.onGround())
|
if (!itemEntity.isAlive() || !itemEntity.onGround())
|
||||||
continue;
|
continue;
|
||||||
if (!specifics.tryProcessInWorld(itemEntity, true))
|
if (!specifics.tryProcessInWorld(itemEntity, true))
|
||||||
|
@ -160,7 +164,6 @@ public class PressingBehaviour extends BeltProcessingBehaviour {
|
||||||
start(Mode.WORLD);
|
start(Mode.WORLD);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -171,7 +174,7 @@ public class PressingBehaviour extends BeltProcessingBehaviour {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (runningTicks == CYCLE / 2 && specifics.getKineticSpeed() != 0) {
|
if (runningTicks >= CYCLE / 2 && !wentDown) {
|
||||||
if (inWorld())
|
if (inWorld())
|
||||||
applyInWorld();
|
applyInWorld();
|
||||||
if (onBasin())
|
if (onBasin())
|
||||||
|
@ -186,22 +189,22 @@ public class PressingBehaviour extends BeltProcessingBehaviour {
|
||||||
|
|
||||||
if (!level.isClientSide)
|
if (!level.isClientSide)
|
||||||
blockEntity.sendData();
|
blockEntity.sendData();
|
||||||
|
|
||||||
|
wentDown = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!level.isClientSide && runningTicks > CYCLE) {
|
if (!level.isClientSide && runningTicks > CYCLE) {
|
||||||
finished = true;
|
wentDown = false;
|
||||||
particleItems.clear();
|
particleItems.clear();
|
||||||
specifics.onPressingCompleted();
|
specifics.onPressingCompleted();
|
||||||
blockEntity.sendData();
|
blockEntity.sendData();
|
||||||
prevRunningTicks = runningTicks - 240;
|
runningTicks -= 240;
|
||||||
runningTicks += getRunningTickSpeed() - 240;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
prevRunningTicks = runningTicks;
|
prevRunningTicks = runningTicks;
|
||||||
runningTicks += getRunningTickSpeed();
|
runningTicks += getRunningTickSpeed();
|
||||||
if (prevRunningTicks < CYCLE / 2 && runningTicks >= CYCLE / 2) {
|
if (prevRunningTicks < CYCLE / 2 && runningTicks >= CYCLE / 2) {
|
||||||
runningTicks = CYCLE / 2;
|
|
||||||
// Pause the ticks until a packet is received
|
// Pause the ticks until a packet is received
|
||||||
if (level.isClientSide && !blockEntity.isVirtual())
|
if (level.isClientSide && !blockEntity.isVirtual())
|
||||||
runningTicks = -(CYCLE / 2);
|
runningTicks = -(CYCLE / 2);
|
||||||
|
@ -257,7 +260,8 @@ public class PressingBehaviour extends BeltProcessingBehaviour {
|
||||||
|
|
||||||
if (mode == Mode.BASIN)
|
if (mode == Mode.BASIN)
|
||||||
particleItems
|
particleItems
|
||||||
.forEach(stack -> makeCompactingParticleEffect(VecHelper.getCenterOf(worldPosition.below(2)), stack));
|
.forEach(stack -> makeCompactingParticleEffect(VecHelper.getCenterOf(worldPosition.below(2)),
|
||||||
|
stack));
|
||||||
if (mode == Mode.BELT)
|
if (mode == Mode.BELT)
|
||||||
particleItems.forEach(stack -> makePressingParticleEffect(VecHelper.getCenterOf(worldPosition.below(2))
|
particleItems.forEach(stack -> makePressingParticleEffect(VecHelper.getCenterOf(worldPosition.below(2))
|
||||||
.add(0, 8 / 16f, 0), stack));
|
.add(0, 8 / 16f, 0), stack));
|
||||||
|
|
Loading…
Reference in a new issue