This commit is contained in:
kuba6000 committed 2022-10-12 21:09:45 +02:00
1 parent d993c90c3e
commit 14a712260b
156 files changed
+14896 -13422

No files matched your search

@@ -3,7 +3,6 @@ package magicbees.client.gui;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
@@ -12,90 +11,70 @@ import net.minecraftforge.oredict.OreDictionary;
/**
* @author MysteriousAges
*/
public class SlotCustomItems extends Slot
{
private List<ItemStack> items;
public class SlotCustomItems extends Slot {
private List<ItemStack> items;
public SlotCustomItems(IInventory inventory, int slotIndex, int xPos, int yPos, ItemStack... items)
{
super(inventory, slotIndex, xPos, yPos);
this.items = new ArrayList<ItemStack>(items.length);
public SlotCustomItems(IInventory inventory, int slotIndex, int xPos, int yPos, ItemStack... items) {
super(inventory, slotIndex, xPos, yPos);
this.items = new ArrayList<ItemStack>(items.length);
Collections.addAll(this.items, items);
}
/**
* @return List of valid ItemStacks
*/
public List<ItemStack> getValidItems()
{
return this.items;
}
public void addValidItem(ItemStack newItem)
{
boolean contains = false;
for (int i = 0; i < this.items.size(); ++i)
{
ItemStack s = this.items.get(i);
if (s.getItem() == newItem.getItem())
{
if (s.getItemDamage() == OreDictionary.WILDCARD_VALUE)
{
contains = true;
break;
}
else if (s.getItemDamage() == newItem.getItemDamage())
{
contains = true;
break;
}
}
}
if (!contains)
{
this.items.add(newItem);
}
}
/**
* @param removeItem ItemStack to remove.
*/
public void removeValidItem(ItemStack removeItem)
{
for (int i = 0; i < this.items.size(); ++i)
{
ItemStack s = this.items.get(i);
if (s.getItem() == removeItem.getItem())
{
if (s.getItemDamage() == OreDictionary.WILDCARD_VALUE)
{
this.items.remove(i);
break;
}
else if (s.getItemDamage() == removeItem.getItemDamage())
{
this.items.remove(i);
break;
}
}
}
}
Collections.addAll(this.items, items);
}
@Override
public boolean isItemValid(ItemStack itemStack)
{
for (ItemStack item : this.items)
{
if (item != null && item.getItem() == itemStack.getItem())
{
if (item.getItemDamage() == itemStack.getItemDamage() || item.getItemDamage() == OreDictionary.WILDCARD_VALUE)
{
return true;
}
}
}
return false;
}
/**
* @return List of valid ItemStacks
*/
public List<ItemStack> getValidItems() {
return this.items;
}
public void addValidItem(ItemStack newItem) {
boolean contains = false;
for (int i = 0; i < this.items.size(); ++i) {
ItemStack s = this.items.get(i);
if (s.getItem() == newItem.getItem()) {
if (s.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
contains = true;
break;
} else if (s.getItemDamage() == newItem.getItemDamage()) {
contains = true;
break;
}
}
}
if (!contains) {
this.items.add(newItem);
}
}
/**
* @param removeItem ItemStack to remove.
*/
public void removeValidItem(ItemStack removeItem) {
for (int i = 0; i < this.items.size(); ++i) {
ItemStack s = this.items.get(i);
if (s.getItem() == removeItem.getItem()) {
if (s.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
this.items.remove(i);
break;
} else if (s.getItemDamage() == removeItem.getItemDamage()) {
this.items.remove(i);
break;
}
}
}
}
@Override
public boolean isItemValid(ItemStack itemStack) {
for (ItemStack item : this.items) {
if (item != null && item.getItem() == itemStack.getItem()) {
if (item.getItemDamage() == itemStack.getItemDamage()
|| item.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
return true;
}
}
}
return false;
}
}