Compare commits

...
16 Commits
Author SHA1 Message Date
mezz 40c4fc5d1f Update for Minecraft 1.10 2016-06-23 02:19:36 -07:00
mezz 645dba903d Improve the look of cherry tree leaf generation 2016-06-22 21:14:38 -07:00
mezz 1ac4acdb47 Fix ebony trees growing offcenter from their saplings 2016-06-22 21:13:52 -07:00
mezz 74aa33e80c Remove all the saplings when a large tree grows 2016-06-22 21:13:35 -07:00
mezz 6f6b45abcf Add EnderIO compat for ice coolant and ethanol fuel 2016-06-22 19:00:05 -07:00
mezz 7297a6a5d3 Add ExtraUtils2 EnderLily compat for the farm 2016-06-22 18:40:07 -07:00
mezz 5ef76cffca Fix invalid recipes warning when BoP plugin is enabled 2016-06-22 16:19:40 -07:00
mezz 9284f84645 Fix pipette filling bug 2016-06-22 16:18:55 -07:00
mezz 85ba33e1ff Add trapdoorWood oredict name 2016-06-20 23:11:44 -07:00
mezz 9f5f5e7812 Fix network sync of item floating over Escritoire 2016-06-19 23:03:02 -07:00
mezz 8617c4a79f Properly center the item floating over the escritoire 2016-06-19 22:18:31 -07:00
mezz e9809238de Fix #1325 Null Pointer Exception from broken mailbox 2016-06-18 16:14:13 -07:00
mezz c0a22f4a28 Split mutationCustom into mutationBuilder and Mutation
Remove EntityBee
Update MutationConditionRequiresResource to use blockState
2016-06-17 15:20:19 -07:00
mezz 41c6fb15b3 Make escritoire convert vanilla saplings for analysis 2016-06-17 15:17:43 -07:00
mezz b5d65e83f0 Render floating sapling over Escritoire when in use 2016-06-17 15:17:43 -07:00
mezz 1a7c148a7e Update JEI 2016-06-16 18:55:53 -07:00
72 changed files with 556 additions and 511 deletions

No files matched your search

+5 -5
View File
@@ -1,10 +1,10 @@
mcversion=1.9.4
forgeversion=12.17.0.1957
mcversion=1.10
forgeversion=12.18.0.1981-1.10.0
mcp_mappings=snapshot_20160525
jei_version=3.6.0.+
jei_version=3.7.0.+
ic2_version=2.5.5-ex19
version_major=5
version_minor=0
version_patch=16
version_minor=1
version_patch=0
+2 -2
View File
@@ -1,6 +1,6 @@
#Mon Sep 14 12:28:28 PDT 2015
#Tue Jun 21 15:23:47 PDT 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.7-all.zip
+2 -2
View File
@@ -49,7 +49,7 @@ import forestry.plugins.PluginManager;
name = "Forestry",
version = Constants.VERSION,
guiFactory = "forestry.core.config.ForestryGuiConfigFactory",
dependencies = "required-after:Forge@[12.17.0.1949,);"
dependencies = "required-after:Forge@[12.18.0.1981,);"
+ "after:Buildcraft|Core@[7.2,);"
+ "after:BuildCraft|Energy@[7.2,);"
+ "after:ExtrabiomesXL;"
@@ -57,7 +57,7 @@ import forestry.plugins.PluginManager;
+ "after:IC2@[2.3.235,);"
+ "after:Natura@[2.2.0,);"
+ "after:HardcoreEnderExpansion;"
+ "after:JEI@[3.6.0,);"
+ "after:JEI@[3.7.0,);"
+ "after:basemetals;")
public class Forestry {
@@ -50,12 +50,4 @@ public interface IAlleleBeeSpecies extends IAlleleSpecies {
@SideOnly(Side.CLIENT)
void registerModels(Item item, IModelManager manager);
/**
* @deprecated since Forestry 3.6.
* @return Path of the texture to use for entity rendering.
*/
@Deprecated
String getEntityTexture();
}
@@ -5,8 +5,9 @@
******************************************************************************/
package forestry.api.apiculture;
import forestry.api.genetics.IMutationCustom;
public interface IBeeMutationCustom extends IBeeMutation, IMutationCustom {
import forestry.api.genetics.IMutationBuilder;
public interface IBeeMutationBuilder extends IMutationBuilder {
@Override
IBeeMutation build();
}
@@ -11,7 +11,7 @@ public interface IBeeMutationFactory {
/**
* Creates a new bee mutation.
* Automatically registered with BeeManager.beeRoot.registerMutation()
* See IBeeMutationCustom and IMutationCustom for adding additional properties to the returned mutation.
* See IBeeMutationBuilder and IMutationBuilder for adding additional properties to the returned mutation.
*
* @param parentBee0 A parent bee for this mutation
* @param parentBee1 A parent bee for this mutation
@@ -19,5 +19,5 @@ public interface IBeeMutationFactory {
* @param chance The chance that breeding the two parent bees will result in this mutation
* @return a new bee mutation.
*/
IBeeMutationCustom createMutation(IAlleleBeeSpecies parentBee0, IAlleleBeeSpecies parentBee1, IAllele[] result, int chance);
IBeeMutationBuilder createMutation(IAlleleBeeSpecies parentBee0, IAlleleBeeSpecies parentBee1, IAllele[] result, int chance);
}
@@ -84,7 +84,7 @@ public interface ITree extends IIndividual, ITreeGenData {
* @return Integer denoting the size of the tree trunk.
*/
@Override
int getGirth(World world, BlockPos pos);
int getGirth();
/**
* @return Growth conditions at the given position.
@@ -5,8 +5,9 @@
******************************************************************************/
package forestry.api.arboriculture;
import forestry.api.genetics.IMutationCustom;
public interface ITreeMutationCustom extends ITreeMutation, IMutationCustom {
import forestry.api.genetics.IMutationBuilder;
public interface ITreeMutationBuilder extends IMutationBuilder {
@Override
ITreeMutation build();
}
@@ -11,7 +11,7 @@ public interface ITreeMutationFactory {
/**
* Creates a new tree mutation.
* Automatically registered with TreeManager.treeRoot.registerMutation()
* See ITreeMutationCustom and IMutationCustom for adding additional properties to the returned mutation.
* See ITreeMutationBuilder and IMutationBuilder for adding additional properties to the returned mutation.
*
* @param parentTree0 A parent tree for this mutation
* @param parentTree1 A parent tree for this mutation
@@ -19,5 +19,5 @@ public interface ITreeMutationFactory {
* @param chance The chance that breeding the two parent trees will result in this mutation
* @return a new tree mutation.
*/
ITreeMutationCustom createMutation(IAlleleTreeSpecies parentTree0, IAlleleTreeSpecies parentTree1, IAllele[] result, int chance);
ITreeMutationBuilder createMutation(IAlleleTreeSpecies parentTree0, IAlleleTreeSpecies parentTree1, IAllele[] result, int chance);
}
@@ -6,6 +6,7 @@
package forestry.api.genetics;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraftforge.common.BiomeDictionary;
@@ -13,40 +14,42 @@ import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
/** Set custom mutation requirements */
public interface IMutationCustom extends IMutation {
public interface IMutationBuilder {
IMutation build();
/** Prevent this mutation from being shown in the analyzers */
IMutationCustom setIsSecret();
IMutationBuilder setIsSecret();
/** Require a specific temperature for this mutation to occur */
IMutationCustom restrictTemperature(EnumTemperature temperature);
IMutationBuilder restrictTemperature(EnumTemperature temperature);
IMutationCustom restrictTemperature(EnumTemperature minTemperature, EnumTemperature maxTemperature);
IMutationBuilder restrictTemperature(EnumTemperature minTemperature, EnumTemperature maxTemperature);
/** Require a specific humidity for this mutation to occur */
IMutationCustom restrictHumidity(EnumHumidity humidity);
IMutationBuilder restrictHumidity(EnumHumidity humidity);
IMutationCustom restrictHumidity(EnumHumidity minHumidity, EnumHumidity maxHumidity);
IMutationBuilder restrictHumidity(EnumHumidity minHumidity, EnumHumidity maxHumidity);
/**
* Restrict this mutation to certain types of biomes.
* @param types The types of biomes this mutation can occur.
*/
IMutationCustom restrictBiomeType(BiomeDictionary.Type... types);
IMutationBuilder restrictBiomeType(BiomeDictionary.Type... types);
/** Restrict the days of the year that this mutation can occur */
IMutationCustom restrictDateRange(int startMonth, int startDay, int endMonth, int endDay);
IMutationBuilder restrictDateRange(int startMonth, int startDay, int endMonth, int endDay);
/** Restrict the time of day that this mutation can occur */
IMutationCustom requireDay();
IMutationBuilder requireDay();
IMutationCustom requireNight();
IMutationBuilder requireNight();
/** Require a specific resource to be under the location of the mutation */
IMutationCustom requireResource(Block block, int meta);
IMutationBuilder requireResource(IBlockState requiredBlockState);
IMutationCustom requireResource(String oreDictName);
IMutationBuilder requireResource(String oreDictName);
/** Require some other custom mutation condition */
IMutationCustom addMutationCondition(IMutationCondition mutationCondition);
IMutationBuilder addMutationCondition(IMutationCondition mutationCondition);
}
@@ -5,8 +5,9 @@
******************************************************************************/
package forestry.api.lepidopterology;
import forestry.api.genetics.IMutationCustom;
public interface IButterflyMutationCustom extends IButterflyMutation, IMutationCustom {
import forestry.api.genetics.IMutationBuilder;
public interface IButterflyMutationBuilder extends IMutationBuilder {
@Override
IButterflyMutation build();
}
@@ -11,7 +11,7 @@ public interface IButterflyMutationFactory {
/**
* Creates a new butterfly mutation.
* Automatically registered with ButterflyManager.butterflyRoot.registerMutation()
* See IButterflyMutationCustom and IMutationCustom for adding additional properties to the returned mutation.
* See IButterflyMutationBuilder and IMutationBuilder for adding additional properties to the returned mutation.
*
* @param parentButterfly0 A parent butterfly for this mutation
* @param parentButterfly1 A parent butterfly for this mutation
@@ -19,5 +19,5 @@ public interface IButterflyMutationFactory {
* @param chance The chance that breeding the two parent butterfly's will result in this mutation
* @return a new butterfly mutation.
*/
IButterflyMutationCustom createMutation(IAlleleButterflySpecies parentButterfly0, IAlleleButterflySpecies parentButterfly1, IAllele[] result, int chance);
IButterflyMutationBuilder createMutation(IAlleleButterflySpecies parentButterfly0, IAlleleButterflySpecies parentButterfly1, IAllele[] result, int chance);
}
@@ -17,9 +17,5 @@ public interface IMailAddress extends INbtWritable {
boolean isValid();
boolean isPlayer();
boolean isTrader();
GameProfile getPlayerProfile();
}
@@ -5,6 +5,7 @@
******************************************************************************/
package forestry.api.mail;
import javax.annotation.Nonnull;
import java.util.Map;
import net.minecraft.item.ItemStack;
@@ -18,9 +19,10 @@ public interface IPostRegistry {
IPostOffice getPostOffice(World world);
/* MAIL ADDRESSES */
IMailAddress getMailAddress(GameProfile gameProfile);
IMailAddress getMailAddress(String traderName);
@Nonnull
IMailAddress getMailAddress(@Nonnull GameProfile gameProfile);
IMailAddress getMailAddress(@Nonnull String traderName);
/* LETTERS */
boolean isLetter(ItemStack itemstack);
@@ -18,7 +18,7 @@ import forestry.api.arboriculture.ITreeGenome;
public interface ITreeGenData {
int getGirth(World world, BlockPos pos);
int getGirth();
float getHeightModifier();
@@ -6,7 +6,6 @@ import java.util.Arrays;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import forestry.api.genetics.IAlleleSpecies;
import forestry.apiculture.PluginApiculture;
@@ -14,7 +13,7 @@ import forestry.apiculture.genetics.BeeGenome;
import mezz.jei.api.BlankModPlugin;
import mezz.jei.api.IModRegistry;
import mezz.jei.api.INbtRegistry;
import mezz.jei.api.ISubtypeRegistry;
import mezz.jei.api.JEIPlugin;
@JEIPlugin
@@ -40,19 +39,19 @@ public class ApicultureJeiPlugin extends BlankModPlugin {
registry.addDescription(new ItemStack(PluginApiculture.items.scoop), "for.jei.description.scoop");
INbtRegistry nbtRegistry = registry.getJeiHelpers().getNbtRegistry();
nbtRegistry.registerNbtInterpreter(PluginApiculture.items.beeDroneGE, BeeNbtInterpreter.INSTANCE);
nbtRegistry.registerNbtInterpreter(PluginApiculture.items.beePrincessGE, BeeNbtInterpreter.INSTANCE);
nbtRegistry.registerNbtInterpreter(PluginApiculture.items.beeQueenGE, BeeNbtInterpreter.INSTANCE);
ISubtypeRegistry subtypeRegistry = registry.getJeiHelpers().getSubtypeRegistry();
subtypeRegistry.registerNbtInterpreter(PluginApiculture.items.beeDroneGE, BeeSubtypeInterpreter.INSTANCE);
subtypeRegistry.registerNbtInterpreter(PluginApiculture.items.beePrincessGE, BeeSubtypeInterpreter.INSTANCE);
subtypeRegistry.registerNbtInterpreter(PluginApiculture.items.beeQueenGE, BeeSubtypeInterpreter.INSTANCE);
}
private static class BeeNbtInterpreter implements INbtRegistry.INbtInterpreter {
public static BeeNbtInterpreter INSTANCE = new BeeNbtInterpreter();
private static class BeeSubtypeInterpreter implements ISubtypeRegistry.ISubtypeInterpreter {
public static BeeSubtypeInterpreter INSTANCE = new BeeSubtypeInterpreter();
@Nullable
@Override
public String getSubtypeInfoFromNbt(@Nonnull NBTTagCompound nbtTagCompound) {
IAlleleSpecies species = BeeGenome.getSpeciesDirectly(nbtTagCompound);
public String getSubtypeInfo(@Nonnull ItemStack itemStack) {
IAlleleSpecies species = BeeGenome.getSpeciesDirectly(itemStack);
return species == null ? null : species.getUID();
}
}
@@ -66,7 +66,7 @@ public class AIAvoidPlayers extends EntityAIBase {
}
path = pathNavigator.getPathToXYZ(randomTarget.xCoord, randomTarget.yCoord, randomTarget.zCoord);
return path != null && path.isDestinationSame(randomTarget);
return path != null;
}
@Override
@@ -1,94 +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.apiculture.entities;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.passive.IAnimals;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBee;
import forestry.core.config.Constants;
import forestry.core.render.ForestryResource;
public class EntityBee extends EntityCreature implements IAnimals {
private static final String DEFAULT_TEXTURE = Constants.TEXTURE_PATH_ENTITIES + "/bees/honeyBee.png";
private IBee contained;
private IAlleleBeeSpecies species;
private EnumBeeType type = EnumBeeType.DRONE;
private String beeTexture = DEFAULT_TEXTURE;
private long lastUpdate;
public EntityBee(World world) {
super(world);
}
private void resetAppearance() {
beeTexture = species.getEntityTexture();
}
public EntityBee setIndividual(IBee bee) {
if (bee != null) {
contained = bee;
} else {
contained = BeeManager.beeRoot.templateAsIndividual(BeeManager.beeRoot.getDefaultTemplate());
}
//isImmuneToFire = contained.getGenome().getFireResist();
setSpecies(contained.getGenome().getPrimary());
//dataWatcher.updateObject(DATAWATCHER_ID_SPECIES, species.getUID());
//dataWatcher.updateObject(DATAWATCHER_ID_SCALE, (int)(contained.getSize() * 100));
return this;
}
public IBee getBee() {
return contained;
}
public EntityBee setType(EnumBeeType type) {
this.type = type;
return this;
}
public EnumBeeType getType() {
return type;
}
public EntityBee setSpecies(IAlleleBeeSpecies species) {
this.species = species;
resetAppearance();
lastUpdate = worldObj.getTotalWorldTime();
return this;
}
@SideOnly(Side.CLIENT)
private ResourceLocation textureResource;
private long lastTextureUpdate;
@SideOnly(Side.CLIENT)
public ResourceLocation getTexture() {
if (textureResource == null || lastTextureUpdate != lastUpdate) {
textureResource = new ForestryResource(beeTexture);
}
return textureResource;
}
}
@@ -29,7 +29,7 @@ import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IAlleleBeeSpeciesBuilder;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeMutationCustom;
import forestry.api.apiculture.IBeeMutationBuilder;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.genetics.IAllele;
@@ -1035,7 +1035,7 @@ public enum BeeDefinition implements IBeeDefinition {
BeeManager.beeRoot.registerTemplate(template);
}
protected final IBeeMutationCustom registerMutation(BeeDefinition parent1, BeeDefinition parent2, int chance) {
protected final IBeeMutationBuilder registerMutation(BeeDefinition parent1, BeeDefinition parent2, int chance) {
return BeeManager.beeMutationFactory.createMutation(parent1.species, parent2.species, getTemplate(), chance);
}
@@ -18,17 +18,23 @@ import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeeModifier;
import forestry.api.apiculture.IBeeMutationCustom;
import forestry.api.apiculture.IBeeMutation;
import forestry.api.apiculture.IBeeMutationBuilder;
import forestry.api.apiculture.IBeeRoot;
import forestry.api.genetics.IAllele;
import forestry.core.genetics.mutations.Mutation;
public class BeeMutation extends Mutation implements IBeeMutationCustom {
public class BeeMutation extends Mutation implements IBeeMutation, IBeeMutationBuilder {
public BeeMutation(IAlleleBeeSpecies bee0, IAlleleBeeSpecies bee1, IAllele[] result, int chance) {
super(bee0, bee1, result, chance);
}
@Override
public IBeeMutation build() {
return this;
}
@Override
public IBeeRoot getRoot() {
return BeeManager.beeRoot;
@@ -12,16 +12,16 @@ package forestry.apiculture.genetics;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBeeMutationCustom;
import forestry.api.apiculture.IBeeMutationBuilder;
import forestry.api.apiculture.IBeeMutationFactory;
import forestry.api.genetics.IAllele;
public class BeeMutationFactory implements IBeeMutationFactory {
@Override
public IBeeMutationCustom createMutation(IAlleleBeeSpecies parentBee0, IAlleleBeeSpecies parentBee1, IAllele[] result, int chance) {
IBeeMutationCustom mutation = new BeeMutation(parentBee0, parentBee1, result, chance);
BeeManager.beeRoot.registerMutation(mutation);
return mutation;
public IBeeMutationBuilder createMutation(IAlleleBeeSpecies parentBee0, IAlleleBeeSpecies parentBee1, IAllele[] result, int chance) {
BeeMutation beeMutation = new BeeMutation(parentBee0, parentBee1, result, chance);
BeeManager.beeRoot.registerMutation(beeMutation);
return beeMutation;
}
}
@@ -195,9 +195,4 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
public int getSpriteColour(int renderPass) {
return beeSpriteColourProvider.getSpriteColour(renderPass);
}
@Override
public String getEntityTexture() {
return null;
}
}
@@ -1,44 +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.apiculture.render;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.util.ResourceLocation;
import forestry.apiculture.entities.EntityBee;
import forestry.core.proxy.Proxies;
public class RenderBeeEntity extends RenderLiving {
private final ModelBee beeModel;
public RenderBeeEntity() {
super(Proxies.common.getClientInstance().getRenderManager(), new ModelBee(), 0.15f);
beeModel = (ModelBee) mainModel;
}
private void renderBee(EntityBee entity, double posX, double posY, double posZ, float par8, float par9) {
beeModel.setType(entity.getType());
this.doRender(entity, posX, posY, posZ, par8, par9);
}
@Override
public void doRender(EntityLiving entity, double x, double y, double z, float entityYaw, float partialTicks) {
renderBee((EntityBee) entity, x, y, z, entityYaw, partialTicks);
}
@Override
protected ResourceLocation getEntityTexture(Entity entity) {
return ((EntityBee) entity).getTexture();
}
}
@@ -69,7 +69,6 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
private static final Random random = new Random();
private int averageGroundLevel = -1;
private boolean isInDesert = false;
private IBlockState planks;
private IBlockState slabs;
private IBlockState logs;
@@ -86,8 +85,6 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
public VillageApiaristHouse(StructureVillagePieces.Start startPiece, int componentType, Random random, StructureBoundingBox boundingBox, EnumFacing facing) {
super(startPiece, componentType, random, boundingBox, facing);
isInDesert = startPiece.inDesert;
createBuildingBlocks(random);
}
@@ -280,7 +277,7 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
private void buildGarden(World world, StructureBoundingBox box) {
Block ground = Blocks.DIRT;
if (isInDesert) {
if (field_189928_h == 1) { // desert
ground = Blocks.SAND;
}
@@ -293,7 +290,7 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
private void plantFlowerGarden(World world, StructureBoundingBox box, int minX, int minY, int minZ, int maxX, int maxY, int maxZ) {
if (isInDesert) {
if (field_189928_h == 1) { // desert
setBlockState(world, Blocks.CACTUS.getDefaultState(), 4, 1, 7, box);
return;
}
@@ -203,7 +203,7 @@ public class Tree extends Individual implements ITree, IPlantable {
}
@Override
public int getGirth(World world, BlockPos pos) {
public int getGirth() {
return genome.getGirth();
}
@@ -39,7 +39,7 @@ import forestry.api.arboriculture.ILeafSpriteProvider;
import forestry.api.arboriculture.ITree;
import forestry.api.arboriculture.ITreeGenerator;
import forestry.api.arboriculture.ITreeGenome;
import forestry.api.arboriculture.ITreeMutationCustom;
import forestry.api.arboriculture.ITreeMutationBuilder;
import forestry.api.arboriculture.IWoodProvider;
import forestry.api.arboriculture.IWoodType;
import forestry.api.arboriculture.TreeManager;
@@ -1056,7 +1056,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
TreeManager.treeRoot.registerTemplate(template);
}
protected final ITreeMutationCustom registerMutation(TreeDefinition parent1, TreeDefinition parent2, int chance) {
protected final ITreeMutationBuilder registerMutation(TreeDefinition parent1, TreeDefinition parent2, int chance) {
return TreeManager.treeMutationFactory.createMutation(parent1.species, parent2.species, getTemplate(), chance);
}
@@ -15,18 +15,24 @@ import net.minecraft.world.World;
import forestry.api.arboriculture.IAlleleTreeSpecies;
import forestry.api.arboriculture.ITreeGenome;
import forestry.api.arboriculture.ITreeMutationCustom;
import forestry.api.arboriculture.ITreeMutation;
import forestry.api.arboriculture.ITreeMutationBuilder;
import forestry.api.arboriculture.ITreeRoot;
import forestry.api.arboriculture.TreeManager;
import forestry.api.genetics.IAllele;
import forestry.core.genetics.mutations.Mutation;
public class TreeMutation extends Mutation implements ITreeMutationCustom {
public class TreeMutation extends Mutation implements ITreeMutation, ITreeMutationBuilder {
public TreeMutation(IAlleleTreeSpecies allele0, IAlleleTreeSpecies allele1, IAllele[] template, int chance) {
super(allele0, allele1, template, chance);
}
@Override
public ITreeMutation build() {
return this;
}
@Override
public ITreeRoot getRoot() {
return TreeManager.treeRoot;
@@ -11,7 +11,7 @@
package forestry.arboriculture.genetics;
import forestry.api.arboriculture.IAlleleTreeSpecies;
import forestry.api.arboriculture.ITreeMutationCustom;
import forestry.api.arboriculture.ITreeMutationBuilder;
import forestry.api.arboriculture.ITreeMutationFactory;
import forestry.api.arboriculture.TreeManager;
import forestry.api.genetics.IAllele;
@@ -19,9 +19,9 @@ import forestry.api.genetics.IAllele;
public class TreeMutationFactory implements ITreeMutationFactory {
@Override
public ITreeMutationCustom createMutation(IAlleleTreeSpecies parent0, IAlleleTreeSpecies parent1, IAllele[] result, int chance) {
ITreeMutationCustom mutation = new TreeMutation(parent0, parent1, result, chance);
TreeManager.treeRoot.registerMutation(mutation);
return mutation;
public ITreeMutationBuilder createMutation(IAlleleTreeSpecies parent0, IAlleleTreeSpecies parent1, IAllele[] result, int chance) {
TreeMutation treeMutation = new TreeMutation(parent0, parent1, result, chance);
TreeManager.treeRoot.registerMutation(treeMutation);
return treeMutation;
}
}
@@ -130,7 +130,7 @@ public abstract class TileTreeContainer extends TileEntity implements IStreamabl
}
@Override
public void setOwner(@Nullable GameProfile owner) {
public void setOwner(@Nonnull GameProfile owner) {
this.owner = owner;
}
@@ -18,6 +18,7 @@ import java.util.List;
import java.util.Random;
import java.util.Set;
import forestry.arboriculture.blocks.BlockSapling;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@@ -61,6 +62,7 @@ public abstract class WorldGenArboriculture extends WorldGenBase {
}
if (genPos != null) {
clearSaplings(world, genPos);
List<BlockPos> branchEnds = new ArrayList<>(generateTrunk(world, rand, wood, genPos));
Collections.sort(branchEnds, TopDownBlockPosComparator.INSTANCE);
generateLeaves(world, rand, leaf, branchEnds, genPos);
@@ -96,6 +98,18 @@ public abstract class WorldGenArboriculture extends WorldGenBase {
@Nullable
public abstract BlockPos getValidGrowthPos(World world, BlockPos pos);
public void clearSaplings(World world, BlockPos genPos) {
int treeGirth = tree.getGirth();
for (int x = 0; x < treeGirth; x++) {
for (int z = 0; z < treeGirth; z++) {
BlockPos saplingPos = genPos.add(x, 0, z);
if (world.getBlockState(saplingPos).getBlock() instanceof BlockSapling) {
world.setBlockToAir(saplingPos);
}
}
}
}
public boolean hasPods() {
return tree.allowsFruitBlocks();
}
@@ -47,12 +47,13 @@ public class WorldGenCherry extends WorldGenTree {
@Override
protected void generateLeaves(World world, Random rand, TreeBlockTypeLeaf leaf, List<BlockPos> branchEnds, BlockPos startPos) {
int leafSpawn = height + 1;
int leafSpawn = height + 2;
WorldGenHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.add(0, leafSpawn--, 0), girth, girth, 1, WorldGenHelper.EnumReplaceMode.SOFT);
WorldGenHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.add(0, leafSpawn, 0), girth, (float) 1 + girth, 1, WorldGenHelper.EnumReplaceMode.SOFT);
WorldGenHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.add(0, leafSpawn, 0), girth, 1 + girth, 1, WorldGenHelper.EnumReplaceMode.SOFT);
for (BlockPos branchEnd : branchEnds) {
WorldGenHelper.generateCircle(world, rand, branchEnd, 4, 3, 2, leaf, 1.0f, WorldGenHelper.EnumReplaceMode.AIR);
WorldGenHelper.generateCircle(world, rand, branchEnd.up(), 3, 3, 1, leaf, 1.0f, WorldGenHelper.EnumReplaceMode.AIR);
WorldGenHelper.generateCircle(world, rand, branchEnd, 4, 3, 1, leaf, 1.0f, WorldGenHelper.EnumReplaceMode.AIR);
}
}
}
@@ -31,11 +31,10 @@ public class WorldGenEbony extends WorldGenTree {
@Nonnull
@Override
public Set<BlockPos> generateTrunk(World world, Random rand, TreeBlockTypeLog wood, BlockPos startPos) {
int offset = (girth - 1) / 2;
int trunksGenerated = 0;
for (int x = -offset; x < -offset + girth; x++) {
for (int z = -offset; z < -offset + girth; z++) {
for (int x = 0; x < girth; x++) {
for (int z = 0; z < girth; z++) {
if (rand.nextFloat() < 0.6f) {
for (int y = 0; y < height; y++) {
WorldGenHelper.addBlock(world, startPos.add(x, y, z), wood, WorldGenHelper.EnumReplaceMode.ALL);
@@ -68,8 +67,8 @@ public class WorldGenEbony extends WorldGenTree {
h = height / 2 + rand.nextInt(height / 2);
}
int x_off = -girth + rand.nextInt(2 * girth);
int y_off = -girth + rand.nextInt(2 * girth);
int x_off = rand.nextInt(girth);
int y_off = rand.nextInt(girth);
BlockPos center = startPos.add(x_off, h, y_off);
int radius = 1 + rand.nextInt(girth);
@@ -74,7 +74,7 @@ public abstract class WorldGenTree extends WorldGenArboriculture {
public final void preGenerate(World world, Random rand, BlockPos startPos) {
super.preGenerate(world, rand, startPos);
height = determineHeight(world, rand, baseHeight, heightVariation);
girth = tree.getGirth(world, startPos);
girth = tree.getGirth();
}
protected int modifyByHeight(World world, int val, int min, int max) {
@@ -10,6 +10,7 @@
******************************************************************************/
package forestry.core.access;
import javax.annotation.Nonnull;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -100,7 +101,7 @@ public final class AccessHandler implements IAccessHandler {
}
@Override
public void setOwner(GameProfile owner) {
public void setOwner(@Nonnull GameProfile owner) {
this.owner = owner;
for (IAccessOwnerListener listener : accessOwnerListeners) {
listener.onOwnerSet(owner);
@@ -10,6 +10,7 @@
******************************************************************************/
package forestry.core.access;
import javax.annotation.Nonnull;
import java.io.IOException;
import net.minecraft.entity.player.EntityPlayer;
@@ -90,7 +91,7 @@ public class FakeAccessHandler implements IAccessHandler {
}
@Override
public void setOwner(GameProfile owner) {
public void setOwner(@Nonnull GameProfile owner) {
}
@@ -10,6 +10,9 @@
******************************************************************************/
package forestry.core.access;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraft.entity.player.EntityPlayer;
import com.mojang.authlib.GameProfile;
@@ -17,10 +20,11 @@ import com.mojang.authlib.GameProfile;
public interface IOwnable {
boolean isOwned();
@Nullable
GameProfile getOwner();
void setOwner(GameProfile owner);
void setOwner(@Nonnull GameProfile owner);
boolean isOwner(EntityPlayer player);
@@ -69,5 +69,6 @@ public class BlockRegistryCore extends BlockRegistry {
// register some common oreDict names for our recipes
OreDictionary.registerOre(OreDictUtil.CRAFTING_TABLE_WOOD, Blocks.CRAFTING_TABLE);
OreDictionary.registerOre(OreDictUtil.TRAPDOOR_WOOD, Blocks.TRAPDOOR);
}
}
@@ -15,6 +15,7 @@ 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;
@@ -25,10 +26,11 @@ import forestry.api.core.EnumTemperature;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IAlleleSpecies;
import forestry.api.genetics.IGenome;
import forestry.api.genetics.IMutation;
import forestry.api.genetics.IMutationBuilder;
import forestry.api.genetics.IMutationCondition;
import forestry.api.genetics.IMutationCustom;
public abstract class Mutation implements IMutationCustom {
public abstract class Mutation implements IMutation, IMutationBuilder {
private final int chance;
@@ -107,8 +109,8 @@ public abstract class Mutation implements IMutationCustom {
}
@Override
public Mutation requireResource(Block block, int meta) {
IMutationCondition mutationCondition = new MutationConditionRequiresResource(block, meta);
public Mutation requireResource(IBlockState blockState) {
IMutationCondition mutationCondition = new MutationConditionRequiresResource(blockState);
return addMutationCondition(mutationCondition);
}
@@ -10,9 +10,7 @@
******************************************************************************/
package forestry.core.genetics.mutations;
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;
@@ -25,30 +23,25 @@ import forestry.core.utils.Translator;
public class MutationConditionRequiresResource implements IMutationCondition {
private final ItemStack blockRequired;
private final IBlockState requiredBlockState;
public MutationConditionRequiresResource(Block block, int meta) {
blockRequired = new ItemStack(block, 1, meta);
public MutationConditionRequiresResource(IBlockState requiredBlockState) {
this.requiredBlockState = requiredBlockState;
}
@Override
public float getChance(World world, BlockPos pos, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1) {
Block block;
int meta;
int i = 1;
IBlockState blockState;
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);
pos = pos.down();
blockState = world.getBlockState(pos);
} while (blockState.getBlock() instanceof IBeeHousing);
return ItemStackUtil.equals(block, meta, blockRequired) ? 1 : 0;
return this.requiredBlockState == blockState ? 1 : 0;
}
@Override
public String getDescription() {
return Translator.translateToLocalFormatted("for.mutation.condition.resource", blockRequired.getDisplayName());
return Translator.translateToLocalFormatted("for.mutation.condition.resource", requiredBlockState.getBlock().getLocalizedName());
}
}
@@ -42,7 +42,7 @@ public class InventoryEscritoire extends InventoryAdapterTile<TileEscritoire> {
}
if (slotIndex == SLOT_ANALYZE) {
return AlleleManager.alleleRegistry.isIndividual(itemStack);
return AlleleManager.alleleRegistry.isIndividual(itemStack) || GeneticsUtil.getGeneticEquivalent(itemStack) != null;
}
return false;
@@ -75,17 +75,16 @@ public class InventoryEscritoire extends InventoryAdapterTile<TileEscritoire> {
@Override
public void setInventorySlotContents(int slotIndex, ItemStack itemstack) {
super.setInventorySlotContents(slotIndex, itemstack);
if (tile.getWorld() == null) {
return;
}
if (slotIndex == SLOT_ANALYZE && !tile.getWorld().isRemote) {
if (slotIndex == SLOT_ANALYZE) {
if (!AlleleManager.alleleRegistry.isIndividual(getStackInSlot(SLOT_ANALYZE)) && getStackInSlot(SLOT_ANALYZE) != null) {
ItemStack ersatz = GeneticsUtil.convertToGeneticEquivalent(getStackInSlot(SLOT_ANALYZE));
if (ersatz != null) {
setInventorySlotContents(SLOT_ANALYZE, ersatz);
super.setInventorySlotContents(SLOT_ANALYZE, ersatz);
}
}
tile.getGame().initialize(getStackInSlot(SLOT_ANALYZE));
if (tile.getWorld() != null && !tile.getWorld().isRemote) {
tile.getGame().initialize(getStackInSlot(SLOT_ANALYZE));
}
}
}
}
@@ -59,7 +59,6 @@ public class ItemPipette extends ItemForestry implements IToolPipette, IFluidCon
}
contained = new PipetteContents(new FluidStack(liquid, filled));
filled = liquid.amount;
} else {
if (contained.getContents().amount >= limit) {
return 0;
@@ -141,7 +140,7 @@ public class ItemPipette extends ItemForestry implements IToolPipette, IFluidCon
contained.getContents().amount -= drained;
if (contained.getContents().amount <= 0) {
pipette.setTagCompound(null);
pipette.setTagCompound(new NBTTagCompound());
pipette.setItemDamage(0);
} else {
NBTTagCompound nbttagcompound = new NBTTagCompound();
@@ -10,6 +10,7 @@
******************************************************************************/
package forestry.core.network.packets;
import javax.annotation.Nullable;
import java.io.IOException;
import net.minecraft.entity.player.EntityPlayer;
@@ -30,8 +31,8 @@ public class PacketItemStackDisplay extends PacketCoordinates implements IForest
public PacketItemStackDisplay() {
}
public <T extends TileForestry & IItemStackDisplay> PacketItemStackDisplay(T tile, ItemStack itemStack) {
public <T extends TileForestry & IItemStackDisplay> PacketItemStackDisplay(T tile, @Nullable ItemStack itemStack) {
super(tile);
this.itemStack = itemStack;
}
@@ -6,8 +6,9 @@ import forestry.core.utils.Translator;
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.recipe.BlankRecipeCategory;
import mezz.jei.api.recipe.IRecipeWrapper;
public abstract class ForestryRecipeCategory extends BlankRecipeCategory {
public abstract class ForestryRecipeCategory<T extends IRecipeWrapper> extends BlankRecipeCategory<T> {
@Nonnull
private final IDrawable background;
@Nonnull
@@ -1,72 +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.recipes.jei;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidBlock;
import net.minecraftforge.fluids.IFluidContainerItem;
public class JEIUtils {
public static List<ItemStack> getItemVariations(ItemStack base) {
List<ItemStack> variations = new ArrayList<>();
base.getItem().getSubItems(base.getItem(), null, variations);
Iterator<ItemStack> itr = variations.iterator();
ItemStack stack;
while (itr.hasNext()) {
stack = itr.next();
if (!base.isItemEqual(stack) || !stack.hasTagCompound()) {
itr.remove();
}
}
if (variations.isEmpty()) {
return Collections.singletonList(base);
}
return variations;
}
public static FluidStack getFluidStack(ItemStack stack) {
if (stack != null) {
FluidStack fluidStack = null;
if (stack.getItem() instanceof IFluidContainerItem) {
fluidStack = ((IFluidContainerItem) stack.getItem()).getFluid(stack);
}
if (fluidStack == null) {
fluidStack = FluidContainerRegistry.getFluidForFilledItem(stack);
}
if (fluidStack == null && Block.getBlockFromItem(stack.getItem()) instanceof IFluidBlock) {
Fluid fluid = ((IFluidBlock) Block.getBlockFromItem(stack.getItem())).getFluid();
if (fluid != null) {
fluidStack = new FluidStack(fluid, Fluid.BUCKET_VOLUME);
}
}
return fluidStack;
}
return null;
}
public static boolean areFluidsSameType(FluidStack fluidStack1, FluidStack fluidStack2) {
if (fluidStack1 == null || fluidStack2 == null) {
return false;
}
return fluidStack1.getFluid() == fluidStack2.getFluid();
}
}
@@ -10,16 +10,20 @@
******************************************************************************/
package forestry.core.render;
import javax.annotation.Nullable;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import forestry.core.blocks.BlockBase;
import forestry.core.config.Constants;
import forestry.core.inventory.InventoryEscritoire;
import forestry.core.models.ModelEscritoire;
import forestry.core.proxy.Proxies;
import forestry.core.tiles.TileEscritoire;
@@ -27,77 +31,79 @@ import forestry.core.tiles.TileEscritoire;
public class RenderEscritoire extends TileEntitySpecialRenderer<TileEscritoire> {
private static final ResourceLocation texture = new ForestryResource(Constants.TEXTURE_PATH_BLOCKS + "/escritoire.png");
private final ModelEscritoire modelEscritoire;
public RenderEscritoire() {
modelEscritoire = new ModelEscritoire();
}
private final ModelEscritoire modelEscritoire = new ModelEscritoire();
private final EntityItem dummyEntityItem = new EntityItem(null);
private long lastTick;
/**
* @param escritoire If it null its render the item else it render the tile entity.
*/
@Override
public void renderTileEntityAt(TileEscritoire escritoire, double x, double y, double z, float partialTicks, int destroyStage) {
public void renderTileEntityAt(@Nullable TileEscritoire escritoire, double x, double y, double z, float partialTicks, int destroyStage) {
if (escritoire != null) {
IBlockState blockState = escritoire.getWorldObj().getBlockState(escritoire.getPos());
World world = escritoire.getWorldObj();
IBlockState blockState = world.getBlockState(escritoire.getPos());
if (blockState != null && blockState.getBlock() instanceof BlockBase) {
EnumFacing facing = blockState.getValue(BlockBase.FACING);
render(escritoire.getStackInSlot(InventoryEscritoire.SLOT_ANALYZE), facing, x, y, z);
render(escritoire.getIndividualOnDisplay(), world, facing, x, y, z);
return;
}
}
render(null, EnumFacing.SOUTH, x, y, z);
render(null, null, EnumFacing.SOUTH, x, y, z);
}
private void render(ItemStack itemstack, EnumFacing orientation, double x, double y, double z) {
private void render(@Nullable ItemStack itemstack, @Nullable World world, EnumFacing orientation, double x, double y, double z) {
float factor = (float) (1.0 / 16.0);
GlStateManager.pushMatrix();
GlStateManager.translate((float) x + 0.5f, (float) y + 0.875f, (float) z + 0.5f);
float[] angle = {(float) Math.PI, 0, 0};
if (orientation == null) {
orientation = EnumFacing.WEST;
{
GlStateManager.translate((float) x + 0.5f, (float) y + 0.875f, (float) z + 0.5f);
float[] angle = {(float) Math.PI, 0, 0};
if (orientation == null) {
orientation = EnumFacing.WEST;
}
switch (orientation) {
case EAST:
angle[1] = (float) Math.PI / 2;
break;
case SOUTH:
break;
case NORTH:
angle[1] = (float) Math.PI;
break;
case WEST:
default:
angle[1] = -(float) Math.PI / 2;
break;
}
Proxies.render.bindTexture(texture);
modelEscritoire.render(null, angle[0], angle[1], angle[2], 0f, 0f, factor);
}
switch (orientation) {
case EAST:
angle[1] = (float) Math.PI / 2;
break;
case SOUTH:
break;
case NORTH:
angle[1] = (float) Math.PI;
break;
case WEST:
default:
angle[1] = -(float) Math.PI / 2;
break;
}
Proxies.render.bindTexture(texture);
modelEscritoire.render(null, angle[0], angle[1], angle[2], 0f, 0f, factor);
GlStateManager.popMatrix();
/*
if(itemstack != null) {
float renderScale = 1.0f;
if (itemstack != null && world != null) {
dummyEntityItem.worldObj = world;
float renderScale = 0.75f;
GlStateManager.pushMatrix();
GlStateManager.translate((float) x, (float) y, (float) z);
GlStateManager.translate(0.6f, 0.8f, 0.5f);
GlStateManager.rotate(90.0f, 1.0F, 0.0F, 0.0F);
GlStateManager.scale(renderScale, renderScale, renderScale);
RenderItem.renderInFrame = true;
dummyEntityItem.setEntityItemStack(itemstack);
customRenderItem.doRenderItem(dummyEntityItem, 0, 0, 0, 0, 0);
RenderItem.renderInFrame = false;
{
GlStateManager.translate((float) x + 0.5f, (float) y + 0.6f, (float) z + 0.5f);
GlStateManager.scale(renderScale, renderScale, renderScale);
dummyEntityItem.setEntityItemStack(itemstack);
if (world.getTotalWorldTime() != lastTick) {
lastTick = world.getTotalWorldTime();
dummyEntityItem.onUpdate();
}
RenderManager rendermanager = Proxies.common.getClientInstance().getRenderManager();
rendermanager.doRenderEntity(dummyEntityItem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F, false);
}
GlStateManager.popMatrix();
}
*/
}
}
@@ -25,16 +25,20 @@ import forestry.api.genetics.IAlleleSpecies;
import forestry.api.genetics.IIndividual;
import forestry.core.gui.ContainerEscritoire;
import forestry.core.gui.GuiEscritoire;
import forestry.core.inventory.InventoryAnalyzer;
import forestry.core.inventory.InventoryEscritoire;
import forestry.core.inventory.watchers.ISlotPickupWatcher;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.IStreamableGui;
import forestry.core.network.packets.PacketItemStackDisplay;
import forestry.core.proxy.Proxies;
import forestry.core.utils.InventoryUtil;
public class TileEscritoire extends TileBase implements ISidedInventory, ISlotPickupWatcher, IStreamableGui {
public class TileEscritoire extends TileBase implements ISidedInventory, ISlotPickupWatcher, IStreamableGui, IItemStackDisplay {
private final EscritoireGame game = new EscritoireGame();
private ItemStack individualOnDisplayClient;
public TileEscritoire() {
super("escritoire");
@@ -116,15 +120,39 @@ public class TileEscritoire extends TileBase implements ISidedInventory, ISlotPi
public void readGuiData(DataInputStreamForestry data) throws IOException {
game.readData(data);
}
@Override
public void writeData(DataOutputStreamForestry data) throws IOException {
super.writeData(data);
ItemStack displayStack = getIndividualOnDisplay();
data.writeItemStack(displayStack);
}
@Override
public void readData(DataInputStreamForestry data) throws IOException {
super.readData(data);
individualOnDisplayClient = data.readItemStack();
}
/* ISlotPickupWatcher */
@Override
public void onPickupFromSlot(int slotIndex, EntityPlayer player) {
if (slotIndex == InventoryEscritoire.SLOT_ANALYZE) {
game.reset();
PacketItemStackDisplay packet = new PacketItemStackDisplay(this, getIndividualOnDisplay());
Proxies.net.sendNetworkPacket(packet, worldObj);
}
}
@Override
public void setInventorySlotContents(int slotIndex, ItemStack itemstack) {
super.setInventorySlotContents(slotIndex, itemstack);
if (slotIndex == InventoryEscritoire.SLOT_ANALYZE) {
PacketItemStackDisplay packet = new PacketItemStackDisplay(this, getIndividualOnDisplay());
Proxies.net.sendNetworkPacket(packet, worldObj);
}
}
@Override
public Object getGui(EntityPlayer player, int data) {
return new GuiEscritoire(player, this);
@@ -134,4 +162,19 @@ public class TileEscritoire extends TileBase implements ISidedInventory, ISlotPi
public Object getContainer(EntityPlayer player, int data) {
return new ContainerEscritoire(player, this);
}
@Override
public void handleItemStackForDisplay(ItemStack itemStack) {
if (!ItemStack.areItemStacksEqual(itemStack, individualOnDisplayClient)) {
individualOnDisplayClient = itemStack;
worldObj.markBlockRangeForRenderUpdate(getPos(), getPos());
}
}
public ItemStack getIndividualOnDisplay() {
if (worldObj.isRemote) {
return individualOnDisplayClient;
}
return getStackInSlot(InventoryAnalyzer.SLOT_ANALYZE);
}
}
@@ -14,11 +14,17 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
import cofh.api.energy.IEnergyConnection;
import cofh.api.energy.IEnergyReceiver;
import forestry.core.network.packets.PacketFXSignal;
import forestry.core.proxy.Proxies;
import forestry.core.tiles.TileEngine;
import net.minecraft.block.Block;
import net.minecraft.block.BlockHorizontal;
import net.minecraft.block.BlockOldLog;
import net.minecraft.block.BlockPlanks;
import net.minecraft.block.BlockStaticLiquid;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
@@ -31,16 +37,8 @@ import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;
import forestry.core.network.packets.PacketFXSignal;
import forestry.core.proxy.Proxies;
import forestry.core.tiles.TileEngine;
import cofh.api.energy.IEnergyConnection;
import cofh.api.energy.IEnergyReceiver;
public abstract class BlockUtil {
private static final int slabWoodId = OreDictionary.getOreID("slabWood");
@@ -343,4 +341,17 @@ public abstract class BlockUtil {
}
return false;
}
@Nullable
public static <T extends Comparable<T>> IProperty<T> getProperty(Block block, String propertyName, Class<T> valueClass) {
for (IProperty<?> property : block.getDefaultState().getPropertyNames()) {
if (property.getName().equals(propertyName)) {
if (property.getValueClass().isAssignableFrom(valueClass)) {
//noinspection unchecked
return (IProperty<T>) property;
}
}
}
return null;
}
}
@@ -34,6 +34,7 @@ public class OreDictUtil {
public static final String FENCE_GATE_WOOD = "fenceGateWood";
public static final String STAIR_WOOD = "stairWood";
public static final String DOOR_WOOD = "doorWood";
public static final String TRAPDOOR_WOOD = "trapdoorWood";
public static final String TREE_LEAVES = "treeLeaves";
public static final String EMPTIED_LETTER_ORE_DICT = "emptiedLetter";
@@ -29,6 +29,10 @@ public class FermenterRecipe implements IFermenterRecipe {
if (resource == null) {
throw new NullPointerException("Fermenter Resource cannot be null!");
}
if (resource.getItem() == null) {
throw new NullPointerException("Fermenter Resource item cannot be null!");
}
if (output == null) {
throw new NullPointerException("Fermenter Output cannot be null!");
@@ -92,7 +92,7 @@ public class FactoryJeiPlugin extends BlankModPlugin {
registry.addRecipes(CarpenterRecipeMaker.getCarpenterRecipes());
registry.addRecipes(CentrifugeRecipeMaker.getCentrifugeRecipe());
registry.addRecipes(FabricatorRecipeMaker.getFabricatorRecipes());
registry.addRecipes(FermenterRecipeMaker.getFermenterRecipes());
registry.addRecipes(FermenterRecipeMaker.getFermenterRecipes(jeiHelpers.getStackHelper()));
registry.addRecipes(MoistenerRecipeMaker.getMoistenerRecipes());
registry.addRecipes(RainmakerRecipeMaker.getRecipes());
registry.addRecipes(SqueezerRecipeMaker.getSqueezerRecipes());
@@ -6,19 +6,17 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
import forestry.factory.gui.ContainerWorktable;
import forestry.factory.inventory.InventoryCraftingForestry;
import forestry.factory.recipes.MemorizedRecipe;
import mezz.jei.api.gui.IGuiIngredient;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
import mezz.jei.api.recipe.transfer.IRecipeTransferError;
import mezz.jei.api.recipe.transfer.IRecipeTransferHandler;
import mezz.jei.gui.ingredients.IGuiIngredient;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
class WorktableRecipeTransferHandler implements IRecipeTransferHandler {
@Override
@@ -23,7 +23,7 @@ import mezz.jei.api.gui.IGuiItemStackGroup;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.recipe.IRecipeWrapper;
public class FermenterRecipeCategory extends ForestryRecipeCategory {
public class FermenterRecipeCategory extends ForestryRecipeCategory<FermenterRecipeWrapper> {
private static final int resourceSlot = 0;
private static final int fuelSlot = 1;
@@ -62,7 +62,7 @@ public class FermenterRecipeCategory extends ForestryRecipeCategory {
}
@Override
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) {
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull FermenterRecipeWrapper recipeWrapper) {
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks();
@@ -72,18 +72,15 @@ public class FermenterRecipeCategory extends ForestryRecipeCategory {
guiFluidStacks.init(inputTank, true, 1, 1, 16, 58, 3000, false, tankOverlay);
guiFluidStacks.init(outputTank, false, 91, 1, 16, 58, 3000, false, tankOverlay);
FermenterRecipeWrapper wrapper = (FermenterRecipeWrapper) recipeWrapper;
guiItemStacks.set(resourceSlot, wrapper.getFermentable());
guiItemStacks.set(resourceSlot, recipeWrapper.getFermentable());
List<ItemStack> fuels = new ArrayList<>();
for (FermenterFuel fuel : FuelManager.fermenterFuel.values()) {
fuels.add(fuel.item);
}
guiItemStacks.set(fuelSlot, fuels);
guiFluidStacks.set(inputTank, wrapper.getFluidInputs());
guiFluidStacks.set(outputTank, wrapper.getFluidOutputs());
guiFluidStacks.set(inputTank, recipeWrapper.getFluidInputs());
guiFluidStacks.set(outputTank, recipeWrapper.getFluidOutputs());
}
}
@@ -8,22 +8,29 @@ import net.minecraft.item.ItemStack;
import forestry.api.recipes.IFermenterRecipe;
import forestry.api.recipes.IVariableFermentable;
import forestry.api.recipes.RecipeManagers;
import forestry.core.recipes.jei.JEIUtils;
import forestry.core.utils.Log;
import forestry.factory.recipes.jei.FactoryJeiPlugin;
import mezz.jei.api.recipe.IStackHelper;
public class FermenterRecipeMaker {
private FermenterRecipeMaker() {
}
public static List<FermenterRecipeWrapper> getFermenterRecipes() {
public static List<FermenterRecipeWrapper> getFermenterRecipes(IStackHelper stackHelper) {
List<FermenterRecipeWrapper> recipes = new ArrayList<>();
for (IFermenterRecipe recipe : RecipeManagers.fermenterManager.recipes()) {
if (recipe.getResource() != null && recipe.getResource().getItem() instanceof IVariableFermentable) {
for (ItemStack stack : JEIUtils.getItemVariations(recipe.getResource())) {
recipes.add(new FermenterRecipeWrapper(recipe, stack));
if (recipe.getResource() != null) {
if (recipe.getResource().getItem() instanceof IVariableFermentable) {
for (ItemStack stack : stackHelper.getSubtypes(recipe.getResource())) {
recipes.add(new FermenterRecipeWrapper(recipe, stack));
}
} else {
recipes.add(new FermenterRecipeWrapper(recipe, recipe.getResource()));
}
} else {
recipes.add(new FermenterRecipeWrapper(recipe, recipe.getResource()));
Log.error("Null resource for recipe");
}
}
return recipes;
@@ -42,6 +42,7 @@ import forestry.core.circuits.CircuitLayout;
import forestry.core.config.Constants;
import forestry.core.items.EnumElectronTube;
import forestry.core.recipes.RecipeUtil;
import forestry.core.utils.OreDictUtil;
import forestry.farming.blocks.BlockMushroom;
import forestry.farming.blocks.BlockRegistryFarming;
import forestry.farming.blocks.EnumFarmBlockType;
@@ -207,7 +208,7 @@ public class PluginFarming extends BlankForestryPlugin {
"TDT",
'#', basic,
'T', "gearTin",
'D', Blocks.TRAPDOOR);
'D', OreDictUtil.TRAPDOOR_WOOD);
RecipeUtil.addRecipe(valve,
" # ",
@@ -27,6 +27,7 @@ import forestry.core.fluids.Fluids;
import forestry.core.items.EnumElectronTube;
import forestry.core.network.IPacketRegistry;
import forestry.core.recipes.RecipeUtil;
import forestry.core.utils.OreDictUtil;
import forestry.greenhouse.blocks.BlockGreenhouseType;
import forestry.greenhouse.blocks.BlockRegistryGreenhouse;
import forestry.greenhouse.logics.GreenhouseLogicGreenhouseDoor;
@@ -91,7 +92,7 @@ public class PluginGreenhouse extends BlankForestryPlugin {
"TXT",
"#H#",
'X', blocks.getGreenhouseBlock(BlockGreenhouseType.PLAIN),
'H', Blocks.TRAPDOOR,
'H', OreDictUtil.TRAPDOOR_WOOD,
'#', "gearTin",
'T', PluginCore.items.tubes.get(EnumElectronTube.BRONZE, 1));
@@ -100,7 +101,7 @@ public class PluginGreenhouse extends BlankForestryPlugin {
"#H#",
"TXT",
'X', blocks.getGreenhouseBlock(BlockGreenhouseType.PLAIN),
'H', Blocks.TRAPDOOR,
'H', OreDictUtil.TRAPDOOR_WOOD,
'#', "gearTin",
'T', PluginCore.items.tubes.get(EnumElectronTube.BRONZE, 1));
@@ -26,7 +26,7 @@ import forestry.api.lepidopterology.IAlleleButterflySpecies;
import forestry.api.lepidopterology.IAlleleButterflySpeciesBuilder;
import forestry.api.lepidopterology.IButterfly;
import forestry.api.lepidopterology.IButterflyGenome;
import forestry.api.lepidopterology.IButterflyMutationCustom;
import forestry.api.lepidopterology.IButterflyMutationBuilder;
import forestry.core.config.Constants;
import forestry.core.genetics.alleles.AlleleHelper;
import forestry.core.genetics.alleles.EnumAllele;
@@ -351,7 +351,7 @@ public enum ButterflyDefinition implements IButterflyDefinition {
}
protected final IButterflyMutationCustom registerMutation(IButterflyDefinition parent1, IButterflyDefinition parent2, int chance) {
protected final IButterflyMutationBuilder registerMutation(IButterflyDefinition parent1, IButterflyDefinition parent2, int chance) {
IAlleleButterflySpecies species1 = null;
IAlleleButterflySpecies species2 = null;
if(parent1 instanceof ButterflyDefinition){
@@ -10,22 +10,29 @@
******************************************************************************/
package forestry.lepidopterology.genetics;
import net.minecraft.world.World;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IAlleleSpecies;
import forestry.api.genetics.IGenome;
import forestry.api.genetics.ISpeciesRoot;
import forestry.api.lepidopterology.ButterflyManager;
import forestry.api.lepidopterology.IButterflyMutationCustom;
import forestry.api.lepidopterology.IButterflyMutation;
import forestry.api.lepidopterology.IButterflyMutationBuilder;
import forestry.api.lepidopterology.IButterflyNursery;
import forestry.core.genetics.mutations.Mutation;
import net.minecraft.world.World;
public class ButterflyMutation extends Mutation implements IButterflyMutationCustom {
public class ButterflyMutation extends Mutation implements IButterflyMutation, IButterflyMutationBuilder {
protected ButterflyMutation(IAlleleSpecies species0, IAlleleSpecies species1, IAllele[] template, int chance) {
super(species0, species1, template, chance);
}
@Override
public IButterflyMutation build() {
return this;
}
@Override
public float getChance(World world, IButterflyNursery housing, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1) {
float processedChance = super.getChance(world, housing.getCoordinates(), allele0, allele1, genome0, genome1);
@@ -13,16 +13,16 @@ package forestry.lepidopterology.genetics;
import forestry.api.genetics.IAllele;
import forestry.api.lepidopterology.ButterflyManager;
import forestry.api.lepidopterology.IAlleleButterflySpecies;
import forestry.api.lepidopterology.IButterflyMutationCustom;
import forestry.api.lepidopterology.IButterflyMutationBuilder;
import forestry.api.lepidopterology.IButterflyMutationFactory;
public class ButterflyMutationFactory implements IButterflyMutationFactory {
@Override
public IButterflyMutationCustom createMutation(IAlleleButterflySpecies parentButterfly0, IAlleleButterflySpecies parentButterfly1, IAllele[] result, int chance) {
IButterflyMutationCustom mutation = new ButterflyMutation(parentButterfly0, parentButterfly1, result, chance);
ButterflyManager.butterflyRoot.registerMutation(mutation);
return mutation;
public IButterflyMutationBuilder createMutation(IAlleleButterflySpecies parentButterfly0, IAlleleButterflySpecies parentButterfly1, IAllele[] result, int chance) {
ButterflyMutation butterflyMutation = new ButterflyMutation(parentButterfly0, parentButterfly1, result, chance);
ButterflyManager.butterflyRoot.registerMutation(butterflyMutation);
return butterflyMutation;
}
}
@@ -25,7 +25,7 @@ import forestry.api.lepidopterology.IAlleleButterflySpecies;
import forestry.api.lepidopterology.IAlleleButterflySpeciesBuilder;
import forestry.api.lepidopterology.IButterfly;
import forestry.api.lepidopterology.IButterflyGenome;
import forestry.api.lepidopterology.IButterflyMutationCustom;
import forestry.api.lepidopterology.IButterflyMutationBuilder;
import forestry.core.config.Constants;
import forestry.core.genetics.alleles.AlleleHelper;
import forestry.core.genetics.alleles.EnumAllele;
@@ -113,7 +113,7 @@ public enum MothDefinition implements IButterflyDefinition {
}
protected final IButterflyMutationCustom registerMutation(IButterflyDefinition parent1, IButterflyDefinition parent2, int chance) {
protected final IButterflyMutationBuilder registerMutation(IButterflyDefinition parent1, IButterflyDefinition parent2, int chance) {
IAlleleButterflySpecies species1 = null;
IAlleleButterflySpecies species2 = null;
if(parent1 instanceof MothDefinition){
@@ -152,7 +152,7 @@ public class TileCocoon extends TileEntity implements IStreamable, IOwnable, IBu
}
@Override
public void setOwner(GameProfile owner) {
public void setOwner(@Nonnull GameProfile owner) {
this.owner = owner;
}
+3 -13
View File
@@ -90,20 +90,10 @@ public class MailAddress implements INbtWritable, IMailAddress {
public boolean isValid() {
return gameProfile.getName() != null && !PlayerUtil.isSameGameProfile(gameProfile, invalidGameProfile);
}
@Override
public boolean isPlayer() {
return type == EnumAddressee.PLAYER;
}
@Override
public boolean isTrader() {
return type == EnumAddressee.TRADER;
}
@Override
public GameProfile getPlayerProfile() {
if (!this.isPlayer()) {
if (this.type != EnumAddressee.PLAYER) {
return null;
}
return gameProfile;
@@ -127,7 +117,7 @@ public class MailAddress implements INbtWritable, IMailAddress {
@Override
public String toString() {
String name = getName().toLowerCase(Locale.ENGLISH);
if (isPlayer()) {
if (getType() == EnumAddressee.PLAYER) {
return type + "-" + name + '-' + gameProfile.getId();
} else {
return type + "-" + name;
+3 -2
View File
@@ -17,6 +17,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.WorldSavedData;
import forestry.api.mail.EnumAddressee;
import forestry.api.mail.ILetter;
import forestry.api.mail.IMailAddress;
import forestry.api.mail.PostManager;
@@ -33,7 +34,7 @@ public class POBox extends WorldSavedData implements IInventory {
public POBox(IMailAddress address) {
super(SAVE_NAME + address);
if (!address.isPlayer()) {
if (address.getType() != EnumAddressee.PLAYER) {
throw new IllegalArgumentException("POBox address must be a player");
}
this.address = address;
@@ -85,7 +86,7 @@ public class POBox extends WorldSavedData implements IInventory {
continue;
}
ILetter letter = new Letter(letters.getStackInSlot(i).getTagCompound());
if (letter.getSender().isPlayer()) {
if (letter.getSender().getType() == EnumAddressee.PLAYER) {
playerLetters++;
} else {
tradeLetters++;
@@ -10,6 +10,7 @@
******************************************************************************/
package forestry.mail;
import javax.annotation.Nonnull;
import java.io.File;
import java.util.EnumMap;
import java.util.HashMap;
@@ -47,7 +48,7 @@ public class PostRegistry implements IPostRegistry {
*/
@Override
public boolean isValidPOBox(World world, IMailAddress address) {
return address.isPlayer() && address.getName().matches("^[a-zA-Z0-9]+$");
return address.getType() == EnumAddressee.PLAYER && address.getName().matches("^[a-zA-Z0-9]+$");
}
public static POBox getPOBox(World world, IMailAddress address) {
@@ -88,7 +89,7 @@ public class PostRegistry implements IPostRegistry {
*/
@Override
public boolean isValidTradeAddress(World world, IMailAddress address) {
return address != null && address.isTrader() && address.getName().matches("^[a-zA-Z0-9]+$");
return address != null && address.getType() == EnumAddressee.TRADER && address.getName().matches("^[a-zA-Z0-9]+$");
}
/**
@@ -173,13 +174,14 @@ public class PostRegistry implements IPostRegistry {
return office;
}
@Nonnull
@Override
public IMailAddress getMailAddress(GameProfile gameProfile) {
public IMailAddress getMailAddress(@Nonnull GameProfile gameProfile) {
return new MailAddress(gameProfile);
}
@Override
public IMailAddress getMailAddress(String traderName) {
public IMailAddress getMailAddress(@Nonnull String traderName) {
return new MailAddress(traderName);
}
@@ -23,6 +23,7 @@ import net.minecraft.world.WorldSavedData;
import com.mojang.authlib.GameProfile;
import forestry.api.mail.EnumAddressee;
import forestry.api.mail.EnumPostage;
import forestry.api.mail.EnumTradeStationState;
import forestry.api.mail.ILetter;
@@ -64,7 +65,7 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve
public TradeStation(GameProfile owner, IMailAddress address) {
super(SAVE_NAME + address);
if (!address.isTrader()) {
if (address.getType() != EnumAddressee.TRADER) {
throw new IllegalArgumentException("TradeStation address must be a trader");
}
this.owner = owner;
@@ -14,6 +14,7 @@ import net.minecraft.item.ItemStack;
import com.mojang.authlib.GameProfile;
import forestry.api.mail.EnumAddressee;
import forestry.api.mail.EnumTradeStationState;
import forestry.api.mail.IMailAddress;
import forestry.api.mail.ITradeStationInfo;
@@ -26,7 +27,7 @@ public class TradeStationInfo implements ITradeStationInfo {
private final EnumTradeStationState state;
public TradeStationInfo(IMailAddress address, GameProfile owner, ItemStack tradegood, ItemStack[] required, EnumTradeStationState state) {
if (!address.isTrader()) {
if (address.getType() != EnumAddressee.TRADER) {
throw new IllegalArgumentException("TradeStation address must be a trader");
}
this.address = address;
@@ -10,8 +10,8 @@
******************************************************************************/
package forestry.mail.gui;
import javax.annotation.Nullable;
import java.util.Iterator;
import java.util.UUID;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.server.MinecraftServer;
@@ -126,7 +126,7 @@ public class ContainerLetter extends ContainerItemInventory<ItemInventoryLetter>
getLetter().setRecipient(recipient);
// Update the trading info
if (recipient == null || recipient.isTrader()) {
if (recipient == null || recipient.getType() == EnumAddressee.TRADER) {
updateTradeInfo(player.worldObj, recipient);
}
@@ -134,12 +134,13 @@ public class ContainerLetter extends ContainerItemInventory<ItemInventoryLetter>
Proxies.net.sendToPlayer(new PacketLetterInfoResponse(type, tradeInfo, recipient), player);
}
@Nullable
private static IMailAddress getRecipient(MinecraftServer minecraftServer, String recipientName, EnumAddressee type) {
switch (type) {
case PLAYER: {
GameProfile gameProfile = minecraftServer.getPlayerProfileCache().getGameProfileForUsername(recipientName);
if (gameProfile == null) {
gameProfile = new GameProfile(new UUID(0, 0), recipientName);
return null;
}
return PostManager.postRegistry.getMailAddress(gameProfile);
}
@@ -10,6 +10,8 @@
******************************************************************************/
package forestry.mail.tiles;
import javax.annotation.Nonnull;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
@@ -63,13 +65,16 @@ public class TileMailbox extends TileBase implements IMailContainer {
@Override
public void updateServerSide() {
if (!isLinked) {
getOrCreateMailInventory(worldObj, getAccessHandler().getOwner());
GameProfile owner = getAccessHandler().getOwner();
if (owner != null) {
getOrCreateMailInventory(worldObj, owner);
}
isLinked = true;
}
}
/* MAIL HANDLING */
public IInventory getOrCreateMailInventory(World world, GameProfile playerProfile) {
public IInventory getOrCreateMailInventory(World world, @Nonnull GameProfile playerProfile) {
if (world.isRemote) {
return getInternalInventory();
}
@@ -93,8 +98,11 @@ public class TileMailbox extends TileBase implements IMailContainer {
@Override
public boolean hasMail() {
IInventory mailInventory = getOrCreateMailInventory(worldObj, getAccessHandler().getOwner());
GameProfile owner = getAccessHandler().getOwner();
if (owner == null) {
return false;
}
IInventory mailInventory = getOrCreateMailInventory(worldObj, owner);
for (int i = 0; i < mailInventory.getSizeInventory(); i++) {
if (mailInventory.getStackInSlot(i) != null) {
return true;
@@ -20,6 +20,8 @@ public class ForestryPluginUids {
public static final String BUILDCRAFT_STATEMENTS = "forestry.buildcraft.statements";
public static final String BUILDCRAFT_TRANSPORT = "forestry.buildcraft.transport";
public static final String CHISEL = "forestry.chisel";
public static final String ENDER_IO = "forestry.ender.io";
public static final String EXTRA_UTILITIES = "forestry.extra.utilities";
public static final String NATURA = "forestry.natura";
public static final String INDUSTRIALCRAFT2 = "forestry.industrialcraft2";
}
@@ -14,14 +14,18 @@ import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.event.FMLInterModComms;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.oredict.OreDictionary;
import forestry.api.core.ForestryAPI;
import forestry.api.farming.Farmables;
import forestry.api.recipes.RecipeManagers;
import forestry.api.storage.BackpackManager;
import forestry.core.PluginCore;
@@ -31,6 +35,8 @@ import forestry.core.recipes.RecipeUtil;
import forestry.core.utils.ItemStackUtil;
import forestry.core.utils.Log;
import forestry.core.utils.ModUtil;
import forestry.farming.logic.FarmableBasicAgricraft;
import forestry.farming.logic.FarmableGE;
import forestry.plugins.BlankForestryPlugin;
import forestry.plugins.ForestryPlugin;
import forestry.plugins.ForestryPluginUids;
@@ -43,8 +49,6 @@ public class PluginBiomesOPlenty extends BlankForestryPlugin {
private static Block saplings;
private static Block colorizedSaplings;
private static Item food;
private static Item misc;
private static ItemStack persimmon;
private static int amount;
@Override
@@ -61,12 +65,9 @@ public class PluginBiomesOPlenty extends BlankForestryPlugin {
public void doInit() {
super.doInit();
saplings = GameRegistry.findBlock(BoP, "saplings");
colorizedSaplings = GameRegistry.findBlock(BoP, "colorizedSaplings");
food = GameRegistry.findItem(BoP, "food");
if (food != null) {
persimmon = new ItemStack(food, 1, 8);
}
saplings = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(BoP, "saplings"));
colorizedSaplings = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(BoP, "colorizedSaplings"));
food = ForgeRegistries.ITEMS.getValue(new ResourceLocation(BoP, "food"));
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.APICULTURE)) {
addFlowers();
@@ -98,21 +99,21 @@ public class PluginBiomesOPlenty extends BlankForestryPlugin {
}
for (String key : saplingItemKeys) {
Item saplingItem = GameRegistry.findItem(BoP, key);
Item saplingItem = ForgeRegistries.ITEMS.getValue(new ResourceLocation(BoP, key));
String saplingName = ItemStackUtil.getItemNameFromRegistryAsString(saplingItem);
if (saplingName != null) {
FMLInterModComms.sendMessage(Constants.MOD_ID, "add-farmable-sapling", String.format("farmArboreal@%s.-1", saplingName));
}
}
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.FARMING) && saplings != null && persimmon != null) {
//TODO BoP for 1.9: Add farmables
//TODO BoP for 1.9: Add farmables
// if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.FARMING) && saplings != null && persimmon != null) {
// Farmables.farmables.put("farmArboreal", new FarmableGenericSapling(saplings, 15, persimmon));
}
// }
Block boPTurnip = GameRegistry.findBlock(BoP, "turnip");
Block boPTurnip = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(BoP, "turnip"));
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.FARMING) && boPTurnip != null) {
Item boPTurnipSeeds = GameRegistry.findItem(BoP, "turnipSeeds");
Item boPTurnipSeeds = ForgeRegistries.ITEMS.getValue(new ResourceLocation(BoP, "turnipSeeds"));
ItemStack boPTurnipSeedStack = new ItemStack(boPTurnipSeeds, 1, 0);
if (boPTurnipSeeds != null) {
//TODO BoP for 1.9: Add farmable saplings
@@ -130,11 +131,11 @@ public class PluginBiomesOPlenty extends BlankForestryPlugin {
private static void addFermenterRecipes() {
int saplingYield = ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.sapling");
if (saplings != null) {
if (saplings != Blocks.AIR) {
RecipeUtil.addFermenterRecipes(new ItemStack(saplings, 1, OreDictionary.WILDCARD_VALUE), saplingYield, Fluids.BIOMASS);
}
if (colorizedSaplings != null) {
if (colorizedSaplings != Blocks.AIR) {
RecipeUtil.addFermenterRecipes(new ItemStack(colorizedSaplings, 1, OreDictionary.WILDCARD_VALUE), saplingYield, Fluids.BIOMASS);
}
}
@@ -142,20 +143,18 @@ public class PluginBiomesOPlenty extends BlankForestryPlugin {
private static void addSqueezerRecipes() {
ItemStack mulch = new ItemStack(PluginCore.items.mulch);
misc = GameRegistry.findItem(BoP, "misc");
if (misc != null) {
ItemStack pinecone = new ItemStack(misc, 1, 13);
if (pinecone != null) {
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{pinecone}, Fluids.SEED_OIL.getFluid(3 * amount));
}
Item pinecone = ForgeRegistries.ITEMS.getValue(new ResourceLocation(BoP, "pinecone"));
if (pinecone != null) {
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(pinecone)}, Fluids.SEED_OIL.getFluid(3 * amount));
}
if (food != null) {
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(food)}, Fluids.JUICE.getFluid(50), mulch, 5);
}
Item persimmon = ForgeRegistries.ITEMS.getValue(new ResourceLocation(BoP, "persimmon"));
if (persimmon != null) {
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{persimmon}, Fluids.JUICE.getFluid(200), mulch, 20);
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(persimmon)}, Fluids.JUICE.getFluid(200), mulch, 20);
}
}
@@ -234,7 +233,7 @@ public class PluginBiomesOPlenty extends BlankForestryPlugin {
private static void addBlocksToBackpack(String backpackUid, String... blockNames) {
for (String blockName : blockNames) {
Block block = GameRegistry.findBlock(BoP, blockName);
Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(BoP, blockName));
if (block != null) {
ItemStack blockStack = new ItemStack(block, 1, OreDictionary.WILDCARD_VALUE);
BackpackManager.backpackInterface.getBackpack(backpackUid).addValidItem(blockStack);
@@ -0,0 +1,70 @@
package forestry.plugins.compat;
import forestry.api.core.ForestryAPI;
import forestry.core.config.Constants;
import forestry.core.fluids.Fluids;
import forestry.core.utils.ModUtil;
import forestry.plugins.BlankForestryPlugin;
import forestry.plugins.ForestryPlugin;
import forestry.plugins.ForestryPluginUids;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fml.common.event.FMLInterModComms;
@ForestryPlugin(pluginID = ForestryPluginUids.ENDER_IO, name = "EnderIO", author = "mezz", url = Constants.URL, unlocalizedDescription = "for.plugin.enderIO.description")
public class PluginEnderIO extends BlankForestryPlugin {
private static final String EnderIO = "EnderIO";
private static final String FLUID_FUEL_ADD = "fluidFuel:add";
private static final String FLUID_COOLANT_ADD = "fluidCoolant:add";
private static final String KEY_FLUID_NAME = "fluidName";
private static final String KEY_POWER_PER_CYCLE = "powerPerCycle";
private static final String KEY_TOTAL_BURN_TIME = "totalBurnTime";
private static final String KEY_COOLING_PER_MB = "coolingPerMb";
private static final float WATER_COOLING_PER_MB = 0.0023f;
@Override
public boolean isAvailable() {
return ModUtil.isModLoaded(EnderIO);
}
@Override
public String getFailMessage() {
return "EnderIO not found";
}
@Override
public void doInit() {
Fluid ethanol = Fluids.BIO_ETHANOL.getFluid();
if (ethanol != null) {
int ethanolBurnTime = Math.round(Constants.ENGINE_CYCLE_DURATION_ETHANOL * ForestryAPI.activeMode.getFloatSetting("fuel.ethanol.combustion"));
addFuel(ethanol, 40, ethanolBurnTime);
}
Fluid crushedIce = Fluids.ICE.getFluid();
if (crushedIce != null) {
addCoolant(crushedIce, Constants.ICE_COOLING_MULTIPLIER);
}
}
private static void addFuel(Fluid fluid, int powerPerCycle, int totalBurnTime) {
NBTTagCompound fuelTag = new NBTTagCompound();
fuelTag.setString(KEY_FLUID_NAME, fluid.getName());
fuelTag.setInteger(KEY_POWER_PER_CYCLE, powerPerCycle);
fuelTag.setInteger(KEY_TOTAL_BURN_TIME, totalBurnTime);
FMLInterModComms.sendMessage(EnderIO, FLUID_FUEL_ADD, fuelTag);
}
private static void addCoolant(Fluid fluid, float coolingMultiplier) {
float coolingPerMb = coolingMultiplier * WATER_COOLING_PER_MB;
NBTTagCompound coolantTag = new NBTTagCompound();
coolantTag.setString(KEY_FLUID_NAME, fluid.getName());
coolantTag.setFloat(KEY_COOLING_PER_MB, coolingPerMb);
FMLInterModComms.sendMessage(EnderIO, FLUID_COOLANT_ADD, coolantTag);
}
}
@@ -0,0 +1,89 @@
/*******************************************************************************
* 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.plugins.compat;
import java.util.Collections;
import forestry.api.circuits.ChipsetManager;
import forestry.api.circuits.ICircuitLayout;
import forestry.api.core.ForestryAPI;
import forestry.api.farming.Farmables;
import forestry.core.PluginCore;
import forestry.core.circuits.Circuit;
import forestry.core.config.Config;
import forestry.core.config.Constants;
import forestry.core.items.EnumElectronTube;
import forestry.core.utils.BlockUtil;
import forestry.core.utils.Log;
import forestry.core.utils.ModUtil;
import forestry.farming.circuits.CircuitFarmLogic;
import forestry.farming.logic.FarmLogicEnder;
import forestry.farming.logic.FarmableAgingCrop;
import forestry.plugins.BlankForestryPlugin;
import forestry.plugins.ForestryPlugin;
import forestry.plugins.ForestryPluginUids;
import net.minecraft.block.Block;
import net.minecraft.block.properties.IProperty;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
@ForestryPlugin(pluginID = ForestryPluginUids.EXTRA_UTILITIES, name = "ExtraUtilities", author = "Nirek", url = Constants.URL, unlocalizedDescription = "for.plugin.extrautilities.description")
public class PluginExtraUtilities extends BlankForestryPlugin {
private static final String ExU = "ExtraUtils2";
@Override
public boolean isAvailable() {
return ModUtil.isModLoaded(ExU);
}
@Override
public String getFailMessage() {
return "ExtraUtilities not found";
}
@Override
public void doInit() {
super.doInit();
if (Config.isExUtilEnderLilyEnabled()) {
Block enderLillyBlock = ForgeRegistries.BLOCKS.getValue(new ResourceLocation("extrautils2", "EnderLilly"));
Item enderLillyItem = Item.getItemFromBlock(enderLillyBlock);
if (enderLillyBlock == Blocks.AIR) {
Log.error("Could not find ender lilly block.");
} else if (enderLillyItem == null) {
Log.error("Could not find ender lilly item.");
} else {
IProperty<Integer> growthProperty = BlockUtil.getProperty(enderLillyBlock, "growth", Integer.class);
if (growthProperty == null) {
Log.error("Could not find the growth property of ender lily.");
} else {
int harvestAge = Collections.max(growthProperty.getAllowedValues());
int replantAge = enderLillyBlock.getDefaultState().getValue(growthProperty);
Farmables.farmables.put("farmEnder", new FarmableAgingCrop(new ItemStack(enderLillyItem), enderLillyBlock, growthProperty, harvestAge, replantAge));
Circuit.farmEnderManaged = new CircuitFarmLogic("managedEnder", new FarmLogicEnder());
}
}
}
}
@Override
public void registerRecipes() {
super.registerRecipes();
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.FARMING) && Circuit.farmEnderManaged != null) {
ICircuitLayout layoutManaged = ChipsetManager.circuitRegistry.getLayout("forestry.farms.managed");
ChipsetManager.solderManager.addRecipe(layoutManaged, PluginCore.items.tubes.get(EnumElectronTube.ENDER, 1), Circuit.farmEnderManaged);
}
}
}
@@ -219,11 +219,12 @@ public class PluginStorage extends BlankForestryPlugin {
"stainedGlass[A-Z].*",
"stone",
"sandstone",
"plankWood",
"stairWood",
"slabWood",
OreDictUtil.PLANK_WOOD,
OreDictUtil.STAIR_WOOD,
OreDictUtil.SLAB_WOOD,
OreDictUtil.FENCE_WOOD,
OreDictUtil.FENCE_GATE_WOOD,
OreDictUtil.TRAPDOOR_WOOD,
"glass",
"paneGlass",
"torch",
@@ -350,7 +351,6 @@ public class PluginStorage extends BlankForestryPlugin {
new ItemStack(Blocks.PURPUR_SLAB),
new ItemStack(Blocks.END_BRICKS),
new ItemStack(Blocks.CARPET, 1, OreDictionary.WILDCARD_VALUE),
new ItemStack(Blocks.TRAPDOOR),
new ItemStack(Blocks.IRON_TRAPDOOR),
new ItemStack(Blocks.STONE_PRESSURE_PLATE),
new ItemStack(Blocks.WOODEN_PRESSURE_PLATE),