Skip to content

Commit

Permalink
Fixed Upgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
Zokonius committed Mar 12, 2020
1 parent 06d0749 commit ab0de22
Show file tree
Hide file tree
Showing 34 changed files with 223 additions and 186 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@
## gedit
*~

## minecraft files
/asm
/config
/saves
/logs
/crash-reports

## translation reports
resources/assets/enderio/lang/*.lang.txt
*.bat
3 changes: 3 additions & 0 deletions src/main/java/crazypants/enderio/EnderIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import crazypants.enderio.conduit.item.ItemFunctionUpgrade;
import crazypants.enderio.conduit.item.ItemItemConduit;
import crazypants.enderio.conduit.item.filter.ItemBasicItemFilter;
import crazypants.enderio.conduit.item.filter.ItemBigItemFilter;
import crazypants.enderio.conduit.item.filter.ItemExistingItemFilter;
import crazypants.enderio.conduit.item.filter.ItemModItemFilter;
import crazypants.enderio.conduit.item.filter.ItemPowerItemFilter;
Expand Down Expand Up @@ -239,6 +240,7 @@ public class EnderIO {
public static ItemMEConduit itemMEConduit;
public static ItemOCConduit itemOCConduit;
public static ItemBasicItemFilter itemBasicFilterUpgrade;
public static ItemBigItemFilter itemBigFilterUpgrade;
public static ItemExistingItemFilter itemExistingItemFilter;
public static ItemModItemFilter itemModItemFilter;
public static ItemPowerItemFilter itemPowerItemFilter;
Expand Down Expand Up @@ -442,6 +444,7 @@ public void preInit(FMLPreInitializationEvent event) {
itemOCConduit = ItemOCConduit.create();

itemBasicFilterUpgrade = ItemBasicItemFilter.create();
// itemBigFilterUpgrade = ItemBigItemFilter.create();
itemExistingItemFilter = ItemExistingItemFilter.create();
itemModItemFilter = ItemModItemFilter.create();
itemPowerItemFilter = ItemPowerItemFilter.create();
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/crazypants/enderio/ModObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ public enum ModObject {
itemItemConduit,
itemGasConduit,
itemMEConduit,
itemOCConduit,
itemOCConduit,
itemBasicFilterUpgrade,
itemBigFilterUpgrade,
itemExistingItemFilter,
itemModItemFilter,
itemPowerItemFilter,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package crazypants.enderio.conduit.item.filter;

import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.EnderIOTab;
import crazypants.enderio.ModObject;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;

public class ItemBigItemFilter extends ItemBasicItemFilter {

public static ItemBigItemFilter create() {
ItemBigItemFilter result = new ItemBigItemFilter();
result.init();
return result;
}

private final IIcon[] icons;

protected ItemBigItemFilter() {
setCreativeTab(EnderIOTab.tabEnderIO);
setUnlocalizedName(ModObject.itemBigFilterUpgrade.unlocalisedName);
setHasSubtypes(true);
setMaxDamage(0);
setMaxStackSize(64);
icons = new IIcon[2];
}

protected void init() {
GameRegistry.registerItem(this, ModObject.itemBigFilterUpgrade.unlocalisedName);
}

@Override
public IItemFilter createFilterFromStack(ItemStack stack) {
int damage = MathHelper.clamp_int(stack.getItemDamage(), 0, 1);
ItemFilter filter;
if(damage == 0) {
filter = new ItemFilter(30,false);
} else {
filter = new ItemFilter(30,true);
}
if(stack.stackTagCompound != null && stack.stackTagCompound.hasKey("filter")) {
filter.readFromNBT(stack.stackTagCompound.getCompoundTag("filter"));
}
return filter;
}

@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister IIconRegister) {
icons[0] = IIconRegister.registerIcon("enderio:filterUpgradeBig");
icons[1] = IIconRegister.registerIcon("enderio:filterUpgradeBigAdvanced");
}

@Override
public String getUnlocalizedName(ItemStack par1ItemStack) {
int i = MathHelper.clamp_int(par1ItemStack.getItemDamage(), 0, 1);
return i == 0 ? "enderio.filterUpgradeBig" : "enderio.filterUpgradeBigAdvanced";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class ItemFilter implements IInventory, IItemFilter {

final List<int[]> oreIds;

private boolean isAdvanced;
private boolean isAdvanced;

public void copyFrom(ItemFilter o) {
isBlacklist = o.isBlacklist;
Expand All @@ -67,12 +67,12 @@ public void copyFrom(ItemFilter o) {
public ItemFilter() {
this(5, false);
}

public ItemFilter(boolean advanced) {
this(advanced ? 10 : 5, advanced);
}

private ItemFilter(int numItems, boolean isAdvanced) {
public ItemFilter(int numItems, boolean isAdvanced) {
this.isAdvanced = isAdvanced;
items = new ItemStack[numItems];
oreIds = new ArrayList<int[]>(numItems);
Expand Down Expand Up @@ -119,7 +119,7 @@ private boolean itemMatched(ItemStack item) {
matched = false;
} else if(matchNBT && !isNBTMatch(item, it)) {
matched = false;
}
}
}
if(!matched && useOreDict && isOreDicMatch(i, item)) {
matched = true;
Expand Down Expand Up @@ -147,10 +147,10 @@ private boolean isOreDicMatch(int filterItemIndex, ItemStack item) {
return true;
}
}
}
}
return false;
}

private boolean isNBTMatch(ItemStack filter, ItemStack item)
{
if (filter.stackTagCompound == null && item.stackTagCompound == null) return true;
Expand All @@ -163,7 +163,7 @@ private boolean isNBTMatch(ItemStack filter, ItemStack item)
return filterTag.equals(itemTag);
}

private int[] getCachedIds(int filterItemIndex) {
private int[] getCachedIds(int filterItemIndex) {
int[] res = oreIds.get(filterItemIndex);
if(res == null) {
ItemStack item = items[filterItemIndex];
Expand Down Expand Up @@ -280,13 +280,13 @@ public void readFromNBT(NBTTagCompound nbtRoot) {
isAdvanced = nbtRoot.getBoolean("isAdvanced");
fuzzyMode = FuzzyMode.values()[nbtRoot.getByte("fuzzyMode") & 255];

int numItems = isAdvanced ? 10 : 5;
int numItems = items.length;
items = new ItemStack[numItems];
oreIds.clear();
for(int i=0;i<numItems;i++) {
oreIds.add(null);
}
for (int i = 0; i < numItems; i++) {
for (int i = 0; i < numItems; i++) {
NBTBase tag = nbtRoot.getTag("item" + i);
if(tag instanceof NBTTagCompound) {
items[i] = ItemStack.loadItemStackFromNBT((NBTTagCompound) tag);
Expand Down Expand Up @@ -366,7 +366,7 @@ public boolean hasCustomInventoryName() {
}

@Override
public void markDirty() {
public void markDirty() {
}

@Override
Expand All @@ -391,8 +391,8 @@ public boolean isItemValidForSlot(int i, ItemStack itemstack) {
public void createGhostSlots(List<GhostSlot> slots, int xOffset, int yOffset, Runnable cb) {
int topY = yOffset;
int leftX = xOffset;
int index = 0;
int numRows = isAdvanced ? 2 : 1;
int index = 0;
int numRows = (int) Math.ceil(items.length/5);
for (int row = 0; row < numRows; ++row) {
for (int col = 0; col < 5; ++col) {
int x = leftX + col * 18;
Expand All @@ -404,14 +404,14 @@ public void createGhostSlots(List<GhostSlot> slots, int xOffset, int yOffset, Ru
}

@Override
public int getSlotCount() {
public int getSlotCount() {
return getSizeInventory();
}

public boolean isAdvanced() {
public boolean isAdvanced() {
return isAdvanced;
}

public boolean isDefault() {
return !isAdvanced && !isValid() && isBlacklist == DEFAULT_BLACKLIST &&
matchMeta == DEFAULT_META &&
Expand Down
21 changes: 10 additions & 11 deletions src/main/java/crazypants/enderio/item/ItemRecipes.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import cpw.mods.fml.common.registry.GameRegistry;
import crazypants.enderio.EnderIO;
import crazypants.enderio.item.darksteel.DarkSteelItems;
import crazypants.enderio.item.endsteel.EndSteelItems;
import crazypants.enderio.material.FrankenSkull;
import crazypants.enderio.material.MachinePart;

Expand Down Expand Up @@ -45,10 +44,10 @@ public static void addRecipes() {
addShaped(DarkSteelItems.itemDarkSteelBoots.createItemStack(), "s s", "s s", 's', darkSteel);

//End Steel
addShaped(EndSteelItems.itemEndSteelHelmet.createItemStack(), "sss", "sds", 's', endSteel, 'd', diode);
addShaped(EndSteelItems.itemEndSteelChestplate.createItemStack(), "sds", "sss", "sss", 's', endSteel, 'd', diode);
addShaped(EndSteelItems.itemEndSteelLeggings.createItemStack(), "sss", "sds", "s s", 's', endSteel, 'd', diode);
addShaped(EndSteelItems.itemEndSteelBoots.createItemStack(), "s s", "sds", 's', endSteel, 'd', diode);
addShaped(DarkSteelItems.itemEndSteelHelmet.createItemStack(), "sss", "sds", 's', endSteel, 'd', diode);
addShaped(DarkSteelItems.itemEndSteelChestplate.createItemStack(), "sds", "sss", "sss", 's', endSteel, 'd', diode);
addShaped(DarkSteelItems.itemEndSteelLeggings.createItemStack(), "sss", "sds", "s s", 's', endSteel, 'd', diode);
addShaped(DarkSteelItems.itemEndSteelBoots.createItemStack(), "s s", "sds", 's', endSteel, 'd', diode);

ItemStack wing = new ItemStack(DarkSteelItems.itemGliderWing, 1, 0);
addShaped(wing, " s", " sl", "sll", 's', darkSteel, 'l', Items.leather);
Expand Down Expand Up @@ -79,12 +78,12 @@ public static void addRecipes() {
addShaped(DarkSteelItems.itemDarkSteelAxe.createItemStack(), "ss ", "sw ", " w ", 's', darkSteel, 'w', "stickWood");

// ES Tools
addShaped(EndSteelItems.itemEndSteelSword.createItemStack(), " s ", " s ", " w ", 's', endSteel, 'w', "stickDarkSteel");
addShaped(EndSteelItems.itemEndSteelSword.createItemStack(), " s ", " s ", " w ", 's', endSteel, 'w', "itemDarkSteelRod");
addShaped(EndSteelItems.itemEndSteelPickaxe.createItemStack(), "sss", " w ", " w ", 's', endSteel, 'w', "stickDarkSteel");
addShaped(EndSteelItems.itemEndSteelPickaxe.createItemStack(), "sss", " w ", " w ", 's', endSteel, 'w', "itemDarkSteelRod");
addShaped(EndSteelItems.itemEndSteelAxe.createItemStack(), "ss ", "sw ", " w ", 's', endSteel, 'w', "stickDarkSteel");
addShaped(EndSteelItems.itemEndSteelAxe.createItemStack(), "ss ", "sw ", " w ", 's', endSteel, 'w', "itemDarkSteelRod");
addShaped(DarkSteelItems.itemEndSteelSword.createItemStack(), " s ", " s ", " w ", 's', endSteel, 'w', "stickDarkSteel");
addShaped(DarkSteelItems.itemEndSteelSword.createItemStack(), " s ", " s ", " w ", 's', endSteel, 'w', "itemDarkSteelRod");
addShaped(DarkSteelItems.itemEndSteelPickaxe.createItemStack(), "sss", " w ", " w ", 's', endSteel, 'w', "stickDarkSteel");
addShaped(DarkSteelItems.itemEndSteelPickaxe.createItemStack(), "sss", " w ", " w ", 's', endSteel, 'w', "itemDarkSteelRod");
addShaped(DarkSteelItems.itemEndSteelAxe.createItemStack(), "ss ", "sw ", " w ", 's', endSteel, 'w', "stickDarkSteel");
addShaped(DarkSteelItems.itemEndSteelAxe.createItemStack(), "ss ", "sw ", " w ", 's', endSteel, 'w', "itemDarkSteelRod");

}
}
Loading

0 comments on commit ab0de22

Please sign in to comment.