From 33593ecc7201a1cc5465e9375c5d905800a4c401 Mon Sep 17 00:00:00 2001 From: Intybyte Date: Sat, 24 Aug 2024 00:23:07 +0200 Subject: [PATCH 1/9] Tracking Moveblocks and Flyblocks --- .../features/status/StatusManager.java | 21 ++++++++++++++++++- .../countercraft/movecraft/craft/Craft.java | 3 ++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusManager.java b/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusManager.java index ed48e75d4..66bb285f2 100644 --- a/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusManager.java +++ b/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusManager.java @@ -5,7 +5,6 @@ import net.countercraft.movecraft.craft.Craft; import net.countercraft.movecraft.craft.CraftManager; import net.countercraft.movecraft.craft.SinkingCraft; -import net.countercraft.movecraft.craft.datatag.CraftDataTagContainer; import net.countercraft.movecraft.craft.datatag.CraftDataTagKey; import net.countercraft.movecraft.craft.datatag.CraftDataTagRegistry; import net.countercraft.movecraft.craft.type.CraftType; @@ -50,10 +49,12 @@ public void run() { private static final class StatusUpdateTask implements Supplier { private final Craft craft; + private final CraftType crafttype; private final Map fuelTypes; private StatusUpdateTask(@NotNull Craft craft) { this.craft = craft; + this.crafttype = craft.getType(); Object object = craft.getType().getObjectProperty(CraftType.FUEL_TYPES); if(!(object instanceof Map map)) @@ -70,6 +71,8 @@ private StatusUpdateTask(@NotNull Craft craft) { @Override public @Nullable Effect get() { Counter materials = new Counter<>(); + Counter flyblocks = new Counter<>(); + Counter moveblocks = new Counter<>(); int nonNegligibleBlocks = 0; int nonNegligibleSolidBlocks = 0; double fuel = 0; @@ -77,6 +80,20 @@ private StatusUpdateTask(@NotNull Craft craft) { Material type = craft.getMovecraftWorld().getMaterial(l); materials.add(type); + for(RequiredBlockEntry entry : crafttype.getRequiredBlockProperty(CraftType.FLY_BLOCKS)) { + if(entry.contains(type)) { + flyblocks.add(type); + break; + } + } + + for(RequiredBlockEntry entry : crafttype.getRequiredBlockProperty(CraftType.MOVE_BLOCKS)) { + if(entry.contains(type)) { + moveblocks.add(type); + break; + } + } + if (type != Material.FIRE && !type.isAir()) { nonNegligibleBlocks++; } @@ -96,6 +113,8 @@ private StatusUpdateTask(@NotNull Craft craft) { craft.setDataTag(Craft.FUEL, fuel); craft.setDataTag(Craft.MATERIALS, materials); + craft.setDataTag(Craft.FLYBLOCKS, flyblocks); + craft.setDataTag(Craft.MOVEBLOCKS, moveblocks); craft.setDataTag(Craft.NON_NEGLIGIBLE_BLOCKS, nonNegligibleBlocks); craft.setDataTag(Craft.NON_NEGLIGIBLE_SOLID_BLOCKS, nonNegligibleSolidBlocks); craft.setDataTag(LAST_STATUS_CHECK, System.currentTimeMillis()); diff --git a/api/src/main/java/net/countercraft/movecraft/craft/Craft.java b/api/src/main/java/net/countercraft/movecraft/craft/Craft.java index 2c13ad657..7ca332304 100644 --- a/api/src/main/java/net/countercraft/movecraft/craft/Craft.java +++ b/api/src/main/java/net/countercraft/movecraft/craft/Craft.java @@ -21,7 +21,6 @@ import net.countercraft.movecraft.MovecraftLocation; import net.countercraft.movecraft.MovecraftRotation; import net.countercraft.movecraft.TrackedLocation; -import net.countercraft.movecraft.craft.datatag.CraftDataTagContainer; import net.countercraft.movecraft.craft.datatag.CraftDataTagKey; import net.countercraft.movecraft.craft.datatag.CraftDataTagRegistry; import net.countercraft.movecraft.craft.type.CraftType; @@ -47,6 +46,8 @@ public interface Craft { CraftDataTagKey> CONTACTS = CraftDataTagRegistry.INSTANCE.registerTagKey(new NamespacedKey("movecraft", "contacts"), craft -> new ArrayList<>(0)); CraftDataTagKey FUEL = CraftDataTagRegistry.INSTANCE.registerTagKey(new NamespacedKey("movecraft", "fuel"), craft -> 0D); CraftDataTagKey> MATERIALS = CraftDataTagRegistry.INSTANCE.registerTagKey(new NamespacedKey("movecraft", "materials"), craft -> new Counter<>()); + CraftDataTagKey> FLYBLOCKS = CraftDataTagRegistry.INSTANCE.registerTagKey(new NamespacedKey("movecraft", "flyblocks"), craft -> new Counter<>()); + CraftDataTagKey> MOVEBLOCKS = CraftDataTagRegistry.INSTANCE.registerTagKey(new NamespacedKey("movecraft", "moveblocks"), craft -> new Counter<>()); CraftDataTagKey NON_NEGLIGIBLE_BLOCKS = CraftDataTagRegistry.INSTANCE.registerTagKey(new NamespacedKey("movecraft", "non-negligible-blocks"), Craft::getOrigBlockCount); CraftDataTagKey NON_NEGLIGIBLE_SOLID_BLOCKS = CraftDataTagRegistry.INSTANCE.registerTagKey(new NamespacedKey("movecraft", "non-negligible-solid-blocks"), Craft::getOrigBlockCount); From d8a189c39f130678d34b5c8dfe50352ddcd3791d Mon Sep 17 00:00:00 2001 From: Intybyte Date: Sat, 24 Aug 2024 00:32:20 +0200 Subject: [PATCH 2/9] Better save these in a variable --- .../movecraft/features/status/StatusManager.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusManager.java b/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusManager.java index 66bb285f2..dda8657c4 100644 --- a/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusManager.java +++ b/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusManager.java @@ -76,18 +76,20 @@ private StatusUpdateTask(@NotNull Craft craft) { int nonNegligibleBlocks = 0; int nonNegligibleSolidBlocks = 0; double fuel = 0; + final var flyblocksList = crafttype.getRequiredBlockProperty(CraftType.FLY_BLOCKS); + final var moveblocksList = crafttype.getRequiredBlockProperty(CraftType.MOVE_BLOCKS); for (MovecraftLocation l : craft.getHitBox()) { Material type = craft.getMovecraftWorld().getMaterial(l); materials.add(type); - for(RequiredBlockEntry entry : crafttype.getRequiredBlockProperty(CraftType.FLY_BLOCKS)) { + for(RequiredBlockEntry entry : flyblocksList) { if(entry.contains(type)) { flyblocks.add(type); break; } } - for(RequiredBlockEntry entry : crafttype.getRequiredBlockProperty(CraftType.MOVE_BLOCKS)) { + for(RequiredBlockEntry entry : moveblocksList) { if(entry.contains(type)) { moveblocks.add(type); break; From 1458f60ddc48786c5c1a76505093332e17b4d2c5 Mon Sep 17 00:00:00 2001 From: Intybyte Date: Sat, 24 Aug 2024 09:56:55 +0200 Subject: [PATCH 3/9] Moving this out --- .../features/status/StatusManager.java | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusManager.java b/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusManager.java index dda8657c4..e88c78793 100644 --- a/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusManager.java +++ b/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusManager.java @@ -82,20 +82,6 @@ private StatusUpdateTask(@NotNull Craft craft) { Material type = craft.getMovecraftWorld().getMaterial(l); materials.add(type); - for(RequiredBlockEntry entry : flyblocksList) { - if(entry.contains(type)) { - flyblocks.add(type); - break; - } - } - - for(RequiredBlockEntry entry : moveblocksList) { - if(entry.contains(type)) { - moveblocks.add(type); - break; - } - } - if (type != Material.FIRE && !type.isAir()) { nonNegligibleBlocks++; } @@ -113,6 +99,22 @@ private StatusUpdateTask(@NotNull Craft craft) { } } + for(Material material : materials.getKeySet()) { + for(RequiredBlockEntry entry : flyblocksList) { + if(entry.contains(material)) { + flyblocks.add(material, materials.get(material) ); + break; + } + } + + for(RequiredBlockEntry entry : moveblocksList) { + if(entry.contains(material)) { + moveblocks.add(material, materials.get(material) ); + break; + } + } + } + craft.setDataTag(Craft.FUEL, fuel); craft.setDataTag(Craft.MATERIALS, materials); craft.setDataTag(Craft.FLYBLOCKS, flyblocks); From 74a9678e236c8eda6186f76692bbdd38c9cb5f83 Mon Sep 17 00:00:00 2001 From: Intybyte Date: Sat, 24 Aug 2024 10:02:14 +0200 Subject: [PATCH 4/9] Changed var type to Counter --- .../movecraft/features/status/StatusManager.java | 8 ++++---- .../main/java/net/countercraft/movecraft/craft/Craft.java | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusManager.java b/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusManager.java index e88c78793..578360465 100644 --- a/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusManager.java +++ b/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusManager.java @@ -71,8 +71,8 @@ private StatusUpdateTask(@NotNull Craft craft) { @Override public @Nullable Effect get() { Counter materials = new Counter<>(); - Counter flyblocks = new Counter<>(); - Counter moveblocks = new Counter<>(); + Counter flyblocks = new Counter<>(); + Counter moveblocks = new Counter<>(); int nonNegligibleBlocks = 0; int nonNegligibleSolidBlocks = 0; double fuel = 0; @@ -102,14 +102,14 @@ private StatusUpdateTask(@NotNull Craft craft) { for(Material material : materials.getKeySet()) { for(RequiredBlockEntry entry : flyblocksList) { if(entry.contains(material)) { - flyblocks.add(material, materials.get(material) ); + flyblocks.add(entry, materials.get(material) ); break; } } for(RequiredBlockEntry entry : moveblocksList) { if(entry.contains(material)) { - moveblocks.add(material, materials.get(material) ); + moveblocks.add(entry, materials.get(material) ); break; } } diff --git a/api/src/main/java/net/countercraft/movecraft/craft/Craft.java b/api/src/main/java/net/countercraft/movecraft/craft/Craft.java index 7ca332304..a1a44ee69 100644 --- a/api/src/main/java/net/countercraft/movecraft/craft/Craft.java +++ b/api/src/main/java/net/countercraft/movecraft/craft/Craft.java @@ -24,6 +24,7 @@ import net.countercraft.movecraft.craft.datatag.CraftDataTagKey; import net.countercraft.movecraft.craft.datatag.CraftDataTagRegistry; import net.countercraft.movecraft.craft.type.CraftType; +import net.countercraft.movecraft.craft.type.RequiredBlockEntry; import net.countercraft.movecraft.processing.MovecraftWorld; import net.countercraft.movecraft.util.Counter; import net.countercraft.movecraft.util.MathUtils; @@ -46,8 +47,8 @@ public interface Craft { CraftDataTagKey> CONTACTS = CraftDataTagRegistry.INSTANCE.registerTagKey(new NamespacedKey("movecraft", "contacts"), craft -> new ArrayList<>(0)); CraftDataTagKey FUEL = CraftDataTagRegistry.INSTANCE.registerTagKey(new NamespacedKey("movecraft", "fuel"), craft -> 0D); CraftDataTagKey> MATERIALS = CraftDataTagRegistry.INSTANCE.registerTagKey(new NamespacedKey("movecraft", "materials"), craft -> new Counter<>()); - CraftDataTagKey> FLYBLOCKS = CraftDataTagRegistry.INSTANCE.registerTagKey(new NamespacedKey("movecraft", "flyblocks"), craft -> new Counter<>()); - CraftDataTagKey> MOVEBLOCKS = CraftDataTagRegistry.INSTANCE.registerTagKey(new NamespacedKey("movecraft", "moveblocks"), craft -> new Counter<>()); + CraftDataTagKey> FLYBLOCKS = CraftDataTagRegistry.INSTANCE.registerTagKey(new NamespacedKey("movecraft", "flyblocks"), craft -> new Counter<>()); + CraftDataTagKey> MOVEBLOCKS = CraftDataTagRegistry.INSTANCE.registerTagKey(new NamespacedKey("movecraft", "moveblocks"), craft -> new Counter<>()); CraftDataTagKey NON_NEGLIGIBLE_BLOCKS = CraftDataTagRegistry.INSTANCE.registerTagKey(new NamespacedKey("movecraft", "non-negligible-blocks"), Craft::getOrigBlockCount); CraftDataTagKey NON_NEGLIGIBLE_SOLID_BLOCKS = CraftDataTagRegistry.INSTANCE.registerTagKey(new NamespacedKey("movecraft", "non-negligible-solid-blocks"), Craft::getOrigBlockCount); From 1a51dd83562ec4bbe6c405c04691813821aec18a Mon Sep 17 00:00:00 2001 From: Intybyte Date: Sat, 24 Aug 2024 10:10:03 +0200 Subject: [PATCH 5/9] Use new logic to StatusSign --- .../movecraft/features/status/StatusSign.java | 35 ++++++------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusSign.java b/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusSign.java index 1246c1381..d56263f60 100644 --- a/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusSign.java +++ b/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusSign.java @@ -2,15 +2,12 @@ import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; -import net.countercraft.movecraft.Movecraft; import net.countercraft.movecraft.MovecraftLocation; -import net.countercraft.movecraft.craft.BaseCraft; import net.countercraft.movecraft.craft.Craft; import net.countercraft.movecraft.craft.type.CraftType; import net.countercraft.movecraft.craft.type.RequiredBlockEntry; import net.countercraft.movecraft.events.CraftDetectEvent; import net.countercraft.movecraft.events.SignTranslateEvent; -import net.countercraft.movecraft.features.status.StatusManager; import net.countercraft.movecraft.util.Counter; import net.countercraft.movecraft.util.Tags; import org.bukkit.ChatColor; @@ -25,16 +22,8 @@ import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.inventory.InventoryHolder; -import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.logging.Level; - public final class StatusSign implements Listener { @EventHandler @@ -82,25 +71,21 @@ public final void onSignTranslate(SignTranslateEvent event) { totalNonNegligibleWaterBlocks += add; } } + //region Add flyblocks and moveblocks to displayBlocks + Counter flyblocks = craft.getDataTag(Craft.FLYBLOCKS); + Counter moveblocks = craft.getDataTag(Craft.MOVEBLOCKS); Object2IntMap displayBlocks = new Object2IntOpenHashMap<>(); - for (RequiredBlockEntry entry : craft.getType().getRequiredBlockProperty(CraftType.FLY_BLOCKS)) { - int total = 0; - for (Material material : entry.getMaterials()) { - if (materials.getKeySet().contains(material)) { - total += materials.get(material); - } - } + + for (RequiredBlockEntry entry : flyblocks.getKeySet()) { + int total = flyblocks.get(entry); displayBlocks.putIfAbsent(entry, total); } - for (RequiredBlockEntry entry : craft.getType().getRequiredBlockProperty(CraftType.MOVE_BLOCKS)) { - int total = 0; - for (Material material : entry.getMaterials()) { - if (materials.getKeySet().contains(material)) { - total += materials.get(material); - } - } + + for (RequiredBlockEntry entry : moveblocks.getKeySet()) { + int total = flyblocks.get(entry); displayBlocks.putIfAbsent(entry, total); } + //endregion int signLine = 1; int signColumn = 0; for (RequiredBlockEntry entry : displayBlocks.keySet()) { From 004dcc9364633f6b675eed23cbdd950f981bff3d Mon Sep 17 00:00:00 2001 From: Intybyte Date: Sat, 24 Aug 2024 20:25:37 +0200 Subject: [PATCH 6/9] Move down variables --- .../movecraft/features/status/StatusManager.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusManager.java b/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusManager.java index 578360465..69f4887b3 100644 --- a/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusManager.java +++ b/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusManager.java @@ -49,12 +49,10 @@ public void run() { private static final class StatusUpdateTask implements Supplier { private final Craft craft; - private final CraftType crafttype; private final Map fuelTypes; private StatusUpdateTask(@NotNull Craft craft) { this.craft = craft; - this.crafttype = craft.getType(); Object object = craft.getType().getObjectProperty(CraftType.FUEL_TYPES); if(!(object instanceof Map map)) @@ -71,13 +69,11 @@ private StatusUpdateTask(@NotNull Craft craft) { @Override public @Nullable Effect get() { Counter materials = new Counter<>(); - Counter flyblocks = new Counter<>(); - Counter moveblocks = new Counter<>(); int nonNegligibleBlocks = 0; int nonNegligibleSolidBlocks = 0; double fuel = 0; - final var flyblocksList = crafttype.getRequiredBlockProperty(CraftType.FLY_BLOCKS); - final var moveblocksList = crafttype.getRequiredBlockProperty(CraftType.MOVE_BLOCKS); + final CraftType crafttype = craft.getType(); + for (MovecraftLocation l : craft.getHitBox()) { Material type = craft.getMovecraftWorld().getMaterial(l); materials.add(type); @@ -99,6 +95,10 @@ private StatusUpdateTask(@NotNull Craft craft) { } } + Counter flyblocks = new Counter<>(); + Counter moveblocks = new Counter<>(); + final var flyblocksList = crafttype.getRequiredBlockProperty(CraftType.FLY_BLOCKS); + final var moveblocksList = crafttype.getRequiredBlockProperty(CraftType.MOVE_BLOCKS); for(Material material : materials.getKeySet()) { for(RequiredBlockEntry entry : flyblocksList) { if(entry.contains(material)) { From ca44a47a01a21e1a227e11dacda8eb1d3d14cdac Mon Sep 17 00:00:00 2001 From: Intybyte Date: Sat, 24 Aug 2024 21:02:24 +0200 Subject: [PATCH 7/9] Use Counter instead --- .../movecraft/features/status/StatusSign.java | 17 ++++------------- .../countercraft/movecraft/util/Counter.java | 4 ++++ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusSign.java b/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusSign.java index d56263f60..ef7a3f80d 100644 --- a/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusSign.java +++ b/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusSign.java @@ -1,7 +1,5 @@ package net.countercraft.movecraft.features.status; -import it.unimi.dsi.fastutil.objects.Object2IntMap; -import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import net.countercraft.movecraft.MovecraftLocation; import net.countercraft.movecraft.craft.Craft; import net.countercraft.movecraft.craft.type.CraftType; @@ -74,21 +72,14 @@ public final void onSignTranslate(SignTranslateEvent event) { //region Add flyblocks and moveblocks to displayBlocks Counter flyblocks = craft.getDataTag(Craft.FLYBLOCKS); Counter moveblocks = craft.getDataTag(Craft.MOVEBLOCKS); - Object2IntMap displayBlocks = new Object2IntOpenHashMap<>(); + Counter displayBlocks = new Counter<>(); - for (RequiredBlockEntry entry : flyblocks.getKeySet()) { - int total = flyblocks.get(entry); - displayBlocks.putIfAbsent(entry, total); - } - - for (RequiredBlockEntry entry : moveblocks.getKeySet()) { - int total = flyblocks.get(entry); - displayBlocks.putIfAbsent(entry, total); - } + displayBlocks.add(flyblocks); + displayBlocks.add(moveblocks); //endregion int signLine = 1; int signColumn = 0; - for (RequiredBlockEntry entry : displayBlocks.keySet()) { + for (RequiredBlockEntry entry : displayBlocks.getKeySet()) { if (entry.getMin() == 0.0) { continue; } diff --git a/api/src/main/java/net/countercraft/movecraft/util/Counter.java b/api/src/main/java/net/countercraft/movecraft/util/Counter.java index 4e3f04826..89807ef85 100644 --- a/api/src/main/java/net/countercraft/movecraft/util/Counter.java +++ b/api/src/main/java/net/countercraft/movecraft/util/Counter.java @@ -26,6 +26,10 @@ public void set(T item, int count) { counter.put(item, count); } + public void putIfAbsent(T item, int count) { + counter.putIfAbsent(item, count); + } + public void add(T item, int count) { counter.put(item, counter.getInt(item) + count); } From 033f15102f1f32e081d4e566044ddfe7e23b41c2 Mon Sep 17 00:00:00 2001 From: Intybyte Date: Sat, 24 Aug 2024 21:03:49 +0200 Subject: [PATCH 8/9] No region comments --- .../countercraft/movecraft/features/status/StatusSign.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusSign.java b/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusSign.java index ef7a3f80d..79e8f47ce 100644 --- a/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusSign.java +++ b/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusSign.java @@ -69,14 +69,14 @@ public final void onSignTranslate(SignTranslateEvent event) { totalNonNegligibleWaterBlocks += add; } } - //region Add flyblocks and moveblocks to displayBlocks + Counter flyblocks = craft.getDataTag(Craft.FLYBLOCKS); Counter moveblocks = craft.getDataTag(Craft.MOVEBLOCKS); Counter displayBlocks = new Counter<>(); displayBlocks.add(flyblocks); displayBlocks.add(moveblocks); - //endregion + int signLine = 1; int signColumn = 0; for (RequiredBlockEntry entry : displayBlocks.getKeySet()) { From cba1892c5507880d1d4b8f21eb31a481c9a31819 Mon Sep 17 00:00:00 2001 From: TylerS1066 Date: Sun, 25 Aug 2024 09:44:38 -0500 Subject: [PATCH 9/9] Clean up --- .../movecraft/features/status/StatusManager.java | 9 +++------ .../movecraft/features/status/StatusSign.java | 7 ++----- .../java/net/countercraft/movecraft/util/Counter.java | 4 ---- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusManager.java b/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusManager.java index 69f4887b3..761acd77b 100644 --- a/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusManager.java +++ b/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusManager.java @@ -67,12 +67,11 @@ private StatusUpdateTask(@NotNull Craft craft) { } @Override - public @Nullable Effect get() { + public @NotNull Effect get() { Counter materials = new Counter<>(); int nonNegligibleBlocks = 0; int nonNegligibleSolidBlocks = 0; double fuel = 0; - final CraftType crafttype = craft.getType(); for (MovecraftLocation l : craft.getHitBox()) { Material type = craft.getMovecraftWorld().getMaterial(l); @@ -97,17 +96,15 @@ private StatusUpdateTask(@NotNull Craft craft) { Counter flyblocks = new Counter<>(); Counter moveblocks = new Counter<>(); - final var flyblocksList = crafttype.getRequiredBlockProperty(CraftType.FLY_BLOCKS); - final var moveblocksList = crafttype.getRequiredBlockProperty(CraftType.MOVE_BLOCKS); for(Material material : materials.getKeySet()) { - for(RequiredBlockEntry entry : flyblocksList) { + for(RequiredBlockEntry entry : craft.getType().getRequiredBlockProperty(CraftType.FLY_BLOCKS)) { if(entry.contains(material)) { flyblocks.add(entry, materials.get(material) ); break; } } - for(RequiredBlockEntry entry : moveblocksList) { + for(RequiredBlockEntry entry : craft.getType().getRequiredBlockProperty(CraftType.MOVE_BLOCKS)) { if(entry.contains(material)) { moveblocks.add(entry, materials.get(material) ); break; diff --git a/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusSign.java b/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusSign.java index 79e8f47ce..d8a488576 100644 --- a/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusSign.java +++ b/Movecraft/src/main/java/net/countercraft/movecraft/features/status/StatusSign.java @@ -70,12 +70,9 @@ public final void onSignTranslate(SignTranslateEvent event) { } } - Counter flyblocks = craft.getDataTag(Craft.FLYBLOCKS); - Counter moveblocks = craft.getDataTag(Craft.MOVEBLOCKS); Counter displayBlocks = new Counter<>(); - - displayBlocks.add(flyblocks); - displayBlocks.add(moveblocks); + displayBlocks.add(craft.getDataTag(Craft.FLYBLOCKS)); + displayBlocks.add(craft.getDataTag(Craft.MOVEBLOCKS)); int signLine = 1; int signColumn = 0; diff --git a/api/src/main/java/net/countercraft/movecraft/util/Counter.java b/api/src/main/java/net/countercraft/movecraft/util/Counter.java index 89807ef85..4e3f04826 100644 --- a/api/src/main/java/net/countercraft/movecraft/util/Counter.java +++ b/api/src/main/java/net/countercraft/movecraft/util/Counter.java @@ -26,10 +26,6 @@ public void set(T item, int count) { counter.put(item, count); } - public void putIfAbsent(T item, int count) { - counter.putIfAbsent(item, count); - } - public void add(T item, int count) { counter.put(item, counter.getInt(item) + count); }