Inventory sync when the search term is updated (client and server) and ensure that only people using the specified tablet process the inventory update packet
This commit is contained in:
parent
196cb25899
commit
201ecf99db
|
@ -0,0 +1,27 @@
|
|||
package com.pahimar.ee3.client.gui.element;
|
||||
|
||||
import com.pahimar.repackage.cofh.lib.gui.GuiBase;
|
||||
import com.pahimar.repackage.cofh.lib.gui.element.ElementButton;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class ElementStatefulButton extends ElementButton
|
||||
{
|
||||
private int state;
|
||||
|
||||
public ElementStatefulButton(GuiBase gui, int posX, int posY, String name, int sheetX, int sheetY, int hoverX, int hoverY, int disabledX, int disabledY, int sizeX, int sizeY, int texW, int texH, ResourceLocation texture)
|
||||
{
|
||||
super(gui, posX, posY, name, sheetX, sheetY, hoverX, hoverY, disabledX, disabledY, sizeX, sizeY, texW, texH, texture);
|
||||
this.state = 0;
|
||||
}
|
||||
|
||||
public int getState()
|
||||
{
|
||||
return state;
|
||||
}
|
||||
|
||||
public ElementStatefulButton setState(int state)
|
||||
{
|
||||
this.state = state;
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -1,20 +1,24 @@
|
|||
package com.pahimar.ee3.client.gui.inventory;
|
||||
|
||||
import com.pahimar.ee3.client.gui.element.ElementSearchField;
|
||||
import com.pahimar.ee3.client.gui.element.ElementStatefulButton;
|
||||
import com.pahimar.ee3.inventory.ContainerTransmutationTablet;
|
||||
import com.pahimar.ee3.network.PacketHandler;
|
||||
import com.pahimar.ee3.network.message.MessageGuiElementClicked;
|
||||
import com.pahimar.ee3.network.message.MessageSliderElementUpdated;
|
||||
import com.pahimar.ee3.reference.Colors;
|
||||
import com.pahimar.ee3.reference.Messages;
|
||||
import com.pahimar.ee3.reference.Textures;
|
||||
import com.pahimar.ee3.tileentity.TileEntityTransmutationTablet;
|
||||
import com.pahimar.repackage.cofh.lib.gui.GuiBase;
|
||||
import com.pahimar.repackage.cofh.lib.gui.GuiColor;
|
||||
import com.pahimar.repackage.cofh.lib.gui.element.ElementButton;
|
||||
import com.pahimar.repackage.cofh.lib.gui.element.ElementSlider;
|
||||
import com.pahimar.repackage.cofh.lib.gui.element.ElementTextField;
|
||||
import com.pahimar.repackage.cofh.lib.render.RenderHelper;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
|
@ -24,11 +28,18 @@ public class GuiTransmutationTablet extends GuiBase
|
|||
private TileEntityTransmutationTablet tileEntityTransmutationTablet;
|
||||
|
||||
private ElementTextField searchTextField;
|
||||
private ElementButton sortOrderButton;
|
||||
private ElementStatefulButton sortOrderButton;
|
||||
private ElementSlider slider;
|
||||
|
||||
private static DecimalFormat energyValueDecimalFormat = new DecimalFormat("###,###,###,###,###.###");
|
||||
|
||||
private static final int LEFT_MOUSEBUTTON = 0;
|
||||
private static final int RIGHT_MOUSEBUTTON = 1;
|
||||
|
||||
private static final int SORT_BY_DISPLAY_NAME = 0;
|
||||
private static final int SORT_BY_ENERGY_VALUE = 1;
|
||||
private static final int SORT_BY_ID = 2;
|
||||
|
||||
public GuiTransmutationTablet(InventoryPlayer inventoryPlayer, TileEntityTransmutationTablet tileEntityTransmutationTablet)
|
||||
{
|
||||
super(new ContainerTransmutationTablet(inventoryPlayer, tileEntityTransmutationTablet), Textures.Gui.TRANSMUTATION_TABLET);
|
||||
|
@ -49,7 +60,31 @@ public class GuiTransmutationTablet extends GuiBase
|
|||
searchTextField.backgroundColor = new GuiColor(0, 0, 0, 0).getColor();
|
||||
searchTextField.borderColor = new GuiColor(0, 0, 0, 0).getColor();
|
||||
|
||||
sortOrderButton = new ElementButton(this, 151, 36, "sortOrder", 0, 0, 18, 0, 36, 0, 18, 18, 54, 18, Textures.Gui.Elements.BUTTON_SORT_ORDER);
|
||||
sortOrderButton = new ElementStatefulButton(this, 151, 36, "sortOrder", 0, 0, 18, 0, 36, 0, 18, 18, 54, 18, Textures.Gui.Elements.BUTTON_SORT_ORDER)
|
||||
{
|
||||
@Override
|
||||
public void drawBackground(int mouseX, int mouseY, float gameTicks)
|
||||
{
|
||||
|
||||
RenderHelper.bindTexture(texture);
|
||||
if (isEnabled())
|
||||
{
|
||||
if (getState() == SORT_BY_DISPLAY_NAME)
|
||||
{
|
||||
drawTexturedModalRect(posX, posY, 36, 0, sizeX, sizeY);
|
||||
}
|
||||
else if (getState() == SORT_BY_ENERGY_VALUE)
|
||||
{
|
||||
drawTexturedModalRect(posX, posY, 0, 0, sizeX, sizeY);
|
||||
}
|
||||
else if (getState() == SORT_BY_ID)
|
||||
{
|
||||
drawTexturedModalRect(posX, posY, 18, 0, sizeX, sizeY);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
setTooltipByState();
|
||||
|
||||
slider = new ElementSlider(this, 239, 36, 12, 201, 187, 0)
|
||||
{
|
||||
|
@ -91,7 +126,66 @@ public class GuiTransmutationTablet extends GuiBase
|
|||
protected void drawGuiContainerForegroundLayer(int x, int y)
|
||||
{
|
||||
super.drawGuiContainerForegroundLayer(x, y);
|
||||
fontRendererObj.drawString("Energy Value:", 8, 140, Integer.parseInt(Colors.PURE_WHITE, 16)); // TODO Localize
|
||||
fontRendererObj.drawString(String.format("%s:", StatCollector.translateToLocal(Messages.ENERGY_VALUE)), 8, 140, Integer.parseInt(Colors.PURE_WHITE, 16)); // TODO Localize
|
||||
fontRendererObj.drawString(String.format("%s", energyValueDecimalFormat.format(tileEntityTransmutationTablet.getStoredEnergyValue().getEnergyValue())), 8, 150, Integer.parseInt(Colors.PURE_WHITE, 16));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleElementButtonClick(String buttonName, int mouseButton)
|
||||
{
|
||||
if (buttonName.equals("sortOrder"))
|
||||
{
|
||||
PacketHandler.INSTANCE.sendToServer(new MessageGuiElementClicked(buttonName, mouseButton));
|
||||
|
||||
if (mouseButton == LEFT_MOUSEBUTTON)
|
||||
{
|
||||
if (sortOrderButton.getState() == SORT_BY_DISPLAY_NAME)
|
||||
{
|
||||
sortOrderButton.setState(SORT_BY_ENERGY_VALUE);
|
||||
}
|
||||
else if (sortOrderButton.getState() == SORT_BY_ENERGY_VALUE)
|
||||
{
|
||||
sortOrderButton.setState(SORT_BY_ID);
|
||||
}
|
||||
else if (sortOrderButton.getState() == SORT_BY_ID)
|
||||
{
|
||||
sortOrderButton.setState(SORT_BY_DISPLAY_NAME);
|
||||
}
|
||||
}
|
||||
else if (mouseButton == RIGHT_MOUSEBUTTON)
|
||||
{
|
||||
if (sortOrderButton.getState() == SORT_BY_DISPLAY_NAME)
|
||||
{
|
||||
sortOrderButton.setState(SORT_BY_ID);
|
||||
}
|
||||
else if (sortOrderButton.getState() == SORT_BY_ENERGY_VALUE)
|
||||
{
|
||||
sortOrderButton.setState(SORT_BY_DISPLAY_NAME);
|
||||
}
|
||||
else if (sortOrderButton.getState() == SORT_BY_ID)
|
||||
{
|
||||
sortOrderButton.setState(SORT_BY_ENERGY_VALUE);
|
||||
}
|
||||
}
|
||||
|
||||
setTooltipByState();
|
||||
}
|
||||
}
|
||||
|
||||
private void setTooltipByState()
|
||||
{
|
||||
sortOrderButton.clearToolTip();
|
||||
if (sortOrderButton.getState() == SORT_BY_DISPLAY_NAME)
|
||||
{
|
||||
sortOrderButton.setToolTip(Messages.Tooltips.SORT_BY_DISPLAY_NAME);
|
||||
}
|
||||
else if (sortOrderButton.getState() == SORT_BY_ENERGY_VALUE)
|
||||
{
|
||||
sortOrderButton.setToolTip(Messages.Tooltips.SORT_BY_ENERGY_VALUE);
|
||||
}
|
||||
else if (sortOrderButton.getState() == SORT_BY_ID)
|
||||
{
|
||||
sortOrderButton.setToolTip(Messages.Tooltips.SORT_BY_ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,17 +61,17 @@ public class ItemTooltipEventHandler
|
|||
UUID playerUUID = ItemHelper.getOwnerUUID(event.itemStack);
|
||||
if (playerUUID != null && UsernameCache.containsUUID(playerUUID))
|
||||
{
|
||||
event.toolTip.add(StatCollector.translateToLocalFormatted(Messages.ITEM_BELONGS_TO, UsernameCache.getLastKnownUsername(playerUUID)));
|
||||
event.toolTip.add(StatCollector.translateToLocalFormatted(Messages.Tooltips.ITEM_BELONGS_TO, UsernameCache.getLastKnownUsername(playerUUID)));
|
||||
}
|
||||
else if (ItemHelper.hasOwnerName(event.itemStack))
|
||||
{
|
||||
event.toolTip.add(StatCollector.translateToLocalFormatted(Messages.ITEM_BELONGS_TO, ItemHelper.getOwnerName(event.itemStack)));
|
||||
event.toolTip.add(StatCollector.translateToLocalFormatted(Messages.Tooltips.ITEM_BELONGS_TO, ItemHelper.getOwnerName(event.itemStack)));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT))
|
||||
{
|
||||
event.toolTip.add(StatCollector.translateToLocal(Messages.ITEM_BELONGS_TO_NO_ONE));
|
||||
event.toolTip.add(StatCollector.translateToLocal(Messages.Tooltips.ITEM_BELONGS_TO_NO_ONE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ public class EnergyValueRegistry implements INBTTaggable, JsonSerializer<EnergyV
|
|||
private ImmutableSortedMap<WrappedStack, EnergyValue> stackMappings;
|
||||
private ImmutableSortedMap<EnergyValue, List<WrappedStack>> valueMappings;
|
||||
|
||||
private Set<ItemStack> allItemStacksWithValues = new TreeSet<ItemStack>(ItemHelper.baseComparator);
|
||||
private Set<ItemStack> allItemStacksWithValues = new TreeSet<ItemStack>(ItemHelper.idComparator);
|
||||
|
||||
private EnergyValueRegistry()
|
||||
{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.pahimar.ee3.inventory;
|
||||
|
||||
import com.pahimar.ee3.exchange.EnergyValueRegistry;
|
||||
import com.pahimar.ee3.inventory.element.IElementButtonHandler;
|
||||
import com.pahimar.ee3.inventory.element.IElementSliderHandler;
|
||||
import com.pahimar.ee3.inventory.element.IElementTextFieldHandler;
|
||||
import com.pahimar.ee3.item.ItemAlchemicalTome;
|
||||
|
@ -27,13 +28,13 @@ import net.minecraft.item.ItemStack;
|
|||
|
||||
import java.util.*;
|
||||
|
||||
public class ContainerTransmutationTablet extends ContainerEE implements IElementTextFieldHandler, IElementSliderHandler
|
||||
public class ContainerTransmutationTablet extends ContainerEE implements IElementTextFieldHandler, IElementSliderHandler, IElementButtonHandler
|
||||
{
|
||||
private InventoryTransmutationTablet inventoryTransmutationTablet;
|
||||
public final TileEntityTransmutationTablet tileEntityTransmutationTablet;
|
||||
private float energyValue;
|
||||
private String searchTerm;
|
||||
private boolean requiresUpdate = false;
|
||||
private int sortOrder;
|
||||
|
||||
public ContainerTransmutationTablet(InventoryPlayer inventoryPlayer, TileEntityTransmutationTablet tileEntityTransmutationTablet)
|
||||
{
|
||||
|
@ -50,6 +51,7 @@ public class ContainerTransmutationTablet extends ContainerEE implements IElemen
|
|||
}
|
||||
inventoryTransmutationTablet = new InventoryTransmutationTablet(knownTransmutations);
|
||||
|
||||
this.sortOrder = 0;
|
||||
this.energyValue = tileEntityTransmutationTablet.getStoredEnergyValue().getEnergyValue();
|
||||
|
||||
this.addSlotToContainer(new SlotTabletInput(this, tileEntityTransmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_1, 62, 24));
|
||||
|
@ -137,10 +139,14 @@ public class ContainerTransmutationTablet extends ContainerEE implements IElemen
|
|||
energyValueAsInt = (energyValueAsInt & 0xffff) | (updatedValue << 16);
|
||||
energyValue = Float.intBitsToFloat(energyValueAsInt);
|
||||
}
|
||||
|
||||
if (valueType == 0 || valueType == 1)
|
||||
else if (valueType == 2)
|
||||
{
|
||||
this.updateInventory();
|
||||
sortOrder = updatedValue;
|
||||
}
|
||||
|
||||
if (valueType == 0 || valueType == 1 || valueType == 2)
|
||||
{
|
||||
updateInventory();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -175,7 +181,19 @@ public class ContainerTransmutationTablet extends ContainerEE implements IElemen
|
|||
|
||||
Set<ItemStack> filteredSet = FilterUtils.filterByNameContains(this.inventoryTransmutationTablet.getKnownTransmutations(), searchTerm);
|
||||
List<ItemStack> filteredList = new ArrayList(FilterUtils.filterByEnergyValue(filteredSet, energyValue));
|
||||
Collections.sort(filteredList, ItemHelper.displayNameComparator);
|
||||
|
||||
if (sortOrder == 0)
|
||||
{
|
||||
Collections.sort(filteredList, ItemHelper.displayNameComparator);
|
||||
}
|
||||
else if (sortOrder == 1)
|
||||
{
|
||||
Collections.sort(filteredList, ItemHelper.energyValueComparator);
|
||||
}
|
||||
else if (sortOrder == 2)
|
||||
{
|
||||
Collections.sort(filteredList, ItemHelper.idComparator);
|
||||
}
|
||||
|
||||
if (filteredList.size() <= 30)
|
||||
{
|
||||
|
@ -253,6 +271,44 @@ public class ContainerTransmutationTablet extends ContainerEE implements IElemen
|
|||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleElementButtonClick(String elementName, int mouseButton)
|
||||
{
|
||||
if (elementName.equals("sortOrder"))
|
||||
{
|
||||
if (mouseButton == 0)
|
||||
{
|
||||
if (sortOrder == 0)
|
||||
{
|
||||
sortOrder = 1;
|
||||
}
|
||||
else if (sortOrder == 1)
|
||||
{
|
||||
sortOrder = 2;
|
||||
}
|
||||
else if (sortOrder == 2)
|
||||
{
|
||||
sortOrder = 0;
|
||||
}
|
||||
}
|
||||
else if (mouseButton == 1)
|
||||
{
|
||||
if (sortOrder == 0)
|
||||
{
|
||||
sortOrder = 2;
|
||||
}
|
||||
else if (sortOrder == 1)
|
||||
{
|
||||
sortOrder = 0;
|
||||
}
|
||||
else if (sortOrder == 2)
|
||||
{
|
||||
sortOrder = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class SlotAlchemicalTome extends Slot
|
||||
{
|
||||
private ContainerTransmutationTablet containerTransmutationTablet;
|
||||
|
@ -296,12 +352,11 @@ public class ContainerTransmutationTablet extends ContainerEE implements IElemen
|
|||
{
|
||||
super.putStack(itemStack);
|
||||
|
||||
Set<ItemStack> knownTransmutations = TransmutationKnowledgeRegistry.getInstance().getPlayersKnownTransmutations(ItemHelper.getOwnerUUID(itemStack));
|
||||
this.containerTransmutationTablet.inventoryTransmutationTablet = new InventoryTransmutationTablet(knownTransmutations);
|
||||
this.containerTransmutationTablet.updateInventory();
|
||||
|
||||
if (!this.tileEntityTransmutationTablet.getWorldObj().isRemote && itemStack != null && itemStack.getItem() instanceof ItemAlchemicalTome && ItemHelper.hasOwnerUUID(itemStack))
|
||||
{
|
||||
Set<ItemStack> knownTransmutations = TransmutationKnowledgeRegistry.getInstance().getPlayersKnownTransmutations(ItemHelper.getOwnerUUID(itemStack));
|
||||
this.containerTransmutationTablet.inventoryTransmutationTablet = new InventoryTransmutationTablet(knownTransmutations);
|
||||
this.containerTransmutationTablet.updateInventory();
|
||||
PacketHandler.INSTANCE.sendToAllAround(new MessageTransmutationKnowledgeUpdate(this.containerTransmutationTablet.tileEntityTransmutationTablet, knownTransmutations), new NetworkRegistry.TargetPoint(this.tileEntityTransmutationTablet.getWorldObj().provider.dimensionId, (double) this.tileEntityTransmutationTablet.xCoord, (double) this.tileEntityTransmutationTablet.yCoord, (double) this.tileEntityTransmutationTablet.zCoord, 5d));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ public class InventoryAlchemicalTome implements IInventory
|
|||
}
|
||||
else
|
||||
{
|
||||
this.knownTransmutations = new TreeSet<ItemStack>(ItemHelper.baseComparator);
|
||||
this.knownTransmutations = new TreeSet<ItemStack>(ItemHelper.idComparator);
|
||||
}
|
||||
inventory = knownTransmutations.toArray(inventory);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ public class InventoryTransmutationTablet implements IInventory
|
|||
{
|
||||
inventory = new ItemStack[30];
|
||||
|
||||
this.knownTransmutations = new TreeSet<ItemStack>(ItemHelper.baseComparator);
|
||||
this.knownTransmutations = new TreeSet<ItemStack>(ItemHelper.idComparator);
|
||||
if (knownTransmutations != null)
|
||||
{
|
||||
this.knownTransmutations.addAll(knownTransmutations);
|
||||
|
|
|
@ -72,7 +72,7 @@ public class ItemAlchemicalInventoryUpgrade extends ItemEE
|
|||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List list, boolean flag)
|
||||
{
|
||||
list.add(StatCollector.translateToLocal(Messages.UPGRADES_CHESTS));
|
||||
list.add(StatCollector.translateToLocal(Messages.Tooltips.UPGRADES_CHESTS));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -32,15 +32,15 @@ public class ItemBlockAlchemicalChest extends ItemBlock
|
|||
|
||||
if (metaData == 0)
|
||||
{
|
||||
list.add(StatCollector.translateToLocal(StatCollector.translateToLocal(Messages.SMALL)));
|
||||
list.add(StatCollector.translateToLocal(StatCollector.translateToLocal(Messages.Tooltips.SMALL)));
|
||||
}
|
||||
else if (metaData == 1)
|
||||
{
|
||||
list.add(StatCollector.translateToLocal(StatCollector.translateToLocal(Messages.MEDIUM)));
|
||||
list.add(StatCollector.translateToLocal(StatCollector.translateToLocal(Messages.Tooltips.MEDIUM)));
|
||||
}
|
||||
else if (metaData == 2)
|
||||
{
|
||||
list.add(StatCollector.translateToLocal(StatCollector.translateToLocal(Messages.LARGE)));
|
||||
list.add(StatCollector.translateToLocal(StatCollector.translateToLocal(Messages.Tooltips.LARGE)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ public class AbilityRegistry implements JsonSerializer<AbilityRegistry>, JsonDes
|
|||
private boolean hasBeenModified;
|
||||
private Set<WrappedStack> notLearnableSet;
|
||||
private Set<WrappedStack> notRecoverableSet;
|
||||
private SortedSet<ItemStack> allLearnableItemStacks = new TreeSet<ItemStack>(ItemHelper.baseComparator);
|
||||
private SortedSet<ItemStack> allLearnableItemStacks = new TreeSet<ItemStack>(ItemHelper.idComparator);
|
||||
|
||||
private AbilityRegistry()
|
||||
{
|
||||
|
@ -56,7 +56,7 @@ public class AbilityRegistry implements JsonSerializer<AbilityRegistry>, JsonDes
|
|||
|
||||
public void discoverAllLearnableItemStacks()
|
||||
{
|
||||
this.allLearnableItemStacks = new TreeSet<ItemStack>(ItemHelper.baseComparator);
|
||||
this.allLearnableItemStacks = new TreeSet<ItemStack>(ItemHelper.idComparator);
|
||||
for (WrappedStack wrappedStack : EnergyValueRegistry.getInstance().getStackValueMap().keySet())
|
||||
{
|
||||
if (isLearnable(wrappedStack) && EnergyValueRegistry.getInstance().getEnergyValue(wrappedStack) != null)
|
||||
|
|
|
@ -26,7 +26,7 @@ public class TransmutationKnowledge implements INBTTaggable, JsonSerializer<Tran
|
|||
|
||||
public TransmutationKnowledge()
|
||||
{
|
||||
this(new TreeSet<ItemStack>(ItemHelper.baseComparator));
|
||||
this(new TreeSet<ItemStack>(ItemHelper.idComparator));
|
||||
}
|
||||
|
||||
public TransmutationKnowledge(Collection<ItemStack> knownTransmutations)
|
||||
|
@ -37,7 +37,7 @@ public class TransmutationKnowledge implements INBTTaggable, JsonSerializer<Tran
|
|||
public TransmutationKnowledge(Collection<ItemStack> knownTransmutations, boolean canTransmuteEverything)
|
||||
{
|
||||
this.canTransmuteEverything = canTransmuteEverything;
|
||||
this.knownTransmutations = new TreeSet<ItemStack>(ItemHelper.baseComparator);
|
||||
this.knownTransmutations = new TreeSet<ItemStack>(ItemHelper.idComparator);
|
||||
this.knownTransmutations.addAll(knownTransmutations);
|
||||
hasBeenModified = false;
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ public class TransmutationKnowledge implements INBTTaggable, JsonSerializer<Tran
|
|||
public TransmutationKnowledge(NBTTagCompound nbtTagCompound)
|
||||
{
|
||||
canTransmuteEverything = false;
|
||||
this.knownTransmutations = new TreeSet<ItemStack>(ItemHelper.baseComparator);
|
||||
this.knownTransmutations = new TreeSet<ItemStack>(ItemHelper.idComparator);
|
||||
this.readFromNBT(nbtTagCompound);
|
||||
hasBeenModified = false;
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ public class TransmutationKnowledge implements INBTTaggable, JsonSerializer<Tran
|
|||
if (nbtTagCompound.hasKey(Names.NBT.ITEM_TRANSMUTATION_KNOWLEDGE))
|
||||
{
|
||||
NBTTagList tagList = nbtTagCompound.getTagList(Names.NBT.ITEM_TRANSMUTATION_KNOWLEDGE, 10);
|
||||
knownTransmutations = new TreeSet<ItemStack>(ItemHelper.baseComparator);
|
||||
knownTransmutations = new TreeSet<ItemStack>(ItemHelper.idComparator);
|
||||
for (int i = 0; i < tagList.tagCount(); ++i)
|
||||
{
|
||||
NBTTagCompound tagCompound = tagList.getCompoundTagAt(i);
|
||||
|
@ -160,7 +160,7 @@ public class TransmutationKnowledge implements INBTTaggable, JsonSerializer<Tran
|
|||
}
|
||||
else
|
||||
{
|
||||
knownTransmutations = new TreeSet<ItemStack>(ItemHelper.baseComparator);
|
||||
knownTransmutations = new TreeSet<ItemStack>(ItemHelper.idComparator);
|
||||
}
|
||||
|
||||
if (nbtTagCompound.hasKey(Names.NBT.CAN_TRANSMUTE_ANYTHING))
|
||||
|
@ -174,7 +174,7 @@ public class TransmutationKnowledge implements INBTTaggable, JsonSerializer<Tran
|
|||
}
|
||||
else
|
||||
{
|
||||
knownTransmutations = new TreeSet<ItemStack>(ItemHelper.baseComparator);
|
||||
knownTransmutations = new TreeSet<ItemStack>(ItemHelper.idComparator);
|
||||
canTransmuteEverything = false;
|
||||
}
|
||||
}
|
||||
|
@ -245,7 +245,7 @@ public class TransmutationKnowledge implements INBTTaggable, JsonSerializer<Tran
|
|||
JsonObject jsonObject = (JsonObject) json;
|
||||
|
||||
boolean canTransmuteEverything;
|
||||
Set<ItemStack> itemStacks = new TreeSet<ItemStack>(ItemHelper.baseComparator);
|
||||
Set<ItemStack> itemStacks = new TreeSet<ItemStack>(ItemHelper.idComparator);
|
||||
|
||||
if (jsonObject.has("canTransmuteEverything") && jsonObject.get("canTransmuteEverything").isJsonPrimitive())
|
||||
{
|
||||
|
|
|
@ -123,9 +123,7 @@ public class MessageTransmutationKnowledgeUpdate implements IMessage, IMessageHa
|
|||
|
||||
if (guiContainer.inventorySlots instanceof ContainerTransmutationTablet)
|
||||
{
|
||||
TileEntityTransmutationTablet tileEntityTransmutationTablet = ((ContainerTransmutationTablet) guiContainer.inventorySlots).tileEntityTransmutationTablet;
|
||||
|
||||
if (tileEntityTransmutationTablet.xCoord == message.xCoord && tileEntityTransmutationTablet.yCoord == message.yCoord && tileEntityTransmutationTablet.zCoord == message.zCoord)
|
||||
if (FMLClientHandler.instance().getWorldClient().getTileEntity(message.xCoord, message.yCoord, message.zCoord) instanceof TileEntityTransmutationTablet)
|
||||
{
|
||||
((ContainerTransmutationTablet) guiContainer.inventorySlots).handleTransmutationKnowledgeUpdate(message.transmutationKnowledge);
|
||||
}
|
||||
|
|
|
@ -2,14 +2,8 @@ package com.pahimar.ee3.reference;
|
|||
|
||||
public final class Messages
|
||||
{
|
||||
public static final String UPGRADES_CHESTS = "tooltip.ee3:upgradesPrefix";
|
||||
public static final String ITEM_BELONGS_TO = "tooltip.ee3:belongsTo";
|
||||
public static final String ITEM_BELONGS_TO_NO_ONE = "tooltip.ee3:belongsToNoOne";
|
||||
public static final String SMALL = "tooltip.ee3:small";
|
||||
public static final String MEDIUM = "tooltip.ee3:medium";
|
||||
public static final String LARGE = "tooltip.ee3:large";
|
||||
|
||||
public static final String OWNER_SET_TO_SELF = "misc.ee3:owner-set-to-self";
|
||||
public static final String ENERGY_VALUE = "misc.ee3:energy-value";
|
||||
|
||||
/* Fingerprint check related constants */
|
||||
public static final String NO_FINGERPRINT_MESSAGE = "The copy of Equivalent Exchange 3 that you are running is a development version of the mod, and as such may be unstable and/or incomplete.";
|
||||
|
@ -22,6 +16,21 @@ public final class Messages
|
|||
public static final String NO_KNOWN_TRANSMUTATIONS = GUI_PREFIX + "alchemicalTome.noTransmutationsKnown";
|
||||
}
|
||||
|
||||
public static final class Tooltips
|
||||
{
|
||||
private static final String TOOLTIP_PREFIX = "tooltip.ee3:";
|
||||
|
||||
public static final String UPGRADES_CHESTS = TOOLTIP_PREFIX + "upgradesPrefix";
|
||||
public static final String ITEM_BELONGS_TO = TOOLTIP_PREFIX + "belongsTo";
|
||||
public static final String ITEM_BELONGS_TO_NO_ONE = TOOLTIP_PREFIX + "belongsToNoOne";
|
||||
public static final String SMALL = TOOLTIP_PREFIX + "small";
|
||||
public static final String MEDIUM = TOOLTIP_PREFIX + "medium";
|
||||
public static final String LARGE = TOOLTIP_PREFIX + "large";
|
||||
public static final String SORT_BY_DISPLAY_NAME = TOOLTIP_PREFIX + "sortByDisplayName";
|
||||
public static final String SORT_BY_ENERGY_VALUE = TOOLTIP_PREFIX + "sortByEnergyValue";
|
||||
public static final String SORT_BY_ID = TOOLTIP_PREFIX + "sortByID";
|
||||
}
|
||||
|
||||
public static final class Commands
|
||||
{
|
||||
private static final String COMMAND_PREFIX = "commands.ee3.";
|
||||
|
|
|
@ -11,7 +11,7 @@ public class FilterUtils
|
|||
{
|
||||
public static Set<ItemStack> filterForItemBlock(Set<ItemStack> unfilteredItemStackSet)
|
||||
{
|
||||
return filterForItemBlock(unfilteredItemStackSet, ItemHelper.baseComparator);
|
||||
return filterForItemBlock(unfilteredItemStackSet, ItemHelper.idComparator);
|
||||
}
|
||||
|
||||
public static Set<ItemStack> filterForItemBlock(Set<ItemStack> unfilteredItemStackSet, Comparator comparator)
|
||||
|
@ -31,7 +31,7 @@ public class FilterUtils
|
|||
|
||||
public static Set<ItemStack> filterByNameStartsWith(Set<ItemStack> unfilteredItemStackSet, String filterString)
|
||||
{
|
||||
return filterByNameStartsWith(unfilteredItemStackSet, filterString, ItemHelper.baseComparator);
|
||||
return filterByNameStartsWith(unfilteredItemStackSet, filterString, ItemHelper.idComparator);
|
||||
}
|
||||
|
||||
public static Set<ItemStack> filterByNameStartsWith(Set<ItemStack> unfilteredItemStackSet, String filterString, Comparator comparator)
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package com.pahimar.ee3.util;
|
||||
|
||||
import com.pahimar.ee3.exchange.EnergyValueRegistry;
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.UUID;
|
||||
|
@ -18,7 +18,7 @@ public class ItemHelper
|
|||
return clonedItemStack;
|
||||
}
|
||||
|
||||
public static Comparator<ItemStack> baseComparator = new Comparator<ItemStack>()
|
||||
public static Comparator<ItemStack> idComparator = new Comparator<ItemStack>()
|
||||
{
|
||||
public int compare(ItemStack itemStack1, ItemStack itemStack2)
|
||||
{
|
||||
|
@ -97,55 +97,7 @@ public class ItemHelper
|
|||
{
|
||||
if (itemStack1.getDisplayName().equalsIgnoreCase(itemStack2.getDisplayName()))
|
||||
{
|
||||
// Sort on itemID
|
||||
if (Item.getIdFromItem(itemStack1.getItem()) - Item.getIdFromItem(itemStack2.getItem()) == 0)
|
||||
{
|
||||
// Sort on item
|
||||
if (itemStack1.getItem() == itemStack2.getItem())
|
||||
{
|
||||
// Then sort on meta
|
||||
if (itemStack1.getItemDamage() == itemStack2.getItemDamage() || itemStack1.getItemDamage() == OreDictionary.WILDCARD_VALUE || itemStack2.getItemDamage() == OreDictionary.WILDCARD_VALUE)
|
||||
{
|
||||
// Then sort on NBT
|
||||
if (itemStack1.hasTagCompound() && itemStack2.hasTagCompound())
|
||||
{
|
||||
// Then sort on stack size
|
||||
if (ItemStack.areItemStackTagsEqual(itemStack1, itemStack2))
|
||||
{
|
||||
return (itemStack1.stackSize - itemStack2.stackSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (itemStack1.getTagCompound().hashCode() - itemStack2.getTagCompound().hashCode());
|
||||
}
|
||||
}
|
||||
else if (!(itemStack1.hasTagCompound()) && itemStack2.hasTagCompound())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else if (itemStack1.hasTagCompound() && !(itemStack2.hasTagCompound()))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (itemStack1.stackSize - itemStack2.stackSize);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return (itemStack1.getItemDamage() - itemStack2.getItemDamage());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return itemStack1.getItem().getUnlocalizedName(itemStack1).compareToIgnoreCase(itemStack2.getItem().getUnlocalizedName(itemStack2));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return Item.getIdFromItem(itemStack1.getItem()) - Item.getIdFromItem(itemStack2.getItem());
|
||||
}
|
||||
return idComparator.compare(itemStack1, itemStack2);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -167,6 +119,37 @@ public class ItemHelper
|
|||
}
|
||||
};
|
||||
|
||||
public static Comparator<ItemStack> energyValueComparator = new Comparator<ItemStack>()
|
||||
{
|
||||
@Override
|
||||
public int compare(ItemStack itemStack1, ItemStack itemStack2)
|
||||
{
|
||||
if (itemStack1 != null && itemStack2 != null)
|
||||
{
|
||||
if (EnergyValueRegistry.getInstance().hasEnergyValue(itemStack1) && EnergyValueRegistry.getInstance().hasEnergyValue(itemStack2))
|
||||
{
|
||||
return Float.compare(EnergyValueRegistry.getInstance().getEnergyValue(itemStack1).getEnergyValue(), EnergyValueRegistry.getInstance().getEnergyValue(itemStack2).getEnergyValue());
|
||||
}
|
||||
else
|
||||
{
|
||||
return idComparator.compare(itemStack1, itemStack2);
|
||||
}
|
||||
}
|
||||
else if (itemStack1 != null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else if (itemStack2 != null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Compares two ItemStacks for equality, testing itemID, metaData, stackSize, and their NBTTagCompounds (if they are
|
||||
* present)
|
||||
|
@ -177,7 +160,7 @@ public class ItemHelper
|
|||
*/
|
||||
public static boolean equals(ItemStack first, ItemStack second)
|
||||
{
|
||||
return (baseComparator.compare(first, second) == 0);
|
||||
return (idComparator.compare(first, second) == 0);
|
||||
}
|
||||
|
||||
public static boolean equalsIgnoreStackSize(ItemStack itemStack1, ItemStack itemStack2)
|
||||
|
@ -216,7 +199,7 @@ public class ItemHelper
|
|||
|
||||
public static int compare(ItemStack itemStack1, ItemStack itemStack2)
|
||||
{
|
||||
return baseComparator.compare(itemStack1, itemStack2);
|
||||
return idComparator.compare(itemStack1, itemStack2);
|
||||
}
|
||||
|
||||
public static String toString(ItemStack itemStack)
|
||||
|
|
|
@ -37,15 +37,15 @@ public class WailaDataProvider implements IWailaDataProvider
|
|||
}
|
||||
else if (accessor.getTileEntity() instanceof TileEntityAlchemicalChestSmall)
|
||||
{
|
||||
currentTip.set(0, SpecialChars.WHITE + StatCollector.translateToLocal(Messages.SMALL) + " " + StatCollector.translateToLocal(Names.Blocks.ALCHEMICAL_CHEST));
|
||||
currentTip.set(0, SpecialChars.WHITE + StatCollector.translateToLocal(Messages.Tooltips.SMALL) + " " + StatCollector.translateToLocal(Names.Blocks.ALCHEMICAL_CHEST));
|
||||
}
|
||||
else if (accessor.getTileEntity() instanceof TileEntityAlchemicalChestMedium)
|
||||
{
|
||||
currentTip.set(0, SpecialChars.WHITE + StatCollector.translateToLocal(Messages.MEDIUM) + " " + StatCollector.translateToLocal(Names.Blocks.ALCHEMICAL_CHEST));
|
||||
currentTip.set(0, SpecialChars.WHITE + StatCollector.translateToLocal(Messages.Tooltips.MEDIUM) + " " + StatCollector.translateToLocal(Names.Blocks.ALCHEMICAL_CHEST));
|
||||
}
|
||||
else if (accessor.getTileEntity() instanceof TileEntityAlchemicalChestLarge)
|
||||
{
|
||||
currentTip.set(0, SpecialChars.WHITE + StatCollector.translateToLocal(Messages.LARGE) + " " + StatCollector.translateToLocal(Names.Blocks.ALCHEMICAL_CHEST));
|
||||
currentTip.set(0, SpecialChars.WHITE + StatCollector.translateToLocal(Messages.Tooltips.LARGE) + " " + StatCollector.translateToLocal(Names.Blocks.ALCHEMICAL_CHEST));
|
||||
}
|
||||
else if (accessor.getTileEntity() instanceof TileEntityAlchemyArray)
|
||||
{
|
||||
|
|
|
@ -164,6 +164,10 @@ tooltip.ee3:upgradesPrefix=Upgrades (Alchemical) Chests
|
|||
tooltip.ee3:small=Small
|
||||
tooltip.ee3:medium=Medium
|
||||
tooltip.ee3:large=Large
|
||||
tooltip.ee3:sortByDisplayName=Sort by Display Name
|
||||
tooltip.ee3:sortByEnergyValue=Sort by Energy Value
|
||||
tooltip.ee3:sortByID=Sort by ID
|
||||
|
||||
#Misc
|
||||
misc.ee3:owner-set-to-self=You are now the owner of %s
|
||||
misc.ee3:owner-set-to-self=You are now the owner of %s
|
||||
misc.ee3:energy-value=Energy Value
|
Binary file not shown.
Before Width: | Height: | Size: 749 B After Width: | Height: | Size: 18 KiB |
Loading…
Reference in a new issue