Skip to content

Commit

Permalink
remove enabled state cache
Browse files Browse the repository at this point in the history
  • Loading branch information
iTwins committed Sep 6, 2023
1 parent 97dee49 commit 40e4b3c
Showing 1 changed file with 2 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
*/
public abstract class SignalInsulator extends SlimefunItem {

private static final HashMap<Location, Boolean> enabledStates = new HashMap<>();

@ParametersAreNonnullByDefault
public SignalInsulator(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(itemGroup, item, recipeType, recipe);
Expand Down Expand Up @@ -86,16 +84,14 @@ public static void setEnabled(@Nonnull Location location, boolean enabled) {

@Override
public void preRegister() {
addItemHandler(onPlace());
addItemHandler(onRightClick());
addItemHandler(onBreak());
addItemHandler(onPlace(), onRightClick());
}

private @Nonnull BlockPlaceHandler onPlace() {
return new BlockPlaceHandler(false) {
@Override
public void onPlayerPlace(@Nonnull BlockPlaceEvent e) {
enabledStates.put(e.getBlock().getLocation(), true);
setEnabled(e.getBlock().getLocation(), true);
}
};
}
Expand Down Expand Up @@ -123,13 +119,4 @@ public void onPlayerPlace(@Nonnull BlockPlaceEvent e) {
};
}

private @Nonnull BlockBreakHandler onBreak() {
return new SimpleBlockBreakHandler() {
@Override
public void onBlockBreak(@Nonnull Block b) {
enabledStates.remove(b.getLocation());
}
};
}

}

0 comments on commit 40e4b3c

Please sign in to comment.