mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-15 17:44:55 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9f5f5e7812 | ||
|
|
8617c4a79f | ||
|
|
e9809238de | ||
|
|
c0a22f4a28 | ||
|
|
41c6fb15b3 | ||
|
|
b5d65e83f0 |
No files matched your search
+1
-1
@@ -7,4 +7,4 @@ ic2_version=2.5.5-ex19
|
||||
|
||||
version_major=5
|
||||
version_minor=0
|
||||
version_patch=17
|
||||
version_patch=20
|
||||
@@ -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();
|
||||
|
||||
}
|
||||
+4
-3
@@ -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);
|
||||
}
|
||||
+4
-3
@@ -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);
|
||||
}
|
||||
+16
-13
@@ -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);
|
||||
}
|
||||
+4
-3
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+9
-16
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user