mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-15 09:34:57 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
76f09be39d | ||
|
|
e6cb758e0e | ||
|
|
b3549edf51 | ||
|
|
e09d159935 | ||
|
|
4cb2610b1c | ||
|
|
c44f11cf09 | ||
|
|
b69c31ed8a | ||
|
|
6a2231f8fb | ||
|
|
a3a6c71c42 | ||
|
|
8d5c0c6f8b | ||
|
|
56603fd00c | ||
|
|
ed69411d2e | ||
|
|
e1d017f077 | ||
|
|
9269af7a13 | ||
|
|
8ffdba5021 | ||
|
|
e00aecd886 | ||
|
|
98f859f2fb | ||
|
|
55a15d23b2 | ||
|
|
307580aed8 | ||
|
|
d2d93004e0 | ||
|
|
e1df424bfd | ||
|
|
6a75347b05 | ||
|
|
cfd513ea80 | ||
|
|
edcc47a6b3 | ||
|
|
6593118f3d | ||
|
|
fd724d147a | ||
|
|
b2e1b2dc9b | ||
|
|
defc47000b | ||
|
|
0a37ad0666 | ||
|
|
13d4907bff | ||
|
|
78725009c1 | ||
|
|
a1bc9144bd | ||
|
|
b897056824 | ||
|
|
87563b6c97 | ||
|
|
62d6294da2 | ||
|
|
b4d71543db | ||
|
|
73db1a608a | ||
|
|
1c6b60122e | ||
|
|
1e7a042b53 | ||
|
|
bf08336bc5 |
No files matched your search
Executable → Regular
+10
-17
@@ -5,15 +5,17 @@ buildscript {
|
||||
}
|
||||
dependencies {
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
|
||||
classpath "gradle.plugin.se.bjurr.gitchangelog:git-changelog-gradle-plugin:1.47"
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id "com.matthewprenger.cursegradle" version "1.0.9"
|
||||
id "se.bjurr.gitchangelog.git-changelog-gradle-plugin" version "1.32"
|
||||
}
|
||||
apply plugin: 'net.minecraftforge.gradle.forge'
|
||||
apply plugin: 'idea'
|
||||
apply plugin: 'maven'
|
||||
apply plugin: "se.bjurr.gitchangelog.git-changelog-gradle-plugin"
|
||||
|
||||
version = version_major + '.' + version_minor + '.' + version_patch + '.' + getBuildNumber()
|
||||
if (project.hasProperty('buildQualifier')) {
|
||||
@@ -60,9 +62,9 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
deobfCompile "net.darkhax.tesla:Tesla-${mcversion}:${tesla_version}"
|
||||
deobfCompile "mezz.jei:jei_${mcversion}:${jei_version}:api"
|
||||
runtime "mezz.jei:jei_${mcversion}:${jei_version}"
|
||||
deobfCompile "net.darkhax.tesla:Tesla-${tesla_mcversion}:${tesla_version}"
|
||||
deobfCompile "mezz.jei:jei_${jei_mcversion}:${jei_version}:api"
|
||||
runtime "mezz.jei:jei_${jei_mcversion}:${jei_version}"
|
||||
deobfCompile "net.industrial-craft:industrialcraft-2:${ic2_version}:api"
|
||||
}
|
||||
|
||||
@@ -149,26 +151,17 @@ task makeChangelog(type: se.bjurr.gitchangelog.plugin.gradle.GitChangelogTask) {
|
||||
untaggedName = "Current release ${project.version}"
|
||||
fromCommit = "5a3850c2642e535656d090d1473054d5fa8d3331"
|
||||
toRef = "HEAD"
|
||||
templateContent = """
|
||||
Please help the Forestry project by <a href="https://github.com/ForestryMC/ForestryMC/issues">reporting issues here.</a><br/>
|
||||
{{#tags}}
|
||||
<h3>{{name}}</h3>
|
||||
<ul>
|
||||
{{#commits}}
|
||||
<li>{{{message}}} - {{authorName}}</li>
|
||||
{{/commits}}
|
||||
</ul>
|
||||
{{/tags}}
|
||||
"""
|
||||
templateContent = file('changelog.mustache').getText('UTF-8')
|
||||
}
|
||||
|
||||
curseforge {
|
||||
apiKey = project.hasProperty('curseforge_apikey') ? project.curseforge_apikey : '0'
|
||||
project {
|
||||
id = '59751'
|
||||
id = curse_project_id
|
||||
changelog = file('changelog.html')
|
||||
changelogType = 'html'
|
||||
releaseType = 'alpha'
|
||||
releaseType = 'beta'
|
||||
addGameVersion '1.12'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
Please help the Forestry project by <a href="https://github.com/ForestryMC/ForestryMC/issues">reporting issues here.</a><br/>
|
||||
{{#tags}}
|
||||
<h3>{{name}}</h3>
|
||||
<ul>
|
||||
{{#commits}}
|
||||
<li>{{{message}}} - {{authorName}}</li>
|
||||
{{/commits}}
|
||||
</ul>
|
||||
{{/tags}}
|
||||
+10
-7
@@ -1,11 +1,14 @@
|
||||
mcversion=1.12
|
||||
forgeversion=14.21.1.2395
|
||||
mcp_mappings=snapshot_20170703
|
||||
mcversion=1.12.1
|
||||
forgeversion=14.22.0.2462
|
||||
mcp_mappings=snapshot_20170826
|
||||
curse_project_id=59751
|
||||
|
||||
tesla_version=1.0.60
|
||||
jei_version=4.7.0.67
|
||||
ic2_version=2.7.30-ex111
|
||||
tesla_mcversion=1.12
|
||||
jei_version=4.7.8.91
|
||||
jei_mcversion=1.12.1
|
||||
ic2_version=2.8.17-ex112
|
||||
|
||||
version_major=5
|
||||
version_minor=4
|
||||
version_patch=3
|
||||
version_minor=5
|
||||
version_patch=1
|
||||
+1
-1
Submodule lang updated: f5300f059b...192d6f8584.
@@ -15,12 +15,11 @@ import com.google.common.base.Preconditions;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
import forestry.plugins.compat.PluginNatura;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventHandler;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
@@ -29,6 +28,7 @@ import net.minecraftforge.fml.common.event.FMLInterModComms.IMCEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
@@ -44,7 +44,6 @@ import forestry.core.gui.GuiHandler;
|
||||
import forestry.core.multiblock.MultiblockEventHandler;
|
||||
import forestry.core.network.PacketHandler;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.MigrationHelper;
|
||||
import forestry.core.worldgen.WorldGenerator;
|
||||
import forestry.plugins.PluginManager;
|
||||
import forestry.plugins.compat.PluginIC2;
|
||||
@@ -59,10 +58,11 @@ import forestry.plugins.compat.PluginIC2;
|
||||
name = Constants.MOD_NAME,
|
||||
version = Constants.VERSION,
|
||||
guiFactory = "forestry.core.config.ForestryGuiConfigFactory",
|
||||
acceptedMinecraftVersions = "[1.12]",
|
||||
acceptedMinecraftVersions = "[1.12, 1.12.1]",
|
||||
dependencies = "required-after:forge@[14.21.1.2395,);"
|
||||
+ "after:JEI@[4.7.0,);"
|
||||
+ "after:" + PluginIC2.modId + ";")
|
||||
+ "after:jei@[4.7.0,);"
|
||||
+ "after:" + PluginIC2.modId + ";"
|
||||
+ "after:" + PluginNatura.modId + ";")
|
||||
public class Forestry {
|
||||
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@@ -77,6 +77,7 @@ public class Forestry {
|
||||
ForestryAPI.errorStateRegistry = new ErrorStateRegistry();
|
||||
EnumErrorCode.init();
|
||||
FluidRegistry.enableUniversalBucket();
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -109,6 +110,11 @@ public class Forestry {
|
||||
|
||||
PluginManager.runPreInit(event.getSide());
|
||||
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void registerModels(ModelRegistryEvent event) {
|
||||
PluginManager.runRegisterBackpacksAndCrates();
|
||||
Proxies.render.registerModels();
|
||||
}
|
||||
|
||||
@@ -151,14 +157,4 @@ public class Forestry {
|
||||
public void processIMCMessages(IMCEvent event) {
|
||||
PluginManager.processIMCMessages(event.getMessages());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMissingBlockMappings(RegistryEvent.MissingMappings<Block> event) {
|
||||
MigrationHelper.onMissingBlockMappings(event);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMissingItemMappings(RegistryEvent.MissingMappings<Item> event) {
|
||||
MigrationHelper.onMissingItemMappings(event);
|
||||
}
|
||||
}
|
||||
@@ -20,5 +20,18 @@ public interface IHiveFrame {
|
||||
*/
|
||||
ItemStack frameUsed(IBeeHousing housing, ItemStack frame, IBee queen, int wear);
|
||||
|
||||
/**
|
||||
* @param frame ItemStack containing the actual frame.
|
||||
* @return the {@link IBeeModifier} for this frame.
|
||||
* @since Forestry 5.5.1
|
||||
*/
|
||||
default IBeeModifier getBeeModifier(ItemStack frame) {
|
||||
return getBeeModifier();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Forestry 5.5.1. Use {@link #getBeeModifier(ItemStack)}
|
||||
*/
|
||||
@Deprecated
|
||||
IBeeModifier getBeeModifier();
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import java.util.List;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IChromosome;
|
||||
import forestry.api.genetics.IFruitFamily;
|
||||
import forestry.api.genetics.ISpeciesRootPollinatable;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -101,4 +102,6 @@ public interface ITreeRoot extends ISpeciesRootPollinatable {
|
||||
/* MUTATIONS */
|
||||
@Override
|
||||
List<ITreeMutation> getMutations(boolean shuffle);
|
||||
|
||||
Collection<IFruitProvider> getFruitProvidersForFruitFamily(IFruitFamily fruitFamily);
|
||||
}
|
||||
@@ -7,6 +7,7 @@ package forestry.api.farming;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@@ -33,6 +34,8 @@ public interface IFarmLogic {
|
||||
|
||||
IFarmLogic setManual(boolean manual);
|
||||
|
||||
void addSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
ResourceLocation getTextureMap();
|
||||
|
||||
|
||||
@@ -11,6 +11,13 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IFarmRegistry {
|
||||
|
||||
/**
|
||||
* Registers farming logic in registry under given identifier
|
||||
* @param identifier Valid identifiers: farmArboreal farmWheat farmGourd farmInfernal farmPoales farmSucculentes farmVegetables farmShroom
|
||||
* @param logic corresponding instance of logic
|
||||
*/
|
||||
void registerFarmLogic(String identifier, IFarmLogic logic);
|
||||
|
||||
/**
|
||||
* Can be used to add IFarmables to some of the vanilla farm logics.
|
||||
* <p>
|
||||
|
||||
@@ -33,6 +33,7 @@ import net.minecraft.potion.PotionUtils;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.DimensionType;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.gen.IChunkGenerator;
|
||||
@@ -45,6 +46,8 @@ import net.minecraftforge.common.brewing.BrewingRecipeRegistry;
|
||||
import net.minecraftforge.common.capabilities.CapabilityManager;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.event.FMLInterModComms.IMCMessage;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
@@ -53,7 +56,6 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.common.registry.VillagerRegistry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
|
||||
import forestry.Forestry;
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
@@ -494,13 +496,14 @@ public class PluginApiculture extends BlankForestryPlugin {
|
||||
"C",
|
||||
'B', new ItemStack(blocks.apiary),
|
||||
'C', Items.MINECART);
|
||||
for(int i = 0;i < blocks.beeCombs.length;i++){
|
||||
BlockHoneyComb block = blocks.beeCombs[i];
|
||||
for(int m = 0;m < EnumHoneyComb.VALUES.length - i * 16;m++){
|
||||
RecipeUtil.addRecipe("comb." + m, new ItemStack(block, 1, m),
|
||||
for(int blockCount = 0;blockCount < blocks.beeCombs.length;blockCount++){
|
||||
BlockHoneyComb block = blocks.beeCombs[blockCount];
|
||||
for(int blockMeta = 0;blockMeta < EnumHoneyComb.VALUES.length - blockCount * 16;blockMeta++){
|
||||
int itemMeta = blockMeta + blockCount * 16;
|
||||
RecipeUtil.addRecipe("comb." + itemMeta, new ItemStack(block, 1, blockMeta),
|
||||
"###",
|
||||
"###",
|
||||
"###", '#', items.beeComb.get(EnumHoneyComb.get(i * 16 + m), 1));
|
||||
"###", '#', items.beeComb.get(EnumHoneyComb.get(itemMeta), 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -899,8 +902,18 @@ public class PluginApiculture extends BlankForestryPlugin {
|
||||
|
||||
@Override
|
||||
public void populateChunk(IChunkGenerator chunkGenerator, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated) {
|
||||
if(!world.provider.getDimensionType().equals(DimensionType.THE_END)) return;
|
||||
if (Config.getBeehivesAmount() > 0.0) {
|
||||
HiveDecorator.decorateHives(chunkGenerator, world, rand, chunkX, chunkZ, hasVillageGenerated);
|
||||
HiveDecorator.decorateHives(world, rand, chunkX, chunkZ);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decorateBiome(World world, Random rand, BlockPos pos) {
|
||||
if (Config.getBeehivesAmount() > 0.0) {
|
||||
int chunkX = pos.getX() >> 4;
|
||||
int chunkZ = pos.getZ() >> 4;
|
||||
HiveDecorator.decorateHives(world, rand, chunkX, chunkZ);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ package forestry.apiculture.blocks;
|
||||
import java.util.Map;
|
||||
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.apiculture.items.ItemBlockHoneyComb;
|
||||
import forestry.apiculture.items.ItemBlockCandle;
|
||||
import forestry.apiculture.items.ItemBlockHoneyComb;
|
||||
import forestry.core.blocks.BlockBase;
|
||||
import forestry.core.blocks.BlockRegistry;
|
||||
import forestry.core.items.ItemBlockForestry;
|
||||
@@ -33,23 +33,23 @@ public class BlockRegistryApiculture extends BlockRegistry {
|
||||
|
||||
public BlockRegistryApiculture() {
|
||||
apiary = new BlockApiculture(BlockTypeApiculture.APIARY);
|
||||
registerBlock(apiary, new ItemBlockForestry(apiary), "apiary");
|
||||
registerBlock(apiary, new ItemBlockForestry<>(apiary), "apiary");
|
||||
|
||||
beeHouse = new BlockApiculture(BlockTypeApiculture.BEE_HOUSE);
|
||||
registerBlock(beeHouse, new ItemBlockForestry(beeHouse), "bee_house");
|
||||
registerBlock(beeHouse, new ItemBlockForestry<>(beeHouse), "bee_house");
|
||||
|
||||
beeChest = new BlockBase<>(BlockTypeApicultureTesr.APIARIST_CHEST, Material.WOOD);
|
||||
registerBlock(beeChest, new ItemBlockForestry(beeChest), "bee_chest");
|
||||
registerBlock(beeChest, new ItemBlockForestry<>(beeChest), "bee_chest");
|
||||
beeChest.setCreativeTab(Tabs.tabApiculture);
|
||||
beeChest.setHarvestLevel("axe", 0);
|
||||
|
||||
beehives = new BlockBeeHives();
|
||||
registerBlock(beehives, new ItemBlockForestry(beehives), "beehives");
|
||||
registerBlock(beehives, new ItemBlockForestry<>(beehives), "beehives");
|
||||
|
||||
candle = new BlockCandle();
|
||||
registerBlock(candle, new ItemBlockCandle(candle), "candle");
|
||||
stump = new BlockStump();
|
||||
registerBlock(stump, new ItemBlockForestry(stump), "stump");
|
||||
registerBlock(stump, new ItemBlockForestry<>(stump), "stump");
|
||||
|
||||
beeCombs = BlockHoneyComb.create();
|
||||
for(int i = 0;i < beeCombs.length;i++){
|
||||
@@ -59,7 +59,7 @@ public class BlockRegistryApiculture extends BlockRegistry {
|
||||
|
||||
alvearyBlockMap = BlockAlveary.create();
|
||||
for (BlockAlveary block : alvearyBlockMap.values()) {
|
||||
registerBlock(block, new ItemBlockForestry(block), "alveary." + block.getAlvearyType());
|
||||
registerBlock(block, new ItemBlockForestry<>(block), "alveary." + block.getAlvearyType());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ public class ApicultureJeiPlugin implements IModPlugin {
|
||||
|
||||
ISubtypeRegistry.ISubtypeInterpreter beeSubtypeInterpreter = itemStack -> {
|
||||
IAlleleSpecies species = Genome.getSpeciesDirectly(BeeManager.beeRoot, itemStack);
|
||||
return species == null ? null : species.getUID();
|
||||
return species == null ? ISubtypeRegistry.ISubtypeInterpreter.NONE : species.getUID();
|
||||
};
|
||||
|
||||
subtypeRegistry.registerSubtypeInterpreter(items.beeDroneGE, beeSubtypeInterpreter);
|
||||
|
||||
@@ -33,6 +33,7 @@ import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Tuple;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
@@ -89,8 +90,11 @@ public class EntityMinecartApiary extends EntityMinecartBeeHousingBase implement
|
||||
|
||||
beeModifiers.add(beeModifier);
|
||||
|
||||
for (IHiveFrame frame : inventory.getFrames()) {
|
||||
beeModifiers.add(frame.getBeeModifier());
|
||||
for (Tuple<IHiveFrame, ItemStack> frame : inventory.getFrames()) {
|
||||
IHiveFrame hiveFrame = frame.getFirst();
|
||||
ItemStack stack = frame.getSecond();
|
||||
IBeeModifier beeModifier = hiveFrame.getBeeModifier(stack);
|
||||
beeModifiers.add(beeModifier);
|
||||
}
|
||||
|
||||
return beeModifiers;
|
||||
|
||||
@@ -22,6 +22,7 @@ import forestry.apiculture.InventoryBeeHousing;
|
||||
import forestry.core.utils.SlotUtil;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Tuple;
|
||||
|
||||
public class InventoryApiary extends InventoryBeeHousing implements IApiaryInventory {
|
||||
public static final int SLOT_FRAMES_1 = 9;
|
||||
@@ -47,14 +48,15 @@ public class InventoryApiary extends InventoryBeeHousing implements IApiaryInven
|
||||
super.isItemValidForSlot(slotIndex, itemStack);
|
||||
}
|
||||
|
||||
public Collection<IHiveFrame> getFrames() {
|
||||
Collection<IHiveFrame> hiveFrames = new ArrayList<>(SLOT_FRAMES_COUNT);
|
||||
public Collection<Tuple<IHiveFrame, ItemStack>> getFrames() {
|
||||
Collection<Tuple<IHiveFrame, ItemStack>> hiveFrames = new ArrayList<>(SLOT_FRAMES_COUNT);
|
||||
|
||||
for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) {
|
||||
ItemStack stackInSlot = getStackInSlot(i);
|
||||
Item itemInSlot = stackInSlot.getItem();
|
||||
if (itemInSlot instanceof IHiveFrame) {
|
||||
hiveFrames.add((IHiveFrame) itemInSlot);
|
||||
IHiveFrame frame = (IHiveFrame) itemInSlot;
|
||||
hiveFrames.add(new Tuple<>(frame, stackInSlot.copy()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ package forestry.apiculture.items;
|
||||
import forestry.apiculture.blocks.BlockCandle;
|
||||
import forestry.core.items.IColoredItem;
|
||||
import forestry.core.items.ItemBlockForestry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
@@ -21,7 +20,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemBlockCandle extends ItemBlockForestry<BlockCandle> implements IColoredItem {
|
||||
|
||||
public ItemBlockCandle(Block block) {
|
||||
public ItemBlockCandle(BlockCandle block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,14 +3,13 @@ package forestry.apiculture.items;
|
||||
import forestry.apiculture.blocks.BlockHoneyComb;
|
||||
import forestry.core.items.IColoredItem;
|
||||
import forestry.core.items.ItemBlockForestry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemBlockHoneyComb extends ItemBlockForestry<BlockHoneyComb> implements IColoredItem {
|
||||
|
||||
public ItemBlockHoneyComb(Block block) {
|
||||
public ItemBlockHoneyComb(BlockHoneyComb block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,11 @@ public class ItemHiveFrame extends ItemForestry implements IHiveFrame {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBeeModifier getBeeModifier(ItemStack frame) {
|
||||
return beeModifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBeeModifier getBeeModifier() {
|
||||
return beeModifier;
|
||||
|
||||
@@ -29,6 +29,8 @@ import forestry.apiculture.inventory.InventoryApiary;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Tuple;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -58,8 +60,11 @@ public class TileApiary extends TileBeeHousingBase implements IApiary {
|
||||
|
||||
beeModifiers.add(beeModifier);
|
||||
|
||||
for (IHiveFrame frame : inventory.getFrames()) {
|
||||
beeModifiers.add(frame.getBeeModifier());
|
||||
for (Tuple<IHiveFrame, ItemStack> frame : inventory.getFrames()) {
|
||||
IHiveFrame hiveFrame = frame.getFirst();
|
||||
ItemStack stack = frame.getSecond();
|
||||
IBeeModifier beeModifier = hiveFrame.getBeeModifier(stack);
|
||||
beeModifiers.add(beeModifier);
|
||||
}
|
||||
|
||||
return beeModifiers;
|
||||
|
||||
@@ -142,6 +142,14 @@ public abstract class BlockForestryLog<T extends Enum<T> & IWoodType> extends Bl
|
||||
return woodType.getHardness();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack getSilkTouchDrop(IBlockState state) {
|
||||
ItemStack silkTouchDrop = super.getSilkTouchDrop(state);
|
||||
int damage = this.damageDropped(state);
|
||||
silkTouchDrop.setItemDamage(damage);
|
||||
return silkTouchDrop;
|
||||
}
|
||||
|
||||
/* PROPERTIES */
|
||||
@Override
|
||||
public final int getFireSpreadSpeed(IBlockAccess world, BlockPos pos, EnumFacing face) {
|
||||
|
||||
@@ -32,7 +32,6 @@ import forestry.core.blocks.BlockRegistry;
|
||||
import forestry.core.items.ItemBlockForestry;
|
||||
import forestry.core.utils.OreDictUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockLeaves;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
@@ -79,37 +78,37 @@ public class BlockRegistryArboriculture extends BlockRegistry {
|
||||
// Wood blocks
|
||||
logs = BlockArbLog.create(false);
|
||||
for (BlockArbLog block : logs) {
|
||||
registerBlock(block, new ItemBlockWood(block), "logs." + block.getBlockNumber());
|
||||
registerBlock(block, new ItemBlockWood<>(block), "logs." + block.getBlockNumber());
|
||||
registerOreDictWildcard(OreDictUtil.LOG_WOOD, block);
|
||||
}
|
||||
|
||||
logsFireproof = BlockArbLog.create(true);
|
||||
for (BlockArbLog block : logsFireproof) {
|
||||
registerBlock(block, new ItemBlockWood(block), "logs.fireproof." + block.getBlockNumber());
|
||||
registerBlock(block, new ItemBlockWood<>(block), "logs.fireproof." + block.getBlockNumber());
|
||||
registerOreDictWildcard(OreDictUtil.LOG_WOOD, block);
|
||||
}
|
||||
|
||||
logsVanillaFireproof = BlockFireproofVanillaLog.create();
|
||||
for (BlockFireproofVanillaLog block : logsVanillaFireproof) {
|
||||
registerBlock(block, new ItemBlockWood(block), "logs.vanilla.fireproof." + block.getBlockNumber());
|
||||
registerBlock(block, new ItemBlockWood<>(block), "logs.vanilla.fireproof." + block.getBlockNumber());
|
||||
registerOreDictWildcard(OreDictUtil.LOG_WOOD, block);
|
||||
}
|
||||
|
||||
planks = BlockArbPlanks.create(false);
|
||||
for (BlockArbPlanks block : planks) {
|
||||
registerBlock(block, new ItemBlockWood(block), "planks." + block.getBlockNumber());
|
||||
registerBlock(block, new ItemBlockWood<>(block), "planks." + block.getBlockNumber());
|
||||
registerOreDictWildcard(OreDictUtil.PLANK_WOOD, block);
|
||||
}
|
||||
|
||||
planksFireproof = BlockArbPlanks.create(true);
|
||||
for (BlockArbPlanks block : planksFireproof) {
|
||||
registerBlock(block, new ItemBlockWood(block), "planks.fireproof." + block.getBlockNumber());
|
||||
registerBlock(block, new ItemBlockWood<>(block), "planks.fireproof." + block.getBlockNumber());
|
||||
registerOreDictWildcard(OreDictUtil.PLANK_WOOD, block);
|
||||
}
|
||||
|
||||
planksVanillaFireproof = BlockFireproofVanillaPlanks.create();
|
||||
for (BlockFireproofVanillaPlanks block : planksVanillaFireproof) {
|
||||
registerBlock(block, new ItemBlockWood(block), "planks.vanilla.fireproof." + block.getBlockNumber());
|
||||
registerBlock(block, new ItemBlockWood<>(block), "planks.vanilla.fireproof." + block.getBlockNumber());
|
||||
registerOreDictWildcard(OreDictUtil.PLANK_WOOD, block);
|
||||
}
|
||||
|
||||
@@ -145,19 +144,19 @@ public class BlockRegistryArboriculture extends BlockRegistry {
|
||||
|
||||
fences = BlockArbFence.create(false);
|
||||
for (BlockArbFence block : fences) {
|
||||
registerBlock(block, new ItemBlockWood(block), "fences." + block.getBlockNumber());
|
||||
registerBlock(block, new ItemBlockWood<>(block), "fences." + block.getBlockNumber());
|
||||
registerOreDictWildcard(OreDictUtil.FENCE_WOOD, block);
|
||||
}
|
||||
|
||||
fencesFireproof = BlockArbFence.create(true);
|
||||
for (BlockArbFence block : fencesFireproof) {
|
||||
registerBlock(block, new ItemBlockWood(block), "fences.fireproof." + block.getBlockNumber());
|
||||
registerBlock(block, new ItemBlockWood<>(block), "fences.fireproof." + block.getBlockNumber());
|
||||
registerOreDictWildcard(OreDictUtil.FENCE_WOOD, block);
|
||||
}
|
||||
|
||||
fencesVanillaFireproof = BlockFireproofVanillaFence.create();
|
||||
for (BlockFireproofVanillaFence block : fencesVanillaFireproof) {
|
||||
registerBlock(block, new ItemBlockWood(block), "fences.vanilla.fireproof." + block.getBlockNumber());
|
||||
registerBlock(block, new ItemBlockWood<>(block), "fences.vanilla.fireproof." + block.getBlockNumber());
|
||||
registerOreDictWildcard(OreDictUtil.FENCE_WOOD, block);
|
||||
}
|
||||
|
||||
@@ -165,12 +164,12 @@ public class BlockRegistryArboriculture extends BlockRegistry {
|
||||
fenceGatesFireproof = new ArrayList<>();
|
||||
for (EnumForestryWoodType woodType : EnumForestryWoodType.VALUES) {
|
||||
BlockForestryFenceGate fenceGate = new BlockForestryFenceGate<>(false, woodType);
|
||||
registerBlock(fenceGate, new ItemBlockWood(fenceGate), "fence.gates." + woodType);
|
||||
registerBlock(fenceGate, new ItemBlockWood<>(fenceGate), "fence.gates." + woodType);
|
||||
registerOreDictWildcard(OreDictUtil.FENCE_GATE_WOOD, fenceGate);
|
||||
fenceGates.add(fenceGate);
|
||||
|
||||
BlockForestryFenceGate fenceGateFireproof = new BlockForestryFenceGate<>(true, woodType);
|
||||
registerBlock(fenceGateFireproof, new ItemBlockWood(fenceGateFireproof), "fence.gates.fireproof." + woodType);
|
||||
registerBlock(fenceGateFireproof, new ItemBlockWood<>(fenceGateFireproof), "fence.gates.fireproof." + woodType);
|
||||
registerOreDictWildcard(OreDictUtil.FENCE_GATE_WOOD, fenceGateFireproof);
|
||||
fenceGatesFireproof.add(fenceGateFireproof);
|
||||
}
|
||||
@@ -178,7 +177,7 @@ public class BlockRegistryArboriculture extends BlockRegistry {
|
||||
fenceGatesVanillaFireproof = new ArrayList<>();
|
||||
for (EnumVanillaWoodType woodType : EnumVanillaWoodType.VALUES) {
|
||||
BlockForestryFenceGate fenceGateFireproof = new BlockForestryFenceGate<>(true, woodType);
|
||||
registerBlock(fenceGateFireproof, new ItemBlockWood(fenceGateFireproof), "fence.gates.vanilla.fireproof." + woodType);
|
||||
registerBlock(fenceGateFireproof, new ItemBlockWood<>(fenceGateFireproof), "fence.gates.vanilla.fireproof." + woodType);
|
||||
registerOreDictWildcard(OreDictUtil.FENCE_GATE_WOOD, fenceGateFireproof);
|
||||
fenceGatesFireproof.add(fenceGateFireproof);
|
||||
}
|
||||
@@ -190,7 +189,7 @@ public class BlockRegistryArboriculture extends BlockRegistry {
|
||||
EnumForestryWoodType woodType = plank.getWoodType(meta);
|
||||
|
||||
BlockForestryStairs stair = new BlockForestryStairs<>(false, blockState, woodType);
|
||||
registerBlock(stair, new ItemBlockWood(stair), "stairs." + woodType);
|
||||
registerBlock(stair, new ItemBlockWood<>(stair), "stairs." + woodType);
|
||||
registerOreDictWildcard(OreDictUtil.STAIR_WOOD, stair);
|
||||
stairs.add(stair);
|
||||
}
|
||||
@@ -203,7 +202,7 @@ public class BlockRegistryArboriculture extends BlockRegistry {
|
||||
EnumForestryWoodType woodType = plank.getWoodType(meta);
|
||||
|
||||
BlockForestryStairs stair = new BlockForestryStairs<>(true, blockState, woodType);
|
||||
registerBlock(stair, new ItemBlockWood(stair), "stairs.fireproof." + woodType);
|
||||
registerBlock(stair, new ItemBlockWood<>(stair), "stairs.fireproof." + woodType);
|
||||
registerOreDictWildcard(OreDictUtil.STAIR_WOOD, stair);
|
||||
stairsFireproof.add(stair);
|
||||
}
|
||||
@@ -216,7 +215,7 @@ public class BlockRegistryArboriculture extends BlockRegistry {
|
||||
EnumVanillaWoodType woodType = plank.getWoodType(meta);
|
||||
|
||||
BlockForestryStairs stair = new BlockForestryStairs<>(true, blockState, woodType);
|
||||
registerBlock(stair, new ItemBlockWood(stair), "stairs.vanilla.fireproof." + woodType);
|
||||
registerBlock(stair, new ItemBlockWood<>(stair), "stairs.vanilla.fireproof." + woodType);
|
||||
registerOreDictWildcard(OreDictUtil.STAIR_WOOD, stair);
|
||||
stairsVanillaFireproof.add(stair);
|
||||
}
|
||||
@@ -233,7 +232,7 @@ public class BlockRegistryArboriculture extends BlockRegistry {
|
||||
// Saplings
|
||||
TreeDefinition.preInit();
|
||||
saplingGE = new BlockSapling();
|
||||
registerBlock(saplingGE, new ItemBlockForestry(saplingGE), "sapling_ge");
|
||||
registerBlock(saplingGE, new ItemBlockForestry<>(saplingGE), "sapling_ge");
|
||||
registerOreDictWildcard(OreDictUtil.TREE_SAPLING, saplingGE);
|
||||
|
||||
// Leaves
|
||||
@@ -271,7 +270,7 @@ public class BlockRegistryArboriculture extends BlockRegistry {
|
||||
}
|
||||
|
||||
charcoal = new BlockCharcoal();
|
||||
ItemBlockForestry itemBlockCharcoal = new ItemBlockForestry(charcoal) {
|
||||
ItemBlockForestry itemBlockCharcoal = new ItemBlockForestry<BlockCharcoal>(charcoal) {
|
||||
@Override
|
||||
public int getItemBurnTime(ItemStack itemStack) {
|
||||
return 16000;
|
||||
@@ -280,7 +279,7 @@ public class BlockRegistryArboriculture extends BlockRegistry {
|
||||
registerBlock(charcoal, itemBlockCharcoal, "charcoal");
|
||||
|
||||
woodPile = new BlockWoodPile();
|
||||
ItemBlockForestry itemBlockWoodPile = new ItemBlockForestry(woodPile) {
|
||||
ItemBlockForestry itemBlockWoodPile = new ItemBlockForestry<BlockWoodPile>(woodPile) {
|
||||
@Override
|
||||
public int getItemBurnTime(ItemStack itemStack) {
|
||||
return 1200;
|
||||
@@ -289,11 +288,11 @@ public class BlockRegistryArboriculture extends BlockRegistry {
|
||||
registerBlock(woodPile, itemBlockWoodPile, "wood_pile");
|
||||
|
||||
loam = new BlockLoam();
|
||||
registerBlock(loam, new ItemBlockForestry(loam), "loam");
|
||||
registerBlock(loam, new ItemBlockForestry<>(loam), "loam");
|
||||
|
||||
// Pods
|
||||
AlleleFruits.registerAlleles();
|
||||
MinecraftForge.EVENT_BUS.post(new AlleleRegisterEvent(IAlleleFruit.class));
|
||||
MinecraftForge.EVENT_BUS.post(new AlleleRegisterEvent<>(IAlleleFruit.class));
|
||||
podsMap = new HashMap<>();
|
||||
for (BlockFruitPod pod : BlockFruitPod.create()) {
|
||||
IAlleleFruit fruit = pod.getFruit();
|
||||
@@ -303,7 +302,7 @@ public class BlockRegistryArboriculture extends BlockRegistry {
|
||||
|
||||
// Machines
|
||||
treeChest = new BlockArboriculture(BlockTypeArboricultureTesr.ARB_CHEST);
|
||||
registerBlock(treeChest, new ItemBlockForestry(treeChest), "tree_chest");
|
||||
registerBlock(treeChest, new ItemBlockForestry<>(treeChest), "tree_chest");
|
||||
}
|
||||
|
||||
public ItemStack getDecorativeLeaves(String speciesUid) {
|
||||
|
||||
@@ -152,7 +152,10 @@ public class BlockSapling extends BlockTreeContainer implements IGrowable, IStat
|
||||
/* REMOVING */
|
||||
@Override
|
||||
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
|
||||
ItemStack drop = getDrop(world, pos);
|
||||
if (!drop.isEmpty()) {
|
||||
drops.add(drop);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -179,13 +182,21 @@ public class BlockSapling extends BlockTreeContainer implements IGrowable, IStat
|
||||
if (world.isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
TileSapling sapling = TileUtil.getTile(world, pos, TileSapling.class);
|
||||
if (sapling != null && sapling.getTree() != null) {
|
||||
ItemStack saplingStack = TreeManager.treeRoot.getMemberStack(sapling.getTree(), EnumGermlingType.SAPLING);
|
||||
ItemStackUtil.dropItemStackAsEntity(saplingStack, world, pos);
|
||||
ItemStack drop = getDrop(world, pos);
|
||||
if (!drop.isEmpty()) {
|
||||
ItemStackUtil.dropItemStackAsEntity(drop, world, pos);
|
||||
}
|
||||
}
|
||||
|
||||
private static ItemStack getDrop(IBlockAccess world, BlockPos pos) {
|
||||
TileSapling sapling = TileUtil.getTile(world, pos, TileSapling.class);
|
||||
if (sapling != null) {
|
||||
ITree tree = sapling.getTree();
|
||||
if (tree != null) {
|
||||
return TreeManager.treeRoot.getMemberStack(tree, EnumGermlingType.SAPLING);
|
||||
}
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
/* GROWNING */
|
||||
|
||||
@@ -14,9 +14,11 @@ import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
@@ -26,6 +28,7 @@ import forestry.api.arboriculture.EnumTreeChromosome;
|
||||
import forestry.api.arboriculture.IAlleleFruit;
|
||||
import forestry.api.arboriculture.IAlleleTreeSpecies;
|
||||
import forestry.api.arboriculture.IArboristTracker;
|
||||
import forestry.api.arboriculture.IFruitProvider;
|
||||
import forestry.api.arboriculture.ILeafTickHandler;
|
||||
import forestry.api.arboriculture.ITree;
|
||||
import forestry.api.arboriculture.ITreeGenome;
|
||||
@@ -38,6 +41,7 @@ import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IAlyzerPlugin;
|
||||
import forestry.api.genetics.ICheckPollinatable;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.genetics.IFruitFamily;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IMutation;
|
||||
import forestry.api.genetics.IPollinatable;
|
||||
@@ -75,6 +79,7 @@ public class TreeRoot extends SpeciesRoot implements ITreeRoot {
|
||||
private static ITreekeepingMode activeTreekeepingMode;
|
||||
public static final List<ITree> treeTemplates = new ArrayList<>();
|
||||
|
||||
private final Map<IFruitFamily, Collection<IFruitProvider>> providersForFamilies = new HashMap<>();
|
||||
private final List<ITreekeepingMode> treekeepingModes = new ArrayList<>();
|
||||
|
||||
public TreeRoot() {
|
||||
@@ -154,7 +159,6 @@ public class TreeRoot extends SpeciesRoot implements ITreeRoot {
|
||||
@Override
|
||||
@Nullable
|
||||
public ITree getMember(ItemStack itemstack) {
|
||||
itemstack = GeneticsUtil.convertToGeneticEquivalent(itemstack);
|
||||
if (!isMember(itemstack) || itemstack.getTagCompound() == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -440,4 +444,18 @@ public class TreeRoot extends SpeciesRoot implements ITreeRoot {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<IFruitProvider> getFruitProvidersForFruitFamily(IFruitFamily fruitFamily) {
|
||||
if (providersForFamilies.isEmpty()) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Collection<IAlleleFruit> fruitAlleles = (Collection<IAlleleFruit>) (Object) AlleleManager.alleleRegistry.getRegisteredAlleles(EnumTreeChromosome.FRUITS);
|
||||
for (IAlleleFruit alleleFruit : fruitAlleles) {
|
||||
IFruitProvider fruitProvider = alleleFruit.getProvider();
|
||||
Collection<IFruitProvider> fruitProviders = providersForFamilies.computeIfAbsent(fruitProvider.getFamily(), k -> new ArrayList<>());
|
||||
fruitProviders.add(fruitProvider);
|
||||
}
|
||||
}
|
||||
|
||||
return providersForFamilies.computeIfAbsent(fruitFamily, k -> new ArrayList<>());
|
||||
}
|
||||
}
|
||||
@@ -11,12 +11,16 @@
|
||||
package forestry.arboriculture.genetics.alleles;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import forestry.api.arboriculture.EnumGermlingType;
|
||||
import forestry.api.arboriculture.EnumTreeChromosome;
|
||||
import forestry.api.arboriculture.IAlleleFruit;
|
||||
import forestry.api.arboriculture.IAlleleTreeSpecies;
|
||||
import forestry.api.arboriculture.IAlleleTreeSpeciesBuilder;
|
||||
import forestry.api.arboriculture.IFruitProvider;
|
||||
import forestry.api.arboriculture.IGermlingModelProvider;
|
||||
import forestry.api.arboriculture.IGrowthProvider;
|
||||
import forestry.api.arboriculture.ILeafProvider;
|
||||
@@ -27,6 +31,7 @@ import forestry.api.arboriculture.IWoodProvider;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IClassification;
|
||||
import forestry.api.genetics.IFruitFamily;
|
||||
import forestry.arboriculture.genetics.ClimateGrowthProvider;
|
||||
@@ -34,6 +39,7 @@ import forestry.arboriculture.genetics.LeafProvider;
|
||||
import forestry.core.genetics.alleles.AlleleSpecies;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
@@ -196,6 +202,34 @@ public class AlleleTreeSpecies extends AlleleSpecies implements IAlleleTreeSpeci
|
||||
return modID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getResearchSuitability(ItemStack itemstack) {
|
||||
if (itemstack.isEmpty()) {
|
||||
return 0f;
|
||||
}
|
||||
|
||||
List<IFruitFamily> suitableFruit = getSuitableFruit();
|
||||
for (IFruitFamily fruitFamily : suitableFruit) {
|
||||
Collection<IFruitProvider> fruitProviders = TreeManager.treeRoot.getFruitProvidersForFruitFamily(fruitFamily);
|
||||
for (IFruitProvider fruitProvider : fruitProviders) {
|
||||
Map<ItemStack, Float> products = fruitProvider.getProducts();
|
||||
for (ItemStack stack : products.keySet()) {
|
||||
if (stack.isItemEqual(itemstack)) {
|
||||
return 1.0f;
|
||||
}
|
||||
}
|
||||
Map<ItemStack, Float> specialtyChances = fruitProvider.getSpecialty();
|
||||
for (ItemStack stack : specialtyChances.keySet()) {
|
||||
if (stack.isItemEqual(itemstack)) {
|
||||
return 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return super.getResearchSuitability(itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(IAlleleTreeSpecies o) {
|
||||
return 0;
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
package forestry.arboriculture.items;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.arboriculture.IFruitProvider;
|
||||
import forestry.api.arboriculture.ITreeGenome;
|
||||
import forestry.arboriculture.blocks.BlockDecorativeLeaves;
|
||||
import forestry.arboriculture.genetics.TreeDefinition;
|
||||
import forestry.core.items.IColoredItem;
|
||||
import forestry.core.items.ItemBlockForestry;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemBlockDecorativeLeaves extends ItemBlockForestry<BlockDecorativeLeaves> implements IColoredItem {
|
||||
public ItemBlockDecorativeLeaves(Block block) {
|
||||
public ItemBlockDecorativeLeaves(BlockDecorativeLeaves block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,12 +12,10 @@ package forestry.arboriculture.items;
|
||||
|
||||
import forestry.arboriculture.PluginArboriculture;
|
||||
import forestry.arboriculture.blocks.BlockAbstractLeaves;
|
||||
import forestry.arboriculture.blocks.BlockForestryLeaves;
|
||||
import forestry.arboriculture.tiles.TileLeaves;
|
||||
import forestry.core.items.IColoredItem;
|
||||
import forestry.core.items.ItemBlockForestry;
|
||||
import forestry.core.utils.Translator;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -30,7 +28,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemBlockLeaves extends ItemBlockForestry<BlockAbstractLeaves> implements IColoredItem {
|
||||
|
||||
public ItemBlockLeaves(Block block) {
|
||||
public ItemBlockLeaves(BlockAbstractLeaves block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,13 +13,12 @@ package forestry.arboriculture.items;
|
||||
import forestry.api.arboriculture.IWoodType;
|
||||
import forestry.arboriculture.IWoodTyped;
|
||||
import forestry.arboriculture.WoodHelper;
|
||||
import forestry.arboriculture.blocks.BlockArbSlab;
|
||||
import forestry.core.items.ItemBlockForestry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemBlockWood<B extends Block & IWoodTyped> extends ItemBlockForestry<B> {
|
||||
public ItemBlockWood(Block block) {
|
||||
public ItemBlockWood(B block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import net.minecraft.world.World;
|
||||
|
||||
public class ItemBlockWoodDoor extends ItemBlockWood<BlockArbDoor> {
|
||||
|
||||
public ItemBlockWoodDoor(Block block) {
|
||||
public ItemBlockWoodDoor(BlockArbDoor block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
|
||||
@@ -47,28 +47,35 @@ public class SimpleModel implements IModel {
|
||||
private static final ModelResourceLocation MISSING = new ModelResourceLocation("builtin/missing", "missing");
|
||||
|
||||
private final List<Variant> variants;
|
||||
private final List<ResourceLocation> locations = new ArrayList<>();
|
||||
private final Set<ResourceLocation> textures = Sets.newHashSet();
|
||||
private final List<IModel> models = new ArrayList<>();
|
||||
private final ImmutableList<ResourceLocation> locations;
|
||||
private final ImmutableSet<ResourceLocation> textures;
|
||||
private final ImmutableList<IModel> models;
|
||||
private final IModelState defaultState;
|
||||
|
||||
public SimpleModel(List<ResourceLocation> locations, List<IModel> models, List<Variant> variants,
|
||||
IModelState defaultState) {
|
||||
this.locations.addAll(locations);
|
||||
this.models.addAll(models);
|
||||
this.variants = variants;
|
||||
this.locations = ImmutableList.copyOf(locations);
|
||||
this.models = ImmutableList.copyOf(models);
|
||||
this.defaultState = defaultState;
|
||||
|
||||
ImmutableSet.Builder<ResourceLocation> texturesBuilder = ImmutableSet.builder();
|
||||
for (IModel model : models) {
|
||||
textures.addAll(model.getTextures());
|
||||
texturesBuilder.addAll(model.getTextures());
|
||||
}
|
||||
textures = texturesBuilder.build();
|
||||
}
|
||||
|
||||
public SimpleModel(ResourceLocation parent, VariantList variants) throws Exception {
|
||||
this.variants = variants.getVariantList();
|
||||
ImmutableList.Builder<Pair<IModel, IModelState>> builder = ImmutableList.builder();
|
||||
ImmutableList.Builder<IModel> modelsBuilder = ImmutableList.builder();
|
||||
ImmutableList.Builder<ResourceLocation> locationsBuilder = ImmutableList.builder();
|
||||
ImmutableSet.Builder<ResourceLocation> texturesBuilder = ImmutableSet.builder();
|
||||
|
||||
for (Variant variant : this.variants) {
|
||||
ResourceLocation loc = variant.getModelLocation();
|
||||
locations.add(loc);
|
||||
locationsBuilder.add(loc);
|
||||
|
||||
IModel model;
|
||||
if (loc.equals(MISSING)) {
|
||||
@@ -81,19 +88,23 @@ public class SimpleModel implements IModel {
|
||||
for (ResourceLocation location : model.getDependencies()) {
|
||||
ModelLoaderRegistry.getModelOrMissing(location);
|
||||
}
|
||||
textures.addAll(model.getTextures());
|
||||
texturesBuilder.addAll(model.getTextures());
|
||||
|
||||
models.add(model);
|
||||
modelsBuilder.add(model);
|
||||
builder.add(Pair.of(model, variant.getState()));
|
||||
}
|
||||
|
||||
if (models.size() == 0) {
|
||||
if (this.variants.size() == 0) {
|
||||
IModel missing = ModelLoaderRegistry.getMissingModel();
|
||||
models.add(missing);
|
||||
modelsBuilder.add(missing);
|
||||
builder.add(Pair.of(missing, TRSRTransformation.identity()));
|
||||
}
|
||||
|
||||
defaultState = new MultiModelState(builder.build());
|
||||
|
||||
locations = locationsBuilder.build();
|
||||
models = modelsBuilder.build();
|
||||
textures = texturesBuilder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -129,6 +140,7 @@ public class SimpleModel implements IModel {
|
||||
|
||||
@Override
|
||||
public IModel retexture(ImmutableMap<String, String> textures) {
|
||||
List<ResourceLocation> locations = new ArrayList<>();
|
||||
List<IModel> models = new ArrayList<>();
|
||||
ImmutableList.Builder<Pair<IModel, IModelState>> builder = ImmutableList.builder();
|
||||
for (Variant variant : this.variants) {
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture.worldgen;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -18,6 +19,18 @@ import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
import net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate;
|
||||
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
import forestry.api.arboriculture.EnumTreeChromosome;
|
||||
import forestry.api.arboriculture.IAlleleTreeSpecies;
|
||||
import forestry.api.arboriculture.IGrowthProvider;
|
||||
@@ -28,22 +41,10 @@ import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.arboriculture.commands.TreeGenHelper;
|
||||
import forestry.core.utils.BlockUtil;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
import net.minecraftforge.common.util.EnumHelper;
|
||||
import net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate;
|
||||
|
||||
public class TreeDecorator {
|
||||
|
||||
private static final EventType EVENT_TYPE = EnumHelper.addEnum(EventType.class, "FORESTRY_TREES", new Class[0]);
|
||||
private static final List<IAlleleTreeSpecies> SPECIES = new ArrayList<>();
|
||||
private static final Map<Biome, Set<ITree>> biomeCache = new HashMap<>();
|
||||
private static final Map<ResourceLocation, Set<ITree>> biomeCache = new HashMap<>();
|
||||
|
||||
@SubscribeEvent
|
||||
public void decorateTrees(Decorate event) {
|
||||
@@ -53,7 +54,7 @@ public class TreeDecorator {
|
||||
}
|
||||
|
||||
public static void decorateTrees(World world, Random rand, int worldX, int worldZ) {
|
||||
if(biomeCache.isEmpty()){
|
||||
if (biomeCache.isEmpty()) {
|
||||
generateBiomeCache(world, rand);
|
||||
}
|
||||
for (int tries = 0; tries < 4 + rand.nextInt(2); tries++) {
|
||||
@@ -62,9 +63,9 @@ public class TreeDecorator {
|
||||
|
||||
BlockPos pos = new BlockPos(x, 0, z);
|
||||
Biome biome = world.getBiome(pos);
|
||||
|
||||
Set<ITree> trees = biomeCache.get(biome);
|
||||
for(ITree tree : trees){
|
||||
|
||||
Set<ITree> trees = biomeCache.computeIfAbsent(biome.getRegistryName(), k -> new HashSet<>());
|
||||
for (ITree tree : trees) {
|
||||
IAlleleTreeSpecies species = tree.getGenome().getPrimary();
|
||||
if (species.getRarity() >= rand.nextFloat()) {
|
||||
pos = getValidPos(world, x, z, tree);
|
||||
@@ -83,15 +84,16 @@ public class TreeDecorator {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static BlockPos getValidPos(World world, int x, int z, ITree tree){
|
||||
// get to the ground
|
||||
final BlockPos topPos = world.getHeight(new BlockPos(x, 0, z));
|
||||
if (topPos.getY() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
final BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(topPos);
|
||||
|
||||
|
||||
IBlockState blockState = world.getBlockState(pos);
|
||||
IBlockState downState = world.getBlockState(pos.down());
|
||||
while (BlockUtil.canReplace(blockState, world, pos)) {
|
||||
@@ -124,14 +126,14 @@ public class TreeDecorator {
|
||||
}
|
||||
|
||||
private static void generateBiomeCache(World world, Random rand){
|
||||
for(IAlleleTreeSpecies species : getSpecies()){
|
||||
for (IAlleleTreeSpecies species : getSpecies()) {
|
||||
IAllele[] template = TreeManager.treeRoot.getTemplate(species);
|
||||
ITreeGenome genome = TreeManager.treeRoot.templateAsGenome(template);
|
||||
ITree tree = TreeManager.treeRoot.getTree(world, genome);
|
||||
IGrowthProvider growthProvider = species.getGrowthProvider();
|
||||
for(Biome biome : Biome.REGISTRY){
|
||||
Set<ITree> trees = biomeCache.computeIfAbsent(biome, k -> new HashSet<>());
|
||||
if(growthProvider.isBiomeValid(tree, biome)){
|
||||
for (Biome biome : Biome.REGISTRY) {
|
||||
Set<ITree> trees = biomeCache.computeIfAbsent(biome.getRegistryName(), k -> new HashSet<>());
|
||||
if (growthProvider.isBiomeValid(tree, biome)) {
|
||||
trees.add(tree);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,15 +49,17 @@ public class WorldGenGreenheart extends WorldGenTree {
|
||||
WorldGenHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.add(0, leafSpawn--, 0), girth, 1.5f + girth, 1, WorldGenHelper.EnumReplaceMode.SOFT);
|
||||
WorldGenHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.add(0, leafSpawn, 0), girth, 0.5f + girth, 1, WorldGenHelper.EnumReplaceMode.SOFT);
|
||||
|
||||
// Add some smaller twigs below for flavour
|
||||
for (int times = 0; times < height / 4; times++) {
|
||||
int h = 10 + rand.nextInt(height - 10);
|
||||
if (rand.nextBoolean() && h < height / 2) {
|
||||
h = height / 2 + rand.nextInt(height / 2);
|
||||
if (height > 10) {
|
||||
// Add some smaller twigs below for flavour
|
||||
for (int times = 0; times < height / 4; times++) {
|
||||
int h = 10 + rand.nextInt(height - 10);
|
||||
if (rand.nextBoolean() && h < height / 2) {
|
||||
h = height / 2 + rand.nextInt(height / 2);
|
||||
}
|
||||
int x_off = -1 + rand.nextInt(3);
|
||||
int y_off = -1 + rand.nextInt(3);
|
||||
WorldGenHelper.generateSphere(world, startPos.add(x_off, h, y_off), 1 + rand.nextInt(1), leaf, WorldGenHelper.EnumReplaceMode.AIR);
|
||||
}
|
||||
int x_off = -1 + rand.nextInt(3);
|
||||
int y_off = -1 + rand.nextInt(3);
|
||||
WorldGenHelper.generateSphere(world, startPos.add(x_off, h, y_off), 1 + rand.nextInt(1), leaf, WorldGenHelper.EnumReplaceMode.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,16 @@ public class EventHandlerCore {
|
||||
@SubscribeEvent
|
||||
public void handlePlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) {
|
||||
EntityPlayer player = event.player;
|
||||
syncBreedingTrackers(player);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void handlePlayerChangedDimension(PlayerEvent.PlayerChangedDimensionEvent event) {
|
||||
EntityPlayer player = event.player;
|
||||
syncBreedingTrackers(player);
|
||||
}
|
||||
|
||||
private static void syncBreedingTrackers(EntityPlayer player) {
|
||||
IAlleleRegistry alleleRegistry = AlleleManager.alleleRegistry;
|
||||
Collection<ISpeciesRoot> speciesRoots = alleleRegistry.getSpeciesRoot().values();
|
||||
for (ISpeciesRoot speciesRoot : speciesRoots) {
|
||||
|
||||
@@ -10,13 +10,32 @@
|
||||
******************************************************************************/
|
||||
package forestry.core;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.command.ICommand;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.storage.loot.functions.LootFunctionManager;
|
||||
|
||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.circuits.ChipsetManager;
|
||||
import forestry.api.core.CamouflageManager;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
@@ -59,21 +78,6 @@ import forestry.core.utils.OreDictUtil;
|
||||
import forestry.plugins.BlankForestryPlugin;
|
||||
import forestry.plugins.ForestryPlugin;
|
||||
import forestry.plugins.ForestryPluginUids;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.command.ICommand;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.storage.loot.functions.LootFunctionManager;
|
||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
@ForestryPlugin(pluginID = ForestryPluginUids.CORE, name = "Core", author = "SirSengir", url = Constants.URL, unlocalizedDescription = "for.plugin.core.description")
|
||||
public class PluginCore extends BlankForestryPlugin {
|
||||
@@ -330,7 +334,6 @@ public class PluginCore extends BlankForestryPlugin {
|
||||
"YBR",
|
||||
"WWW",
|
||||
'W', OreDictUtil.PLANK_WOOD,
|
||||
'D', OreDictUtil.DUST_REDSTONE,
|
||||
'Y', OreDictUtil.DYE_YELLOW,
|
||||
'B', OreDictUtil.DYE_BLUE,
|
||||
'R', OreDictUtil.DYE_RED);
|
||||
|
||||
@@ -29,7 +29,7 @@ public class BlockRegistryCore extends BlockRegistry {
|
||||
|
||||
public BlockRegistryCore() {
|
||||
analyzer = new BlockCore(BlockTypeCoreTesr.ANALYZER);
|
||||
registerBlock(analyzer, new ItemBlockForestry(analyzer), "analyzer");
|
||||
registerBlock(analyzer, new ItemBlockForestry<>(analyzer), "analyzer");
|
||||
|
||||
escritoire = new BlockCore(BlockTypeCoreTesr.ESCRITOIRE);
|
||||
registerBlock(escritoire, new ItemBlockForestry<>(escritoire), "escritoire");
|
||||
@@ -43,14 +43,14 @@ public class BlockRegistryCore extends BlockRegistry {
|
||||
humus.setHarvestLevel("shovel", 0);
|
||||
|
||||
resources = new BlockResourceOre();
|
||||
registerBlock(resources, new ItemBlockForestry(resources), "resources");
|
||||
registerBlock(resources, new ItemBlockForestry<>(resources), "resources");
|
||||
resources.setHarvestLevel("pickaxe", 1);
|
||||
OreDictionary.registerOre(OreDictUtil.ORE_APATITE, resources.get(EnumResourceType.APATITE, 1));
|
||||
OreDictionary.registerOre(OreDictUtil.ORE_COPPER, resources.get(EnumResourceType.COPPER, 1));
|
||||
OreDictionary.registerOre(OreDictUtil.ORE_TIN, resources.get(EnumResourceType.TIN, 1));
|
||||
|
||||
BlockResourceStorage resourceStorage = new BlockResourceStorage();
|
||||
registerBlock(resourceStorage, new ItemBlockForestry(resourceStorage), "resource_storage");
|
||||
registerBlock(resourceStorage, new ItemBlockForestry<>(resourceStorage), "resource_storage");
|
||||
resourceStorage.setHarvestLevel("pickaxe", 0);
|
||||
|
||||
resourceStorageApatite = resourceStorage.get(EnumResourceType.APATITE);
|
||||
|
||||
@@ -29,6 +29,7 @@ public class Circuits {
|
||||
public static ICircuit farmOrchardManual;
|
||||
public static ICircuit farmRubberManual;
|
||||
public static ICircuit farmEnderManaged;
|
||||
public static ICircuit farmOrchidManaged;
|
||||
public static ICircuit machineSpeedUpgrade1;
|
||||
public static ICircuit machineSpeedUpgrade2;
|
||||
public static ICircuit machineEfficiencyUpgrade1;
|
||||
|
||||
@@ -92,6 +92,7 @@ public class Config {
|
||||
public static int farmSize = 2;
|
||||
public static boolean squareFarms = false;
|
||||
private static boolean enableExUtilEnderLily = true;
|
||||
private static boolean enableExUtilRedOrchid = true;
|
||||
private static boolean enableMagicalCropsSupport = true;
|
||||
|
||||
// Mail
|
||||
@@ -131,6 +132,8 @@ public class Config {
|
||||
return enableExUtilEnderLily;
|
||||
}
|
||||
|
||||
public static boolean isExUtilRedOrchidEnabled() { return enableExUtilRedOrchid; }
|
||||
|
||||
public static boolean isMagicalCropsSupportEnabled() {
|
||||
return enableMagicalCropsSupport;
|
||||
}
|
||||
@@ -241,6 +244,7 @@ public class Config {
|
||||
farmSize = configCommon.getIntLocalized("tweaks.farms", "size", farmSize, 1, 3);
|
||||
squareFarms = configCommon.getBooleanLocalized("tweaks.farms", "square", squareFarms);
|
||||
enableExUtilEnderLily = configCommon.getBooleanLocalized("tweaks.farms", "enderlily", enableExUtilEnderLily);
|
||||
enableExUtilRedOrchid = configCommon.getBooleanLocalized("tweaks.farms", "redorchid", enableExUtilRedOrchid);
|
||||
enableMagicalCropsSupport = configCommon.getBooleanLocalized("tweaks.farms", "magicalcrops", enableMagicalCropsSupport);
|
||||
|
||||
String[] availableStructures = new String[]{"alveary3x3", "farm3x3", "farm3x4", "farm3x5", "farm4x4", "farm5x5"};
|
||||
|
||||
@@ -12,7 +12,6 @@ package forestry.core.fluids;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import forestry.core.utils.InventoryUtil;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -107,7 +106,7 @@ public final class FluidHelper {
|
||||
|
||||
boolean moveToOutput = fluidInContainer.amount >= containerCapacity;
|
||||
if (moveToOutput) {
|
||||
if (!output.isEmpty() && (output.getCount() >= output.getMaxStackSize() || !InventoryUtil.isItemEqual(filled, output))) {
|
||||
if (!output.isEmpty() && (output.getCount() >= output.getMaxStackSize() || !ItemStackUtil.areItemStacksEqualIgnoreCount(filled, output))) {
|
||||
return FillStatus.NO_SPACE;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
package forestry.core.genetics;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Arrays;
|
||||
@@ -26,6 +25,7 @@ import forestry.api.genetics.IChromosome;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.genetics.IGenome;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.core.utils.Log;
|
||||
|
||||
public abstract class Genome implements IGenome {
|
||||
private static final String SLOT_TAG = "Slot";
|
||||
@@ -138,12 +138,23 @@ public abstract class Genome implements IGenome {
|
||||
|
||||
private static IChromosome getChromosome(ItemStack itemStack, IChromosomeType chromosomeType, ISpeciesRoot speciesRoot) {
|
||||
NBTTagCompound nbtTagCompound = itemStack.getTagCompound();
|
||||
Preconditions.checkArgument(nbtTagCompound != null, "itemStack must have nbt");
|
||||
if (nbtTagCompound == null) {
|
||||
nbtTagCompound = new NBTTagCompound();
|
||||
itemStack.setTagCompound(nbtTagCompound);
|
||||
}
|
||||
|
||||
NBTTagCompound genome = nbtTagCompound.getCompoundTag("Genome");
|
||||
Preconditions.checkArgument(!genome.hasNoTags(), "itemStack nbt must have a genome tag");
|
||||
NBTTagCompound genomeNbt = nbtTagCompound.getCompoundTag("Genome");
|
||||
if (genomeNbt.hasNoTags()) {
|
||||
Log.error("Got a genetic item with no genome, setting it to a default value.");
|
||||
genomeNbt = new NBTTagCompound();
|
||||
|
||||
IAllele[] defaultTemplate = speciesRoot.getDefaultTemplate();
|
||||
IGenome genome = speciesRoot.templateAsGenome(defaultTemplate);
|
||||
genome.writeToNBT(genomeNbt);
|
||||
nbtTagCompound.setTag("Genome", genomeNbt);
|
||||
}
|
||||
|
||||
IChromosome[] chromosomes = getChromosomes(genome, speciesRoot);
|
||||
IChromosome[] chromosomes = getChromosomes(genomeNbt, speciesRoot);
|
||||
|
||||
return chromosomes[chromosomeType.ordinal()];
|
||||
}
|
||||
|
||||
@@ -12,11 +12,13 @@ package forestry.core.inventory;
|
||||
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.core.tiles.EscritoireGame;
|
||||
import forestry.core.tiles.TileEscritoire;
|
||||
import forestry.core.utils.GeneticsUtil;
|
||||
import forestry.core.utils.SlotUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class InventoryEscritoire extends InventoryAdapterTile<TileEscritoire> {
|
||||
public static final short SLOT_ANALYZE = 0;
|
||||
@@ -79,8 +81,10 @@ public class InventoryEscritoire extends InventoryAdapterTile<TileEscritoire> {
|
||||
super.setInventorySlotContents(SLOT_ANALYZE, ersatz);
|
||||
}
|
||||
}
|
||||
if (!tile.getWorld().isRemote) {
|
||||
tile.getGame().initialize(getStackInSlot(SLOT_ANALYZE));
|
||||
World world = tile.getWorld();
|
||||
if (world != null && !world.isRemote) {
|
||||
EscritoireGame game = tile.getGame();
|
||||
game.initialize(getStackInSlot(SLOT_ANALYZE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,8 @@ public enum EnumElectronTube implements ItemOverlay.IOverlayInfo {
|
||||
EMERALD(new Color(0x00CC41)),
|
||||
APATITE(new Color(0x579CD9)),
|
||||
LAPIS(new Color(0x1c57c6)),
|
||||
ENDER(new Color(0x33adad), new Color(0x255661));
|
||||
ENDER(new Color(0x33adad), new Color(0x255661)),
|
||||
ORCHID(new Color(0x820208), new Color(0xc64f3f));
|
||||
|
||||
public static final EnumElectronTube[] VALUES = values();
|
||||
|
||||
|
||||
@@ -13,6 +13,11 @@ package forestry.core.items;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
import forestry.core.blocks.IBlockRotatable;
|
||||
import forestry.core.blocks.IBlockWithMeta;
|
||||
import forestry.core.tiles.TileForestry;
|
||||
import forestry.core.tiles.TileUtil;
|
||||
import forestry.core.utils.ItemTooltipUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
@@ -22,19 +27,12 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.core.blocks.IBlockRotatable;
|
||||
import forestry.core.blocks.IBlockWithMeta;
|
||||
import forestry.core.tiles.TileForestry;
|
||||
import forestry.core.tiles.TileUtil;
|
||||
import forestry.core.utils.ItemTooltipUtil;
|
||||
|
||||
public class ItemBlockForestry<B extends Block> extends ItemBlock {
|
||||
|
||||
public ItemBlockForestry(Block block) {
|
||||
public ItemBlockForestry(B block) {
|
||||
super(block);
|
||||
setMaxDamage(0);
|
||||
setHasSubtypes(true);
|
||||
|
||||
@@ -25,6 +25,7 @@ import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.models;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.Matrix4f;
|
||||
import java.util.ArrayList;
|
||||
@@ -39,11 +37,12 @@ import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.client.model.PerspectiveMapWrapper;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.core.items.ItemCrated;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.core.utils.ModelUtil;
|
||||
import forestry.storage.PluginStorage;
|
||||
|
||||
@@ -107,8 +106,16 @@ public class ModelCrate extends BlankModel {
|
||||
@Override
|
||||
public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, @Nullable World world, @Nullable EntityLivingBase entity) {
|
||||
ItemCrated crated = (ItemCrated) stack.getItem();
|
||||
ResourceLocation itemName = ItemStackUtil.getItemNameFromRegistry(crated);
|
||||
Preconditions.checkNotNull(itemName);
|
||||
ResourceLocation itemName = crated.getRegistryName();
|
||||
if(itemName == null){
|
||||
IBakedModel baseCrateModel = cache.get("base");
|
||||
if(baseCrateModel == null){
|
||||
baseCrateModel = ModelUtil.getModel(new ItemStack(PluginStorage.getItems().crate, 1, 1));
|
||||
baseCrateModel = ForgeHooksClient.handleCameraTransforms(baseCrateModel, TransformType.GROUND, false);
|
||||
}
|
||||
Log.error("Failed to load the model of the create item: {}, please report this to the authors of forestry.", itemName);
|
||||
return baseCrateModel;
|
||||
}
|
||||
String crateUID = itemName.getResourcePath();
|
||||
IBakedModel model = cache.get(crateUID);
|
||||
if (model == null) {
|
||||
|
||||
@@ -57,58 +57,58 @@ public abstract class RecipeUtil {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static InventoryCraftingForestry getCraftRecipe(NonNullList<ItemStack> recipeItems, NonNullList<ItemStack> availableItems, World world, IRecipe recipe) {
|
||||
// Need at least one matched set
|
||||
if (ItemStackUtil.containsSets(recipeItems, availableItems, true, true) == 0) {
|
||||
public static InventoryCraftingForestry getCraftRecipe(InventoryCrafting originalCrafting, NonNullList<ItemStack> availableItems, World world, IRecipe recipe) {
|
||||
if (!recipe.matches(originalCrafting, world)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Check that it doesn't make a different recipe.
|
||||
// For example:
|
||||
// Wood Logs are all ore dictionary equivalent with each other,
|
||||
// but an Oak Log shouldn't be able to make Ebony Wood Planks
|
||||
// because it makes Oak Wood Planks using the same recipe.
|
||||
// Strategy:
|
||||
// Create a fake crafting inventory using items we have in availableItems
|
||||
// in place of the ones in the saved crafting inventory.
|
||||
// Check that the recipe it makes is the same as the currentRecipe.
|
||||
|
||||
ItemStack expectedOutput = recipe.getCraftingResult(originalCrafting);
|
||||
if (expectedOutput.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
InventoryCraftingForestry crafting = new InventoryCraftingForestry();
|
||||
NonNullList<ItemStack> stockCopy = ItemStackUtil.condenseStacks(availableItems);
|
||||
|
||||
for (int slot = 0; slot < recipeItems.size(); slot++) {
|
||||
ItemStack recipeStack = recipeItems.get(slot);
|
||||
if (recipeStack.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Use crafting equivalent (not oredict) items first
|
||||
for (ItemStack stockStack : stockCopy) {
|
||||
if (stockStack.getCount() > 0 && ItemStackUtil.isCraftingEquivalent(recipeStack, stockStack, false, false)) {
|
||||
ItemStack stack = ItemStackUtil.createCopyWithCount(stockStack, 1);
|
||||
stockStack.shrink(1);
|
||||
crafting.setInventorySlotContents(slot, stack);
|
||||
break;
|
||||
for (int slot = 0; slot < originalCrafting.getSizeInventory(); slot++) {
|
||||
ItemStack stackInSlot = originalCrafting.getStackInSlot(slot);
|
||||
if (!stackInSlot.isEmpty()) {
|
||||
ItemStack equivalent = getCraftingEquivalent(stockCopy, originalCrafting, slot, world, recipe, expectedOutput);
|
||||
if (equivalent.isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
crafting.setInventorySlotContents(slot, equivalent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (recipe.matches(crafting, world)) {
|
||||
ItemStack output = recipe.getCraftingResult(crafting);
|
||||
if (ItemStack.areItemStacksEqual(output, expectedOutput)) {
|
||||
return crafting;
|
||||
}
|
||||
}
|
||||
|
||||
// Use oredict items if crafting equivalent items aren't available
|
||||
if (crafting.getStackInSlot(slot).isEmpty()) {
|
||||
for (ItemStack stockStack : stockCopy) {
|
||||
if (stockStack.getCount() > 0 && ItemStackUtil.isCraftingEquivalent(recipeStack, stockStack, true, true)) {
|
||||
ItemStack stack = ItemStackUtil.createCopyWithCount(stockStack, 1);
|
||||
stockStack.shrink(1);
|
||||
crafting.setInventorySlotContents(slot, stack);
|
||||
break;
|
||||
return null;
|
||||
}
|
||||
|
||||
private static ItemStack getCraftingEquivalent(NonNullList<ItemStack> stockCopy, InventoryCrafting crafting, int slot, World world, IRecipe recipe, ItemStack expectedOutput) {
|
||||
ItemStack originalStack = crafting.getStackInSlot(slot);
|
||||
for (ItemStack stockStack : stockCopy) {
|
||||
if (!stockStack.isEmpty()) {
|
||||
ItemStack singleStockStack = ItemStackUtil.createCopyWithCount(stockStack, 1);
|
||||
crafting.setInventorySlotContents(slot, singleStockStack);
|
||||
if (recipe.matches(crafting, world)) {
|
||||
ItemStack output = recipe.getCraftingResult(crafting);
|
||||
if (ItemStack.areItemStacksEqual(output, expectedOutput)) {
|
||||
crafting.setInventorySlotContents(slot, originalStack);
|
||||
return stockStack.splitStack(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<IRecipe> outputs = findMatchingRecipes(crafting, world);
|
||||
if (outputs.contains(recipe)) {
|
||||
return crafting;
|
||||
}
|
||||
return null;
|
||||
crafting.setInventorySlotContents(slot, originalStack);
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
public static List<IRecipe> findMatchingRecipes(InventoryCrafting inventory, World world) {
|
||||
@@ -147,6 +147,7 @@ public abstract class RecipeUtil {
|
||||
GameRegistry.addSmelting(res, prod, xp);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String[][] matches(IDescriptiveRecipe recipe, IInventory inventoryCrafting) {
|
||||
NonNullList<NonNullList<ItemStack>> recipeIngredients = recipe.getRawIngredients();
|
||||
NonNullList<String> oreDicts = recipe.getOreDicts();
|
||||
@@ -155,6 +156,7 @@ public abstract class RecipeUtil {
|
||||
return matches(recipeIngredients, oreDicts, width, height, inventoryCrafting);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String[][] matches(NonNullList<NonNullList<ItemStack>> recipeIngredients, NonNullList<String> oreDicts, int width, int height, IInventory inventoryCrafting) {
|
||||
ItemStack[][] resources = getResources(inventoryCrafting);
|
||||
return matches(recipeIngredients, oreDicts, width, height, resources);
|
||||
|
||||
@@ -97,6 +97,7 @@ public class EscritoireGame implements INbtWritable, INbtReadable, IStreamable {
|
||||
|
||||
/* INTERACTION */
|
||||
public void initialize(ItemStack specimen) {
|
||||
reset();
|
||||
if (gameBoard.initialize(specimen)) {
|
||||
status = Status.PLAYING;
|
||||
bountyLevel = BOUNTY_MAX;
|
||||
|
||||
@@ -11,14 +11,7 @@
|
||||
package forestry.core.utils;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.core.circuits.ISocketable;
|
||||
import forestry.core.inventory.ItemHandlerInventoryManipulator;
|
||||
import forestry.core.inventory.StandardStackFilters;
|
||||
import forestry.core.tiles.AdjacentTileCache;
|
||||
import forestry.plugins.ForestryPluginUids;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -29,78 +22,20 @@ import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.core.circuits.ISocketable;
|
||||
import forestry.core.inventory.ItemHandlerInventoryManipulator;
|
||||
import forestry.core.inventory.StandardStackFilters;
|
||||
import forestry.core.tiles.AdjacentTileCache;
|
||||
import forestry.plugins.ForestryPluginUids;
|
||||
|
||||
public abstract class InventoryUtil {
|
||||
|
||||
public static boolean isWildcard(ItemStack stack) {
|
||||
return stack.getItemDamage() == OreDictionary.WILDCARD_VALUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* A more robust item comparison function. Supports items with damage = -1
|
||||
* matching any sub-type.
|
||||
*
|
||||
* @param a An ItemStack
|
||||
* @param b An ItemStack
|
||||
* @return True if equal
|
||||
*/
|
||||
public static boolean isItemEqual(ItemStack a, ItemStack b) {
|
||||
return isItemEqual(a, b, true, true);
|
||||
}
|
||||
|
||||
public static boolean isItemEqual(final ItemStack a, final ItemStack b, final boolean matchDamage, final boolean matchNBT) {
|
||||
if (a.isEmpty() || b.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
if (a.getItem() != b.getItem()) {
|
||||
return false;
|
||||
}
|
||||
if (matchNBT && !ItemStack.areItemStackTagsEqual(a, b)) {
|
||||
return false;
|
||||
}
|
||||
if (matchDamage && a.getHasSubtypes()) {
|
||||
if (isWildcard(a) || isWildcard(b)) {
|
||||
return true;
|
||||
}
|
||||
if (a.getItemDamage() != b.getItemDamage()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the item is equal to any one of several possible matches.
|
||||
*/
|
||||
public static boolean isItemEqual(ItemStack stack, ItemStack... matches) {
|
||||
for (ItemStack match : matches) {
|
||||
if (isItemEqual(stack, match)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the item is equal to any one of several possible matches.
|
||||
*
|
||||
* @param stack the ItemStack to test
|
||||
* @param matches the ItemStacks to test against
|
||||
* @return true if a match is found
|
||||
*/
|
||||
public static boolean isItemEqual(ItemStack stack, Collection<ItemStack> matches) {
|
||||
for (ItemStack match : matches) {
|
||||
if (isItemEqual(stack, match)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to move an ItemStack from one inventory to another.
|
||||
*
|
||||
@@ -218,6 +153,48 @@ public abstract class InventoryUtil {
|
||||
return ItemStackUtil.containsSets(set, stock, oreDicts, craftingTools) >= count;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean deleteExactSet(IInventory inventory, NonNullList<ItemStack> required) {
|
||||
NonNullList<ItemStack> offered = getStacks(inventory);
|
||||
NonNullList<ItemStack> condensedRequired = ItemStackUtil.condenseStacks(required);
|
||||
NonNullList<ItemStack> condensedOffered = ItemStackUtil.condenseStacks(offered);
|
||||
|
||||
for (ItemStack req : condensedRequired) {
|
||||
if (!containsExactStack(req, condensedOffered)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (ItemStack itemStack : condensedRequired) {
|
||||
deleteExactStack(inventory, itemStack);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean containsExactStack(ItemStack req, NonNullList<ItemStack> condensedOffered) {
|
||||
for (ItemStack offer : condensedOffered) {
|
||||
if (offer.getCount() >= req.getCount() && ItemStackUtil.areItemStacksEqualIgnoreCount(req, offer)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void deleteExactStack(IInventory inventory, ItemStack itemStack) {
|
||||
int count = itemStack.getCount();
|
||||
for (int j = 0; j < inventory.getSizeInventory(); j++) {
|
||||
ItemStack stackInSlot = inventory.getStackInSlot(j);
|
||||
if (!stackInSlot.isEmpty()) {
|
||||
if (ItemStackUtil.areItemStacksEqualIgnoreCount(itemStack, stackInSlot)) {
|
||||
ItemStack removed = inventory.decrStackSize(j, count);
|
||||
count -= removed.getCount();
|
||||
if (count == 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static NonNullList<ItemStack> removeSets(IInventory inventory, int count, NonNullList<ItemStack> set, @Nullable EntityPlayer player, boolean stowContainer, boolean oreDictionary, boolean craftingTools) {
|
||||
@@ -303,7 +280,7 @@ public abstract class InventoryUtil {
|
||||
for (int j = 0; j < inventory.getSizeInventory(); j++) {
|
||||
ItemStack stackInSlot = inventory.getStackInSlot(j);
|
||||
if (!stackInSlot.isEmpty()) {
|
||||
if (ItemStackUtil.isCraftingEquivalent(stackInSlot, stackToRemove, oreDictOfStack, craftingTools)) {
|
||||
if (ItemStackUtil.isCraftingEquivalent(stackToRemove, stackInSlot, oreDictOfStack, craftingTools)) {
|
||||
ItemStack removed = inventory.decrStackSize(j, stackToRemove.getCount());
|
||||
stackToRemove.shrink(removed.getCount());
|
||||
|
||||
@@ -394,7 +371,7 @@ public abstract class InventoryUtil {
|
||||
public static boolean tryAddStacksCopy(IInventory inventory, NonNullList<ItemStack> stacks, int startSlot, int slots, boolean all) {
|
||||
|
||||
for (ItemStack stack : stacks) {
|
||||
if (stack == null) {
|
||||
if (stack == null || stack.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -594,5 +594,24 @@ public abstract class ItemStackUtil {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks like {@link ItemStack#areItemStacksEqual(ItemStack, ItemStack)}
|
||||
* but ignores stack size (count).
|
||||
*/
|
||||
public static boolean areItemStacksEqualIgnoreCount(ItemStack a, ItemStack b) {
|
||||
if (a.isEmpty() && b.isEmpty()) {
|
||||
return true;
|
||||
} else if (a.isEmpty() || b.isEmpty()) {
|
||||
return false;
|
||||
} else if (a.getItem() != b.getItem()) {
|
||||
return false;
|
||||
} else if (a.getItemDamage() != b.getItemDamage()) {
|
||||
return false;
|
||||
} else if (a.getTagCompound() == null && b.getTagCompound() != null) {
|
||||
return false;
|
||||
} else {
|
||||
return (a.getTagCompound() == null || a.getTagCompound().equals(b.getTagCompound())) && a.areCapsCompatible(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,8 +13,12 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
|
||||
@Mod.EventBusSubscriber
|
||||
public class MigrationHelper {
|
||||
private static Map<String, String> blockRemappings = new HashMap<>();
|
||||
private static Map<String, String> itemRemappings = new HashMap<>();
|
||||
@@ -51,6 +55,7 @@ public class MigrationHelper {
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onMissingBlockMappings(RegistryEvent.MissingMappings<Block> event) {
|
||||
for (RegistryEvent.MissingMappings.Mapping<Block> missingMapping : event.getMappings()) {
|
||||
ResourceLocation resourceLocation = missingMapping.key;
|
||||
@@ -70,6 +75,7 @@ public class MigrationHelper {
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onMissingItemMappings(RegistryEvent.MissingMappings<Item> event) {
|
||||
for (RegistryEvent.MissingMappings.Mapping<Item> missingMapping : event.getMappings()) {
|
||||
ResourceLocation resourceLocation = missingMapping.key;
|
||||
|
||||
@@ -67,6 +67,26 @@ public abstract class PlayerUtil {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a fake player for a given World and GameProfile.
|
||||
* Do not store references to the return value, to prevent worlds staying in memory.
|
||||
*/
|
||||
@Nullable
|
||||
public static EntityPlayer getFakePlayer(World world, @Nullable GameProfile profile) {
|
||||
if (profile == null || profile.getName() == null) {
|
||||
if (world instanceof WorldServer) {
|
||||
return FakePlayerFactory.getMinecraft((WorldServer) world);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (world instanceof WorldServer) {
|
||||
return FakePlayerFactory.get((WorldServer) world, profile);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void writeGameProfile(NBTTagCompound tagCompound, GameProfile profile) {
|
||||
if (!StringUtils.isNullOrEmpty(profile.getName())) {
|
||||
tagCompound.setString("Name", profile.getName());
|
||||
|
||||
@@ -12,6 +12,7 @@ package forestry.core.utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import forestry.core.gui.slots.SlotCrafter;
|
||||
import forestry.core.gui.slots.SlotForestry;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
@@ -70,7 +71,7 @@ public abstract class SlotUtil {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
boolean fromCraftingSlot = slot instanceof SlotCrafting;
|
||||
boolean fromCraftingSlot = slot instanceof SlotCrafting || slot instanceof SlotCrafter;
|
||||
|
||||
int numSlots = inventorySlots.size();
|
||||
ItemStack stackInSlot = slot.getStack();
|
||||
@@ -82,7 +83,7 @@ public abstract class SlotUtil {
|
||||
|
||||
slot.onSlotChange(stackInSlot, originalStack);
|
||||
if (stackInSlot.isEmpty()) {
|
||||
slot.putStack(stackInSlot);
|
||||
slot.putStack(ItemStack.EMPTY);
|
||||
} else {
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import net.minecraft.world.gen.IChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.WorldGenMinable;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.terraingen.DecorateBiomeEvent;
|
||||
import net.minecraftforge.event.terraingen.PopulateChunkEvent;
|
||||
import net.minecraftforge.fml.common.IWorldGenerator;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
@@ -54,6 +55,11 @@ public class WorldGenerator implements IWorldGenerator {
|
||||
PluginManager.populateChunk(event.getGen(), event.getWorld(), event.getRand(), event.getChunkX(), event.getChunkZ(), event.isHasVillageGenerated());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void decorateBiome(DecorateBiomeEvent.Post event) {
|
||||
PluginManager.decorateBiome(event.getWorld(), event.getRand(), event.getPos());
|
||||
}
|
||||
|
||||
public void retroGen(Random random, int chunkX, int chunkZ, World world) {
|
||||
generateWorld(random, chunkX, chunkZ, world);
|
||||
PluginManager.populateChunkRetroGen(world, random, chunkX, chunkZ);
|
||||
|
||||
@@ -325,6 +325,12 @@ public class PluginFactory extends BlankForestryPlugin {
|
||||
"XXX",
|
||||
'#', new ItemStack(Items.ENDER_EYE, 1, 0),
|
||||
'X', new ItemStack(Blocks.END_STONE, 1, 0)});
|
||||
RecipeManagers.fabricatorManager.addRecipe(ItemStack.EMPTY, Fluids.GLASS.getFluid(500), electronTube.get(EnumElectronTube.ORCHID, 4), new Object[]{
|
||||
" X ",
|
||||
"#X#",
|
||||
"XXX",
|
||||
'#', new ItemStack(Items.REPEATER, 1, 0),
|
||||
'X', new ItemStack(Blocks.REDSTONE_ORE, 1, 0)});
|
||||
|
||||
String[] dyes = {"dyeBlack", "dyeRed", "dyeGreen", "dyeBrown", "dyeBlue", "dyePurple", "dyeCyan", "dyeLightGray", "dyeGray", "dyePink", "dyeLime",
|
||||
"dyeYellow", "dyeLightBlue", "dyeMagenta", "dyeOrange", "dyeWhite"};
|
||||
|
||||
@@ -30,28 +30,28 @@ public class BlockRegistryFactory extends BlockRegistry {
|
||||
|
||||
public BlockRegistryFactory() {
|
||||
bottler = new BlockFactoryTESR(BlockTypeFactoryTesr.BOTTLER);
|
||||
registerBlock(bottler, new ItemBlockForestry(bottler), "bottler");
|
||||
registerBlock(bottler, new ItemBlockForestry<>(bottler), "bottler");
|
||||
|
||||
carpenter = new BlockFactoryTESR(BlockTypeFactoryTesr.CARPENTER);
|
||||
registerBlock(carpenter, new ItemBlockForestry(carpenter), "carpenter");
|
||||
registerBlock(carpenter, new ItemBlockForestry<>(carpenter), "carpenter");
|
||||
|
||||
centrifuge = new BlockFactoryTESR(BlockTypeFactoryTesr.CENTRIFUGE);
|
||||
registerBlock(centrifuge, new ItemBlockForestry(centrifuge), "centrifuge");
|
||||
registerBlock(centrifuge, new ItemBlockForestry<>(centrifuge), "centrifuge");
|
||||
|
||||
fermenter = new BlockFactoryTESR(BlockTypeFactoryTesr.FERMENTER);
|
||||
registerBlock(fermenter, new ItemBlockForestry(fermenter), "fermenter");
|
||||
registerBlock(fermenter, new ItemBlockForestry<>(fermenter), "fermenter");
|
||||
|
||||
moistener = new BlockFactoryTESR(BlockTypeFactoryTesr.MOISTENER);
|
||||
registerBlock(moistener, new ItemBlockForestry(moistener), "moistener");
|
||||
registerBlock(moistener, new ItemBlockForestry<>(moistener), "moistener");
|
||||
|
||||
squeezer = new BlockFactoryTESR(BlockTypeFactoryTesr.SQUEEZER);
|
||||
registerBlock(squeezer, new ItemBlockForestry(squeezer), "squeezer");
|
||||
registerBlock(squeezer, new ItemBlockForestry<>(squeezer), "squeezer");
|
||||
|
||||
still = new BlockFactoryTESR(BlockTypeFactoryTesr.STILL);
|
||||
registerBlock(still, new ItemBlockForestry(still), "still");
|
||||
registerBlock(still, new ItemBlockForestry<>(still), "still");
|
||||
|
||||
rainmaker = new BlockFactoryTESR(BlockTypeFactoryTesr.RAINMAKER);
|
||||
registerBlock(rainmaker, new ItemBlockForestry(rainmaker), "rainmaker");
|
||||
registerBlock(rainmaker, new ItemBlockForestry<>(rainmaker), "rainmaker");
|
||||
|
||||
fabricator = new BlockFactoryPlain(BlockTypeFactoryPlain.FABRICATOR);
|
||||
registerBlock(fabricator, new ItemBlockNBT(fabricator), "fabricator");
|
||||
|
||||
@@ -12,14 +12,31 @@ package forestry.factory.inventory;
|
||||
|
||||
import forestry.core.gui.ContainerDummy;
|
||||
import forestry.factory.gui.ContainerWorktable;
|
||||
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
|
||||
public class InventoryCraftingForestry extends InventoryCrafting {
|
||||
private final Container eventHandlerIn;
|
||||
|
||||
public InventoryCraftingForestry(ContainerWorktable containerWorktable) {
|
||||
super(containerWorktable, 3, 3);
|
||||
this(containerWorktable, 3, 3);
|
||||
}
|
||||
|
||||
public InventoryCraftingForestry() {
|
||||
super(ContainerDummy.instance, 3, 3);
|
||||
this(ContainerDummy.instance, 3, 3);
|
||||
}
|
||||
|
||||
private InventoryCraftingForestry(Container eventHandlerIn, int width, int height) {
|
||||
super(eventHandlerIn, width, height);
|
||||
this.eventHandlerIn = eventHandlerIn;
|
||||
}
|
||||
|
||||
public InventoryCraftingForestry copy() {
|
||||
InventoryCraftingForestry copy = new InventoryCraftingForestry(this.eventHandlerIn, getWidth(), getHeight());
|
||||
for (int slot = 0; slot < getSizeInventory(); slot++) {
|
||||
copy.setInventorySlotContents(slot, getStackInSlot(slot).copy());
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
}
|
||||
@@ -24,9 +24,6 @@ import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.registries.ForgeRegistry;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
|
||||
import forestry.api.core.INbtReadable;
|
||||
@@ -38,7 +35,7 @@ import forestry.core.utils.NBTUtilForestry;
|
||||
import forestry.factory.inventory.InventoryCraftingForestry;
|
||||
|
||||
public final class MemorizedRecipe implements INbtWritable, INbtReadable, IStreamable {
|
||||
private final InventoryCraftingForestry craftMatrix = new InventoryCraftingForestry();
|
||||
private InventoryCraftingForestry craftMatrix = new InventoryCraftingForestry();
|
||||
private List<IRecipe> recipes = new ArrayList<>();
|
||||
private int selectedRecipe;
|
||||
private long lastUsed;
|
||||
@@ -60,6 +57,10 @@ public final class MemorizedRecipe implements INbtWritable, INbtReadable, IStrea
|
||||
public InventoryCraftingForestry getCraftMatrix() {
|
||||
return craftMatrix;
|
||||
}
|
||||
|
||||
public void setCraftMatrix(InventoryCraftingForestry craftMatrix) {
|
||||
this.craftMatrix = craftMatrix;
|
||||
}
|
||||
|
||||
public void incrementRecipe() {
|
||||
selectedRecipe++;
|
||||
|
||||
@@ -23,7 +23,6 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryBasic;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.NonNullList;
|
||||
@@ -150,14 +149,13 @@ public class TileWorktable extends TileBase implements ICrafterWorktable {
|
||||
return false;
|
||||
}
|
||||
|
||||
NonNullList<ItemStack> recipeItems = InventoryUtil.getStacks(currentRecipe.getCraftMatrix());
|
||||
NonNullList<ItemStack> inventoryStacks = InventoryUtil.getStacks(this);
|
||||
InventoryCraftingForestry crafting = RecipeUtil.getCraftRecipe(recipeItems, inventoryStacks, world, selectedRecipe);
|
||||
InventoryCraftingForestry crafting = RecipeUtil.getCraftRecipe(currentRecipe.getCraftMatrix(), inventoryStacks, world, selectedRecipe);
|
||||
if (crafting == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
recipeItems = InventoryUtil.getStacks(crafting);
|
||||
|
||||
NonNullList<ItemStack> recipeItems = InventoryUtil.getStacks(crafting);
|
||||
|
||||
IInventory inventory;
|
||||
if (simulate) {
|
||||
@@ -167,15 +165,14 @@ public class TileWorktable extends TileBase implements ICrafterWorktable {
|
||||
inventory = this;
|
||||
}
|
||||
|
||||
// craft recipe should exactly match ingredients here, so no oreDict or tool matching
|
||||
NonNullList<ItemStack> removed = InventoryUtil.removeSets(inventory, 1, recipeItems, null, false, false, false);
|
||||
if (removed == null) {
|
||||
if (!InventoryUtil.deleteExactSet(inventory, recipeItems)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!simulate) {
|
||||
// update crafting display to match the ingredients that were actually used
|
||||
setCraftingDisplay(crafting);
|
||||
currentRecipe.setCraftMatrix(crafting);
|
||||
setCurrentRecipe(currentRecipe);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -184,13 +181,16 @@ public class TileWorktable extends TileBase implements ICrafterWorktable {
|
||||
@Override
|
||||
public void onCraftingComplete(EntityPlayer player) {
|
||||
Preconditions.checkState(currentRecipe != null);
|
||||
|
||||
IRecipe selectedRecipe = currentRecipe.getSelectedRecipe();
|
||||
Preconditions.checkState(selectedRecipe != null);
|
||||
|
||||
ForgeHooks.setCraftingPlayer(player);
|
||||
NonNullList<ItemStack> remainingItems = CraftingManager.getRemainingItems(currentRecipe.getCraftMatrix(), player.world);
|
||||
InventoryCraftingForestry craftMatrix = currentRecipe.getCraftMatrix();
|
||||
NonNullList<ItemStack> remainingItems = selectedRecipe.getRemainingItems(craftMatrix.copy());
|
||||
ForgeHooks.setCraftingPlayer(null);
|
||||
|
||||
for (ItemStack remainingItem : remainingItems) {
|
||||
if (remainingItem != null) {
|
||||
if (remainingItem != null && !remainingItem.isEmpty()) {
|
||||
if (!InventoryUtil.tryAddStack(this, remainingItem, true)) {
|
||||
player.dropItem(remainingItem, false);
|
||||
}
|
||||
|
||||
@@ -1,19 +1,23 @@
|
||||
package forestry.farming;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.farming.IFarmLogic;
|
||||
import forestry.api.farming.IFarmRegistry;
|
||||
@@ -24,15 +28,13 @@ import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.core.utils.Translator;
|
||||
import forestry.farming.logic.FarmLogicSimple;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public final class FarmRegistry implements IFarmRegistry {
|
||||
|
||||
private static final FarmRegistry INSTANCE = new FarmRegistry();
|
||||
private final Multimap<String, IFarmable> farmables = HashMultimap.create();
|
||||
private final Map<ItemStack, Integer> fertilizers = new LinkedHashMap<>();
|
||||
private final Map<String, IFarmLogic> logics = new HashMap<String, IFarmLogic>();
|
||||
|
||||
static {
|
||||
ForestryAPI.farmRegistry = INSTANCE;
|
||||
@@ -42,6 +44,14 @@ public final class FarmRegistry implements IFarmRegistry {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public void registerFarmLogic(String identifier, IFarmLogic logic) {
|
||||
logics.put(identifier, logic);
|
||||
}
|
||||
|
||||
public IFarmLogic getFarmLogic(String identifier) {
|
||||
return logics.get(identifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerFarmables(String identifier, IFarmable... farmablesArray) {
|
||||
farmables.putAll(identifier, Arrays.asList(farmablesArray));
|
||||
@@ -90,7 +100,11 @@ public final class FarmRegistry implements IFarmRegistry {
|
||||
try {
|
||||
String fertilizer = fertilizerList[i];
|
||||
String[] fertilizers = fertilizer.split(";");
|
||||
ItemStack fertilizerItem = ItemStackUtil.parseItemStackString(fertilizers[0], OreDictionary.WILDCARD_VALUE);
|
||||
String itemName = fertilizers[0];
|
||||
if(itemName.equals("forestry:fertilizerCompound")){
|
||||
itemName = "forestry:fertilizer_compound";
|
||||
}
|
||||
ItemStack fertilizerItem = ItemStackUtil.parseItemStackString(itemName, OreDictionary.WILDCARD_VALUE);
|
||||
int fertilizerValue = Integer.parseInt(fertilizers[1]);
|
||||
registerFertilizer(fertilizerItem, fertilizerValue);
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -190,6 +190,13 @@ public class PluginFarming extends BlankForestryPlugin {
|
||||
Circuits.farmCocoaManual = new CircuitFarmLogic("manualCocoa", new FarmLogicCocoa()).setManual();
|
||||
|
||||
Circuits.farmOrchardManual = new CircuitFarmLogic("manualOrchard", new FarmLogicOrchard());
|
||||
|
||||
// Make Forestry farming logics accessible to plugins via FarmRegistry
|
||||
FarmRegistry.getInstance().registerFarmLogic("farmArboreal",((CircuitFarmLogic)Circuits.farmArborealManaged).getFarmLogic());
|
||||
FarmRegistry.getInstance().registerFarmLogic("farmShroom",((CircuitFarmLogic)Circuits.farmShroomManaged).getFarmLogic());
|
||||
FarmRegistry.getInstance().registerFarmLogic("farmWheat",((CircuitFarmLogic)Circuits.farmCerealManaged).getFarmLogic());
|
||||
FarmRegistry.getInstance().registerFarmLogic("farmVegetables",((CircuitFarmLogic)Circuits.farmVegetableManaged).getFarmLogic());
|
||||
FarmRegistry.getInstance().registerFarmLogic("farmInfernal",((CircuitFarmLogic)Circuits.farmInfernalManaged).getFarmLogic());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -213,7 +220,7 @@ public class PluginFarming extends BlankForestryPlugin {
|
||||
valve.setTagCompound(compound);
|
||||
control.setTagCompound(compound);
|
||||
|
||||
RecipeUtil.addRecipe("farm_basic", basic,
|
||||
RecipeUtil.addRecipe("farm_basic_" + block.getUid(), basic,
|
||||
"I#I",
|
||||
"WCW",
|
||||
'#', block.getBase(),
|
||||
@@ -221,27 +228,27 @@ public class PluginFarming extends BlankForestryPlugin {
|
||||
'C', coreItems.tubes.get(EnumElectronTube.TIN, 1),
|
||||
'I', "ingotCopper");
|
||||
|
||||
RecipeUtil.addRecipe("farm_gearbox", gearbox,
|
||||
RecipeUtil.addRecipe("farm_gearbox_" + block.getUid(), gearbox,
|
||||
" # ",
|
||||
"TTT",
|
||||
'#', basic,
|
||||
'T', "gearTin");
|
||||
|
||||
RecipeUtil.addRecipe("farm_hatch", hatch,
|
||||
RecipeUtil.addRecipe("farm_hatch_" + block.getUid(), hatch,
|
||||
" # ",
|
||||
"TDT",
|
||||
'#', basic,
|
||||
'T', "gearTin",
|
||||
'D', OreDictUtil.TRAPDOOR_WOOD);
|
||||
|
||||
RecipeUtil.addRecipe("farm_valve", valve,
|
||||
RecipeUtil.addRecipe("farm_valve_" + block.getUid(), valve,
|
||||
" # ",
|
||||
"XTX",
|
||||
'#', basic,
|
||||
'T', "gearTin",
|
||||
'X', "blockGlass");
|
||||
|
||||
RecipeUtil.addRecipe("farm_control", control,
|
||||
RecipeUtil.addRecipe("farm_control_" + block.getUid(), control,
|
||||
" # ",
|
||||
"XTX",
|
||||
'#', basic,
|
||||
|
||||
@@ -20,7 +20,7 @@ public class BlockRegistryFarming extends BlockRegistry {
|
||||
|
||||
public BlockRegistryFarming() {
|
||||
mushroom = new BlockMushroom();
|
||||
registerBlock(mushroom, new ItemBlockForestry(mushroom), "mushroom");
|
||||
registerBlock(mushroom, new ItemBlockForestry<>(mushroom), "mushroom");
|
||||
|
||||
farm = new BlockFarm();
|
||||
registerBlock(farm, new ItemBlockFarm(farm), "ffarm");
|
||||
|
||||
@@ -26,6 +26,10 @@ public class CircuitFarmLogic extends Circuit {
|
||||
super(uid);
|
||||
this.logic = logic;
|
||||
}
|
||||
|
||||
public IFarmLogic getFarmLogic() {
|
||||
return logic;
|
||||
}
|
||||
|
||||
public CircuitFarmLogic setManual() {
|
||||
isManual = true;
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package forestry.farming.compat;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.farming.PluginFarming;
|
||||
import forestry.farming.blocks.BlockRegistryFarming;
|
||||
import forestry.farming.models.EnumFarmBlockTexture;
|
||||
import forestry.plugins.ForestryPluginUids;
|
||||
|
||||
import mezz.jei.api.IModPlugin;
|
||||
import mezz.jei.api.ISubtypeRegistry;
|
||||
import mezz.jei.api.JEIPlugin;
|
||||
|
||||
@JEIPlugin
|
||||
public class FarmingJeiPlugin implements IModPlugin {
|
||||
@Override
|
||||
public void registerItemSubtypes(ISubtypeRegistry subtypeRegistry) {
|
||||
if (!ForestryAPI.enabledPlugins.contains(ForestryPluginUids.FARMING)) {
|
||||
return;
|
||||
}
|
||||
|
||||
BlockRegistryFarming blocks = PluginFarming.getBlocks();
|
||||
Item farmBlock = Item.getItemFromBlock(blocks.farm);
|
||||
subtypeRegistry.registerSubtypeInterpreter(farmBlock, itemStack -> {
|
||||
NBTTagCompound nbt = itemStack.getTagCompound();
|
||||
EnumFarmBlockTexture texture = EnumFarmBlockTexture.getFromCompound(nbt);
|
||||
return itemStack.getItemDamage() + "." + texture.getUid();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@FieldsAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package forestry.farming.compat;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import forestry.core.utils.FieldsAreNonnullByDefault;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
@@ -73,6 +73,11 @@ public class FarmLogicCocoa extends FarmLogic {
|
||||
public boolean isAcceptedWindfall(ItemStack stack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData) {
|
||||
// do nothing as soil is not managed by farm
|
||||
}
|
||||
|
||||
@Override
|
||||
public NonNullList<ItemStack> collect(World world, IFarmHousing farmHousing) {
|
||||
|
||||
+23
-13
@@ -13,34 +13,44 @@ package forestry.farming.logic;
|
||||
import java.util.Collection;
|
||||
import java.util.Stack;
|
||||
|
||||
import forestry.farming.FarmRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import forestry.api.farming.FarmDirection;
|
||||
import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmHousing;
|
||||
import forestry.api.farming.IFarmable;
|
||||
import forestry.core.utils.BlockUtil;
|
||||
import forestry.farming.FarmRegistry;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class FarmLogicEnder extends FarmLogicHomogeneous {
|
||||
public class FarmLogicExU extends FarmLogicHomogeneous {
|
||||
|
||||
public FarmLogicEnder() {
|
||||
super(new ItemStack(Blocks.END_STONE), Blocks.END_STONE.getDefaultState(), FarmRegistry.getInstance().getFarmables("farmEnder"));
|
||||
private final String name;
|
||||
private final Item iconItem;
|
||||
|
||||
public FarmLogicExU(String name, Item iconItem, Block soil, String farmablesKey) {
|
||||
super(new ItemStack(soil), soil.getDefaultState(), FarmRegistry.getInstance().getFarmables(farmablesKey));
|
||||
if (soil.equals(Blocks.REDSTONE_ORE)) {
|
||||
super.addSoil(new ItemStack(Blocks.LIT_REDSTONE_ORE), Blocks.LIT_REDSTONE_ORE.getDefaultState(), false);
|
||||
}
|
||||
this.name = name;
|
||||
this.iconItem = iconItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Managed Ender Farm";
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getIconItemStack() {
|
||||
return new ItemStack(Items.ENDER_EYE);
|
||||
return new ItemStack(iconItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -97,4 +97,9 @@ public class FarmLogicGourd extends FarmLogic {
|
||||
return crops;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData) {
|
||||
// do nothing as soil is not managed by farm
|
||||
|
||||
}
|
||||
}
|
||||
@@ -37,17 +37,17 @@ public abstract class FarmLogicHomogeneous extends FarmLogic {
|
||||
this.farmables = new ArrayList<>(farmables);
|
||||
}
|
||||
|
||||
protected void addSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData){
|
||||
public void addSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData){
|
||||
soils.add(new Soil(resource, soilState, hasMetaData));
|
||||
}
|
||||
|
||||
protected boolean isAcceptedSoil(IBlockState blockState) {
|
||||
for(Soil soil : soils){
|
||||
IBlockState soilState = soil.soilState;
|
||||
IBlockState soilState = soil.getSoilState();
|
||||
Block soilBlock = soilState.getBlock();
|
||||
Block block = blockState.getBlock();
|
||||
if(soilState.getBlock() == blockState.getBlock()){
|
||||
if(!soil.hasMetaData || block.getMetaFromState(blockState) == soilBlock.getMetaFromState(soilState)){
|
||||
if(!soil.hasMetaData() || block.getMetaFromState(blockState) == soilBlock.getMetaFromState(soilState)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -58,7 +58,7 @@ public abstract class FarmLogicHomogeneous extends FarmLogic {
|
||||
@Override
|
||||
public boolean isAcceptedResource(ItemStack itemstack) {
|
||||
for(Soil soil : soils){
|
||||
ItemStack resource = soil.resource;
|
||||
ItemStack resource = soil.getResource();
|
||||
if(resource.isItemEqual(itemstack)){
|
||||
return true;
|
||||
}
|
||||
@@ -95,7 +95,7 @@ public abstract class FarmLogicHomogeneous extends FarmLogic {
|
||||
private boolean maintainSoil(World world, IFarmHousing farmHousing, BlockPos pos, FarmDirection direction, int extent) {
|
||||
for(Soil soil : soils){
|
||||
NonNullList<ItemStack> resources = NonNullList.create();
|
||||
resources.add(soil.resource);
|
||||
resources.add(soil.getResource());
|
||||
if (!farmHousing.getFarmInventory().hasResources(resources)) {
|
||||
continue;
|
||||
}
|
||||
@@ -120,7 +120,7 @@ public abstract class FarmLogicHomogeneous extends FarmLogic {
|
||||
|
||||
produce.addAll(BlockUtil.getBlockDrops(world, position));
|
||||
|
||||
BlockUtil.setBlockWithPlaceSound(world, position, soil.soilState);
|
||||
BlockUtil.setBlockWithPlaceSound(world, position, soil.getSoilState());
|
||||
farmHousing.getFarmInventory().removeResources(resources);
|
||||
return true;
|
||||
}
|
||||
@@ -130,16 +130,4 @@ public abstract class FarmLogicHomogeneous extends FarmLogic {
|
||||
}
|
||||
|
||||
protected abstract boolean maintainGermlings(World world, IFarmHousing farmHousing, BlockPos pos, FarmDirection direction, int extent);
|
||||
|
||||
private static class Soil{
|
||||
protected final ItemStack resource;
|
||||
protected final IBlockState soilState;
|
||||
protected final boolean hasMetaData;
|
||||
|
||||
public Soil(ItemStack resource, IBlockState soilState, boolean hasMetaData) {
|
||||
this.resource = resource;
|
||||
this.soilState = soilState;
|
||||
this.hasMetaData = hasMetaData;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -130,6 +130,11 @@ public class FarmLogicOrchard extends FarmLogic {
|
||||
public String getName() {
|
||||
return "Orchard";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData) {
|
||||
// do nothing as soil is not managed by farm
|
||||
}
|
||||
|
||||
private Collection<ICrop> getHarvestBlocks(World world, BlockPos position) {
|
||||
Set<BlockPos> seen = new HashSet<>();
|
||||
|
||||
@@ -10,15 +10,10 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.logic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Stack;
|
||||
|
||||
import forestry.api.farming.FarmDirection;
|
||||
import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmHousing;
|
||||
import forestry.api.farming.IFarmable;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.farming.FarmRegistry;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
@@ -26,10 +21,23 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import forestry.api.farming.FarmDirection;
|
||||
import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmHousing;
|
||||
import forestry.api.farming.IFarmable;
|
||||
import forestry.farming.FarmRegistry;
|
||||
|
||||
public class FarmLogicReeds extends FarmLogic {
|
||||
|
||||
private final Collection<IFarmable> germlings = FarmRegistry.getInstance().getFarmables("farmPoales");
|
||||
|
||||
private ArrayList<Soil> soils = new ArrayList<>();
|
||||
|
||||
|
||||
public FarmLogicReeds() {
|
||||
addSoil(new ItemStack(Blocks.SAND), Blocks.SAND.getDefaultState(),true);
|
||||
addSoil(new ItemStack(Blocks.DIRT), Blocks.DIRT.getDefaultState(),false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getIconItemStack() {
|
||||
return new ItemStack(Items.REEDS);
|
||||
@@ -44,6 +52,11 @@ public class FarmLogicReeds extends FarmLogic {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData) {
|
||||
this.soils.add(new Soil(resource,soilState,hasMetaData));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFertilizerConsumption() {
|
||||
return 10;
|
||||
@@ -60,7 +73,14 @@ public class FarmLogicReeds extends FarmLogic {
|
||||
return false;
|
||||
}
|
||||
|
||||
return ItemStackUtil.equals(Blocks.SAND, itemstack) || ItemStackUtil.equals(Blocks.DIRT, itemstack);
|
||||
for(Soil soil : soils){
|
||||
ItemStack resource = soil.getResource();
|
||||
if(resource.isItemEqual(itemstack)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -104,4 +124,6 @@ public class FarmLogicReeds extends FarmLogic {
|
||||
return crops;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -131,4 +131,9 @@ public class FarmLogicRubber extends FarmLogic {
|
||||
return crops;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData) {
|
||||
// do nothing as soil is not managed by farm
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,6 +10,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.logic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Stack;
|
||||
|
||||
@@ -20,7 +21,6 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.farming.FarmDirection;
|
||||
import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmHousing;
|
||||
@@ -29,8 +29,14 @@ import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.farming.FarmRegistry;
|
||||
|
||||
public class FarmLogicSucculent extends FarmLogic {
|
||||
|
||||
private final Collection<IFarmable> germlings = FarmRegistry.getInstance().getFarmables("farmSucculentes");
|
||||
|
||||
private ArrayList<Soil> soils = new ArrayList<>();
|
||||
|
||||
public FarmLogicSucculent() {
|
||||
addSoil(new ItemStack(Blocks.SAND), Blocks.SAND.getDefaultState(),true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getIconItemStack() {
|
||||
return new ItemStack(Items.DYE, 1, 2);
|
||||
@@ -45,6 +51,11 @@ public class FarmLogicSucculent extends FarmLogic {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData) {
|
||||
this.soils.add(new Soil(resource,soilState,hasMetaData));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFertilizerConsumption() {
|
||||
return 10;
|
||||
@@ -54,14 +65,20 @@ public class FarmLogicSucculent extends FarmLogic {
|
||||
public int getWaterConsumption(float hydrationModifier) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedResource(ItemStack itemstack) {
|
||||
if (isManual) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return ItemStackUtil.equals(Blocks.SAND, itemstack);
|
||||
for(Soil soil : soils){
|
||||
ItemStack resource = soil.getResource();
|
||||
if(resource.isItemEqual(itemstack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,17 +10,19 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.logic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import forestry.api.farming.FarmDirection;
|
||||
import forestry.api.farming.IFarmHousing;
|
||||
import forestry.core.utils.BlockUtil;
|
||||
@@ -28,16 +30,20 @@ import forestry.farming.FarmHelper;
|
||||
|
||||
public abstract class FarmLogicWatered extends FarmLogic {
|
||||
|
||||
protected final IBlockState ground;
|
||||
private final ItemStack resource;
|
||||
|
||||
|
||||
private final List<Soil> soils = new ArrayList<>();
|
||||
|
||||
private static final FluidStack STACK_WATER = new FluidStack(FluidRegistry.WATER, Fluid.BUCKET_VOLUME);
|
||||
|
||||
protected NonNullList<ItemStack> produce = NonNullList.create();
|
||||
|
||||
protected FarmLogicWatered(ItemStack resource, IBlockState ground) {
|
||||
this.ground = ground;
|
||||
this.resource = resource;
|
||||
addSoil(resource,ground,false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData) {
|
||||
soils.add(new Soil(resource,soilState,hasMetaData));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -51,12 +57,28 @@ public abstract class FarmLogicWatered extends FarmLogic {
|
||||
}
|
||||
|
||||
protected boolean isAcceptedGround(IBlockState ground) {
|
||||
return this.ground.getBlock() == ground.getBlock();
|
||||
for(Soil soil : soils){
|
||||
IBlockState soilState = soil.getSoilState();
|
||||
Block soilBlock = soilState.getBlock();
|
||||
Block block = ground.getBlock();
|
||||
if(soilState.getBlock() == ground.getBlock()){
|
||||
if(!soil.hasMetaData() || block.getMetaFromState(ground) == soilBlock.getMetaFromState(soilState)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedResource(ItemStack itemstack) {
|
||||
return resource.isItemEqual(itemstack);
|
||||
for(Soil soil : soils){
|
||||
ItemStack resource = soil.getResource();
|
||||
if(resource.isItemEqual(itemstack)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -85,34 +107,36 @@ public abstract class FarmLogicWatered extends FarmLogic {
|
||||
}
|
||||
|
||||
private boolean maintainSoil(World world, IFarmHousing farmHousing, BlockPos pos, FarmDirection direction, int extent) {
|
||||
NonNullList<ItemStack> resources = NonNullList.create();
|
||||
resources.add(resource);
|
||||
for (Soil soil : soils) {
|
||||
NonNullList<ItemStack> resources = NonNullList.create();
|
||||
resources.add(soil.getResource());
|
||||
|
||||
for (int i = 0; i < extent; i++) {
|
||||
BlockPos position = translateWithOffset(pos, direction, i);
|
||||
IBlockState state = world.getBlockState(position);
|
||||
if (isAcceptedGround(state) || isWaterSourceBlock(world, position) || !farmHousing.getFarmInventory().hasResources(resources)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BlockPos platformPosition = position.down();
|
||||
IBlockState blockState = world.getBlockState(platformPosition);
|
||||
if (!FarmHelper.bricks.contains(blockState.getBlock())) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!BlockUtil.isReplaceableBlock(state, world, position)) {
|
||||
produce.addAll(BlockUtil.getBlockDrops(world, position));
|
||||
world.setBlockToAir(position);
|
||||
return trySetSoil(world, farmHousing, position);
|
||||
}
|
||||
|
||||
if (!isManual) {
|
||||
if (trySetWater(world, farmHousing, position)) {
|
||||
return true;
|
||||
for (int i = 0; i < extent; i++) {
|
||||
BlockPos position = translateWithOffset(pos, direction, i);
|
||||
IBlockState state = world.getBlockState(position);
|
||||
if (isAcceptedGround(state) || isWaterSourceBlock(world, position) || !farmHousing.getFarmInventory().hasResources(resources)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BlockPos platformPosition = position.down();
|
||||
IBlockState blockState = world.getBlockState(platformPosition);
|
||||
if (!FarmHelper.bricks.contains(blockState.getBlock())) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!BlockUtil.isReplaceableBlock(state, world, position)) {
|
||||
produce.addAll(BlockUtil.getBlockDrops(world, position));
|
||||
world.setBlockToAir(position);
|
||||
return trySetSoil(world, farmHousing, position, soil.getResource(), soil.getSoilState());
|
||||
}
|
||||
|
||||
if (!isManual) {
|
||||
if (trySetWater(world, farmHousing, position)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return trySetSoil(world, farmHousing, position, soil.getResource(), soil.getSoilState());
|
||||
}
|
||||
|
||||
return trySetSoil(world, farmHousing, position);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +166,7 @@ public abstract class FarmLogicWatered extends FarmLogic {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean trySetSoil(World world, IFarmHousing farmHousing, BlockPos position) {
|
||||
private boolean trySetSoil(World world, IFarmHousing farmHousing, BlockPos position, ItemStack resource, IBlockState ground) {
|
||||
NonNullList<ItemStack> resources = NonNullList.create();
|
||||
resources.add(resource);
|
||||
if (!farmHousing.getFarmInventory().hasResources(resources)) {
|
||||
|
||||
@@ -53,18 +53,12 @@ public class FarmableGE implements IFarmable {
|
||||
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
|
||||
ITreeRoot treeRoot = TreeManager.treeRoot;
|
||||
|
||||
germling = GeneticsUtil.convertToGeneticEquivalent(germling);
|
||||
if (treeRoot.isMember(germling)) {
|
||||
ITree tree = treeRoot.getMember(germling);
|
||||
return treeRoot.plantSapling(world, tree, player.getGameProfile(), pos);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
ITree tree = treeRoot.getMember(germling);
|
||||
return tree != null && treeRoot.plantSapling(world, tree, player.getGameProfile(), pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGermling(ItemStack itemstack) {
|
||||
itemstack = GeneticsUtil.convertToGeneticEquivalent(itemstack);
|
||||
return TreeManager.treeRoot.isMember(itemstack);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
/*******************************************************************************
|
||||
* 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.farming.logic;
|
||||
|
||||
import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmable;
|
||||
import forestry.core.network.packets.PacketFXSignal;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.core.utils.NetworkUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class FarmableSapling implements IFarmable {
|
||||
protected final ItemStack germling;
|
||||
protected final boolean ignoreMetadata;
|
||||
protected final Block saplingBlock;
|
||||
protected final ItemStack[] windfall;
|
||||
|
||||
public FarmableSapling(final ItemStack germling, final ItemStack[] windfall) {
|
||||
this(germling, windfall, true);
|
||||
}
|
||||
|
||||
public FarmableSapling(final ItemStack germling, final ItemStack[] windfall, boolean addSubItems) {
|
||||
this.germling = germling;
|
||||
this.windfall = windfall;
|
||||
this.saplingBlock = ItemStackUtil.getBlock(germling);
|
||||
this.ignoreMetadata = addSubItems;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
|
||||
ItemStack copy = germling.copy();
|
||||
player.setHeldItem(EnumHand.MAIN_HAND, copy);
|
||||
EnumActionResult actionResult = copy.onItemUse(player, world, pos.down(), EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0);
|
||||
player.setHeldItem(EnumHand.MAIN_HAND, ItemStack.EMPTY);
|
||||
if (actionResult == EnumActionResult.SUCCESS) {
|
||||
PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.SoundFXType.BLOCK_PLACE, pos, Blocks.SAPLING.getDefaultState());
|
||||
NetworkUtil.sendNetworkPacket(packet, pos, world);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSaplingAt(World world, BlockPos pos) {
|
||||
return world.getBlockState(pos).getBlock() == this.saplingBlock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICrop getCropAt(World world, BlockPos pos, IBlockState blockState) {
|
||||
Block block = blockState.getBlock();
|
||||
if (!block.isWood(world, pos)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new CropDestroy(world, blockState, pos, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGermling(ItemStack itemstack) {
|
||||
if (ignoreMetadata) {
|
||||
return ItemStack.areItemsEqual(germling, new ItemStack((itemstack.getItem())));
|
||||
}
|
||||
return ItemStack.areItemsEqual(germling, itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWindfall(ItemStack itemstack) {
|
||||
for (ItemStack drop : windfall) {
|
||||
if (drop.isItemEqual(itemstack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -10,86 +10,13 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.logic;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.arboriculture.ITree;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmable;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.core.network.packets.PacketFXSignal;
|
||||
import forestry.core.utils.GeneticsUtil;
|
||||
import forestry.core.utils.NetworkUtil;
|
||||
import forestry.plugins.ForestryPluginUids;
|
||||
|
||||
public class FarmableVanillaSapling implements IFarmable {
|
||||
|
||||
protected final ItemStack germling;
|
||||
private final ItemStack[] windfall;
|
||||
public class FarmableVanillaSapling extends FarmableSapling {
|
||||
|
||||
public FarmableVanillaSapling() {
|
||||
this.germling = new ItemStack(Blocks.SAPLING);
|
||||
this.windfall = new ItemStack[]{new ItemStack(Items.APPLE), new ItemStack(FarmableCocoa.COCOA_SEED, 1, FarmableCocoa.COCOA_META)};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
|
||||
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.ARBORICULTURE)) {
|
||||
IIndividual tree = GeneticsUtil.getGeneticEquivalent(germling);
|
||||
if (!(tree instanceof ITree)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return TreeManager.treeRoot.plantSapling(world, (ITree) tree, player.getGameProfile(), pos);
|
||||
} else {
|
||||
EnumActionResult actionResult = germling.copy().onItemUse(player, world, pos.down(), EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0);
|
||||
if (actionResult == EnumActionResult.SUCCESS) {
|
||||
PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.SoundFXType.BLOCK_PLACE, pos, Blocks.SAPLING.getDefaultState());
|
||||
NetworkUtil.sendNetworkPacket(packet, pos, world);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSaplingAt(World world, BlockPos pos) {
|
||||
return world.getBlockState(pos).getBlock() == Blocks.SAPLING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICrop getCropAt(World world, BlockPos pos, IBlockState blockState) {
|
||||
Block block = blockState.getBlock();
|
||||
if (!block.isWood(world, pos)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new CropDestroy(world, blockState, pos, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGermling(ItemStack itemstack) {
|
||||
return ItemStack.areItemsEqual(germling, itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWindfall(ItemStack itemstack) {
|
||||
for (ItemStack drop : windfall) {
|
||||
if (drop.isItemEqual(itemstack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
super(new ItemStack(Blocks.SAPLING), new ItemStack[]{new ItemStack(Items.APPLE), new ItemStack(FarmableCocoa.COCOA_SEED, 1, FarmableCocoa.COCOA_META)});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package forestry.farming.logic;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
class Soil {
|
||||
private final ItemStack resource;
|
||||
private final IBlockState soilState;
|
||||
private final boolean hasMetaData;
|
||||
|
||||
public Soil(ItemStack resource, IBlockState soilState, boolean hasMetaData) {
|
||||
this.resource = resource;
|
||||
this.soilState = soilState;
|
||||
this.hasMetaData = hasMetaData;
|
||||
}
|
||||
|
||||
public ItemStack getResource() {
|
||||
return resource;
|
||||
}
|
||||
|
||||
public IBlockState getSoilState() {
|
||||
return soilState;
|
||||
}
|
||||
|
||||
public boolean hasMetaData() {
|
||||
return this.hasMetaData;
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,8 @@ package forestry.farming.models;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
@@ -109,6 +111,10 @@ public enum EnumFarmBlockTexture {
|
||||
public String getName() {
|
||||
return base.getItem().getItemStackDisplayName(base);
|
||||
}
|
||||
|
||||
public String getUid() {
|
||||
return toString().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
public ItemStack getBase() {
|
||||
return base;
|
||||
|
||||
@@ -769,7 +769,7 @@ public class FarmController extends RectangularMultiblockControllerBase implemen
|
||||
|
||||
@Override
|
||||
public boolean plantGermling(IFarmable germling, World world, BlockPos pos) {
|
||||
EntityPlayer player = PlayerUtil.getPlayer(world, getOwnerHandler().getOwner());
|
||||
EntityPlayer player = PlayerUtil.getFakePlayer(world, getOwnerHandler().getOwner());
|
||||
return player != null && inventory.plantGermling(germling, player, pos);
|
||||
}
|
||||
|
||||
|
||||
@@ -95,8 +95,7 @@ public class InventoryFarm extends InventoryAdapterRestricted implements IFarmIn
|
||||
|
||||
@Override
|
||||
public void removeResources(NonNullList<ItemStack> resources) {
|
||||
EntityPlayer player = PlayerUtil.getPlayer(farmController.getWorldObj(), farmController.getOwnerHandler().getOwner());
|
||||
InventoryUtil.removeSets(resourcesInventory, 1, resources, player, false, true, false, true);
|
||||
InventoryUtil.removeSets(resourcesInventory, 1, resources, null, false, true, false, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -14,9 +14,9 @@ public class BlockRegistryGreenhouse extends BlockRegistry {
|
||||
public BlockRegistryGreenhouse() {
|
||||
greenhouseBlockMap = BlockGreenhouse.create();
|
||||
for (BlockGreenhouse block : greenhouseBlockMap.values()) {
|
||||
ItemBlock itemBlock = new ItemBlockForestry(block);
|
||||
ItemBlock itemBlock = new ItemBlockForestry<>(block);
|
||||
if (block instanceof BlockGreenhouseDoor) {
|
||||
itemBlock = new ItemBlockGreenhouseDoor(block);
|
||||
itemBlock = new ItemBlockGreenhouseDoor((BlockGreenhouseDoor) block);
|
||||
}
|
||||
registerBlock(block, itemBlock, "greenhouse." + block.getGreenhouseType());
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import net.minecraft.world.World;
|
||||
|
||||
public class ItemBlockGreenhouseDoor extends ItemBlockForestry<BlockGreenhouseDoor> {
|
||||
|
||||
public ItemBlockGreenhouseDoor(Block block) {
|
||||
public ItemBlockGreenhouseDoor(BlockGreenhouseDoor block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,13 +21,13 @@ public class BlockRegistryLepidopterology extends BlockRegistry {
|
||||
|
||||
public BlockRegistryLepidopterology() {
|
||||
butterflyChest = new BlockLepidopterology(BlockTypeLepidopterologyTesr.LEPICHEST);
|
||||
registerBlock(butterflyChest, new ItemBlockForestry(butterflyChest), "butterfly_chest");
|
||||
registerBlock(butterflyChest, new ItemBlockForestry<>(butterflyChest), "butterfly_chest");
|
||||
|
||||
ButterflyAlleles.registerCocoonAlleles();
|
||||
cocoon = new BlockCocoon();
|
||||
registerBlock(cocoon, new ItemBlockForestry(cocoon), "cocoon");
|
||||
registerBlock(cocoon, new ItemBlockForestry<>(cocoon), "cocoon");
|
||||
|
||||
solidCocoon = new BlockSolidCocoon();
|
||||
registerBlock(solidCocoon, new ItemBlockForestry(solidCocoon), "cocoon.solid");
|
||||
registerBlock(solidCocoon, new ItemBlockForestry<>(solidCocoon), "cocoon.solid");
|
||||
}
|
||||
}
|
||||
@@ -20,12 +20,12 @@ public class BlockRegistryMail extends BlockRegistry {
|
||||
|
||||
public BlockRegistryMail() {
|
||||
mailbox = new BlockMail(BlockTypeMail.MAILBOX);
|
||||
registerBlock(mailbox, new ItemBlockForestry(mailbox), "mailbox");
|
||||
registerBlock(mailbox, new ItemBlockForestry<>(mailbox), "mailbox");
|
||||
|
||||
tradeStation = new BlockMail(BlockTypeMail.TRADE_STATION);
|
||||
registerBlock(tradeStation, new ItemBlockForestry(tradeStation), "trade_station");
|
||||
registerBlock(tradeStation, new ItemBlockForestry<>(tradeStation), "trade_station");
|
||||
|
||||
stampCollector = new BlockMail(BlockTypeMail.PHILATELIST);
|
||||
registerBlock(stampCollector, new ItemBlockForestry(stampCollector), "stamp_collector");
|
||||
registerBlock(stampCollector, new ItemBlockForestry<>(stampCollector), "stamp_collector");
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import java.util.Set;
|
||||
|
||||
import net.minecraft.command.ICommand;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.IChunkGenerator;
|
||||
|
||||
@@ -111,6 +112,10 @@ public abstract class BlankForestryPlugin implements IForestryPlugin {
|
||||
public void populateChunkRetroGen(World world, Random rand, int chunkX, int chunkZ) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decorateBiome(World world, Random rand, BlockPos pos) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getHiddenItems(List<ItemStack> hiddenItems) {
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.util.Set;
|
||||
|
||||
import net.minecraft.command.ICommand;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.IChunkGenerator;
|
||||
|
||||
@@ -58,6 +59,8 @@ public interface IForestryPlugin {
|
||||
|
||||
void populateChunkRetroGen(World world, Random rand, int chunkX, int chunkZ);
|
||||
|
||||
void decorateBiome(World world, Random rand, BlockPos pos);
|
||||
|
||||
void getHiddenItems(List<ItemStack> hiddenItems);
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -28,6 +28,7 @@ import net.minecraft.command.CommandHandler;
|
||||
import net.minecraft.command.ICommand;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.IChunkGenerator;
|
||||
|
||||
@@ -65,7 +66,8 @@ public class PluginManager {
|
||||
SETUP, // setup API to make it functional. GameMode Configs are not yet accessible
|
||||
SETUP_DISABLED, // setup fallback API to avoid crashes
|
||||
REGISTER, // register basic blocks and items
|
||||
PRE_INIT, // register handlers, triggers, definitions, backpacks, crates, and anything that depends on basic items
|
||||
PRE_INIT, // register handlers, triggers, definitions, and anything that depends on basic items
|
||||
BACKPACKS_CRATES, // backpacks, crates
|
||||
INIT, // anything that depends on PreInit stages, recipe registration
|
||||
POST_INIT, // stubborn mod integration, dungeon loot, and finalization of things that take input from mods
|
||||
FINISHED
|
||||
@@ -227,11 +229,19 @@ public class PluginManager {
|
||||
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.BUILDCRAFT_STATEMENTS)) {
|
||||
plugin.registerTriggers();
|
||||
}
|
||||
Log.debug("Pre-Init Complete: {}", plugin);
|
||||
}
|
||||
}
|
||||
|
||||
public static void runRegisterBackpacksAndCrates() {
|
||||
stage = Stage.BACKPACKS_CRATES;
|
||||
for (IForestryPlugin plugin : loadedPlugins) {
|
||||
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.STORAGE)) {
|
||||
Log.debug("BackpacksAndCrates Start: {}", plugin);
|
||||
plugin.registerBackpackItems();
|
||||
plugin.registerCrates();
|
||||
Log.debug("BackpacksAndCrates Complete: {}", plugin);
|
||||
}
|
||||
Log.debug("Pre-Init Complete: {}", plugin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,6 +296,12 @@ public class PluginManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static void decorateBiome(World world, Random rand, BlockPos pos) {
|
||||
for (IForestryPlugin plugin : loadedPlugins) {
|
||||
plugin.decorateBiome(world, rand, pos);
|
||||
}
|
||||
}
|
||||
|
||||
public static void populateChunkRetroGen(World world, Random rand, int chunkX, int chunkZ) {
|
||||
for (IForestryPlugin plugin : loadedPlugins) {
|
||||
plugin.populateChunkRetroGen(world, rand, chunkX, chunkZ);
|
||||
|
||||
@@ -72,7 +72,7 @@ public class PluginActuallyAdditions extends BlankForestryPlugin {
|
||||
}
|
||||
|
||||
//add canola oil fermenting in still
|
||||
Fluid oil = getFluid("oil");
|
||||
Fluid oil = getFluid("refinedcanolaoil");
|
||||
if (oil != null) {
|
||||
RecipeManagers.stillManager.addRecipe(200, new FluidStack(canolaOil, 5), new FluidStack(oil, 5));
|
||||
}
|
||||
|
||||
@@ -11,8 +11,10 @@
|
||||
package forestry.plugins.compat;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import forestry.api.circuits.ChipsetManager;
|
||||
import forestry.api.circuits.ICircuit;
|
||||
import forestry.api.circuits.ICircuitLayout;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.core.PluginCore;
|
||||
@@ -25,7 +27,7 @@ import forestry.core.utils.Log;
|
||||
import forestry.core.utils.ModUtil;
|
||||
import forestry.farming.FarmRegistry;
|
||||
import forestry.farming.circuits.CircuitFarmLogic;
|
||||
import forestry.farming.logic.FarmLogicEnder;
|
||||
import forestry.farming.logic.FarmLogicExU;
|
||||
import forestry.farming.logic.FarmableAgingCrop;
|
||||
import forestry.plugins.BlankForestryPlugin;
|
||||
import forestry.plugins.ForestryPlugin;
|
||||
@@ -33,7 +35,6 @@ import forestry.plugins.ForestryPluginUids;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@@ -58,33 +59,46 @@ public class PluginExtraUtilities extends BlankForestryPlugin {
|
||||
public void doInit() {
|
||||
super.doInit();
|
||||
|
||||
if (Config.isExUtilRedOrchidEnabled()) {
|
||||
registerExPlant("Orchid", "redorchid", "Red Orchid", Blocks.REDSTONE_ORE, circuit -> Circuits.farmOrchidManaged = circuit);
|
||||
}
|
||||
|
||||
if (Config.isExUtilEnderLilyEnabled()) {
|
||||
Block enderLillyBlock = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(ExU, "enderlilly"));
|
||||
Item enderLillyItem = Item.getItemFromBlock(enderLillyBlock);
|
||||
if (enderLillyBlock == Blocks.AIR) {
|
||||
Log.error("Could not find ender lilly block.");
|
||||
} else if (enderLillyItem == Items.AIR) {
|
||||
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);
|
||||
FarmRegistry.getInstance().registerFarmables("farmEnder", new FarmableAgingCrop(new ItemStack(enderLillyItem), enderLillyBlock, growthProperty, harvestAge, replantAge));
|
||||
Circuits.farmEnderManaged = new CircuitFarmLogic("managedEnder", new FarmLogicEnder());
|
||||
}
|
||||
}
|
||||
registerExPlant("Ender", "enderlilly", "Ender Lily", Blocks.END_STONE, circuit -> Circuits.farmEnderManaged = circuit);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRecipes() {
|
||||
super.registerRecipes();
|
||||
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.FARMING) && Circuits.farmEnderManaged != null) {
|
||||
if (!ForestryAPI.enabledPlugins.contains(ForestryPluginUids.FARMING)) return;
|
||||
if(Circuits.farmEnderManaged != null) {
|
||||
ICircuitLayout layoutManaged = ChipsetManager.circuitRegistry.getLayout("forestry.farms.managed");
|
||||
ChipsetManager.solderManager.addRecipe(layoutManaged, PluginCore.getItems().tubes.get(EnumElectronTube.ENDER, 1), Circuits.farmEnderManaged);
|
||||
}
|
||||
if(Circuits.farmOrchidManaged != null) {
|
||||
ICircuitLayout layoutManaged = ChipsetManager.circuitRegistry.getLayout("forestry.farms.managed");
|
||||
ChipsetManager.solderManager.addRecipe(layoutManaged, PluginCore.items.tubes.get(EnumElectronTube.ORCHID, 1), Circuits.farmOrchidManaged);
|
||||
}
|
||||
}
|
||||
|
||||
private void registerExPlant(String id, String itemResourceName, String itemName, Block soil, Consumer<ICircuit> assignTo) {
|
||||
Block plantBlock = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(ExU, itemResourceName));
|
||||
Item plantItem = Item.getItemFromBlock(plantBlock);
|
||||
if(plantBlock == Blocks.AIR) {
|
||||
Log.error("Could not find {} block.", itemName);
|
||||
} else if (plantItem == null) {
|
||||
Log.error("Could not find {} item.", itemName);
|
||||
} else {
|
||||
IProperty<Integer> growthProperty = BlockUtil.getProperty(plantBlock, "growth", Integer.class);
|
||||
if (growthProperty == null) {
|
||||
Log.error("Could not find the growth property of {}.", itemName);
|
||||
} else {
|
||||
int harvestAge = Collections.max(growthProperty.getAllowedValues());
|
||||
int replantAge = plantBlock.getDefaultState().getValue(growthProperty);
|
||||
FarmRegistry.getInstance().registerFarmables(itemName, new FarmableAgingCrop(new ItemStack(plantItem), plantBlock, growthProperty, harvestAge, replantAge));
|
||||
assignTo.accept(new CircuitFarmLogic("managed" + id, new FarmLogicExU("Managed " + itemName + " Farm", plantItem, soil, itemName)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -199,8 +199,8 @@ public class PluginHarvestCraft extends BlankForestryPlugin {
|
||||
genericCropsBuilder.add(
|
||||
"cotton",
|
||||
"rice",
|
||||
"tea",
|
||||
"coffee",
|
||||
"tealeaf",
|
||||
"coffeebean",
|
||||
"candleberry"
|
||||
);
|
||||
genericCropsBuilder.addAll(herbs);
|
||||
@@ -220,9 +220,9 @@ public class PluginHarvestCraft extends BlankForestryPlugin {
|
||||
|
||||
juiceAmount = Math.max(juiceAmount, 1); // Produce at least 1 mb of juice.
|
||||
for (String berryName : berries) {
|
||||
ItemStack berry = getItemStack(berryName + "Item");
|
||||
ItemStack berrySeed = getItemStack(berryName + "seedItem");
|
||||
Block berryBlock = getBlock("pam" + berryName + "Crop");
|
||||
ItemStack berry = getItemStack(berryName + "item");
|
||||
ItemStack berrySeed = getItemStack( berryName + "seeditem");
|
||||
Block berryBlock = getBlock("pam" + berryName + "crop");
|
||||
if (berry != null) {
|
||||
RecipeManagers.squeezerManager.addRecipe(10, berry, Fluids.JUICE.getFluid(juiceAmount));
|
||||
}
|
||||
@@ -238,9 +238,9 @@ public class PluginHarvestCraft extends BlankForestryPlugin {
|
||||
|
||||
juiceAmount = ForestryAPI.activeMode.getIntegerSetting("squeezer.liquid.apple");
|
||||
for (String fruitName : fruits) {
|
||||
ItemStack fruit = getItemStack(fruitName + "Item");
|
||||
ItemStack fruitSeed = getItemStack(fruitName + "seedItem");
|
||||
Block fruitBlock = getBlock("pam" + fruitName + "Crop");
|
||||
ItemStack fruit = getItemStack(fruitName + "item");
|
||||
ItemStack fruitSeed = getItemStack(fruitName + "seeditem");
|
||||
Block fruitBlock = getBlock("pam" + fruitName + "crop");
|
||||
if (fruit != null) {
|
||||
RecipeManagers.squeezerManager.addRecipe(10, fruit, Fluids.JUICE.getFluid(juiceAmount));
|
||||
}
|
||||
@@ -257,9 +257,9 @@ public class PluginHarvestCraft extends BlankForestryPlugin {
|
||||
juiceAmount = ForestryAPI.activeMode.getIntegerSetting("squeezer.liquid.apple") / 2; // vegetables produce less juice
|
||||
juiceAmount = Math.max(juiceAmount, 1); // Produce at least 1 mb of juice.
|
||||
for (String vegetableName : vegetables) {
|
||||
ItemStack vegetable = getItemStack(vegetableName + "Item");
|
||||
ItemStack vegetableSeed = getItemStack(vegetableName + "seedItem");
|
||||
Block vegetableBlock = getBlock("pam" + vegetableName + "Crop");
|
||||
ItemStack vegetable = getItemStack(vegetableName + "item");
|
||||
ItemStack vegetableSeed = getItemStack(vegetableName + "seeditem");
|
||||
Block vegetableBlock = getBlock("pam" + vegetableName + "crop");
|
||||
if (vegetable != null) {
|
||||
RecipeManagers.squeezerManager.addRecipe(10, vegetable, Fluids.JUICE.getFluid(juiceAmount));
|
||||
}
|
||||
@@ -275,9 +275,9 @@ public class PluginHarvestCraft extends BlankForestryPlugin {
|
||||
|
||||
ItemRegistryCore coreItems = PluginCore.getItems();
|
||||
for (String grainName : grains) {
|
||||
ItemStack grain = getItemStack(grainName + "Item");
|
||||
ItemStack grainSeed = getItemStack(grainName + "seedItem");
|
||||
Block grainBlock = getBlock("pam" + grainName + "Crop");
|
||||
ItemStack grain = getItemStack(grainName + "item");
|
||||
ItemStack grainSeed = getItemStack(grainName + "seeditem");
|
||||
Block grainBlock = getBlock("pam" + grainName + "crop");
|
||||
if (grain != null && wheatamount > 0) {
|
||||
RecipeUtil.addRecipe("pam_compost_" + grainName, coreItems.compost.getItemStack(wheatamount), " X ", "X#X", " X ", '#', Blocks.DIRT, 'X', grain);
|
||||
FuelManager.moistenerResource.put(grain, new MoistenerFuel(grain, coreItems.mouldyWheat.getItemStack(), 0, 300));
|
||||
@@ -294,8 +294,8 @@ public class PluginHarvestCraft extends BlankForestryPlugin {
|
||||
}
|
||||
|
||||
for (String treeFruitName : treeFruits) {
|
||||
ItemStack treeFruit = getItemStack(treeFruitName + "Item");
|
||||
Block treeFruitBlock = getBlock("pam" + (Character.toUpperCase(treeFruitName.charAt(0)) + treeFruitName.substring(1)));
|
||||
ItemStack treeFruit = getItemStack(treeFruitName + "item");
|
||||
Block treeFruitBlock = getBlock("pam" + treeFruitName);
|
||||
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.FARMING) && treeFruitBlock != null) {
|
||||
farmRegistry.registerFarmables("farmOrchard", new FarmableAgingCrop(ItemStack.EMPTY, treeFruitBlock, fruitAGE, 2, 0));
|
||||
}
|
||||
@@ -306,7 +306,7 @@ public class PluginHarvestCraft extends BlankForestryPlugin {
|
||||
}
|
||||
|
||||
for (String treeName : trees) {
|
||||
Block fruitBlock = getBlock("pam" + (Character.toUpperCase(treeName.charAt(0)) + treeName.substring(1)));
|
||||
Block fruitBlock = getBlock("pam" + treeName);
|
||||
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.FARMING) && fruitBlock != null) {
|
||||
farmRegistry.registerFarmables("farmOrchard", new FarmableAgingCrop(ItemStack.EMPTY, fruitBlock, fruitAGE, 2, 0));
|
||||
}
|
||||
@@ -314,15 +314,22 @@ public class PluginHarvestCraft extends BlankForestryPlugin {
|
||||
}
|
||||
|
||||
for (String treeName : treesSpecial) {
|
||||
Block fruitBlock = getBlock("pam" + (Character.toUpperCase(treeName.charAt(0)) + treeName.substring(1)));
|
||||
Block fruitBlock = getBlock("pam" + treeName);
|
||||
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.FARMING) && fruitBlock != null) {
|
||||
farmRegistry.registerFarmables("farmOrchard", new FarmableAgingCrop(ItemStack.EMPTY, fruitBlock, fruitAGE, 2, 0));
|
||||
}
|
||||
}
|
||||
|
||||
for (String cropName : genericCrops) {
|
||||
ItemStack genericCropSeed = getItemStack(cropName + "seedItem");
|
||||
Block genericCropBlock = getBlock("pam" + cropName + "Crop");
|
||||
String seedPrefix = cropName;
|
||||
if (seedPrefix.equals("tealeaf")) {
|
||||
seedPrefix = "tea";
|
||||
}
|
||||
if (seedPrefix.equals("coffeebean")) {
|
||||
seedPrefix = "coffee";
|
||||
}
|
||||
ItemStack genericCropSeed = getItemStack(seedPrefix + "seeditem");
|
||||
Block genericCropBlock = getBlock("pam" + cropName + "crop");
|
||||
if (genericCropSeed != null) {
|
||||
RecipeManagers.squeezerManager.addRecipe(10, genericCropSeed, Fluids.SEED_OIL.getFluid(seedamount));
|
||||
}
|
||||
@@ -332,9 +339,9 @@ public class PluginHarvestCraft extends BlankForestryPlugin {
|
||||
}
|
||||
plants.add(cropName);
|
||||
}
|
||||
ItemStack mustardCropSeed = getItemStack("mustard" + "seedItem");
|
||||
Block mustardCropBlock = getBlock("pam" + "mustardseeds" + "Crop");
|
||||
ItemStack mustardFruit = getItemStack("mustard" + "seedsItem");
|
||||
ItemStack mustardCropSeed = getItemStack("mustard" + "seeditem");
|
||||
Block mustardCropBlock = getBlock("pam" + "mustardseeds" + "crop");
|
||||
ItemStack mustardFruit = getItemStack("mustard" + "seedsitem");
|
||||
if (mustardCropSeed != null) {
|
||||
RecipeManagers.squeezerManager.addRecipe(10, mustardCropSeed, Fluids.SEED_OIL.getFluid(seedamount));
|
||||
}
|
||||
@@ -347,16 +354,16 @@ public class PluginHarvestCraft extends BlankForestryPlugin {
|
||||
}
|
||||
|
||||
for (String plantName : plants.build()) {
|
||||
ItemStack plant = getItemStack(plantName + "Item");
|
||||
ItemStack plant = getItemStack(plantName + "item");
|
||||
if (plant != null) {
|
||||
RecipeUtil.addFermenterRecipes(plant, ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.wheat"), Fluids.BIOMASS);
|
||||
}
|
||||
}
|
||||
|
||||
for (String cropnutName : cropNuts) {
|
||||
ItemStack cropnut = getItemStack(cropnutName + "Item");
|
||||
ItemStack cropnutSeed = getItemStack(cropnutName + "seedItem");
|
||||
Block cropnutBlock = getBlock("pam" + cropnutName + "Crop");
|
||||
ItemStack cropnut = getItemStack(cropnutName + "item");
|
||||
ItemStack cropnutSeed = getItemStack(cropnutName + "seeditem");
|
||||
Block cropnutBlock = getBlock("pam" + cropnutName + "crop");
|
||||
if (cropnutSeed != null) {
|
||||
RecipeManagers.squeezerManager.addRecipe(10, cropnutSeed, Fluids.SEED_OIL.getFluid(seedamount));
|
||||
}
|
||||
@@ -370,8 +377,8 @@ public class PluginHarvestCraft extends BlankForestryPlugin {
|
||||
}
|
||||
|
||||
for (String nutName : nuts) {
|
||||
ItemStack nut = getItemStack(nutName + "Item");
|
||||
Block nutBlock = getBlock("pam" + (Character.toUpperCase(nutName.charAt(0)) + nutName.substring(1)));
|
||||
ItemStack nut = getItemStack(nutName + "item");
|
||||
Block nutBlock = getBlock("pam" + nutName);
|
||||
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.FARMING) && nutBlock != null) {
|
||||
farmRegistry.registerFarmables("farmOrchard", new FarmableAgingCrop(ItemStack.EMPTY, nutBlock, fruitAGE, 2, 0));
|
||||
}
|
||||
@@ -380,12 +387,12 @@ public class PluginHarvestCraft extends BlankForestryPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack hcHoneyItem = getItemStack("honeyItem");
|
||||
ItemStack hcHoneyItem = getItemStack("honeyitem");
|
||||
if (hcHoneyItem != null) {
|
||||
RecipeManagers.squeezerManager.addRecipe(10, hcHoneyItem, Fluids.FOR_HONEY.getFluid(Constants.FLUID_PER_HONEY_DROP));
|
||||
}
|
||||
|
||||
ItemStack hcBeeswaxItem = getItemStack("beeswaxItem");
|
||||
ItemStack hcBeeswaxItem = getItemStack("beeswaxitem");
|
||||
if (hcBeeswaxItem != null) {
|
||||
RecipeUtil.addRecipe("pam_wax_capsule", PluginFluids.getItems().waxCapsuleEmpty.getItemStack(ForestryAPI.activeMode.getIntegerSetting("recipe.output.capsule")), "XXX ", 'X', hcBeeswaxItem);
|
||||
}
|
||||
|
||||
@@ -10,11 +10,28 @@
|
||||
******************************************************************************/
|
||||
package forestry.plugins.compat;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.farming.IFarmLogic;
|
||||
import forestry.api.fuels.FuelManager;
|
||||
import forestry.api.fuels.MoistenerFuel;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
@@ -25,48 +42,40 @@ import forestry.core.config.Constants;
|
||||
import forestry.core.fluids.Fluids;
|
||||
import forestry.core.recipes.RecipeUtil;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.core.utils.ModUtil;
|
||||
import forestry.farming.FarmRegistry;
|
||||
import forestry.farming.logic.FarmableAgingCrop;
|
||||
import forestry.farming.logic.FarmableSapling;
|
||||
import forestry.plugins.BlankForestryPlugin;
|
||||
import forestry.plugins.ForestryPlugin;
|
||||
import forestry.plugins.ForestryPluginUids;
|
||||
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.oredict.OreDictionary;
|
||||
|
||||
@ForestryPlugin(pluginID = ForestryPluginUids.NATURA, name = "Natura", author = "SirSengir", url = Constants.URL, unlocalizedDescription = "for.plugin.natura.description")
|
||||
public class PluginNatura extends BlankForestryPlugin {
|
||||
|
||||
private static final String NATURA = "Natura";
|
||||
public static final String modId = "natura";
|
||||
|
||||
@Nullable
|
||||
private static Block logNatura;
|
||||
@Nullable
|
||||
private static Block logWillow;
|
||||
@Nullable
|
||||
private static Block leavesNatura;
|
||||
@Nullable
|
||||
private static Block saplingNatura;
|
||||
@Nullable
|
||||
private static Block saplingNaturaRare;
|
||||
private static ArrayList<ItemStack> fruits = new ArrayList<>();
|
||||
private static ArrayList<ItemStack> soups = new ArrayList<>();
|
||||
private static ArrayList<ItemStack> berries = new ArrayList<>();
|
||||
private static ArrayList<ItemStack> edibles = new ArrayList<>();
|
||||
private static ArrayList<ItemStack> seeds = new ArrayList<>();
|
||||
private static ArrayList<ItemStack> logs = new ArrayList<>();
|
||||
private static ArrayList<ItemStack> saplings = new ArrayList<>();
|
||||
private static ArrayList<ItemStack> shrooms = new ArrayList<>();
|
||||
private static ArrayList<ItemStack> materials = new ArrayList<>();
|
||||
private static ArrayList<ItemStack> crops = new ArrayList<>();
|
||||
private static ArrayList<ItemStack> cropBlocks = new ArrayList<>();
|
||||
|
||||
private static ItemStack berryBlight = ItemStack.EMPTY;
|
||||
private static ItemStack berryDusk = ItemStack.EMPTY;
|
||||
private static ItemStack berrySky = ItemStack.EMPTY;
|
||||
private static ItemStack berrySting = ItemStack.EMPTY;
|
||||
private static ItemStack berryRasp = ItemStack.EMPTY;
|
||||
private static ItemStack berryBlue = ItemStack.EMPTY;
|
||||
private static ItemStack berryBlack = ItemStack.EMPTY;
|
||||
private static ItemStack berryMalo = ItemStack.EMPTY;
|
||||
private static ItemStack itemBarley = ItemStack.EMPTY;
|
||||
public PluginNatura() {
|
||||
super();
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return ModUtil.isModLoaded(NATURA);
|
||||
return ModUtil.isModLoaded(modId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -74,44 +83,103 @@ public class PluginNatura extends BlankForestryPlugin {
|
||||
return "Natura not found";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preInit() {
|
||||
super.preInit();
|
||||
@SubscribeEvent
|
||||
public void registerItems(RegistryEvent<Item> itemRegistryEvent) {
|
||||
ForgeRegistries.ITEMS.forEach(item -> {
|
||||
final ResourceLocation registryName = item.getRegistryName();
|
||||
if(!registryName.getResourceDomain().equals(modId)) return;
|
||||
|
||||
logNatura = getBlock("tree");
|
||||
logWillow = getBlock("willow");
|
||||
leavesNatura = getBlock("floraleaves");
|
||||
saplingNatura = getBlock("florasapling");
|
||||
saplingNaturaRare = getBlock("Rare Sapling");
|
||||
final String itemName = registryName.getResourcePath();
|
||||
|
||||
ArrayList<String> saplingItemKeys = new ArrayList<>();
|
||||
if(itemName.matches("^.*_sapling\\d?$")) {
|
||||
consumeSubItems(item, "saplings", saplings);
|
||||
|
||||
if (saplingNatura != null) {
|
||||
saplingItemKeys.add("florasapling");
|
||||
}
|
||||
if (saplingNaturaRare != null) {
|
||||
saplingItemKeys.add("Rare Sapling");
|
||||
}
|
||||
RecipeUtil.addFermenterRecipes(
|
||||
new ItemStack(item, 1, OreDictionary.WILDCARD_VALUE),
|
||||
ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.sapling"),
|
||||
Fluids.BIOMASS
|
||||
);
|
||||
|
||||
for (String key : saplingItemKeys) {
|
||||
ItemStack saplingWild = getItemStack(key, OreDictionary.WILDCARD_VALUE);
|
||||
if (!saplingWild.isEmpty()) {
|
||||
RecipeUtil.addFermenterRecipes(saplingWild, ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.sapling"), Fluids.BIOMASS);
|
||||
|
||||
String saplingName = ItemStackUtil.getItemNameFromRegistryAsString(saplingWild.getItem());
|
||||
FMLInterModComms.sendMessage(Constants.MOD_ID, "add-farmable-sapling", String.format("farmArboreal@%s.-1", saplingName));
|
||||
FarmRegistry.getInstance().registerFarmables("farmArboreal", new FarmableSapling(
|
||||
new ItemStack(item),
|
||||
new ItemStack[] {}
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
if(itemName.matches("^edibles|.*fruit_item|soups$")) {
|
||||
complexConsumeSubItems(item, "edibles", subitem -> {
|
||||
final String subItemName = subitem.getUnlocalizedName();
|
||||
if(subItemName.matches("^.*berry$")) {
|
||||
berries.add(subitem);
|
||||
return;
|
||||
}
|
||||
|
||||
if(subItemName.matches("^.*(fruit_item|apple)$")) {
|
||||
fruits.add(subitem);
|
||||
return;
|
||||
}
|
||||
|
||||
if(subItemName.matches("^.*stew$")) {
|
||||
soups.add(subitem);
|
||||
return;
|
||||
}
|
||||
|
||||
edibles.add(subitem);
|
||||
});
|
||||
}
|
||||
|
||||
if(itemName.matches("^.*_seeds$")) {
|
||||
consumeSubItems(item, "seeds", seeds);
|
||||
return;
|
||||
}
|
||||
|
||||
if(itemName.matches("^.*_logs\\d?$")) {
|
||||
consumeSubItems(item, "logs", logs);
|
||||
return;
|
||||
}
|
||||
|
||||
if(itemName.matches("^.*_crop\\d?$")) {
|
||||
consumeSubItems(item, "cropBlocks", cropBlocks);
|
||||
return;
|
||||
}
|
||||
|
||||
if(itemName.matches("^materials$")) {
|
||||
complexConsumeSubItems(item, "materials", subitem -> {
|
||||
final String subItemName = subitem.getUnlocalizedName();
|
||||
|
||||
if (subItemName.matches("^.*(barley|cotton)$")) {
|
||||
crops.add(subitem);
|
||||
return;
|
||||
}
|
||||
materials.add(subitem);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void consumeSubItems(Item item, String groupName, Collection<ItemStack> consumer) {
|
||||
complexConsumeSubItems(item, groupName, subItem -> consumer.add(subItem));
|
||||
}
|
||||
|
||||
private void complexConsumeSubItems(Item item, String groupName, Consumer<ItemStack> consumer) {
|
||||
final NonNullList<ItemStack> subItems = NonNullList.create();
|
||||
item.getSubItems(CreativeTabs.SEARCH, subItems);
|
||||
|
||||
// Fallback if item is not returned in sub items
|
||||
if(subItems.isEmpty()) {
|
||||
final ItemStack itemStack = new ItemStack(item, 1);
|
||||
final String subItemName = itemStack.getUnlocalizedName();
|
||||
Log.info("[PluginNatura] Adding '{}' to list of {}", subItemName, groupName);
|
||||
consumer.accept(itemStack);
|
||||
return;
|
||||
}
|
||||
|
||||
berryBlight = getItemStack("berry.nether", 0);
|
||||
berryDusk = getItemStack("berry.nether", 1);
|
||||
berrySky = getItemStack("berry.nether", 2);
|
||||
berrySting = getItemStack("berry.nether", 3);
|
||||
berryRasp = getItemStack("berry", 0);
|
||||
berryBlue = getItemStack("berry", 1);
|
||||
berryBlack = getItemStack("berry", 2);
|
||||
berryMalo = getItemStack("berry", 3);
|
||||
itemBarley = getItemStack("barleyFood", 0);
|
||||
subItems.forEach(itemStack -> {
|
||||
final String subItemName = itemStack.getUnlocalizedName();
|
||||
Log.info("[PluginNatura] Adding '{}' to list of {}", subItemName, groupName);
|
||||
consumer.accept(itemStack);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -120,196 +188,86 @@ public class PluginNatura extends BlankForestryPlugin {
|
||||
|
||||
ICrateRegistry crateRegistry = StorageManager.crateRegistry;
|
||||
|
||||
if (!berryBlight.isEmpty()) {
|
||||
crateRegistry.registerCrate(berryBlight);
|
||||
}
|
||||
if (!berryDusk.isEmpty()) {
|
||||
crateRegistry.registerCrate(berryDusk);
|
||||
}
|
||||
if (!berrySky.isEmpty()) {
|
||||
crateRegistry.registerCrate(berrySky);
|
||||
}
|
||||
if (!berrySting.isEmpty()) {
|
||||
crateRegistry.registerCrate(berrySting);
|
||||
}
|
||||
if (!berryRasp.isEmpty()) {
|
||||
crateRegistry.registerCrate(berryRasp);
|
||||
}
|
||||
if (!berryBlue.isEmpty()) {
|
||||
crateRegistry.registerCrate(berryBlue);
|
||||
}
|
||||
if (!berryBlack.isEmpty()) {
|
||||
crateRegistry.registerCrate(berryBlack);
|
||||
}
|
||||
if (!berryMalo.isEmpty()) {
|
||||
crateRegistry.registerCrate(berryMalo);
|
||||
}
|
||||
if (!itemBarley.isEmpty()) {
|
||||
crateRegistry.registerCrate(itemBarley);
|
||||
}
|
||||
if (saplingNatura != null) {
|
||||
crateRegistry.registerCrate(new ItemStack(saplingNatura, 1, 0));
|
||||
crateRegistry.registerCrate(new ItemStack(saplingNatura, 1, 1));
|
||||
crateRegistry.registerCrate(new ItemStack(saplingNatura, 1, 2));
|
||||
crateRegistry.registerCrate(new ItemStack(saplingNatura, 1, 3));
|
||||
crateRegistry.registerCrate(new ItemStack(saplingNatura, 1, 4));
|
||||
crateRegistry.registerCrate(new ItemStack(saplingNatura, 1, 5));
|
||||
crateRegistry.registerCrate(new ItemStack(saplingNatura, 1, 6));
|
||||
crateRegistry.registerCrate(new ItemStack(saplingNatura, 1, 7));
|
||||
}
|
||||
|
||||
if (saplingNaturaRare != null) {
|
||||
crateRegistry.registerCrate(new ItemStack(saplingNaturaRare, 1, 0));
|
||||
crateRegistry.registerCrate(new ItemStack(saplingNaturaRare, 1, 1));
|
||||
crateRegistry.registerCrate(new ItemStack(saplingNaturaRare, 1, 2));
|
||||
crateRegistry.registerCrate(new ItemStack(saplingNaturaRare, 1, 3));
|
||||
crateRegistry.registerCrate(new ItemStack(saplingNaturaRare, 1, 4));
|
||||
}
|
||||
ItemStack potashApple = getItemStack("Natura.netherfood", 0);
|
||||
if (!potashApple.isEmpty()) {
|
||||
crateRegistry.registerCrate(potashApple);
|
||||
}
|
||||
Item glowShroom = getItem("Glowshroom");
|
||||
if (glowShroom != null) {
|
||||
crateRegistry.registerCrate(new ItemStack(glowShroom, 1, 0));
|
||||
crateRegistry.registerCrate(new ItemStack(glowShroom, 1, 1));
|
||||
crateRegistry.registerCrate(new ItemStack(glowShroom, 1, 2));
|
||||
}
|
||||
if (logNatura != null) {
|
||||
crateRegistry.registerCrate(new ItemStack(logNatura, 1, 0));
|
||||
crateRegistry.registerCrate(new ItemStack(logNatura, 1, 1));
|
||||
crateRegistry.registerCrate(new ItemStack(logNatura, 1, 2));
|
||||
crateRegistry.registerCrate(new ItemStack(logNatura, 1, 3));
|
||||
}
|
||||
if (logWillow != null) {
|
||||
crateRegistry.registerCrate(new ItemStack(logWillow, 1, 0));
|
||||
}
|
||||
|
||||
Item bloodWood = getItem("bloodwood");
|
||||
if (bloodWood != null) {
|
||||
crateRegistry.registerCrate(new ItemStack(bloodWood, 1, 0));
|
||||
}
|
||||
Item darkTree = getItem("Dark Tree");
|
||||
if (darkTree != null) {
|
||||
crateRegistry.registerCrate(new ItemStack(darkTree, 1, 0));
|
||||
crateRegistry.registerCrate(new ItemStack(darkTree, 1, 1));
|
||||
}
|
||||
Item heatSand = getItem("heatsand");
|
||||
if (heatSand != null) {
|
||||
crateRegistry.registerCrate(new ItemStack(heatSand, 1, 0));
|
||||
}
|
||||
Item taintedSoil = getItem("soil.tainted");
|
||||
if (taintedSoil != null) {
|
||||
crateRegistry.registerCrate(new ItemStack(taintedSoil, 1, 0));
|
||||
}
|
||||
Iterables.concat(
|
||||
edibles, logs, saplings, shrooms,
|
||||
materials, seeds, berries, fruits,
|
||||
crops
|
||||
).forEach(item -> crateRegistry.registerCrate(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRecipes() {
|
||||
int amount = ForestryAPI.activeMode.getIntegerSetting("squeezer.liquid.seed");
|
||||
|
||||
Item seed = getItem("barley.seed");
|
||||
if (seed != null) {
|
||||
ItemStack seedBarley = new ItemStack(seed, 1, 0);
|
||||
ItemStack seedCotton = new ItemStack(seed, 1, 1);
|
||||
|
||||
ArrayList<ItemStack> seedList = new ArrayList<>();
|
||||
if (!seedBarley.isEmpty()) {
|
||||
seedList.add(seedBarley);
|
||||
RecipeManagers.moistenerManager.addRecipe(seedBarley, new ItemStack(Blocks.MYCELIUM), 5000);
|
||||
}
|
||||
if (!seedCotton.isEmpty()) {
|
||||
seedList.add(seedCotton);
|
||||
}
|
||||
|
||||
for (ItemStack aSeedList : seedList) {
|
||||
RecipeManagers.squeezerManager.addRecipe(10, aSeedList, Fluids.SEED_OIL.getFluid(amount));
|
||||
}
|
||||
for (ItemStack seed : seeds) {
|
||||
RecipeManagers.squeezerManager.addRecipe(10, NonNullList.from(seed, seed), Fluids.SEED_OIL.getFluid(amount));
|
||||
RecipeManagers.moistenerManager.addRecipe(seed, new ItemStack(Blocks.MYCELIUM), 5000);
|
||||
}
|
||||
|
||||
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.FARMING)) {
|
||||
Block cropBlock = getBlock("N Crops");
|
||||
//TODO: Natura for 1.9
|
||||
// Farmables.farmables.get("farmWheat").add(new FarmableHandPlanted(seedBarley, cropBlock, 3));
|
||||
// Farmables.farmables.get("farmWheat").add(new FarmableHandPlanted(seedCotton, cropBlock, 8));
|
||||
}
|
||||
cropBlocks.forEach(itemStack -> {
|
||||
Block block = ItemStackUtil.getBlock(itemStack);
|
||||
ItemStack seedItem;
|
||||
int maxAge;
|
||||
try {
|
||||
maxAge = (int)block.getClass().getDeclaredMethod("getMaxAge").invoke(block);
|
||||
seedItem = block.getPickBlock(block.getBlockState().getBaseState(), null, null, null, null);
|
||||
} catch (Exception ignored) {
|
||||
return;
|
||||
}
|
||||
Log.info("[PluginNatura] Addding crop '{}'", itemStack);
|
||||
if (seedItem.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<ItemStack> berries = new ArrayList<>();
|
||||
if (!berryBlight.isEmpty()) {
|
||||
berries.add(berryBlight);
|
||||
FarmRegistry.getInstance().registerFarmables("farmWheat",
|
||||
new FarmableAgingCrop(
|
||||
seedItem,
|
||||
block,
|
||||
(IProperty<Integer>)block.getBlockState().getProperty("age"),
|
||||
maxAge
|
||||
)
|
||||
);
|
||||
});
|
||||
}
|
||||
if (!berryDusk.isEmpty()) {
|
||||
berries.add(berryDusk);
|
||||
}
|
||||
if (!berrySky.isEmpty()) {
|
||||
berries.add(berrySky);
|
||||
}
|
||||
if (!berrySting.isEmpty()) {
|
||||
berries.add(berrySting);
|
||||
}
|
||||
if (!berryRasp.isEmpty()) {
|
||||
berries.add(berryRasp);
|
||||
}
|
||||
if (!berryBlue.isEmpty()) {
|
||||
berries.add(berryBlue);
|
||||
}
|
||||
if (!berryBlack.isEmpty()) {
|
||||
berries.add(berryBlack);
|
||||
}
|
||||
if (!berryMalo.isEmpty()) {
|
||||
berries.add(berryMalo);
|
||||
}
|
||||
|
||||
|
||||
amount = ForestryAPI.activeMode.getIntegerSetting("squeezer.liquid.apple") / 2;
|
||||
amount = Math.max(amount, 1); // Produce at least 1 mb of juice.
|
||||
ItemStack netherFood = getItemStack("Natura.netherfood", 0);
|
||||
ItemStack mulch = PluginCore.getItems().mulch.getItemStack();
|
||||
RecipeManagers.squeezerManager.addRecipe(10, netherFood, Fluids.JUICE.getFluid(amount), mulch, ForestryAPI.activeMode.getIntegerSetting("squeezer.mulch.apple"));
|
||||
final int juiceAmount = Math.max(amount, 1); // Produce at least 1 mb of juice.
|
||||
ItemStack mulch = PluginCore.items.mulch.getItemStack();
|
||||
fruits.forEach(fruit -> RecipeManagers.squeezerManager.addRecipe(
|
||||
10, NonNullList.from(fruit, fruit),
|
||||
Fluids.JUICE.getFluid(juiceAmount), mulch,
|
||||
ForestryAPI.activeMode.getIntegerSetting("squeezer.mulch.apple"))
|
||||
);
|
||||
|
||||
amount = ForestryAPI.activeMode.getIntegerSetting("squeezer.liquid.apple") / 25;
|
||||
amount = Math.max(amount, 1); // Produce at least 1 mb of juice.
|
||||
|
||||
for (ItemStack berry : berries) {
|
||||
RecipeManagers.squeezerManager.addRecipe(3, berry, Fluids.JUICE.getFluid(amount));
|
||||
RecipeManagers.squeezerManager.addRecipe(3, NonNullList.from(berry, berry), Fluids.JUICE.getFluid(amount));
|
||||
}
|
||||
|
||||
if (!itemBarley.isEmpty()) {
|
||||
RecipeUtil.addFermenterRecipes(itemBarley, ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.wheat"), Fluids.BIOMASS);
|
||||
crops.forEach(crop -> {
|
||||
RecipeUtil.addFermenterRecipes(crop, ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.wheat"), Fluids.BIOMASS);
|
||||
if (crop.getUnlocalizedName().matches("^.*cotton$")) return;
|
||||
|
||||
int compostWheatAmount = ForestryAPI.activeMode.getIntegerSetting("recipe.output.compost.wheat");
|
||||
if (compostWheatAmount > 0) {
|
||||
ItemStack compostWheat = PluginCore.getItems().compost.getItemStack(compostWheatAmount);
|
||||
RecipeUtil.addRecipe("natura_compost_wheat", compostWheat, " X ", "X#X", " X ", '#', Blocks.DIRT, 'X', itemBarley);
|
||||
ItemStack compostWheat = PluginCore.items.fertilizerCompound.getItemStack(compostWheatAmount);
|
||||
RecipeUtil.addRecipe(compostWheat.getUnlocalizedName(), compostWheat, " X ", "X#X", " X ", '#', Blocks.DIRT, 'X', crop);
|
||||
}
|
||||
FuelManager.moistenerResource.put(itemBarley, new MoistenerFuel(itemBarley, PluginCore.getItems().mouldyWheat.getItemStack(), 0, 300));
|
||||
}
|
||||
FuelManager.moistenerResource.put(crop, new MoistenerFuel(crop, PluginCore.items.mouldyWheat.getItemStack(), 0, 300));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Register soils required by Natura trees. Must run in postInit(), after core PluginFarming has registered FarmingLogic instances
|
||||
*/
|
||||
@Override
|
||||
public void postInit() {
|
||||
IFarmLogic farmArboreal = FarmRegistry.getInstance().getFarmLogic("farmArboreal");
|
||||
farmArboreal.addSoil(new ItemStack(Blocks.NETHERRACK), Blocks.NETHERRACK.getDefaultState(), false);
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Block getBlock(String blockName) {
|
||||
ResourceLocation key = new ResourceLocation(NATURA, blockName);
|
||||
if (ForgeRegistries.BLOCKS.containsKey(key)) {
|
||||
return ForgeRegistries.BLOCKS.getValue(key);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Item getItem(String itemName) {
|
||||
ResourceLocation key = new ResourceLocation(NATURA, itemName);
|
||||
if (ForgeRegistries.ITEMS.containsKey(key)) {
|
||||
return ForgeRegistries.ITEMS.getValue(key);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static ItemStack getItemStack(String itemName, int meta) {
|
||||
ResourceLocation key = new ResourceLocation(NATURA, itemName);
|
||||
if (ForgeRegistries.ITEMS.containsKey(key)) {
|
||||
return new ItemStack(ForgeRegistries.ITEMS.getValue(key), 1, meta);
|
||||
} else {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,12 +12,11 @@ package forestry.storage;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.api.storage.EnumBackpackType;
|
||||
import forestry.api.storage.IBackpackDefinition;
|
||||
@@ -28,13 +27,14 @@ import forestry.storage.items.ItemBackpack;
|
||||
import forestry.storage.items.ItemBackpackNaturalist;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
public class BackpackInterface implements IBackpackInterface {
|
||||
|
||||
private final Map<String, IBackpackDefinition> definitions = new HashMap<>();
|
||||
private final Multimap<String, String> backpackAcceptedItems = HashMultimap.create();
|
||||
private final Map<String, List<String>> backpackAcceptedItems = new HashMap<>();
|
||||
|
||||
public Multimap<String, String> getBackpackAcceptedItems() {
|
||||
public Map<String, List<String>> getBackpackAcceptedItems() {
|
||||
return backpackAcceptedItems;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,10 @@ public class BackpackInterface implements IBackpackInterface {
|
||||
Preconditions.checkArgument(!itemStack.isEmpty(), "itemStack must not be empty");
|
||||
|
||||
String stringForItemStack = ItemStackUtil.getStringForItemStack(itemStack);
|
||||
backpackAcceptedItems.put(backpackUid, stringForItemStack);
|
||||
if (stringForItemStack != null) {
|
||||
List<String> acceptedItems = backpackAcceptedItems.computeIfAbsent(backpackUid, k -> NonNullList.create());
|
||||
acceptedItems.add(stringForItemStack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,9 +15,12 @@ import java.awt.Color;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@@ -58,6 +61,8 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
@@ -84,10 +89,10 @@ public class PluginStorage extends BlankForestryPlugin {
|
||||
@Nullable
|
||||
private static ItemRegistryStorage items;
|
||||
|
||||
private final Multimap<String, String> backpackAcceptedOreDictRegexpDefaults = HashMultimap.create();
|
||||
private final Multimap<String, String> backpackRejectedOreDictRegexpDefaults = HashMultimap.create();
|
||||
private final Multimap<String, String> backpackAcceptedItemDefaults = HashMultimap.create();
|
||||
private final Multimap<String, String> backpackRejectedItemDefaults = HashMultimap.create();
|
||||
private final Map<String, List<String>> backpackAcceptedOreDictRegexpDefaults = new HashMap<>();
|
||||
private final Map<String, List<String>> backpackRejectedOreDictRegexpDefaults = new HashMap<>();
|
||||
private final Map<String, List<String>> backpackAcceptedItemDefaults = new HashMap<>();
|
||||
private final Map<String, List<String>> backpackRejectedItemDefaults = new HashMap<>();
|
||||
|
||||
private final List<String> forestryBackpackUids = Arrays.asList(
|
||||
BackpackManager.MINER_UID,
|
||||
@@ -182,7 +187,7 @@ public class PluginStorage extends BlankForestryPlugin {
|
||||
private void setDefaultsForConfig() {
|
||||
ItemRegistryCore coreItems = PluginCore.getItems();
|
||||
|
||||
backpackAcceptedOreDictRegexpDefaults.get(BackpackManager.MINER_UID).addAll(Arrays.asList(
|
||||
backpackAcceptedOreDictRegexpDefaults.put(BackpackManager.MINER_UID, Arrays.asList(
|
||||
"obsidian",
|
||||
"ore[A-Z].*",
|
||||
"dust[A-Z].*",
|
||||
@@ -194,7 +199,7 @@ public class PluginStorage extends BlankForestryPlugin {
|
||||
"denseore[A-Z].*"
|
||||
));
|
||||
|
||||
backpackAcceptedOreDictRegexpDefaults.get(BackpackManager.DIGGER_UID).addAll(Arrays.asList(
|
||||
backpackAcceptedOreDictRegexpDefaults.put(BackpackManager.DIGGER_UID, Arrays.asList(
|
||||
"cobblestone",
|
||||
"dirt",
|
||||
"gravel",
|
||||
@@ -204,7 +209,7 @@ public class PluginStorage extends BlankForestryPlugin {
|
||||
"sand"
|
||||
));
|
||||
|
||||
backpackAcceptedOreDictRegexpDefaults.get(BackpackManager.HUNTER_UID).addAll(Arrays.asList(
|
||||
backpackAcceptedOreDictRegexpDefaults.put(BackpackManager.HUNTER_UID, Arrays.asList(
|
||||
"bone",
|
||||
"egg",
|
||||
"enderpearl",
|
||||
@@ -216,7 +221,7 @@ public class PluginStorage extends BlankForestryPlugin {
|
||||
"string"
|
||||
));
|
||||
|
||||
backpackAcceptedOreDictRegexpDefaults.get(BackpackManager.FORESTER_UID).addAll(Arrays.asList(
|
||||
backpackAcceptedOreDictRegexpDefaults.put(BackpackManager.FORESTER_UID, Arrays.asList(
|
||||
"logWood",
|
||||
"stickWood",
|
||||
"woodStick",
|
||||
@@ -230,7 +235,7 @@ public class PluginStorage extends BlankForestryPlugin {
|
||||
"tree[A-Z].*"
|
||||
));
|
||||
|
||||
backpackAcceptedOreDictRegexpDefaults.get(BackpackManager.BUILDER_UID).addAll(Arrays.asList(
|
||||
backpackAcceptedOreDictRegexpDefaults.put(BackpackManager.BUILDER_UID, Arrays.asList(
|
||||
"block[A-Z].*",
|
||||
"paneGlass[A-Z].*",
|
||||
"slabWood[A-Z].*",
|
||||
@@ -253,7 +258,7 @@ public class PluginStorage extends BlankForestryPlugin {
|
||||
"doorWood"
|
||||
));
|
||||
|
||||
backpackAcceptedItemDefaults.get(BackpackManager.MINER_UID).addAll(getItemStrings(Arrays.asList(
|
||||
backpackAcceptedItemDefaults.put(BackpackManager.MINER_UID, getItemStrings(Arrays.asList(
|
||||
new ItemStack(Blocks.COAL_ORE),
|
||||
new ItemStack(Items.COAL),
|
||||
coreItems.bronzePickaxe.getItemStack(),
|
||||
@@ -261,7 +266,7 @@ public class PluginStorage extends BlankForestryPlugin {
|
||||
coreItems.brokenBronzePickaxe.getItemStack()
|
||||
)));
|
||||
|
||||
backpackAcceptedItemDefaults.get(BackpackManager.DIGGER_UID).addAll(getItemStrings(Arrays.asList(
|
||||
backpackAcceptedItemDefaults.put(BackpackManager.DIGGER_UID, getItemStrings(Arrays.asList(
|
||||
new ItemStack(Blocks.DIRT, 1, OreDictionary.WILDCARD_VALUE),
|
||||
new ItemStack(Items.FLINT),
|
||||
new ItemStack(Blocks.SANDSTONE, 1, 0),
|
||||
@@ -273,7 +278,7 @@ public class PluginStorage extends BlankForestryPlugin {
|
||||
coreItems.brokenBronzeShovel.getItemStack()
|
||||
)));
|
||||
|
||||
backpackAcceptedItemDefaults.get(BackpackManager.FORESTER_UID).addAll(getItemStrings(Arrays.asList(
|
||||
backpackAcceptedItemDefaults.put(BackpackManager.FORESTER_UID, getItemStrings(Arrays.asList(
|
||||
new ItemStack(Blocks.RED_MUSHROOM),
|
||||
new ItemStack(Blocks.BROWN_MUSHROOM),
|
||||
new ItemStack(Blocks.RED_FLOWER, 1, OreDictionary.WILDCARD_VALUE),
|
||||
@@ -293,7 +298,7 @@ public class PluginStorage extends BlankForestryPlugin {
|
||||
new ItemStack(Items.APPLE)
|
||||
)));
|
||||
|
||||
backpackAcceptedItemDefaults.get(BackpackManager.HUNTER_UID).addAll(getItemStrings(Arrays.asList(
|
||||
backpackAcceptedItemDefaults.put(BackpackManager.HUNTER_UID, getItemStrings(Arrays.asList(
|
||||
new ItemStack(Items.BLAZE_POWDER),
|
||||
new ItemStack(Items.BLAZE_ROD),
|
||||
new ItemStack(Items.ROTTEN_FLESH),
|
||||
@@ -334,7 +339,7 @@ public class PluginStorage extends BlankForestryPlugin {
|
||||
new ItemStack(Items.IRON_HORSE_ARMOR)
|
||||
)));
|
||||
|
||||
backpackAcceptedItemDefaults.get(BackpackManager.BUILDER_UID).addAll(getItemStrings(Arrays.asList(
|
||||
backpackAcceptedItemDefaults.put(BackpackManager.BUILDER_UID, getItemStrings(Arrays.asList(
|
||||
new ItemStack(Blocks.REDSTONE_TORCH),
|
||||
new ItemStack(Blocks.REDSTONE_LAMP),
|
||||
new ItemStack(Blocks.SEA_LANTERN),
|
||||
@@ -388,7 +393,7 @@ public class PluginStorage extends BlankForestryPlugin {
|
||||
|
||||
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.APICULTURE)) {
|
||||
BlockRegistryApiculture beeBlocks = PluginApiculture.getBlocks();
|
||||
backpackAcceptedItemDefaults.get(BackpackManager.BUILDER_UID).addAll(getItemStrings(Arrays.asList(
|
||||
backpackAcceptedItemDefaults.put(BackpackManager.BUILDER_UID, getItemStrings(Arrays.asList(
|
||||
new ItemStack(beeBlocks.candle, 1, OreDictionary.WILDCARD_VALUE),
|
||||
new ItemStack(beeBlocks.stump, 1, OreDictionary.WILDCARD_VALUE)
|
||||
)));
|
||||
@@ -415,11 +420,13 @@ public class PluginStorage extends BlankForestryPlugin {
|
||||
OreDictionary.registerOre(OreDictUtil.FENCE_GATE_WOOD, Blocks.ACACIA_FENCE_GATE);
|
||||
}
|
||||
|
||||
private static Set<String> getItemStrings(List<ItemStack> itemStacks) {
|
||||
Set<String> itemStrings = new HashSet<>(itemStacks.size());
|
||||
private static List<String> getItemStrings(List<ItemStack> itemStacks) {
|
||||
List<String> itemStrings = new ArrayList<>(itemStacks.size());
|
||||
for (ItemStack itemStack : itemStacks) {
|
||||
String itemString = ItemStackUtil.getStringForItemStack(itemStack);
|
||||
itemStrings.add(itemString);
|
||||
if (itemString != null) {
|
||||
itemStrings.add(itemString);
|
||||
}
|
||||
}
|
||||
return itemStrings;
|
||||
}
|
||||
@@ -437,9 +444,12 @@ public class PluginStorage extends BlankForestryPlugin {
|
||||
|
||||
// accepted items
|
||||
{
|
||||
List<String> defaultAcceptedItemNames = new ArrayList<>(backpackAcceptedItemDefaults.get(backpackUid));
|
||||
Collections.sort(defaultAcceptedItemNames);
|
||||
String[] defaultValidItems = defaultAcceptedItemNames.toArray(new String[defaultAcceptedItemNames.size()]);
|
||||
String[] defaultValidItems = new String[0];
|
||||
List<String> defaultAcceptedItemNames = backpackAcceptedItemDefaults.get(backpackUid);
|
||||
if (defaultAcceptedItemNames != null) {
|
||||
Collections.sort(defaultAcceptedItemNames);
|
||||
defaultValidItems = defaultAcceptedItemNames.toArray(new String[defaultAcceptedItemNames.size()]);
|
||||
}
|
||||
|
||||
Property backpackConf = config.get("backpacks." + backpackUid, "item.stacks.accepted", defaultValidItems);
|
||||
backpackConf.setComment(Translator.translateToLocalFormatted("for.config.backpacks.item.stacks.format", backpackUid));
|
||||
@@ -453,9 +463,12 @@ public class PluginStorage extends BlankForestryPlugin {
|
||||
|
||||
// rejected items
|
||||
{
|
||||
List<String> defaultRejectedItemNames = new ArrayList<>(backpackRejectedItemDefaults.get(backpackUid));
|
||||
Collections.sort(defaultRejectedItemNames);
|
||||
String[] defaultRejectedItems = defaultRejectedItemNames.toArray(new String[defaultRejectedItemNames.size()]);
|
||||
String[] defaultRejectedItems = new String[0];
|
||||
List<String> defaultRejectedItemNames = backpackRejectedItemDefaults.get(backpackUid);
|
||||
if (defaultRejectedItemNames != null) {
|
||||
Collections.sort(defaultRejectedItemNames);
|
||||
defaultRejectedItems = defaultRejectedItemNames.toArray(new String[defaultRejectedItemNames.size()]);
|
||||
}
|
||||
|
||||
Property backpackConf = config.get("backpacks." + backpackUid, "item.stacks.rejected", defaultRejectedItems);
|
||||
backpackConf.setComment(Translator.translateToLocalFormatted("for.config.backpacks.item.stacks.format", backpackUid));
|
||||
@@ -469,9 +482,12 @@ public class PluginStorage extends BlankForestryPlugin {
|
||||
|
||||
// accepted oreDict
|
||||
{
|
||||
List<String> defaultOreRegexpList = new ArrayList<>(backpackAcceptedOreDictRegexpDefaults.get(backpackUid));
|
||||
Collections.sort(defaultOreRegexpList);
|
||||
String[] defaultOreRegexpNames = defaultOreRegexpList.toArray(new String[defaultOreRegexpList.size()]);
|
||||
String[] defaultOreRegexpNames =new String[0];
|
||||
List<String> defaultOreRegexpList = backpackAcceptedOreDictRegexpDefaults.get(backpackUid);
|
||||
if (defaultOreRegexpList != null) {
|
||||
Collections.sort(defaultOreRegexpList);
|
||||
defaultOreRegexpNames = defaultOreRegexpList.toArray(new String[defaultOreRegexpList.size()]);
|
||||
}
|
||||
|
||||
Property backpackConf = config.get("backpacks." + backpackUid, "ore.dict.accepted", defaultOreRegexpNames);
|
||||
backpackConf.setComment(Translator.translateToLocalFormatted("for.config.backpacks.ore.dict.format", backpackUid));
|
||||
@@ -491,9 +507,12 @@ public class PluginStorage extends BlankForestryPlugin {
|
||||
|
||||
// rejected oreDict
|
||||
{
|
||||
List<String> defaultOreRegexpList = new ArrayList<>(backpackRejectedOreDictRegexpDefaults.get(backpackUid));
|
||||
Collections.sort(defaultOreRegexpList);
|
||||
String[] defaultOreRegexpNames = defaultOreRegexpList.toArray(new String[defaultOreRegexpList.size()]);
|
||||
String[] defaultOreRegexpNames = new String[0];
|
||||
List<String> defaultOreRegexpList = backpackRejectedOreDictRegexpDefaults.get(backpackUid);
|
||||
if (defaultOreRegexpList != null) {
|
||||
Collections.sort(defaultOreRegexpList);
|
||||
defaultOreRegexpNames = defaultOreRegexpList.toArray(new String[defaultOreRegexpList.size()]);
|
||||
}
|
||||
|
||||
Property backpackConf = config.get("backpacks." + backpackUid, "ore.dict.rejected", defaultOreRegexpNames);
|
||||
backpackConf.setComment(Translator.translateToLocalFormatted("for.config.backpacks.ore.dict.format", backpackUid));
|
||||
|
||||
Reference in new issue
Block a user