Skip to content

Commit

Permalink
Add some methods
Browse files Browse the repository at this point in the history
  • Loading branch information
PanSzelescik committed Aug 28, 2024
1 parent 9fe6f9e commit 6806ede
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ public enum Colors {
this.dyeColor = dyeColor;
}

public @NotNull String getName() {
var dyeColor = this.getDyeColor();
if (dyeColor == null) {
return "";
}
return dyeColor.getName();
}

public @Nullable DyeColor getDyeColor() {
return this.dyeColor;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectMaps;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Unmodifiable;

import java.util.Optional;

public class RightClicker2BlockMap extends Object2ObjectOpenHashMap<RightClicker, Block> {

public RightClicker2BlockMap(int expected) {
Expand All @@ -35,6 +39,16 @@ public RightClicker2BlockMap(int expected) {
return block;
}

public @NotNull Optional<Block> put(@NotNull Colors color, @NotNull ResourceLocation resourceLocation) {
var block = BuiltInRegistries.BLOCK.getOptional(resourceLocation);
if (block.isEmpty()) {
return block;
}

this.put(RightClicker.of(color), block.get());
return block;
}

public @NotNull @Unmodifiable Object2ObjectMap<RightClicker, Block> freeze() {
return Object2ObjectMaps.unmodifiable(this);
}
Expand Down

0 comments on commit 6806ede

Please sign in to comment.