Skip to content

Commit

Permalink
Merge branch '1.10.2_develop' into 1.10.2_master
Browse files Browse the repository at this point in the history
  • Loading branch information
defeatedcrow committed Mar 7, 2018
2 parents 252a94a + baead87 commit f2b3c31
Show file tree
Hide file tree
Showing 9 changed files with 149 additions and 115 deletions.
4 changes: 2 additions & 2 deletions java/defeatedcrow/hac/core/ClimateCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public class ClimateCore {
public static final String MOD_ID = "dcs_lib";
public static final String MOD_NAME = "HeatAndClimateLib";
public static final int MOD_MEJOR = 2;
public static final int MOD_MINOR = 2;
public static final int MOD_BUILD = 4;
public static final int MOD_MINOR = 3;
public static final int MOD_BUILD = 0;
public static final String MOD_DEPENDENCIES = "before:cavern;before:mekanism";
public static final String MOD_ACCEPTED_MC_VERSIONS = "[1.10, 1.11]";
public static final String PACKAGE_BASE = "dcs";
Expand Down
67 changes: 35 additions & 32 deletions java/defeatedcrow/hac/core/base/DCInventory.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ public ItemStack decrStackSize(int i, int num) {
if (i < 0 || i >= this.getSizeInventory())
return null;
if (!DCUtil.isEmpty(getStackInSlot(i))) {
ItemStack itemstack;
itemstack = getStackInSlot(i).splitStack(num);
ItemStack itemstack = getStackInSlot(i).splitStack(num);
if (getStackInSlot(i).stackSize <= 0) {
inv[i] = null;
}
return itemstack;
} else
return null;
Expand All @@ -76,7 +78,9 @@ public void setInventorySlotContents(int i, ItemStack stack) {

inv[i] = stack;

if (!DCUtil.isEmpty(stack) && stack.stackSize > this.getInventoryStackLimit()) {
if (DCUtil.isEmpty(stack)) {
stack = null;
} else if (!DCUtil.isEmpty(stack) && DCUtil.getSize(stack) > this.getInventoryStackLimit()) {
stack.stackSize = getInventoryStackLimit();
}

Expand Down Expand Up @@ -126,50 +130,53 @@ public boolean isItemValidForSlot(int i, ItemStack stack) {

// 追加メソッド
public static int isItemStackable(ItemStack target, ItemStack current) {
if (DCUtil.isEmpty(target) || DCUtil.isEmpty(current))
return 0;

if (target.getItem() == current.getItem() && target.getMetadata() == current.getMetadata()
&& ItemStack.areItemStackTagsEqual(target, current)) {
int i = current.stackSize + target.stackSize;
if (i > current.getMaxStackSize()) {
i = current.getMaxStackSize() - current.stackSize;
return i;
if (DCUtil.isSameItem(target, current, false)) {
int i1 = DCUtil.getSize(current) + DCUtil.getSize(target);
if (!DCUtil.isEmpty(current) && i1 > current.getMaxStackSize()) {
return current.getMaxStackSize() - DCUtil.getSize(current);
} else {
return DCUtil.getSize(target);
}
return target.stackSize;
}

return 0;
}

public void incrStackInSlot(int i, ItemStack input) {
if (i < this.getSizeInventory() && !DCUtil.isEmpty(input)) {
public int canIncr(int i, ItemStack get) {
if (i < 0 || i >= this.getSizeInventory() || DCUtil.isEmpty(get))
return 0;
else if (DCUtil.isEmpty(getStackInSlot(i)))
return DCUtil.getSize(get);
else {
return isItemStackable(get, getStackInSlot(i));
}
}

public int incrStackInSlot(int i, ItemStack input) {
if (i >= 0 || i < this.getSizeInventory() && !DCUtil.isEmpty(input)) {
if (!DCUtil.isEmpty(getStackInSlot(i))) {
ItemStack stack = getStackInSlot(i);
if (stack.getItem() == input.getItem() && stack.getMetadata() == input.getMetadata()) {
DCUtil.addStackSize(stack, input.stackSize);
if (stack.stackSize > this.getInventoryStackLimit()) {
stack.stackSize = getInventoryStackLimit();
}
}
int add = isItemStackable(input, getStackInSlot(i));
DCUtil.addStackSize(getStackInSlot(i), add);
return add;
} else {
this.setInventorySlotContents(i, input);
return DCUtil.getSize(input);
}
}
return 0;
}

@Override
public ItemStack removeStackFromSlot(int i) {
if (i < 0 || i >= this.getSizeInventory())
return null;
else {
ItemStack itemstack = null;
if (!DCUtil.isEmpty(getStackInSlot(i))) {
ItemStack itemstack = this.getStackInSlot(i);
inv[i] = null;
return itemstack;
itemstack = this.getStackInSlot(i).copy();
}
inv[i] = null;
return itemstack;
}
return null;
}

@Override
Expand Down Expand Up @@ -210,13 +217,9 @@ public void readFromNBT(NBTTagCompound tag) {
byte b0 = tag1.getByte("Slot");

if (b0 >= 0 && b0 < this.getSizeInventory()) {
inv2[b0] = ItemStack.loadItemStackFromNBT(tag1);
inv[b0] = ItemStack.loadItemStackFromNBT(tag1);
}
}

for (int i1 = 0; i1 < getSizeInventory(); i1++) {
inv[i1] = inv2[i1];
}
}

public NBTTagCompound writeToNBT(NBTTagCompound tag) {
Expand Down
20 changes: 1 addition & 19 deletions java/defeatedcrow/hac/core/climate/recipe/ClimateSmelting.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import defeatedcrow.hac.core.fluid.DCFluidUtil;
import defeatedcrow.hac.core.util.DCUtil;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
Expand Down Expand Up @@ -58,24 +57,7 @@ public ClimateSmelting(ItemStack o, ItemStack s, DCHeatTier t, DCHumidity h, DCA
hum.add(h);
if (a != null)
air.add(a);
processedInput = new ArrayList<ItemStack>();
if (input instanceof String) {
List<ItemStack> ret = new ArrayList<ItemStack>();
ret.addAll(OreDictionary.getOres((String) input));
processedInput.addAll(ret);
} else if (input instanceof List && !((List) input).isEmpty()) {
List<ItemStack> ret = (List<ItemStack>) input;
processedInput.addAll(ret);
} else if (input instanceof ItemStack) {
if (!DCUtil.isEmpty((ItemStack) input))
processedInput.add(((ItemStack) input).copy());
} else if (input instanceof Item) {
processedInput.add(new ItemStack((Item) input, 1, 0));
} else if (input instanceof Block) {
processedInput.add(new ItemStack((Block) input, 1, 0));
} else {
throw new IllegalArgumentException("Unknown Object passed to recipe!");
}
processedInput = DCUtil.getProcessedList(input);
}

@Override
Expand Down
22 changes: 1 addition & 21 deletions java/defeatedcrow/hac/core/climate/recipe/CrusherRecipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@

import defeatedcrow.hac.api.recipe.ICrusherRecipe;
import defeatedcrow.hac.core.util.DCUtil;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.OreDictionary;

public class CrusherRecipe implements ICrusherRecipe {

Expand All @@ -36,24 +33,7 @@ public CrusherRecipe(ItemStack o, float c0, ItemStack s, float c1, ItemStack t,
chance2 = c2;
outputF = oF;
catalyst = cat;
processedInput = new ArrayList<ItemStack>();
if (input instanceof String) {
List<ItemStack> ret = new ArrayList<ItemStack>();
ret.addAll(OreDictionary.getOres((String) input));
processedInput.addAll(ret);
} else if (input instanceof List && !((List) input).isEmpty()) {
List<ItemStack> ret = (List<ItemStack>) input;
processedInput.addAll(ret);
} else if (input instanceof ItemStack) {
if (!DCUtil.isEmpty((ItemStack) input))
processedInput.add(((ItemStack) input).copy());
} else if (input instanceof Item) {
processedInput.add(new ItemStack((Item) input, 1, 0));
} else if (input instanceof Block) {
processedInput.add(new ItemStack((Block) input, 1, 0));
} else {
throw new IllegalArgumentException("Unknown Object passed to recipe!");
}
processedInput = DCUtil.getProcessedList(input);
}

@Override
Expand Down
22 changes: 1 addition & 21 deletions java/defeatedcrow/hac/core/climate/recipe/MillRecipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
import defeatedcrow.hac.api.recipe.IMillRecipe;
import defeatedcrow.hac.core.fluid.DCFluidUtil;
import defeatedcrow.hac.core.util.DCUtil;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;

public class MillRecipe implements IMillRecipe {

Expand All @@ -25,24 +22,7 @@ public MillRecipe(ItemStack o, ItemStack s, float c, Object i) {
output = o;
secondary = s;
chance = c;
processedInput = new ArrayList<ItemStack>();
if (input instanceof String) {
List<ItemStack> ret = new ArrayList<ItemStack>();
ret.addAll(OreDictionary.getOres((String) input));
processedInput.addAll(ret);
} else if (input instanceof List && !((List) input).isEmpty()) {
List<ItemStack> ret = (List<ItemStack>) input;
processedInput.addAll(ret);
} else if (input instanceof ItemStack) {
if (!DCUtil.isEmpty((ItemStack) input))
processedInput.add(((ItemStack) input).copy());
} else if (input instanceof Item) {
processedInput.add(new ItemStack((Item) input, 1, 0));
} else if (input instanceof Block) {
processedInput.add(new ItemStack((Block) input, 1, 0));
} else {
throw new IllegalArgumentException("Unknown Object passed to recipe!");
}
processedInput = DCUtil.getProcessedList(input);
}

@Override
Expand Down
10 changes: 10 additions & 0 deletions java/defeatedcrow/hac/core/energy/SidedEnergyStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ public SidedEnergyStorage(int cap, int rate, boolean forcedSide) {
receive[6] = !forcedSide;
}

public SidedEnergyStorage setExtract(boolean[] bools) {
extract = bools;
return this;
}

public SidedEnergyStorage setReceive(boolean[] bools) {
receive = bools;
return this;
}

@Override
public int receiveEnergy(int maxReceive, boolean simulate) {
return receiveEnergy(maxReceive, simulate, null);
Expand Down
22 changes: 3 additions & 19 deletions java/defeatedcrow/hac/core/energy/TileTorqueProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public int insertResult(ItemStack item) {
this.incrStackInSlot(i, item.copy());
return item.stackSize;
} else {
int size = this.isItemStackable(item, this.getStackInSlot(i));
int size = inventory.isItemStackable(item, this.getStackInSlot(i));
if (size > 0) {
DCUtil.addStackSize(this.getStackInSlot(i), size);
return size;
Expand Down Expand Up @@ -248,25 +248,9 @@ public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction)
}

// 追加メソッド
public static int isItemStackable(ItemStack target, ItemStack current) {
if (DCUtil.isEmpty(target) || DCUtil.isEmpty(current))
return 0;

if (target.getItem() == current.getItem() && target.getMetadata() == current.getMetadata()
&& ItemStack.areItemStackTagsEqual(target, current)) {
int i = current.stackSize + target.stackSize;
if (i > current.getMaxStackSize()) {
i = current.getMaxStackSize() - current.stackSize;
return i;
}
return target.stackSize;
}

return 0;
}

public void incrStackInSlot(int i, ItemStack input) {
inventory.incrStackInSlot(i, input);
public int incrStackInSlot(int i, ItemStack input) {
return inventory.incrStackInSlot(i, input);
}

@Override
Expand Down

0 comments on commit f2b3c31

Please sign in to comment.