mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-15 17:44:55 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d2a086ac02 | ||
|
|
859a79a824 | ||
|
|
00c31a6158 | ||
|
|
5db5b712ce | ||
|
|
9cac9a14df | ||
|
|
43f98e9cca | ||
|
|
ff4c09324b | ||
|
|
d1c17a13b1 | ||
|
|
8a8ac56266 | ||
|
|
208de8ad3a | ||
|
|
d988fb849d | ||
|
|
ab83d90dd3 | ||
|
|
79c5cff926 | ||
|
|
5522c33924 | ||
|
|
93aa429cf2 | ||
|
|
fa5c4c0218 | ||
|
|
32691c6af4 | ||
|
|
5615ffc518 | ||
|
|
2af41cf68d | ||
|
|
0cdaf8cff8 | ||
|
|
7b5eafc42a | ||
|
|
59ca1d2082 | ||
|
|
0df88973c0 | ||
|
|
e54bb5d4ea | ||
|
|
824f155804 | ||
|
|
24e2cf668e |
No files matched your search
@@ -1,6 +1,9 @@
|
||||
[submodule "lang"]
|
||||
path = lang
|
||||
url = https://github.com/ForestryMC/Forestry-Localization.git
|
||||
[submodule "api/redstoneflux"]
|
||||
path = api/redstoneflux
|
||||
url = https://github.com/Texasjake95/RedstoneFlux-API.git
|
||||
[submodule "api/forestry"]
|
||||
path = api/forestry
|
||||
url = https://github.com/ForestryMC/ForestryAPI.git
|
||||
Submodule
+1
Submodule api/redstoneflux added at b5771e4ef8.
@@ -257,3 +257,7 @@ def getBuildNumber() {
|
||||
return "$System.env.BUILD_NUMBER" != "null" ? "$System.env.BUILD_NUMBER" : "0"
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main { output.resourcesDir = output.classesDir }
|
||||
}
|
||||
|
||||
+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=19
|
||||
version_patch=27
|
||||
Vendored
BIN
Binary file not shown.
+2
-2
@@ -1,6 +1,6 @@
|
||||
#Wed Jul 02 15:54:47 CDT 2014
|
||||
#Sat Jan 04 01:52:14 CET 2020
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-bin.zip
|
||||
@@ -10,17 +10,19 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.genetics;
|
||||
|
||||
import forestry.api.apiculture.IAlleleBeeSpecies;
|
||||
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;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.apiculture.IAlleleBeeSpecies;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IJubilanceProvider;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
//import forestry.core.utils.ItemStackUtil;
|
||||
|
||||
public class JubilanceRequiresResource implements IJubilanceProvider {
|
||||
|
||||
@@ -34,6 +36,7 @@ public class JubilanceRequiresResource implements IJubilanceProvider {
|
||||
public boolean isJubilant(IAlleleBeeSpecies species, IBeeGenome genome, IBeeHousing housing) {
|
||||
World world = housing.getWorld();
|
||||
ChunkCoordinates housingCoords = housing.getCoordinates();
|
||||
/*
|
||||
Block block;
|
||||
TileEntity tile;
|
||||
int meta;
|
||||
@@ -46,6 +49,12 @@ public class JubilanceRequiresResource implements IJubilanceProvider {
|
||||
} while (tile instanceof IBeeHousing);
|
||||
|
||||
return ItemStackUtil.equals(block, meta, blockRequired);
|
||||
*/
|
||||
ItemStack stk = BlockUtil.getItemStackFromBlockBelow(world, housingCoords.posX, housingCoords.posY, housingCoords.posZ,
|
||||
(TileEntity tile) -> (tile instanceof IBeeHousing)
|
||||
);
|
||||
|
||||
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..
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import net.minecraft.world.gen.feature.WorldGenerator;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import forestry.api.arboriculture.EnumFruitFamily;
|
||||
@@ -458,7 +459,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
|
||||
|
||||
@Override
|
||||
protected void registerMutations() {
|
||||
// only available by rare villager trade
|
||||
registerMutation(Sequioa,Baobab,1).requireNight().restrictBiomeType(BiomeDictionary.Type.FOREST);
|
||||
}
|
||||
},
|
||||
Jungle(TreeBranchDefinition.TROPICAL, "jungle", "tectona", false, EnumLeafType.JUNGLE, new Color(4764952), new Color(0x658917), 3, new ItemStack(Blocks.log, 1, 3)) {
|
||||
|
||||
@@ -77,6 +77,12 @@ public class Config {
|
||||
// Performance
|
||||
public static boolean enableBackpackResupply = true;
|
||||
|
||||
// Optimization
|
||||
public static boolean enableCraftingTimeout = true;
|
||||
public static int craftingTimeout = 200; // Time given in ms
|
||||
public static boolean cacheWorktableRecipes = true;
|
||||
public static boolean promoteWorktableRecipesToFrontOfGlobalRecipemap = true;
|
||||
|
||||
// Customization
|
||||
private static boolean craftingBronzeEnabled = true;
|
||||
|
||||
@@ -215,6 +221,11 @@ public class Config {
|
||||
|
||||
enableBackpackResupply = configCommon.getBooleanLocalized("performance", "backpacks.resupply", enableBackpackResupply);
|
||||
|
||||
enableCraftingTimeout = configCommon.getBooleanLocalized("optimization","enable.crafting.timeout", enableCraftingTimeout);
|
||||
craftingTimeout = configCommon.getIntLocalized("optimization","crafting.timeout",craftingTimeout, 50, 2000 ); // min 50ms, default 200ms, max 2000 ms. Integer.MAX_VALUE is ~ 2100 ms because of multiplication by 1,000,000
|
||||
cacheWorktableRecipes = configCommon.getBooleanLocalized("optimization","cache.worktable.recipes", cacheWorktableRecipes);
|
||||
promoteWorktableRecipesToFrontOfGlobalRecipemap = configCommon.getBooleanLocalized("optimization","promote.worktable.recipes",promoteWorktableRecipesToFrontOfGlobalRecipemap);
|
||||
|
||||
// move legacy mail property
|
||||
configCommon.moveProperty("tweaks.gui", "mail.alert", "tweaks.gui.mail.alert");
|
||||
configCommon.renameProperty("tweaks.gui.mail.alert", "mail.alert", "enabled");
|
||||
|
||||
+16
-6
@@ -10,17 +10,20 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.genetics.mutations;
|
||||
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
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;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IGenome;
|
||||
import forestry.api.genetics.IMutationCondition;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.core.utils.StringUtil;
|
||||
//import forestry.core.utils.ItemStackUtil;
|
||||
|
||||
public class MutationConditionRequiresResource implements IMutationCondition {
|
||||
|
||||
@@ -32,6 +35,7 @@ public class MutationConditionRequiresResource implements IMutationCondition {
|
||||
|
||||
@Override
|
||||
public float getChance(World world, int x, int y, int z, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1) {
|
||||
/*
|
||||
Block block;
|
||||
TileEntity tile;
|
||||
int meta;
|
||||
@@ -44,6 +48,12 @@ public class MutationConditionRequiresResource implements IMutationCondition {
|
||||
} while (tile instanceof IBeeHousing);
|
||||
|
||||
return ItemStackUtil.equals(block, meta, blockRequired) ? 1 : 0;
|
||||
*/
|
||||
ItemStack stk = BlockUtil.getItemStackFromBlockBelow(world, x, y, z,
|
||||
(TileEntity tile) -> (tile instanceof IBeeHousing)
|
||||
);
|
||||
|
||||
return InventoryUtil.isItemEqual(blockRequired, stk, true, true) ? 1 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+18
-17
@@ -10,20 +10,18 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.genetics.mutations;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IGenome;
|
||||
import forestry.api.genetics.IMutationCondition;
|
||||
import forestry.core.utils.BlockUtil;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class MutationConditionRequiresResourceOreDict implements IMutationCondition {
|
||||
|
||||
@@ -43,6 +41,7 @@ public class MutationConditionRequiresResourceOreDict implements IMutationCondit
|
||||
|
||||
@Override
|
||||
public float getChance(World world, int x, int y, int z, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1) {
|
||||
/*
|
||||
Block block;
|
||||
int meta;
|
||||
TileEntity tile;
|
||||
@@ -53,18 +52,20 @@ public class MutationConditionRequiresResourceOreDict implements IMutationCondit
|
||||
tile = world.getTileEntity(x, y-i, z);
|
||||
i++;
|
||||
} while (tile instanceof IBeeHousing);
|
||||
|
||||
int[] oreIds = OreDictionary.getOreIDs(new ItemStack(block, 1, meta));
|
||||
for (int oreId : oreIds) {
|
||||
if (oreId == this.oreDictId) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
*/
|
||||
ItemStack stk = BlockUtil.getItemStackFromBlockBelow(world, x, y, z,
|
||||
(TileEntity tile) -> (tile instanceof IBeeHousing)
|
||||
);
|
||||
int[] oreIds = OreDictionary.getOreIDs(stk);
|
||||
for (int oreId : oreIds)
|
||||
if (oreId == this.oreDictId)
|
||||
return 1f;
|
||||
return 0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return StringUtil.localizeAndFormat("mutation.condition.resource", displayName);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,13 +30,14 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
import forestry.api.recipes.IDescriptiveRecipe;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.fluids.Fluids;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.factory.inventory.InventoryCraftingForestry;
|
||||
|
||||
public abstract class RecipeUtil {
|
||||
|
||||
static List<Object> cachedRecipes = new ArrayList<Object>();
|
||||
public static void addFermenterRecipes(ItemStack resource, int fermentationValue, Fluids output) {
|
||||
if (RecipeManagers.fermenterManager == null) {
|
||||
return;
|
||||
@@ -99,7 +100,6 @@ public abstract class RecipeUtil {
|
||||
if (ItemStackUtil.containsSets(recipeItems, availableItems, true, true) == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Check that it doesn't make a different recipe.
|
||||
// For example:
|
||||
// Wood Logs are all ore dictionary equivalent with each other,
|
||||
@@ -140,7 +140,6 @@ public abstract class RecipeUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<ItemStack> outputs = findMatchingRecipes(crafting, world);
|
||||
if (!ItemStackUtil.containsItemStack(outputs, recipeOutput)) {
|
||||
return null;
|
||||
@@ -155,7 +154,29 @@ public abstract class RecipeUtil {
|
||||
}
|
||||
|
||||
List<ItemStack> matchingRecipes = new ArrayList<>();
|
||||
List<Integer> matchingIndex=new ArrayList();
|
||||
List<Object> matchingRecipeMap = new ArrayList();
|
||||
int index = 0;
|
||||
|
||||
if(Config.cacheWorktableRecipes) {
|
||||
// Check across the whole cached recipe map
|
||||
// Add each recipe to the matchingRecipes list
|
||||
for (Object recipe : cachedRecipes) {
|
||||
IRecipe irecipe = (IRecipe) recipe;
|
||||
|
||||
if (irecipe.matches(inventory, world)) {
|
||||
ItemStack result = irecipe.getCraftingResult(inventory);
|
||||
if (!ItemStackUtil.containsItemStack(matchingRecipes, result)) {
|
||||
matchingRecipes.add(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
if( matchingRecipes.size() > 0 ) {
|
||||
// If we found recipes here, we found all the potential recipes, so we can just return immediately.
|
||||
return matchingRecipes;
|
||||
}
|
||||
}
|
||||
// Only do this if there were no cached recipes hit
|
||||
for (Object recipe : CraftingManager.getInstance().getRecipeList()) {
|
||||
IRecipe irecipe = (IRecipe) recipe;
|
||||
|
||||
@@ -163,10 +184,39 @@ public abstract class RecipeUtil {
|
||||
ItemStack result = irecipe.getCraftingResult(inventory);
|
||||
if (!ItemStackUtil.containsItemStack(matchingRecipes, result)) {
|
||||
matchingRecipes.add(result);
|
||||
if(Config.promoteWorktableRecipesToFrontOfGlobalRecipemap || Config.cacheWorktableRecipes) {
|
||||
// Add to the back of the list. That way when we cycle through the list
|
||||
// moving items to the front, the index locations for the following items doesn't change
|
||||
matchingRecipeMap.add(recipe);
|
||||
matchingIndex.add(new Integer(index));
|
||||
}
|
||||
}
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
if (matchingRecipeMap.size() > 0 )
|
||||
{
|
||||
if (Config.promoteWorktableRecipesToFrontOfGlobalRecipemap) {
|
||||
// Only move the recipes if the last one was beyond 500 in the recipeMap (in GTNH about 57k recipes)
|
||||
if (matchingIndex.get(matchingIndex.size()-1) > 500) {
|
||||
List recipeMap = CraftingManager.getInstance().getRecipeList();
|
||||
// System.out.println( "Highest recipe found at " + matchingIndex.get(matchingIndex.size()-1) + ", moving " + matchingIndex.size() + " to front" );
|
||||
// System.out.println( "Size of recipe map " + recipeMap.size() );
|
||||
for (index = 0; index < matchingIndex.size(); index++) { // index is reused here, it goes through the matching groups.
|
||||
// Remove recipe and add back at the front
|
||||
int target = matchingIndex.get(index); // remove requires int
|
||||
// System.out.println("Removing recipe at " + target);
|
||||
recipeMap.remove(target);
|
||||
recipeMap.add(0,matchingRecipeMap.get(index));
|
||||
}
|
||||
}
|
||||
}
|
||||
if(Config.cacheWorktableRecipes) {
|
||||
// However, we should always add found recipes the cached recipe map
|
||||
// Location doesn't matter since we have to scan the whole cached recipe map anyways.
|
||||
cachedRecipes.addAll(matchingRecipeMap);
|
||||
}
|
||||
}
|
||||
return matchingRecipes;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,8 +10,12 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import cofh.api.energy.IEnergyConnection;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.tiles.TileEngine;
|
||||
import forestry.core.utils.vect.Vect;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockCocoa;
|
||||
import net.minecraft.block.BlockLog;
|
||||
@@ -22,16 +26,13 @@ import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.tiles.TileEngine;
|
||||
import forestry.core.utils.vect.Vect;
|
||||
|
||||
import cofh.api.energy.IEnergyConnection;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public abstract class BlockUtil {
|
||||
|
||||
@@ -228,4 +229,35 @@ public abstract class BlockUtil {
|
||||
private static boolean isVecInsideXYBounds(Vec3 vec, float minX, float minY, float maxX, float maxY) {
|
||||
return vec != null && (vec.xCoord >= minX && vec.xCoord <= maxX && vec.yCoord >= minY && vec.yCoord <= maxY);
|
||||
}
|
||||
}
|
||||
|
||||
private static Class<? extends Block> BW_MetaGenerated_WerkstoffBlocksClass;
|
||||
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");
|
||||
BWBlocks = (Block) Class.forName("com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader").getField("BWBlocks").get(null);
|
||||
} catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack getItemStackFromBlockBelow(World world, int x, int y, int z, Predicate<TileEntity> stillInside) {
|
||||
TileEntity tile;
|
||||
Block block;
|
||||
int depth = 0;
|
||||
|
||||
do {
|
||||
++depth;
|
||||
tile = world.getTileEntity(x, y - depth, z);
|
||||
} while (stillInside.test(tile));
|
||||
block = world.getBlock(x, y - depth, z);
|
||||
|
||||
if (bw && BW_MetaGenerated_WerkstoffBlocksClass.isInstance(block)) {
|
||||
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;
|
||||
|
||||
@@ -265,6 +265,7 @@ public abstract class SlotUtil {
|
||||
// if mergeOnly = true, don't shift into empty slots.
|
||||
private static boolean shiftToMachineInventory(List inventorySlots, ItemStack stackToShift, int numSlots, boolean mergeOnly) {
|
||||
for (int machineIndex = playerInventorySize; machineIndex < numSlots; machineIndex++) {
|
||||
// System.out.println("SlotUtil::shiftToMachineinventory");
|
||||
Slot slot = (Slot) inventorySlots.get(machineIndex);
|
||||
if (mergeOnly && slot.getStack() == null) {
|
||||
continue;
|
||||
|
||||
@@ -21,6 +21,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
|
||||
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.inventory.InventoryAdapterTile;
|
||||
import forestry.core.inventory.wrappers.InventoryMapper;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
@@ -41,7 +42,9 @@ public class TileWorktable extends TileBase implements ICrafterWorktable {
|
||||
private final RecipeMemory recipeMemory;
|
||||
private final InventoryAdapterTile craftingDisplay;
|
||||
private MemorizedRecipe currentRecipe;
|
||||
|
||||
private long savedTick = 0;
|
||||
private long savedSystemTimeExpiration = 0;
|
||||
|
||||
public TileWorktable() {
|
||||
super("worktable");
|
||||
setInternalInventory(new InventoryWorktable(this));
|
||||
@@ -121,10 +124,27 @@ public class TileWorktable extends TileBase implements ICrafterWorktable {
|
||||
return false;
|
||||
}
|
||||
|
||||
if( Config.enableCraftingTimeout ) {
|
||||
long currentTick = worldObj.getTotalWorldTime();
|
||||
if (currentTick == savedTick){
|
||||
// Processing in the same tick, second call, check expiration timer
|
||||
long currentTime = System.nanoTime();
|
||||
if(currentTime > savedSystemTimeExpiration) {
|
||||
// Time to craft has expired, stop crafting loop
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// New tick has arrived, so reset timer data
|
||||
savedTick=currentTick;
|
||||
savedSystemTimeExpiration = System.nanoTime() + Config.craftingTimeout * 1000000;
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack[] recipeItems = InventoryUtil.getStacks(currentRecipe.getCraftMatrix());
|
||||
ItemStack[] inventory = InventoryUtil.getStacks(this);
|
||||
InventoryCraftingForestry crafting = RecipeUtil.getCraftRecipe(recipeItems, inventory, worldObj, currentRecipe.getRecipeOutput());
|
||||
return crafting != null;
|
||||
|
||||
return crafting != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -147,7 +167,6 @@ public class TileWorktable extends TileBase implements ICrafterWorktable {
|
||||
if (removed == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// update crafting display to match the ingredients that were actually used
|
||||
setCraftingDisplay(crafting);
|
||||
return true;
|
||||
|
||||
@@ -28,7 +28,7 @@ public class ButterflySpawner implements ILeafTickHandler {
|
||||
if (world.rand.nextFloat() >= tree.getGenome().getSappiness() * tree.getGenome().getYield()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
IButterfly spawn = ButterflyManager.butterflyRoot.getIndividualTemplates().get(world.rand.nextInt(ButterflyManager.butterflyRoot.getIndividualTemplates().size()));
|
||||
if (world.rand.nextFloat() >= spawn.getGenome().getPrimary().getRarity() * 0.5f) {
|
||||
return false;
|
||||
|
||||
@@ -23,6 +23,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
@@ -69,6 +70,7 @@ public class EntityButterfly extends EntityCreature implements IEntityButterfly
|
||||
public static final int EXHAUSTION_REST = 1000;
|
||||
public static final int EXHAUSTION_CONSUMPTION = 100 * EXHAUSTION_REST;
|
||||
public static final int MAX_LIFESPAN = 24000 * 7; // one minecraft week in ticks
|
||||
private int maximumHomeDistance = 64;
|
||||
|
||||
private Vec3 flightTarget;
|
||||
private int exhaustion;
|
||||
@@ -89,10 +91,11 @@ public class EntityButterfly extends EntityCreature implements IEntityButterfly
|
||||
setDefaults();
|
||||
}
|
||||
|
||||
public EntityButterfly(World world, IButterfly butterfly) {
|
||||
public EntityButterfly(World world, IButterfly butterfly, int x, int y, int z) {
|
||||
super(world);
|
||||
setDefaults();
|
||||
setIndividual(butterfly);
|
||||
setHomeArea(x, y, z, maximumHomeDistance);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -124,7 +127,9 @@ public class EntityButterfly extends EntityCreature implements IEntityButterfly
|
||||
super.writeEntityToNBT(nbttagcompound);
|
||||
|
||||
NBTTagCompound bio = new NBTTagCompound();
|
||||
contained.writeToNBT(bio);
|
||||
if (contained != null)
|
||||
contained.writeToNBT(bio);
|
||||
|
||||
nbttagcompound.setTag("BTFLY", bio);
|
||||
|
||||
if (pollen != null) {
|
||||
@@ -194,6 +199,13 @@ public class EntityButterfly extends EntityCreature implements IEntityButterfly
|
||||
@Override
|
||||
public float getBlockPathWeight(int x, int y, int z) {
|
||||
float weight = 0.0f;
|
||||
final ChunkCoordinates home = getHomePosition();
|
||||
double distanceToHome = home.getDistanceSquared(x, y, z);
|
||||
|
||||
if(!isWithinHomeDistanceFromPosition(distanceToHome)){
|
||||
|
||||
weight -= 7.5f + 0.005 * (distanceToHome / 4);
|
||||
}
|
||||
|
||||
if (!getButterfly().isAcceptedEnvironment(worldObj, x, y, z)) {
|
||||
weight -= 15.0f;
|
||||
@@ -232,6 +244,10 @@ public class EntityButterfly extends EntityCreature implements IEntityButterfly
|
||||
return weight;
|
||||
}
|
||||
|
||||
private boolean isWithinHomeDistanceFromPosition(double distanceToHome) {
|
||||
return distanceToHome < (maximumHomeDistance * maximumHomeDistance);
|
||||
}
|
||||
|
||||
private int getFluidDepth(int x, int z) {
|
||||
Chunk chunk = worldObj.getChunkFromBlockCoords(x, z);
|
||||
int xx = x & 15;
|
||||
|
||||
@@ -149,7 +149,7 @@ public class ButterflyHelper extends SpeciesRoot implements IButterflyRoot {
|
||||
|
||||
@Override
|
||||
public EntityButterfly spawnButterflyInWorld(World world, IButterfly butterfly, double x, double y, double z) {
|
||||
return EntityUtil.spawnEntity(world, new EntityButterfly(world, butterfly), x, y, z);
|
||||
return EntityUtil.spawnEntity(world, new EntityButterfly(world, butterfly, (int)x, (int)y, (int)z), x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -133,7 +133,7 @@ public class ItemButterflyGE extends ItemGE {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (EntityUtil.spawnEntity(entityItem.worldObj, new EntityButterfly(entityItem.worldObj, butterfly), entityItem.posX, entityItem.posY, entityItem.posZ) != null) {
|
||||
if (EntityUtil.spawnEntity(entityItem.worldObj, new EntityButterfly(entityItem.worldObj, butterfly, (int)entityItem.posX, (int)entityItem.posY, (int)entityItem.posZ), entityItem.posX, entityItem.posY, entityItem.posZ) != null) {
|
||||
if (entityItem.getEntityItem().stackSize > 1) {
|
||||
entityItem.getEntityItem().stackSize--;
|
||||
} else {
|
||||
|
||||
@@ -81,7 +81,7 @@ public class RenderButterflyItem implements IItemRenderer {
|
||||
}
|
||||
|
||||
if (entity == null) {
|
||||
entity = new EntityButterfly(Proxies.common.getRenderWorld(), butterfly);
|
||||
entity = new EntityButterfly(Proxies.common.getRenderWorld(), butterfly, 0, 0, 0);
|
||||
} else {
|
||||
entity.setIndividual(butterfly);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user