mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-15 09:34:57 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
95135544e2 | ||
|
|
e34b71c13e | ||
|
|
cc8bcf384a | ||
|
|
1f21952beb | ||
|
|
1ed4ced65f | ||
|
|
beb74e635d |
No files matched your search
+2
-2
@@ -40,7 +40,6 @@ targetCompatibility = 1.8
|
||||
minecraft {
|
||||
version = mcversion + "-" + forgeversion
|
||||
runDir = "run"
|
||||
useDepAts = true
|
||||
mappings = mcp_mappings
|
||||
|
||||
replace '@VERSION@', project.version
|
||||
@@ -66,7 +65,8 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
deobfCompile "mezz.jei:jei_${mcversion}:${jei_version}"
|
||||
deobfCompile "mezz.jei:jei_${mcversion}:${jei_version}:api"
|
||||
runtime "mezz.jei:jei_${mcversion}:${jei_version}"
|
||||
deobfCompile "net.industrial-craft:industrialcraft-2:${ic2_version}:api"
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
mcversion=1.10
|
||||
forgeversion=12.18.0.1981-1.10.0
|
||||
forgeversion=12.18.0.1984-1.10.0
|
||||
mcp_mappings=snapshot_20160525
|
||||
|
||||
jei_version=3.7.0.+
|
||||
@@ -7,4 +7,4 @@ ic2_version=2.5.5-ex19
|
||||
|
||||
version_major=5
|
||||
version_minor=1
|
||||
version_patch=0
|
||||
version_patch=2
|
||||
@@ -49,16 +49,9 @@ import forestry.plugins.PluginManager;
|
||||
name = "Forestry",
|
||||
version = Constants.VERSION,
|
||||
guiFactory = "forestry.core.config.ForestryGuiConfigFactory",
|
||||
dependencies = "required-after:Forge@[12.18.0.1981,);"
|
||||
+ "after:Buildcraft|Core@[7.2,);"
|
||||
+ "after:BuildCraft|Energy@[7.2,);"
|
||||
+ "after:ExtrabiomesXL;"
|
||||
+ "after:BiomesOPlenty;"
|
||||
+ "after:IC2@[2.3.235,);"
|
||||
+ "after:Natura@[2.2.0,);"
|
||||
+ "after:HardcoreEnderExpansion;"
|
||||
+ "after:JEI@[3.7.0,);"
|
||||
+ "after:basemetals;")
|
||||
acceptedMinecraftVersions = "[1.10]",
|
||||
dependencies = "required-after:Forge@[12.18.0.1984,);"
|
||||
+ "after:JEI@[3.7.0,);")
|
||||
public class Forestry {
|
||||
|
||||
@Mod.Instance(Constants.MOD_ID)
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.apiculture;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
||||
public interface IJubilanceFactory {
|
||||
/** The default Jubilance Provider is satisfied when the humidity and temperature are ideal for the bee. */
|
||||
IJubilanceProvider getDefault();
|
||||
|
||||
/** The Requires Resource Jubilance Provider is satisfied when a specific block is under the hive. */
|
||||
IJubilanceProvider getRequiresResource(Block block, int meta);
|
||||
IJubilanceProvider getRequiresResource(IBlockState... acceptedBlockStates);
|
||||
}
|
||||
@@ -5,13 +5,10 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.genetics;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
|
||||
/** Set custom mutation requirements */
|
||||
public interface IMutationBuilder {
|
||||
@@ -46,7 +43,7 @@ public interface IMutationBuilder {
|
||||
IMutationBuilder requireNight();
|
||||
|
||||
/** Require a specific resource to be under the location of the mutation */
|
||||
IMutationBuilder requireResource(IBlockState requiredBlockState);
|
||||
IMutationBuilder requireResource(IBlockState... acceptedBlockStates);
|
||||
|
||||
IMutationBuilder requireResource(String oreDictName);
|
||||
|
||||
|
||||
@@ -10,10 +10,9 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.genetics;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import forestry.api.apiculture.IJubilanceFactory;
|
||||
import forestry.api.apiculture.IJubilanceProvider;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
||||
public class JubilanceFactory implements IJubilanceFactory {
|
||||
@Override
|
||||
@@ -22,7 +21,7 @@ public class JubilanceFactory implements IJubilanceFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IJubilanceProvider getRequiresResource(Block block, int meta) {
|
||||
return new JubilanceRequiresResource(block, meta);
|
||||
public IJubilanceProvider getRequiresResource(IBlockState... acceptedBlockStates) {
|
||||
return new JubilanceRequiresResource(acceptedBlockStates);
|
||||
}
|
||||
}
|
||||
@@ -10,33 +10,40 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.genetics;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
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 net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class JubilanceRequiresResource implements IJubilanceProvider {
|
||||
|
||||
private final ItemStack blockRequired;
|
||||
private final Set<IBlockState> acceptedBlockStates = new HashSet<>();
|
||||
|
||||
public JubilanceRequiresResource(Block block, int meta) {
|
||||
this.blockRequired = new ItemStack(block, meta);
|
||||
public JubilanceRequiresResource(IBlockState... acceptedBlockStates) {
|
||||
Collections.addAll(this.acceptedBlockStates, acceptedBlockStates);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isJubilant(IAlleleBeeSpecies species, IBeeGenome genome, IBeeHousing housing) {
|
||||
World world = housing.getWorldObj();
|
||||
BlockPos housingCoords = housing.getCoordinates();
|
||||
BlockPos pos = housing.getCoordinates();
|
||||
|
||||
IBlockState state = world.getBlockState(housingCoords.down());
|
||||
return ItemStackUtil.equals(state, blockRequired);
|
||||
TileEntity tile;
|
||||
do {
|
||||
pos = pos.down();
|
||||
tile = world.getTileEntity(pos);
|
||||
} while (tile instanceof IBeeHousing && pos.getY() > 0);
|
||||
|
||||
IBlockState blockState = world.getBlockState(pos);
|
||||
return this.acceptedBlockStates.contains(blockState);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,13 +14,6 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.genetics.IAllele;
|
||||
@@ -29,6 +22,10 @@ import forestry.api.genetics.IGenome;
|
||||
import forestry.api.genetics.IMutation;
|
||||
import forestry.api.genetics.IMutationBuilder;
|
||||
import forestry.api.genetics.IMutationCondition;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
|
||||
public abstract class Mutation implements IMutation, IMutationBuilder {
|
||||
|
||||
@@ -109,14 +106,14 @@ public abstract class Mutation implements IMutation, IMutationBuilder {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mutation requireResource(IBlockState blockState) {
|
||||
IMutationCondition mutationCondition = new MutationConditionRequiresResource(blockState);
|
||||
public Mutation requireResource(IBlockState... acceptedBlockStates) {
|
||||
IMutationCondition mutationCondition = new MutationConditionRequiresResource(acceptedBlockStates);
|
||||
return addMutationCondition(mutationCondition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mutation requireResource(String oreName) {
|
||||
IMutationCondition mutationCondition = new MutationConditionRequiresResourceOreDict(oreName);
|
||||
IMutationCondition mutationCondition = new MutationConditionRequiresResource(oreName);
|
||||
return addMutationCondition(mutationCondition);
|
||||
}
|
||||
|
||||
|
||||
+37
-12
@@ -10,38 +10,63 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.genetics.mutations;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
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.Translator;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class MutationConditionRequiresResource implements IMutationCondition {
|
||||
|
||||
private final IBlockState requiredBlockState;
|
||||
private final Set<IBlockState> acceptedBlockStates = new HashSet<>();
|
||||
private final String displayName;
|
||||
|
||||
public MutationConditionRequiresResource(IBlockState requiredBlockState) {
|
||||
this.requiredBlockState = requiredBlockState;
|
||||
public MutationConditionRequiresResource(String oreDictName) {
|
||||
this.displayName = oreDictName;
|
||||
for (ItemStack ore : OreDictionary.getOres(oreDictName)) {
|
||||
if (ore != null) {
|
||||
Item oreItem = ore.getItem();
|
||||
if (oreItem != null) {
|
||||
Block oreBlock = Block.getBlockFromItem(oreItem);
|
||||
if (oreBlock != null) {
|
||||
this.acceptedBlockStates.addAll(oreBlock.getBlockState().getValidStates());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public MutationConditionRequiresResource(IBlockState... acceptedBlockStates) {
|
||||
Collections.addAll(this.acceptedBlockStates, acceptedBlockStates);
|
||||
this.displayName = acceptedBlockStates[0].getBlock().getLocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getChance(World world, BlockPos pos, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1) {
|
||||
IBlockState blockState;
|
||||
TileEntity tile;
|
||||
do {
|
||||
pos = pos.down();
|
||||
blockState = world.getBlockState(pos);
|
||||
} while (blockState.getBlock() instanceof IBeeHousing);
|
||||
tile = world.getTileEntity(pos);
|
||||
} while (tile instanceof IBeeHousing);
|
||||
|
||||
return this.requiredBlockState == blockState ? 1 : 0;
|
||||
IBlockState blockState = world.getBlockState(pos);
|
||||
return this.acceptedBlockStates.contains(blockState) ? 1 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return Translator.translateToLocalFormatted("for.mutation.condition.resource", requiredBlockState.getBlock().getLocalizedName());
|
||||
return Translator.translateToLocalFormatted("for.mutation.condition.resource", displayName);
|
||||
}
|
||||
}
|
||||
-71
@@ -1,71 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.genetics.mutations;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
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.Translator;
|
||||
|
||||
public class MutationConditionRequiresResourceOreDict implements IMutationCondition {
|
||||
|
||||
private final int oreDictId;
|
||||
private final String displayName;
|
||||
|
||||
public MutationConditionRequiresResourceOreDict(String oreDictName) {
|
||||
this.oreDictId = OreDictionary.getOreID(oreDictName);
|
||||
|
||||
List<ItemStack> ores = OreDictionary.getOres(oreDictName);
|
||||
if (ores != null && !ores.isEmpty()) {
|
||||
this.displayName = ores.get(0).getDisplayName();
|
||||
} else {
|
||||
this.displayName = oreDictName;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getChance(World world, BlockPos pos, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1) {
|
||||
Block block;
|
||||
int meta;
|
||||
int i = 1;
|
||||
do {
|
||||
BlockPos blockPos = new BlockPos(pos.getX(), pos.getY() - i, pos.getY());
|
||||
IBlockState blockState = world.getBlockState(blockPos);
|
||||
block = blockState.getBlock();
|
||||
meta = block.getMetaFromState(blockState);
|
||||
i++;
|
||||
} while (block instanceof IBeeHousing);
|
||||
|
||||
int[] oreIds = OreDictionary.getOreIDs(new ItemStack(block, 1, meta));
|
||||
for (int oreId : oreIds) {
|
||||
if (oreId == this.oreDictId) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return Translator.translateToLocalFormatted("for.mutation.condition.resource", displayName);
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ public class SlotWorking extends SlotForestry {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getHasStack() {
|
||||
public boolean canTakeStack(EntityPlayer stack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -423,9 +423,15 @@ public abstract class ItemStackUtil {
|
||||
}
|
||||
|
||||
public static ItemStack copyWithRandomSize(ItemStack template, int max, Random rand) {
|
||||
int size = rand.nextInt(max);
|
||||
int size = max <= 0 ? 0 : rand.nextInt(max);
|
||||
ItemStack created = template.copy();
|
||||
created.stackSize = size <= 0 ? 1 : size > created.getMaxStackSize() ? created.getMaxStackSize() : size;
|
||||
if (size <= 0) {
|
||||
created.stackSize = 1;
|
||||
} else if (size > created.getMaxStackSize()) {
|
||||
created.stackSize = created.getMaxStackSize();
|
||||
} else {
|
||||
created.stackSize = size;
|
||||
}
|
||||
return created;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user