Compare commits

...
91 Commits
Author SHA1 Message Date
mezz dea1fb144a Fix #1434 Fix #1551 Make hives spawn existing flowers only, up to 10 2017-09-07 23:41:59 -07:00
mezz a01190a242 Fix #1679 use fractions of world height to define ore generation levels 2017-09-07 21:41:15 -07:00
mezz 0ebced9609 Fix #1845 API has references to internal classes 2017-09-07 19:23:59 -07:00
mezz b9924ea98b Fix #1843 Improve performance of worldgen hives 2017-09-06 00:35:54 -07:00
mezz 5707d27598 Fix #1577 Hives load new chunks when retrogen is active 2017-09-04 14:46:56 -07:00
mezz 42bde9e576 Fix #1836 Update minimum required JEI version 2017-09-04 14:10:55 -07:00
mezz 76f09be39d Close #1838 Make IHiveFrame's getBeeModifier() ItemStack aware 2017-09-04 13:52:32 -07:00
LachimHeigrim e6cb758e0e Fix #1827 Allow Natura nether saplings to be autofarmed in arboreal farm (#1829) 2017-09-01 19:58:46 -07:00
mezz b3549edf51 Fix #1833 Item in players hand get deleted by farm planting 2017-08-29 22:14:47 -07:00
mezz e09d159935 Fix breeding data desync after changing dimensions 2017-08-29 20:55:31 -07:00
Nedelosk 4cb2610b1c Fix #1830 Carpenter removes the wrong item 2017-08-28 16:03:12 +02:00
mezz c44f11cf09 Update dependencies 2017-08-27 14:56:59 -07:00
mezz b69c31ed8a Clean up generics for Forestry ItemBlocks 2017-08-25 21:14:13 -07:00
mezz 6a2231f8fb Fix a crash when escritoire loads with a specimen already in it 2017-08-22 23:00:27 -07:00
mezz a3a6c71c42 Fix #1762 Swapping specimens in the escritoire has strange effects 2017-08-22 22:46:13 -07:00
mezz 8d5c0c6f8b Fix #1806 Allow sapling's products to work as hint items in escritoire 2017-08-22 22:37:35 -07:00
mezz 56603fd00c Fix #1813 Saplings do not drop when removed by water of piston 2017-08-22 22:10:47 -07:00
mezz ed69411d2e Fix #1815 Stop MultiFarm from converting vanilla saplings 2017-08-22 21:45:55 -07:00
mezz e1d017f077 Fix #1819 Crash when growing short Sipiri trees 2017-08-20 22:24:53 -07:00
mezz 9269af7a13 Update to 1.12.1 2017-08-18 20:17:18 -07:00
Nedelosk 8ffdba5021 Fix build script 2017-08-17 13:59:39 +02:00
Nedelosk e00aecd886 Fix #1807 Honeycomb block uncraftable 2017-08-16 19:26:15 +02:00
Nedelosk 98f859f2fb Add a log message to the Create Model 2017-08-16 14:48:11 +02:00
mezz 55a15d23b2 Fix Pam's harvestcraft integration 2017-08-14 21:19:29 -07:00
mezz 307580aed8 Mark as working on 1.12.1 on CurseForge 2017-08-13 22:06:46 -07:00
Nedelosk d2d93004e0 Merge pull request #1801 from asiekierka/mc-1.12
Reduce SimpleModel memory usage
2017-08-13 18:21:02 +02:00
Adrian Siekierka e1df424bfd reduce SimpleModel memory usage 2017-08-13 16:35:26 +02:00
Robert Obermeier 6a75347b05 Add Red Orchid support to farm (#1800) 2017-08-12 17:09:00 -07:00
Robert Obermeier cfd513ea80 Fix Natura support (#1794) 2017-08-12 15:50:31 -07:00
Robert Obermeier edcc47a6b3 Fix #1753 Add generalized sapling support (#1798) 2017-08-12 14:44:16 -07:00
mezz 6593118f3d Fix #1787 Wood logs drop the wrong item when harvested with silk touch 2017-08-12 12:39:59 -07:00
Robert Obermeier fd724d147a Fix #1789 The End has no hives. (#1795) 2017-08-11 20:56:12 -07:00
mezz b2e1b2dc9b Fix tree generation with Mystcraft 2017-07-29 15:42:34 -07:00
mezz defc47000b Fix client visual glitch with worktable 2017-07-29 00:56:34 -07:00
mezz 0a37ad0666 First beta version 2017-07-28 23:31:04 -07:00
mezz 13d4907bff #1687 Fix crash when genetics items are missing nbt 2017-07-28 23:28:43 -07:00
mezz 78725009c1 Fix #1777 crash on load from backpacks 2017-07-28 23:13:51 -07:00
mezz a1bc9144bd Fix #1768 fix serious issues with the worktable 2017-07-27 22:39:49 -07:00
Nedelosk b897056824 Fix #1772 crash if forestry.factory=false 2017-07-28 00:11:03 +02:00
Nedelosk 87563b6c97 Merge remote-tracking branch 'origin/mc-1.12' into mc-1.12 2017-07-25 16:01:11 +02:00
Nedelosk 62d6294da2 Fix Fertilizer Config from 1.10 to 1.11 / 1.12 2017-07-25 16:01:01 +02:00
Robert Obermeier b4d71543db Move hives into biome decoration generation
fixes #1760
2017-07-24 22:33:21 -07:00
mezz 73db1a608a Fix #1741 Fix recipes for farm blocks only allow quartz 2017-07-17 23:41:18 -07:00
Brennan Ward 1c6b60122e Update to AA r115 2017-07-15 17:51:15 -07:00
mezz 1e7a042b53 Fix missing item/block event handling 2017-07-12 22:47:26 -07:00
mezz bf08336bc5 Fix JEI dependency info 2017-07-09 21:02:15 -07:00
mezz 62cbf31ac2 Version 5.4.3 2017-07-03 17:22:56 -07:00
mezz a2eac214b4 Minor cleanup 2017-07-03 17:22:39 -07:00
Nedelosk 32933ce90b Merge remote-tracking branch 'origin/mc-1.12' into mc-1.12 2017-07-04 02:15:42 +02:00
Nedelosk 44cdc191fc Fix #1732 Forestry - Blocks all look the same when placed 2017-07-04 02:15:30 +02:00
mezz e4f77e42d3 Fix #1237 Fireproof blocks work as fuel 2017-07-03 16:52:45 -07:00
mezz 9f91832c7e Experiment updating Gradle Wrapper to 4.0 2017-07-03 15:26:50 -07:00
mezz 6d4af0fb5d Version 5.4.2 2017-07-03 00:17:10 -07:00
mezz 4345739a87 Merge remote-tracking branch 'origin/mc-1.11' into mc-1.12 2017-07-03 00:15:34 -07:00
mezz 0a881a81f8 Fix worktable crafting (#1728) 2017-07-03 00:12:58 -07:00
mezz b066f7ad4c Create proper recipe registry names 2017-07-03 00:06:31 -07:00
mezz a19380347a Fix missing textures on butterfly items (#1730) 2017-07-02 21:31:49 -07:00
mezz 9bc1211e57 Fix missing textures on machine tabs (#1730) 2017-07-02 21:31:29 -07:00
mezz cbce5d0fc0 Cleanup 2017-07-02 21:31:03 -07:00
mezz b20b56c5d4 Update Forge 2017-07-02 21:30:40 -07:00
mezz 27041c205c Fix #1723 Items show in the wrong creative tabs 2017-07-02 01:00:28 -07:00
mezz 00504d4096 Version 5.4.1 2017-07-02 00:51:29 -07:00
mezz ed0c5e1a7e Move away from deprecated JEI classes 2017-07-02 00:51:06 -07:00
mezz ddf90f4ee0 Update Forge to Recommended Build 2017-07-02 00:47:37 -07:00
mezz 39290512cf Fix GUIs drawing without the black background 2017-06-26 20:02:45 -07:00
Nedelosk 09ea20729d Improve Wood Model Loader 2017-06-26 14:00:41 +02:00
Nedelosk 736e6c5fa2 Change wood texture json file name 2017-06-25 15:33:00 +02:00
Nedelosk e96f4fc8a0 Fix Fence Gate Model 2017-06-25 11:55:25 +02:00
mezz bbe1f539dd Update cursegradle plugin 2017-06-24 22:22:42 -07:00
mezz 1fcaacd41b Stop using some deprecated methods and classes 2017-06-24 22:10:55 -07:00
mezz 7306764c51 Initial update to Minecraft 1.12 2017-06-24 21:49:47 -07:00
Nedelosk d3c7280f3f Fix #1712 1.11.2 Ferementer does not work when sappinessHigh 2017-06-23 20:23:38 +02:00
Nedelosk 2c6ed06574 More Recipe Clean Up 2017-06-23 18:56:30 +02:00
Nedelosk 81e2e18089 Clean Up Carpenter and Fabricator RecipeManagers 2017-06-23 18:50:51 +02:00
Nedelosk 7b7e7eb7e7 Update formatting-settings to 1.11.2
Changed IMPORT_LAYOUT cpw.mods.fml to net.minecraftforge.fml
2017-06-23 18:30:39 +02:00
Nedelosk 944aaf3297 Fix #1715 Forestry 1.11.2 trees spawn even when disabled in config 2017-06-22 14:57:47 +02:00
Nedelosk 5a5793f243 Fix forestry slab brightness 2017-06-22 14:54:40 +02:00
Nedelosk 5e41a4d2c0 Fix #1676 Soldering Iron usage has insufficient server-side validation 2017-06-21 22:01:46 +02:00
Nedelosk c4ac0bc7a5 Fix #1685 1.11.2 crashing when rendering item 2017-06-21 21:53:11 +02:00
Nedelosk 5549cfaaa1 Fix #1674 Forestry logs do not triggers Getting Wood Achievement 2017-06-21 21:45:56 +02:00
Nedelosk ae4d246c59 Fix #1690 Backpack does not resupply the offhand 2017-06-21 21:45:22 +02:00
Nedelosk 2622557a00 Fix #1702 Slabs not blocking light 2017-06-21 20:58:42 +02:00
Nedelosk 339abedeee Fix 1.11 Bees do damage on peaceful mode 2017-06-21 20:47:03 +02:00
Nedelosk 149b35224a Fix #1714 Wax cast negative durability 2017-06-21 20:34:38 +02:00
Nedelosk d148279224 Fix Bottler JEI integration 2017-06-18 01:45:53 +02:00
Nedelosk 554fe8bad1 Add tintindex to the door models 2017-06-17 13:59:00 +02:00
Nedelosk 27e8259ff6 Move the bee allele register event to the preInit 2017-06-15 19:50:48 +02:00
mezz 3a51df154a Update JEI integration 2017-06-06 23:50:11 -07:00
mezz a3c79c0427 Fix leaves spawning near 0,0,0 2017-06-04 13:34:59 -07:00
mezz f569a04797 Fix backpack pickup handler 2017-05-10 15:27:01 -07:00
mezz 610ddfed12 Update dependencies 2017-05-10 15:18:53 -07:00
463 changed files with 5773 additions and 4076 deletions

No files matched your search

Executable → Regular
+14 -22
View File
@@ -4,16 +4,18 @@ buildscript {
maven { url = "http://files.minecraftforge.net/maven" }
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
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.7"
id "se.bjurr.gitchangelog.git-changelog-gradle-plugin" version "1.32"
id "com.matthewprenger.cursegradle" version "1.0.9"
}
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')) {
@@ -26,8 +28,8 @@ ext.dirDest = './build/dist'
ext.dirLang = "./lang"
// java version
sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
minecraft {
version = mcversion + "-" + forgeversion
@@ -60,9 +62,9 @@ repositories {
}
dependencies {
deobfCompile "net.darkhax.tesla:Tesla:${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,27 +151,17 @@ task makeChangelog(type: se.bjurr.gitchangelog.plugin.gradle.GitChangelogTask) {
untaggedName = "Current release ${project.version}"
fromCommit = "5a3850c2642e535656d090d1473054d5fa8d3331"
toRef = "HEAD"
templateContent = """
Alpha version, still buggy. Do not create a world you care about with this version, it can and will break things severely.<br/>
Please help the project by trying it out and <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'
}
}
+9
View File
@@ -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}}
Binary file not shown.
Regular → Executable
+10 -7
View File
@@ -1,11 +1,14 @@
mcversion=1.11.2
forgeversion=13.20.0.2279
mcp_mappings=snapshot_20161220
mcversion=1.12.1
forgeversion=14.22.0.2469
mcp_mappings=snapshot_20170904
curse_project_id=59751
tesla_version=1.11-1.3.0.51
jei_version=4.3.0.252
ic2_version=2.7.7-ex111
tesla_version=1.0.60
tesla_mcversion=1.12
jei_version=4.7.8.92
jei_mcversion=1.12.1
ic2_version=2.8.24-ex112
version_major=5
version_minor=3
version_minor=5
version_patch=4
Binary file not shown.
+6 -6
View File
@@ -1,6 +1,6 @@
#Mon Sep 14 12:28:28 PDT 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.7-bin.zip
#Mon Jul 03 15:24:47 PDT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-all.zip
Vendored
+1 -5
View File
@@ -42,11 +42,6 @@ case "`uname`" in
;;
esac
# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
@@ -114,6 +109,7 @@ fi
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+1 -1
Submodule lang updated: f5300f059b...774ccbb680.
+31 -25
View File
@@ -10,10 +10,28 @@
******************************************************************************/
package forestry;
import com.google.common.base.Preconditions;
import javax.annotation.Nullable;
import java.io.File;
import com.google.common.base.Preconditions;
import forestry.plugins.compat.PluginNatura;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.common.MinecraftForge;
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;
import net.minecraftforge.fml.common.event.FMLInterModComms;
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;
import forestry.api.core.ForestryAPI;
import forestry.core.EventHandlerCore;
import forestry.core.climate.ClimateEventHandler;
@@ -26,23 +44,9 @@ 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;
import net.minecraftforge.common.MinecraftForge;
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;
import net.minecraftforge.fml.common.event.FMLInterModComms;
import net.minecraftforge.fml.common.event.FMLInterModComms.IMCEvent;
import net.minecraftforge.fml.common.event.FMLMissingMappingsEvent;
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.network.NetworkRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;
/**
* Forestry Minecraft Mod
@@ -51,13 +55,14 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
*/
@Mod(
modid = Constants.MOD_ID,
name = "Forestry",
name = Constants.MOD_NAME,
version = Constants.VERSION,
guiFactory = "forestry.core.config.ForestryGuiConfigFactory",
acceptedMinecraftVersions = "[1.11]",
dependencies = "required-after:forge@[13.20.0.2270,);"
+ "after:JEI@[4.3.0,);"
+ "after:" + PluginIC2.modId + ";")
acceptedMinecraftVersions = "[1.12, 1.12.1]",
dependencies = "required-after:forge@[14.21.1.2395,);"
+ "after:jei@[4.7.8.91,);"
+ "after:" + PluginIC2.modId + ";"
+ "after:" + PluginNatura.modId + ";")
public class Forestry {
@SuppressWarnings("NullableProblems")
@@ -72,6 +77,7 @@ public class Forestry {
ForestryAPI.errorStateRegistry = new ErrorStateRegistry();
EnumErrorCode.init();
FluidRegistry.enableUniversalBucket();
MinecraftForge.EVENT_BUS.register(this);
}
@Nullable
@@ -104,6 +110,11 @@ public class Forestry {
PluginManager.runPreInit(event.getSide());
}
@SubscribeEvent
public void registerModels(ModelRegistryEvent event) {
PluginManager.runRegisterBackpacksAndCrates();
Proxies.render.registerModels();
}
@@ -146,9 +157,4 @@ public class Forestry {
public void processIMCMessages(IMCEvent event) {
PluginManager.processIMCMessages(event.getMessages());
}
@EventHandler
public void onMissingMappings(FMLMissingMappingsEvent event) {
MigrationHelper.onMissingMappings(event);
}
}
@@ -13,8 +13,10 @@ import forestry.api.core.IErrorState;
import forestry.api.genetics.IEffectData;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IIndividualLiving;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@@ -85,8 +87,26 @@ public interface IBee extends IIndividualLiving {
List<IBee> spawnDrones(IBeeHousing housing);
/**
* @deprecated since Forestry 5.5.4. Use {@link #plantFlowerRandom(IBeeHousing, List)}
*/
@Deprecated
void plantFlowerRandom(IBeeHousing housing);
/**
* Plants a random flower from the given list near the housing
* @param housing the location the bee is living
* @param potentialFlowers the flowers to choose from
* @return the position of the planted flower, or null of none were planted
* @since Forestry 5.5.4
*/
@Nullable
default BlockPos plantFlowerRandom(IBeeHousing housing, List<IBlockState> potentialFlowers) {
//noinspection deprecation
plantFlowerRandom(housing);
return null;
}
@Nullable
IIndividual retrievePollen(IBeeHousing housing);
@@ -5,12 +5,14 @@
******************************************************************************/
package forestry.api.apiculture;
import java.io.IOException;
import java.util.List;
import forestry.api.core.INbtReadable;
import forestry.api.core.INbtWritable;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.PacketBuffer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.relauncher.Side;
@@ -79,4 +81,12 @@ public interface IBeekeepingLogic extends INbtWritable, INbtReadable {
* These positions are synced to the client from the server.
*/
List<BlockPos> getFlowerPositions();
default void readData(PacketBuffer data) throws IOException {
}
default void writeData(PacketBuffer data) {
}
}
@@ -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);
}
+3 -3
View File
@@ -1,12 +1,12 @@
package forestry.api.arboriculture;
import com.google.common.collect.ImmutableMap;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import com.google.common.collect.ImmutableMap;
import net.minecraftforge.client.model.IModel;
import net.minecraftforge.client.model.ModelProcessingHelper;
public enum WoodBlockKind {
LOG, PLANKS, SLAB, FENCE, FENCE_GATE, STAIRS, DOOR;
@@ -57,6 +57,6 @@ public enum WoodBlockKind {
break;
}
textures.putAll(customTextures);
return ModelProcessingHelper.retexture(model, new ImmutableMap.Builder<String, String>().putAll(textures).build());
return model.retexture(ImmutableMap.copyOf(textures));
}
}
@@ -0,0 +1,13 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.core;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public interface IBlockPosPredicate {
boolean test(World world, BlockPos blockPos);
}
+3 -2
View File
@@ -8,14 +8,15 @@ package forestry.api.core;
import javax.annotation.Nullable;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.client.model.IPerspectiveAwareModel;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public interface IModelBakerModel extends IPerspectiveAwareModel {
public interface IModelBakerModel extends IBakedModel {
void setGui3d(boolean gui3d);
@@ -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>
@@ -1,7 +1,5 @@
package forestry.api.genetics;
import net.minecraftforge.fml.common.eventhandler.Event;
/**
* Called after Forestry has registered all his species alleles of a individual.
*/
@@ -5,6 +5,9 @@
******************************************************************************/
package forestry.api.genetics;
import java.util.Collection;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@@ -13,6 +16,19 @@ public interface IFlowerGrowthHelper {
* Plants a random flower from flowerType at the specified position.
*
* @return true if successful, false if it could not be planted.
* @deprecated since Forestry 5.5.4. Use {@link #plantRandomFlower(String, World, BlockPos, Collection)}
*/
@Deprecated
boolean plantRandomFlower(String flowerType, World world, BlockPos pos);
/**
* Plants a random flower from flowerType at the specified position.
* @param flowerType the flower type that can be planted
* @param world the world to plant flowers in
* @param pos the position to plant the flowers
* @param potentialFlowers the potential flowers that can be planted
* @return true if a flower was planted, false otherwise
* @since Forestry 5.5.4
*/
boolean plantRandomFlower(String flowerType, World world, BlockPos pos, Collection<IBlockState> potentialFlowers);
}
@@ -5,6 +5,9 @@
******************************************************************************/
package forestry.api.genetics;
import java.util.Collection;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@@ -18,6 +21,20 @@ public interface IFlowerGrowthRule {
* For implementers, you can plant a random flower using IFlowerGrowthHelper.plantRandomFlower
*
* @since Forestry 4.0.8
* @deprecated since Forestry 5.5.4. Use {@link #growFlower(IFlowerGrowthHelper, String, World, BlockPos, Collection)}
*/
@Deprecated
boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, BlockPos pos);
/**
* Checks a position for suitability, and then plants a flower there.
* Returns true on success.
* For implementers, you can plant a random flower using IFlowerGrowthHelper.plantRandomFlower
*
* @since Forestry 5.5.4
*/
default boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, BlockPos pos, Collection<IBlockState> potentialFlowers) {
//noinspection deprecation
return growFlower(helper, flowerType, world, pos);
}
}
@@ -5,10 +5,13 @@
******************************************************************************/
package forestry.api.genetics;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.core.IBlockPosPredicate;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
@@ -57,8 +60,26 @@ public interface IFlowerRegistry {
/**
* Calls the appropriate IFlowerGrowthRule to grow a flower at a specified position.
* @since Forestry 5.5.4
*/
boolean growFlower(String flowerType, World world, IIndividual individual, BlockPos pos);
boolean growFlower(String flowerType, World world, IIndividual individual, BlockPos pos, Collection<IBlockState> potentialFlowers);
/**
* Gets an iterator over the area a bee can travel from its beeHousing.
* Starts at the bee housing and spirals outward.
*
* @param beeHousing The bee housing that will help determine the size of the area to check.
* @param bee The bee that will help determine the size of the area to check.
* @return an iterator over the area a bee can travel from its beeHousing.
* @since Forestry 5.5.2
*/
Iterator<BlockPos.MutableBlockPos> getAreaIterator(IBeeHousing beeHousing, IBee bee);
/**
* Checks a single coordinate to see if it is an accepted flower.
* @since Forestry 5.5.2
*/
IBlockPosPredicate createAcceptedFlowerPredicate(String flowerType);
/**
* @param beeHousing The bee housing that will help determine the size of the area to check.
@@ -66,11 +87,22 @@ public interface IFlowerRegistry {
* @param flowerType See {@link forestry.api.apiculture.FlowerManager}.FlowerTypeXXX
* @param maxFlowers the largest number of flowers to check for before returning. Use 1 if you only need 1.
* @return the coordinates of nearby accepted flowers, with size from 0 to maxFlowers.
* @deprecated since Forestry 5.5.2. Use {@link #getAreaIterator(IBeeHousing, IBee)} and {@link #createAcceptedFlowerPredicate(String)}.
*/
@Deprecated
List<BlockPos> getAcceptedFlowerCoordinates(IBeeHousing beeHousing, IBee bee, String flowerType, int maxFlowers);
/**
* Checks a single coordinate to see if it is an accepted flower.
* @deprecated since Forestry 5.5.2. Use {@link #createAcceptedFlowerPredicate(String)}.
*/
@Deprecated
boolean isAcceptedFlower(String flowerType, World world, BlockPos pos);
/**
* Calls the appropriate IFlowerGrowthRule to grow a flower at a specified position.
* @deprecated since Forestry 5.5.4. Use {@link #growFlower(String, World, IIndividual, BlockPos, Collection)}
*/
@Deprecated
boolean growFlower(String flowerType, World world, IIndividual individual, BlockPos pos);
}
+1 -1
View File
@@ -30,7 +30,7 @@ public interface IDescriptiveRecipe {
* @return array of all the ingredients in the crafting table.
* Each inner list represents one slot's accepted ItemStacks
*/
NonNullList<NonNullList<ItemStack>> getIngredients();
NonNullList<NonNullList<ItemStack>> getRawIngredients();
NonNullList<String> getOreDicts();
+4 -2
View File
@@ -8,12 +8,14 @@ package forestry.api.storage;
import javax.annotation.Nullable;
import java.util.function.Predicate;
import forestry.api.genetics.ISpeciesRoot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.common.registry.IForgeRegistryEntry;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.registries.IForgeRegistryEntry;
import forestry.api.genetics.ISpeciesRoot;
/**
* The Backpack Interface allows you to add items to Forestry backpacks or create your own backpacks.
@@ -38,23 +38,23 @@ import forestry.apiculture.network.packets.PacketBeeLogicActive;
import forestry.apiculture.network.packets.PacketBeeLogicActiveEntity;
import forestry.core.config.Constants;
import forestry.core.errors.EnumErrorCode;
import forestry.core.network.IStreamable;
import forestry.core.network.PacketBufferForestry;
import forestry.core.utils.Log;
import forestry.core.utils.NetworkUtil;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.PacketBuffer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
public class BeekeepingLogic implements IBeekeepingLogic {
private static final int totalBreedingTime = Constants.APIARY_BREEDING_TIME;
@@ -136,7 +136,7 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
}
@Override
public void writeData(PacketBufferForestry data) {
public void writeData(PacketBuffer data) {
data.writeBoolean(active);
if (active) {
data.writeItemStack(queenStack);
@@ -145,7 +145,7 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
}
@Override
public void readData(PacketBufferForestry data) throws IOException {
public void readData(PacketBuffer data) throws IOException {
boolean active = data.readBoolean();
setActive(active);
if (active) {
@@ -203,11 +203,13 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
if (this.queenStack != queenStack) {
if (!queenStack.isEmpty()) {
this.queen = BeeManager.beeRoot.getMember(queenStack);
if (this.queen != null) {
hasFlowersCache.onNewQueen(queen, housing);
}
} else {
this.queen = null;
}
this.queenStack = queenStack;
hasFlowersCache.clear();
queenCanWorkCache.clear();
}
@@ -222,7 +224,8 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
errorLogic.setCondition(true, errorState);
}
boolean hasFlowers = hasFlowersCache.hasFlowers(queen, housing);
hasFlowersCache.update(queen, housing);
boolean hasFlowers = hasFlowersCache.hasFlowers();
boolean flowerCacheNeedsSync = hasFlowersCache.needsSync();
errorLogic.setCondition(!hasFlowers, EnumErrorCode.NO_FLOWER);
@@ -250,9 +253,11 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
@Override
public void clearCachedValues() {
if (!housing.getWorldObj().isRemote) {
hasFlowersCache.clear();
queenCanWorkCache.clear();
canWork();
if (queen != null) {
hasFlowersCache.forceLookForFlowers(queen, housing);
}
}
}
@@ -272,14 +277,21 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
queenWorkCycleThrottle = 0;
doProduction(queen, housing, beeListener);
queen.plantFlowerRandom(housing);
World world = housing.getWorldObj();
List<IBlockState> flowers = hasFlowersCache.getFlowers(world);
if (flowers.size() < PluginApiculture.maxFlowersSpawnedPerHive) {
BlockPos blockPos = queen.plantFlowerRandom(housing, flowers);
if (blockPos != null) {
hasFlowersCache.addFlowerPos(blockPos);
}
}
pollenHandler.doPollination(queen, housing, beeListener);
// Age the queen
IBeeGenome mate = queen.getMate();
Preconditions.checkState(mate != null);
float lifespanModifier = beeModifier.getLifespanModifier(queen.getGenome(), mate, 1.0f);
queen.age(housing.getWorldObj(), lifespanModifier);
queen.age(world, lifespanModifier);
// Write the changed queen back into the item stack.
NBTTagCompound nbttagcompound = new NBTTagCompound();
@@ -10,80 +10,99 @@
******************************************************************************/
package forestry.apiculture;
import javax.annotation.Nullable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.FlowerManager;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeeModifier;
import forestry.api.core.INbtReadable;
import forestry.api.core.INbtWritable;
import forestry.api.core.IBlockPosPredicate;
import forestry.api.genetics.IFlowerProvider;
import forestry.core.network.IStreamable;
import forestry.core.network.PacketBufferForestry;
import forestry.core.utils.VectUtil;
import forestry.core.utils.TickHelper;
import net.minecraft.block.state.IBlockState;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3i;
import net.minecraft.world.World;
public class HasFlowersCache implements INbtWritable, INbtReadable, IStreamable {
private static final String nbtKey = "hasFlowerCache";
private static final String nbtKeyFlowers = "flowers";
private static final String nbtKeyCooldown = "cooldown";
public class HasFlowersCache implements INbtWritable, INbtReadable {
private static final String NBT_KEY = "hasFlowerCache";
private static final String NBT_KEY_FLOWERS = "flowers";
private static final int FLOWER_CHECK_INTERVAL = 200;
private static final Random random = new Random();
private static final int flowerCheckInterval = 128;
private final TickHelper tickHelper = new TickHelper();
private final int flowerCheckTime = random.nextInt(flowerCheckInterval);
private List<BlockPos> flowerCoords = new ArrayList<>();
private int cooldown = 0;
@Nullable
private FlowerData flowerData;
private final List<BlockPos> flowerCoords = new ArrayList<>();
private final List<IBlockState> flowers = new ArrayList<>();
private boolean needsSync = false;
public boolean hasFlowers(IBee queen, IBeeHousing beeHousing) {
IFlowerProvider flowerProvider = queen.getGenome().getFlowerProvider();
String flowerType = flowerProvider.getFlowerType();
private static class FlowerData {
public final String flowerType;
public final Vec3i territory;
public final IBlockPosPredicate flowerPredicate;
public Iterator<BlockPos.MutableBlockPos> areaIterator;
public FlowerData(IBee queen, IBeeHousing beeHousing) {
IFlowerProvider flowerProvider = queen.getGenome().getFlowerProvider();
this.flowerType = flowerProvider.getFlowerType();
this.territory = queen.getGenome().getTerritory();
this.flowerPredicate = FlowerManager.flowerRegistry.createAcceptedFlowerPredicate(flowerType);
this.areaIterator = FlowerManager.flowerRegistry.getAreaIterator(beeHousing, queen);
}
public void resetIterator(IBee queen, IBeeHousing beeHousing) {
this.areaIterator = FlowerManager.flowerRegistry.getAreaIterator(beeHousing, queen);
}
}
public void update(IBee queen, IBeeHousing beeHousing) {
if (flowerData == null) {
this.flowerData = new FlowerData(queen, beeHousing);
this.flowerCoords.clear();
this.flowers.clear();
}
World world = beeHousing.getWorldObj();
tickHelper.onTick();
if (!flowerCoords.isEmpty()) {
if (world.getTotalWorldTime() % flowerCheckInterval != flowerCheckTime) {
return true;
}
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(beeHousing);
BlockPos housingCoords = beeHousing.getCoordinates();
Vec3i genomeTerritory = queen.getGenome().getTerritory();
float housingModifier = beeModifier.getTerritoryModifier(queen.getGenome(), 1f);
Vec3i area = VectUtil.scale(genomeTerritory, housingModifier * 3.0f);
BlockPos min = VectUtil.scale(area, -0.5f).add(housingCoords);
BlockPos max = VectUtil.scale(area, 0.5f).add(housingCoords);
for (BlockPos flowerPos : flowerCoords) {
if (!isFlowerValid(world, flowerPos, flowerType, min, max)) {
cooldown = 0;
break;
if (!flowerCoords.isEmpty() && tickHelper.updateOnInterval(FLOWER_CHECK_INTERVAL)) {
Iterator<BlockPos> iterator = flowerCoords.iterator();
while (iterator.hasNext()) {
BlockPos flowerPos = iterator.next();
if (!flowerData.flowerPredicate.test(world, flowerPos) && world.isBlockLoaded(flowerPos)) {
iterator.remove();
flowers.clear();
needsSync = true;
}
}
}
if (cooldown <= 0) {
List<BlockPos> newFlowerCoords = FlowerManager.flowerRegistry.getAcceptedFlowerCoordinates(beeHousing, queen, flowerType, 5);
cooldown = PluginApiculture.ticksPerBeeWorkCycle;
if (!flowerCoords.equals(newFlowerCoords)) {
flowerCoords = newFlowerCoords;
needsSync = true;
}
} else {
cooldown--;
}
final int flowerCount = flowerCoords.size();
final int ticksPerCheck = 1 + (flowerCount * flowerCount);
if (tickHelper.updateOnInterval(ticksPerCheck)) {
if (flowerData.areaIterator.hasNext()) {
BlockPos.MutableBlockPos blockPos = flowerData.areaIterator.next();
if (flowerData.flowerPredicate.test(world, blockPos)) {
addFlowerPos(blockPos.toImmutable());
}
} else {
flowerData.resetIterator(queen, beeHousing);
}
}
}
public boolean hasFlowers() {
return !flowerCoords.isEmpty();
}
@@ -93,37 +112,65 @@ public class HasFlowersCache implements INbtWritable, INbtReadable, IStreamable
return returnVal;
}
public void clear() {
flowerCoords.clear();
cooldown = 0;
public void onNewQueen(IBee queen, IBeeHousing housing) {
if (this.flowerData != null) {
IBeeGenome genome = queen.getGenome();
String flowerType = genome.getFlowerProvider().getFlowerType();
if (!this.flowerData.flowerType.equals(flowerType)
|| !this.flowerData.territory.equals(genome.getTerritory())) {
flowerData = new FlowerData(queen, housing);
flowerCoords.clear();
flowers.clear();
}
}
}
public List<BlockPos> getFlowerCoords() {
return Collections.unmodifiableList(flowerCoords);
}
private static boolean isFlowerValid(World world, BlockPos flowerCoords, String flowerType, BlockPos min, BlockPos max) {
if (!isFlowerCoordInRange(flowerCoords, min, max)) {
return false;
public List<IBlockState> getFlowers(World world) {
if (flowers.isEmpty() && !flowerCoords.isEmpty()) {
flowers.clear();
for (BlockPos flowerCoord : flowerCoords) {
IBlockState blockState = world.getBlockState(flowerCoord);
flowers.add(blockState);
}
}
return FlowerManager.flowerRegistry.isAcceptedFlower(flowerType, world, flowerCoords);
return Collections.unmodifiableList(flowers);
}
private static boolean isFlowerCoordInRange(BlockPos flowerCoords, BlockPos min, BlockPos max) {
return flowerCoords.getX() >= min.getX() && flowerCoords.getX() <= max.getX() && flowerCoords.getY() >= min.getY() && flowerCoords.getY() <= max.getY() && flowerCoords.getZ() >= min.getZ() && flowerCoords.getZ() <= max.getZ();
public void addFlowerPos(BlockPos blockPos) {
flowerCoords.add(blockPos);
flowers.clear();
needsSync = true;
}
public void forceLookForFlowers(IBee queen, IBeeHousing housing) {
if (flowerData != null) {
flowerCoords.clear();
flowers.clear();
flowerData.resetIterator(queen, housing);
World world = housing.getWorldObj();
while (flowerData.areaIterator.hasNext()) {
BlockPos.MutableBlockPos blockPos = flowerData.areaIterator.next();
if (flowerData.flowerPredicate.test(world, blockPos)) {
addFlowerPos(blockPos.toImmutable());
}
}
}
}
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
if (!nbttagcompound.hasKey(nbtKey)) {
if (!nbttagcompound.hasKey(NBT_KEY)) {
return;
}
NBTTagCompound hasFlowerCacheNBT = nbttagcompound.getCompoundTag(nbtKey);
NBTTagCompound hasFlowerCacheNBT = nbttagcompound.getCompoundTag(NBT_KEY);
if (hasFlowerCacheNBT.hasKey(nbtKeyFlowers)) {
int[] flowersList = hasFlowerCacheNBT.getIntArray(nbtKeyFlowers);
if (hasFlowerCacheNBT.hasKey(NBT_KEY_FLOWERS)) {
int[] flowersList = hasFlowerCacheNBT.getIntArray(NBT_KEY_FLOWERS);
if (flowersList.length % 3 == 0) {
int flowerCount = flowersList.length / 3;
for (int i = 0; i < flowerCount; i++) {
@@ -133,8 +180,7 @@ public class HasFlowersCache implements INbtWritable, INbtReadable, IStreamable
needsSync = true;
}
}
cooldown = hasFlowerCacheNBT.getInteger(nbtKeyCooldown);
flowers.clear();
}
@Override
@@ -151,17 +197,14 @@ public class HasFlowersCache implements INbtWritable, INbtReadable, IStreamable
i++;
}
hasFlowerCacheNBT.setIntArray(nbtKeyFlowers, flowersList);
hasFlowerCacheNBT.setIntArray(NBT_KEY_FLOWERS, flowersList);
}
hasFlowerCacheNBT.setInteger(nbtKeyCooldown, cooldown);
nbttagcompound.setTag(nbtKey, hasFlowerCacheNBT);
nbttagcompound.setTag(NBT_KEY, hasFlowerCacheNBT);
return nbttagcompound;
}
@Override
public void writeData(PacketBufferForestry data) {
public void writeData(PacketBuffer data) {
int size = flowerCoords.size();
data.writeVarInt(size);
if (size > 0) {
@@ -173,9 +216,9 @@ public class HasFlowersCache implements INbtWritable, INbtReadable, IStreamable
}
}
@Override
public void readData(PacketBufferForestry data) throws IOException {
public void readData(PacketBuffer data) throws IOException {
flowerCoords.clear();
flowers.clear();
int size = data.readVarInt();
while (size > 0) {
+95 -73
View File
@@ -10,6 +10,9 @@
******************************************************************************/
package forestry.apiculture;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import javax.annotation.Nullable;
import java.io.File;
import java.util.ArrayList;
@@ -18,8 +21,42 @@ import java.util.Objects;
import java.util.Random;
import java.util.Set;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import net.minecraft.block.BlockFlower;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.init.PotionTypes;
import net.minecraft.item.ItemStack;
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;
import net.minecraft.world.storage.loot.LootTableList;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.MinecraftForge;
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;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
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 forestry.Forestry;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
@@ -96,36 +133,6 @@ import forestry.food.items.ItemRegistryFood;
import forestry.plugins.BlankForestryPlugin;
import forestry.plugins.ForestryPlugin;
import forestry.plugins.ForestryPluginUids;
import net.minecraft.block.BlockFlower;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.init.PotionTypes;
import net.minecraft.item.ItemStack;
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.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.chunk.IChunkGenerator;
import net.minecraft.world.storage.loot.LootTableList;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.MinecraftForge;
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.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.event.FMLInterModComms.IMCMessage;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
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;
@ForestryPlugin(pluginID = ForestryPluginUids.APICULTURE, name = "Apiculture", author = "SirSengir", url = Constants.URL, unlocalizedDescription = "for.plugin.apiculture.description")
public class PluginApiculture extends BlankForestryPlugin {
@@ -144,6 +151,7 @@ public class PluginApiculture extends BlankForestryPlugin {
public static String beekeepingMode = "NORMAL";
public static final int ticksPerBeeWorkCycle = 550;
public static int maxFlowersSpawnedPerHive = 20;
@Nullable
public static VillagerRegistry.VillagerProfession villagerApiarist;
@@ -254,6 +262,8 @@ public class PluginApiculture extends BlankForestryPlugin {
secondPrincessChance = config.getFloatLocalized("beekeeping", "second.princess", secondPrincessChance, 0.0f, 100.0f);
maxFlowersSpawnedPerHive = config.getIntLocalized("beekeeping", "flowers.spawn", 20, 0, 1000);
String[] blacklist = config.getStringListLocalized("species", "blacklist", Constants.EMPTY_STRINGS);
parseBeeBlacklist(blacklist);
@@ -306,7 +316,8 @@ public class PluginApiculture extends BlankForestryPlugin {
villagerRegistry.registerVillageCreationHandler(villageHandler);
villagerApiarist = new VillagerRegistry.VillagerProfession(Constants.ID_VILLAGER_APIARIST, Constants.TEXTURE_SKIN_BEEKPEEPER, Constants.TEXTURE_SKIN_ZOMBIE_BEEKPEEPER);
villagerRegistry.register(villagerApiarist);
IForgeRegistry<VillagerRegistry.VillagerProfession> villagerProfessions = ForgeRegistries.VILLAGER_PROFESSIONS;
villagerProfessions.register(villagerApiarist);
ItemStack wildcardPrincess = new ItemStack(items.beePrincessGE, 1);
ItemStack wildcardDrone = new ItemStack(items.beeDroneGE, 1);
@@ -431,87 +442,88 @@ public class PluginApiculture extends BlankForestryPlugin {
// / APIARIST'S ARMOR
ItemStack wovenSilk = coreItems.craftingMaterial.getWovenSilk();
RecipeUtil.addRecipe(items.apiaristHat,
RecipeUtil.addRecipe("apiarist_hat", items.apiaristHat,
"###", "# #",
'#', wovenSilk);
RecipeUtil.addRecipe(items.apiaristChest,
RecipeUtil.addRecipe("apiarist_chest", items.apiaristChest,
"# #", "###", "###",
'#', wovenSilk);
RecipeUtil.addRecipe(items.apiaristLegs,
RecipeUtil.addRecipe("apiarist_legs", items.apiaristLegs,
"###", "# #", "# #",
'#', wovenSilk);
RecipeUtil.addRecipe(items.apiaristBoots,
RecipeUtil.addRecipe("apiarist_boots", items.apiaristBoots,
"# #", "# #",
'#', wovenSilk);
// / HABITAT LOCATOR
RecipeUtil.addRecipe(items.habitatLocator,
RecipeUtil.addRecipe("habitat_locator", items.habitatLocator,
" X ",
"X#X",
" X ",
'#', OreDictUtil.DUST_REDSTONE, 'X', OreDictUtil.INGOT_BRONZE);
// Bees
RecipeUtil.addRecipe(items.scoop,
RecipeUtil.addRecipe("scoop", items.scoop,
"#X#", "###", " # ",
'#', OreDictUtil.STICK_WOOD,
'X', Blocks.WOOL);
RecipeUtil.addRecipe(items.smoker,
RecipeUtil.addRecipe("smoker", items.smoker,
"LS#",
"LF#",
"###",
'#', "ingotTin", 'S', OreDictUtil.STICK_WOOD, 'F', Items.FLINT_AND_STEEL, 'L', OreDictUtil.LEATHER);
RecipeUtil.addRecipe(new ItemStack(Items.SLIME_BALL),
RecipeUtil.addRecipe("propolis_to_slime", new ItemStack(Items.SLIME_BALL),
"#X#", "#X#", "#X#",
'#', items.propolis,
'X', items.pollenCluster.get(EnumPollenCluster.NORMAL, 1));
RecipeUtil.addRecipe(new ItemStack(Items.SPECKLED_MELON),
RecipeUtil.addRecipe("honey_melon", new ItemStack(Items.SPECKLED_MELON),
"#X#", "#Y#", "#X#",
'#', items.honeyDrop,
'X', items.honeydew,
'Y', Items.MELON);
RecipeUtil.addRecipe(items.frameUntreated,
RecipeUtil.addRecipe("frame_untreated", items.frameUntreated,
"###", "#S#", "###",
'#', OreDictUtil.STICK_WOOD,
'S', Items.STRING);
RecipeUtil.addRecipe(items.frameImpregnated,
RecipeUtil.addRecipe("frame_impregnated", items.frameImpregnated,
"###", "#S#", "###",
'#', coreItems.stickImpregnated,
'S', Items.STRING);
RecipeUtil.addRecipe(items.minecartBeehouse.getBeeHouseMinecart(),
RecipeUtil.addRecipe("bee_house_minecart", items.minecartBeehouse.getBeeHouseMinecart(),
"B",
"C",
'B', new ItemStack(blocks.beeHouse),
'C', Items.MINECART);
RecipeUtil.addRecipe(items.minecartBeehouse.getApiaryMinecart(),
RecipeUtil.addRecipe("apiary_minecart", items.minecartBeehouse.getApiaryMinecart(),
"B",
"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(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));
}
}
// FOOD STUFF
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.FOOD)) {
ItemRegistryFood foodItems = PluginFood.getItems();
RecipeUtil.addRecipe(new ItemStack(foodItems.honeyedSlice, 4),
RecipeUtil.addRecipe("honeyed_slice", new ItemStack(foodItems.honeyedSlice, 4),
"###", "#X#", "###",
'#', items.honeyDrop,
'X', Items.BREAD);
RecipeUtil.addRecipe(foodItems.honeyPot,
RecipeUtil.addRecipe("honey_pot", foodItems.honeyPot,
"# #", " X ", "# #",
'#', items.honeyDrop,
'X', fluidItems.waxCapsuleEmpty);
RecipeUtil.addRecipe(foodItems.ambrosia,
RecipeUtil.addRecipe("ambrosia", foodItems.ambrosia,
"#Y#", "XXX", "###",
'#', items.honeydew,
'X', items.royalJelly,
@@ -523,33 +535,33 @@ public class PluginApiculture extends BlankForestryPlugin {
int outputCapsuleAmount = ForestryAPI.activeMode.getIntegerSetting("recipe.output.capsule");
if (outputCapsuleAmount > 0) {
ItemStack capsule = fluidItems.waxCapsuleEmpty.getItemStack(outputCapsuleAmount);
RecipeUtil.addRecipe(capsule, "###", '#', coreItems.beeswax);
RecipeUtil.addRecipe("wax_capsule", capsule, "###", '#', coreItems.beeswax);
}
int outputRefractoryAmount = ForestryAPI.activeMode.getIntegerSetting("recipe.output.refractory");
if (outputRefractoryAmount > 0) {
ItemStack capsule = fluidItems.refractoryEmpty.getItemStack(outputRefractoryAmount);
RecipeUtil.addRecipe(capsule, "###", '#', coreItems.refractoryWax);
RecipeUtil.addRecipe("refractory_capsule", capsule, "###", '#', coreItems.refractoryWax);
}
// / BITUMINOUS PEAT
RecipeUtil.addRecipe(coreItems.bituminousPeat.getItemStack(),
RecipeUtil.addRecipe("bituminous_peat", coreItems.bituminousPeat.getItemStack(),
" # ", "XYX", " # ",
'#', OreDictUtil.DUST_ASH,
'X', coreItems.peat,
'Y', items.propolis);
// / TORCHES
RecipeUtil.addRecipe(new ItemStack(Blocks.TORCH, 3),
RecipeUtil.addRecipe("beeswax_worth", new ItemStack(Blocks.TORCH, 3),
" # ", " # ", " Y ",
'#', coreItems.beeswax,
'Y', OreDictUtil.STICK_WOOD);
RecipeUtil.addRecipe(coreItems.craftingMaterial.getPulsatingMesh(),
RecipeUtil.addRecipe("pulsating_mesh", coreItems.craftingMaterial.getPulsatingMesh(),
"# #", " # ", "# #",
'#', items.propolis.get(EnumPropolis.PULSATING, 1));
// / WAX CAST
RecipeUtil.addRecipe(items.waxCast,
RecipeUtil.addRecipe("wax_cast", items.waxCast,
"###",
"# #",
"###",
@@ -557,14 +569,14 @@ public class PluginApiculture extends BlankForestryPlugin {
// / ALVEARY
ItemStack alvearyPlainBlock = blocks.getAlvearyBlock(BlockAlvearyType.PLAIN);
RecipeUtil.addRecipe(alvearyPlainBlock,
RecipeUtil.addRecipe("alveary_plain", alvearyPlainBlock,
"###",
"#X#",
"###",
'X', coreItems.impregnatedCasing,
'#', coreItems.craftingMaterial.getScentedPaneling());
// SWARMER
RecipeUtil.addRecipe(blocks.getAlvearyBlock(BlockAlvearyType.SWARMER),
RecipeUtil.addRecipe("alveary_swarmer", blocks.getAlvearyBlock(BlockAlvearyType.SWARMER),
"#G#",
" X ",
"#G#",
@@ -572,7 +584,7 @@ public class PluginApiculture extends BlankForestryPlugin {
'X', alvearyPlainBlock,
'G', OreDictUtil.INGOT_GOLD);
// FAN
RecipeUtil.addRecipe(blocks.getAlvearyBlock(BlockAlvearyType.FAN),
RecipeUtil.addRecipe("alveary_fan", blocks.getAlvearyBlock(BlockAlvearyType.FAN),
"I I",
" X ",
"I#I",
@@ -580,7 +592,7 @@ public class PluginApiculture extends BlankForestryPlugin {
'X', alvearyPlainBlock,
'I', OreDictUtil.INGOT_IRON);
// HEATER
RecipeUtil.addRecipe(blocks.getAlvearyBlock(BlockAlvearyType.HEATER),
RecipeUtil.addRecipe("alveary_heater", blocks.getAlvearyBlock(BlockAlvearyType.HEATER),
"#I#",
" X ",
"YYY",
@@ -588,7 +600,7 @@ public class PluginApiculture extends BlankForestryPlugin {
'X', alvearyPlainBlock,
'I', OreDictUtil.INGOT_IRON, 'Y', OreDictUtil.STONE);
// HYGROREGULATOR
RecipeUtil.addRecipe(blocks.getAlvearyBlock(BlockAlvearyType.HYGRO),
RecipeUtil.addRecipe("alveary_hygro", blocks.getAlvearyBlock(BlockAlvearyType.HYGRO),
"GIG",
"GXG",
"GIG",
@@ -596,14 +608,14 @@ public class PluginApiculture extends BlankForestryPlugin {
'I', OreDictUtil.INGOT_IRON,
'G', OreDictUtil.BLOCK_GLASS);
// STABILISER
RecipeUtil.addRecipe(blocks.getAlvearyBlock(BlockAlvearyType.STABILISER),
RecipeUtil.addRecipe("alveary_stabiliser", blocks.getAlvearyBlock(BlockAlvearyType.STABILISER),
"G G",
"GXG",
"G G",
'X', alvearyPlainBlock,
'G', OreDictUtil.GEM_QUARTZ);
// SIEVE
RecipeUtil.addRecipe(blocks.getAlvearyBlock(BlockAlvearyType.SIEVE),
RecipeUtil.addRecipe("alveary_sieve", blocks.getAlvearyBlock(BlockAlvearyType.SIEVE),
"III",
" X ",
"WWW",
@@ -651,8 +663,8 @@ public class PluginApiculture extends BlankForestryPlugin {
"#X#",
'#', coreItems.beeswax,
'X', coreItems.craftingMaterial.getSilkWisp());
RecipeUtil.addShapelessRecipe(blocks.candle.getUnlitCandle(1), blocks.candle.getUnlitCandle(1));
RecipeUtil.addShapelessRecipe(blocks.candle.getLitCandle(1), blocks.candle.getLitCandle(1));
RecipeUtil.addShapelessRecipe("candle_unlit_reset", blocks.candle.getUnlitCandle(1), blocks.candle.getUnlitCandle(1));
RecipeUtil.addShapelessRecipe("candle_lit_reset", blocks.candle.getLitCandle(1), blocks.candle.getLitCandle(1));
// / CENTRIFUGE
// Honey combs
@@ -752,7 +764,7 @@ public class PluginApiculture extends BlankForestryPlugin {
RecipeManagers.fermenterManager.addRecipe(items.honeydew.getItemStack(), 500, 1.0f, Fluids.SHORT_MEAD.getFluid(1), Fluids.FOR_HONEY.getFluid(1));
}
RecipeUtil.addRecipe(blocks.apiary,
RecipeUtil.addRecipe("apiary", blocks.apiary,
"XXX",
"#C#",
"###",
@@ -760,7 +772,7 @@ public class PluginApiculture extends BlankForestryPlugin {
'#', OreDictUtil.PLANK_WOOD,
'C', coreItems.impregnatedCasing);
RecipeUtil.addRecipe(blocks.beeChest,
RecipeUtil.addRecipe("bee_chest", blocks.beeChest,
" # ",
"XYX",
"XXX",
@@ -768,7 +780,7 @@ public class PluginApiculture extends BlankForestryPlugin {
'X', OreDictUtil.BEE_COMB,
'Y', OreDictUtil.CHEST_WOOD);
RecipeUtil.addRecipe(blocks.beeHouse,
RecipeUtil.addRecipe("bee_house", blocks.beeHouse,
"XXX",
"#C#",
"###",
@@ -893,8 +905,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);
}
}
@@ -10,9 +10,10 @@
******************************************************************************/
package forestry.apiculture;
import net.minecraft.world.World;
import forestry.api.apiculture.BeeManager;
import forestry.core.ISaveEventHandler;
import net.minecraft.world.World;
public class SaveEventHandlerApiculture implements ISaveEventHandler {
@@ -0,0 +1,163 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture;
import java.io.IOException;
import java.util.List;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeekeepingLogic;
import forestry.api.genetics.IEffectData;
import forestry.apiculture.network.packets.PacketBeeLogicActive;
import forestry.apiculture.tiles.TileHive;
import forestry.core.utils.NetworkUtil;
import forestry.core.utils.TickHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class WorldgenBeekeepingLogic implements IBeekeepingLogic {
private final TileHive housing;
private IEffectData effectData[] = new IEffectData[2];
private final HasFlowersCache hasFlowersCache = new HasFlowersCache();
private final TickHelper tickHelper = new TickHelper();
// Client
private boolean active;
public WorldgenBeekeepingLogic(TileHive housing) {
this.housing = housing;
}
// / SAVING & LOADING
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
setActive(nbttagcompound.getBoolean("Active"));
hasFlowersCache.readFromNBT(nbttagcompound);
}
@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
nbttagcompound.setBoolean("Active", active);
hasFlowersCache.writeToNBT(nbttagcompound);
return nbttagcompound;
}
@Override
public void writeData(PacketBuffer data) {
data.writeBoolean(active);
if (active) {
hasFlowersCache.writeData(data);
}
}
@Override
public void readData(PacketBuffer data) throws IOException {
boolean active = data.readBoolean();
setActive(active);
if (active) {
hasFlowersCache.readData(data);
}
}
/* Activatable */
private void setActive(boolean active) {
if (this.active == active) {
return;
}
this.active = active;
syncToClient();
}
/* UPDATING */
@Override
public boolean canWork() {
tickHelper.onTick();
IBee queen = housing.getContainedBee();
hasFlowersCache.update(queen, housing);
if (tickHelper.updateOnInterval(200)) {
World world = housing.getWorldObj();
boolean canWork = (world.isDaytime() || queen.getGenome().getNeverSleeps()) &&
(!housing.isRaining() || queen.getGenome().getToleratesRain());
boolean flowerCacheNeedsSync = hasFlowersCache.needsSync();
if (active != canWork) {
setActive(canWork);
} else if (flowerCacheNeedsSync) {
syncToClient();
}
}
return active;
}
@Override
public void doWork() {
}
@Override
public void clearCachedValues() {
}
/* CLIENT */
@Override
public void syncToClient() {
World world = housing.getWorldObj();
if (world != null && !world.isRemote) {
NetworkUtil.sendNetworkPacket(new PacketBeeLogicActive(housing), housing.getCoordinates(), world);
}
}
@Override
public void syncToClient(EntityPlayerMP player) {
World world = housing.getWorldObj();
if (world != null && !world.isRemote) {
NetworkUtil.sendToPlayer(new PacketBeeLogicActive(housing), player);
}
}
@Override
public int getBeeProgressPercent() {
return 0;
}
@Override
@SideOnly(Side.CLIENT)
public boolean canDoBeeFX() {
return !Minecraft.getMinecraft().isGamePaused() && active;
}
@Override
@SideOnly(Side.CLIENT)
public void doBeeFX() {
IBee queen = housing.getContainedBee();
queen.doFX(effectData, housing);
}
@Override
public List<BlockPos> getFlowerPositions() {
return hasFlowersCache.getFlowerCoords();
}
}
+23 -20
View File
@@ -10,12 +10,34 @@
******************************************************************************/
package forestry.apiculture.blocks;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.core.IModelManager;
import forestry.api.core.IStateMapperRegister;
import forestry.api.core.Tabs;
@@ -36,25 +58,6 @@ import forestry.core.tiles.TileUtil;
import forestry.core.utils.BlockUtil;
import forestry.core.utils.NetworkUtil;
import forestry.core.utils.Translator;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public abstract class BlockAlveary extends BlockStructure implements IStateMapperRegister {
private static final PropertyEnum<State> STATE = PropertyEnum.create("state", State.class);
@@ -259,7 +262,7 @@ public abstract class BlockAlveary extends BlockStructure implements IStateMappe
@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced) {
public void addInformation(ItemStack stack, @Nullable World world, List<String> tooltip, ITooltipFlag advanced) {
tooltip.add(Translator.translateToLocal("tile.for.alveary.tooltip"));
}
}
+20 -23
View File
@@ -11,11 +11,28 @@
package forestry.apiculture.blocks;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IBee;
@@ -30,22 +47,6 @@ import forestry.apiculture.PluginApiculture;
import forestry.apiculture.tiles.TileHive;
import forestry.core.blocks.IBlockWithMeta;
import forestry.core.tiles.TileUtil;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockBeeHives extends BlockContainer implements IItemModelRegister, IBlockWithMeta {
private static final PropertyEnum<HiveType> HIVE_TYPES = PropertyEnum.create("hive", HiveType.class);
@@ -96,9 +97,7 @@ public class BlockBeeHives extends BlockContainer implements IItemModelRegister,
}
@Override
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
List<ItemStack> drops = new ArrayList<>();
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
Random random = world instanceof World ? ((World) world).rand : RANDOM;
List<IHiveDrop> hiveDrops = getDropsForHive(getMetaFromState(state));
@@ -142,8 +141,6 @@ public class BlockBeeHives extends BlockContainer implements IItemModelRegister,
break;
}
}
return drops;
}
// / CREATIVE INVENTORY
@@ -173,7 +170,7 @@ public class BlockBeeHives extends BlockContainer implements IItemModelRegister,
}
@Override
public void getSubBlocks(Item itemIn, CreativeTabs tab, NonNullList<ItemStack> list) {
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
for (IBlockState blockState : getBlockState().getValidStates()) {
if (getHiveType(blockState) != HiveType.SWARM) {
int meta = getMetaFromState(blockState);
+20 -21
View File
@@ -10,24 +10,16 @@
******************************************************************************/
package forestry.apiculture.blocks;
import com.google.common.collect.ImmutableMap;
import javax.annotation.Nullable;
import java.awt.Color;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import com.google.common.collect.ImmutableMap;
import forestry.api.core.IItemModelRegister;
import forestry.api.core.IModelManager;
import forestry.api.core.Tabs;
import forestry.apiculture.tiles.TileCandle;
import forestry.core.blocks.IColoredBlock;
import forestry.core.tiles.TileUtil;
import forestry.core.utils.ItemStackUtil;
import net.minecraft.block.BlockTorch;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.SoundType;
@@ -51,9 +43,19 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.oredict.OreDictionary;
import forestry.api.core.IItemModelRegister;
import forestry.api.core.IModelManager;
import forestry.api.core.Tabs;
import forestry.apiculture.tiles.TileCandle;
import forestry.core.blocks.IColoredBlock;
import forestry.core.tiles.TileUtil;
import forestry.core.utils.ItemStackUtil;
public class BlockCandle extends BlockTorch implements IItemModelRegister, ITileEntityProvider, IColoredBlock {
@@ -148,7 +150,7 @@ public class BlockCandle extends BlockTorch implements IItemModelRegister, ITile
}
@Override
public void getSubBlocks(Item itemIn, CreativeTabs tab, NonNullList<ItemStack> list) {
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
list.add(new ItemStack(this, 1, 0));
}
@@ -200,9 +202,9 @@ public class BlockCandle extends BlockTorch implements IItemModelRegister, ITile
if (toggleLitState) {
tileCandle.setLit(!isLit);
worldIn.markBlockRangeForRenderUpdate(pos, pos);
worldIn.theProfiler.startSection("checkLight");
worldIn.profiler.startSection("checkLight");
worldIn.checkLight(pos);
worldIn.theProfiler.endSection();
worldIn.profiler.endSection();
flag = true;
}
return flag;
@@ -238,9 +240,9 @@ public class BlockCandle extends BlockTorch implements IItemModelRegister, ITile
drop.set(itemStack);
}
}
@Override
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
ItemStack dropStack = drop.get();
drop.remove();
@@ -249,10 +251,7 @@ public class BlockCandle extends BlockTorch implements IItemModelRegister, ITile
dropStack = getCandleDrop(world, pos);
}
ArrayList<ItemStack> drops = new ArrayList<>(1);
drops.add(dropStack);
return drops;
}
@Override
@@ -287,9 +286,9 @@ public class BlockCandle extends BlockTorch implements IItemModelRegister, ITile
tileCandle.setColour(colour);
tileCandle.setLit(isLit);
if (tileCandle.isLit()) {
world.theProfiler.startSection("checkLight");
world.profiler.startSection("checkLight");
world.checkLight(pos);
world.theProfiler.endSection();
world.profiler.endSection();
}
}
}
+14 -12
View File
@@ -1,18 +1,9 @@
package forestry.apiculture.blocks;
import javax.annotation.Nullable;
import com.google.common.base.Predicate;
import forestry.api.core.IItemModelRegister;
import forestry.api.core.IModelManager;
import forestry.api.core.IStateMapperRegister;
import forestry.api.core.Tabs;
import forestry.apiculture.items.EnumHoneyComb;
import forestry.core.blocks.IBlockWithMeta;
import forestry.core.blocks.IColoredBlock;
import forestry.core.config.Config;
import forestry.core.config.Constants;
import javax.annotation.Nullable;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyEnum;
@@ -27,10 +18,21 @@ import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.core.IItemModelRegister;
import forestry.api.core.IModelManager;
import forestry.api.core.IStateMapperRegister;
import forestry.api.core.Tabs;
import forestry.apiculture.items.EnumHoneyComb;
import forestry.core.blocks.IBlockWithMeta;
import forestry.core.blocks.IColoredBlock;
import forestry.core.config.Config;
import forestry.core.config.Constants;
public abstract class BlockHoneyComb extends Block implements IItemModelRegister, IBlockWithMeta, IColoredBlock, IStateMapperRegister {
public final int minMeta;
@@ -75,7 +77,7 @@ public abstract class BlockHoneyComb extends Block implements IItemModelRegister
}
@Override
public void getSubBlocks(Item itemIn, CreativeTabs tab, NonNullList<ItemStack> list) {
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
for (EnumHoneyComb honeyComb : getVariant().getAllowedValues()) {
if(!honeyComb.isSecret() || Config.isDebug){
list.add(get(honeyComb));
@@ -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());
}
}
+9 -7
View File
@@ -12,12 +12,6 @@ package forestry.apiculture.blocks;
import java.util.Random;
import forestry.api.core.IItemModelRegister;
import forestry.api.core.IModelManager;
import forestry.api.core.Tabs;
import forestry.apiculture.PluginApiculture;
import forestry.apiculture.tiles.TileCandle;
import forestry.core.config.Constants;
import net.minecraft.block.Block;
import net.minecraft.block.BlockTorch;
import net.minecraft.block.SoundType;
@@ -31,9 +25,17 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
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.api.core.IItemModelRegister;
import forestry.api.core.IModelManager;
import forestry.api.core.Tabs;
import forestry.apiculture.PluginApiculture;
import forestry.apiculture.tiles.TileCandle;
import forestry.core.config.Constants;
public class BlockStump extends BlockTorch implements IItemModelRegister {
public BlockStump() {
@@ -49,7 +51,7 @@ public class BlockStump extends BlockTorch implements IItemModelRegister {
}
@Override
public void getSubBlocks(Item itemIn, CreativeTabs tab, NonNullList<ItemStack> list) {
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
list.add(new ItemStack(this, 1, 0));
}
@@ -7,13 +7,13 @@ import forestry.apiculture.PluginApiculture;
import forestry.apiculture.items.ItemRegistryApiculture;
import forestry.core.genetics.Genome;
import forestry.core.utils.JeiUtil;
import mezz.jei.api.BlankModPlugin;
import mezz.jei.api.IModPlugin;
import mezz.jei.api.IModRegistry;
import mezz.jei.api.ISubtypeRegistry;
import mezz.jei.api.JEIPlugin;
@JEIPlugin
public class ApicultureJeiPlugin extends BlankModPlugin {
public class ApicultureJeiPlugin implements IModPlugin {
@Override
public void registerItemSubtypes(ISubtypeRegistry subtypeRegistry) {
ItemRegistryApiculture items = PluginApiculture.getItems();
@@ -21,7 +21,7 @@ public class ApicultureJeiPlugin extends BlankModPlugin {
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);
+5 -5
View File
@@ -63,17 +63,17 @@ public class AIAvoidPlayers extends EntityAIBase {
if (randomTarget == null) {
return false;
}
if (player.getDistanceSq(randomTarget.xCoord, randomTarget.yCoord, randomTarget.zCoord) < player.getDistanceSqToEntity(mob)) {
if (player.getDistanceSq(randomTarget.x, randomTarget.y, randomTarget.z) < player.getDistanceSqToEntity(mob)) {
return false;
}
path = pathNavigator.getPathToXYZ(randomTarget.xCoord, randomTarget.yCoord, randomTarget.zCoord);
path = pathNavigator.getPathToXYZ(randomTarget.x, randomTarget.y, randomTarget.z);
return path != null;
}
@Override
public boolean continueExecuting() {
public boolean shouldContinueExecuting() {
return !this.pathNavigator.noPath();
}
@@ -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;
@@ -36,6 +36,7 @@ import forestry.core.owner.OwnerHandler;
import forestry.core.tiles.IClimatised;
import forestry.core.utils.ClimateUtil;
import forestry.core.utils.NetworkUtil;
import forestry.core.utils.TickHelper;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.datasync.DataParameter;
import net.minecraft.network.datasync.EntityDataManager;
@@ -47,12 +48,10 @@ import net.minecraft.world.biome.Biome;
public abstract class EntityMinecartBeeHousingBase extends EntityMinecartContainerForestry implements IBeeHousing, IOwnedTile, IGuiBeeHousingDelegate, IClimatised, IStreamableGui {
private static final DataParameter<Optional<GameProfile>> OWNER = EntityDataManager.createKey(EntityMinecartBeeHousingBase.class, GameProfileDataSerializer.INSTANCE);
private static final Random random = new Random();
private static final int beeFXInterval = 4;
private static final int pollenFXInterval = 50;
private final int beeFXTime = random.nextInt(beeFXInterval);
private final int pollenFXTime = random.nextInt(pollenFXInterval);
private final TickHelper tickHelper = new TickHelper();
private final IBeekeepingLogic beeLogic = BeeManager.beeRoot.createBeekeepingLogic(this);
private final IErrorLogic errorLogic = ForestryAPI.errorStateRegistry.createErrorLogic();
@@ -184,6 +183,7 @@ public abstract class EntityMinecartBeeHousingBase extends EntityMinecartContain
@Override
public void onUpdate() {
super.onUpdate();
tickHelper.onTick();
if (!world.isRemote) {
if (beeLogic.canWork()) {
beeLogic.doWork();
@@ -196,11 +196,11 @@ public abstract class EntityMinecartBeeHousingBase extends EntityMinecartContain
}
if (beeLogic.canDoBeeFX()) {
if (world.getTotalWorldTime() % beeFXInterval == beeFXTime) {
if (tickHelper.updateOnInterval(beeFXInterval)) {
beeLogic.doBeeFX();
}
if (world.getTotalWorldTime() % pollenFXInterval == pollenFXTime) {
if (tickHelper.updateOnInterval(pollenFXInterval)) {
TileBeeHousingBase.doPollenFX(world, posX - 0.5, posY - 0.1, posZ - 0.5);
}
}
+16 -15
View File
@@ -10,19 +10,20 @@
******************************************************************************/
package forestry.apiculture.entities;
import forestry.apiculture.PluginApiculture;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.renderer.VertexBuffer;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import forestry.apiculture.PluginApiculture;
public class ParticleBeeExplore extends Particle {
private final Vec3d origin;
public ParticleBeeExplore(World world, Vec3d origin, BlockPos destination, int color) {
super(world, origin.xCoord, origin.yCoord, origin.zCoord, 0.0D, 0.0D, 0.0D);
super(world, origin.x, origin.y, origin.z, 0.0D, 0.0D, 0.0D);
setParticleTexture(PluginApiculture.getBeeSprite());
this.origin = origin;
@@ -54,9 +55,9 @@ public class ParticleBeeExplore extends Particle {
this.move(this.motionX, this.motionY, this.motionZ);
if (this.particleAge == this.particleMaxAge / 2) {
this.motionX = (origin.xCoord - this.posX) * 0.03;
this.motionY = (origin.yCoord - this.posY) * 0.03;
this.motionZ = (origin.zCoord - this.posZ) * 0.03;
this.motionX = (origin.x - this.posX) * 0.03;
this.motionY = (origin.y - this.posY) * 0.03;
this.motionZ = (origin.z - this.posZ) * 0.03;
}
if (this.particleAge < this.particleMaxAge * 0.25) {
@@ -72,15 +73,15 @@ public class ParticleBeeExplore extends Particle {
} else if (this.particleAge < this.particleMaxAge * 0.75) {
// venture back
this.motionX *= 0.95;
this.motionY = (origin.yCoord - this.posY) * 0.03;
this.motionY = (origin.y - this.posY) * 0.03;
this.motionY = (this.motionY + 0.2 * (-0.5 + rand.nextFloat())) / 2;
this.motionZ *= 0.95;
} else {
// get to origin
this.motionX = (origin.xCoord - this.posX) * 0.03;
this.motionY = (origin.yCoord - this.posY) * 0.03;
this.motionX = (origin.x - this.posX) * 0.03;
this.motionY = (origin.y - this.posY) * 0.03;
this.motionY = (this.motionY + 0.2 * (-0.5 + rand.nextFloat())) / 2;
this.motionZ = (origin.zCoord - this.posZ) * 0.03;
this.motionZ = (origin.z - this.posZ) * 0.03;
}
if (this.particleAge++ >= this.particleMaxAge) {
@@ -89,7 +90,7 @@ public class ParticleBeeExplore extends Particle {
}
@Override
public void renderParticle(VertexBuffer worldRendererIn, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) {
public void renderParticle(BufferBuilder buffer, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) {
float minU = 0;
float maxU = 1;
float minV = 0;
@@ -110,10 +111,10 @@ public class ParticleBeeExplore extends Particle {
int i = this.getBrightnessForRender(partialTicks);
int j = i >> 16 & 65535;
int k = i & 65535;
worldRendererIn.pos(f11 - rotationX * f10 - rotationXY * f10, f12 - rotationZ * f10, f13 - rotationYZ * f10 - rotationXZ * f10).tex(maxU, maxV).color(particleRed, particleGreen, particleBlue, 1.0F).lightmap(j, k).endVertex();
worldRendererIn.pos(f11 - rotationX * f10 + rotationXY * f10, f12 + rotationZ * f10, f13 - rotationYZ * f10 + rotationXZ * f10).tex(maxU, minV).color(particleRed, particleGreen, particleBlue, 1.0F).lightmap(j, k).endVertex();
worldRendererIn.pos(f11 + rotationX * f10 + rotationXY * f10, f12 + rotationZ * f10, f13 + rotationYZ * f10 + rotationXZ * f10).tex(minU, minV).color(particleRed, particleGreen, particleBlue, 1.0F).lightmap(j, k).endVertex();
worldRendererIn.pos(f11 + rotationX * f10 - rotationXY * f10, f12 - rotationZ * f10, f13 + rotationYZ * f10 - rotationXZ * f10).tex(minU, maxV).color(particleRed, particleGreen, particleBlue, 1.0F).lightmap(j, k).endVertex();
buffer.pos(f11 - rotationX * f10 - rotationXY * f10, f12 - rotationZ * f10, f13 - rotationYZ * f10 - rotationXZ * f10).tex(maxU, maxV).color(particleRed, particleGreen, particleBlue, 1.0F).lightmap(j, k).endVertex();
buffer.pos(f11 - rotationX * f10 + rotationXY * f10, f12 + rotationZ * f10, f13 - rotationYZ * f10 + rotationXZ * f10).tex(maxU, minV).color(particleRed, particleGreen, particleBlue, 1.0F).lightmap(j, k).endVertex();
buffer.pos(f11 + rotationX * f10 + rotationXY * f10, f12 + rotationZ * f10, f13 + rotationYZ * f10 + rotationXZ * f10).tex(minU, minV).color(particleRed, particleGreen, particleBlue, 1.0F).lightmap(j, k).endVertex();
buffer.pos(f11 + rotationX * f10 - rotationXY * f10, f12 - rotationZ * f10, f13 + rotationYZ * f10 - rotationXZ * f10).tex(minU, maxV).color(particleRed, particleGreen, particleBlue, 1.0F).lightmap(j, k).endVertex();
}
// avoid calculating lighting for bees, it is too much processing
+16 -15
View File
@@ -10,20 +10,21 @@
******************************************************************************/
package forestry.apiculture.entities;
import forestry.apiculture.PluginApiculture;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.renderer.VertexBuffer;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import forestry.apiculture.PluginApiculture;
public class ParticleBeeRoundTrip extends Particle {
private final Vec3d origin;
private final BlockPos destination;
public ParticleBeeRoundTrip(World world, Vec3d origin, BlockPos destination, int color) {
super(world, origin.xCoord, origin.yCoord, origin.zCoord, 0.0D, 0.0D, 0.0D);
super(world, origin.x, origin.y, origin.z, 0.0D, 0.0D, 0.0D);
setParticleTexture(PluginApiculture.getBeeSprite());
this.origin = origin;
@@ -56,9 +57,9 @@ public class ParticleBeeRoundTrip extends Particle {
this.move(this.motionX, this.motionY, this.motionZ);
if (this.particleAge == this.particleMaxAge / 2) {
this.motionX = (origin.xCoord - this.posX) * 0.03 + 0.1 * rand.nextFloat();
this.motionY = (origin.yCoord - this.posY) * 0.03 + 0.1 * rand.nextFloat();
this.motionZ = (origin.zCoord - this.posZ) * 0.03 + 0.1 * rand.nextFloat();
this.motionX = (origin.x - this.posX) * 0.03 + 0.1 * rand.nextFloat();
this.motionY = (origin.y - this.posY) * 0.03 + 0.1 * rand.nextFloat();
this.motionZ = (origin.z - this.posZ) * 0.03 + 0.1 * rand.nextFloat();
}
if (this.particleAge < this.particleMaxAge * 0.25) {
@@ -75,15 +76,15 @@ public class ParticleBeeRoundTrip extends Particle {
} else if (this.particleAge < this.particleMaxAge * 0.75) {
// venture back
this.motionX *= 0.95;
this.motionY = (origin.yCoord - this.posY) * 0.03;
this.motionY = (origin.y - this.posY) * 0.03;
this.motionY = (this.motionY + 0.2 * (-0.5 + rand.nextFloat())) / 2;
this.motionZ *= 0.95;
} else {
// get to origin
this.motionX = (origin.xCoord - this.posX) * 0.03;
this.motionY = (origin.yCoord - this.posY) * 0.03;
this.motionX = (origin.x - this.posX) * 0.03;
this.motionY = (origin.y - this.posY) * 0.03;
this.motionY = (this.motionY + 0.2 * (-0.5 + rand.nextFloat())) / 2;
this.motionZ = (origin.zCoord - this.posZ) * 0.03;
this.motionZ = (origin.z - this.posZ) * 0.03;
}
if (this.particleAge++ >= this.particleMaxAge) {
@@ -92,7 +93,7 @@ public class ParticleBeeRoundTrip extends Particle {
}
@Override
public void renderParticle(VertexBuffer worldRendererIn, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) {
public void renderParticle(BufferBuilder buffer, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) {
float minU = 0;
float maxU = 1;
float minV = 0;
@@ -113,10 +114,10 @@ public class ParticleBeeRoundTrip extends Particle {
int i = this.getBrightnessForRender(partialTicks);
int j = i >> 16 & 65535;
int k = i & 65535;
worldRendererIn.pos(f11 - rotationX * f10 - rotationXY * f10, f12 - rotationZ * f10, f13 - rotationYZ * f10 - rotationXZ * f10).tex(maxU, maxV).color(particleRed, particleGreen, particleBlue, 1.0F).lightmap(j, k).endVertex();
worldRendererIn.pos(f11 - rotationX * f10 + rotationXY * f10, f12 + rotationZ * f10, f13 - rotationYZ * f10 + rotationXZ * f10).tex(maxU, minV).color(particleRed, particleGreen, particleBlue, 1.0F).lightmap(j, k).endVertex();
worldRendererIn.pos(f11 + rotationX * f10 + rotationXY * f10, f12 + rotationZ * f10, f13 + rotationYZ * f10 + rotationXZ * f10).tex(minU, minV).color(particleRed, particleGreen, particleBlue, 1.0F).lightmap(j, k).endVertex();
worldRendererIn.pos(f11 + rotationX * f10 - rotationXY * f10, f12 - rotationZ * f10, f13 + rotationYZ * f10 - rotationXZ * f10).tex(minU, maxV).color(particleRed, particleGreen, particleBlue, 1.0F).lightmap(j, k).endVertex();
buffer.pos(f11 - rotationX * f10 - rotationXY * f10, f12 - rotationZ * f10, f13 - rotationYZ * f10 - rotationXZ * f10).tex(maxU, maxV).color(particleRed, particleGreen, particleBlue, 1.0F).lightmap(j, k).endVertex();
buffer.pos(f11 - rotationX * f10 + rotationXY * f10, f12 + rotationZ * f10, f13 - rotationYZ * f10 + rotationXZ * f10).tex(maxU, minV).color(particleRed, particleGreen, particleBlue, 1.0F).lightmap(j, k).endVertex();
buffer.pos(f11 + rotationX * f10 + rotationXY * f10, f12 + rotationZ * f10, f13 + rotationYZ * f10 + rotationXZ * f10).tex(minU, minV).color(particleRed, particleGreen, particleBlue, 1.0F).lightmap(j, k).endVertex();
buffer.pos(f11 + rotationX * f10 - rotationXY * f10, f12 - rotationZ * f10, f13 + rotationYZ * f10 - rotationXZ * f10).tex(minU, maxV).color(particleRed, particleGreen, particleBlue, 1.0F).lightmap(j, k).endVertex();
}
// avoid calculating lighting for bees, it is too much processing
+16 -15
View File
@@ -10,19 +10,20 @@
******************************************************************************/
package forestry.apiculture.entities;
import forestry.apiculture.PluginApiculture;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.renderer.VertexBuffer;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import forestry.apiculture.PluginApiculture;
public class ParticleBeeTargetEntity extends Particle {
private final Vec3d origin;
private final Entity entity;
public ParticleBeeTargetEntity(World world, Vec3d origin, Entity entity, int color) {
super(world, origin.xCoord, origin.yCoord, origin.zCoord, 0.0D, 0.0D, 0.0D);
super(world, origin.x, origin.y, origin.z, 0.0D, 0.0D, 0.0D);
setParticleTexture(PluginApiculture.getBeeSprite());
this.origin = origin;
@@ -56,9 +57,9 @@ public class ParticleBeeTargetEntity extends Particle {
this.move(this.motionX, this.motionY, this.motionZ);
if (this.particleAge == this.particleMaxAge / 2) {
this.motionX = (origin.xCoord - this.posX) * 0.03;
this.motionY = (origin.yCoord - this.posY) * 0.03;
this.motionZ = (origin.zCoord - this.posZ) * 0.03;
this.motionX = (origin.x - this.posX) * 0.03;
this.motionY = (origin.y - this.posY) * 0.03;
this.motionZ = (origin.z - this.posZ) * 0.03;
}
if (this.particleAge < this.particleMaxAge * 0.5) {
@@ -72,15 +73,15 @@ public class ParticleBeeTargetEntity extends Particle {
} else if (this.particleAge < this.particleMaxAge * 0.75) {
// venture back
this.motionX *= 0.95;
this.motionY = (origin.yCoord - this.posY) * 0.03;
this.motionY = (origin.y - this.posY) * 0.03;
this.motionY = (this.motionY + 0.2 * (-0.5 + rand.nextFloat())) / 2;
this.motionZ *= 0.95;
} else {
// get to origin
this.motionX = (origin.xCoord - this.posX) * 0.03;
this.motionY = (origin.yCoord - this.posY) * 0.03;
this.motionX = (origin.x - this.posX) * 0.03;
this.motionY = (origin.y - this.posY) * 0.03;
this.motionY = (this.motionY + 0.2 * (-0.5 + rand.nextFloat())) / 2;
this.motionZ = (origin.zCoord - this.posZ) * 0.03;
this.motionZ = (origin.z - this.posZ) * 0.03;
}
if (this.particleAge++ >= this.particleMaxAge) {
@@ -89,7 +90,7 @@ public class ParticleBeeTargetEntity extends Particle {
}
@Override
public void renderParticle(VertexBuffer worldRendererIn, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) {
public void renderParticle(BufferBuilder buffer, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) {
float minU = 0;
float maxU = 1;
float minV = 0;
@@ -110,10 +111,10 @@ public class ParticleBeeTargetEntity extends Particle {
int i = this.getBrightnessForRender(partialTicks);
int j = i >> 16 & 65535;
int k = i & 65535;
worldRendererIn.pos(f11 - rotationX * f10 - rotationXY * f10, f12 - rotationZ * f10, f13 - rotationYZ * f10 - rotationXZ * f10).tex(maxU, maxV).color(particleRed, particleGreen, particleBlue, 1.0F).lightmap(j, k).endVertex();
worldRendererIn.pos(f11 - rotationX * f10 + rotationXY * f10, f12 + rotationZ * f10, f13 - rotationYZ * f10 + rotationXZ * f10).tex(maxU, minV).color(particleRed, particleGreen, particleBlue, 1.0F).lightmap(j, k).endVertex();
worldRendererIn.pos(f11 + rotationX * f10 + rotationXY * f10, f12 + rotationZ * f10, f13 + rotationYZ * f10 + rotationXZ * f10).tex(minU, minV).color(particleRed, particleGreen, particleBlue, 1.0F).lightmap(j, k).endVertex();
worldRendererIn.pos(f11 + rotationX * f10 - rotationXY * f10, f12 - rotationZ * f10, f13 + rotationYZ * f10 - rotationXZ * f10).tex(minU, maxV).color(particleRed, particleGreen, particleBlue, 1.0F).lightmap(j, k).endVertex();
buffer.pos(f11 - rotationX * f10 - rotationXY * f10, f12 - rotationZ * f10, f13 - rotationYZ * f10 - rotationXZ * f10).tex(maxU, maxV).color(particleRed, particleGreen, particleBlue, 1.0F).lightmap(j, k).endVertex();
buffer.pos(f11 - rotationX * f10 + rotationXY * f10, f12 + rotationZ * f10, f13 - rotationYZ * f10 + rotationXZ * f10).tex(maxU, minV).color(particleRed, particleGreen, particleBlue, 1.0F).lightmap(j, k).endVertex();
buffer.pos(f11 + rotationX * f10 + rotationXY * f10, f12 + rotationZ * f10, f13 + rotationYZ * f10 + rotationXZ * f10).tex(minU, minV).color(particleRed, particleGreen, particleBlue, 1.0F).lightmap(j, k).endVertex();
buffer.pos(f11 + rotationX * f10 - rotationXY * f10, f12 - rotationZ * f10, f13 + rotationYZ * f10 - rotationXZ * f10).tex(minU, maxV).color(particleRed, particleGreen, particleBlue, 1.0F).lightmap(j, k).endVertex();
}
// avoid calculating lighting for bees, it is too much processing
+3 -1
View File
@@ -10,7 +10,9 @@
******************************************************************************/
package forestry.apiculture.flowers;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import net.minecraft.block.state.IBlockState;
public final class Flower {
@@ -57,7 +59,7 @@ public final class Flower {
@Override
public String toString() {
return Objects.toStringHelper(this).add("blockState", blockState).add("weight", weight).toString();
return MoreObjects.toStringHelper(this).add("blockState", blockState).add("weight", weight).toString();
}
}
@@ -10,13 +10,16 @@
******************************************************************************/
package forestry.apiculture.flowers;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.TreeMap;
import com.google.common.base.Preconditions;
import com.google.common.collect.ArrayListMultimap;
@@ -27,12 +30,15 @@ import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeeModifier;
import forestry.api.core.IBlockPosPredicate;
import forestry.api.genetics.IFlowerAcceptableRule;
import forestry.api.genetics.IFlowerGrowthHelper;
import forestry.api.genetics.IFlowerGrowthRule;
import forestry.api.genetics.IFlowerRegistry;
import forestry.api.genetics.IIndividual;
import forestry.core.utils.BlockStateSet;
import forestry.core.utils.VectUtil;
import forestry.core.utils.WeightedCollection;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
@@ -43,16 +49,16 @@ import net.minecraft.world.World;
public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelper {
private final HashMultimap<String, IFlowerAcceptableRule> registeredRules;
private final HashMultimap<String, Block> acceptableBlocks;
private final HashMultimap<String, IBlockState> acceptableBlockStates;
private final Map<String, BlockStateSet> acceptableBlockStates;
private final HashMultimap<String, Flower> plantableFlowers;
private final ArrayListMultimap<String, IFlowerGrowthRule> growthRules;
private final Map<String, TreeMap<Double, Flower>> chances;
private final Map<String, WeightedCollection<Flower>> chances;
public FlowerRegistry() {
this.registeredRules = HashMultimap.create();
this.acceptableBlocks = HashMultimap.create();
this.acceptableBlockStates = HashMultimap.create();
this.acceptableBlockStates = new HashMap<>();
this.plantableFlowers = HashMultimap.create();
this.growthRules = ArrayListMultimap.create();
this.chances = new HashMap<>();
@@ -78,7 +84,7 @@ public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelpe
throw new NullPointerException("Tried to register flower with null type. " + blockState);
}
this.acceptableBlockStates.get(flowerType).add(blockState);
this.getAcceptedBlockStates(flowerType).add(blockState);
}
}
@@ -113,7 +119,7 @@ public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelpe
Set<Flower> flowers = this.plantableFlowers.get(flowerType);
flowers.add(newFlower);
Set<IBlockState> blocks = this.acceptableBlockStates.get(flowerType);
Set<IBlockState> blocks = this.getAcceptedBlockStates(flowerType);
blocks.add(blockState);
if (this.chances.containsKey(flowerType)) {
@@ -129,43 +135,16 @@ public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelpe
}
@Override
public List<BlockPos> getAcceptedFlowerCoordinates(IBeeHousing beeHousing, IBee bee, String flowerType, int maxFlowers) {
Set<IFlowerAcceptableRule> acceptableRules = this.registeredRules.get(flowerType);
Set<IBlockState> acceptedBlockStates = this.acceptableBlockStates.get(flowerType);
Set<Block> acceptedBlocks = this.acceptableBlocks.get(flowerType);
World world = beeHousing.getWorldObj();
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(beeHousing);
Vec3i area = getArea(bee.getGenome(), beeModifier);
BlockPos minPos = beeHousing.getCoordinates().add(-area.getX() / 2, -area.getY() / 2, -area.getZ() / 2);
BlockPos maxPos = minPos.add(area);
List<BlockPos> flowerCoords = new ArrayList<>();
for (BlockPos.MutableBlockPos posBlock : VectUtil.getAllInBoxFromCenterMutable(world, minPos, beeHousing.getCoordinates(), maxPos)) {
if (!world.isBlockLoaded(posBlock)) {
continue;
}
IBlockState blockState = world.getBlockState(posBlock);
if (blockState.getBlock().isAir(blockState, world, posBlock)) {
continue;
}
for (IFlowerAcceptableRule acceptableRule : acceptableRules) {
if (acceptableRule.isAcceptableFlower(blockState, world, posBlock, flowerType)) {
flowerCoords.add(posBlock.toImmutable());
if (flowerCoords.size() >= maxFlowers) {
return flowerCoords;
}
}
}
if (isAcceptedFlower(blockState, acceptedBlocks, acceptedBlockStates)) {
flowerCoords.add(posBlock.toImmutable());
if (flowerCoords.size() >= maxFlowers) {
return flowerCoords;
}
World world = beeHousing.getWorldObj();
IBlockPosPredicate acceptedFlowerPredicate = createAcceptedFlowerPredicate(flowerType);
Iterator<BlockPos.MutableBlockPos> areaIterator = getAreaIterator(beeHousing, bee);
while (areaIterator.hasNext() && flowerCoords.size() < maxFlowers) {
BlockPos.MutableBlockPos pos = areaIterator.next();
if (acceptedFlowerPredicate.test(world, pos)) {
flowerCoords.add(pos.toImmutable());
}
}
@@ -173,6 +152,17 @@ public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelpe
}
@Override
public Iterator<BlockPos.MutableBlockPos> getAreaIterator(IBeeHousing beeHousing, IBee bee) {
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(beeHousing);
Vec3i area = getArea(bee.getGenome(), beeModifier);
BlockPos minPos = beeHousing.getCoordinates().add(-area.getX() / 2, -area.getY() / 2, -area.getZ() / 2);
BlockPos maxPos = minPos.add(area);
World world = beeHousing.getWorldObj();
return VectUtil.getAllInBoxFromCenterMutable(world, minPos, beeHousing.getCoordinates(), maxPos);
}
@Override
@Deprecated
public boolean isAcceptedFlower(String flowerType, World world, BlockPos pos) {
if (!world.isBlockLoaded(pos)) {
return true; // Avoid actually checking until the flower's position is loaded.
@@ -185,18 +175,32 @@ public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelpe
}
}
Set<IBlockState> acceptedBlockStates = this.acceptableBlockStates.get(flowerType);
Set<IBlockState> acceptedBlockStates = this.getAcceptedBlockStates(flowerType);
Set<Block> acceptedBlocks = this.acceptableBlocks.get(flowerType);
return isAcceptedFlower(blockState, acceptedBlocks, acceptedBlockStates);
}
private Set<IBlockState> getAcceptedBlockStates(String flowerType) {
return this.acceptableBlockStates.computeIfAbsent(flowerType, k -> new BlockStateSet());
}
@Override
public IBlockPosPredicate createAcceptedFlowerPredicate(String flowerType) {
Set<IFlowerAcceptableRule> acceptableRules = this.registeredRules.get(flowerType);
Set<IBlockState> acceptedBlockStates = this.getAcceptedBlockStates(flowerType);
Set<Block> acceptedBlocks = this.acceptableBlocks.get(flowerType);
return new AcceptedFlowerPredicate(flowerType, acceptableRules, acceptedBlocks, acceptedBlockStates);
}
private static boolean isAcceptedFlower(IBlockState blockState, Set<Block> acceptedBlocks, Set<IBlockState> acceptedBlockStates) {
Block block = blockState.getBlock();
return acceptedBlocks.contains(block) || acceptedBlockStates.contains(blockState);
}
@Override
@Deprecated
public boolean growFlower(String flowerType, World world, IIndividual individual, BlockPos pos) {
if (!this.growthRules.containsKey(flowerType)) {
return false;
@@ -211,6 +215,23 @@ public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelpe
return false;
}
@Override
public boolean growFlower(String flowerType, World world, IIndividual individual, BlockPos pos, Collection<IBlockState> potentialFlowers) {
if (!this.growthRules.containsKey(flowerType)) {
return false;
}
List<IFlowerGrowthRule> growthRules = this.growthRules.get(flowerType);
Collections.shuffle(growthRules);
for (IFlowerGrowthRule rule : growthRules) {
if (rule.growFlower(this, flowerType, world, pos, potentialFlowers)) {
return true;
}
}
return false;
}
@Override
public void registerGrowthRule(IFlowerGrowthRule rule, String... flowerTypes) {
Preconditions.checkNotNull(rule);
@@ -220,20 +241,18 @@ public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelpe
}
}
@Nullable
public Flower getRandomPlantableFlower(String flowerType, Random rand) {
TreeMap<Double, Flower> chancesMap = getChancesMap(flowerType);
double maxKey = chancesMap.lastKey() + 1.0;
return chancesMap.get(chancesMap.lowerKey(rand.nextDouble() * maxKey));
WeightedCollection<Flower> chancesMap = getFlowerChances(flowerType);
return chancesMap.getRandom(rand);
}
private TreeMap<Double, Flower> getChancesMap(String flowerType) {
private WeightedCollection<Flower> getFlowerChances(String flowerType) {
if (!this.chances.containsKey(flowerType)) {
TreeMap<Double, Flower> flowerChances = new TreeMap<>();
double count = 0.0;
WeightedCollection<Flower> flowerChances = new WeightedCollection<>();
for (Flower flower : this.plantableFlowers.get(flowerType)) {
if (flower.isPlantable()) {
flowerChances.put(count, flower);
count += flower.getWeight();
flowerChances.put(flower.getWeight(), flower);
}
}
this.chances.put(flowerType, flowerChances);
@@ -253,6 +272,56 @@ public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelpe
@Override
public boolean plantRandomFlower(String flowerType, World world, BlockPos pos) {
Flower flower = getRandomPlantableFlower(flowerType, world.rand);
return world.setBlockState(pos, flower.getBlockState());
return flower != null && world.setBlockState(pos, flower.getBlockState());
}
@Override
public boolean plantRandomFlower(String flowerType, World world, BlockPos pos, Collection<IBlockState> potentialFlowers) {
WeightedCollection<Flower> chances = getFlowerChances(flowerType);
WeightedCollection<IBlockState> potentialChances = new WeightedCollection<>();
for (Map.Entry<Double, Flower> entry : chances.entrySet()) {
Flower flower = entry.getValue();
IBlockState blockState = flower.getBlockState();
if (potentialFlowers.contains(blockState)) {
potentialChances.put(entry.getKey(), blockState);
}
}
final IBlockState blockState = potentialChances.getRandom(world.rand);
return blockState != null && world.setBlockState(pos, blockState);
}
private static class AcceptedFlowerPredicate implements IBlockPosPredicate {
private final String flowerType;
private final Set<IFlowerAcceptableRule> acceptableRules;
private final Set<Block> acceptedBlocks;
private final Set<IBlockState> acceptedBlockStates;
public AcceptedFlowerPredicate(String flowerType, Set<IFlowerAcceptableRule> acceptableRules, Set<Block> acceptedBlocks, Set<IBlockState> acceptedBlockStates) {
this.flowerType = flowerType;
this.acceptableRules = acceptableRules;
this.acceptedBlocks = acceptedBlocks;
this.acceptedBlockStates = acceptedBlockStates;
}
@Override
public boolean test(World world, BlockPos blockPos) {
if (world.isBlockLoaded(blockPos)) {
IBlockState blockState = world.getBlockState(blockPos);
if (!blockState.getBlock().isAir(blockState, world, blockPos)) {
for (IFlowerAcceptableRule acceptableRule : acceptableRules) {
if (acceptableRule.isAcceptableFlower(blockState, world, blockPos, flowerType)) {
return true;
}
}
if (isAcceptedFlower(blockState, acceptedBlocks, acceptedBlockStates)) {
return true;
}
}
}
return false;
}
}
}
@@ -10,9 +10,12 @@
******************************************************************************/
package forestry.apiculture.flowers;
import java.util.Collection;
import forestry.api.genetics.IFlowerGrowthHelper;
import forestry.api.genetics.IFlowerGrowthRule;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@@ -20,14 +23,24 @@ import net.minecraft.world.World;
public class GrowthRuleDirtGrass implements IFlowerGrowthRule {
@Override
@Deprecated
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, BlockPos pos) {
return isValidSpot(world, pos) &&
helper.plantRandomFlower(flowerType, world, pos);
}
@Override
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, BlockPos pos, Collection<IBlockState> potentialFlowers) {
return isValidSpot(world, pos) &&
helper.plantRandomFlower(flowerType, world, pos, potentialFlowers);
}
private boolean isValidSpot(World world, BlockPos pos) {
if (!world.isBlockLoaded(pos) || !world.isAirBlock(pos)) {
return false;
}
Block ground = world.getBlockState(new BlockPos(pos.getX(), pos.getY() - 1, pos.getZ())).getBlock();
return (ground == Blocks.DIRT || ground == Blocks.GRASS) &&
helper.plantRandomFlower(flowerType, world, pos);
return (ground == Blocks.DIRT || ground == Blocks.GRASS);
}
}
@@ -11,6 +11,7 @@
package forestry.apiculture.flowers;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import forestry.api.genetics.IFlowerGrowthHelper;
@@ -33,6 +34,11 @@ public class GrowthRuleFertilize implements IFlowerGrowthRule {
return growFlower(world, pos);
}
@Override
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, BlockPos pos, Collection<IBlockState> potentialFlowers) {
return growFlower(world, pos);
}
private boolean growFlower(World world, BlockPos pos) {
if (!world.isBlockLoaded(pos)) {
return false;
@@ -10,9 +10,12 @@
******************************************************************************/
package forestry.apiculture.flowers;
import java.util.Collection;
import forestry.api.genetics.IFlowerGrowthHelper;
import forestry.api.genetics.IFlowerGrowthRule;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@@ -20,14 +23,25 @@ import net.minecraft.world.World;
public class GrowthRuleMycelium implements IFlowerGrowthRule {
@Override
@Deprecated
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, BlockPos pos) {
return isValidSpot(world, pos) &&
helper.plantRandomFlower(flowerType, world, pos);
}
@Override
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, BlockPos pos, Collection<IBlockState> potentialFlowers) {
return isValidSpot(world, pos) &&
helper.plantRandomFlower(flowerType, world, pos, potentialFlowers);
}
private boolean isValidSpot(World world, BlockPos pos) {
if (!world.isBlockLoaded(pos) || !world.isAirBlock(pos)) {
return false;
}
Block ground = world.getBlockState(new BlockPos(pos.getX(), pos.getY() - 1, pos.getZ())).getBlock();
return ground == Blocks.MYCELIUM &&
helper.plantRandomFlower(flowerType, world, pos);
return ground == Blocks.MYCELIUM;
}
}
@@ -10,8 +10,11 @@
******************************************************************************/
package forestry.apiculture.flowers;
import java.util.Collection;
import forestry.api.genetics.IFlowerGrowthHelper;
import forestry.api.genetics.IFlowerGrowthRule;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@@ -22,4 +25,8 @@ public class GrowthRuleNone implements IFlowerGrowthRule {
return true;
}
@Override
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, BlockPos pos, Collection<IBlockState> potentialFlowers) {
return true;
}
}
@@ -10,9 +10,12 @@
******************************************************************************/
package forestry.apiculture.flowers;
import java.util.Collection;
import forestry.api.genetics.IFlowerGrowthHelper;
import forestry.api.genetics.IFlowerGrowthRule;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@@ -20,14 +23,24 @@ import net.minecraft.world.World;
public class GrowthRuleSnow implements IFlowerGrowthRule {
@Override
@Deprecated
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, BlockPos pos) {
return isValidSpot(world, pos) &&
helper.plantRandomFlower(flowerType, world, pos);
}
@Override
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, BlockPos pos, Collection<IBlockState> potentialFlowers) {
return isValidSpot(world, pos) &&
helper.plantRandomFlower(flowerType, world, pos, potentialFlowers);
}
private boolean isValidSpot(World world, BlockPos pos) {
if (!world.isBlockLoaded(pos) || world.getBlockState(pos).getBlock() != Blocks.SNOW) {
return false;
}
Block ground = world.getBlockState(new BlockPos(pos.getX(), pos.getY() - 1, pos.getZ())).getBlock();
return (ground == Blocks.DIRT || ground == Blocks.GRASS) &&
helper.plantRandomFlower(flowerType, world, pos);
return (ground == Blocks.DIRT || ground == Blocks.GRASS);
}
}
@@ -10,6 +10,9 @@
******************************************************************************/
package forestry.apiculture.genetics;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.IApiaristTracker;
@@ -18,8 +21,6 @@ import forestry.api.genetics.IIndividual;
import forestry.api.genetics.ISpeciesRoot;
import forestry.apiculture.PluginApiculture;
import forestry.core.genetics.BreedingTracker;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
public class ApiaristTracker extends BreedingTracker implements IApiaristTracker {
+31 -16
View File
@@ -19,7 +19,22 @@ import java.util.Map;
import java.util.Random;
import java.util.Set;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3i;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import com.mojang.authlib.GameProfile;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.FlowerManager;
@@ -56,17 +71,6 @@ import forestry.core.tiles.TileUtil;
import forestry.core.utils.GeneticsUtil;
import forestry.core.utils.Translator;
import forestry.core.utils.VectUtil;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3i;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class Bee extends IndividualLiving implements IBee {
@@ -269,7 +273,7 @@ public class Bee extends IndividualLiving implements IBee {
}
// / Check for the sky, except if in hell
if (!world.provider.hasNoSky()) {
if (!world.provider.isNether()) {
if (!housing.canBlockSeeTheSky() && !canWorkUnderground(beeModifier)) {
errorStates.add(EnumErrorCode.NO_SKY);
}
@@ -732,7 +736,11 @@ public class Bee extends IndividualLiving implements IBee {
@Override
public void plantFlowerRandom(IBeeHousing housing) {
plantFlowerRandom(housing, null);
}
@Override
public BlockPos plantFlowerRandom(IBeeHousing housing, @Nullable List<IBlockState> potentialFlowers) {
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
int chance = Math.round(genome.getFlowering() * beeModifier.getFloweringModifier(getGenome(), 1f));
@@ -742,9 +750,8 @@ public class Bee extends IndividualLiving implements IBee {
// Correct speed
if (random.nextInt(100) >= chance) {
return;
return null;
}
// Gather required info
IFlowerProvider provider = genome.getFlowerProvider();
Vec3i area = getArea(genome, beeModifier);
@@ -755,10 +762,18 @@ public class Bee extends IndividualLiving implements IBee {
BlockPos randomPos = VectUtil.getRandomPositionInArea(random, area);
BlockPos posBlock = VectUtil.add(housingPos, randomPos, offset);
if (FlowerManager.flowerRegistry.growFlower(provider.getFlowerType(), world, this, posBlock)) {
break;
if (potentialFlowers != null) {
if (FlowerManager.flowerRegistry.growFlower(provider.getFlowerType(), world, this, posBlock, potentialFlowers)) {
return posBlock;
}
} else { // legacy
//noinspection deprecation
if (FlowerManager.flowerRegistry.growFlower(provider.getFlowerType(), world, this, posBlock)) {
return posBlock;
}
}
}
return null;
}
private static Vec3i getArea(IBeeGenome genome, IBeeModifier beeModifier) {
@@ -1021,11 +1021,10 @@ public enum BeeDefinition implements IBeeDefinition {
for (BeeDefinition bee : values()) {
bee.registerMutations();
}
MinecraftForge.EVENT_BUS.post(new AlleleSpeciesRegisterEvent(BeeManager.beeRoot, IAlleleBeeSpecies.class));
}
public static void preInit() {
MinecraftForge.EVENT_BUS.post(new AlleleSpeciesRegisterEvent<>(BeeManager.beeRoot, IAlleleBeeSpecies.class));
}
private void init() {
@@ -10,12 +10,17 @@
******************************************************************************/
package forestry.apiculture.genetics;
import java.util.concurrent.TimeUnit;
import com.google.common.base.Preconditions;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import java.util.concurrent.TimeUnit;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.Vec3i;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.IAlleleBeeEffect;
@@ -33,9 +38,6 @@ import forestry.core.genetics.Genome;
import forestry.core.genetics.alleles.AlleleArea;
import forestry.core.genetics.alleles.AlleleBoolean;
import forestry.core.genetics.alleles.AlleleTolerance;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.Vec3i;
public class BeeGenome extends Genome implements IBeeGenome {
/**
@@ -16,6 +16,9 @@ import java.util.List;
import java.util.Locale;
import java.util.Random;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.DefaultBeeModifier;
import forestry.api.apiculture.IBee;
@@ -23,8 +26,6 @@ import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeeModifier;
import forestry.api.apiculture.IBeekeepingMode;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BeekeepingMode implements IBeekeepingMode {
@@ -12,13 +12,14 @@ package forestry.apiculture.genetics;
import java.util.Collections;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IHiveDrop;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IHiveDrop;
public class HiveDrop implements IHiveDrop {
private final IBeeDefinition beeTemplate;
@@ -12,11 +12,12 @@ package forestry.apiculture.genetics;
import java.util.List;
import net.minecraft.entity.EntityLiving;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.apiculture.genetics.alleles.AlleleEffect;
import net.minecraft.entity.EntityLiving;
/**
* Hermits will not produce if there are any other living creatures nearby.
+8 -6
View File
@@ -12,16 +12,18 @@ package forestry.apiculture.genetics.alleles;
import java.util.List;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.core.render.ParticleRender;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class AlleleEffectIgnition extends AlleleEffectThrottled {
private static final int ignitionChance = 50;
@@ -72,7 +74,7 @@ public class AlleleEffectIgnition extends AlleleEffectThrottled {
super.doFX(genome, storedData, housing);
} else {
Vec3d beeFXCoordinates = housing.getBeeFXCoordinates();
ParticleRender.addEntityIgnitionFX(world, beeFXCoordinates.xCoord, beeFXCoordinates.yCoord + 0.5, beeFXCoordinates.zCoord);
ParticleRender.addEntityIgnitionFX(world, beeFXCoordinates.x, beeFXCoordinates.y + 0.5, beeFXCoordinates.z);
}
return storedData;
}
+8 -6
View File
@@ -14,11 +14,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.core.render.ParticleRender;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.IMob;
import net.minecraft.potion.Potion;
@@ -26,9 +21,16 @@ import net.minecraft.potion.PotionEffect;
import net.minecraft.potion.PotionUtils;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.core.render.ParticleRender;
public class AlleleEffectPotion extends AlleleEffectThrottled {
private final Potion potion;
@@ -93,7 +95,7 @@ public class AlleleEffectPotion extends AlleleEffectThrottled {
super.doFX(genome, storedData, housing);
} else {
Vec3d beeFXCoordinates = housing.getBeeFXCoordinates();
ParticleRender.addEntityPotionFX(world, beeFXCoordinates.xCoord, beeFXCoordinates.yCoord + 0.5, beeFXCoordinates.zCoord, potionFXColor);
ParticleRender.addEntityPotionFX(world, beeFXCoordinates.x, beeFXCoordinates.y + 0.5, beeFXCoordinates.z, potionFXColor);
}
return storedData;
}
@@ -14,11 +14,6 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.core.utils.EntityUtil;
import forestry.core.utils.ItemStackUtil;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.boss.EntityDragon;
import net.minecraft.entity.item.EntityItem;
@@ -34,6 +29,12 @@ import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.core.utils.EntityUtil;
import forestry.core.utils.ItemStackUtil;
public class AlleleEffectResurrection extends AlleleEffectThrottled {
public static class Resurrectable {
@@ -97,7 +98,7 @@ public class AlleleEffectResurrection extends AlleleEffectThrottled {
if (entity.isDead) {
return false;
}
ItemStack contained = entity.getEntityItem();
ItemStack contained = entity.getItem();
for (Resurrectable entry : resurrectables) {
if (ItemStackUtil.isIdenticalItem(entry.res, contained)) {
EntityUtil.spawnEntity(entity.world, entry.risen, entity.posX, entity.posY, entity.posZ);
@@ -10,11 +10,12 @@
******************************************************************************/
package forestry.apiculture.gui;
import net.minecraft.entity.player.InventoryPlayer;
import forestry.apiculture.multiblock.TileAlveary;
import forestry.core.gui.ContainerTile;
import forestry.core.network.IForestryPacketClient;
import forestry.core.network.packets.PacketGuiUpdate;
import net.minecraft.entity.player.InventoryPlayer;
public class ContainerAlveary extends ContainerTile<TileAlveary> {
@@ -10,11 +10,12 @@
******************************************************************************/
package forestry.apiculture.gui;
import net.minecraft.entity.player.InventoryPlayer;
import forestry.apiculture.inventory.InventoryHygroregulator;
import forestry.apiculture.multiblock.TileAlvearyHygroregulator;
import forestry.core.gui.ContainerLiquidTanks;
import forestry.core.gui.slots.SlotLiquidIn;
import net.minecraft.entity.player.InventoryPlayer;
public class ContainerAlvearyHygroregulator extends ContainerLiquidTanks<TileAlvearyHygroregulator> {
@@ -10,13 +10,14 @@
******************************************************************************/
package forestry.apiculture.gui;
import net.minecraft.entity.player.InventoryPlayer;
import forestry.apiculture.inventory.InventoryAlvearySieve;
import forestry.apiculture.multiblock.TileAlvearySieve;
import forestry.core.gui.ContainerTile;
import forestry.core.gui.slots.SlotFiltered;
import forestry.core.gui.slots.SlotOutput;
import forestry.core.inventory.watchers.ISlotPickupWatcher;
import net.minecraft.entity.player.InventoryPlayer;
public class ContainerAlvearySieve extends ContainerTile<TileAlvearySieve> {
@@ -10,10 +10,11 @@
******************************************************************************/
package forestry.apiculture.gui;
import net.minecraft.entity.player.InventoryPlayer;
import forestry.apiculture.multiblock.TileAlvearySwarmer;
import forestry.core.gui.ContainerTile;
import forestry.core.gui.slots.SlotFiltered;
import net.minecraft.entity.player.InventoryPlayer;
public class ContainerAlvearySwarmer extends ContainerTile<TileAlvearySwarmer> {
@@ -10,11 +10,12 @@
******************************************************************************/
package forestry.apiculture.gui;
import net.minecraft.entity.player.EntityPlayer;
import forestry.apiculture.inventory.ItemInventoryHabitatLocator;
import forestry.core.gui.ContainerItemInventory;
import forestry.core.gui.slots.SlotFiltered;
import forestry.core.gui.slots.SlotOutput;
import net.minecraft.entity.player.EntityPlayer;
public class ContainerHabitatLocator extends ContainerItemInventory<ItemInventoryHabitatLocator> {
@@ -10,6 +10,9 @@
******************************************************************************/
package forestry.apiculture.gui;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import forestry.apiculture.inventory.ItemInventoryImprinter;
import forestry.apiculture.network.packets.PacketImprintSelectionResponse;
import forestry.core.gui.ContainerItemInventory;
@@ -17,8 +20,6 @@ import forestry.core.gui.IGuiSelectable;
import forestry.core.gui.slots.SlotFiltered;
import forestry.core.gui.slots.SlotOutput;
import forestry.core.utils.NetworkUtil;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
public class ContainerImprinter extends ContainerItemInventory<ItemInventoryImprinter> implements IGuiSelectable {
@@ -10,12 +10,13 @@
******************************************************************************/
package forestry.apiculture.gui;
import net.minecraft.entity.player.InventoryPlayer;
import forestry.apiculture.multiblock.IAlvearyControllerInternal;
import forestry.apiculture.multiblock.TileAlveary;
import forestry.core.config.Constants;
import forestry.core.gui.GuiForestryTitled;
import forestry.core.render.EnumTankLevel;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiAlveary extends GuiForestryTitled<ContainerAlveary> {
private final TileAlveary tile;
@@ -10,11 +10,12 @@
******************************************************************************/
package forestry.apiculture.gui;
import net.minecraft.entity.player.InventoryPlayer;
import forestry.apiculture.multiblock.TileAlvearyHygroregulator;
import forestry.core.config.Constants;
import forestry.core.gui.GuiForestryTitled;
import forestry.core.gui.widgets.TankWidget;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiAlvearyHygroregulator extends GuiForestryTitled<ContainerAlvearyHygroregulator> {
private final TileAlvearyHygroregulator tile;
@@ -10,10 +10,11 @@
******************************************************************************/
package forestry.apiculture.gui;
import net.minecraft.entity.player.InventoryPlayer;
import forestry.apiculture.multiblock.TileAlvearySieve;
import forestry.core.config.Constants;
import forestry.core.gui.GuiForestryTitled;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiAlvearySieve extends GuiForestryTitled<ContainerAlvearySieve> {
private final TileAlvearySieve tile;
@@ -10,10 +10,11 @@
******************************************************************************/
package forestry.apiculture.gui;
import net.minecraft.entity.player.InventoryPlayer;
import forestry.apiculture.multiblock.TileAlvearySwarmer;
import forestry.core.config.Constants;
import forestry.core.gui.GuiForestryTitled;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiAlvearySwarmer extends GuiForestryTitled<ContainerAlvearySwarmer> {
private final TileAlvearySwarmer tile;
@@ -10,6 +10,8 @@
******************************************************************************/
package forestry.apiculture.gui;
import com.google.common.collect.LinkedListMultimap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -17,16 +19,17 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import com.google.common.collect.LinkedListMultimap;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.common.BiomeDictionary;
import forestry.apiculture.inventory.ItemInventoryHabitatLocator;
import forestry.core.config.Constants;
import forestry.core.gui.GuiForestry;
import forestry.core.render.ColourProperties;
import forestry.core.utils.Translator;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.common.BiomeDictionary;
public class GuiHabitatLocator extends GuiForestry<ContainerHabitatLocator> {
private static final LinkedListMultimap<String, BiomeDictionary.Type> habitats = LinkedListMultimap.create();
@@ -83,7 +86,7 @@ public class GuiHabitatLocator extends GuiForestry<ContainerHabitatLocator> {
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
String str = Translator.translateToLocal("item.for.habitatLocator.name").toUpperCase();
fontRendererObj.drawString(str, startX + 8 + textLayout.getCenteredOffset(str, 138), startY + 16, ColourProperties.INSTANCE.get("gui.screen"));
fontRenderer.drawString(str, startX + 8 + textLayout.getCenteredOffset(str, 138), startY + 16, ColourProperties.INSTANCE.get("gui.screen"));
// Set active according to valid biomes.
Set<BiomeDictionary.Type> activeBiomeTypes = new HashSet<>();
@@ -14,6 +14,10 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.apiculture.PluginApiculture;
import forestry.apiculture.genetics.BeeGenome;
@@ -25,9 +29,6 @@ import forestry.core.network.packets.PacketGuiSelectRequest;
import forestry.core.render.ColourProperties;
import forestry.core.utils.NetworkUtil;
import forestry.core.utils.Translator;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
public class GuiImprinter extends GuiForestry<ContainerImprinter> {
private final ItemInventoryImprinter itemInventory;
@@ -56,21 +57,21 @@ public class GuiImprinter extends GuiForestry<ContainerImprinter> {
@Override
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
int offset = (138 - fontRendererObj.getStringWidth(Translator.translateToLocal("for.gui.imprinter.name"))) / 2;
fontRendererObj.drawString(Translator.translateToLocal("for.gui.imprinter.name"), startX + 8 + offset, startY + 16, ColourProperties.INSTANCE.get("gui.screen"));
int offset = (138 - fontRenderer.getStringWidth(Translator.translateToLocal("for.gui.imprinter.name"))) / 2;
fontRenderer.drawString(Translator.translateToLocal("for.gui.imprinter.name"), startX + 8 + offset, startY + 16, ColourProperties.INSTANCE.get("gui.screen"));
IAlleleBeeSpecies primary = itemInventory.getPrimary();
drawBeeSpeciesIcon(primary, startX + 12, startY + 32);
fontRendererObj.drawString(primary.getAlleleName(), startX + 32, startY + 36, ColourProperties.INSTANCE.get("gui.screen"));
fontRenderer.drawString(primary.getAlleleName(), startX + 32, startY + 36, ColourProperties.INSTANCE.get("gui.screen"));
IAlleleBeeSpecies secondary = itemInventory.getSecondary();
drawBeeSpeciesIcon(secondary, startX + 12, startY + 52);
fontRendererObj.drawString(secondary.getAlleleName(), startX + 32, startY + 56, ColourProperties.INSTANCE.get("gui.screen"));
fontRenderer.drawString(secondary.getAlleleName(), startX + 32, startY + 56, ColourProperties.INSTANCE.get("gui.screen"));
String youCheater = Translator.translateToLocal("for.gui.imprinter.cheater");
offset = (138 - fontRendererObj.getStringWidth(youCheater)) / 2;
fontRendererObj.drawString(youCheater, startX + 8 + offset, startY + 76, ColourProperties.INSTANCE.get("gui.screen"));
offset = (138 - fontRenderer.getStringWidth(youCheater)) / 2;
fontRenderer.drawString(youCheater, startX + 8 + offset, startY + 76, ColourProperties.INSTANCE.get("gui.screen"));
}
@@ -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()));
}
}
@@ -12,13 +12,6 @@ package forestry.apiculture.items;
import javax.annotation.Nullable;
import forestry.api.apiculture.ApicultureCapabilities;
import forestry.api.arboriculture.ArboricultureCapabilities;
import forestry.api.core.IItemModelRegister;
import forestry.api.core.IModelManager;
import forestry.api.core.Tabs;
import forestry.apiculture.PluginApiculture;
import forestry.core.config.Constants;
import net.minecraft.entity.Entity;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.Item;
@@ -26,11 +19,20 @@ import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.apiculture.ApicultureCapabilities;
import forestry.api.arboriculture.ArboricultureCapabilities;
import forestry.api.core.IItemModelRegister;
import forestry.api.core.IModelManager;
import forestry.api.core.Tabs;
import forestry.apiculture.PluginApiculture;
import forestry.core.config.Constants;
public class ItemArmorApiarist extends ItemArmor implements IItemModelRegister {
public ItemArmorApiarist(EntityEquipmentSlot equipmentSlotIn) {
@@ -13,6 +13,19 @@ package forestry.apiculture.items;
import javax.annotation.Nullable;
import java.util.List;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IAlleleBeeSpecies;
@@ -28,16 +41,6 @@ import forestry.core.config.Config;
import forestry.core.genetics.ItemGE;
import forestry.core.items.IColoredItem;
import forestry.core.utils.Translator;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class ItemBeeGE extends ItemGE implements IColoredItem {
@@ -81,7 +84,7 @@ public class ItemBeeGE extends ItemGE implements IColoredItem {
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack itemstack, EntityPlayer player, List<String> list, boolean flag) {
public void addInformation(ItemStack itemstack, @Nullable World world, List<String> list, ITooltipFlag flag) {
if (itemstack.getTagCompound() == null) {
return;
}
@@ -94,13 +97,15 @@ public class ItemBeeGE extends ItemGE implements IColoredItem {
list.add(TextFormatting.YELLOW + Translator.translateToLocal("for.bees.stock.ignoble"));
}
}
super.addInformation(itemstack, player, list, flag);
super.addInformation(itemstack, world, list, flag);
}
@Override
public void getSubItems(Item item, CreativeTabs tab, NonNullList<ItemStack> subItems) {
addCreativeItems(subItems, true);
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> subItems) {
if (this.isInCreativeTab(tab)) {
addCreativeItems(subItems, true);
}
}
public void addCreativeItems(NonNullList<ItemStack> subItems, boolean hideSecrets) {
@@ -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);
}
+32 -23
View File
@@ -10,8 +10,24 @@
******************************************************************************/
package forestry.apiculture.items;
import javax.annotation.Nullable;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.core.ISpriteRegister;
@@ -25,17 +41,6 @@ import forestry.apiculture.render.TextureHabitatLocator;
import forestry.core.items.ItemWithGui;
import forestry.core.utils.ClimateUtil;
import forestry.core.utils.Translator;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class ItemHabitatLocator extends ItemWithGui implements ISpriteRegister {
private static final String iconName = "forestry:items/biomefinder";
@@ -69,18 +74,22 @@ public class ItemHabitatLocator extends ItemWithGui implements ISpriteRegister {
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack itemstack, EntityPlayer player, List<String> list, boolean flag) {
super.addInformation(itemstack, player, list, flag);
Biome currentBiome = player.world.getBiome(player.getPosition());
float temperatureValue = ClimateUtil.getTemperature(player.world, player.getPosition());
EnumTemperature temperature = EnumTemperature.getFromValue(temperatureValue);
EnumHumidity humidity = EnumHumidity.getFromValue(ClimateUtil.getHumidity(player.world, player.getPosition()));
list.add(Translator.translateToLocal("for.gui.currentBiome") + ": " + currentBiome.getBiomeName());
list.add(Translator.translateToLocal("for.gui.temperature") + ": " + AlleleManager.climateHelper.toDisplay(temperature));
list.add(Translator.translateToLocal("for.gui.humidity") + ": " + AlleleManager.climateHelper.toDisplay(humidity));
public void addInformation(ItemStack itemstack, @Nullable World world, List<String> list, ITooltipFlag flag) {
super.addInformation(itemstack, world, list, flag);
Minecraft minecraft = Minecraft.getMinecraft();
if (world != null && minecraft.player != null) {
EntityPlayerSP player = minecraft.player;
Biome currentBiome = player.world.getBiome(player.getPosition());
float temperatureValue = ClimateUtil.getTemperature(world, player.getPosition());
EnumTemperature temperature = EnumTemperature.getFromValue(temperatureValue);
EnumHumidity humidity = EnumHumidity.getFromValue(ClimateUtil.getHumidity(world, player.getPosition()));
list.add(Translator.translateToLocal("for.gui.currentBiome") + ": " + currentBiome.getBiomeName());
list.add(Translator.translateToLocal("for.gui.temperature") + ": " + AlleleManager.climateHelper.toDisplay(temperature));
list.add(Translator.translateToLocal("for.gui.humidity") + ": " + AlleleManager.climateHelper.toDisplay(humidity));
}
}
@Override
@@ -10,8 +10,16 @@
******************************************************************************/
package forestry.apiculture.items;
import javax.annotation.Nullable;
import java.util.List;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.apiculture.DefaultBeeModifier;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeGenome;
@@ -21,10 +29,6 @@ import forestry.api.apiculture.IHiveFrame;
import forestry.api.core.Tabs;
import forestry.core.items.ItemForestry;
import forestry.core.utils.Translator;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class ItemHiveFrame extends ItemForestry implements IHiveFrame {
@@ -48,6 +52,11 @@ public class ItemHiveFrame extends ItemForestry implements IHiveFrame {
}
}
@Override
public IBeeModifier getBeeModifier(ItemStack frame) {
return beeModifier;
}
@Override
public IBeeModifier getBeeModifier() {
return beeModifier;
@@ -55,9 +64,9 @@ public class ItemHiveFrame extends ItemForestry implements IHiveFrame {
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) {
super.addInformation(stack, playerIn, tooltip, advanced);
beeModifier.addInformation(stack, playerIn, tooltip, advanced);
public void addInformation(ItemStack stack, @Nullable World world, List<String> tooltip, ITooltipFlag advanced) {
super.addInformation(stack, world, tooltip, advanced);
beeModifier.addInformation(stack, world, tooltip, advanced);
if (!stack.isItemDamaged()) {
tooltip.add(Translator.translateToLocalFormatted("item.for.durability", stack.getMaxDamage()));
}
@@ -82,7 +91,7 @@ public class ItemHiveFrame extends ItemForestry implements IHiveFrame {
}
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) {
public void addInformation(ItemStack stack, @Nullable World world, List<String> tooltip, ITooltipFlag advanced) {
tooltip.add(Translator.translateToLocalFormatted("item.for.bee.modifier.production", production));
tooltip.add(Translator.translateToLocalFormatted("item.for.bee.modifier.genetic.decay", geneticDecay));
}
@@ -15,17 +15,19 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.core.IModelManager;
import forestry.api.core.Tabs;
import forestry.core.config.Config;
import forestry.core.items.IColoredItem;
import forestry.core.items.ItemForestry;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class ItemHoneyComb extends ItemForestry implements IColoredItem {
public ItemHoneyComb() {
@@ -59,11 +61,13 @@ public class ItemHoneyComb extends ItemForestry implements IColoredItem {
}
@Override
public void getSubItems(Item item, CreativeTabs tab, NonNullList<ItemStack> subItems) {
for (int i = 0; i < EnumHoneyComb.VALUES.length; i++) {
EnumHoneyComb honeyComb = EnumHoneyComb.get(i);
if (!honeyComb.isSecret() || Config.isDebug) {
subItems.add(new ItemStack(this, 1, i));
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> subItems) {
if (this.isInCreativeTab(tab)) {
for (int i = 0; i < EnumHoneyComb.VALUES.length; i++) {
EnumHoneyComb honeyComb = EnumHoneyComb.get(i);
if (!honeyComb.isSecret() || Config.isDebug) {
subItems.add(new ItemStack(this, 1, i));
}
}
}
}
+12 -8
View File
@@ -10,11 +10,6 @@
******************************************************************************/
package forestry.apiculture.items;
import forestry.api.core.IItemModelRegister;
import forestry.api.core.IModelManager;
import forestry.apiculture.entities.EntityMinecartApiary;
import forestry.apiculture.entities.EntityMinecartBeeHousingBase;
import forestry.apiculture.entities.EntityMinecartBeehouse;
import net.minecraft.block.BlockDispenser;
import net.minecraft.block.BlockRailBase;
import net.minecraft.creativetab.CreativeTabs;
@@ -30,9 +25,16 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
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.api.core.IItemModelRegister;
import forestry.api.core.IModelManager;
import forestry.apiculture.entities.EntityMinecartApiary;
import forestry.apiculture.entities.EntityMinecartBeeHousingBase;
import forestry.apiculture.entities.EntityMinecartBeehouse;
public class ItemMinecartBeehouse extends ItemMinecart implements IItemModelRegister {
private final String[] definition = new String[]{"cart.beehouse", "cart.apiary"};
@@ -94,9 +96,11 @@ public class ItemMinecartBeehouse extends ItemMinecart implements IItemModelRegi
}
@Override
public void getSubItems(Item item, CreativeTabs tab, NonNullList<ItemStack> subItems) {
for (int i = 0; i < definition.length; i++) {
subItems.add(new ItemStack(this, 1, i));
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> subItems) {
if (this.isInCreativeTab(tab)) {
for (int i = 0; i < definition.length; i++) {
subItems.add(new ItemStack(this, 1, i));
}
}
}
+13 -11
View File
@@ -2,12 +2,6 @@ package forestry.apiculture.items;
import javax.annotation.Nullable;
import forestry.api.apiculture.ApicultureCapabilities;
import forestry.api.apiculture.IHiveTile;
import forestry.api.core.Tabs;
import forestry.core.items.ItemForestry;
import forestry.core.render.ParticleRender;
import forestry.core.tiles.TileUtil;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
@@ -21,9 +15,17 @@ import net.minecraft.util.EnumHandSide;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import forestry.api.apiculture.ApicultureCapabilities;
import forestry.api.apiculture.IHiveTile;
import forestry.api.core.Tabs;
import forestry.core.items.ItemForestry;
import forestry.core.render.ParticleRender;
import forestry.core.tiles.TileUtil;
public class ItemSmoker extends ItemForestry {
public ItemSmoker() {
super(Tabs.tabApiculture);
@@ -72,16 +74,16 @@ public class ItemSmoker extends ItemForestry {
} else {
handOffset = look.crossProduct(new Vec3d(0, -1, 0));
}
Vec3d lookDistance = new Vec3d(look.xCoord * distance, look.yCoord * distance, look.zCoord * distance);
Vec3d lookDistance = new Vec3d(look.x * distance, look.y * distance, look.z * distance);
Vec3d scaledOffset = handOffset.scale(1.0 / distance);
Vec3d smokePos = lookDistance.add(entity.getPositionVector()).add(scaledOffset);
if (world.isRemote) {
ParticleRender.addEntitySmokeFX(world, smokePos.xCoord, smokePos.yCoord + 1, smokePos.zCoord);
ParticleRender.addEntitySmokeFX(world, smokePos.x, smokePos.y + 1, smokePos.z);
}
BlockPos blockPos = new BlockPos(smokePos.xCoord, smokePos.yCoord + 1, smokePos.zCoord);
BlockPos blockPos = new BlockPos(smokePos.x, smokePos.y + 1, smokePos.z);
TileUtil.actOnTile(world, blockPos, IHiveTile.class, IHiveTile::calmBees);
}
@@ -10,10 +10,11 @@
******************************************************************************/
package forestry.apiculture.items;
import net.minecraft.item.ItemStack;
import forestry.api.core.Tabs;
import forestry.core.items.ICraftingPlan;
import forestry.core.items.ItemForestry;
import net.minecraft.item.ItemStack;
public class ItemWaxCast extends ItemForestry implements ICraftingPlan {
@@ -27,7 +28,11 @@ public class ItemWaxCast extends ItemForestry implements ICraftingPlan {
@Override
public ItemStack planUsed(ItemStack plan, ItemStack result) {
plan.setItemDamage(plan.getItemDamage() + result.getCount());
return plan;
if (plan.getItemDamage() >= plan.getMaxDamage()) {
return ItemStack.EMPTY;
} else {
return plan;
}
}
}
@@ -14,7 +14,6 @@ import java.io.IOException;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeekeepingLogic;
import forestry.apiculture.BeekeepingLogic;
import forestry.core.network.ForestryPacket;
import forestry.core.network.IForestryPacketClient;
import forestry.core.network.IForestryPacketHandlerClient;
@@ -28,11 +27,11 @@ import net.minecraftforge.fml.relauncher.SideOnly;
public class PacketBeeLogicActive extends ForestryPacket implements IForestryPacketClient {
private final BlockPos tilePos;
private final BeekeepingLogic beekeepingLogic;
private final IBeekeepingLogic beekeepingLogic;
public PacketBeeLogicActive(IBeeHousing tile) {
this.tilePos = tile.getCoordinates();
this.beekeepingLogic = (BeekeepingLogic) tile.getBeekeepingLogic();
this.beekeepingLogic = tile.getBeekeepingLogic();
}
@Override
@@ -55,9 +54,7 @@ public class PacketBeeLogicActive extends ForestryPacket implements IForestryPac
IBeeHousing beeHousing = TileUtil.getTile(player.world, tilePos, IBeeHousing.class);
if (beeHousing != null) {
IBeekeepingLogic beekeepingLogic = beeHousing.getBeekeepingLogic();
if (beekeepingLogic instanceof BeekeepingLogic) {
((BeekeepingLogic) beekeepingLogic).readData(data);
}
beekeepingLogic.readData(data);
}
}
}
@@ -10,7 +10,6 @@
******************************************************************************/
package forestry.apiculture.render;
import forestry.core.render.ForestryResource;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
@@ -18,9 +17,12 @@ import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.core.render.ForestryResource;
@SideOnly(Side.CLIENT)
public class ModelAnalyzer extends ModelBase {
@@ -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;
@@ -10,40 +10,14 @@
******************************************************************************/
package forestry.apiculture.tiles;
import com.google.common.base.Predicate;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;
import com.google.common.base.Predicate;
import com.mojang.authlib.GameProfile;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeeHousingInventory;
import forestry.api.apiculture.IBeeListener;
import forestry.api.apiculture.IBeeModifier;
import forestry.api.apiculture.IBeekeepingLogic;
import forestry.api.apiculture.IHiveTile;
import forestry.api.apiculture.hives.IHiveRegistry;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.core.ForestryAPI;
import forestry.api.core.IErrorLogic;
import forestry.api.genetics.IAllele;
import forestry.apiculture.BeekeepingLogic;
import forestry.apiculture.blocks.BlockBeeHives;
import forestry.apiculture.genetics.BeeDefinition;
import forestry.apiculture.genetics.alleles.AlleleEffect;
import forestry.apiculture.network.packets.PacketActiveUpdate;
import forestry.core.config.Config;
import forestry.core.inventory.InventoryAdapter;
import forestry.core.tiles.IActivatable;
import forestry.core.utils.ClimateUtil;
import forestry.core.utils.DamageSourceForestry;
import forestry.core.utils.InventoryUtil;
import forestry.core.utils.ItemStackUtil;
import forestry.core.utils.NetworkUtil;
import forestry.apiculture.WorldgenBeekeepingLogic;
import forestry.core.utils.TickHelper;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
@@ -62,20 +36,53 @@ import net.minecraft.util.ITickable;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.EnumDifficulty;
import net.minecraft.world.EnumSkyBlock;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import com.mojang.authlib.GameProfile;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeeHousingInventory;
import forestry.api.apiculture.IBeeListener;
import forestry.api.apiculture.IBeeModifier;
import forestry.api.apiculture.IBeekeepingLogic;
import forestry.api.apiculture.IHiveTile;
import forestry.api.apiculture.hives.IHiveRegistry;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.core.ForestryAPI;
import forestry.api.core.IErrorLogic;
import forestry.api.genetics.IAllele;
import forestry.apiculture.blocks.BlockBeeHives;
import forestry.apiculture.genetics.BeeDefinition;
import forestry.apiculture.genetics.alleles.AlleleEffect;
import forestry.apiculture.network.packets.PacketActiveUpdate;
import forestry.core.config.Config;
import forestry.core.inventory.InventoryAdapter;
import forestry.core.tiles.IActivatable;
import forestry.core.utils.ClimateUtil;
import forestry.core.utils.DamageSourceForestry;
import forestry.core.utils.InventoryUtil;
import forestry.core.utils.ItemStackUtil;
import forestry.core.utils.NetworkUtil;
public class TileHive extends TileEntity implements ITickable, IHiveTile, IActivatable, IBeeHousing {
private static final DamageSource damageSourceBeeHive = new DamageSourceForestry("bee.hive");
private final InventoryAdapter contained = new InventoryAdapter(2, "Contained");
private final HiveBeeHousingInventory inventory;
private final BeekeepingLogic beeLogic;
private final WorldgenBeekeepingLogic beeLogic;
private final IErrorLogic errorLogic;
private final Predicate<EntityLivingBase> beeTargetPredicate;
private final TickHelper tickHelper = new TickHelper();
@Nullable
private IBee containedBee = null;
@@ -91,7 +98,7 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
public TileHive() {
inventory = new HiveBeeHousingInventory(this);
beeLogic = new BeekeepingLogic(this);
beeLogic = new WorldgenBeekeepingLogic(this);
errorLogic = ForestryAPI.errorStateRegistry.createErrorLogic();
beeTargetPredicate = new BeeTargetPredicate(this);
}
@@ -101,12 +108,13 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
if (Config.generateBeehivesDebug) {
return;
}
tickHelper.onTick();
if (world.isRemote) {
if (!updatedLight && world.getWorldTime() % 100 == 0) {
if (!updatedLight && tickHelper.updateOnInterval(100)) {
updatedLight = world.checkLightFor(EnumSkyBlock.BLOCK, getPos());
}
if (active && world.rand.nextInt(4) == 0) {
if (active && tickHelper.updateOnInterval(4)) {
if (beeLogic.canDoBeeFX()) {
beeLogic.doBeeFX();
}
@@ -114,15 +122,17 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
} else {
boolean canWork = beeLogic.canWork(); // must be called every tick to stay updated
if (world.rand.nextInt(angry ? 10 : 200) == 0) {
if (tickHelper.updateOnInterval(angry ? 10 : 200)) {
if (calmTime == 0) {
if (canWork) {
AxisAlignedBB boundingBox = AlleleEffect.getBounding(getContainedBee().getGenome(), this);
List<EntityLivingBase> entities = world.getEntitiesWithinAABB(EntityLivingBase.class, boundingBox, beeTargetPredicate);
if (!entities.isEmpty()) {
Collections.shuffle(entities);
EntityLivingBase entity = entities.get(0);
attack(entity, 2);
if(world.getWorldInfo().getDifficulty() != EnumDifficulty.PEACEFUL) {
AxisAlignedBB boundingBox = AlleleEffect.getBounding(getContainedBee().getGenome(), this);
List<EntityLivingBase> entities = world.getEntitiesWithinAABB(EntityLivingBase.class, boundingBox, beeTargetPredicate);
if (!entities.isEmpty()) {
Collections.shuffle(entities);
EntityLivingBase entity = entities.get(0);
attack(entity, 2);
}
}
beeLogic.doWork();
}
@@ -14,21 +14,23 @@ import java.util.Collections;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.IChunkGenerator;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType;
import net.minecraftforge.event.terraingen.TerrainGen;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.apiculture.PluginApiculture;
import forestry.core.config.Config;
import forestry.core.config.Constants;
import forestry.core.utils.Log;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.chunk.IChunkGenerator;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType;
import net.minecraftforge.event.terraingen.TerrainGen;
public abstract class HiveDecorator {
+28 -23
View File
@@ -15,6 +15,28 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDoor;
import net.minecraft.block.BlockHorizontal;
import net.minecraft.block.BlockLog;
import net.minecraft.block.BlockSlab;
import net.minecraft.block.BlockStairs;
import net.minecraft.block.BlockTorch;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.structure.StructureBoundingBox;
import net.minecraft.world.gen.structure.StructureComponent;
import net.minecraft.world.gen.structure.StructureVillagePieces;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import net.minecraftforge.fml.common.registry.VillagerRegistry;
import net.minecraftforge.registries.ForgeRegistry;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.FlowerManager;
@@ -41,25 +63,6 @@ import forestry.core.blocks.BlockBase;
import forestry.core.config.Constants;
import forestry.core.tiles.TileUtil;
import forestry.plugins.ForestryPluginUids;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDoor;
import net.minecraft.block.BlockHorizontal;
import net.minecraft.block.BlockLog;
import net.minecraft.block.BlockSlab;
import net.minecraft.block.BlockStairs;
import net.minecraft.block.BlockTorch;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.structure.StructureBoundingBox;
import net.minecraft.world.gen.structure.StructureComponent;
import net.minecraft.world.gen.structure.StructureVillagePieces;
import net.minecraftforge.fml.common.registry.FMLControlledNamespacedRegistry;
import net.minecraftforge.fml.common.registry.VillagerRegistry;
public class VillageApiaristHouse extends StructureVillagePieces.House1 {
@@ -283,7 +286,9 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
FlowerRegistry flowerRegistry = (FlowerRegistry) FlowerManager.flowerRegistry;
Flower flower = flowerRegistry.getRandomPlantableFlower(FlowerManager.FlowerTypeVanilla, world.rand);
setBlockState(world, flower.getBlockState(), j, i, k, box);
if (flower != null) {
setBlockState(world, flower.getBlockState(), j, i, k, box);
}
}
}
}
@@ -372,12 +377,12 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
@Override
protected int chooseProfession(int villagerCount, int currentVillagerProfession) {
FMLControlledNamespacedRegistry<VillagerRegistry.VillagerProfession> registry = (FMLControlledNamespacedRegistry<VillagerRegistry.VillagerProfession>) VillagerRegistry.instance().getRegistry();
ForgeRegistry<VillagerRegistry.VillagerProfession> registry = (ForgeRegistry<VillagerRegistry.VillagerProfession>) ForgeRegistries.VILLAGER_PROFESSIONS;
if (villagerCount <= 0) {
return registry.getId(PluginApiculture.villagerApiarist);
return registry.getID(PluginApiculture.villagerApiarist);
} else if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.ARBORICULTURE)) {
return registry.getId(PluginArboriculture.villagerArborist);
return registry.getID(PluginArboriculture.villagerArborist);
} else {
return currentVillagerProfession;
}
+12 -8
View File
@@ -11,11 +11,9 @@
package forestry.arboriculture;
import com.google.common.base.Preconditions;
import forestry.api.core.CamouflageManager;
import forestry.api.core.ICamouflageHandler;
import forestry.api.core.ICamouflageItemHandler;
import forestry.api.core.ICamouflagedTile;
import forestry.arboriculture.items.ItemBlockWoodDoor;
import org.apache.commons.lang3.tuple.Pair;
import net.minecraft.block.BlockDoor;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
@@ -24,9 +22,15 @@ import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.commons.lang3.tuple.Pair;
import forestry.api.core.CamouflageManager;
import forestry.api.core.ICamouflageHandler;
import forestry.api.core.ICamouflageItemHandler;
import forestry.api.core.ICamouflagedTile;
import forestry.arboriculture.items.ItemBlockWoodDoor;
public class CamouflageHandlerArbDoor implements ICamouflageItemHandler {
@@ -57,8 +61,8 @@ public class CamouflageHandlerArbDoor implements ICamouflageItemHandler {
IBlockState currentState = blockState.getActualState(world, pos);
ItemBlockWoodDoor itemDoor = (ItemBlockWoodDoor) stack.getItem();
IBlockState doorState = itemDoor.block.getDefaultState()
IBlockState doorState = itemDoor.getBlock().getDefaultState()
.withProperty(BlockDoor.FACING, currentState.getValue(BlockDoor.FACING))
.withProperty(BlockDoor.HINGE, currentState.getValue(BlockDoor.HINGE))
.withProperty(BlockDoor.OPEN, currentState.getValue(BlockDoor.OPEN))
@@ -16,11 +16,6 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import forestry.api.arboriculture.IFruitProvider;
import forestry.api.arboriculture.ITreeGenome;
import forestry.api.genetics.IFruitFamily;
import forestry.core.config.Constants;
import forestry.core.utils.Translator;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.item.ItemStack;
@@ -29,9 +24,16 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.arboriculture.IFruitProvider;
import forestry.api.arboriculture.ITreeGenome;
import forestry.api.genetics.IFruitFamily;
import forestry.core.config.Constants;
import forestry.core.utils.Translator;
public class FruitProviderNone implements IFruitProvider {
private static class OverlayType {
@@ -17,21 +17,23 @@ import java.util.Locale;
import java.util.Map;
import java.util.Random;
import forestry.api.arboriculture.EnumTreeChromosome;
import forestry.api.arboriculture.IAlleleFruit;
import forestry.api.arboriculture.ITreeGenome;
import forestry.api.arboriculture.TreeManager;
import forestry.api.genetics.IFruitFamily;
import forestry.core.utils.BlockUtil;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.arboriculture.EnumTreeChromosome;
import forestry.api.arboriculture.IAlleleFruit;
import forestry.api.arboriculture.ITreeGenome;
import forestry.api.arboriculture.TreeManager;
import forestry.api.genetics.IFruitFamily;
import forestry.core.utils.BlockUtil;
public class FruitProviderPod extends FruitProviderNone {
public enum EnumPodType {
@@ -15,15 +15,16 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import forestry.api.arboriculture.ITreeGenome;
import forestry.api.arboriculture.TreeManager;
import forestry.api.genetics.IFruitFamily;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import forestry.api.arboriculture.ITreeGenome;
import forestry.api.arboriculture.TreeManager;
import forestry.api.genetics.IFruitFamily;
/**
* Simple fruit provider which drops from any leaf block according to yield and either marks all leave blocks as fruit leaves or none.
*/
@@ -15,15 +15,16 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import forestry.api.arboriculture.ITreeGenome;
import forestry.api.arboriculture.TreeManager;
import forestry.api.genetics.IFruitFamily;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import forestry.api.arboriculture.ITreeGenome;
import forestry.api.arboriculture.TreeManager;
import forestry.api.genetics.IFruitFamily;
public class FruitProviderRipening extends FruitProviderNone {
private final Map<ItemStack, Float> products = new HashMap<>();
private int colourCallow = 0xffffff;
+54 -101
View File
@@ -10,16 +10,48 @@
******************************************************************************/
package forestry.arboriculture;
import com.google.common.base.Preconditions;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import java.util.Map.Entry;
import java.util.Random;
import java.util.Set;
import com.google.common.base.Preconditions;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLeaves;
import net.minecraft.block.BlockNewLeaf;
import net.minecraft.block.BlockOldLeaf;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.capabilities.CapabilityManager;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInterModComms.IMCMessage;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
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 forestry.api.arboriculture.EnumForestryWoodType;
import forestry.api.arboriculture.EnumGermlingType;
import forestry.api.arboriculture.EnumVanillaWoodType;
@@ -39,7 +71,6 @@ import forestry.api.recipes.RecipeManagers;
import forestry.api.storage.ICrateRegistry;
import forestry.api.storage.StorageManager;
import forestry.arboriculture.blocks.BlockArbLog;
import forestry.arboriculture.blocks.BlockArbSlab;
import forestry.arboriculture.blocks.BlockDefaultLeaves;
import forestry.arboriculture.blocks.BlockForestryLeaves;
import forestry.arboriculture.blocks.BlockRegistryArboriculture;
@@ -54,7 +85,6 @@ import forestry.arboriculture.genetics.TreeRoot;
import forestry.arboriculture.genetics.TreekeepingMode;
import forestry.arboriculture.genetics.alleles.AlleleFruits;
import forestry.arboriculture.genetics.alleles.AlleleLeafEffects;
import forestry.arboriculture.items.ItemGermlingGE;
import forestry.arboriculture.items.ItemGrafter;
import forestry.arboriculture.items.ItemRegistryArboriculture;
import forestry.arboriculture.models.TextureLeaves;
@@ -83,36 +113,6 @@ import forestry.core.utils.VillagerTradeLists;
import forestry.plugins.BlankForestryPlugin;
import forestry.plugins.ForestryPlugin;
import forestry.plugins.ForestryPluginUids;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLeaves;
import net.minecraft.block.BlockNewLeaf;
import net.minecraft.block.BlockOldLeaf;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.capabilities.CapabilityManager;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.fml.common.IFuelHandler;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInterModComms.IMCMessage;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
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.oredict.OreDictionary;
@ForestryPlugin(pluginID = ForestryPluginUids.ARBORICULTURE, name = "Arboriculture", author = "Binnie & SirSengir", url = Constants.URL, unlocalizedDescription = "for.plugin.arboriculture.description")
public class PluginArboriculture extends BlankForestryPlugin {
@@ -254,7 +254,7 @@ public class PluginArboriculture extends BlankForestryPlugin {
if (Config.enableVillagers) {
villagerArborist = new VillagerRegistry.VillagerProfession(Constants.ID_VILLAGER_ARBORIST, Constants.TEXTURE_SKIN_LUMBERJACK, Constants.TEXTURE_SKIN_ZOMBIE_LUMBERJACK);
VillagerRegistry.instance().register(villagerArborist);
ForgeRegistries.VILLAGER_PROFESSIONS.register(villagerArborist);
VillagerRegistry.VillagerCareer arboristCareer = new VillagerRegistry.VillagerCareer(villagerArborist, "arborist");
arboristCareer.addTrade(1,
@@ -324,29 +324,29 @@ public class PluginArboriculture extends BlankForestryPlugin {
if (woodType instanceof EnumForestryWoodType) {
planks.setCount(4);
logs.setCount(1);
RecipeUtil.addShapelessRecipe(planks.copy(), logs.copy());
RecipeUtil.addShapelessRecipe("planks_" + woodType.getName(), planks.copy(), logs.copy());
slabs.setCount(6);
planks.setCount(1);
RecipeUtil.addPriorityRecipe(slabs.copy(), "###", '#', planks.copy());
RecipeUtil.addRecipe("slabs_" + woodType.getName(), slabs.copy(), "###", '#', planks.copy());
fences.setCount(3);
planks.setCount(1);
RecipeUtil.addRecipe(fences.copy(),
RecipeUtil.addRecipe("fences_" + woodType.getName(), fences.copy(),
"#X#",
"#X#",
'#', planks.copy(), 'X', "stickWood");
fenceGates.setCount(1);
planks.setCount(1);
RecipeUtil.addRecipe(fenceGates.copy(),
RecipeUtil.addRecipe("fence_gates_" + woodType.getName(), fenceGates.copy(),
"X#X",
"X#X",
'#', planks.copy(), 'X', "stickWood");
stairs.setCount(4);
planks.setCount(1);
RecipeUtil.addPriorityRecipe(stairs.copy(),
RecipeUtil.addRecipe("stairs_" + woodType.getName(), stairs.copy(),
"# ",
"## ",
"###",
@@ -354,7 +354,7 @@ public class PluginArboriculture extends BlankForestryPlugin {
doors.setCount(3);
planks.setCount(1);
RecipeUtil.addPriorityRecipe(doors.copy(),
RecipeUtil.addRecipe("doors_" + woodType.getName(), doors.copy(),
"## ",
"## ",
"## ",
@@ -363,31 +363,31 @@ public class PluginArboriculture extends BlankForestryPlugin {
fireproofPlanks.setCount(4);
fireproofLogs.setCount(1);
RecipeUtil.addShapelessRecipe(fireproofPlanks.copy(), fireproofLogs.copy());
RecipeUtil.addShapelessRecipe("fireproof_planks_" + woodType.getName(), fireproofPlanks.copy(), fireproofLogs.copy());
fireproofSlabs.setCount(6);
fireproofPlanks.setCount(1);
RecipeUtil.addPriorityRecipe(fireproofSlabs.copy(),
RecipeUtil.addRecipe("fireproof_slabs_" + woodType.getName(), fireproofSlabs.copy(),
"###",
'#', fireproofPlanks.copy());
fireproofFences.setCount(3);
fireproofPlanks.setCount(1);
RecipeUtil.addRecipe(fireproofFences.copy(),
RecipeUtil.addRecipe("fireproof_fences_" + woodType.getName(), fireproofFences.copy(),
"#X#",
"#X#",
'#', fireproofPlanks.copy(), 'X', "stickWood");
fireproofFenceGates.setCount(1);
fireproofPlanks.setCount(1);
RecipeUtil.addRecipe(fireproofFenceGates.copy(),
RecipeUtil.addRecipe("fireproof_fence_gates_" + woodType.getName(), fireproofFenceGates.copy(),
"X#X",
"X#X",
'#', fireproofPlanks.copy(), 'X', "stickWood");
fireproofStairs.setCount(4);
fireproofPlanks.setCount(1);
RecipeUtil.addPriorityRecipe(fireproofStairs.copy(),
RecipeUtil.addRecipe("fireproof_stairs_" + woodType.getName(), fireproofStairs.copy(),
"# ",
"## ",
"###",
@@ -395,7 +395,7 @@ public class PluginArboriculture extends BlankForestryPlugin {
doors.setCount(3);
fireproofPlanks.setCount(1);
RecipeUtil.addPriorityRecipe(doors.copy(),
RecipeUtil.addRecipe("fireproof_doors_" + woodType.getName(), doors.copy(),
"## ",
"## ",
"## ",
@@ -437,23 +437,19 @@ public class PluginArboriculture extends BlankForestryPlugin {
RecipeManagers.squeezerManager.addRecipe(10, EnumFruit.PLUM.getStack(), Fluids.JUICE.getFluid((int) Math.floor(juiceMultiplier * 0.5f)), mulch, mulchMultiplier * 3);
RecipeManagers.squeezerManager.addRecipe(10, EnumFruit.PAPAYA.getStack(), Fluids.JUICE.getFluid(juiceMultiplier * 3), mulch, (int) Math.floor(mulchMultiplier * 0.5f));
RecipeManagers.squeezerManager.addRecipe(10, EnumFruit.DATES.getStack(), Fluids.JUICE.getFluid((int) Math.floor(juiceMultiplier * 0.25)), mulch, mulchMultiplier);
NonNullList<ItemStack> saplings = NonNullList.create();
items.sapling.addCreativeItems(saplings, false);
for (ItemStack sapling : saplings) {
RecipeUtil.addFermenterRecipes(sapling, ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.sapling"), Fluids.BIOMASS);
}
RecipeUtil.addFermenterRecipes(new ItemStack(items.sapling, 1, OreDictionary.WILDCARD_VALUE), ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.sapling"), Fluids.BIOMASS);
}
// Grafter
RecipeUtil.addRecipe(items.grafter.getItemStack(),
RecipeUtil.addRecipe("grafter", items.grafter.getItemStack(),
" B",
" # ",
"# ",
'B', "ingotBronze",
'#', "stickWood");
RecipeUtil.addRecipe(blocks.treeChest,
RecipeUtil.addRecipe("tree_chest", blocks.treeChest,
" # ",
"XYX",
"XXX",
@@ -462,10 +458,10 @@ public class PluginArboriculture extends BlankForestryPlugin {
'Y', "chestWood");
//Wood Pile
RecipeUtil.addShapelessRecipe(new ItemStack(blocks.woodPile), OreDictUtil.LOG_WOOD, OreDictUtil.LOG_WOOD, OreDictUtil.LOG_WOOD, OreDictUtil.LOG_WOOD);
RecipeUtil.addShapelessRecipe("wood_pile", new ItemStack(blocks.woodPile), OreDictUtil.LOG_WOOD, OreDictUtil.LOG_WOOD, OreDictUtil.LOG_WOOD, OreDictUtil.LOG_WOOD);
//Dirt Pile Block
RecipeUtil.addShapelessRecipe(new ItemStack(blocks.loam, 4), Items.CLAY_BALL, coreItems.fertilizerBio, Items.CLAY_BALL, OreDictUtil.SAND, Items.CLAY_BALL, OreDictUtil.SAND, Items.CLAY_BALL, coreItems.fertilizerBio, Items.CLAY_BALL);
RecipeUtil.addShapelessRecipe("loam", new ItemStack(blocks.loam, 4), Items.CLAY_BALL, coreItems.compost, Items.CLAY_BALL, OreDictUtil.SAND, Items.CLAY_BALL, OreDictUtil.SAND, Items.CLAY_BALL, coreItems.compost, Items.CLAY_BALL);
}
private static void registerAlleles() {
@@ -545,11 +541,6 @@ public class PluginArboriculture extends BlankForestryPlugin {
}
}
@Override
public IFuelHandler getFuelHandler() {
return new FuelHandler(getItems().sapling);
}
@Override
public IPacketRegistry getPacketRegistry() {
return new PacketRegistryArboriculture();
@@ -576,49 +567,11 @@ public class PluginArboriculture extends BlankForestryPlugin {
hiddenItems.add(new ItemStack(getBlocks().saplingGE));
}
private static class FuelHandler implements IFuelHandler {
private final ItemGermlingGE sapling;
public FuelHandler(ItemGermlingGE sapling) {
this.sapling = sapling;
}
@Override
public int getBurnTime(ItemStack fuel) {
Item item = fuel.getItem();
if (sapling == item) {
return 100;
}
if(Item.getItemFromBlock(blocks.charcoal) == item){
return 16000;
}
if(Item.getItemFromBlock(blocks.woodPile) == item){
return 1200;
}
Block block = Block.getBlockFromItem(item);
if (block instanceof IWoodTyped) {
IWoodTyped woodTypedBlock = (IWoodTyped) block;
if (woodTypedBlock.isFireproof()) {
return 0;
} else if (block instanceof BlockArbSlab) {
return 150;
} else {
return 300;
}
}
return 0;
}
}
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void registerSprites(TextureStitchEvent.Pre event) {
TextureLeaves.registerAllSprites();
WoodTextureManager.parseFile(Minecraft.getMinecraft().getResourceManager());
WoodTextureManager.parseFile();
for (IAlleleFruit alleleFruit : AlleleFruits.getFruitAlleles()) {
alleleFruit.getProvider().registerSprites();
}
@@ -3,21 +3,22 @@ package forestry.arboriculture;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.arboriculture.EnumForestryWoodType;
import forestry.api.arboriculture.EnumVanillaWoodType;
import forestry.api.arboriculture.IWoodItemMeshDefinition;
import forestry.api.arboriculture.IWoodType;
import forestry.api.arboriculture.TreeManager;
import forestry.api.arboriculture.WoodBlockKind;
import forestry.arboriculture.models.WoodModelLoader;
import forestry.core.config.Constants;
import forestry.core.models.ModelManager;
import forestry.core.utils.Translator;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class WoodHelper {
@@ -77,16 +78,18 @@ public class WoodHelper {
@Override
public ModelResourceLocation getModelLocation(ItemStack stack) {
if (!WoodModelLoader.INSTANCE.isEnabled) {
return new ModelResourceLocation(getDefaultModelLocation(stack), "inventory");
}
int meta = stack.getMetadata();
IWoodType woodType = wood.getWoodType(meta);
WoodBlockKind blockKind = wood.getBlockKind();
if (woodType instanceof EnumVanillaWoodType) {
return new ModelResourceLocation("minecraft:" + woodType + "_" + blockKind, "inventory");
} else {
return ModelManager.getInstance().getModelLocation(blockKind + "/" + woodType);
String modID = Constants.MOD_ID;
Block block = Block.getBlockFromItem(stack.getItem());
if(block != null){
modID = block.getRegistryName().getResourceDomain();
}
return new ModelResourceLocation(modID + ":" + blockKind + "/" + woodType, "inventory");
}
}
+28 -28
View File
@@ -5,18 +5,6 @@ import java.util.Collections;
import java.util.List;
import java.util.Random;
import com.mojang.authlib.GameProfile;
import forestry.api.arboriculture.IToolGrafter;
import forestry.api.arboriculture.ITree;
import forestry.api.core.IItemModelRegister;
import forestry.api.core.Tabs;
import forestry.arboriculture.LeafDecayHelper;
import forestry.arboriculture.genetics.TreeDefinition;
import forestry.arboriculture.tiles.TileLeaves;
import forestry.core.blocks.IColoredBlock;
import forestry.core.proxy.Proxies;
import forestry.core.tiles.TileUtil;
import forestry.core.utils.BlockUtil;
import net.minecraft.block.BlockLeaves;
import net.minecraft.block.BlockPlanks;
import net.minecraft.block.state.IBlockState;
@@ -36,9 +24,21 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import com.mojang.authlib.GameProfile;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.arboriculture.IToolGrafter;
import forestry.api.arboriculture.ITree;
import forestry.api.core.IItemModelRegister;
import forestry.arboriculture.LeafDecayHelper;
import forestry.arboriculture.genetics.TreeDefinition;
import forestry.core.blocks.IColoredBlock;
import forestry.core.proxy.Proxies;
import forestry.core.utils.BlockUtil;
/**
* Parent class for shared behavior between {@link BlockDefaultLeaves} and {@link BlockForestryLeaves}
*/
@@ -56,7 +56,7 @@ public abstract class BlockAbstractLeaves extends BlockLeaves implements IItemMo
public abstract IBlockState getStateFromMeta(int meta);
@Override
public final void getSubBlocks(Item itemIn, CreativeTabs tab, NonNullList<ItemStack> list) {
public final void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
// creative menu shows BlockDecorativeLeaves instead of these
}
@@ -158,7 +158,7 @@ public abstract class BlockAbstractLeaves extends BlockLeaves implements IItemMo
// Hack: When harvesting leaves we need to get the drops in onBlockHarvested,
// because there is no Player parameter in getDrops()
// and Mojang destroys the block and tile before calling getDrops.
private final ThreadLocal<List<ItemStack>> drops = new ThreadLocal<>();
private final ThreadLocal<NonNullList<ItemStack>> drops = new ThreadLocal<>();
/**
* {@link IToolGrafter}'s drop bonus handling is done here.
@@ -180,22 +180,22 @@ public abstract class BlockAbstractLeaves extends BlockLeaves implements IItemMo
}
GameProfile playerProfile = player.getGameProfile();
List<ItemStack> leafDrops = getLeafDrop(world, playerProfile, pos, saplingModifier, fortune);
drops.set(leafDrops);
NonNullList<ItemStack> drops = NonNullList.create();
getLeafDrop(drops, world, playerProfile, pos, saplingModifier, fortune);
this.drops.set(drops);
}
@Override
public final List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
List<ItemStack> ret = drops.get();
drops.remove();
// leaves not harvested, get drops normally
if (ret == null) {
ret = getLeafDrop((World) world, null, pos, 1.0f, fortune);
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
List<ItemStack> ret = this.drops.get();
this.drops.remove();
if (ret != null) {
drops.addAll(ret);
} else {
// leaves not harvested, get drops normally
getLeafDrop(drops, (World) world, null, pos, 1.0f, fortune);
}
return ret;
}
protected abstract NonNullList<ItemStack> getLeafDrop(World world, @Nullable GameProfile playerProfile, BlockPos pos, float saplingModifier, int fortune);
protected abstract void getLeafDrop(NonNullList<ItemStack> drops, World world, @Nullable GameProfile playerProfile, BlockPos pos, float saplingModifier, int fortune);
}
@@ -1,12 +1,5 @@
package forestry.arboriculture.blocks;
import java.util.Collections;
import java.util.List;
import forestry.api.core.IItemModelRegister;
import forestry.api.core.IModelManager;
import forestry.api.core.IStateMapperRegister;
import forestry.api.core.Tabs;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.MapColor;
@@ -18,12 +11,20 @@ import net.minecraft.client.renderer.block.statemap.StateMap;
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.IBlockAccess;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.core.IItemModelRegister;
import forestry.api.core.IModelManager;
import forestry.api.core.IStateMapperRegister;
import forestry.api.core.Tabs;
public class BlockCharcoal extends Block implements IStateMapperRegister, IItemModelRegister {
public static final PropertyInteger AMOUNT = PropertyInteger.create("amount", 0, 15);
@@ -60,11 +61,11 @@ public class BlockCharcoal extends Block implements IStateMapperRegister, IItemM
}
@Override
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
if(state.getValue(AMOUNT) > 0){
return Collections.singletonList(new ItemStack(Items.COAL, state.getValue(AMOUNT) + 9, 1));
drops.add(new ItemStack(Items.COAL, state.getValue(AMOUNT) + 9, 1));
}
return super.getDrops(world, pos, state, fortune);
super.getDrops(drops, world, pos, state, fortune);
}
@SideOnly(Side.CLIENT)
+15 -12
View File
@@ -5,14 +5,6 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import forestry.api.arboriculture.IFruitProvider;
import forestry.api.arboriculture.ITreeGenome;
import forestry.api.core.IItemModelRegister;
import forestry.api.core.IModelManager;
import forestry.api.core.Tabs;
import forestry.arboriculture.genetics.TreeDefinition;
import forestry.core.blocks.IColoredBlock;
import forestry.core.proxy.Proxies;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
@@ -32,11 +24,22 @@ import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.IShearable;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.arboriculture.IFruitProvider;
import forestry.api.arboriculture.ITreeGenome;
import forestry.api.core.IItemModelRegister;
import forestry.api.core.IModelManager;
import forestry.api.core.Tabs;
import forestry.arboriculture.genetics.TreeDefinition;
import forestry.core.blocks.IColoredBlock;
import forestry.core.proxy.Proxies;
public abstract class BlockDecorativeLeaves extends Block implements IItemModelRegister, IColoredBlock, IShearable {
private static final int VARIANTS_PER_BLOCK = 16;
@@ -79,10 +82,10 @@ public abstract class BlockDecorativeLeaves extends Block implements IItemModelR
}
@Override
public void getSubBlocks(Item itemIn, CreativeTabs tab, NonNullList<ItemStack> list) {
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
for (IBlockState state : getBlockState().getValidStates()) {
int meta = getMetaFromState(state);
ItemStack itemStack = new ItemStack(itemIn, 1, meta);
ItemStack itemStack = new ItemStack(this, 1, meta);
list.add(itemStack);
}
}
@@ -158,8 +161,8 @@ public abstract class BlockDecorativeLeaves extends Block implements IItemModelR
}
@Override
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
return Collections.emptyList();
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
}
@Override
@@ -4,14 +4,6 @@ import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
import com.mojang.authlib.GameProfile;
import forestry.api.arboriculture.EnumGermlingType;
import forestry.api.arboriculture.IFruitProvider;
import forestry.api.arboriculture.ITree;
import forestry.api.arboriculture.ITreeGenome;
import forestry.api.arboriculture.TreeManager;
import forestry.api.core.IModelManager;
import forestry.arboriculture.genetics.TreeDefinition;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
@@ -24,10 +16,22 @@ import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import com.mojang.authlib.GameProfile;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.arboriculture.EnumGermlingType;
import forestry.api.arboriculture.IFruitProvider;
import forestry.api.arboriculture.ITree;
import forestry.api.arboriculture.ITreeGenome;
import forestry.api.arboriculture.TreeManager;
import forestry.api.core.IModelManager;
import forestry.arboriculture.genetics.TreeDefinition;
/**
* Genetic leaves with no tile entity, used for worldgen trees.
* Similar to decorative leaves, but these will drop saplings and can be used for pollination.
@@ -120,19 +124,17 @@ public abstract class BlockDefaultLeaves extends BlockAbstractLeaves {
}
@Override
protected NonNullList<ItemStack> getLeafDrop(World world, @Nullable GameProfile playerProfile, BlockPos pos, float saplingModifier, int fortune) {
NonNullList<ItemStack> prod = NonNullList.create();
protected void getLeafDrop(NonNullList<ItemStack> drops, World world, @Nullable GameProfile playerProfile, BlockPos pos, float saplingModifier, int fortune) {
ITree tree = getTree(world, pos);
if (tree == null) {
return prod;
return;
}
// Add saplings
List<ITree> saplings = tree.getSaplings(world, playerProfile, pos, saplingModifier);
for (ITree sapling : saplings) {
if (sapling != null) {
prod.add(TreeManager.treeRoot.getMemberStack(sapling, EnumGermlingType.SAPLING));
drops.add(TreeManager.treeRoot.getMemberStack(sapling, EnumGermlingType.SAPLING));
}
}
@@ -141,10 +143,8 @@ public abstract class BlockDefaultLeaves extends BlockAbstractLeaves {
IFruitProvider fruitProvider = genome.getFruitProvider();
if (fruitProvider.isFruitLeaf(genome, world, pos)) {
NonNullList<ItemStack> produceStacks = tree.produceStacks(world, pos, Integer.MAX_VALUE);
prod.addAll(produceStacks);
drops.addAll(produceStacks);
}
return prod;
}
@Override
+22 -44
View File
@@ -2,6 +2,27 @@ package forestry.arboriculture.blocks;
import java.util.Collection;
import net.minecraft.block.BlockFence;
import net.minecraft.block.BlockPlanks;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.ModelBakery;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.arboriculture.IWoodType;
import forestry.api.arboriculture.TreeManager;
import forestry.api.arboriculture.WoodBlockKind;
@@ -10,31 +31,8 @@ import forestry.api.core.IModelManager;
import forestry.api.core.IStateMapperRegister;
import forestry.api.core.Tabs;
import forestry.arboriculture.IWoodTyped;
import forestry.arboriculture.PluginArboriculture;
import forestry.arboriculture.WoodHelper;
import forestry.arboriculture.proxy.ProxyArboricultureClient;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFence;
import net.minecraft.block.BlockFenceGate;
import net.minecraft.block.BlockPlanks;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.ModelBakery;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public abstract class BlockForestryFence<T extends Enum<T> & IWoodType> extends BlockFence implements IWoodTyped, IItemModelRegister, IStateMapperRegister {
protected static final int VARIANTS_PER_BLOCK = 16;
@@ -74,26 +72,6 @@ public abstract class BlockForestryFence<T extends Enum<T> & IWoodType> extends
return blockNumber;
}
@Override
public boolean canConnectTo(IBlockAccess worldIn, BlockPos pos) {
IBlockState blockState = worldIn.getBlockState(pos);
Block block = blockState.getBlock();
if (PluginArboriculture.validFences.contains(block)) {
return true;
}
if (block != Blocks.BARRIER) {
Material blockMaterial = blockState.getMaterial();
if (block instanceof BlockFence || block instanceof BlockFenceGate) {
return blockMaterial == this.blockMaterial;
}
if (blockMaterial.isOpaque() && blockState.isFullCube() && blockMaterial != Material.GOURD) {
return true;
}
}
return false;
}
/* Models */
@SideOnly(Side.CLIENT)
@Override
@@ -166,7 +144,7 @@ public abstract class BlockForestryFence<T extends Enum<T> & IWoodType> extends
}
@Override
public void getSubBlocks(Item itemIn, CreativeTabs tab, NonNullList<ItemStack> list) {
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
for (T woodType : getVariant().getAllowedValues()) {
list.add(TreeManager.woodAccess.getStack(woodType, getBlockKind(), fireproof));
}
Loaded 100 of 463 files, more files were not shown because too many files have changed in this diff. Show more