Fix NEI GTNH meta bug and added ru_RU.lang

Some default code refactor
This commit is contained in:
Christmas committed 2021-12-21 03:32:22 +03:00
1 parent 7ccf1b0767
commit ce5a76ee68
14 files changed
+96 -82

No files matched your search

@@ -112,8 +112,8 @@ public class NEEContainerDrawHandler implements IContainerDrawHandler {
}
} else {
overlayButtons = new ArrayList<>();
GuiButton overlay1 = ReflectionHelper.getPrivateValue(GuiRecipe.class,guiRecipe,"overlay1");
GuiButton overlay2 = ReflectionHelper.getPrivateValue(GuiRecipe.class,guiRecipe,"overlay2");
GuiButton overlay1 = ReflectionHelper.getPrivateValue(GuiRecipe.class, guiRecipe, "overlay1");
GuiButton overlay2 = ReflectionHelper.getPrivateValue(GuiRecipe.class, guiRecipe, "overlay2");
overlayButtons.add(overlay1);
overlayButtons.add(overlay2);
}
@@ -180,8 +180,8 @@ public class NEEContainerDrawHandler implements IContainerDrawHandler {
}
} else {
overlayButtons = new ArrayList<>();
GuiButton overlay1 = ReflectionHelper.getPrivateValue(GuiRecipe.class,guiRecipe,"overlay1");
GuiButton overlay2 = ReflectionHelper.getPrivateValue(GuiRecipe.class,guiRecipe,"overlay2");
GuiButton overlay1 = ReflectionHelper.getPrivateValue(GuiRecipe.class, guiRecipe, "overlay1");
GuiButton overlay2 = ReflectionHelper.getPrivateValue(GuiRecipe.class, guiRecipe, "overlay2");
overlayButtons.add(overlay1);
overlayButtons.add(overlay2);
}
@@ -203,12 +203,12 @@ public class NEEContainerDrawHandler implements IContainerDrawHandler {
List<String> tooltips = new ArrayList<>();
boolean isCraftingTerm = guiRecipe.firstGui instanceof GuiCraftingTerm || GuiUtils.isGuiWirelessCrafting(guiRecipe.firstGui);
if (isCraftingTerm) {
if(this.drawRequestTooltip) {
if (this.drawRequestTooltip) {
tooltips.add(String.format("%s" + EnumChatFormatting.GRAY + " + " +
EnumChatFormatting.BLUE + I18n.format("neenergistics.gui.tooltip.helper.crafting"),
EnumChatFormatting.YELLOW + Keyboard.getKeyName(NEIClientConfig.getKeyBinding("nee.preview"))));
}
if(this.drawMissingTooltip){
if (this.drawMissingTooltip) {
tooltips.add(EnumChatFormatting.RED + I18n.format("neenergistics.gui.tooltip.missing"));
}
}
@@ -53,7 +53,7 @@ public class NEEConfig {
allowSynchronousSwitchIngredient = config.get("client", "allowSynchronousSwitchIngredient", true,
"If true, it will make all similar ingredient switch at the same time").getBoolean(true);
useStackSizeFromNEI = config.get("client","useStackSizeFromNEI",false,
useStackSizeFromNEI = config.get("client", "useStackSizeFromNEI", false,
"Use the StackSize set by NEI").getBoolean();
draggedStackDefaultSize = config.get("client", "draggedStackDefaultSize", 1,
@@ -80,7 +80,7 @@ public class NEEConfig {
allowSynchronousSwitchIngredient = config.get("client", "allowSynchronousSwitchIngredient", true,
"If true, it will make all similar ingredient switch at the same time").getBoolean(true);
useStackSizeFromNEI = config.get("client","useStackSizeFromNEI",false,
useStackSizeFromNEI = config.get("client", "useStackSizeFromNEI", false,
"Use the StackSize set by NEI").getBoolean();
draggedStackDefaultSize = config.get("client", "draggedStackDefaultSize", 1,
@@ -17,7 +17,6 @@ import com.github.vfyjxf.nee.utils.ItemUtils;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.oredict.OreDictionary;
import java.util.ArrayList;
import java.util.HashMap;
@@ -32,6 +31,12 @@ public class NEECraftingHandler implements IOverlayHandler {
public static final String OUTPUT_KEY = "Outputs";
public static Map<String, PositionedStack> ingredients = new HashMap<>();
public static boolean isCraftingTableRecipe(IRecipeHandler recipe) {
TemplateRecipeHandler templateRecipeHandler = (TemplateRecipeHandler) recipe;
String overlayIdentifier = templateRecipeHandler.getOverlayIdentifier();
return "crafting".equals(overlayIdentifier) || "crafting2x2".equals(overlayIdentifier);
}
@Override
public void overlayRecipe(GuiContainer firstGui, IRecipeHandler recipe, int recipeIndex, boolean shift) {
if (firstGui instanceof GuiPatternTerm || GuiUtils.isPatternTermExGui(firstGui)) {
@@ -102,7 +107,7 @@ public class NEECraftingHandler implements IOverlayHandler {
}
//Fix ItemStack with wrong meta
if (currentStack.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
if (currentStack.getItemDamage() == 32767) {
currentStack.setItemDamage(0);
}
@@ -118,7 +123,7 @@ public class NEECraftingHandler implements IOverlayHandler {
ItemStack outputStack = positionedStack.item.copy();
//Fix ItemStack with wrong meta(maybe ?)
if (outputStack.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
if (outputStack.getItemDamage() == 32767) {
outputStack.setItemDamage(0);
}
@@ -155,7 +160,7 @@ public class NEECraftingHandler implements IOverlayHandler {
}
//Fix ItemStack with wrong meta
if (stack.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
if (stack.getItemDamage() == 32767) {
stack.setItemDamage(0);
}
@@ -271,10 +276,4 @@ public class NEECraftingHandler implements IOverlayHandler {
}
}
public static boolean isCraftingTableRecipe(IRecipeHandler recipe) {
TemplateRecipeHandler templateRecipeHandler = (TemplateRecipeHandler) recipe;
String overlayIdentifier = templateRecipeHandler.getOverlayIdentifier();
return "crafting".equals(overlayIdentifier) || "crafting2x2".equals(overlayIdentifier);
}
}
@@ -48,12 +48,11 @@ import java.util.List;
public class NEECraftingHelper implements IOverlayHandler {
public static final NEECraftingHelper INSTANCE = new NEECraftingHelper();
public static IngredientTracker tracker = null;
public static int stackIndex = 1;
public static boolean noPreview = false;
public static final NEECraftingHelper INSTANCE = new NEECraftingHelper();
@Override
public void overlayRecipe(GuiContainer firstGui, IRecipeHandler recipe, int recipeIndex, boolean shift) {
boolean isCraftingGuiTerm = firstGui instanceof GuiCraftingTerm || GuiUtils.isGuiWirelessCrafting(firstGui);
@@ -214,8 +213,8 @@ public class NEECraftingHelper implements IOverlayHandler {
}
if (!isGtnhNei) {
overlayButtons = new ArrayList<>();
GuiButton overlay1 = ReflectionHelper.getPrivateValue(GuiRecipe.class,guiRecipe,"overlay1");
GuiButton overlay2 = ReflectionHelper.getPrivateValue(GuiRecipe.class,guiRecipe,"overlay2");
GuiButton overlay1 = ReflectionHelper.getPrivateValue(GuiRecipe.class, guiRecipe, "overlay1");
GuiButton overlay2 = ReflectionHelper.getPrivateValue(GuiRecipe.class, guiRecipe, "overlay2");
overlayButtons.add(overlay1);
overlayButtons.add(overlay2);
}
@@ -22,7 +22,8 @@ public class PacketArcaneRecipe implements IMessage, IMessageHandler<PacketArcan
NBTTagCompound input;
public PacketArcaneRecipe() {}
public PacketArcaneRecipe() {
}
public PacketArcaneRecipe(NBTTagCompound input) {
this.input = input;
@@ -28,7 +28,8 @@ public class PacketNEIPatternRecipe implements IMessage, IMessageHandler<PacketN
NBTTagCompound input;
NBTTagCompound output;
public PacketNEIPatternRecipe() {}
public PacketNEIPatternRecipe() {
}
public PacketNEIPatternRecipe(@Nonnull NBTTagCompound input, NBTTagCompound output) {
this.input = input;
@@ -65,9 +66,9 @@ public class PacketNEIPatternRecipe implements IMessage, IMessageHandler<PacketN
} else if (container instanceof ContainerPatternTerm) {
((ContainerPatternTerm) container).getPatternTerminal().setCraftingRecipe(false);
message.processRecipeHandler((ContainerPatternTerm) container, message);
} else if (container instanceof ContainerPatternTermEx && message.output != null){
} else if (container instanceof ContainerPatternTermEx && message.output != null) {
((ContainerPatternTermEx) container).getPatternTerminal().setInverted(false);
message.processRecipeHandler((ContainerPatternTermEx) container,message);
message.processRecipeHandler((ContainerPatternTermEx) container, message);
}
return null;
}
@@ -19,14 +19,6 @@ public class PacketStackCountChange implements IMessage, IMessageHandler<PacketS
private int slotIndex;
private int changeCount;
public int getSlotIndex() {
return slotIndex;
}
public int getChangeCount() {
return changeCount;
}
public PacketStackCountChange() {
}
@@ -36,6 +28,14 @@ public class PacketStackCountChange implements IMessage, IMessageHandler<PacketS
this.changeCount = changeCount;
}
public int getSlotIndex() {
return slotIndex;
}
public int getChangeCount() {
return changeCount;
}
@Override
public void fromBytes(ByteBuf buf) {
this.slotIndex = buf.readInt();
@@ -36,6 +36,24 @@ public class GregTech5RecipeProcessor implements IRecipeProcessor {
gtAssLineClz = gtAL;
}
/**
* For resolving NoSuchMethodError
* Copied from GTNewHorizons/GT5-Unofficial.
*/
public static FluidStack getFluidFromDisplayStack(ItemStack aDisplayStack) {
if (!isStackValid(aDisplayStack) ||
aDisplayStack.getItem() != ItemList.Display_Fluid.getItem() ||
!aDisplayStack.hasTagCompound()) {
return null;
}
Fluid tFluid = FluidRegistry.getFluid(ItemList.Display_Fluid.getItem().getDamage(aDisplayStack));
return new FluidStack(tFluid, (int) aDisplayStack.getTagCompound().getLong("mFluidDisplayAmount"));
}
public static boolean isStackValid(Object aStack) {
return (aStack instanceof ItemStack) && ((ItemStack) aStack).getItem() != null && ((ItemStack) aStack).stackSize >= 0;
}
@Nonnull
@Override
public Set<String> getAllOverlayIdentifier() {
@@ -88,22 +106,4 @@ public class GregTech5RecipeProcessor implements IRecipeProcessor {
return recipeOutputs;
}
/**
* For resolving NoSuchMethodError
* Copied from GTNewHorizons/GT5-Unofficial.
*/
public static FluidStack getFluidFromDisplayStack(ItemStack aDisplayStack) {
if (!isStackValid(aDisplayStack) ||
aDisplayStack.getItem() != ItemList.Display_Fluid.getItem() ||
!aDisplayStack.hasTagCompound()) {
return null;
}
Fluid tFluid = FluidRegistry.getFluid(ItemList.Display_Fluid.getItem().getDamage(aDisplayStack));
return new FluidStack(tFluid, (int) aDisplayStack.getTagCompound().getLong("mFluidDisplayAmount"));
}
public static boolean isStackValid(Object aStack) {
return (aStack instanceof ItemStack) && ((ItemStack) aStack).getItem() != null && ((ItemStack) aStack).stackSize >= 0;
}
}
@@ -14,7 +14,7 @@ import java.util.Set;
public interface IRecipeProcessor {
@Nonnull
default Set<String> getAllOverlayIdentifier(){
default Set<String> getAllOverlayIdentifier() {
return Collections.emptySet();
}
@@ -2,7 +2,7 @@ package com.github.vfyjxf.nee.proxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
public class ServerProxy extends CommonProxy{
public class ServerProxy extends CommonProxy {
@Override
public void init(FMLInitializationEvent event) {
// NO-OP
@@ -5,9 +5,9 @@ import net.minecraft.item.ItemStack;
public class Ingredient {
private PositionedStack ingredients;
private ItemStack craftableIngredient;
private final long requireCount;
private final PositionedStack ingredients;
private ItemStack craftableIngredient;
private long currentCount = 0;
public Ingredient(PositionedStack ingredients) {
@@ -15,10 +15,6 @@ public class Ingredient {
this.requireCount = ingredients.items[0].stackSize;
}
public void setCraftableIngredient(ItemStack craftableIngredient) {
this.craftableIngredient = craftableIngredient;
}
public PositionedStack getIngredients() {
return ingredients;
}
@@ -27,7 +23,11 @@ public class Ingredient {
return craftableIngredient;
}
public long getMissingCount(){
public void setCraftableIngredient(ItemStack craftableIngredient) {
this.craftableIngredient = craftableIngredient;
}
public long getMissingCount() {
return requireCount - currentCount;
}
@@ -35,15 +35,15 @@ public class Ingredient {
return requireCount;
}
public boolean isCraftable(){
public boolean isCraftable() {
return this.craftableIngredient != null;
}
public boolean requiresToCraft(){
public boolean requiresToCraft() {
return this.getMissingCount() > 0;
}
public void addCurrentCount(long count){
public void addCurrentCount(long count) {
currentCount += count;
}
@@ -13,23 +13,25 @@ public class StackProcessor {
public String recipeProcessor;
public String identifier;
public StackProcessor(String modid, String name, String meta, String nbt){
public StackProcessor(String modid, String name, String meta, String nbt) {
this.modid = modid;
this.name = name;
this.meta = meta;
this.nbt = nbt;
}
public StackProcessor(String modid, String name, String meta){
public StackProcessor(String modid, String name, String meta) {
this.modid = modid;
this.name = name;
this.meta = meta;
}
public StackProcessor(String modid, String name){
public StackProcessor(String modid, String name) {
this.modid = modid;
this.name = name;
}
public StackProcessor(ItemStack itemStack, Item item, String recipeProcessor, String identifier){
public StackProcessor(ItemStack itemStack, Item item, String recipeProcessor, String identifier) {
this.itemStack = itemStack;
this.item = item;
this.recipeProcessor = recipeProcessor;