A little bit refactor
This commit is contained in:
parent
a2f20da464
commit
504d7e49e0
2 changed files with 6 additions and 5 deletions
|
@ -33,7 +33,7 @@ public class AlloyingRecipeSerializer implements RecipeSerializer<AlloyingRecipe
|
||||||
@Override
|
@Override
|
||||||
public AlloyingRecipe read(Identifier id, PacketByteBuf packetBuffer) {
|
public AlloyingRecipe read(Identifier id, PacketByteBuf packetBuffer) {
|
||||||
Identifier recipeId = packetBuffer.readIdentifier();
|
Identifier recipeId = packetBuffer.readIdentifier();
|
||||||
return (AlloyingRecipe) EndRecipeManager.getRecipe(AlloyingRecipe.TYPE, recipeId);
|
return EndRecipeManager.getRecipe(AlloyingRecipe.TYPE, recipeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -24,9 +24,10 @@ public class EndRecipeManager {
|
||||||
list.put(recipe.getId(), recipe);
|
list.put(recipe.getId(), recipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Recipe<?> getRecipe(RecipeType<?> type, Identifier id) {
|
@SuppressWarnings("unchecked")
|
||||||
|
public static <T extends Recipe<?>> T getRecipe(RecipeType<T> type, Identifier id) {
|
||||||
if (RECIPES.containsKey(type)) {
|
if (RECIPES.containsKey(type)) {
|
||||||
return RECIPES.get(type).get(id);
|
return (T) RECIPES.get(type).get(id);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -59,11 +60,11 @@ public class EndRecipeManager {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static <S extends RecipeSerializer<T>, T extends Recipe<?>> S registerSerializer(String id, S serializer) {
|
public static <S extends RecipeSerializer<T>, T extends Recipe<?>> S registerSerializer(String id, S serializer) {
|
||||||
return Registry.register(Registry.RECIPE_SERIALIZER, BetterEnd.getStringId(id), serializer);
|
return Registry.register(Registry.RECIPE_SERIALIZER, BetterEnd.getStringId(id), serializer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static <T extends Recipe<?>> RecipeType<T> registerType(String type) {
|
public static <T extends Recipe<?>> RecipeType<T> registerType(String type) {
|
||||||
Identifier recipeTypeId = BetterEnd.getResId(type);
|
Identifier recipeTypeId = BetterEnd.getResId(type);
|
||||||
return Registry.register(Registry.RECIPE_TYPE, recipeTypeId, new RecipeType<T>() {
|
return Registry.register(Registry.RECIPE_TYPE, recipeTypeId, new RecipeType<T>() {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue