Skip to content

Commit

Permalink
Edited Countdown and added option to change particles/tick from CO2 b…
Browse files Browse the repository at this point in the history
…laster
  • Loading branch information
MineDragonCZ committed Jul 4, 2023
1 parent 377ee34 commit b021402
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 16 deletions.
7 changes: 7 additions & 0 deletions src/main/java/tauri/dev/jsg/config/JSGConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
}
}
}
}
Expand All @@ -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();
}
}
}

Expand Down

0 comments on commit b021402

Please sign in to comment.