mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-15 09:34:57 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
00c31a6158 | ||
|
|
5db5b712ce |
No files matched your search
+1
-1
@@ -2,4 +2,4 @@ mcversion=1.7.10
|
||||
forgeversion=10.13.4.1614-1.7.10
|
||||
version_major=4
|
||||
version_minor=2
|
||||
version_patch=25
|
||||
version_patch=26
|
||||
@@ -15,6 +15,8 @@ import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IJubilanceProvider;
|
||||
import forestry.core.utils.BlockUtil;
|
||||
import forestry.core.utils.InventoryUtil;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -52,7 +54,7 @@ public class JubilanceRequiresResource implements IJubilanceProvider {
|
||||
(TileEntity tile) -> (tile instanceof IBeeHousing)
|
||||
);
|
||||
|
||||
return blockRequired.equals(stk); //this way to prevent NPEs
|
||||
return InventoryUtil.isItemEqual(blockRequired, stk, true, true); //ffs dont compare itemsstacks with equal >_> and why tf didnt i got this until i debugged it? im getting old..
|
||||
}
|
||||
|
||||
}
|
||||
+3
-1
@@ -15,6 +15,8 @@ import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IGenome;
|
||||
import forestry.api.genetics.IMutationCondition;
|
||||
import forestry.core.utils.BlockUtil;
|
||||
import forestry.core.utils.InventoryUtil;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -51,7 +53,7 @@ public class MutationConditionRequiresResource implements IMutationCondition {
|
||||
(TileEntity tile) -> (tile instanceof IBeeHousing)
|
||||
);
|
||||
|
||||
return blockRequired.equals(stk) ? 1f : 0f;
|
||||
return InventoryUtil.isItemEqual(blockRequired, stk, true, true) ? 1 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -231,16 +231,14 @@ public abstract class BlockUtil {
|
||||
}
|
||||
|
||||
private static Class<? extends Block> BW_MetaGenerated_WerkstoffBlocksClass;
|
||||
private static Method getDamage;
|
||||
private static Block BWBlocks;
|
||||
private static boolean bw = Loader.isModLoaded("bartworks");
|
||||
static {
|
||||
if (bw)
|
||||
try {
|
||||
BW_MetaGenerated_WerkstoffBlocksClass = (Class<? extends Block>) Class.forName("com.github.bartimaeusnek.bartworks.system.material.BW_MetaGenerated_WerkstoffBlocks");
|
||||
getDamage = Class.forName("com.github.bartimaeusnek.bartworks.system.material.BW_MetaGenerated_Blocks").getMethod("getDamageValue", World.class, int.class, int.class, int.class);
|
||||
BWBlocks = (Block) Class.forName("com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader").getField("BWBlocks").get(null);
|
||||
} catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException | NoSuchMethodException e) {
|
||||
} catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -257,12 +255,7 @@ public abstract class BlockUtil {
|
||||
block = world.getBlock(x, y - depth, z);
|
||||
|
||||
if (bw && BW_MetaGenerated_WerkstoffBlocksClass.isInstance(block)) {
|
||||
try {
|
||||
return new ItemStack(BWBlocks, 1, (Integer) getDamage.invoke(block, world, x, y - depth, z));
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return new ItemStack(BWBlocks, 1, block.getDamageValue(world, x, y - depth, z));
|
||||
}
|
||||
|
||||
return new ItemStack(block, 1, world.getBlockMetadata(x, y - depth, z));
|
||||
|
||||
@@ -105,10 +105,7 @@ public abstract class InventoryUtil {
|
||||
if (a.getItemDamage() != b.getItemDamage()) {
|
||||
return false;
|
||||
}
|
||||
if (a.stackTagCompound != null && !a.stackTagCompound.equals(b.stackTagCompound)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return a.stackTagCompound == null || a.stackTagCompound.equals(b.stackTagCompound);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,9 +134,7 @@ public abstract class InventoryUtil {
|
||||
if (isWildcard(a) || isWildcard(b)) {
|
||||
return true;
|
||||
}
|
||||
if (a.getItemDamage() != b.getItemDamage()) {
|
||||
return false;
|
||||
}
|
||||
return a.getItemDamage() == b.getItemDamage();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -157,8 +157,8 @@ public abstract class ItemStackUtil {
|
||||
|
||||
int reqCount = 0;
|
||||
for (ItemStack offer : condensedOffered) {
|
||||
if (isCraftingEquivalent(req, offer, oreDictionary, craftingTools) && (matchTags ? ItemStack.areItemStackTagsEqual(req, offer) : true)) {
|
||||
int stackCount = (int) Math.floor(offer.stackSize / req.stackSize);
|
||||
if (isCraftingEquivalent(req, offer, oreDictionary, craftingTools) && (!matchTags || ItemStack.areItemStackTagsEqual(req, offer))) {
|
||||
int stackCount = (int) Math.floor( (float) offer.stackSize / (float) req.stackSize);
|
||||
reqCount = Math.max(reqCount, stackCount);
|
||||
}
|
||||
}
|
||||
@@ -316,7 +316,7 @@ public abstract class ItemStackUtil {
|
||||
public static ItemStack copyWithRandomSize(ItemStack template, int max, Random rand) {
|
||||
int size = rand.nextInt(max);
|
||||
ItemStack created = template.copy();
|
||||
created.stackSize = size <= 0 ? 1 : size > created.getMaxStackSize() ? created.getMaxStackSize() : size;
|
||||
created.stackSize = size <= 0 ? 1 : Math.min(size, created.getMaxStackSize());
|
||||
return created;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,9 +35,7 @@ public abstract class ModUtil {
|
||||
VersionRange versionRange = VersionParser.parseRange(versionRangeString);
|
||||
DefaultArtifactVersion requiredVersion = new DefaultArtifactVersion(modname, versionRange);
|
||||
|
||||
if (!requiredVersion.containsVersion(modVersion)) {
|
||||
return false;
|
||||
}
|
||||
return requiredVersion.containsVersion(modVersion);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -69,9 +67,7 @@ public abstract class ModUtil {
|
||||
DefaultArtifactVersion givenVersion = new DefaultArtifactVersion(apiName, apiVersionString);
|
||||
DefaultArtifactVersion requiredVersion = new DefaultArtifactVersion(apiName, versionRange);
|
||||
|
||||
if (!requiredVersion.containsVersion(givenVersion)) {
|
||||
return false;
|
||||
}
|
||||
return requiredVersion.containsVersion(givenVersion);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
Reference in new issue
Block a user