mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-15 09:34:57 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
40eece7d77 | ||
|
|
4fcc785e85 | ||
|
|
11e4097bd8 | ||
|
|
f8c37da06d | ||
|
|
09756f21fd | ||
|
|
a06c4bd1dc | ||
|
|
bb477f0dfb | ||
|
|
0b86b3df8f | ||
|
|
edd5357008 |
No files matched your search
+1
-1
@@ -7,4 +7,4 @@ ic2_version=2.5.5-ex19
|
||||
|
||||
version_major=5
|
||||
version_minor=1
|
||||
version_patch=4
|
||||
version_patch=7
|
||||
+1
-1
Submodule lang updated: 6fc3c7ef64...2d88011e4a.
@@ -7,17 +7,15 @@ package forestry.api.apiculture;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
|
||||
public interface IBeeRoot extends ISpeciesRoot {
|
||||
|
||||
/**
|
||||
@@ -100,7 +98,7 @@ public interface IBeeRoot extends ISpeciesRoot {
|
||||
|
||||
/* MUTATIONS */
|
||||
@Override
|
||||
Collection<IBeeMutation> getMutations(boolean shuffle);
|
||||
List<IBeeMutation> getMutations(boolean shuffle);
|
||||
|
||||
/* GAME MODE */
|
||||
void resetBeekeepingMode();
|
||||
|
||||
@@ -8,18 +8,17 @@ package forestry.api.arboriculture;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IChromosome;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IChromosome;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
|
||||
public interface ITreeRoot extends ISpeciesRoot {
|
||||
|
||||
@Override
|
||||
@@ -82,7 +81,7 @@ public interface ITreeRoot extends ISpeciesRoot {
|
||||
boolean setFruitBlock(World world, IAlleleFruit allele, float sappiness, BlockPos pos);
|
||||
|
||||
/* GAME MODE */
|
||||
ArrayList<ITreekeepingMode> getTreekeepingModes();
|
||||
List<ITreekeepingMode> getTreekeepingModes();
|
||||
|
||||
ITreekeepingMode getTreekeepingMode(World world);
|
||||
|
||||
@@ -98,6 +97,5 @@ public interface ITreeRoot extends ISpeciesRoot {
|
||||
|
||||
/* MUTATIONS */
|
||||
@Override
|
||||
Collection<ITreeMutation> getMutations(boolean shuffle);
|
||||
|
||||
List<ITreeMutation> getMutations(boolean shuffle);
|
||||
}
|
||||
@@ -138,13 +138,13 @@ public interface ISpeciesRoot {
|
||||
/**
|
||||
* @return All registered mutations.
|
||||
*/
|
||||
Collection<? extends IMutation> getMutations(boolean shuffle);
|
||||
List<? extends IMutation> getMutations(boolean shuffle);
|
||||
|
||||
/**
|
||||
* @param other Allele to match mutations against.
|
||||
* @return All registered mutations the given allele is part of.
|
||||
*/
|
||||
Collection<? extends IMutation> getCombinations(IAllele other);
|
||||
List<? extends IMutation> getCombinations(IAllele other);
|
||||
|
||||
/**
|
||||
* @since Forestry 3.7
|
||||
|
||||
@@ -7,18 +7,16 @@ package forestry.api.lepidopterology;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
|
||||
public interface IButterflyRoot extends ISpeciesRoot {
|
||||
|
||||
@Override
|
||||
@@ -67,7 +65,7 @@ public interface IButterflyRoot extends ISpeciesRoot {
|
||||
|
||||
/* MUTATIONS */
|
||||
@Override
|
||||
Collection<IButterflyMutation> getMutations(boolean shuffle);
|
||||
List<IButterflyMutation> getMutations(boolean shuffle);
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
|
||||
@@ -12,8 +12,8 @@ package forestry.apiculture.genetics;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@@ -249,10 +249,10 @@ public class BeeRoot extends SpeciesRoot implements IBeeRoot {
|
||||
/**
|
||||
* List of possible mutations on species alleles.
|
||||
*/
|
||||
private static final ArrayList<IBeeMutation> beeMutations = new ArrayList<>();
|
||||
private static final List<IBeeMutation> beeMutations = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public Collection<IBeeMutation> getMutations(boolean shuffle) {
|
||||
public List<IBeeMutation> getMutations(boolean shuffle) {
|
||||
if (shuffle) {
|
||||
Collections.shuffle(beeMutations);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class ItemHiveFrame extends ItemForestry implements IHiveFrame {
|
||||
super.addInformation(stack, playerIn, tooltip, advanced);
|
||||
beeModifier.addInformation(stack, playerIn, tooltip, advanced);
|
||||
if (!stack.isItemDamaged()) {
|
||||
tooltip.add(Translator.translateToLocalFormatted("item.for.frame.durability", stack.getMaxDamage()));
|
||||
tooltip.add(Translator.translateToLocalFormatted("item.for.durability", stack.getMaxDamage()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ import forestry.api.genetics.ISaplingTranslator;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
import forestry.api.storage.ICrateRegistry;
|
||||
import forestry.api.storage.StorageManager;
|
||||
import forestry.arboriculture.blocks.BlockForestryLeaves;
|
||||
import forestry.arboriculture.blocks.BlockPile;
|
||||
import forestry.arboriculture.blocks.BlockRegistryArboriculture;
|
||||
import forestry.arboriculture.blocks.log.BlockArbLog;
|
||||
@@ -49,6 +50,7 @@ import forestry.arboriculture.genetics.alleles.AlleleFruit;
|
||||
import forestry.arboriculture.genetics.alleles.AlleleGrowth;
|
||||
import forestry.arboriculture.genetics.alleles.AlleleLeafEffect;
|
||||
import forestry.arboriculture.items.ItemCharcoal;
|
||||
import forestry.arboriculture.items.ItemGrafter;
|
||||
import forestry.arboriculture.items.ItemRegistryArboriculture;
|
||||
import forestry.arboriculture.models.TextureLeaves;
|
||||
import forestry.arboriculture.network.PacketRegistryArboriculture;
|
||||
@@ -79,12 +81,16 @@ import net.minecraft.block.BlockNewLeaf;
|
||||
import net.minecraft.block.BlockOldLeaf;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.passive.EntityVillager;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import net.minecraftforge.fml.common.IFuelHandler;
|
||||
import net.minecraftforge.fml.common.SidedProxy;
|
||||
import net.minecraftforge.fml.common.event.FMLInterModComms.IMCMessage;
|
||||
@@ -546,4 +552,31 @@ public class PluginArboriculture extends BlankForestryPlugin {
|
||||
alleleFruit.getProvider().registerSprites();
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onHarvestDropsEvent(BlockEvent.HarvestDropsEvent event) {
|
||||
IBlockState state = event.getState();
|
||||
Block block = state.getBlock();
|
||||
if (block instanceof BlockLeaves && !(block instanceof BlockForestryLeaves)) {
|
||||
EntityPlayer player = event.getHarvester();
|
||||
if (player != null) {
|
||||
ItemStack harvestingTool = player.getHeldItemMainhand();
|
||||
if (harvestingTool != null && harvestingTool.getItem() instanceof ItemGrafter) {
|
||||
if (event.getDrops().isEmpty()) {
|
||||
World world = event.getWorld();
|
||||
Item itemDropped = block.getItemDropped(state, world.rand, 3);
|
||||
if (itemDropped != null) {
|
||||
event.getDrops().add(new ItemStack(itemDropped, 1, block.damageDropped(state)));
|
||||
}
|
||||
}
|
||||
|
||||
harvestingTool.damageItem(1, player);
|
||||
if (harvestingTool.stackSize <= 0) {
|
||||
net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(player, harvestingTool, EnumHand.MAIN_HAND);
|
||||
player.setHeldItem(EnumHand.MAIN_HAND, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,29 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import forestry.api.arboriculture.EnumGermlingType;
|
||||
import forestry.api.arboriculture.IToolGrafter;
|
||||
import forestry.api.arboriculture.ITree;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.core.IToolScoop;
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.api.lepidopterology.ButterflyManager;
|
||||
import forestry.api.lepidopterology.EnumFlutterType;
|
||||
import forestry.api.lepidopterology.IButterfly;
|
||||
import forestry.arboriculture.LeafDecayHelper;
|
||||
import forestry.arboriculture.PluginArboriculture;
|
||||
import forestry.arboriculture.genetics.TreeDefinition;
|
||||
import forestry.arboriculture.tiles.TileLeaves;
|
||||
import forestry.core.blocks.IColoredBlock;
|
||||
import forestry.core.blocks.propertys.UnlistedBlockAccess;
|
||||
import forestry.core.blocks.propertys.UnlistedBlockPos;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.tiles.TileUtil;
|
||||
import forestry.core.utils.BlockUtil;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import net.minecraft.block.BlockLeaves;
|
||||
import net.minecraft.block.BlockPlanks;
|
||||
import net.minecraft.block.IGrowable;
|
||||
@@ -40,9 +63,6 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.common.property.ExtendedBlockState;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
@@ -50,29 +70,6 @@ import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.arboriculture.EnumGermlingType;
|
||||
import forestry.api.arboriculture.IToolGrafter;
|
||||
import forestry.api.arboriculture.ITree;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.core.IToolScoop;
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.api.lepidopterology.ButterflyManager;
|
||||
import forestry.api.lepidopterology.EnumFlutterType;
|
||||
import forestry.api.lepidopterology.IButterfly;
|
||||
import forestry.arboriculture.LeafDecayHelper;
|
||||
import forestry.arboriculture.PluginArboriculture;
|
||||
import forestry.arboriculture.genetics.TreeDefinition;
|
||||
import forestry.arboriculture.tiles.TileLeaves;
|
||||
import forestry.core.blocks.IColoredBlock;
|
||||
import forestry.core.blocks.propertys.UnlistedBlockAccess;
|
||||
import forestry.core.blocks.propertys.UnlistedBlockPos;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.tiles.TileUtil;
|
||||
import forestry.core.utils.BlockUtil;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
|
||||
public class BlockForestryLeaves extends BlockLeaves implements ITileEntityProvider, IGrowable, IItemModelRegister, IColoredBlock {
|
||||
|
||||
public BlockForestryLeaves() {
|
||||
@@ -137,17 +134,16 @@ public class BlockForestryLeaves extends BlockLeaves implements ITileEntityProvi
|
||||
int fortune = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, player.getActiveItemStack());
|
||||
float saplingModifier = 1.0f;
|
||||
|
||||
if (!world.isRemote) {
|
||||
ItemStack held = player.inventory.getCurrentItem();
|
||||
if (held != null && held.getItem() instanceof IToolGrafter) {
|
||||
saplingModifier = ((IToolGrafter) held.getItem()).getSaplingModifier(held, world, player, pos);
|
||||
held.damageItem(1, player);
|
||||
if (held.stackSize <= 0) {
|
||||
net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(player, held, EnumHand.MAIN_HAND);
|
||||
player.setHeldItem(EnumHand.MAIN_HAND, null);
|
||||
}
|
||||
ItemStack held = player.inventory.getCurrentItem();
|
||||
if (held != null && held.getItem() instanceof IToolGrafter) {
|
||||
saplingModifier = ((IToolGrafter) held.getItem()).getSaplingModifier(held, world, player, pos);
|
||||
held.damageItem(1, player);
|
||||
if (held.stackSize <= 0) {
|
||||
net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(player, held, EnumHand.MAIN_HAND);
|
||||
player.setHeldItem(EnumHand.MAIN_HAND, null);
|
||||
}
|
||||
}
|
||||
|
||||
GameProfile playerProfile = player.getGameProfile();
|
||||
List<ItemStack> leafDrops = getLeafDrop(world, playerProfile, pos, saplingModifier, fortune);
|
||||
drops.set(leafDrops);
|
||||
|
||||
@@ -13,17 +13,16 @@ package forestry.arboriculture.commands;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.arboriculture.ITreekeepingMode;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.core.commands.ICommandModeHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class TreeModeHelper implements ICommandModeHelper {
|
||||
|
||||
@Override
|
||||
public String[] getModeNames() {
|
||||
ArrayList<ITreekeepingMode> treekeepingModes = TreeManager.treeRoot.getTreekeepingModes();
|
||||
List<ITreekeepingMode> treekeepingModes = TreeManager.treeRoot.getTreekeepingModes();
|
||||
int modeStringCount = treekeepingModes.size();
|
||||
List<String> modeStrings = new ArrayList<>(modeStringCount);
|
||||
for (ITreekeepingMode mode : treekeepingModes) {
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import forestry.core.utils.Translator;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockLeaves;
|
||||
import net.minecraft.block.material.Material;
|
||||
@@ -34,6 +37,14 @@ public class ItemGrafter extends ItemForestryTool implements IToolGrafter {
|
||||
setEfficiencyOnProperMaterial(4.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) {
|
||||
super.addInformation(stack, playerIn, tooltip, advanced);
|
||||
if (!stack.isItemDamaged()) {
|
||||
tooltip.add(Translator.translateToLocalFormatted("item.for.uses", stack.getMaxDamage() + 1));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHarvestBlock(IBlockState state, ItemStack stack) {
|
||||
Block block = state.getBlock();
|
||||
|
||||
@@ -35,7 +35,7 @@ public class ItemRegistryArboriculture extends ItemRegistry {
|
||||
registerOreDict(OreDictUtil.CHARCOAL, new ItemStack(charcoal, 1, OreDictionary.WILDCARD_VALUE));
|
||||
registerOreDict(OreDictUtil.CHARCOAL, new ItemStack(Items.COAL, 1, 1));
|
||||
|
||||
grafter = registerItem(new ItemGrafter(4), "grafter");
|
||||
grafter = registerItem(new ItemGrafter(9), "grafter");
|
||||
grafterProven = registerItem(new ItemGrafter(149), "grafterProven");
|
||||
}
|
||||
}
|
||||
@@ -104,8 +104,10 @@ public abstract class EntityMinecartForestry extends EntityMinecart implements I
|
||||
@Override
|
||||
public void killMinecart(DamageSource damageSource) {
|
||||
super.killMinecart(damageSource);
|
||||
Block block = getDisplayTile().getBlock();
|
||||
entityDropItem(new ItemStack(block, 1, block.getMetaFromState(getDisplayTile())), 0.0F);
|
||||
if (this.worldObj.getGameRules().getBoolean("doEntityDrops")) {
|
||||
Block block = getDisplayTile().getBlock();
|
||||
entityDropItem(new ItemStack(block), 0.0F);
|
||||
}
|
||||
}
|
||||
|
||||
// fix cart contents rendering as black in the End dimension
|
||||
|
||||
@@ -20,14 +20,13 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.api.genetics.IChromosome;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.genetics.IMutation;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public abstract class SpeciesRoot implements ISpeciesRoot {
|
||||
|
||||
@@ -82,8 +81,8 @@ public abstract class SpeciesRoot implements ISpeciesRoot {
|
||||
|
||||
/* MUTATIONS */
|
||||
@Override
|
||||
public Collection<? extends IMutation> getCombinations(IAllele other) {
|
||||
ArrayList<IMutation> combinations = new ArrayList<>();
|
||||
public List<IMutation> getCombinations(IAllele other) {
|
||||
List<IMutation> combinations = new ArrayList<>();
|
||||
for (IMutation mutation : getMutations(false)) {
|
||||
if (mutation.isPartner(other)) {
|
||||
combinations.add(mutation);
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
package forestry.core.genetics.alleles;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
@@ -20,6 +21,7 @@ import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.api.genetics.IAlleleSpeciesBuilder;
|
||||
import forestry.api.genetics.IBreedingTracker;
|
||||
import forestry.api.genetics.IClassification;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IMutation;
|
||||
@@ -111,20 +113,30 @@ public abstract class AlleleSpecies extends Allele implements IAlleleSpeciesBuil
|
||||
|
||||
@Override
|
||||
public ItemStack[] getResearchBounty(World world, GameProfile researcher, IIndividual individual, int bountyLevel) {
|
||||
ItemStack research = null;
|
||||
if (world.rand.nextFloat() < (float) 10 / bountyLevel) {
|
||||
Collection<? extends IMutation> combinations = getRoot().getCombinations(this);
|
||||
if (!combinations.isEmpty()) {
|
||||
IMutation[] candidates = combinations.toArray(new IMutation[combinations.size()]);
|
||||
research = AlleleManager.alleleRegistry.getMutationNoteStack(researcher, candidates[world.rand.nextInt(candidates.length)]);
|
||||
if (world.rand.nextFloat() < bountyLevel / 32.0f) {
|
||||
List<? extends IMutation> allMutations = getRoot().getCombinations(this);
|
||||
if (!allMutations.isEmpty()) {
|
||||
List<IMutation> unresearchedMutations = new ArrayList<>();
|
||||
IBreedingTracker tracker = individual.getGenome().getSpeciesRoot().getBreedingTracker(world, researcher);
|
||||
for (IMutation mutation : allMutations) {
|
||||
if (!tracker.isResearched(mutation)) {
|
||||
unresearchedMutations.add(mutation);
|
||||
}
|
||||
}
|
||||
|
||||
IMutation chosenMutation;
|
||||
if (!unresearchedMutations.isEmpty()) {
|
||||
chosenMutation = unresearchedMutations.get(world.rand.nextInt(unresearchedMutations.size()));
|
||||
} else {
|
||||
chosenMutation = allMutations.get(world.rand.nextInt(allMutations.size()));
|
||||
}
|
||||
|
||||
ItemStack researchNote = AlleleManager.alleleRegistry.getMutationNoteStack(researcher, chosenMutation);
|
||||
return new ItemStack[]{researchNote};
|
||||
}
|
||||
}
|
||||
|
||||
if (research != null) {
|
||||
return new ItemStack[]{research};
|
||||
} else {
|
||||
return ItemStackUtil.EMPTY_STACK_ARRAY;
|
||||
}
|
||||
return ItemStackUtil.EMPTY_STACK_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,16 +23,11 @@ import forestry.core.tiles.EscritoireGame;
|
||||
import forestry.core.tiles.TileEscritoire;
|
||||
|
||||
public class ContainerEscritoire extends ContainerTile<TileEscritoire> implements IGuiSelectable {
|
||||
|
||||
private final EntityPlayer player;
|
||||
|
||||
private long lastUpdate;
|
||||
|
||||
public ContainerEscritoire(EntityPlayer player, TileEscritoire tile) {
|
||||
super(tile, player.inventory, 34, 153);
|
||||
|
||||
this.player = player;
|
||||
|
||||
// Analyze slot
|
||||
addSlotToContainer(new SlotFiltered(this.tile, InventoryEscritoire.SLOT_ANALYZE, 97, 67).setPickupWatcher(this.tile).setStackLimit(1));
|
||||
|
||||
@@ -54,7 +49,7 @@ public class ContainerEscritoire extends ContainerTile<TileEscritoire> implement
|
||||
long gameLastUpdate = tile.getGame().getLastUpdate();
|
||||
if (lastUpdate != gameLastUpdate) {
|
||||
lastUpdate = gameLastUpdate;
|
||||
Proxies.net.sendToPlayer(new PacketGuiUpdate(tile), player);
|
||||
sendPacketToListeners(new PacketGuiUpdate(tile));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -91,6 +91,7 @@ public class GameTokenWidget extends Widget {
|
||||
|
||||
@Override
|
||||
public void handleMouseClick(int mouseX, int mouseY, int mouseButton) {
|
||||
game.choose(index);
|
||||
Proxies.net.sendToServer(new PacketGuiSelectRequest(index, 0));
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import forestry.api.genetics.IAllele;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
@@ -72,10 +73,10 @@ public class EscritoireGameBoard implements INbtWritable, IStreamable {
|
||||
tokenCount = getTokenCount(genome);
|
||||
|
||||
for (int i = 0; i < tokenCount / 2; i++) {
|
||||
IIndividual token = root.templateAsIndividual(root.getRandomTemplate(rand));
|
||||
ItemStack pair = root.getMemberStack(token, root.getIconType());
|
||||
gameTokens.add(new EscritoireGameToken(pair));
|
||||
gameTokens.add(new EscritoireGameToken(pair));
|
||||
IAllele[] randomTemplate = root.getRandomTemplate(rand);
|
||||
String speciesUid = randomTemplate[root.getSpeciesChromosomeType().ordinal()].getUID();
|
||||
gameTokens.add(new EscritoireGameToken(speciesUid));
|
||||
gameTokens.add(new EscritoireGameToken(speciesUid));
|
||||
}
|
||||
Collections.shuffle(gameTokens);
|
||||
return true;
|
||||
|
||||
@@ -14,17 +14,19 @@ import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import forestry.api.core.INbtWritable;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.IStreamable;
|
||||
import forestry.core.utils.ColourUtil;
|
||||
import forestry.core.utils.Translator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class EscritoireGameToken implements INbtWritable, IStreamable {
|
||||
|
||||
@@ -41,6 +43,8 @@ public class EscritoireGameToken implements INbtWritable, IStreamable {
|
||||
private static final String[] OVERLAY_FAILED = new String[]{"errors/errored"};
|
||||
private static final String[] OVERLAY_SELECTED = new String[]{"errors/unknown"};
|
||||
|
||||
@Nullable
|
||||
private IIndividual tokenIndividual;
|
||||
@Nullable
|
||||
private ItemStack tokenStack;
|
||||
@Nonnull
|
||||
@@ -51,8 +55,8 @@ public class EscritoireGameToken implements INbtWritable, IStreamable {
|
||||
// required for IStreamable serialization
|
||||
}
|
||||
|
||||
public EscritoireGameToken(@Nullable ItemStack tokenStack) {
|
||||
this.tokenStack = tokenStack;
|
||||
public EscritoireGameToken(@Nullable String speciesUid) {
|
||||
setTokenSpecies(speciesUid);
|
||||
}
|
||||
|
||||
public EscritoireGameToken(@Nonnull NBTTagCompound nbttagcompound) {
|
||||
@@ -61,8 +65,29 @@ public class EscritoireGameToken implements INbtWritable, IStreamable {
|
||||
state = State.values()[stateOrdinal];
|
||||
}
|
||||
|
||||
// legacy
|
||||
if (nbttagcompound.hasKey("tokenStack")) {
|
||||
tokenStack = ItemStack.loadItemStackFromNBT(nbttagcompound.getCompoundTag("tokenStack"));
|
||||
ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(tokenStack);
|
||||
tokenIndividual = speciesRoot.getMember(tokenStack);
|
||||
}
|
||||
|
||||
if (nbttagcompound.hasKey("tokenSpecies")) {
|
||||
String speciesUid = nbttagcompound.getString("tokenSpecies");
|
||||
setTokenSpecies(speciesUid);
|
||||
}
|
||||
}
|
||||
|
||||
private void setTokenSpecies(String speciesUid) {
|
||||
IAllele allele = AlleleManager.alleleRegistry.getAllele(speciesUid);
|
||||
if (allele instanceof IAlleleSpecies) {
|
||||
IAlleleSpecies species = (IAlleleSpecies) allele;
|
||||
ISpeciesRoot root = species.getRoot();
|
||||
IAllele[] template = root.getTemplate(speciesUid);
|
||||
if (template != null) {
|
||||
this.tokenIndividual = root.templateAsIndividual(template);
|
||||
this.tokenStack = root.getMemberStack(this.tokenIndividual, root.getIconType());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,12 +133,11 @@ public class EscritoireGameToken implements INbtWritable, IStreamable {
|
||||
}
|
||||
|
||||
public int getTokenColour() {
|
||||
if (tokenStack == null || !isVisible()) {
|
||||
if (tokenIndividual == null || !isVisible()) {
|
||||
return 0xffffff;
|
||||
}
|
||||
|
||||
IIndividual individual = AlleleManager.alleleRegistry.getIndividual(tokenStack);
|
||||
int iconColor = individual.getGenome().getPrimary().getSpriteColour(0);
|
||||
int iconColor = tokenIndividual.getGenome().getPrimary().getSpriteColour(0);
|
||||
|
||||
if (state == State.MATCHED) {
|
||||
return ColourUtil.multiplyRGBComponents(iconColor, 0.7f);
|
||||
@@ -146,10 +170,8 @@ public class EscritoireGameToken implements INbtWritable, IStreamable {
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
nbttagcompound.setInteger("state", state.ordinal());
|
||||
|
||||
if (tokenStack != null) {
|
||||
NBTTagCompound stackcompound = new NBTTagCompound();
|
||||
tokenStack.writeToNBT(stackcompound);
|
||||
nbttagcompound.setTag("tokenStack", stackcompound);
|
||||
if (tokenIndividual != null) {
|
||||
nbttagcompound.setString("tokenSpecies", tokenIndividual.getGenome().getPrimary().getUID());
|
||||
}
|
||||
return nbttagcompound;
|
||||
}
|
||||
@@ -158,12 +180,20 @@ public class EscritoireGameToken implements INbtWritable, IStreamable {
|
||||
@Override
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
data.writeEnum(state, State.VALUES);
|
||||
data.writeItemStack(tokenStack);
|
||||
if (tokenIndividual != null) {
|
||||
data.writeBoolean(true);
|
||||
data.writeUTF(tokenIndividual.getGenome().getPrimary().getUID());
|
||||
} else {
|
||||
data.writeBoolean(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
state = data.readEnum(State.VALUES);
|
||||
tokenStack = data.readItemStack();
|
||||
if (data.readBoolean()) {
|
||||
String speciesUid = data.readUTF();
|
||||
setTokenSpecies(speciesUid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,8 +12,8 @@ package forestry.lepidopterology.genetics;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
@@ -264,7 +264,7 @@ public class ButterflyRoot extends SpeciesRoot implements IButterflyRoot {
|
||||
}
|
||||
|
||||
/* MUTATIONS */
|
||||
private static final ArrayList<IButterflyMutation> butterflyMutations = new ArrayList<>();
|
||||
private static final List<IButterflyMutation> butterflyMutations = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void registerMutation(IMutation mutation) {
|
||||
@@ -282,7 +282,7 @@ public class ButterflyRoot extends SpeciesRoot implements IButterflyRoot {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<IButterflyMutation> getMutations(boolean shuffle) {
|
||||
public List<IButterflyMutation> getMutations(boolean shuffle) {
|
||||
if (shuffle) {
|
||||
Collections.shuffle(butterflyMutations);
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 199 B After Width: | Height: | Size: 202 B |
Reference in new issue
Block a user