Stuff that isn't complete
This commit is contained in:
parent
66f2289f97
commit
bd06adddc2
|
@ -63,6 +63,14 @@ public class BlockCalcinator extends BlockEE implements ITileEntityProvider
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockEventReceived(World world, int x, int y, int z, int eventId, int eventData)
|
||||
{
|
||||
super.onBlockEventReceived(world, x, y, z, eventId, eventData);
|
||||
TileEntity tileentity = world.getTileEntity(x, y, z);
|
||||
return tileentity != null && tileentity.receiveClientEvent(eventId, eventData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
|
@ -84,14 +92,6 @@ public class BlockCalcinator extends BlockEE implements ITileEntityProvider
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockEventReceived(World world, int x, int y, int z, int eventId, int eventData)
|
||||
{
|
||||
super.onBlockEventReceived(world, x, y, z, eventId, eventData);
|
||||
TileEntity tileentity = world.getTileEntity(x, y, z);
|
||||
return tileentity != null && tileentity.receiveClientEvent(eventId, eventData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue(IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
|
|
|
@ -2,11 +2,14 @@ package com.pahimar.ee3.client.gui.inventory;
|
|||
|
||||
import com.pahimar.ee3.client.gui.element.ElementSearchField;
|
||||
import com.pahimar.ee3.inventory.ContainerTransmutationTablet;
|
||||
import com.pahimar.ee3.network.PacketHandler;
|
||||
import com.pahimar.ee3.network.message.MessageSliderElementUpdated;
|
||||
import com.pahimar.ee3.reference.Colors;
|
||||
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 cpw.mods.fml.relauncher.Side;
|
||||
|
@ -21,6 +24,7 @@ public class GuiTransmutationTablet extends GuiBase
|
|||
private TileEntityTransmutationTablet tileEntityTransmutationTablet;
|
||||
|
||||
private ElementTextField searchTextField;
|
||||
private ElementButton sortOrderButton;
|
||||
private ElementSlider slider;
|
||||
|
||||
private static DecimalFormat energyValueDecimalFormat = new DecimalFormat("###,###,###,###,###.###");
|
||||
|
@ -44,9 +48,10 @@ public class GuiTransmutationTablet extends GuiBase
|
|||
searchTextField = new ElementSearchField(this, 173, 18, "searchField", 78, 10);
|
||||
searchTextField.backgroundColor = new GuiColor(0, 0, 0, 0).getColor();
|
||||
searchTextField.borderColor = new GuiColor(0, 0, 0, 0).getColor();
|
||||
searchTextField.setFocused(true);
|
||||
|
||||
slider = new ElementSlider(this, 239, 36, 12, 74, 187, 0)
|
||||
sortOrderButton = new ElementButton(this, 151, 36, "sortOrder", 0, 0, 18, 0, 36, 0, 18, 18, 54, 18, Textures.Gui.Elements.BUTTON_SORT_ORDER);
|
||||
|
||||
slider = new ElementSlider(this, 239, 36, 12, 201, 187, 0)
|
||||
{
|
||||
@Override
|
||||
protected void dragSlider(int x, int y)
|
||||
|
@ -61,6 +66,12 @@ public class GuiTransmutationTablet extends GuiBase
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopDragging()
|
||||
{
|
||||
PacketHandler.INSTANCE.sendToServer(new MessageSliderElementUpdated(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSliderY()
|
||||
{
|
||||
|
@ -71,6 +82,7 @@ public class GuiTransmutationTablet extends GuiBase
|
|||
slider.borderColor = new GuiColor(0, 0, 0, 0).getColor();
|
||||
slider.setSliderSize(12, 15);
|
||||
|
||||
addElement(sortOrderButton);
|
||||
addElement(searchTextField);
|
||||
addElement(slider);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.pahimar.ee3.inventory;
|
||||
|
||||
import com.pahimar.ee3.inventory.element.IElementButtonHandler;
|
||||
import com.pahimar.ee3.inventory.element.IElementTextFieldHandler;
|
||||
import com.pahimar.ee3.item.ItemAlchemicalTome;
|
||||
import com.pahimar.ee3.knowledge.TransmutationKnowledgeRegistry;
|
||||
import com.pahimar.ee3.util.FilterUtils;
|
||||
|
@ -16,7 +18,7 @@ import java.util.List;
|
|||
import java.util.TreeSet;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ContainerAlchemicalTome extends ContainerEE implements ITextFieldElementHandler
|
||||
public class ContainerAlchemicalTome extends ContainerEE implements IElementButtonHandler, IElementTextFieldHandler
|
||||
{
|
||||
private final InventoryAlchemicalTome inventoryAlchemicalTome;
|
||||
private final ItemStack alchemicalTomeItemStack;
|
||||
|
@ -112,6 +114,8 @@ public class ContainerAlchemicalTome extends ContainerEE implements ITextFieldEl
|
|||
icrafting.sendProgressBarUpdate(this, 0, this.pageOffset);
|
||||
icrafting.sendProgressBarUpdate(this, 1, this.maxPageOffset);
|
||||
}
|
||||
|
||||
requiresUpdate = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -149,14 +153,14 @@ public class ContainerAlchemicalTome extends ContainerEE implements ITextFieldEl
|
|||
}
|
||||
|
||||
@Override
|
||||
public void handleElementButtonClick(String buttonName, int mouseButton)
|
||||
public void handleElementButtonClick(String elementName, int mouseButton)
|
||||
{
|
||||
if (buttonName.equalsIgnoreCase("prev") && mouseButton == 0 && this.pageOffset > 0)
|
||||
if (elementName.equalsIgnoreCase("prev") && mouseButton == 0 && this.pageOffset > 0)
|
||||
{
|
||||
this.pageOffset--;
|
||||
updateInventory();
|
||||
}
|
||||
else if (buttonName.equalsIgnoreCase("next") && mouseButton == 0 && this.pageOffset < this.maxPageOffset)
|
||||
else if (elementName.equalsIgnoreCase("next") && mouseButton == 0 && this.pageOffset < this.maxPageOffset)
|
||||
{
|
||||
this.pageOffset++;
|
||||
updateInventory();
|
||||
|
@ -164,9 +168,9 @@ public class ContainerAlchemicalTome extends ContainerEE implements ITextFieldEl
|
|||
}
|
||||
|
||||
@Override
|
||||
public void handleElementTextFieldUpdate(String buttonName, String updatedText)
|
||||
public void handleElementTextFieldUpdate(String elementName, String updatedText)
|
||||
{
|
||||
if (buttonName.equalsIgnoreCase("searchField"))
|
||||
if (elementName.equalsIgnoreCase("searchField"))
|
||||
{
|
||||
this.searchTerm = updatedText;
|
||||
pageOffset = 0;
|
||||
|
@ -180,7 +184,6 @@ public class ContainerAlchemicalTome extends ContainerEE implements ITextFieldEl
|
|||
boolean shouldUpdateInventory = false;
|
||||
ItemStack[] newInventory = new ItemStack[80];
|
||||
List<ItemStack> filteredList = new ArrayList(FilterUtils.filterByNameContains(inventoryAlchemicalTome.getKnownTransmutations(), searchTerm, ItemHelper.displayNameComparator));
|
||||
FilterUtils.filterOutListItemsWithInvalidIcons(filteredList, ItemHelper.displayNameComparator);
|
||||
|
||||
maxPageOffset = filteredList.size() / 80;
|
||||
if (pageOffset > maxPageOffset)
|
||||
|
|
|
@ -87,9 +87,4 @@ public abstract class ContainerEE extends Container
|
|||
|
||||
return slotFound;
|
||||
}
|
||||
|
||||
public void handleElementButtonClick(String buttonName, int mouseButton)
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,40 +1,65 @@
|
|||
package com.pahimar.ee3.inventory;
|
||||
|
||||
import com.pahimar.ee3.api.EnergyValue;
|
||||
import com.pahimar.ee3.exchange.EnergyValueRegistry;
|
||||
import com.pahimar.ee3.inventory.element.IElementSliderHandler;
|
||||
import com.pahimar.ee3.inventory.element.IElementTextFieldHandler;
|
||||
import com.pahimar.ee3.item.ItemAlchemicalTome;
|
||||
import com.pahimar.ee3.item.ItemMiniumStone;
|
||||
import com.pahimar.ee3.item.ItemPhilosophersStone;
|
||||
import com.pahimar.ee3.knowledge.AbilityRegistry;
|
||||
import com.pahimar.ee3.knowledge.TransmutationKnowledge;
|
||||
import com.pahimar.ee3.knowledge.TransmutationKnowledgeRegistry;
|
||||
import com.pahimar.ee3.network.PacketHandler;
|
||||
import com.pahimar.ee3.network.message.MessageTransmutationKnowledgeUpdate;
|
||||
import com.pahimar.ee3.tileentity.TileEntityTransmutationTablet;
|
||||
import com.pahimar.ee3.util.FilterUtils;
|
||||
import com.pahimar.ee3.util.ItemHelper;
|
||||
import com.pahimar.ee3.util.LogHelper;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerTransmutationTablet extends ContainerEE implements ITextFieldElementHandler
|
||||
import java.util.*;
|
||||
|
||||
public class ContainerTransmutationTablet extends ContainerEE implements IElementTextFieldHandler, IElementSliderHandler
|
||||
{
|
||||
private InventoryTransmutationTablet inventoryTransmutationTablet;
|
||||
private TileEntityTransmutationTablet tileEntityTransmutationTablet;
|
||||
private EnergyValue energyValue;
|
||||
private float energyValue;
|
||||
private String searchTerm;
|
||||
private boolean requiresUpdate = false;
|
||||
|
||||
public ContainerTransmutationTablet(InventoryPlayer inventoryPlayer, TileEntityTransmutationTablet tileEntityTransmutationTablet)
|
||||
{
|
||||
this.tileEntityTransmutationTablet = tileEntityTransmutationTablet;
|
||||
|
||||
this.addSlotToContainer(new SlotTabletInput(tileEntityTransmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_1, 62, 24));
|
||||
this.addSlotToContainer(new SlotTabletInput(tileEntityTransmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_2, 35, 35));
|
||||
this.addSlotToContainer(new SlotTabletInput(tileEntityTransmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_3, 26, 61));
|
||||
this.addSlotToContainer(new SlotTabletInput(tileEntityTransmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_4, 35, 87));
|
||||
this.addSlotToContainer(new SlotTabletInput(tileEntityTransmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_5, 62, 99));
|
||||
this.addSlotToContainer(new SlotTabletInput(tileEntityTransmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_6, 89, 87));
|
||||
this.addSlotToContainer(new SlotTabletInput(tileEntityTransmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_7, 98, 61));
|
||||
this.addSlotToContainer(new SlotTabletInput(tileEntityTransmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_8, 89, 35));
|
||||
TreeSet<ItemStack> knownTransmutations = new TreeSet<ItemStack>(ItemHelper.displayNameComparator);
|
||||
if (tileEntityTransmutationTablet.getStackInSlot(TileEntityTransmutationTablet.ALCHEMICAL_TOME_INDEX) != null)
|
||||
{
|
||||
ItemStack itemStack = tileEntityTransmutationTablet.getStackInSlot(TileEntityTransmutationTablet.ALCHEMICAL_TOME_INDEX);
|
||||
if (itemStack.getItem() instanceof ItemAlchemicalTome && ItemHelper.hasOwnerUUID(itemStack))
|
||||
{
|
||||
knownTransmutations.addAll(TransmutationKnowledgeRegistry.getInstance().getPlayersKnownTransmutations(ItemHelper.getOwnerUUID(itemStack)));
|
||||
}
|
||||
}
|
||||
inventoryTransmutationTablet = new InventoryTransmutationTablet(knownTransmutations);
|
||||
|
||||
this.energyValue = tileEntityTransmutationTablet.getStoredEnergyValue().getEnergyValue();
|
||||
|
||||
this.addSlotToContainer(new SlotTabletInput(this, tileEntityTransmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_1, 62, 24));
|
||||
this.addSlotToContainer(new SlotTabletInput(this, tileEntityTransmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_2, 35, 35));
|
||||
this.addSlotToContainer(new SlotTabletInput(this, tileEntityTransmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_3, 26, 61));
|
||||
this.addSlotToContainer(new SlotTabletInput(this, tileEntityTransmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_4, 35, 87));
|
||||
this.addSlotToContainer(new SlotTabletInput(this, tileEntityTransmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_5, 62, 99));
|
||||
this.addSlotToContainer(new SlotTabletInput(this, tileEntityTransmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_6, 89, 87));
|
||||
this.addSlotToContainer(new SlotTabletInput(this, tileEntityTransmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_7, 98, 61));
|
||||
this.addSlotToContainer(new SlotTabletInput(this, tileEntityTransmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_8, 89, 35));
|
||||
this.addSlotToContainer(new Slot(tileEntityTransmutationTablet, TileEntityTransmutationTablet.STONE_INDEX, 62, 61)
|
||||
{
|
||||
@Override
|
||||
|
@ -49,70 +74,13 @@ public class ContainerTransmutationTablet extends ContainerEE implements ITextFi
|
|||
return itemStack.getItem() instanceof ItemMiniumStone || itemStack.getItem() instanceof ItemPhilosophersStone;
|
||||
}
|
||||
});
|
||||
this.addSlotToContainer(new Slot(tileEntityTransmutationTablet, TileEntityTransmutationTablet.ALCHEMICAL_TOME_INDEX, 152, 15)
|
||||
{
|
||||
@Override
|
||||
public int getSlotStackLimit()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack itemStack)
|
||||
{
|
||||
return itemStack.getItem() instanceof ItemAlchemicalTome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickupFromSlot(EntityPlayer entityPlayer, ItemStack itemStack)
|
||||
{
|
||||
super.onPickupFromSlot(entityPlayer, itemStack);
|
||||
|
||||
if (!((TileEntityTransmutationTablet) this.inventory).getWorldObj().isRemote)
|
||||
{
|
||||
LogHelper.info("onPickup: " + ItemHelper.toString(itemStack));
|
||||
this.inventory.setInventorySlotContents(15, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack(ItemStack itemStack)
|
||||
{
|
||||
super.putStack(itemStack);
|
||||
|
||||
if (!((TileEntityTransmutationTablet) this.inventory).getWorldObj().isRemote)
|
||||
{
|
||||
LogHelper.info("putStack: " + ItemHelper.toString(itemStack));
|
||||
this.inventory.setInventorySlotContents(15, itemStack);
|
||||
}
|
||||
}
|
||||
});
|
||||
this.addSlotToContainer(new SlotAlchemicalTome(this, tileEntityTransmutationTablet, TileEntityTransmutationTablet.ALCHEMICAL_TOME_INDEX, 152, 15));
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(tileEntityTransmutationTablet, 10 + (j + i * 3), 175 + j * 20, 39 + i * 20)
|
||||
{
|
||||
@Override
|
||||
public boolean canTakeStack(EntityPlayer entityPlayer)
|
||||
{
|
||||
return super.canTakeStack(entityPlayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickupFromSlot(EntityPlayer entityPlayer, ItemStack itemStack)
|
||||
{
|
||||
super.onPickupFromSlot(entityPlayer, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean func_111238_b()
|
||||
{
|
||||
return this.getHasStack();
|
||||
}
|
||||
});
|
||||
this.addSlotToContainer(new SlotTabletOutput(this, inventoryTransmutationTablet, i * 3 + j, 175 + j * 20, 38 + i * 20));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,28 +98,98 @@ public class ContainerTransmutationTablet extends ContainerEE implements ITextFi
|
|||
{
|
||||
this.addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 8 + actionBarSlotIndex * 18, 222));
|
||||
}
|
||||
|
||||
this.updateInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
super.detectAndSendChanges();
|
||||
this.energyValue = this.tileEntityTransmutationTablet.getStoredEnergyValue();
|
||||
|
||||
for (Object crafter : this.crafters)
|
||||
{
|
||||
ICrafting iCrafting = (ICrafting) crafter;
|
||||
|
||||
if (this.energyValue != this.tileEntityTransmutationTablet.getStoredEnergyValue().getEnergyValue())
|
||||
{
|
||||
this.energyValue = this.tileEntityTransmutationTablet.getStoredEnergyValue().getEnergyValue();
|
||||
this.updateInventory();
|
||||
int energyValueAsInt = Float.floatToRawIntBits(this.tileEntityTransmutationTablet.getStoredEnergyValue().getEnergyValue());
|
||||
iCrafting.sendProgressBarUpdate(this, 0, energyValueAsInt & 0xffff);
|
||||
iCrafting.sendProgressBarUpdate(this, 1, energyValueAsInt >>> 16);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void updateProgressBar(int valueType, int updatedValue)
|
||||
{
|
||||
if (valueType == 0)
|
||||
{
|
||||
int energyValueAsInt = Float.floatToRawIntBits(energyValue);
|
||||
energyValueAsInt = (energyValueAsInt & 0xffff0000) | updatedValue;
|
||||
energyValue = Float.intBitsToFloat(energyValueAsInt);
|
||||
}
|
||||
else if (valueType == 1)
|
||||
{
|
||||
int energyValueAsInt = Float.floatToRawIntBits(energyValue);
|
||||
energyValueAsInt = (energyValueAsInt & 0xffff) | (updatedValue << 16);
|
||||
energyValue = Float.intBitsToFloat(energyValueAsInt);
|
||||
}
|
||||
|
||||
if (valueType == 0 || valueType == 1)
|
||||
{
|
||||
this.updateInventory();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleElementTextFieldUpdate(String buttonName, String updatedText)
|
||||
public void handleElementTextFieldUpdate(String elementName, String updatedText)
|
||||
{
|
||||
if (buttonName.equalsIgnoreCase("searchField"))
|
||||
if (elementName.equalsIgnoreCase("searchField"))
|
||||
{
|
||||
this.searchTerm = updatedText;
|
||||
updateInventory();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleElementSliderUpdate(String elementName, int elementValue)
|
||||
{
|
||||
LogHelper.info(elementValue);
|
||||
}
|
||||
|
||||
public void handleTransmutationKnowledgeUpdate(TransmutationKnowledge transmutationKnowledge)
|
||||
{
|
||||
if (transmutationKnowledge != null)
|
||||
{
|
||||
this.inventoryTransmutationTablet = new InventoryTransmutationTablet(transmutationKnowledge.getKnownTransmutations());
|
||||
this.updateInventory();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateInventory()
|
||||
{
|
||||
ItemStack[] newInventory = new ItemStack[30];
|
||||
|
||||
Set<ItemStack> filteredSet = FilterUtils.filterByNameContains(this.inventoryTransmutationTablet.getKnownTransmutations(), searchTerm);
|
||||
List<ItemStack> filteredList = new ArrayList(FilterUtils.filterByEnergyValue(filteredSet, energyValue));
|
||||
Collections.sort(filteredList, ItemHelper.displayNameComparator);
|
||||
|
||||
if (filteredList.size() <= 30)
|
||||
{
|
||||
newInventory = filteredList.toArray(newInventory);
|
||||
}
|
||||
else
|
||||
{
|
||||
newInventory = filteredList.subList(0, 30).toArray(newInventory);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 30; i++)
|
||||
{
|
||||
this.getSlot(i + 10).putStack(newInventory[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -215,11 +253,67 @@ public class ContainerTransmutationTablet extends ContainerEE implements ITextFi
|
|||
return itemStack;
|
||||
}
|
||||
|
||||
private class SlotTabletOutput extends Slot
|
||||
private class SlotAlchemicalTome extends Slot
|
||||
{
|
||||
public SlotTabletOutput(IInventory iInventory, int slotIndex, int x, int y)
|
||||
private ContainerTransmutationTablet containerTransmutationTablet;
|
||||
private TileEntityTransmutationTablet tileEntityTransmutationTablet;
|
||||
|
||||
public SlotAlchemicalTome(ContainerTransmutationTablet containerTransmutationTablet, IInventory iInventory, int slotIndex, int x, int y)
|
||||
{
|
||||
super(iInventory, slotIndex, x, y);
|
||||
this.containerTransmutationTablet = containerTransmutationTablet;
|
||||
this.tileEntityTransmutationTablet = containerTransmutationTablet.tileEntityTransmutationTablet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotStackLimit()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack itemStack)
|
||||
{
|
||||
return itemStack.getItem() instanceof ItemAlchemicalTome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickupFromSlot(EntityPlayer entityPlayer, ItemStack itemStack)
|
||||
{
|
||||
super.onPickupFromSlot(entityPlayer, 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))
|
||||
{
|
||||
PacketHandler.INSTANCE.sendToAllAround(new MessageTransmutationKnowledgeUpdate(knownTransmutations), new NetworkRegistry.TargetPoint(this.tileEntityTransmutationTablet.getWorldObj().provider.dimensionId, (double) this.tileEntityTransmutationTablet.xCoord, (double) this.tileEntityTransmutationTablet.yCoord, (double) this.tileEntityTransmutationTablet.zCoord, 5d));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack(ItemStack itemStack)
|
||||
{
|
||||
super.putStack(itemStack);
|
||||
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(knownTransmutations), new NetworkRegistry.TargetPoint(this.tileEntityTransmutationTablet.getWorldObj().provider.dimensionId, (double) this.tileEntityTransmutationTablet.xCoord, (double) this.tileEntityTransmutationTablet.yCoord, (double) this.tileEntityTransmutationTablet.zCoord, 5d));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class SlotTabletOutput extends Slot
|
||||
{
|
||||
private ContainerTransmutationTablet containerTransmutationTablet;
|
||||
|
||||
public SlotTabletOutput(ContainerTransmutationTablet containerTransmutationTablet, IInventory iInventory, int slotIndex, int x, int y)
|
||||
{
|
||||
super(iInventory, slotIndex, x, y);
|
||||
this.containerTransmutationTablet = containerTransmutationTablet;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -227,13 +321,36 @@ public class ContainerTransmutationTablet extends ContainerEE implements ITextFi
|
|||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack(EntityPlayer entityPlayer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickupFromSlot(EntityPlayer entityPlayer, ItemStack itemStack)
|
||||
{
|
||||
super.onPickupFromSlot(entityPlayer, itemStack);
|
||||
this.containerTransmutationTablet.inventoryTransmutationTablet.setInventorySlotContents(this.getSlotIndex(), new ItemStack(itemStack.getItem(), 1, itemStack.getItemDamage()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean func_111238_b()
|
||||
{
|
||||
return this.getHasStack();
|
||||
}
|
||||
}
|
||||
|
||||
private class SlotTabletInput extends Slot
|
||||
{
|
||||
public SlotTabletInput(IInventory iInventory, int slotIndex, int x, int y)
|
||||
private ContainerTransmutationTablet containerTransmutationTablet;
|
||||
|
||||
public SlotTabletInput(ContainerTransmutationTablet containerTransmutationTablet, IInventory iInventory, int slotIndex, int x, int y)
|
||||
{
|
||||
super(iInventory, slotIndex, x, y);
|
||||
this.containerTransmutationTablet = containerTransmutationTablet;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -241,5 +358,21 @@ public class ContainerTransmutationTablet extends ContainerEE implements ITextFi
|
|||
{
|
||||
return EnergyValueRegistry.getInstance().hasEnergyValue(itemStack) && AbilityRegistry.getInstance().isRecoverable(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickupFromSlot(EntityPlayer entityPlayer, ItemStack itemStack)
|
||||
{
|
||||
super.onPickupFromSlot(entityPlayer, itemStack);
|
||||
this.containerTransmutationTablet.tileEntityTransmutationTablet.updateEnergyValueFromInventory();
|
||||
this.containerTransmutationTablet.updateInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack(ItemStack itemStack)
|
||||
{
|
||||
super.putStack(itemStack);
|
||||
this.containerTransmutationTablet.tileEntityTransmutationTablet.updateEnergyValueFromInventory();
|
||||
this.containerTransmutationTablet.updateInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
package com.pahimar.ee3.inventory;
|
||||
|
||||
public interface ITextFieldElementHandler
|
||||
{
|
||||
public abstract void handleElementTextFieldUpdate(String buttonName, String updatedText);
|
||||
}
|
|
@ -6,26 +6,45 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.*;
|
||||
|
||||
public class InventoryTransmutationTablet implements IInventory
|
||||
{
|
||||
private ItemStack[] inventory;
|
||||
private Set<ItemStack> knownTransmutations;
|
||||
|
||||
public InventoryTransmutationTablet(Set<ItemStack> knownTransmutations)
|
||||
public InventoryTransmutationTablet()
|
||||
{
|
||||
this(null);
|
||||
}
|
||||
|
||||
public InventoryTransmutationTablet(Collection<ItemStack> knownTransmutations)
|
||||
{
|
||||
inventory = new ItemStack[30];
|
||||
|
||||
this.knownTransmutations = new TreeSet<ItemStack>(ItemHelper.baseComparator);
|
||||
if (knownTransmutations != null)
|
||||
{
|
||||
this.knownTransmutations = knownTransmutations;
|
||||
this.knownTransmutations.addAll(knownTransmutations);
|
||||
}
|
||||
|
||||
List<ItemStack> knownTransmutationsList = new ArrayList<ItemStack>(this.knownTransmutations);
|
||||
if (knownTransmutationsList.size() <= 30)
|
||||
{
|
||||
inventory = knownTransmutationsList.toArray(inventory);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.knownTransmutations = new TreeSet<ItemStack>(ItemHelper.baseComparator);
|
||||
inventory = knownTransmutationsList.subList(0, 30).toArray(inventory);
|
||||
}
|
||||
|
||||
for (int i = 0; i < inventory.length; i++)
|
||||
{
|
||||
if (inventory[i] instanceof ItemStack)
|
||||
{
|
||||
inventory[i].stackSize = 1;
|
||||
}
|
||||
}
|
||||
inventory = knownTransmutations.toArray(inventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -45,6 +64,10 @@ public class InventoryTransmutationTablet implements IInventory
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes from an inventory slot (first arg) up to a specified number (second arg) of items and returns them in a
|
||||
* new stack.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slotIndex, int decrementAmount)
|
||||
{
|
||||
|
@ -58,11 +81,14 @@ public class InventoryTransmutationTablet implements IInventory
|
|||
else
|
||||
{
|
||||
itemStack = itemStack.splitStack(decrementAmount);
|
||||
|
||||
if (itemStack.stackSize == 0)
|
||||
{
|
||||
setInventorySlotContents(slotIndex, null);
|
||||
}
|
||||
}
|
||||
|
||||
setInventorySlotContents(slotIndex, itemStack);
|
||||
}
|
||||
|
||||
return itemStack;
|
||||
|
@ -88,7 +114,16 @@ public class InventoryTransmutationTablet implements IInventory
|
|||
{
|
||||
if (slotIndex < inventory.length)
|
||||
{
|
||||
inventory[slotIndex] = itemStack;
|
||||
if (itemStack != null)
|
||||
{
|
||||
ItemStack copiedItemStack = itemStack.copy();
|
||||
copiedItemStack.stackSize = 1;
|
||||
inventory[slotIndex] = copiedItemStack;
|
||||
}
|
||||
else
|
||||
{
|
||||
inventory[slotIndex] = itemStack;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
package com.pahimar.ee3.inventory.element;
|
||||
|
||||
public interface IElementButtonHandler
|
||||
{
|
||||
public abstract void handleElementButtonClick(String elementName, int mouseButton);
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package com.pahimar.ee3.inventory.element;
|
||||
|
||||
public interface IElementSliderHandler
|
||||
{
|
||||
public abstract void handleElementSliderUpdate(String elementName, int elementValue);
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package com.pahimar.ee3.inventory.element;
|
||||
|
||||
public interface IElementTextFieldHandler
|
||||
{
|
||||
public abstract void handleElementTextFieldUpdate(String elementName, String updatedText);
|
||||
}
|
|
@ -27,5 +27,7 @@ public class PacketHandler
|
|||
INSTANCE.registerMessage(MessageTileEntityAlchemyArray.class, MessageTileEntityAlchemyArray.class, 12, Side.CLIENT);
|
||||
INSTANCE.registerMessage(MessageTileEntityTransmutationTablet.class, MessageTileEntityTransmutationTablet.class, 13, Side.CLIENT);
|
||||
INSTANCE.registerMessage(MessageSingleParticleEvent.class, MessageSingleParticleEvent.class, 14, Side.CLIENT);
|
||||
INSTANCE.registerMessage(MessageSliderElementUpdated.class, MessageSliderElementUpdated.class, 15, Side.SERVER);
|
||||
INSTANCE.registerMessage(MessageTransmutationKnowledgeUpdate.class, MessageTransmutationKnowledgeUpdate.class, 16, Side.CLIENT);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.pahimar.ee3.network.message;
|
||||
|
||||
import com.pahimar.ee3.inventory.ContainerEE;
|
||||
import com.pahimar.ee3.inventory.element.IElementButtonHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
|
@ -46,9 +46,9 @@ public class MessageGuiElementClicked implements IMessage, IMessageHandler<Messa
|
|||
|
||||
if (entityPlayer != null)
|
||||
{
|
||||
if (entityPlayer.openContainer instanceof ContainerEE)
|
||||
if (entityPlayer.openContainer instanceof IElementButtonHandler)
|
||||
{
|
||||
((ContainerEE) entityPlayer.openContainer).handleElementButtonClick(message.elementName, message.buttonPressed);
|
||||
((IElementButtonHandler) entityPlayer.openContainer).handleElementButtonClick(message.elementName, message.buttonPressed);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.pahimar.ee3.network.message;
|
||||
|
||||
import com.pahimar.ee3.inventory.ITextFieldElementHandler;
|
||||
import com.pahimar.ee3.inventory.element.IElementTextFieldHandler;
|
||||
import com.pahimar.repackage.cofh.lib.gui.element.ElementTextField;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
|
@ -54,9 +54,9 @@ public class MessageGuiElementTextFieldUpdate implements IMessage, IMessageHandl
|
|||
|
||||
if (entityPlayer != null)
|
||||
{
|
||||
if (entityPlayer.openContainer instanceof ITextFieldElementHandler)
|
||||
if (entityPlayer.openContainer instanceof IElementTextFieldHandler)
|
||||
{
|
||||
((ITextFieldElementHandler) entityPlayer.openContainer).handleElementTextFieldUpdate(message.elementName, message.elementText);
|
||||
((IElementTextFieldHandler) entityPlayer.openContainer).handleElementTextFieldUpdate(message.elementName, message.elementText);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
package com.pahimar.ee3.network.message;
|
||||
|
||||
import com.pahimar.ee3.inventory.element.IElementSliderHandler;
|
||||
import com.pahimar.repackage.cofh.lib.gui.element.ElementSlider;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
public class MessageSliderElementUpdated implements IMessage, IMessageHandler<MessageSliderElementUpdated, IMessage>
|
||||
{
|
||||
public String elementName;
|
||||
public int elementValue;
|
||||
|
||||
public MessageSliderElementUpdated()
|
||||
{
|
||||
}
|
||||
|
||||
public MessageSliderElementUpdated(ElementSlider elementSlider)
|
||||
{
|
||||
this(elementSlider.getName(), elementSlider.getValue());
|
||||
}
|
||||
|
||||
public MessageSliderElementUpdated(String elementName, int elementValue)
|
||||
{
|
||||
this.elementName = elementName;
|
||||
this.elementValue = elementValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf)
|
||||
{
|
||||
int elementNameLength = buf.readInt();
|
||||
this.elementName = new String(buf.readBytes(elementNameLength).array());
|
||||
this.elementValue = buf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf)
|
||||
{
|
||||
if (elementName != null)
|
||||
{
|
||||
buf.writeInt(elementName.length());
|
||||
buf.writeBytes(elementName.getBytes());
|
||||
}
|
||||
else
|
||||
{
|
||||
buf.writeInt(0);
|
||||
}
|
||||
buf.writeInt(elementValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(MessageSliderElementUpdated message, MessageContext ctx)
|
||||
{
|
||||
EntityPlayer entityPlayer = ctx.getServerHandler().playerEntity;
|
||||
|
||||
if (entityPlayer != null)
|
||||
{
|
||||
if (entityPlayer.openContainer instanceof IElementSliderHandler)
|
||||
{
|
||||
((IElementSliderHandler) entityPlayer.openContainer).handleElementSliderUpdate(message.elementName, message.elementValue);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
package com.pahimar.ee3.network.message;
|
||||
|
||||
import com.pahimar.ee3.inventory.ContainerTransmutationTablet;
|
||||
import com.pahimar.ee3.knowledge.TransmutationKnowledge;
|
||||
import com.pahimar.ee3.util.CompressionHelper;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class MessageTransmutationKnowledgeUpdate implements IMessage, IMessageHandler<MessageTransmutationKnowledgeUpdate, IMessage>
|
||||
{
|
||||
public TransmutationKnowledge transmutationKnowledge;
|
||||
|
||||
public MessageTransmutationKnowledgeUpdate()
|
||||
{
|
||||
}
|
||||
|
||||
public MessageTransmutationKnowledgeUpdate(Collection<ItemStack> knownTransmutationsCollection)
|
||||
{
|
||||
this.transmutationKnowledge = new TransmutationKnowledge(knownTransmutationsCollection);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf)
|
||||
{
|
||||
byte[] compressedString = null;
|
||||
int readableBytes = buf.readInt();
|
||||
|
||||
if (readableBytes > 0)
|
||||
{
|
||||
compressedString = buf.readBytes(readableBytes).array();
|
||||
}
|
||||
|
||||
if (compressedString != null)
|
||||
{
|
||||
String uncompressedString = CompressionHelper.decompressStringFromByteArray(compressedString);
|
||||
this.transmutationKnowledge = TransmutationKnowledge.createFromJson(uncompressedString);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf)
|
||||
{
|
||||
byte[] compressedString = null;
|
||||
|
||||
if (transmutationKnowledge != null)
|
||||
{
|
||||
compressedString = CompressionHelper.compressStringToByteArray(transmutationKnowledge.toJson());
|
||||
}
|
||||
|
||||
if (compressedString != null)
|
||||
{
|
||||
buf.writeInt(compressedString.length);
|
||||
buf.writeBytes(compressedString);
|
||||
}
|
||||
else
|
||||
{
|
||||
buf.writeInt(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(MessageTransmutationKnowledgeUpdate message, MessageContext ctx)
|
||||
{
|
||||
EntityPlayer entityPlayer = FMLClientHandler.instance().getClientPlayerEntity();
|
||||
|
||||
if (entityPlayer != null && entityPlayer.openContainer instanceof ContainerTransmutationTablet)
|
||||
{
|
||||
((ContainerTransmutationTablet) entityPlayer.openContainer).handleTransmutationKnowledgeUpdate(message.transmutationKnowledge);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -60,6 +60,7 @@ public final class Textures
|
|||
public static final ResourceLocation BUTTON_ENABLED = ResourceLocationHelper.getResourceLocation(ELEMENT_TEXTURE_LOCATION + "buttonEnabled.png");
|
||||
public static final ResourceLocation BUTTON_DISABLED = ResourceLocationHelper.getResourceLocation(ELEMENT_TEXTURE_LOCATION + "buttonDisabled.png");
|
||||
public static final ResourceLocation BUTTON_HOVER = ResourceLocationHelper.getResourceLocation(ELEMENT_TEXTURE_LOCATION + "buttonHover.png");
|
||||
public static final ResourceLocation BUTTON_SORT_ORDER = ResourceLocationHelper.getResourceLocation(ELEMENT_TEXTURE_LOCATION + "buttonSortOrder.png");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||
|
||||
public class TileEntityTransmutationTablet extends TileEntityEE implements ISidedInventory
|
||||
{
|
||||
public static final int INVENTORY_SIZE = 40;
|
||||
public static final int INVENTORY_SIZE = 10;
|
||||
public static final int ITEM_INPUT_1 = 0;
|
||||
public static final int ITEM_INPUT_2 = 1;
|
||||
public static final int ITEM_INPUT_3 = 2;
|
||||
|
@ -36,6 +36,7 @@ public class TileEntityTransmutationTablet extends TileEntityEE implements ISide
|
|||
public static final int ALCHEMICAL_TOME_INDEX = 9;
|
||||
|
||||
private EnergyValue storedEnergyValue;
|
||||
private EnergyValue availableEnergyValue;
|
||||
private ForgeDirection rotation;
|
||||
private ItemStack[] inventory;
|
||||
|
||||
|
@ -57,6 +58,19 @@ public class TileEntityTransmutationTablet extends TileEntityEE implements ISide
|
|||
this.storedEnergyValue = storedEnergyValue;
|
||||
}
|
||||
|
||||
public void updateEnergyValueFromInventory()
|
||||
{
|
||||
float newEnergyValue = 0f;
|
||||
for (int i = 0; i <= STONE_INDEX; i++)
|
||||
{
|
||||
if (inventory[i] != null && EnergyValueRegistry.getInstance().hasEnergyValue(inventory[i]))
|
||||
{
|
||||
newEnergyValue += EnergyValueRegistry.getInstance().getEnergyValue(inventory[i]).getEnergyValue() * inventory[i].stackSize;
|
||||
}
|
||||
}
|
||||
this.storedEnergyValue = new EnergyValue(newEnergyValue);
|
||||
}
|
||||
|
||||
public ForgeDirection getRotation()
|
||||
{
|
||||
return rotation;
|
||||
|
@ -90,6 +104,7 @@ public class TileEntityTransmutationTablet extends TileEntityEE implements ISide
|
|||
public void updateEntity()
|
||||
{
|
||||
super.updateEntity();
|
||||
updateEnergyValueFromInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -213,15 +228,7 @@ public class TileEntityTransmutationTablet extends TileEntityEE implements ISide
|
|||
itemStack.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
|
||||
float newEnergyValue = 0f;
|
||||
for (int i = 0; i <= STONE_INDEX; i++)
|
||||
{
|
||||
if (inventory[i] != null && EnergyValueRegistry.getInstance().hasEnergyValue(inventory[i]))
|
||||
{
|
||||
newEnergyValue += EnergyValueRegistry.getInstance().getEnergyValue(inventory[i]).getEnergyValue() * inventory[i].stackSize;
|
||||
}
|
||||
}
|
||||
this.storedEnergyValue = new EnergyValue(newEnergyValue);
|
||||
updateEnergyValueFromInventory();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.pahimar.ee3.util;
|
||||
|
||||
import com.pahimar.ee3.api.EnergyValue;
|
||||
import com.pahimar.ee3.api.EnergyValueRegistryProxy;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
@ -56,16 +58,11 @@ public class FilterUtils
|
|||
return nameSortedSet;
|
||||
}
|
||||
|
||||
public static Set<ItemStack> filterByNameContains(Set<ItemStack> unfilteredItemStackSet, String filterString)
|
||||
public static Set<ItemStack> filterByNameContains(Collection<ItemStack> unfilteredCollection, String filterString)
|
||||
{
|
||||
return filterByNameContains(unfilteredItemStackSet, filterString, ItemHelper.baseComparator);
|
||||
}
|
||||
Set<ItemStack> nameSortedSet = new HashSet<ItemStack>();
|
||||
|
||||
public static Set<ItemStack> filterByNameContains(Set<ItemStack> unfilteredItemStackSet, String filterString, Comparator comparator)
|
||||
{
|
||||
Set<ItemStack> nameSortedSet = new TreeSet<ItemStack>(comparator);
|
||||
|
||||
for (ItemStack itemStack : unfilteredItemStackSet)
|
||||
for (ItemStack itemStack : unfilteredCollection)
|
||||
{
|
||||
String itemDisplayName = itemStack.getDisplayName().toLowerCase();
|
||||
|
||||
|
@ -85,49 +82,73 @@ public class FilterUtils
|
|||
return nameSortedSet;
|
||||
}
|
||||
|
||||
public static void filterOutListItemsWithInvalidIcons(List<ItemStack> unfilteredCollection)
|
||||
public static Set<ItemStack> filterByNameContains(Collection<ItemStack> unfilteredCollection, String filterString, Comparator comparator)
|
||||
{
|
||||
filterOutListItemsWithInvalidIcons(unfilteredCollection, ItemHelper.baseComparator);
|
||||
}
|
||||
|
||||
public static Set<ItemStack> filterOutItemsWithInvalidIcons(Set<ItemStack> unfilteredCollection, Comparator comparator)
|
||||
{
|
||||
List<ItemStack> itemsToRemove = new ArrayList<ItemStack>();
|
||||
Set<ItemStack> filteredSet = new TreeSet<ItemStack>(comparator);
|
||||
Set<ItemStack> nameSortedSet = new TreeSet<ItemStack>(comparator);
|
||||
|
||||
for (ItemStack itemStack : unfilteredCollection)
|
||||
{
|
||||
try
|
||||
String itemDisplayName = itemStack.getDisplayName().toLowerCase();
|
||||
|
||||
if (filterString != null)
|
||||
{
|
||||
itemStack.getItem().getIconIndex(itemStack);
|
||||
filteredSet.add(itemStack);
|
||||
if (itemDisplayName.contains(filterString.toLowerCase()))
|
||||
{
|
||||
nameSortedSet.add(itemStack);
|
||||
}
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException e)
|
||||
else
|
||||
{
|
||||
itemsToRemove.add(itemStack);
|
||||
nameSortedSet.add(itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
return filteredSet;
|
||||
return nameSortedSet;
|
||||
}
|
||||
|
||||
public static void filterOutListItemsWithInvalidIcons(List<ItemStack> unfilteredCollection, Comparator comparator)
|
||||
public static Set<ItemStack> filterByEnergyValue(Collection<ItemStack> unfilteredCollection, EnergyValue energyValue)
|
||||
{
|
||||
List<ItemStack> itemsToRemove = new ArrayList<ItemStack>();
|
||||
return filterByEnergyValue(unfilteredCollection, energyValue.getEnergyValue());
|
||||
}
|
||||
|
||||
public static Set<ItemStack> filterByEnergyValue(Collection<ItemStack> unfilteredCollection, EnergyValue energyValue, Comparator<ItemStack> comparator)
|
||||
{
|
||||
return filterByEnergyValue(unfilteredCollection, energyValue.getEnergyValue(), comparator);
|
||||
}
|
||||
|
||||
public static Set<ItemStack> filterByEnergyValue(Collection<ItemStack> unfilteredCollection, float energyValue)
|
||||
{
|
||||
Set<ItemStack> sortedSet = new HashSet<ItemStack>();
|
||||
|
||||
for (ItemStack itemStack : unfilteredCollection)
|
||||
{
|
||||
try
|
||||
if (energyValue > 0f && EnergyValueRegistryProxy.hasEnergyValue(itemStack))
|
||||
{
|
||||
itemStack.getItem().getIconIndex(itemStack);
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException e)
|
||||
{
|
||||
itemsToRemove.add(itemStack);
|
||||
if (EnergyValueRegistryProxy.getEnergyValue(itemStack).getEnergyValue() <= energyValue)
|
||||
{
|
||||
sortedSet.add(itemStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unfilteredCollection.removeAll(itemsToRemove);
|
||||
Collections.sort(unfilteredCollection, comparator);
|
||||
return sortedSet;
|
||||
}
|
||||
|
||||
public static Set<ItemStack> filterByEnergyValue(Collection<ItemStack> unfilteredCollection, float energyValue, Comparator<ItemStack> comparator)
|
||||
{
|
||||
Set<ItemStack> sortedSet = new TreeSet<ItemStack>(comparator);
|
||||
|
||||
for (ItemStack itemStack : unfilteredCollection)
|
||||
{
|
||||
if (energyValue > 0f && EnergyValueRegistryProxy.hasEnergyValue(itemStack))
|
||||
{
|
||||
if (EnergyValueRegistryProxy.getEnergyValue(itemStack).getEnergyValue() <= energyValue)
|
||||
{
|
||||
sortedSet.add(itemStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return sortedSet;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,6 +49,11 @@ public abstract class ElementSlider extends ElementBase
|
|||
return this;
|
||||
}
|
||||
|
||||
public int getValue()
|
||||
{
|
||||
return this._value;
|
||||
}
|
||||
|
||||
public ElementSlider setValue(int value)
|
||||
{
|
||||
value = Math.max(_valueMin, Math.min(_valueMax, value));
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 749 B |
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 5.5 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue