From b021402617d19aa3db6cec2a200cee96af5db76d Mon Sep 17 00:00:00 2001 From: MineDragonCZ_ Date: Tue, 4 Jul 2023 20:47:50 +0200 Subject: [PATCH] Edited Countdown and added option to change particles/tick from CO2 blaster --- .../java/tauri/dev/jsg/config/JSGConfig.java | 7 +++ .../renderer/props/DestinyVentRenderer.java | 6 +- .../props/DestinyCountDownTile.java | 57 ++++++++++++++----- 3 files changed, 54 insertions(+), 16 deletions(-) diff --git a/src/main/java/tauri/dev/jsg/config/JSGConfig.java b/src/main/java/tauri/dev/jsg/config/JSGConfig.java index 4a6aa743..41f1dbb5 100644 --- a/src/main/java/tauri/dev/jsg/config/JSGConfig.java +++ b/src/main/java/tauri/dev/jsg/config/JSGConfig.java @@ -132,6 +132,13 @@ public static class Visual { "SIDE: CLIENT" }) public TemperatureHelper.EnumTemperatureUnit temperatureUnit = TemperatureHelper.EnumTemperatureUnit.CELSIUS; + + @Config.Name("Destiny CO2 blaster particles count/tick") + @Config.RangeInt(min = 0, max = 100) + @Config.Comment({ + "SIDE: CLIENT" + }) + public int destinyVentParticlesCount = 5; } public static class Debug { diff --git a/src/main/java/tauri/dev/jsg/renderer/props/DestinyVentRenderer.java b/src/main/java/tauri/dev/jsg/renderer/props/DestinyVentRenderer.java index 58cb7b7e..527726ed 100644 --- a/src/main/java/tauri/dev/jsg/renderer/props/DestinyVentRenderer.java +++ b/src/main/java/tauri/dev/jsg/renderer/props/DestinyVentRenderer.java @@ -6,6 +6,7 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; +import tauri.dev.jsg.config.JSGConfig; import tauri.dev.jsg.loader.ElementEnum; import tauri.dev.jsg.loader.texture.TextureLoader; import tauri.dev.jsg.particle.ParticleBlenderCOBlast; @@ -55,8 +56,9 @@ public void render(@Nonnull DestinyVentTile te, double x, double y, double z, fl ElementEnum.DESTINY_VENT_MOVING.render(); if (fireParticles) { - for (int i = 0; i < 50; i++) { - boolean orange = (i < 25); + int particleCount = JSGConfig.General.visual.destinyVentParticlesCount; + for (int i = 0; i < particleCount; i++) { + boolean orange = (i < (particleCount/2)); float coef = orange ? (float) (0.5f * Math.random()) : 1; new ParticleBlenderCOBlast((float) (-0.5f + Math.random()), 0, (float) (-0.3f + Math.random() * 0.6f), 2, 2, (-0.1f + (float) (Math.random() * 0.2f)) * (orange ? 0.25f : 1), (0.4f + (-0.1f + (float) (Math.random() * 0.2f))) * coef, (-(0.2f + (-0.1f + (float) (Math.random() * 0.2f)))) * coef, orange, (motion) -> { }).spawn(te.getWorld(), te.getPos(), rot, false); diff --git a/src/main/java/tauri/dev/jsg/tileentity/props/DestinyCountDownTile.java b/src/main/java/tauri/dev/jsg/tileentity/props/DestinyCountDownTile.java index a1a951a0..102fa65d 100644 --- a/src/main/java/tauri/dev/jsg/tileentity/props/DestinyCountDownTile.java +++ b/src/main/java/tauri/dev/jsg/tileentity/props/DestinyCountDownTile.java @@ -61,7 +61,9 @@ public long getCountdownTicks() { return countdownTo - world.getTotalWorldTime(); } + @SuppressWarnings("all") private long countStart = -1; + private long gateIdleFrom = -1; private boolean gateOpenedThisRound = false; public void setCountDown(long countToTime) { @@ -117,21 +119,42 @@ public void update() { sendState(StateTypeEnum.RENDERER_UPDATE, getState(StateTypeEnum.RENDERER_UPDATE)); } - if (getConfig().getOption(ENABLE_GATE_OPENING.id).getBooleanValue() && !gateOpenedThisRound && i > 1300 && (world.getTotalWorldTime() - countStart) > (20L * JSGConfig.General.countdownConfig.dialStartDelay) && (world.getTotalWorldTime() % 40 == 0)) { + /* + * OPENING THE GATE + */ + if (getConfig().getOption(ENABLE_GATE_OPENING.id).getBooleanValue() && !gateOpenedThisRound && i > 1300 && (world.getTotalWorldTime() % 40 == 0)) { StargateUniverseBaseTile gate = getNearestGate(); if (gate != null) { EnumStargateState state = gate.getStargateState(); - if (state.idle() && gate.isMerged()) { - NearbyGate found = gate.getRandomNearbyGate(); - if (found != null) { - StargateAddress foundAddress = found.address; - int symbols = (found.symbolsNeeded - 1); - if (foundAddress != null) { - gate.dialAddress(foundAddress, symbols); - gateOpenedThisRound = true; - markDirty(); + if(state != null){ + if(!state.idle() && gateIdleFrom != -1){ + gateIdleFrom = -1; + markDirty(); + } + if (state.idle() && gate.isMerged()) { + if((world.getTotalWorldTime() - gateIdleFrom) > (20L * JSGConfig.General.countdownConfig.dialStartDelay)) { + NearbyGate found = gate.getRandomNearbyGate(); + if (found != null) { + if (gateIdleFrom == -1) { + gateIdleFrom = this.world.getTotalWorldTime(); + markDirty(); + } else { + StargateAddress foundAddress = found.address; + int symbols = (found.symbolsNeeded - 1); + if (foundAddress != null) { + gate.dialAddress(foundAddress, symbols); + gateOpenedThisRound = true; + markDirty(); + } + } + } } } + else if(state.engaged()){ + // gate is already open while countdown counts (by dialer or OC or incoming) + gateOpenedThisRound = true; + markDirty(); + } } } } @@ -142,16 +165,22 @@ public void update() { playSound(EnumCountDownEventType.ZERO); sendSignal(null, "countdown_zero", new Object[]{0}); gateOpenedThisRound = false; + gateIdleFrom = -1; markDirty(); + /* + * CLOSING THE GATE + */ if (getConfig().getOption(ENABLE_GATE_CLOSING.id).getBooleanValue()) { StargateUniverseBaseTile gate = getNearestGate(); if (gate != null) { EnumStargateState state = gate.getStargateState(); - if (state.unstable() || state.incoming() || state.engaged()) - gate.attemptClose(StargateClosedReasonEnum.AUTOCLOSE); - else if (!state.idle()) - gate.abortDialingSequence(); + if(state != null){ + if (state.unstable() || state.incoming() || state.engaged()) + gate.attemptClose(StargateClosedReasonEnum.AUTOCLOSE); + else if (!state.idle()) + gate.abortDialingSequence(); + } } }