Skip to content

Commit

Permalink
Switch silenced to datatag
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerS1066 committed Jul 27, 2024
1 parent 71d1208 commit a206f64
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void onBlockDispense (BlockDispenseEvent event) {
if (craft == null) return;
CraftHeat heat = MovecraftOverheat.getInstance().getHeatManager().getHeat(craft);
if (heat != null) {
if (heat.isSilenced() && craft.getHitBox().contains(MathUtils.bukkit2MovecraftLoc(event.getBlock().getLocation()))) {
if (craft.getDataTag(CraftHeat.SILENCED) && craft.getHitBox().contains(MathUtils.bukkit2MovecraftLoc(event.getBlock().getLocation()))) {
event.setCancelled(true);
craft.getAudience().playSound(Sound.sound(Key.key("block.dispenser.fail"), Sound.Source.BLOCK, 1f, 1f));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ public class CraftHeat {
public static final CraftDataTagKey<Double> HEAT_CAPACITY = CraftDataTagContainer.tryRegisterTagKey(new NamespacedKey("movecraft-overheat", "heat-capacity"), craft -> 0D);
public static final CraftDataTagKey<Double> HEAT = CraftDataTagContainer.tryRegisterTagKey(new NamespacedKey("movecraft-overheat", "heat"), craft -> 0D);
public static final CraftDataTagKey<Double> DISSIPATION = CraftDataTagContainer.tryRegisterTagKey(new NamespacedKey("movecraft-overheat", "dissipation"), craft -> 0D);
public static final CraftDataTagKey<Boolean> SILENCED = CraftDataTagContainer.tryRegisterTagKey(new NamespacedKey("movecraft-overheat", "silenced"), craft -> false);
private final Craft craft;
private long lastUpdate;
private long lastDisaster;
private boolean silenced;

private boolean firedThisTick;
private int explosionsThisTick;
Expand Down Expand Up @@ -94,16 +94,16 @@ public void processDissipation () {

public void checkDisasters () {
// Update whether the craft is silenced
if (silenced) {
if (craft.getDataTag(SILENCED)) {
if (craft.getDataTag(HEAT) < craft.getDataTag(HEAT_CAPACITY) * Settings.SilenceHeatThreshold) {
craft.getAudience().sendMessage(Component.text(ChatUtils.MOVECRAFT_COMMAND_PREFIX + "No longer silenced!"));
silenced = false;
craft.setDataTag(SILENCED, false);
}
} else {
if (Settings.SilenceOverheatedCrafts && craft.getDataTag(HEAT) > craft.getDataTag(HEAT_CAPACITY) * Settings.SilenceHeatThreshold) {
craft.getAudience().sendMessage(Component.text(ChatUtils.MOVECRAFT_COMMAND_PREFIX + ChatColor.RED + "Silenced! Your guns are too hot to fire!"));
craft.getAudience().playSound(Sound.sound(Key.key("entity.blaze.death"), Sound.Source.BLOCK, 2.0f, 1.0f));
silenced = true;
craft.setDataTag(SILENCED, true);
}
}
for (DisasterType type : MovecraftOverheat.getDisasterTypes()) {
Expand Down Expand Up @@ -137,10 +137,6 @@ public long getLastDisaster() {
return lastDisaster;
}

public boolean isSilenced() {
return silenced;
}

private void updateBossBar() {
bossBar.setTitle("Heat: " + Math.round(craft.getDataTag(HEAT)*10)/10d + " / " + craft.getDataTag(HEAT_CAPACITY));
if (craft.getDataTag(HEAT) >= craft.getDataTag(HEAT_CAPACITY)*1.5) {
Expand Down

0 comments on commit a206f64

Please sign in to comment.