diff options
| author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-02-27 11:53:57 -0500 |
|---|---|---|
| committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-02-27 11:53:57 -0500 |
| commit | b09f774d422263ce15b97d6d0804beddf856176d (patch) | |
| tree | e542258481d7496b15679f3c329ef9e087c7d8fc /src/main/java/io/github/moulberry/notenoughupdates/recipes/VillagerTradeRecipe.java | |
| parent | 22cb02adbeb24b7ec98f843bcaba99cebe3e4f03 (diff) | |
| download | notenoughupdates-b09f774d422263ce15b97d6d0804beddf856176d.tar.gz notenoughupdates-b09f774d422263ce15b97d6d0804beddf856176d.tar.bz2 notenoughupdates-b09f774d422263ce15b97d6d0804beddf856176d.zip | |
feat: improve formating :)
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/recipes/VillagerTradeRecipe.java')
| -rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/recipes/VillagerTradeRecipe.java | 251 |
1 files changed, 131 insertions, 120 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/recipes/VillagerTradeRecipe.java b/src/main/java/io/github/moulberry/notenoughupdates/recipes/VillagerTradeRecipe.java index 530e8e32..371d4f3c 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/recipes/VillagerTradeRecipe.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/recipes/VillagerTradeRecipe.java @@ -21,125 +21,136 @@ import java.util.*; public class VillagerTradeRecipe implements NeuRecipe { - public static final int COST_SLOT_X = 51; - public static final int COST_SLOT_Y = 34; - public static final int RESULT_SLOT_Y = 35; - public static final int RESULT_SLOT_X = 124; - - private static class Holder { // This holder object exists to defer initialization to first access - private static final GameProfile DREAM_PROFILE = new GameProfile(UUID.fromString("ec70bcaf-702f-4bb8-b48d-276fa52a780c"), "Dream"); - private static final EntityLivingBase DEMO_DREAM = new AbstractClientPlayer(null, DREAM_PROFILE) { - @Override - protected NetworkPlayerInfo getPlayerInfo() { - return new NetworkPlayerInfo(DREAM_PROFILE) { - @Override - public ResourceLocation getLocationSkin() { - return new ResourceLocation("notenoughupdates", "dreamskin.png"); - } - }; - } - }; - private static final EntityLivingBase DEMO_VILLAGER = new EntityVillager(null); - - private static boolean isAprilFirst() { - Calendar cal = Calendar.getInstance(); - return cal.get(Calendar.DAY_OF_MONTH) == 1 && cal.get(Calendar.MONTH) == Calendar.APRIL; - } - - private static final EntityLivingBase DEMO_ENTITY = isAprilFirst() ? DEMO_DREAM : DEMO_VILLAGER; - - } - - private final static ResourceLocation BACKGROUND = new ResourceLocation("notenoughupdates", "textures/gui/villager_recipe.png"); - - private final Ingredient result; - private final Ingredient cost; - private final int minCost, maxCost; - - public VillagerTradeRecipe(Ingredient result, Ingredient cost, int minCost, int maxCost) { - this.result = result; - this.cost = cost; - this.minCost = minCost; - this.maxCost = maxCost; - } - - public VillagerTradeRecipe(Ingredient result, Ingredient cost) { - this(result, cost, -1, -1); - } - - public boolean hasVariableCost() { - return minCost != -1 && maxCost != -1; - } - - @Override - public Set<Ingredient> getIngredients() { - return Sets.newHashSet(cost); - } - - @Override - public Set<Ingredient> getOutputs() { - return Sets.newHashSet(result); - } - - @Override - public List<RecipeSlot> getSlots() { - return Arrays.asList( - new RecipeSlot(COST_SLOT_X, COST_SLOT_Y, cost.getItemStack()), - new RecipeSlot(RESULT_SLOT_X, RESULT_SLOT_Y, result.getItemStack()) - ); - } - - @Override - public boolean shouldUseForCraftCost() { - return false; - } - - @Override - public boolean isAvailable() { - return SBInfo.getInstance().getCurrentMode() == SBInfo.Gamemode.STRANDED || NotEnoughUpdates.INSTANCE.config.hidden.dev; - } - - @Override - public void drawExtraInfo(GuiItemRecipe gui, int mouseX, int mouseY) { - if (hasVariableCost()) { - FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; - Utils.drawStringCenteredScaledMaxWidth( - minCost + " - " + maxCost, fontRenderer, - gui.guiLeft + 50, gui.guiTop + 60, false, 75, 0xff00ff); - - } - } - - @Override - public void drawExtraBackground(GuiItemRecipe gui, int mouseX, int mouseY) { - GuiInventory.drawEntityOnScreen(gui.guiLeft + 90, gui.guiTop + 75, 30, gui.guiLeft - mouseX + 80, gui.guiTop + 60 - mouseY, Holder.DEMO_ENTITY); - } - - @Override - public JsonObject serialize() { - JsonObject jsonObject = new JsonObject(); - jsonObject.addProperty("type", "trade"); - jsonObject.addProperty("result", result.serialize()); - jsonObject.addProperty("cost", cost.getInternalItemId()); - if (minCost > 0) - jsonObject.addProperty("min", minCost); - if (maxCost > 0) - jsonObject.addProperty("max", maxCost); - return jsonObject; - } - - @Override - public ResourceLocation getBackground() { - return BACKGROUND; - } - - public static VillagerTradeRecipe parseStaticRecipe(NEUManager manager, JsonObject recipe) { - return new VillagerTradeRecipe( - new Ingredient(manager, recipe.get("result").getAsString()), - new Ingredient(manager, recipe.get("cost").getAsString()), - recipe.has("min") ? recipe.get("min").getAsInt() : -1, - recipe.has("max") ? recipe.get("max").getAsInt() : -1 - ); - } + public static final int COST_SLOT_X = 51; + public static final int COST_SLOT_Y = 34; + public static final int RESULT_SLOT_Y = 35; + public static final int RESULT_SLOT_X = 124; + + private static class Holder { // This holder object exists to defer initialization to first access + private static final GameProfile DREAM_PROFILE = + new GameProfile(UUID.fromString("ec70bcaf-702f-4bb8-b48d-276fa52a780c"), "Dream"); + private static final EntityLivingBase DEMO_DREAM = new AbstractClientPlayer(null, DREAM_PROFILE) { + @Override + protected NetworkPlayerInfo getPlayerInfo() { + return new NetworkPlayerInfo(DREAM_PROFILE) { + @Override + public ResourceLocation getLocationSkin() { + return new ResourceLocation("notenoughupdates", "dreamskin.png"); + } + }; + } + }; + private static final EntityLivingBase DEMO_VILLAGER = new EntityVillager(null); + + private static boolean isAprilFirst() { + Calendar cal = Calendar.getInstance(); + return cal.get(Calendar.DAY_OF_MONTH) == 1 && cal.get(Calendar.MONTH) == Calendar.APRIL; + } + + private static final EntityLivingBase DEMO_ENTITY = isAprilFirst() ? DEMO_DREAM : DEMO_VILLAGER; + + } + + private final static ResourceLocation BACKGROUND = + new ResourceLocation("notenoughupdates", "textures/gui/villager_recipe.png"); + + private final Ingredient result; + private final Ingredient cost; + private final int minCost, maxCost; + + public VillagerTradeRecipe(Ingredient result, Ingredient cost, int minCost, int maxCost) { + this.result = result; + this.cost = cost; + this.minCost = minCost; + this.maxCost = maxCost; + } + + public VillagerTradeRecipe(Ingredient result, Ingredient cost) { + this(result, cost, -1, -1); + } + + public boolean hasVariableCost() { + return minCost != -1 && maxCost != -1; + } + + @Override + public Set<Ingredient> getIngredients() { + return Sets.newHashSet(cost); + } + + @Override + public Set<Ingredient> getOutputs() { + return Sets.newHashSet(result); + } + + @Override + public List<RecipeSlot> getSlots() { + return Arrays.asList( + new RecipeSlot(COST_SLOT_X, COST_SLOT_Y, cost.getItemStack()), + new RecipeSlot(RESULT_SLOT_X, RESULT_SLOT_Y, result.getItemStack()) + ); + } + + @Override + public boolean shouldUseForCraftCost() { + return false; + } + + @Override + public boolean isAvailable() { + return SBInfo.getInstance().getCurrentMode() == SBInfo.Gamemode.STRANDED || + NotEnoughUpdates.INSTANCE.config.hidden.dev; + } + + @Override + public void drawExtraInfo(GuiItemRecipe gui, int mouseX, int mouseY) { + if (hasVariableCost()) { + FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; + Utils.drawStringCenteredScaledMaxWidth( + minCost + " - " + maxCost, fontRenderer, + gui.guiLeft + 50, gui.guiTop + 60, false, 75, 0xff00ff + ); + + } + } + + @Override + public void drawExtraBackground(GuiItemRecipe gui, int mouseX, int mouseY) { + GuiInventory.drawEntityOnScreen( + gui.guiLeft + 90, + gui.guiTop + 75, + 30, + gui.guiLeft - mouseX + 80, + gui.guiTop + 60 - mouseY, + Holder.DEMO_ENTITY + ); + } + + @Override + public JsonObject serialize() { + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("type", "trade"); + jsonObject.addProperty("result", result.serialize()); + jsonObject.addProperty("cost", cost.getInternalItemId()); + if (minCost > 0) + jsonObject.addProperty("min", minCost); + if (maxCost > 0) + jsonObject.addProperty("max", maxCost); + return jsonObject; + } + + @Override + public ResourceLocation getBackground() { + return BACKGROUND; + } + + public static VillagerTradeRecipe parseStaticRecipe(NEUManager manager, JsonObject recipe) { + return new VillagerTradeRecipe( + new Ingredient(manager, recipe.get("result").getAsString()), + new Ingredient(manager, recipe.get("cost").getAsString()), + recipe.has("min") ? recipe.get("min").getAsInt() : -1, + recipe.has("max") ? recipe.get("max").getAsInt() : -1 + ); + } } |
