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,13 +72,13 @@ 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);
|
||||||
|
|
||||||
if (clientPacket) {
|
if (clientPacket) {
|
||||||
NBTHelper.iterateCompoundList(compound.getList("ParticleItems", Tag.TAG_COMPOUND),
|
NBTHelper.iterateCompoundList(compound.getList("ParticleItems", Tag.TAG_COMPOUND),
|
||||||
c -> particleItems.add(ItemStack.of(c)));
|
c -> particleItems.add(ItemStack.of(c)));
|
||||||
spawnParticles();
|
spawnParticles();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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,38 +129,40 @@ 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--;
|
||||||
if (entityScanCooldown <= 0) {
|
if (entityScanCooldown <= 0) {
|
||||||
entityScanCooldown = ENTITY_SCAN;
|
entityScanCooldown = ENTITY_SCAN;
|
||||||
|
|
||||||
if (BlockEntityBehaviour.get(level, worldPosition.below(2),
|
if (BlockEntityBehaviour.get(level, worldPosition.below(2),
|
||||||
TransportedItemStackHandlerBehaviour.TYPE) != null)
|
TransportedItemStackHandlerBehaviour.TYPE) != null)
|
||||||
return;
|
return;
|
||||||
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))
|
continue;
|
||||||
continue;
|
start(Mode.WORLD);
|
||||||
start(Mode.WORLD);
|
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,13 +260,14 @@ 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));
|
||||||
if (mode == Mode.WORLD)
|
if (mode == Mode.WORLD)
|
||||||
particleItems.forEach(stack -> makePressingParticleEffect(VecHelper.getCenterOf(worldPosition.below(1))
|
particleItems.forEach(stack -> makePressingParticleEffect(VecHelper.getCenterOf(worldPosition.below(1))
|
||||||
.add(0, -1 / 4f, 0), stack));
|
.add(0, -1 / 4f, 0), stack));
|
||||||
|
|
||||||
particleItems.clear();
|
particleItems.clear();
|
||||||
}
|
}
|
||||||
|
@ -278,10 +282,10 @@ public class PressingBehaviour extends BeltProcessingBehaviour {
|
||||||
return;
|
return;
|
||||||
for (int i = 0; i < amount; i++) {
|
for (int i = 0; i < amount; i++) {
|
||||||
Vec3 motion = VecHelper.offsetRandomly(Vec3.ZERO, level.random, .125f)
|
Vec3 motion = VecHelper.offsetRandomly(Vec3.ZERO, level.random, .125f)
|
||||||
.multiply(1, 0, 1);
|
.multiply(1, 0, 1);
|
||||||
motion = motion.add(0, amount != 1 ? 0.125f : 1 / 16f, 0);
|
motion = motion.add(0, amount != 1 ? 0.125f : 1 / 16f, 0);
|
||||||
level.addParticle(new ItemParticleOption(ParticleTypes.ITEM, stack), pos.x, pos.y - .25f, pos.z, motion.x,
|
level.addParticle(new ItemParticleOption(ParticleTypes.ITEM, stack), pos.x, pos.y - .25f, pos.z, motion.x,
|
||||||
motion.y, motion.z);
|
motion.y, motion.z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,9 +295,9 @@ public class PressingBehaviour extends BeltProcessingBehaviour {
|
||||||
return;
|
return;
|
||||||
for (int i = 0; i < 20; i++) {
|
for (int i = 0; i < 20; i++) {
|
||||||
Vec3 motion = VecHelper.offsetRandomly(Vec3.ZERO, level.random, .175f)
|
Vec3 motion = VecHelper.offsetRandomly(Vec3.ZERO, level.random, .175f)
|
||||||
.multiply(1, 0, 1);
|
.multiply(1, 0, 1);
|
||||||
level.addParticle(new ItemParticleOption(ParticleTypes.ITEM, stack), pos.x, pos.y, pos.z, motion.x,
|
level.addParticle(new ItemParticleOption(ParticleTypes.ITEM, stack), pos.x, pos.y, pos.z, motion.x,
|
||||||
motion.y + .25f, motion.z);
|
motion.y + .25f, motion.z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue