WIP API for adding new slots

Rendering needs reworked and shift-clicking needs some improvements.
This commit is contained in:
jss2a98aj committed 2021-11-03 05:13:32 -04:00
1 parent 36a332e597
commit e50c4de348
11 files changed
+393 -434

No files matched your search

+1 -5
View File
@@ -3,9 +3,5 @@ package baubles.api;
public enum BaubleType {
RING,
AMULET,
BELT,
HEAD,
BODY,
CHARM,
GAUNTLET
BELT
}
+1 -1
View File
@@ -13,7 +13,7 @@ import net.minecraft.item.ItemStack;
public interface IBauble {
/**
* This method return the type of bauble this is.
* This method returns the type of bauble this is.
* Type is used to determine the slots it can go into.
*/
public BaubleType getBaubleType(ItemStack itemstack);
@@ -0,0 +1,65 @@
package baubles.api.expanded;
public class BaubleExpandedSlots {
public static final int slotLimit = 20;
private static String[] slots = new String[slotLimit];
private static int newSlotsRemaining = slotLimit;
static {
requestAddSlot("AMULET");
requestAddSlot("RING");
requestAddSlot("RING");
requestAddSlot("BELT");
}
public static boolean requestAddSlot(String type) {
//TODO: block after GUI init
if(newSlotsRemaining >= 1) {
slots[slotLimit - newSlotsRemaining] = type;
newSlotsRemaining--;
return true;
}
return false;
}
public static boolean requestRemoveSlot(String type) {
//TODO: block after GUI init
for(int slotToCheck = 0; slotToCheck < slotLimit; slotToCheck++) {
if(slots[slotToCheck].equals(type)) {
for(int slotToMove = slotToCheck + 1; slotToMove < slotLimit; slotToMove++) {
slots[slotToMove - 1] = slots[slotToMove];
}
slots[slotLimit - 1] = null;
newSlotsRemaining++;
return true;
}
}
return false;
}
public static int totalCurrentSlotsForType(String type) {
int total = 0;
for(int slotToCheck = 0; slotToCheck < slotLimit; slotToCheck++) {
if(slots[slotToCheck].equals(type)) {
total++;
}
}
return total;
}
public static int getTotalSlots() {
return slotLimit - newSlotsRemaining;
}
public static String getTypeInSlot(int slot) {
if (slot > 0 & slot < slotLimit) {
return slots[slot];
} else {
return null;
}
}
}
@@ -0,0 +1,23 @@
package baubles.api.expanded;
import baubles.api.IBauble;
import net.minecraft.item.ItemStack;
/**
*
* This interface should be extended by items that can be worn in bauble slots.
* Supports multiple original and expanded slot types.
*
* @author jss2a98aj
*/
public interface IBaubleExpanded extends IBauble {
/**
* This method returns the types of bauble slots this item can go into.
* getBaubleType is ignored when using IBaubleExpanded.
* Original slots can be used by putting "AMULET" "RING" or BELT" in the array.
*/
public String[] getBaubleTypes (ItemStack itemstack);
}