Compare commits

..
82 Commits
Author SHA1 Message Date
mezz 1a7c148a7e Update JEI 2016-06-16 18:55:53 -07:00
mezz ead630aa51 Clean up fluids a bit 2016-06-16 14:50:57 -07:00
mezz 85b71c785a Fix colored fluid drip particles 2016-06-16 14:43:18 -07:00
mezz 04cb58dfa2 Use FluidRegistry Water and Lava 2016-06-16 14:38:12 -07:00
mezz 3822e90ada Fix #1299 use dynamic textures for fluid containers 2016-06-16 14:03:30 -07:00
mezz af5cb93689 Use ModelBakery directly, less layers of abstraction 2016-06-16 13:58:03 -07:00
mezz 6a62024dd4 Fix wrench rotation handling 2016-06-15 16:26:57 -07:00
mezz bedb7ffe85 Fix the save bee stats command 2016-06-15 16:04:53 -07:00
mezz 4a21641bcd Fix backpacks trying to interact with inventories in a sided way 2016-06-15 16:04:38 -07:00
mezz 21d0b832b9 Fix crash when mods ask for the inventory without a specific side 2016-06-15 00:03:20 -07:00
mezz ce9081249f Fix compatibility with Chisels & Bits 2016-06-14 16:17:12 -07:00
mezz f6786cd44a Fix #1289 Trade station price can show a negative stack in catalog 2016-06-13 23:08:34 -07:00
mezz a045c18a89 Fix #1300 Crash in CharcoalPileRenderer with WAILA 2016-06-13 21:43:54 -07:00
mezz d6af85ad77 Fix #1314 Crash with WAILA when looking at broken leaves 2016-06-13 21:39:28 -07:00
mezz af55bd86a2 Fix #1322 JEI missing most squeezer recipes 2016-06-13 21:33:32 -07:00
mezz 7aa840282f Fix #1229 Squeezer Recipes in JEI do not show chance % 2016-06-13 21:32:19 -07:00
mezz a5d57c4788 Add villager name localization 2016-06-13 21:30:54 -07:00
mezz 4d0c2d1ea2 Fix all hives spawning with the same flower pattern around them 2016-06-13 20:46:23 -07:00
mezz 840331b7d5 Refresh bee errors when queen is replaced or gui is opened 2016-06-13 19:21:42 -07:00
mezz df91b47b35 Fix missing import for SoundEvent on chest 2016-06-13 15:28:01 -07:00
mezz f400241ff4 Revert greenhouse climate changes. Close #1319 2016-06-13 15:27:19 -07:00
Nedelosk 8639148f20 Fix #1318 1.9.4 Crash with .153 version on world load 2016-06-13 22:56:29 +02:00
Nedelosk 28e7b561ea Fix a bug 2016-06-13 22:14:03 +02:00
Nedelosk ba7ef4228c Update PluginBiomesOPlenty.java 2016-06-13 21:54:53 +02:00
Nedelosk fcd3ee6feb Merge branch 'mc-1.9.4' of https://github.com/ForestryMC/ForestryMC into Greenhouse-Climate-Fix 2016-06-13 21:49:05 +02:00
The-Fireplace 6ddc9f3079 Fixed chests playing the open sound when they close (#1316) 2016-06-12 14:09:31 -07:00
Nedelosk cc53894473 Finish work 2016-06-12 20:42:09 +02:00
Nedelosk 2cd76bdad7 Rework sytem 2016-06-12 01:16:25 +02:00
mezz 92eab8d47a Fix #1308 Restore compatibility with old fluid pipes 2016-06-09 18:35:12 -07:00
mezz 12f5d7be6c Revert "Fix rare possible npe in random hive trade"
This reverts commit 4ba3370fc9.
2016-06-09 16:36:32 -07:00
mezz ab88e7d57c Fix #1311 Crash with WAILA and butterfly or using butterfly kill command 2016-06-09 16:35:33 -07:00
Nedelosk 725d85181d Update System 2016-06-09 21:50:43 +02:00
Nedelosk 23c9b2071b Clen Up and work on climate system 2016-06-09 20:19:13 +02:00
Nedelosk ae025a92fc Clean Up, Work on climate system 2016-06-08 21:58:10 +02:00
Nedelosk fbf30b1a73 Work on new climate system for the greenhouse 2016-06-08 19:25:18 +02:00
Nirek-K 4ba3370fc9 Fix rare possible npe in random hive trade 2016-06-08 11:07:16 -05:00
mezz c1a590961d Cleanup unused fields 2016-06-07 23:40:58 -07:00
mezz a1f7a678c1 Use ForgeRegistries instead of Item and Block registries 2016-06-07 23:40:33 -07:00
mezz 1117b820f1 Update to latest version of JEI 2016-06-07 23:34:01 -07:00
mezz 4681bf4cfb Update Chinese localization 2016-06-07 23:33:05 -07:00
Nirek-K b9dd19a556 Make hive bee trade a random one 2016-06-07 23:49:05 -05:00
Nirek-K f97a737185 Migrate new 1.7 villager trades, fix ic2 uid 2016-06-07 20:18:36 -05:00
mezz 68fb27410e #1295 Add Forestry recipes to the RecipeSorter 2016-06-06 19:00:44 -07:00
mezz b8be42548e Use IconItemStack for farm logic icon 2016-06-05 23:04:48 -07:00
mezz eb9ef642cd Reenable IC2 support 2016-06-05 22:53:12 -07:00
mezz ed658301fd Clean up warnings 2016-06-05 21:40:52 -07:00
mezz d55d86a3c5 Fix #1272 villager house generation is intersecting with the road 2016-06-04 23:31:42 -07:00
mezz b2d5706bbd Stop calculating bee particle collisions 2016-06-04 22:40:27 -07:00
mezz ba6bd8fd10 Fix #1274 Broken fence localization 2016-06-04 21:49:08 -07:00
mezz b998e2ac49 Fix #1286 Crash when trying to break cocoons 2016-06-04 21:46:53 -07:00
mezz 817540d996 Fix #1285 Crash when Biogas Engine starts to burn fuel 2016-06-04 21:33:47 -07:00
mezz 9d8866e4fd Fix missing icons in Genetic Analyzer 2016-06-04 21:28:23 -07:00
mezz 7575b9c6ce Fix #1287 Some genetic traits have broken localization 2016-06-04 18:13:45 -07:00
Nedelosk 6700c511a5 Merge branch 'mc-1.9.4' of https://github.com/ForestryMC/ForestryMC into mc-1.9.4 2016-06-04 23:49:01 +02:00
Nedelosk acc55d4f41 Fix #1277 Transparent sprinkler(item) 2016-06-04 23:47:52 +02:00
mezz 7bd5bb120d Update for new fluid capabilities 2016-06-04 04:25:51 -07:00
Nedelosk dbbb727576 Add Fluid capability to the greenhouse hatch 2016-06-04 11:02:25 +02:00
mezz dcf0fc83ad Fix #1282 NullPointerException from Cocoon with invalid caterpillar 2016-06-04 01:03:13 -07:00
mezz 6ef91590cf Update Forge 2016-06-04 00:59:53 -07:00
mezz 856322b208 Update Forge to fix the crash with cactus placement and BoP grass 2016-06-03 17:29:54 -07:00
mezz 42425e3500 Fix #1281 Crash when trying to place Forestry tiles above Y=255 2016-06-03 16:35:06 -07:00
mezz cde076e702 Fix #1280 Bees can find flowers at very different Y levels in some cases 2016-06-03 16:30:27 -07:00
mezz b5f60d73e3 Fix #1278 Wild bees don't hurt if you wear any 1 piece of Apiarist gear 2016-06-03 16:19:45 -07:00
mezz f82d123b7f Fix #1273 Villagers unable to open forestry doors 2016-06-03 16:07:34 -07:00
mezz ca17801c86 Speed up the check for if a block position is currently in a greenhouse 2016-06-03 15:54:44 -07:00
mezz 33d1685713 Fix #1275 block placement lag when constructing a massive greenhouse 2016-06-03 15:26:57 -07:00
mezz 69c024811f Do not bake leaves based on position 2016-06-03 14:45:00 -07:00
Nedelosk 4dd95625e1 Fix #1244 Opening Greenhouse GUI causes a drop in fps, from 90fps to 6fps(in my case) 2016-06-03 23:11:52 +02:00
mezz 6adcde4a75 Fix NoClassDefFoundError: TextureAtlasSprite 2016-06-03 07:34:38 -07:00
mezz 2f06c777b2 Fix #1246 Greenhouse control redstone logic is inverted 2016-06-03 06:25:29 -07:00
mezz 32f295b16c Fix #1254 Chest bounding boxes are too large 2016-06-03 06:22:14 -07:00
mezz ef4c65c6e6 Fix some bee particles showing up as very dark 2016-06-03 06:09:56 -07:00
mezz ba313a9dfe Fix desync causing hives to have no active bees 2016-06-03 06:09:07 -07:00
mezz 8f36c2a6fc Route more bees to flowers than to exploring 2016-06-03 06:08:24 -07:00
mezz 149a5b6128 Update Forge 2016-06-03 06:08:04 -07:00
mezz 56b871eca1 Improve bee particle performance: do not render when too far away 2016-06-03 04:30:42 -07:00
mezz c09cdcdb64 Add more varied bee particles 2016-06-03 04:30:12 -07:00
mezz 2f66d0ea82 Fix hives only spawning Forest bees 2016-06-03 04:24:53 -07:00
mezz ac224823be Reduce random bee damage if you haven't hit the hive 2016-06-03 04:24:33 -07:00
mezz 1eca6e41af Improve bee particle performance 2016-06-02 17:16:15 -07:00
mezz 94bd65ee8e Improve greenhouse error messages. 2016-06-02 16:24:00 -07:00
mezz 795b154eb5 Fix #1263 Crash when lighting TNT on top of wood pile block 2016-06-02 13:19:41 -07:00
238 changed files with 2904 additions and 2934 deletions

No files matched your search

+1 -2
View File
@@ -67,8 +67,7 @@ repositories {
dependencies {
deobfCompile "mezz.jei:jei_${mcversion}:${jei_version}"
// deobfCompile "net.industrial-craft:industrialcraft-2:${ic2_version}:api"
// runtime "net.industrial-craft:industrialcraft-2:${ic2_version}:dev"
deobfCompile "net.industrial-craft:industrialcraft-2:${ic2_version}:api"
}
configurations {
+4 -3
View File
@@ -1,9 +1,10 @@
mcversion=1.9.4
forgeversion=12.17.0.1932-1.9.4
forgeversion=12.17.0.1957
mcp_mappings=snapshot_20160525
jei_version=3.4.0.+
jei_version=3.6.4.+
ic2_version=2.5.5-ex19
version_major=5
version_minor=0
version_patch=3
version_patch=17
+1 -1
Submodule lang updated: 53d7c93f90...9be86d3c99.
+2 -1
View File
@@ -49,7 +49,7 @@ import forestry.plugins.PluginManager;
name = "Forestry",
version = Constants.VERSION,
guiFactory = "forestry.core.config.ForestryGuiConfigFactory",
dependencies = "required-after:Forge@[12.17.0.1932,);"
dependencies = "required-after:Forge@[12.17.0.1949,);"
+ "after:Buildcraft|Core@[7.2,);"
+ "after:BuildCraft|Energy@[7.2,);"
+ "after:ExtrabiomesXL;"
@@ -57,6 +57,7 @@ import forestry.plugins.PluginManager;
+ "after:IC2@[2.3.235,);"
+ "after:Natura@[2.2.0,);"
+ "after:HardcoreEnderExpansion;"
+ "after:JEI@[3.6.4,);"
+ "after:basemetals;")
public class Forestry {
@@ -9,6 +9,7 @@ import javax.annotation.Nonnull;
import java.util.List;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
@@ -35,12 +36,17 @@ public interface IBeekeepingLogic extends INbtWritable, INbtReadable {
*/
void doWork();
/**
* Force the logic to refresh any cached values and error states.
* Call this when a player opens the gui so that all errors are up to date.
*/
void clearCachedValues();
/* CLIENT */
/**
* Call this when the housing comes into view of the client.
* (i.e. when {@link TileEntity#getUpdateTag()} is called)
* Sync to client by using {@link #writeToNBT(NBTTagCompound)} in your {@link TileEntity#getUpdateTag()}
*/
void syncToClient();
@@ -11,6 +11,8 @@ public interface IHiveTile {
*/
void calmBees();
boolean isAngry();
/**
* Called when the hive is attacked.
*/
@@ -5,6 +5,8 @@
******************************************************************************/
package forestry.api.apiculture.hives;
import java.util.Random;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@@ -46,5 +48,5 @@ public interface IHiveDescription {
* Called after successful hive generation.
* world, x, y, z give the location of the new hive.
**/
void postGen(World world, BlockPos pos);
void postGen(World world, Random rand, BlockPos pos);
}
@@ -17,14 +17,14 @@ public interface IHiveRegistry {
/* Forestry Hive Names */
enum HiveType implements IStringSerializable {
FOREST("Forestry:forest", "Forestry.speciesForest"),
MEADOWS("Forestry:meadows", "Forestry.speciesMeadows"),
DESERT("Forestry:desert", "Forestry.speciesModest"),
JUNGLE("Forestry:jungle", "Forestry.speciesTropical"),
END("Forestry:end", "Forestry.speciesEnded"),
SNOW("Forestry:snow", "Forestry.speciesWintry"),
SWAMP("Forestry:swamp", "Forestry.speciesMarshy"),
SWARM("Forestry:swarm", "Forestry.speciesForest");
FOREST("forestry:forest", "forestry.speciesForest"),
MEADOWS("forestry:meadows", "forestry.speciesMeadows"),
DESERT("forestry:desert", "forestry.speciesModest"),
JUNGLE("forestry:jungle", "forestry.speciesTropical"),
END("forestry:end", "forestry.speciesEnded"),
SNOW("forestry:snow", "forestry.speciesWintry"),
SWAMP("forestry:swamp", "forestry.speciesMarshy"),
SWARM("forestry:swarm", "forestry.speciesForest");
public static final HiveType[] VALUES = values();
@@ -10,6 +10,9 @@ import javax.annotation.Nonnull;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.core.IModelManager;
/**
@@ -18,6 +21,7 @@ import forestry.api.core.IModelManager;
* There is no default implementation because every sapling has a unique icon.
*/
public interface IGermlingModelProvider {
@SideOnly(Side.CLIENT)
void registerModels(Item item, IModelManager manager, EnumGermlingType type);
@Nonnull
@@ -30,6 +30,4 @@ public interface IModelManager {
void registerItemModel(Item item, ItemMeshDefinition definition);
void registerVariant(Item item, ResourceLocation... resources);
}
@@ -38,6 +38,8 @@ public interface IFarmLogic {
String getName();
@SideOnly(Side.CLIENT)
ItemStack getStack();
/**
* @return the itemStack that represents this farm logic. Used as an icon for the farm logic.
*/
ItemStack getIconItemStack();
}
@@ -21,10 +21,10 @@ import net.minecraft.util.math.Vec3i;
*
* For example:
* en_US
* Forestry.allele.smallest=Smallest
* forestry.allele.smallest=Smallest
* ru_RU
* Forestry.allele.smallest=????? ?????????
* Forestry.allele.height.smallest=????? ??????
* forestry.allele.smallest=????? ?????????
* forestry.allele.height.smallest=????? ??????
*/
public interface IAlleleFactory {
/**
@@ -1,6 +1,7 @@
package forestry.api.genetics;
import java.util.List;
import java.util.Map;
import net.minecraft.item.ItemStack;
@@ -20,5 +21,7 @@ public interface IAlyzerPlugin {
@SideOnly(Side.CLIENT)
void drawAnalyticsPage3(GuiAlyzer gui, ItemStack itemStack);
Map<String, ItemStack> getIconStacks();
List<String> getHints();
}
@@ -6,7 +6,7 @@
package forestry.api.greenhouse;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
@@ -22,7 +22,7 @@ public interface IGreenhouseState {
float getExactHumidity();
List<IInternalBlock> getInternalBlocks();
Set<IInternalBlock> getInternalBlocks();
Collection<IMultiblockComponent> getGreenhouseComponents();
@@ -5,6 +5,8 @@
******************************************************************************/
package forestry.api.recipes;
import javax.annotation.Nullable;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
@@ -24,6 +26,7 @@ public interface ISqueezerRecipe extends IForestryRecipe {
/**
* @return Item stack representing the possible remnants from this recipe. (i.e. tin left over from tin cans)
*/
@Nullable
ItemStack getRemnants();
/**
@@ -197,6 +197,8 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
if (!ItemStack.areItemStacksEqual(this.queenStack, queenStack)) {
this.queen = BeeManager.beeRoot.getMember(queenStack);
this.queenStack = queenStack;
hasFlowersCache.clear();
queenCanWorkCache.clear();
}
if (errorLogic.setCondition(queen == null, EnumErrorCode.NO_QUEEN)) {
@@ -235,6 +237,13 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
}
}
@Override
public void clearCachedValues() {
hasFlowersCache.clear();
queenCanWorkCache.clear();
canWork();
}
private void queenWorkTick(IBee queen) {
if (queen == null) {
beeProgress = 0;
@@ -505,6 +514,11 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
return queenCanWorkCached;
}
public void clear() {
queenCanWorkCached.clear();
queenCanWorkCooldown = 0;
}
}
private static class PollenHandler {
@@ -37,6 +37,11 @@ public class FakeBeekeepingLogic implements IBeekeepingLogic {
}
@Override
public void clearCachedValues() {
}
@Override
public void syncToClient() {
@@ -97,6 +97,11 @@ public class HasFlowersCache implements INbtWritable, INbtReadable, IStreamable
return returnVal;
}
public void clear() {
flowerCoords.clear();
cooldown = 0;
}
@Nonnull
public List<BlockPos> getFlowerCoords() {
return Collections.unmodifiableList(flowerCoords);
@@ -14,16 +14,12 @@ import com.google.common.collect.ImmutableMap;
import java.io.File;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Random;
import java.util.Set;
import net.minecraft.block.BlockFlower;
import net.minecraft.block.BlockRedFlower;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.entity.passive.EntityVillager;
@@ -40,6 +36,7 @@ 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.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.SidedProxy;
@@ -71,7 +68,6 @@ import forestry.apiculture.blocks.BlockRegistryApiculture;
import forestry.apiculture.commands.CommandBee;
import forestry.apiculture.entities.EntityMinecartApiary;
import forestry.apiculture.entities.EntityMinecartBeehouse;
import forestry.apiculture.entities.ParticleBee;
import forestry.apiculture.flowers.FlowerRegistry;
import forestry.apiculture.genetics.BeeBranchDefinition;
import forestry.apiculture.genetics.BeeDefinition;
@@ -95,6 +91,7 @@ import forestry.apiculture.multiblock.TileAlvearyStabiliser;
import forestry.apiculture.multiblock.TileAlvearySwarmer;
import forestry.apiculture.network.PacketRegistryApiculture;
import forestry.apiculture.proxy.ProxyApiculture;
import forestry.apiculture.proxy.ProxyApicultureClient;
import forestry.apiculture.tiles.TileCandle;
import forestry.apiculture.tiles.TileHive;
import forestry.apiculture.worldgen.HiveDecorator;
@@ -132,16 +129,12 @@ public class PluginApiculture extends BlankForestryPlugin {
public static String beekeepingMode = "NORMAL";
private static float secondPrincessChance = 0;
public static final int ticksPerBeeWorkCycle = 550;
public static boolean fancyRenderedBees = false;
public static ItemRegistryApiculture items;
public static BlockRegistryApiculture blocks;
public static HiveRegistry hiveRegistry;
private final Map<String, String[]> defaultAcceptedFlowers = new HashMap<>();
private final Map<String, String[]> defaultPlantableFlowers = new HashMap<>();
public static VillagerRegistry.VillagerProfession villagerApiarist;
@Override
@@ -277,9 +270,12 @@ public class PluginApiculture extends BlankForestryPlugin {
villagerRegistry.register(villagerApiarist);
ItemStack wildcardPrincess = new ItemStack(items.beePrincessGE, 1);
ItemStack wildcardDrone = new ItemStack(items.beeDroneGE, 1);
ItemStack apiary = new ItemStack(blocks.apiary);
ItemStack provenFrames = items.frameProven.getItemStack();
ItemStack monasticDrone = BeeDefinition.MONASTIC.getMemberStack(EnumBeeType.DRONE);
ItemStack endDrone = BeeDefinition.ENDED.getMemberStack(EnumBeeType.DRONE);
ItemStack propolis = new ItemStack(PluginApiculture.items.propolis,1);
VillagerRegistry.VillagerCareer apiaristCareer = new VillagerRegistry.VillagerCareer(villagerApiarist, "apiarist");
apiaristCareer.addTrade(1,
@@ -289,19 +285,19 @@ public class PluginApiculture extends BlankForestryPlugin {
);
apiaristCareer.addTrade(2,
new VillagerTradeLists.GiveItemForEmeralds(new EntityVillager.PriceInfo(1, 4), new ItemStack(items.smoker), null),
new VillagerTradeLists.GiveItemForLogsAndEmeralds(apiary, new EntityVillager.PriceInfo(1, 1), new EntityVillager.PriceInfo(16, 32), new EntityVillager.PriceInfo(1, 2))
new VillagerTradeLists.GiveItemForLogsAndEmeralds(apiary, new EntityVillager.PriceInfo(1, 1), new EntityVillager.PriceInfo(16, 32), new EntityVillager.PriceInfo(1, 2)),
new VillagerApiaristTrades.GiveRandomHiveDroneForItems(propolis, null, wildcardDrone, new EntityVillager.PriceInfo(2, 4))
);
apiaristCareer.addTrade(3,
new VillagerTradeLists.GiveEmeraldForItems(wildcardPrincess, null),
new VillagerTradeLists.GiveItemForEmeralds(new EntityVillager.PriceInfo(1, 2), provenFrames, new EntityVillager.PriceInfo(1, 6))
);
apiaristCareer.addTrade(4,
new VillagerTradeLists.GiveItemForItemAndEmerald(wildcardPrincess, null, new EntityVillager.PriceInfo(10, 64), monasticDrone, null)
new VillagerTradeLists.GiveItemForItemAndEmerald(wildcardPrincess, null, new EntityVillager.PriceInfo(10, 64), monasticDrone, null),
new VillagerTradeLists.GiveItemForTwoItems(wildcardPrincess, null,new ItemStack(Items.ENDER_EYE),new EntityVillager.PriceInfo(12, 16),endDrone, null)
);
}
proxy.initializeRendering();
blocks.apiary.init();
blocks.beeHouse.init();
blocks.beeChest.init();
@@ -563,9 +559,9 @@ public class PluginApiculture extends BlankForestryPlugin {
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{items.honeydew.getItemStack()}, honeyDropFluid);
ItemStack phosphor = PluginCore.items.phosphor.getItemStack(2);
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{phosphor, new ItemStack(Blocks.SAND)}, Fluids.LAVA.getFluid(2000));
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{phosphor, new ItemStack(Blocks.SAND, 1, 1)}, Fluids.LAVA.getFluid(2000));
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{phosphor, new ItemStack(Blocks.DIRT)}, Fluids.LAVA.getFluid(1600));
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{phosphor, new ItemStack(Blocks.SAND)}, new FluidStack(FluidRegistry.WATER, 2000));
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{phosphor, new ItemStack(Blocks.SAND, 1, 1)}, new FluidStack(FluidRegistry.LAVA, 2000));
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{phosphor, new ItemStack(Blocks.DIRT)}, new FluidStack(FluidRegistry.LAVA, 1600));
// / CARPENTER
RecipeManagers.carpenterManager.addRecipe(50, Fluids.FOR_HONEY.getFluid(500), null, PluginCore.items.craftingMaterial.getScentedPaneling(),
@@ -574,14 +570,14 @@ public class PluginApiculture extends BlankForestryPlugin {
'J', items.royalJelly,
'W', PluginCore.items.beeswax,
'P', items.pollenCluster.get(EnumPollenCluster.NORMAL, 1));
RecipeManagers.carpenterManager.addRecipe(30, Fluids.WATER.getFluid(600), null, blocks.candle.getUnlitCandle(24),
RecipeManagers.carpenterManager.addRecipe(30, new FluidStack(FluidRegistry.WATER, 600), null, blocks.candle.getUnlitCandle(24),
" X ",
"###",
"###",
'#', PluginCore.items.beeswax,
'X', Items.STRING);
RecipeManagers.carpenterManager.addRecipe(10, Fluids.WATER.getFluid(200), null, blocks.candle.getUnlitCandle(6),
RecipeManagers.carpenterManager.addRecipe(10, new FluidStack(FluidRegistry.WATER, 200), null, blocks.candle.getUnlitCandle(6),
"#X#",
'#', PluginCore.items.beeswax,
'X', PluginCore.items.craftingMaterial.getSilkWisp());
@@ -850,7 +846,7 @@ public class PluginApiculture extends BlankForestryPlugin {
for (int i = 0; i < ParticleSnow.sprites.length; i++) {
ParticleSnow.sprites[i] = event.getMap().registerSprite(new ResourceLocation("forestry:entity/particles/snow." + (i + 1)));
}
ParticleBee.beeSprite = event.getMap().registerSprite(new ResourceLocation("forestry:entity/particles/swarm_bee"));
ProxyApicultureClient.beeSprite = event.getMap().registerSprite(new ResourceLocation("forestry:entity/particles/swarm_bee"));
}
private static class EndFlowerAcceptableRule implements IFlowerAcceptableRule {
@@ -1,5 +1,6 @@
package forestry.apiculture;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Random;
@@ -8,6 +9,9 @@ import net.minecraft.item.ItemStack;
import net.minecraft.village.MerchantRecipe;
import net.minecraft.village.MerchantRecipeList;
import forestry.api.apiculture.EnumBeeType;
import forestry.apiculture.genetics.BeeDefinition;
public class VillagerApiaristTrades {
public static class GiveRandomCombsForItems implements EntityVillager.ITradeList {
@@ -24,7 +28,7 @@ public class VillagerApiaristTrades {
}
@Override
public void modifyMerchantRecipeList(MerchantRecipeList recipeList, Random random) {
public void modifyMerchantRecipeList(@Nonnull MerchantRecipeList recipeList, @Nonnull Random random) {
int sellAmount = 1;
if (this.priceInfo != null) {
sellAmount = this.priceInfo.getPrice(random);
@@ -41,5 +45,46 @@ public class VillagerApiaristTrades {
recipeList.add(new MerchantRecipe(itemToBuy, randomComb));
}
}
public static class GiveRandomHiveDroneForItems implements EntityVillager.ITradeList {
@Nonnull
public ItemStack buyingItemStack;
@Nullable
public EntityVillager.PriceInfo buyingPriceInfo;
@Nonnull
public ItemStack buyingItemStackTwo;
@Nullable
public EntityVillager.PriceInfo buyingPriceItemTwoInfo;
public GiveRandomHiveDroneForItems(
@Nonnull ItemStack buyingItemStack,
@Nullable EntityVillager.PriceInfo buyingPriceInfo,
@Nonnull ItemStack buyingItemStackTwo,
@Nullable EntityVillager.PriceInfo buyingPriceItemTwoInfo) {
this.buyingItemStack = buyingItemStack;
this.buyingPriceInfo = buyingPriceInfo;
this.buyingItemStackTwo = buyingItemStackTwo;
this.buyingPriceItemTwoInfo = buyingPriceItemTwoInfo;
}
@Override
public void modifyMerchantRecipeList(@Nonnull MerchantRecipeList recipeList, @Nonnull Random random) {
int buyAmount = 1;
if (this.buyingPriceInfo != null) {
buyAmount = this.buyingPriceInfo.getPrice(random);
}
int buyTwoAmount = 1;
if (this.buyingPriceItemTwoInfo != null) {
buyTwoAmount = this.buyingPriceItemTwoInfo.getPrice(random);
}
BeeDefinition [] forestryMundane = new BeeDefinition[] { BeeDefinition.FOREST, BeeDefinition.MEADOWS, BeeDefinition.MODEST, BeeDefinition.WINTRY, BeeDefinition.TROPICAL, BeeDefinition.MARSHY };
ItemStack randomHiveDrone = forestryMundane[random.nextInt(forestryMundane.length)].getMemberStack(EnumBeeType.DRONE);
ItemStack buyItemStack = this.buyingItemStack.copy();
buyItemStack.stackSize = buyAmount;
ItemStack buyItemStackTwo = this.buyingItemStackTwo.copy();
buyItemStackTwo.stackSize = buyTwoAmount;
recipeList.add(new MerchantRecipe(buyItemStack, buyItemStackTwo, randomHiveDrone));
}
}
}
@@ -33,12 +33,8 @@ public enum BlockTypeApicultureTesr implements IBlockTypeTesr {
@Nonnull
private final IMachinePropertiesTesr<?> machineProperties;
<T extends TileForestry> BlockTypeApicultureTesr(@Nonnull Class<T> teClass, @Nonnull String name, @Nullable TileEntitySpecialRenderer<? super T> renderer, @Nullable AxisAlignedBB boundingBox) {
if (boundingBox != null) {
this.machineProperties = new MachinePropertiesTesr<>(teClass, name, renderer, boundingBox, Constants.MOD_ID + ":blocks/" + name + ".0");
} else {
this.machineProperties = new MachinePropertiesTesr<>(teClass, name, renderer, Constants.MOD_ID + ":blocks/" + name + ".0");
}
<T extends TileForestry> BlockTypeApicultureTesr(@Nonnull Class<T> teClass, @Nonnull String name, @Nullable TileEntitySpecialRenderer<? super T> renderer, AxisAlignedBB boundingBox) {
this.machineProperties = new MachinePropertiesTesr<>(teClass, name, renderer, boundingBox, Constants.MOD_ID + ":blocks/" + name + ".0");
}
@Nonnull
@@ -1,15 +1,19 @@
package forestry.apiculture.compat;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.List;
import net.minecraft.item.ItemStack;
import forestry.api.genetics.IAlleleSpecies;
import forestry.apiculture.PluginApiculture;
import forestry.apiculture.genetics.BeeGenome;
import mezz.jei.api.BlankModPlugin;
import mezz.jei.api.IModRegistry;
import mezz.jei.api.ISubtypeRegistry;
import mezz.jei.api.JEIPlugin;
@JEIPlugin
@@ -34,5 +38,21 @@ public class ApicultureJeiPlugin extends BlankModPlugin {
registry.addDescription(new ItemStack(PluginApiculture.items.habitatLocator), "for.jei.description.habitat.locator");
registry.addDescription(new ItemStack(PluginApiculture.items.scoop), "for.jei.description.scoop");
ISubtypeRegistry subtypeRegistry = registry.getJeiHelpers().getSubtypeRegistry();
subtypeRegistry.registerNbtInterpreter(PluginApiculture.items.beeDroneGE, BeeSubtypeInterpreter.INSTANCE);
subtypeRegistry.registerNbtInterpreter(PluginApiculture.items.beePrincessGE, BeeSubtypeInterpreter.INSTANCE);
subtypeRegistry.registerNbtInterpreter(PluginApiculture.items.beeQueenGE, BeeSubtypeInterpreter.INSTANCE);
}
private static class BeeSubtypeInterpreter implements ISubtypeRegistry.ISubtypeInterpreter {
public static BeeSubtypeInterpreter INSTANCE = new BeeSubtypeInterpreter();
@Nullable
@Override
public String getSubtypeInfo(@Nonnull ItemStack itemStack) {
IAlleleSpecies species = BeeGenome.getSpeciesDirectly(itemStack);
return species == null ? null : species.getUID();
}
}
}
@@ -0,0 +1,137 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.entities;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.renderer.VertexBuffer;
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.proxy.ProxyApicultureClient;
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);
setParticleTexture(ProxyApicultureClient.beeSprite);
this.origin = origin;
this.motionX = (destination.getX() + 0.5 - this.posX) * 0.015;
this.motionY = (destination.getY() + 0.5 - this.posY) * 0.015;
this.motionZ = (destination.getZ() + 0.5 - this.posZ) * 0.015;
particleRed = (color >> 16 & 255) / 255.0F;
particleGreen = (color >> 8 & 255) / 255.0F;
particleBlue = (color & 255) / 255.0F;
this.setSize(0.1F, 0.1F);
this.particleScale *= 0.2F;
this.particleMaxAge = (int) (80.0D / (Math.random() * 0.8D + 0.2D));
this.motionX *= 0.9D;
this.motionY *= 0.015D;
this.motionZ *= 0.9D;
}
/**
* Called to update the entity's position/logic.
*/
@Override
public void onUpdate() {
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
this.moveEntity(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;
}
if (this.particleAge < this.particleMaxAge * 0.25) {
// venture out
this.motionX *= 0.92 + 0.3D * rand.nextFloat();
this.motionY = (this.motionY + 0.3 * (-0.5 + rand.nextFloat())) / 2;
this.motionZ *= 0.92 + 0.3D * rand.nextFloat();
} else if (this.particleAge < this.particleMaxAge * 0.5) {
// slow down
this.motionX *= 0.75 + 0.3D * rand.nextFloat();
this.motionY = (this.motionY + 0.3 * (-0.5 + rand.nextFloat())) / 2;
this.motionZ *= 0.75 + 0.3D * rand.nextFloat();
} else if (this.particleAge < this.particleMaxAge * 0.75) {
// venture back
this.motionX *= 0.95;
this.motionY = (origin.yCoord - 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.motionY = (this.motionY + 0.2 * (-0.5 + rand.nextFloat())) / 2;
this.motionZ = (origin.zCoord - this.posZ) * 0.03;
}
if (this.particleAge++ >= this.particleMaxAge) {
this.setExpired();
}
}
@Override
public void renderParticle(VertexBuffer worldRendererIn, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) {
float minU = 0;
float maxU = 1;
float minV = 0;
float maxV = 1;
if (this.particleTexture != null) {
minU = particleTexture.getMinU();
maxU = particleTexture.getMaxU();
minV = particleTexture.getMinV();
maxV = particleTexture.getMaxV();
}
float f10 = 0.1F * particleScale;
float f11 = (float) (prevPosX + (posX - prevPosX) * partialTicks - interpPosX);
float f12 = (float) (prevPosY + (posY - prevPosY) * partialTicks - interpPosY);
float f13 = (float) (prevPosZ + (posZ - prevPosZ) * partialTicks - interpPosZ);
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();
}
// avoid calculating lighting for bees, it is too much processing
@Override
public int getBrightnessForRender(float p_189214_1_) {
return 15728880;
}
// avoid calculating collisions
@Override
public void moveEntity(double x, double y, double z) {
this.setEntityBoundingBox(this.getEntityBoundingBox().offset(x, y, z));
this.resetPositionToBB();
}
@Override
public int getFXLayer() {
return 1;
}
}
@@ -12,30 +12,26 @@ package forestry.apiculture.entities;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.renderer.VertexBuffer;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
public class ParticleBee extends Particle {
private final double originX;
private final double originY;
private final double originZ;
private final BlockPos destination;
public static TextureAtlasSprite beeSprite;
import forestry.apiculture.proxy.ProxyApicultureClient;
public ParticleBee(World world, double x, double y, double z, int color, BlockPos destination) {
super(world, x, y, z, 0.0D, 0.0D, 0.0D);
setParticleTexture(beeSprite);
this.originX = x;
this.originY = y;
this.originZ = z;
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);
setParticleTexture(ProxyApicultureClient.beeSprite);
this.origin = origin;
this.destination = destination;
this.motionX = (destination.getX() + 0.5 - this.posX) * 0.015;
this.motionY = (destination.getY() + 0.5 - this.posY) * 0.015;
this.motionZ = (destination.getZ() + 0.5 - this.posZ) * 0.015;
this.motionX = (destination.getX() + 0.5 - this.posX) * 0.02 + 0.1 * rand.nextFloat();
this.motionY = (destination.getY() + 0.5 - this.posY) * 0.015 + 0.1 * rand.nextFloat();
this.motionZ = (destination.getZ() + 0.5 - this.posZ) * 0.02 + 0.1 * rand.nextFloat();
particleRed = (color >> 16 & 255) / 255.0F;
particleGreen = (color >> 8 & 255) / 255.0F;
@@ -61,34 +57,34 @@ public class ParticleBee extends Particle {
this.moveEntity(this.motionX, this.motionY, this.motionZ);
if (this.particleAge == this.particleMaxAge / 2) {
this.motionX = (this.originX - this.posX) * 0.03;
this.motionY = (this.originY - this.posY) * 0.03;
this.motionZ = (this.originZ - this.posZ) * 0.03;
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();
}
if (this.particleAge < this.particleMaxAge * 0.25) {
// venture out
this.motionX *= 0.92 + 0.2D * rand.nextFloat();
this.motionY = (this.motionY + 0.2 * (-0.5 + rand.nextFloat())) / 2;
this.motionY = (this.motionY + 0.3 * (-0.5 + rand.nextFloat())) / 2;
this.motionZ *= 0.92 + 0.2D * rand.nextFloat();
} else if (this.particleAge < this.particleMaxAge * 0.5) {
// get to flower destination
this.motionX = (destination.getX() + 0.5 - this.posX) * 0.03;
this.motionY = (destination.getY() + 0.5 - this.posY) * 0.03;
this.motionY = (destination.getY() + 0.5 - this.posY) * 0.1;
this.motionY = (this.motionY + 0.2 * (-0.5 + rand.nextFloat())) / 2;
this.motionZ = (destination.getZ() + 0.5 - this.posZ) * 0.03;
} else if (this.particleAge < this.particleMaxAge * 0.75) {
// venture back
this.motionX *= 0.95;
this.motionY = (this.originY - this.posY) * 0.03;
this.motionY = (origin.yCoord - 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 = (this.originX - this.posX) * 0.03;
this.motionY = (this.originY - this.posY) * 0.03;
this.motionX = (origin.xCoord - this.posX) * 0.03;
this.motionY = (origin.yCoord - this.posY) * 0.03;
this.motionY = (this.motionY + 0.2 * (-0.5 + rand.nextFloat())) / 2;
this.motionZ = (this.originZ - this.posZ) * 0.03;
this.motionZ = (origin.zCoord - this.posZ) * 0.03;
}
if (this.particleAge++ >= this.particleMaxAge) {
@@ -124,7 +120,13 @@ public class ParticleBee extends Particle {
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();
}
// avoid calculating collisions for bees, it is too much processing
// avoid calculating lighting for bees, it is too much processing
@Override
public int getBrightnessForRender(float p_189214_1_) {
return 15728880;
}
// avoid calculating collisions
@Override
public void moveEntity(double x, double y, double z) {
this.setEntityBoundingBox(this.getEntityBoundingBox().offset(x, y, z));
@@ -0,0 +1,137 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.entities;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.renderer.VertexBuffer;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import forestry.apiculture.proxy.ProxyApicultureClient;
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);
setParticleTexture(ProxyApicultureClient.beeSprite);
this.origin = origin;
this.entity = entity;
this.motionX = (entity.posX - this.posX) * 0.015;
this.motionY = (entity.posY + 1.62F - this.posY) * 0.015;
this.motionZ = (entity.posZ - this.posZ) * 0.015;
particleRed = (color >> 16 & 255) / 255.0F;
particleGreen = (color >> 8 & 255) / 255.0F;
particleBlue = (color & 255) / 255.0F;
this.setSize(0.1F, 0.1F);
this.particleScale *= 0.2F;
this.particleMaxAge = (int) (80.0D / (Math.random() * 0.8D + 0.2D));
this.motionX *= 0.9D;
this.motionY *= 0.9D;
this.motionZ *= 0.9D;
}
/**
* Called to update the entity's position/logic.
*/
@Override
public void onUpdate() {
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
this.moveEntity(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;
}
if (this.particleAge < this.particleMaxAge * 0.5) {
// fly near the entity
this.motionX = (entity.posX - this.posX) * 0.09;
this.motionX = (this.motionX + 0.2 * (-0.5 + rand.nextFloat())) / 2;
this.motionY = (entity.posY + 1.62F - this.posY) * 0.03;
this.motionY = (this.motionY + 0.4 * (-0.5 + rand.nextFloat())) / 4;
this.motionZ = (entity.posZ - this.posZ) * 0.09;
this.motionZ = (this.motionZ + 0.2 * (-0.5 + rand.nextFloat())) / 2;
} else if (this.particleAge < this.particleMaxAge * 0.75) {
// venture back
this.motionX *= 0.95;
this.motionY = (origin.yCoord - 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.motionY = (this.motionY + 0.2 * (-0.5 + rand.nextFloat())) / 2;
this.motionZ = (origin.zCoord - this.posZ) * 0.03;
}
if (this.particleAge++ >= this.particleMaxAge) {
this.setExpired();
}
}
@Override
public void renderParticle(VertexBuffer worldRendererIn, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) {
float minU = 0;
float maxU = 1;
float minV = 0;
float maxV = 1;
if (this.particleTexture != null) {
minU = particleTexture.getMinU();
maxU = particleTexture.getMaxU();
minV = particleTexture.getMinV();
maxV = particleTexture.getMaxV();
}
float f10 = 0.1F * particleScale;
float f11 = (float) (prevPosX + (posX - prevPosX) * partialTicks - interpPosX);
float f12 = (float) (prevPosY + (posY - prevPosY) * partialTicks - interpPosY);
float f13 = (float) (prevPosZ + (posZ - prevPosZ) * partialTicks - interpPosZ);
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();
}
// avoid calculating lighting for bees, it is too much processing
@Override
public int getBrightnessForRender(float p_189214_1_) {
return 15728880;
}
// avoid calculating collisions
@Override
public void moveEntity(double x, double y, double z) {
this.setEntityBoundingBox(this.getEntityBoundingBox().offset(x, y, z));
this.resetPositionToBB();
}
@Override
public int getFXLayer() {
return 1;
}
}
@@ -251,6 +251,11 @@ public class BeeAlyzerPlugin implements IAlyzerPlugin {
textLayout.endPage();
}
@Override
public Map<String, ItemStack> getIconStacks() {
return iconStacks;
}
@Override
public List<String> getHints() {
return Config.hints.get("beealyzer");
@@ -12,6 +12,7 @@ package forestry.apiculture.genetics;
import java.util.Locale;
import net.minecraft.client.renderer.block.model.ModelBakery;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
@@ -47,7 +48,7 @@ public class DefaultBeeModelProvider implements IBeeModelProvider {
}
models[beeType.ordinal()] = manager.getModelLocation(beeTypeNameBase);
manager.registerVariant(item, new ResourceLocation("forestry:" + beeTypeNameBase));
ModelBakery.registerItemVariants(item, new ResourceLocation("forestry:" + beeTypeNameBase));
}
@Override
@@ -17,7 +17,6 @@ import net.minecraft.entity.Entity;
import net.minecraft.init.MobEffects;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Vec3i;
import forestry.api.apiculture.BeeManager;
@@ -105,16 +104,14 @@ public abstract class AlleleEffect extends AlleleCategorized implements IAlleleB
@Override
public IEffectData doFX(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
Vec3d origin = housing.getBeeFXCoordinates();
IBeekeepingLogic beekeepingLogic = housing.getBeekeepingLogic();
List<BlockPos> flowerPositions = beekeepingLogic.getFlowerPositions();
int beeColor = genome.getPrimary().getSpriteColour(0);
Proxies.render.addBeeHiveFX(housing.getWorldObj(), origin.xCoord, origin.yCoord, origin.zCoord, beeColor, flowerPositions);
Proxies.render.addBeeHiveFX(housing, genome, flowerPositions);
return storedData;
}
protected Vec3i getModifiedArea(IBeeGenome genome, IBeeHousing housing) {
public static Vec3i getModifiedArea(IBeeGenome genome, IBeeHousing housing) {
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
float territoryModifier = beeModifier.getTerritoryModifier(genome, 1f);
@@ -85,7 +85,7 @@ public class AlleleEffectCreeper extends AlleleEffectThrottled {
}
float pitch = (1.0F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.7F;
world.playSound((EntityPlayer)null, housingCoords.getX(), housingCoords.getY(), housingCoords.getZ(), SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.BLOCKS, 4.0F, pitch);
world.playSound(null, housingCoords.getX(), housingCoords.getY(), housingCoords.getZ(), SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.BLOCKS, 4.0F, pitch);
storedData.setInteger(indexExplosionTimer, 2); // Set explosion timer
}
@@ -22,6 +22,8 @@ public class ContainerAlveary extends ContainerTile<TileAlveary> {
public ContainerAlveary(InventoryPlayer player, TileAlveary tile) {
super(tile, player, 8, 108);
ContainerBeeHelper.addSlots(this, tile, false);
tile.getBeekeepingLogic().clearCachedValues();
}
private int beeProgress = -1;
@@ -22,6 +22,8 @@ public class ContainerBeeHousing extends ContainerTile<TileBeeHousingBase> imple
public ContainerBeeHousing(InventoryPlayer player, TileBeeHousingBase tile, boolean hasFrames) {
super(tile, player, 8, 108);
ContainerBeeHelper.addSlots(this, tile, hasFrames);
tile.getBeekeepingLogic().clearCachedValues();
}
private int beeProgress = -1;
@@ -21,6 +21,8 @@ public class ContainerMinecartBeehouse extends ContainerEntity<EntityMinecartBee
public ContainerMinecartBeehouse(InventoryPlayer player, EntityMinecartBeeHousingBase entity, boolean hasFrames) {
super(entity, player, 8, 108);
ContainerBeeHelper.addSlots(this, entity, hasFrames);
entity.getBeekeepingLogic().clearCachedValues();
}
private int beeProgress = -1;
@@ -12,10 +12,10 @@ package forestry.apiculture.inventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil;
import forestry.apiculture.multiblock.TileAlvearyHygroregulator;
import forestry.core.fluids.FluidHelper;
import forestry.core.inventory.InventoryAdapterTile;
public class InventoryHygroregulator extends InventoryAdapterTile<TileAlvearyHygroregulator> {
@@ -28,8 +28,8 @@ public class InventoryHygroregulator extends InventoryAdapterTile<TileAlvearyHyg
@Override
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
if (slotIndex == SLOT_INPUT) {
Fluid fluid = FluidHelper.getFluidInContainer(itemStack);
return tile.getTankManager().accepts(fluid);
FluidStack fluid = FluidUtil.getFluidContained(itemStack);
return tile.getTankManager().canFillFluidType(fluid);
}
return false;
}
@@ -317,12 +317,13 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
@Override
public void formatDescriptionPacket(NBTTagCompound data) {
writeToNBT(data);
beekeepingLogic.syncToClient();
beekeepingLogic.writeToNBT(data);
}
@Override
public void decodeDescriptionPacket(NBTTagCompound data) {
readFromNBT(data);
beekeepingLogic.readFromNBT(data);
}
/* IActivatable */
@@ -17,10 +17,11 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import forestry.api.core.IClimateControlled;
import forestry.api.multiblock.IAlvearyComponent;
@@ -36,7 +37,7 @@ import forestry.core.fluids.tanks.FilteredTank;
import forestry.core.inventory.IInventoryAdapter;
import forestry.core.tiles.ILiquidTankTile;
public class TileAlvearyHygroregulator extends TileAlveary implements IInventory, ILiquidTankTile, IFluidHandler, IAlvearyComponent.Climatiser {
public class TileAlvearyHygroregulator extends TileAlveary implements IInventory, ILiquidTankTile, IAlvearyComponent.Climatiser {
private final HygroregulatorRecipe[] recipes;
private final TankManager tankManager;
@@ -50,12 +51,13 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
super(BlockAlvearyType.HYGRO);
this.inventory = new InventoryHygroregulator(this);
Fluid water = Fluids.WATER.getFluid();
Fluid lava = Fluids.LAVA.getFluid();
Fluid water = FluidRegistry.WATER;
Fluid lava = FluidRegistry.LAVA;
Fluid liquidIce = Fluids.ICE.getFluid();
this.liquidTank = new FilteredTank(Constants.PROCESSOR_TANK_CAPACITY, water, lava, liquidIce);
this.liquidTank = new FilteredTank(Constants.PROCESSOR_TANK_CAPACITY).setFilters(water, lava, liquidIce);
this.tankManager = new TankManager(this, liquidTank);
this.recipes = new HygroregulatorRecipe[]{new HygroregulatorRecipe(new FluidStack(water, 1), 1, 0.01f, -0.005f),
@@ -91,7 +93,7 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
currentRecipe = getRecipe(liquidTank.getFluid());
if (currentRecipe != null) {
liquidTank.drain(currentRecipe.liquid.amount, true);
liquidTank.drainInternal(currentRecipe.liquid.amount, true);
transferTime = currentRecipe.transferTime;
}
}
@@ -150,33 +152,22 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
}
@Override
public int fill(EnumFacing from, FluidStack resource, boolean doFill) {
return tankManager.fill(from, resource, doFill);
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
if (super.hasCapability(capability, facing)) {
return true;
}
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY;
}
@Override
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) {
return tankManager.drain(from, resource, doDrain);
}
@Override
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) {
return tankManager.drain(from, maxDrain, doDrain);
}
@Override
public boolean canFill(EnumFacing from, Fluid fluid) {
return tankManager.canFill(from, fluid);
}
@Override
public boolean canDrain(EnumFacing from, Fluid fluid) {
return tankManager.canDrain(from, fluid);
}
@Override
public FluidTankInfo[] getTankInfo(EnumFacing from) {
return tankManager.getTankInfo(from);
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
if (super.hasCapability(capability, facing)) {
return super.getCapability(capability, facing);
}
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tankManager);
}
return null;
}
@Override
@@ -137,7 +137,7 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory,
int x = getPos().getX() + worldObj.rand.nextInt(40 * 2) - 40;
int z = getPos().getZ() + worldObj.rand.nextInt(40 * 2) - 40;
if (HiveDecorator.tryGenHive(worldObj, x, z, hive)) {
if (HiveDecorator.tryGenHive(worldObj, worldObj.rand, x, z, hive)) {
pendingSpawns.pop();
}
}
@@ -12,7 +12,4 @@ package forestry.apiculture.proxy;
public class ProxyApiculture {
public void initializeRendering() {
}
}
@@ -10,10 +10,10 @@
******************************************************************************/
package forestry.apiculture.proxy;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
public class ProxyApicultureClient extends ProxyApiculture {
@Override
public void initializeRendering() {
// TODO: remove unused bee entity model completely
}
public static TextureAtlasSprite beeSprite;
}
@@ -160,9 +160,4 @@ public class ModelBee extends ModelBase {
model.rotateAngleZ = z;
}
@Override
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) {
super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
}
}
@@ -69,8 +69,15 @@ public abstract class TileBeeHousingBase extends TileBase implements IBeeHousing
@Nonnull
@Override
public NBTTagCompound getUpdateTag() {
beeLogic.syncToClient();
return super.getUpdateTag();
NBTTagCompound updateTag = super.getUpdateTag();
beeLogic.writeToNBT(updateTag);
return updateTag;
}
@Override
public void handleUpdateTag(@Nonnull NBTTagCompound tag) {
super.handleUpdateTag(tag);
beeLogic.readFromNBT(tag);
}
/* ICLIMATISED */
@@ -21,6 +21,7 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.DamageSource;
@@ -74,7 +75,7 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
@Nonnull
private final IErrorLogic errorLogic;
private IBee containedBee = null;
private boolean active = true;
private boolean active = false;
private boolean angry = false;
private int calmTime;
@@ -97,7 +98,7 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
}
if (worldObj.isRemote) {
if (!updatedLight && worldObj.getWorldTime() % 20 == 0) {
if (!updatedLight && worldObj.getWorldTime() % 100 == 0) {
updatedLight = worldObj.checkLightFor(EnumSkyBlock.BLOCK, getPos());
}
if (active && worldObj.rand.nextInt(4) == 0) {
@@ -108,7 +109,7 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
} else {
boolean canWork = beeLogic.canWork(); // must be called every tick to stay updated
if (worldObj.rand.nextInt(angry ? 10 : 80) == 0) {
if (worldObj.rand.nextInt(angry ? 10 : 200) == 0) {
if (calmTime == 0) {
if (canWork) {
AxisAlignedBB boundingBox = AlleleEffect.getBounding(getContainedBee().getGenome(), this);
@@ -119,19 +120,13 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
attack(entity, 2);
}
beeLogic.doWork();
setActive(true);
} else {
setActive(false);
}
} else {
calmTime--;
if (calmTime == 0) {
setActive(true);
} else {
setActive(false);
}
}
}
setActive(calmTime == 0);
}
}
@@ -203,6 +198,11 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
setActive(false);
}
@Override
public boolean isAngry() {
return angry;
}
@Override
public void onAttack(World world, BlockPos pos, EntityPlayer player) {
if (calmTime == 0) {
@@ -231,8 +231,7 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
if (damage > 0) {
// Entities are not attacked if they wear a full set of apiarist's armor.
int count = BeeManager.armorApiaristHelper.wearsItems(entity, damageSourceBeeHive.damageType, true);
damage -= damage / 4.0f * count;
if (damage > 0) {
if (entity.worldObj.rand.nextInt(4) >= count) {
entity.attackEntityFrom(damageSourceBeeHive, damage);
}
}
@@ -258,8 +257,30 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
@Nullable
@Override
public SPacketUpdateTileEntity getUpdatePacket() {
beeLogic.syncToClient();
return super.getUpdatePacket();
return new SPacketUpdateTileEntity(pos, 0, getUpdateTag());
}
@Nonnull
@Override
public NBTTagCompound getUpdateTag() {
NBTTagCompound nbt = super.getUpdateTag();
nbt.setBoolean("active", calmTime == 0);
beeLogic.writeToNBT(nbt);
return nbt;
}
@Override
public void handleUpdateTag(@Nonnull NBTTagCompound tag) {
super.handleUpdateTag(tag);
setActive(tag.getBoolean("active"));
beeLogic.readFromNBT(tag);
}
@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {
super.onDataPacket(net, pkt);
NBTTagCompound nbt = pkt.getNbtCompound();
handleUpdateTag(nbt);
}
@Override
@@ -13,6 +13,7 @@ package forestry.apiculture.worldgen;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
@@ -52,8 +53,8 @@ public final class Hive {
return hiveDescription.getGenChance();
}
public void postGen(World world, BlockPos pos) {
hiveDescription.postGen(world, pos);
public void postGen(World world, Random rand, BlockPos pos) {
hiveDescription.postGen(world, rand, pos);
}
public boolean isGoodBiome(Biome biome) {
@@ -34,7 +34,7 @@ import forestry.core.utils.Log;
public abstract class HiveDecorator {
private static final EventType EVENT_TYPE = EnumHelper.addEnum(EventType.class, "FORESTRY_HIVES", new Class[0], new Object[0]);
private static final EventType EVENT_TYPE = EnumHelper.addEnum(EventType.class, "FORESTRY_HIVES", new Class[0]);
public static void decorateHives(IChunkGenerator chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated) {
if (!TerrainGen.populate(chunkProvider, world, rand, chunkX, chunkZ, hasVillageGenerated, EVENT_TYPE)) {
@@ -48,7 +48,7 @@ public abstract class HiveDecorator {
List<Hive> hives = PluginApiculture.hiveRegistry.getHives();
if (Config.generateBeehivesDebug) {
decorateHivesDebug(world, chunkX, chunkZ, hives);
decorateHivesDebug(world, rand, chunkX, chunkZ, hives);
return;
}
@@ -72,7 +72,7 @@ public abstract class HiveDecorator {
for (Hive hive : hives) {
if (hive.genChance() * Config.getBeehivesAmount() >= rand.nextFloat() * 100.0f) {
if (hive.isGoodBiome(biome) && hive.isGoodHumidity(humidity)) {
if (tryGenHive(world, x, z, hive)) {
if (tryGenHive(world, rand, x, z, hive)) {
return;
}
}
@@ -81,7 +81,7 @@ public abstract class HiveDecorator {
}
}
private static void decorateHivesDebug(World world, int chunkX, int chunkZ, List<Hive> hives) {
private static void decorateHivesDebug(World world, Random rand, int chunkX, int chunkZ, List<Hive> hives) {
int worldX = (chunkX << 4) + 8;
int worldZ = (chunkZ << 4) + 8;
Biome biome = world.getBiome(new BlockPos(chunkX, 0, chunkZ));
@@ -95,13 +95,13 @@ public abstract class HiveDecorator {
continue;
}
tryGenHive(world, worldX + x, worldZ + z, hive);
tryGenHive(world, rand, worldX + x, worldZ + z, hive);
}
}
}
}
public static boolean tryGenHive(World world, int x, int z, Hive hive) {
public static boolean tryGenHive(World world, Random rand, int x, int z, Hive hive) {
final BlockPos hivePos = hive.getPosForHive(world, x, z);
@@ -123,10 +123,10 @@ public abstract class HiveDecorator {
return false;
}
return setHive(world, hivePos, hive);
return setHive(world, rand, hivePos, hive);
}
private static boolean setHive(World world, BlockPos pos, Hive hive) {
private static boolean setHive(World world, Random rand, BlockPos pos, Hive hive) {
IBlockState hiveState = hive.getHiveBlockState();
Block hiveBlock = hiveState.getBlock();
boolean placed = world.setBlockState(pos, hiveState, Constants.FLAG_BLOCK_SYNC);
@@ -143,7 +143,7 @@ public abstract class HiveDecorator {
hiveBlock.onBlockAdded(world, pos, state);
if (!Config.generateBeehivesDebug) {
hive.postGen(world, pos);
hive.postGen(world, rand, pos);
}
if (Config.logHivePlacement) {
@@ -13,6 +13,7 @@ package forestry.apiculture.worldgen;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
@@ -41,23 +42,23 @@ public enum HiveDescription implements IHiveDescription {
FOREST(IHiveRegistry.HiveType.FOREST, 3.0f, BeeDefinition.FOREST, HiveManager.genHelper.tree()) {
@Override
public void postGen(World world, BlockPos pos) {
super.postGen(world, pos);
postGenFlowers(world, pos, flowerStates);
public void postGen(World world, Random rand, BlockPos pos) {
super.postGen(world, rand, pos);
postGenFlowers(world, rand, pos, flowerStates);
}
},
MEADOWS(IHiveRegistry.HiveType.MEADOWS, 1.0f, BeeDefinition.MEADOWS, HiveManager.genHelper.ground(Blocks.DIRT, Blocks.GRASS)) {
@Override
public void postGen(World world, BlockPos pos) {
super.postGen(world, pos);
postGenFlowers(world, pos, flowerStates);
public void postGen(World world, Random rand, BlockPos pos) {
super.postGen(world, rand, pos);
postGenFlowers(world, rand, pos, flowerStates);
}
},
DESERT(IHiveRegistry.HiveType.DESERT, 1.0f, BeeDefinition.MODEST, HiveManager.genHelper.ground(Blocks.DIRT, Blocks.GRASS, Blocks.SAND, Blocks.SANDSTONE)) {
@Override
public void postGen(World world, BlockPos pos) {
super.postGen(world, pos);
postGenFlowers(world, pos, cactusStates);
public void postGen(World world, Random rand, BlockPos pos) {
super.postGen(world, rand, pos);
postGenFlowers(world, rand, pos, cactusStates);
}
},
JUNGLE(IHiveRegistry.HiveType.JUNGLE, 6.0f, BeeDefinition.TROPICAL, HiveManager.genHelper.tree()),
@@ -69,21 +70,21 @@ public enum HiveDescription implements IHiveDescription {
},
SNOW(IHiveRegistry.HiveType.SNOW, 2.0f, BeeDefinition.WINTRY, HiveManager.genHelper.ground(Blocks.DIRT, Blocks.GRASS, Blocks.SNOW)) {
@Override
public void postGen(World world, BlockPos pos) {
public void postGen(World world, Random rand, BlockPos pos) {
BlockPos posAbove = pos.up();
if (world.isAirBlock(posAbove)) {
world.setBlockState(posAbove, Blocks.SNOW_LAYER.getDefaultState(), Constants.FLAG_BLOCK_SYNC);
}
postGenFlowers(world, pos, flowerStates);
postGenFlowers(world, rand, pos, flowerStates);
}
},
SWAMP(IHiveRegistry.HiveType.SWAMP, 2.0f, BeeDefinition.MARSHY, HiveManager.genHelper.ground(Blocks.DIRT, Blocks.GRASS)) {
@Override
public void postGen(World world, BlockPos pos) {
super.postGen(world, pos);
public void postGen(World world, Random rand, BlockPos pos) {
super.postGen(world, rand, pos);
postGenFlowers(world, pos, mushroomStates);
postGenFlowers(world, rand, pos, mushroomStates);
}
};
@@ -146,15 +147,15 @@ public enum HiveDescription implements IHiveDescription {
}
@Override
public void postGen(World world, BlockPos pos) {
public void postGen(World world, Random rand, BlockPos pos) {
}
protected static void postGenFlowers(World world, BlockPos hivePos, List<IBlockState> flowerStates) {
protected static void postGenFlowers(World world, Random rand, BlockPos hivePos, List<IBlockState> flowerStates) {
int plantedCount = 0;
for (int i = 0; i < 10; i++) {
int xOffset = world.rand.nextInt(8) - 4;
int zOffset = world.rand.nextInt(8) - 4;
int xOffset = rand.nextInt(8) - 4;
int zOffset = rand.nextInt(8) - 4;
BlockPos blockPos = hivePos.add(xOffset, 0, zOffset);
if ((xOffset == 0 && zOffset == 0) || !world.isBlockLoaded(blockPos)) {
continue;
@@ -165,7 +166,7 @@ public enum HiveDescription implements IHiveDescription {
continue;
}
IBlockState state = flowerStates.get(world.rand.nextInt(flowerStates.size()));
IBlockState state = flowerStates.get(rand.nextInt(flowerStates.size()));
Block block = state.getBlock();
if (!block.canPlaceBlockAt(world, blockPos)) {
continue;
@@ -12,6 +12,7 @@ package forestry.apiculture.worldgen;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
@@ -68,7 +69,7 @@ public class HiveDescriptionSwarmer implements IHiveDescription {
}
@Override
public void postGen(World world, BlockPos pos) {
public void postGen(World world, Random rand, BlockPos pos) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileHive) {
((TileHive) tile).setContained(bees);
@@ -112,7 +112,7 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
}
public static VillageApiaristHouse buildComponent(StructureVillagePieces.Start startPiece, List<StructureComponent> par1List, Random random, int structureMinX, int structureMinY, int structureMinZ, EnumFacing facing, int componentType) {
StructureBoundingBox bbox = StructureBoundingBox.getComponentToAddBoundingBox(structureMinX, structureMinY, structureMinZ, 0, 0, 0, 10, 9, 11, facing);
StructureBoundingBox bbox = StructureBoundingBox.getComponentToAddBoundingBox(structureMinX, structureMinY, structureMinZ, -4, 0, 0, 12, 9, 12, facing);
if (!canVillageGoDeeper(bbox) || StructureComponent.findIntersecting(par1List, bbox) != null) {
return null;
}
@@ -129,7 +129,7 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
return true;
}
boundingBox.offset(0, averageGroundLevel - boundingBox.maxY + 8 - 1, 0);
boundingBox.offset(0, averageGroundLevel - boundingBox.maxY + 9 - 1, 0);
}
fillWithBlocks(world, structBoundingBox, 1, 1, 1, 7, 4, 4, Blocks.AIR.getDefaultState(), Blocks.AIR.getDefaultState(), false);
@@ -71,7 +71,6 @@ import forestry.arboriculture.genetics.alleles.AlleleFruit;
import forestry.arboriculture.genetics.alleles.AlleleGrowth;
import forestry.arboriculture.genetics.alleles.AlleleLeafEffect;
import forestry.arboriculture.items.ItemCharcoal;
import forestry.arboriculture.items.ItemGermlingGE;
import forestry.arboriculture.items.ItemRegistryArboriculture;
import forestry.arboriculture.models.TextureLeaves;
import forestry.arboriculture.network.PacketRegistryArboriculture;
@@ -16,7 +16,9 @@ import java.util.Collections;
import java.util.Random;
import net.minecraft.block.BlockDoor;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.ModelBakery;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
@@ -40,7 +42,7 @@ public class BlockArbDoor extends BlockDoor implements IWoodTyped, IItemModelReg
private final EnumForestryWoodType woodType;
public BlockArbDoor(EnumForestryWoodType woodType) {
super(MaterialArbWood.ARB_WOOD);
super(Material.WOOD);
this.woodType = woodType;
setHarvestLevel("axe", 0);
@@ -50,7 +52,7 @@ public class BlockArbDoor extends BlockDoor implements IWoodTyped, IItemModelReg
@Override
@SideOnly(Side.CLIENT)
public void registerModel(Item item, IModelManager manager) {
manager.registerVariant(item, WoodHelper.getResourceLocations(this));
ModelBakery.registerItemVariants(item, WoodHelper.getResourceLocations(this));
manager.registerItemModel(item, new WoodHelper.WoodMeshDefinition(this));
}
@@ -20,6 +20,7 @@ import net.minecraft.block.BlockPlanks.EnumType;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.ModelBakery;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -59,11 +60,6 @@ public class BlockForestryFenceGate<T extends Enum<T> & IWoodType> extends Block
setCreativeTab(Tabs.tabArboriculture);
}
@Override
public Material getMaterial(IBlockState state) {
return MaterialArbWood.ARB_WOOD;
}
@Override
public boolean isFireproof() {
return fireproof;
@@ -124,7 +120,7 @@ public class BlockForestryFenceGate<T extends Enum<T> & IWoodType> extends Block
@SideOnly(Side.CLIENT)
@Override
public void registerModel(Item item, IModelManager manager) {
manager.registerVariant(item, WoodHelper.getResourceLocations(this));
ModelBakery.registerItemVariants(item, WoodHelper.getResourceLocations(this));
manager.registerItemModel(item, new WoodMeshDefinition(this));
}
}
@@ -214,17 +214,16 @@ public class BlockForestryLeaves extends BlockLeaves implements ITileEntityProvi
@Override
public List<ItemStack> onSheared(ItemStack item, IBlockAccess world, BlockPos pos, int fortune) {
String speciesUid = TreeDefinition.Oak.getUID();
TileLeaves leaves = TileUtil.getTile(world, pos, TileLeaves.class);
if (leaves == null) {
return null;
if (leaves != null) {
ITree tree = leaves.getTree();
if (tree != null) {
speciesUid = tree.getGenome().getPrimary().getUID();
}
}
ITree tree = leaves.getTree();
if (tree == null) {
return null;
}
String speciesUid = tree.getGenome().getPrimary().getUID();
return Collections.singletonList(PluginArboriculture.blocks.getDecorativeLeaves(speciesUid));
}
@@ -7,6 +7,7 @@ import java.util.Collections;
import net.minecraft.block.BlockStairs;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.ModelBakery;
import net.minecraft.item.Item;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
@@ -38,16 +39,11 @@ public class BlockForestryStairs<T extends Enum<T> & IWoodType> extends BlockSta
setHarvestLevel("axe", 0);
}
@Override
public Material getMaterial(IBlockState state) {
return MaterialArbWood.ARB_WOOD;
}
/* MODELS */
@SideOnly(Side.CLIENT)
@Override
public void registerModel(Item item, IModelManager manager) {
manager.registerVariant(item, WoodHelper.getResourceLocations(this));
ModelBakery.registerItemVariants(item, WoodHelper.getResourceLocations(this));
manager.registerItemModel(item, new WoodHelper.WoodMeshDefinition(this));
}
@@ -2,6 +2,7 @@ package forestry.arboriculture.blocks;
import com.google.common.collect.Lists;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.List;
@@ -18,9 +19,11 @@ import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.particle.ParticleManager;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Enchantments;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -44,7 +47,6 @@ import net.minecraftforge.common.property.IUnlistedProperty;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.arboriculture.EnumGermlingType;
import forestry.api.arboriculture.EnumPileType;
import forestry.api.arboriculture.IAlleleTreeSpecies;
import forestry.api.arboriculture.ITree;
@@ -189,7 +191,7 @@ public abstract class BlockPile extends BlockStructure implements ITileEntityPro
@Override
public RayTraceResult collisionRayTrace(IBlockState blockState, World worldIn, BlockPos pos, Vec3d start, Vec3d end){
List<RayTraceResult> list = Lists.<RayTraceResult>newArrayList();
List<RayTraceResult> list = Lists.newArrayList();
for (AxisAlignedBB axisalignedbb : getCollisionBoxList(this.getActualState(blockState, worldIn, pos)))
{
@@ -226,7 +228,7 @@ public abstract class BlockPile extends BlockStructure implements ITileEntityPro
}
private static List<AxisAlignedBB> getCollisionBoxList(IBlockState state){
List<AxisAlignedBB> list = Lists.<AxisAlignedBB>newArrayList();
List<AxisAlignedBB> list = Lists.newArrayList();
EnumPilePosition position = state.getValue(PILE_POSITION);
if(position != EnumPilePosition.INTERIOR){
@@ -309,15 +311,15 @@ public abstract class BlockPile extends BlockStructure implements ITileEntityPro
float f2 = pos.getZ() + 0.5F;
float f3 = 0.52F;
float f4 = rand.nextFloat() * 0.6F - 0.3F;
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, f + f3 - 0.5, f1 + 0.5, f2 + f4, 0.0D, 0.0D, 0.0D, new int[0]);
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, f + f3 - 0.5, f1 + 0.5, f2 + f4, 0.0D, 0.0D, 0.0D);
}
}
@SideOnly(Side.CLIENT)
@Override
public void getSubBlocks(Item item, CreativeTabs tab, List subItems) {
public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> subItems) {
if(getPileType() == EnumPileType.WOOD){
List<ItemStack> woodPiles = new ArrayList();
List<ItemStack> woodPiles = new ArrayList<>();
for(ITree tree : TreeManager.treeRoot.getIndividualTemplates()) {
woodPiles.add(createWoodPile(tree));
}
@@ -383,35 +385,49 @@ public abstract class BlockPile extends BlockStructure implements ITileEntityPro
@Override
public void onBlockHarvested(World world, BlockPos pos, IBlockState state, EntityPlayer player) {
if (!world.isRemote) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof ICharcoalPileComponent) {
ICharcoalPileComponent pile = (ICharcoalPileComponent) tile;
ArrayList<ItemStack> list = new ArrayList<ItemStack>();
if (getPileType() == EnumPileType.ASH) {
if(pile.getTree() != null){
ItemStack charcoal = new ItemStack(PluginArboriculture.items.charcoal, pile.getTree().getGenome().getCarbonization(), pile.getTree().getGenome().getCombustibility());
list.add(charcoal);
list.add(new ItemStack(PluginCore.items.ash, 3));
}else{
list.add(new ItemStack(Blocks.DIRT, 2));
list.add(new ItemStack(PluginCore.items.ash, 2));
}
} else if (getPileType() == EnumPileType.DIRT) {
list.add(new ItemStack(this));
} else {
list.add(createWoodPile(pile.getTree()));
}
drop.set(list);
}
int fortune = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, player.getActiveItemStack());
drop.set(getPileDrop(world, pos, state, fortune));
}
}
@Nonnull
@Override
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
List<ItemStack> drops = drop.get();
drop.remove();
// not harvested, get drops normally
if (drops == null) {
drops = getPileDrop(world, pos, state, fortune);
}
return drops;
}
@Nonnull
private List<ItemStack> getPileDrop(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
List<ItemStack> list = new ArrayList<>();
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof ICharcoalPileComponent) {
ICharcoalPileComponent pile = (ICharcoalPileComponent) tile;
if (getPileType() == EnumPileType.ASH) {
if (pile.getTree() != null) {
ItemStack charcoal = new ItemStack(PluginArboriculture.items.charcoal, pile.getTree().getGenome().getCarbonization(), pile.getTree().getGenome().getCombustibility());
list.add(charcoal);
list.add(new ItemStack(PluginCore.items.ash, 3));
} else {
list.add(new ItemStack(Blocks.DIRT, 2));
list.add(new ItemStack(PluginCore.items.ash, 2));
}
} else if (getPileType() == EnumPileType.DIRT) {
list.add(new ItemStack(this));
} else {
list.add(createWoodPile(pile.getTree()));
}
}
return list;
}
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state) {
@@ -1,15 +0,0 @@
package forestry.arboriculture.blocks;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
public class MaterialArbWood extends Material {
public static final Material ARB_WOOD = new MaterialArbWood();
private MaterialArbWood() {
super(MapColor.WOOD);
setBurning();
}
}
@@ -12,6 +12,7 @@ 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;
@@ -35,7 +36,6 @@ import forestry.api.core.Tabs;
import forestry.arboriculture.IWoodTyped;
import forestry.arboriculture.PluginArboriculture;
import forestry.arboriculture.WoodHelper;
import forestry.arboriculture.blocks.MaterialArbWood;
import forestry.arboriculture.blocks.WoodTypeStateMapper;
import forestry.arboriculture.blocks.property.PropertyWoodType;
import forestry.core.proxy.Proxies;
@@ -48,7 +48,7 @@ public abstract class BlockForestryFence<T extends Enum<T> & IWoodType> extends
private final int blockNumber;
protected BlockForestryFence(boolean fireproof, int blockNumber) {
super(MaterialArbWood.ARB_WOOD, BlockPlanks.EnumType.OAK.getMapColor());
super(Material.WOOD, BlockPlanks.EnumType.OAK.getMapColor());
this.fireproof = fireproof;
this.blockNumber = blockNumber;
@@ -104,7 +104,7 @@ public abstract class BlockForestryFence<T extends Enum<T> & IWoodType> extends
@SideOnly(Side.CLIENT)
@Override
public void registerModel(Item item, IModelManager manager) {
manager.registerVariant(item, WoodHelper.getResourceLocations(this));
ModelBakery.registerItemVariants(item, WoodHelper.getResourceLocations(this));
manager.registerItemModel(item, new WoodHelper.WoodMeshDefinition(this));
}
@@ -8,6 +8,7 @@ import net.minecraft.block.BlockLog;
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;
@@ -29,7 +30,6 @@ import forestry.api.core.IStateMapperRegister;
import forestry.api.core.Tabs;
import forestry.arboriculture.IWoodTyped;
import forestry.arboriculture.WoodHelper;
import forestry.arboriculture.blocks.MaterialArbWood;
import forestry.arboriculture.blocks.WoodTypeStateMapper;
import forestry.arboriculture.blocks.property.PropertyWoodType;
import forestry.core.proxy.Proxies;
@@ -67,11 +67,6 @@ public abstract class BlockForestryLog<T extends Enum<T> & IWoodType> extends Bl
return blockNumber;
}
@Override
public final Material getMaterial(IBlockState state) {
return MaterialArbWood.ARB_WOOD;
}
private static EnumAxis getAxis(int meta) {
switch (meta & 12) {
case 0:
@@ -187,7 +182,7 @@ public abstract class BlockForestryLog<T extends Enum<T> & IWoodType> extends Bl
@SideOnly(Side.CLIENT)
@Override
public final void registerModel(Item item, IModelManager manager) {
manager.registerVariant(item, WoodHelper.getResourceLocations(this));
ModelBakery.registerItemVariants(item, WoodHelper.getResourceLocations(this));
manager.registerItemModel(item, new WoodHelper.WoodMeshDefinition(this));
}
@@ -6,8 +6,10 @@ import java.util.List;
import net.minecraft.block.Block;
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;
@@ -29,7 +31,6 @@ import forestry.api.core.IStateMapperRegister;
import forestry.api.core.Tabs;
import forestry.arboriculture.IWoodTyped;
import forestry.arboriculture.WoodHelper;
import forestry.arboriculture.blocks.MaterialArbWood;
import forestry.arboriculture.blocks.WoodTypeStateMapper;
import forestry.arboriculture.blocks.property.PropertyWoodType;
import forestry.core.proxy.Proxies;
@@ -42,7 +43,7 @@ public abstract class BlockForestryPlanks<T extends Enum<T> & IWoodType> extends
private final int blockNumber;
protected BlockForestryPlanks(boolean fireproof, int blockNumber) {
super(MaterialArbWood.ARB_WOOD);
super(Material.WOOD);
this.fireproof = fireproof;
this.blockNumber = blockNumber;
@@ -120,7 +121,7 @@ public abstract class BlockForestryPlanks<T extends Enum<T> & IWoodType> extends
@SideOnly(Side.CLIENT)
@Override
public void registerModel(Item item, IModelManager manager) {
manager.registerVariant(item, WoodHelper.getResourceLocations(this));
ModelBakery.registerItemVariants(item, WoodHelper.getResourceLocations(this));
manager.registerItemModel(item, new WoodHelper.WoodMeshDefinition(this));
}
@@ -7,9 +7,11 @@ import java.util.Random;
import net.minecraft.block.BlockSlab;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
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.item.Item;
import net.minecraft.item.ItemStack;
@@ -30,7 +32,6 @@ import forestry.api.core.IStateMapperRegister;
import forestry.api.core.Tabs;
import forestry.arboriculture.IWoodTyped;
import forestry.arboriculture.WoodHelper;
import forestry.arboriculture.blocks.MaterialArbWood;
import forestry.arboriculture.blocks.WoodTypeStateMapper;
import forestry.arboriculture.blocks.property.PropertyWoodType;
import forestry.core.proxy.Proxies;
@@ -43,7 +44,7 @@ public abstract class BlockForestrySlab<T extends Enum<T> & IWoodType> extends B
private final int blockNumber;
protected BlockForestrySlab(boolean fireproof, int blockNumber) {
super(MaterialArbWood.ARB_WOOD);
super(Material.WOOD);
this.fireproof = fireproof;
this.blockNumber = blockNumber;
@@ -132,7 +133,7 @@ public abstract class BlockForestrySlab<T extends Enum<T> & IWoodType> extends B
@SideOnly(Side.CLIENT)
@Override
public void registerModel(Item item, IModelManager manager) {
manager.registerVariant(item, WoodHelper.getResourceLocations(this));
ModelBakery.registerItemVariants(item, WoodHelper.getResourceLocations(this));
manager.registerItemModel(item, new WoodHelper.WoodMeshDefinition(this));
}
@@ -291,6 +291,11 @@ public class TreeAlyzerPlugin implements IAlyzerPlugin {
textLayout.endPage();
}
@Override
public Map<String, ItemStack> getIconStacks() {
return iconStacks;
}
@Override
public List<String> getHints() {
return Config.hints.get("treealyzer");
@@ -73,14 +73,16 @@ public class ItemBlockPile<B extends Block> extends ItemBlockForestry<Block> {
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState) {
boolean placed = super.placeBlockAt(stack, player, world, pos, side, hitX, hitY, hitZ, newState);
if(block == PluginArboriculture.blocks.piles.get(EnumPileType.WOOD)){
if (block.hasTileEntity(newState)) {
if (stack.hasTagCompound()) {
TilePile tile = TileUtil.getTile(world, pos, TilePile.class);
if (tile != null) {
tile.readFromNBT(stack.getTagCompound());
tile.setPos(pos);
tile.markDirty();
if (placed) {
if (block == PluginArboriculture.blocks.piles.get(EnumPileType.WOOD)) {
if (block.hasTileEntity(newState)) {
if (stack.hasTagCompound()) {
TilePile tile = TileUtil.getTile(world, pos, TilePile.class);
if (tile != null) {
tile.readFromNBT(stack.getTagCompound());
tile.setPos(pos);
tile.markDirty();
}
}
}
}
@@ -2,11 +2,8 @@ package forestry.arboriculture.items;
import java.util.List;
import forestry.api.arboriculture.ITree;
import forestry.api.arboriculture.TreeManager;
import forestry.api.core.IModelManager;
import forestry.api.core.Tabs;
import forestry.core.genetics.alleles.AlleleHelper;
import forestry.core.items.ItemForestry;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
@@ -92,14 +92,14 @@ public class ModelLeaves extends ModelBlockDefault<BlockForestryLeaves> {
TextureAtlasSprite leafSprite = map.getAtlasSprite(leafSpriteLocation.toString());
// Render the plain leaf block.
baker.addBlockModel(block, Block.FULL_BLOCK_AABB, pos, leafSprite, 0);
baker.addBlockModel(block, Block.FULL_BLOCK_AABB, null, leafSprite, 0);
// Render overlay for fruit leaves.
ResourceLocation fruitSpriteLocation = tile.getFruitSprite();
if (fruitSpriteLocation != null) {
TextureAtlasSprite fruitSprite = map.getAtlasSprite(fruitSpriteLocation.toString());
baker.addBlockModel(block, Block.FULL_BLOCK_AABB, pos, fruitSprite, 1);
baker.addBlockModel(block, Block.FULL_BLOCK_AABB, null, fruitSprite, 1);
}
// Set the particle sprite
@@ -12,10 +12,14 @@ package forestry.arboriculture.models;
import javax.annotation.Nonnull;
import net.minecraft.client.renderer.block.model.ModelBakery;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.arboriculture.EnumGermlingType;
import forestry.api.arboriculture.IGermlingModelProvider;
import forestry.api.core.IModelManager;
@@ -31,14 +35,15 @@ public class ModelProviderGermling implements IGermlingModelProvider {
this.name = modelUid.substring("forestry.".length());
}
@SideOnly(Side.CLIENT)
@Override
public void registerModels(Item item, IModelManager manager, EnumGermlingType type) {
if(type == EnumGermlingType.SAPLING){
germlingModel = manager.getModelLocation("germlings/sapling." + name);
manager.registerVariant(item, new ResourceLocation("forestry:germlings/sapling." + name));
ModelBakery.registerItemVariants(item, new ResourceLocation("forestry:germlings/sapling." + name));
}else if(type == EnumGermlingType.POLLEN){
pollenModel = manager.getModelLocation("pollen");
manager.registerVariant(item, new ResourceLocation("forestry:pollen"));
ModelBakery.registerItemVariants(item, new ResourceLocation("forestry:pollen"));
}
}
@@ -10,6 +10,8 @@
******************************************************************************/
package forestry.arboriculture.render;
import javax.annotation.Nonnull;
import static forestry.arboriculture.multiblock.EnumPilePosition.BACK;
import static forestry.arboriculture.multiblock.EnumPilePosition.CORNER_BACK_LEFT;
import static forestry.arboriculture.multiblock.EnumPilePosition.CORNER_BACK_RIGHT;
@@ -46,8 +48,12 @@ public class CharcoalPileRenderer extends TileEntitySpecialRenderer<TilePile> {
}
@Override
public void renderTileEntityAt(TilePile pile, double x, double y, double z, float p_147500_8_, int destroyStage) {
public void renderTileEntityAt(@Nonnull TilePile pile, double x, double y, double z, float p_147500_8_, int destroyStage) {
IBlockState state = pile.getWorld().getBlockState(pile.getPos());
if (!(state.getBlock() instanceof BlockPile)) {
return;
}
EnumPilePosition pilePosition = state.getValue(BlockPile.PILE_POSITION);
MultiblockLogic<ICharcoalPileControllerInternal> logic = pile.getMultiblockLogic();
if (pilePosition != EnumPilePosition.INTERIOR && logic.isConnected() && logic.getController() != null) {
@@ -29,13 +29,6 @@ public class WorldGenBalsa extends WorldGenTree {
super(tree, 6, 6);
}
@Nonnull
@Override
public Set<BlockPos> generateTrunk(World world, Random rand, TreeBlockTypeLog wood, BlockPos startPos) {
WorldGenHelper.generateTreeTrunk(world, rand, wood, startPos, height, girth, 0, 0, null, 0);
return Collections.emptySet();
}
@Override
protected void generateLeaves(World world, Random rand, TreeBlockTypeLeaf leaf, List<BlockPos> branchEnds, BlockPos startPos) {
BlockPos.MutableBlockPos leafCenter = new BlockPos.MutableBlockPos(startPos.add(0, height, 0));
@@ -28,13 +28,6 @@ public class WorldGenDate extends WorldGenTree {
super(tree, 6, 2);
}
@Nonnull
@Override
public Set<BlockPos> generateTrunk(World world, Random rand, TreeBlockTypeLog wood, BlockPos startPos) {
WorldGenHelper.generateTreeTrunk(world, rand, wood, startPos, height, girth, 0, 0, null, 0);
return Collections.emptySet();
}
@Override
protected void generateLeaves(World world, Random rand, TreeBlockTypeLeaf leaf, List<BlockPos> branchEnds, BlockPos startPos) {
int leafSpawn = height + 1;
@@ -28,13 +28,6 @@ public class WorldGenLarch extends WorldGenTree {
super(tree, 6, 5);
}
@Nonnull
@Override
public Set<BlockPos> generateTrunk(World world, Random rand, TreeBlockTypeLog wood, BlockPos startPos) {
WorldGenHelper.generateTreeTrunk(world, rand, wood, startPos, height, girth, 0, 0, null, 0);
return Collections.emptySet();
}
@Override
protected void generateLeaves(World world, Random rand, TreeBlockTypeLeaf leaf, List<BlockPos> branchEnds, BlockPos startPos) {
int leafSpawn = height + 1;
@@ -28,13 +28,6 @@ public class WorldGenLemon extends WorldGenTree {
super(tree, 6, 3);
}
@Nonnull
@Override
public Set<BlockPos> generateTrunk(World world, Random rand, TreeBlockTypeLog wood, BlockPos startPos) {
WorldGenHelper.generateTreeTrunk(world, rand, wood, startPos, height, girth, 0, 0, null, 0);
return Collections.emptySet();
}
@Override
protected void generateLeaves(World world, Random rand, TreeBlockTypeLeaf leaf, List<BlockPos> branchEnds, BlockPos startPos) {
int yCenter = height - girth;
@@ -28,13 +28,6 @@ public class WorldGenPlum extends WorldGenTree {
super(tree, 6, 3);
}
@Nonnull
@Override
public Set<BlockPos> generateTrunk(World world, Random rand, TreeBlockTypeLog wood, BlockPos startPos) {
WorldGenHelper.generateTreeTrunk(world, rand, wood, startPos, height, girth, 0, 0, null, 0);
return Collections.emptySet();
}
@Override
protected void generateLeaves(World world, Random rand, TreeBlockTypeLeaf leaf, List<BlockPos> branchEnds, BlockPos startPos) {
int yCenter = height - girth;
@@ -28,13 +28,6 @@ public class WorldGenPoplar extends WorldGenTree {
super(tree, 8, 3);
}
@Nonnull
@Override
public Set<BlockPos> generateTrunk(World world, Random rand, TreeBlockTypeLog wood, BlockPos startPos) {
WorldGenHelper.generateTreeTrunk(world, rand, wood, startPos, height, girth, 0, 0, null, 0);
return Collections.emptySet();
}
@Override
protected void generateLeaves(World world, Random rand, TreeBlockTypeLeaf leaf, List<BlockPos> branchEnds, BlockPos startPos) {
int leafSpawn = height + 1;
+10 -5
View File
@@ -26,11 +26,14 @@ import net.minecraft.world.storage.loot.functions.LootFunctionManager;
import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fml.common.IFuelHandler;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.RecipeSorter;
import forestry.api.circuits.ChipsetManager;
import forestry.api.core.ForestryAPI;
@@ -48,7 +51,6 @@ import forestry.core.commands.CommandPlugins;
import forestry.core.commands.RootCommand;
import forestry.core.config.Config;
import forestry.core.config.Constants;
import forestry.core.fluids.Fluids;
import forestry.core.genetics.alleles.AlleleFactory;
import forestry.core.genetics.alleles.AlleleHelper;
import forestry.core.genetics.alleles.AlleleRegistry;
@@ -61,6 +63,7 @@ import forestry.core.network.IPacketRegistry;
import forestry.core.network.PacketRegistryCore;
import forestry.core.proxy.Proxies;
import forestry.core.recipes.RecipeUtil;
import forestry.core.recipes.ShapedRecipeCustom;
import forestry.core.render.TextureManager;
import forestry.core.utils.ClimateUtil;
import forestry.core.utils.ForestryModEnvWarningCallable;
@@ -133,6 +136,8 @@ public class PluginCore extends BlankForestryPlugin {
AlleleHelper.instance.init();
Proxies.render.initRendering();
RecipeSorter.register("forestry:shaped", ShapedRecipeCustom.class, RecipeSorter.Category.SHAPED, "");
}
@Override
@@ -261,7 +266,7 @@ public class PluginCore extends BlankForestryPlugin {
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.FACTORY)) {
// / CARPENTER
RecipeManagers.carpenterManager.addRecipe(100, Fluids.WATER.getFluid(2000), null, PluginCore.items.portableAlyzer.getItemStack(),
RecipeManagers.carpenterManager.addRecipe(100, new FluidStack(FluidRegistry.WATER, 2000), null, PluginCore.items.portableAlyzer.getItemStack(),
"X#X", "X#X", "RDR",
'#', OreDictUtil.PANE_GLASS,
'X', OreDictUtil.INGOT_TIN,
@@ -336,9 +341,9 @@ public class PluginCore extends BlankForestryPlugin {
int bogEarthOutputCan = ForestryAPI.activeMode.getIntegerSetting("recipe.output.bogearth.can");
if (bogEarthOutputCan > 0) {
ItemStack bogEarth = blocks.bogEarth.get(BlockBogEarth.SoilType.BOG_EARTH, bogEarthOutputCan);
ItemStack canWater = PluginFluids.items.getContainer(EnumContainerType.CAN, Fluids.WATER).getItemStack();
ItemStack waxCapsuleWater = PluginFluids.items.getContainer(EnumContainerType.CAPSULE, Fluids.WATER).getItemStack();
ItemStack refractoryWater = PluginFluids.items.getContainer(EnumContainerType.REFRACTORY, Fluids.WATER).getItemStack();
ItemStack canWater = PluginFluids.items.getContainer(EnumContainerType.CAN, FluidRegistry.WATER);
ItemStack waxCapsuleWater = PluginFluids.items.getContainer(EnumContainerType.CAPSULE, FluidRegistry.WATER);
ItemStack refractoryWater = PluginFluids.items.getContainer(EnumContainerType.REFRACTORY, FluidRegistry.WATER);
RecipeUtil.addRecipe(bogEarth, "#Y#", "YXY", "#Y#", '#', Blocks.DIRT, 'X', canWater, 'Y', OreDictUtil.SAND);
RecipeUtil.addRecipe(bogEarth, "#Y#", "YXY", "#Y#", '#', Blocks.DIRT, 'X', waxCapsuleWater, 'Y', OreDictUtil.SAND);
RecipeUtil.addRecipe(bogEarth, "#Y#", "YXY", "#Y#", '#', Blocks.DIRT, 'X', refractoryWater, 'Y', OreDictUtil.SAND);
+10 -27
View File
@@ -12,13 +12,12 @@ package forestry.core;
import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fml.common.registry.GameData;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import net.minecraftforge.fml.common.registry.GameRegistry;
import forestry.api.core.ForestryAPI;
@@ -28,9 +27,6 @@ import forestry.api.recipes.RecipeManagers;
import forestry.core.config.Config;
import forestry.core.config.Constants;
import forestry.core.fluids.Fluids;
import forestry.core.fluids.LiquidRegistryHelper;
import forestry.core.items.EnumContainerType;
import forestry.core.items.ItemLiquidContainer;
import forestry.core.items.ItemRegistryFluids;
import forestry.core.proxy.Proxies;
import forestry.core.utils.Log;
@@ -68,14 +64,20 @@ public class PluginFluids extends BlankForestryPlugin {
if (fluidBlock != null) {
String name = "fluid." + forestryFluid.getTag();
fluidBlock.setUnlocalizedName("forestry." + name);
GameRegistry.registerBlock(fluidBlock, ItemBlock.class, name);
fluidBlock.setRegistryName(name);
GameRegistry.register(fluidBlock);
ItemBlock itemBlock = new ItemBlock(fluidBlock);
itemBlock.setRegistryName(name);
GameRegistry.register(itemBlock);
Proxies.render.registerFluidStateMapper(fluidBlock, forestryFluid);
if (forestryFluid.getOtherContainers().isEmpty()) {
FluidRegistry.addBucketForFluid(fluid);
}
}
} else {
ResourceLocation resourceLocation = GameData.getBlockRegistry().getNameForObject(fluidBlock);
ResourceLocation resourceLocation = ForgeRegistries.BLOCKS.getKey(fluidBlock);
Log.warning("Pre-existing {} fluid block detected, deferring to {}:{}, "
+ "this may cause issues if the server/client have different mod load orders, "
+ "recommended that you disable all but one instance of {} fluid blocks via your configs.", fluid.getName(), resourceLocation.getResourceDomain(), resourceLocation.getResourcePath(), fluid.getName());
@@ -90,7 +92,7 @@ public class PluginFluids extends BlankForestryPlugin {
@Override
public void registerItemsAndBlocks() {
for (Fluids fluidType : Fluids.FORESTRY_FLUIDs) {
for (Fluids fluidType : Fluids.values()) {
createFluid(fluidType);
}
@@ -99,25 +101,6 @@ public class PluginFluids extends BlankForestryPlugin {
@Override
public void doInit() {
for (Fluids fluidType : Fluids.values()) {
if (fluidType.getFluid() == null) {
continue;
}
for (EnumContainerType type : EnumContainerType.values()) {
ItemLiquidContainer container = items.getContainer(type, fluidType);
if (container == null) {
continue;
}
LiquidRegistryHelper.registerLiquidContainer(fluidType, container.getItemStack());
}
for (ItemStack filledContainer : fluidType.getOtherContainers()) {
LiquidRegistryHelper.registerLiquidContainer(fluidType, filledContainer);
}
}
if (RecipeManagers.squeezerManager != null) {
RecipeManagers.squeezerManager.addContainerRecipe(10, items.canEmpty.getItemStack(), PluginCore.items.ingotTin.copy(), 0.05f);
RecipeManagers.squeezerManager.addContainerRecipe(10, items.waxCapsuleEmpty.getItemStack(), PluginCore.items.beeswax.getItemStack(), 0.10f);
@@ -20,7 +20,6 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.client.particle.ParticleManager;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -40,7 +39,9 @@ import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World;
import net.minecraftforge.fluids.IFluidHandler;
import net.minecraftforge.fluids.FluidUtil;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@@ -51,7 +52,6 @@ import forestry.api.core.IStateMapperRegister;
import forestry.api.core.ITextureManager;
import forestry.core.access.IAccessHandler;
import forestry.core.circuits.ISocketable;
import forestry.core.fluids.FluidHelper;
import forestry.core.proxy.Proxies;
import forestry.core.render.MachineParticleCallback;
import forestry.core.render.MachineStateMapper;
@@ -124,6 +124,14 @@ public class BlockBase<P extends Enum<P> & IBlockType & IStringSerializable> ext
return definition.getBoundingBox(pos, blockState);
}
@Nonnull
@Override
@SideOnly(Side.CLIENT)
public AxisAlignedBB getSelectedBoundingBox(IBlockState state, World worldIn, BlockPos pos) {
IMachineProperties definition = getDefinition();
return definition.getBoundingBox(pos, state).offset(pos);
}
@Override
public RayTraceResult collisionRayTrace(IBlockState blockState, World worldIn, BlockPos pos, Vec3d start, Vec3d end) {
IMachineProperties definition = getDefinition();
@@ -139,10 +147,6 @@ public class BlockBase<P extends Enum<P> & IBlockType & IStringSerializable> ext
/* INTERACTION */
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
if (playerIn.isSneaking()) {
return false;
}
TileBase tile = TileUtil.getTile(worldIn, pos, TileBase.class);
if (tile == null) {
return false;
@@ -154,9 +158,12 @@ public class BlockBase<P extends Enum<P> & IBlockType & IStringSerializable> ext
IAccessHandler access = tile.getAccessHandler();
if (heldItem != null && heldItem.getItem() != Items.BUCKET && tile instanceof IFluidHandler && access.allowsAlteration(playerIn)) {
if (FluidHelper.handleRightClick((IFluidHandler) tile, side, playerIn, true, tile.canDrainWithBucket())) {
return true;
if (!playerIn.isSneaking()) {
if (tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side)) {
IFluidHandler tileFluidHandler = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side);
if (FluidUtil.interactWithFluidHandler(heldItem, tileFluidHandler, playerIn)) {
return true;
}
}
}
@@ -10,8 +10,6 @@
******************************************************************************/
package forestry.core.blocks;
import javax.annotation.Nonnull;
import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
@@ -20,7 +18,6 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.oredict.OreDictionary;
import forestry.core.proxy.Proxies;
import forestry.core.utils.OreDictUtil;
import forestry.plugins.PluginManager;
public abstract class BlockRegistry {
@@ -35,7 +35,6 @@ import forestry.api.core.IItemModelRegister;
import forestry.api.core.IModelManager;
import forestry.core.CreativeTabForestry;
import forestry.core.PluginCore;
import forestry.core.utils.OreDictUtil;
public class BlockResourceOre extends Block implements IItemModelRegister, IBlockWithMeta {
public static final PropertyEnum<EnumResourceType> ORE_RESOURCES = PropertyEnum.create("resource", EnumResourceType.class, new Predicate<EnumResourceType>(){
@@ -119,7 +119,7 @@ public final class CommandSaveStats extends SubCommand {
}
}
File file = new File(Proxies.common.getForestryRoot(), "config/" + Constants.MOD_ID + "/stats/" + player.getDisplayName() + '-' + saveHelper.getFileSuffix() + ".log");
File file = new File(Proxies.common.getForestryRoot(), "config/" + Constants.MOD_ID + "/stats/" + player.getDisplayNameString() + '-' + saveHelper.getFileSuffix() + ".log");
try {
File folder = file.getParentFile();
if (folder != null && !folder.exists()) {
@@ -242,8 +242,8 @@ public class Config {
private static void loadConfigFluids(File configFile) {
configFluid = new LocalizedConfiguration(configFile, "1.0.0");
for (Fluids fluid : Fluids.FORESTRY_FLUIDs) {
for (Fluids fluid : Fluids.values()) {
String fluidName = Translator.translateToLocal("fluid." + fluid.getTag());
boolean enabledFluid = !Config.disabledFluids.contains(fluid.getTag());
@@ -297,7 +297,7 @@ public class Config {
try {
InputStream hintStream = Config.class.getResourceAsStream("/config/forestry/hints.properties");
prop.load(hintStream);
} catch (IOException e) {
} catch (IOException | NullPointerException e) {
Log.error("Failed to load hints file.", e);
}
@@ -13,6 +13,7 @@ package forestry.core.config;
import net.minecraft.util.ResourceLocation;
import forestry.api.core.IForestryConstants;
import net.minecraftforge.fluids.Fluid;
public class Constants implements IForestryConstants {
// System
@@ -25,7 +26,6 @@ public class Constants implements IForestryConstants {
public static final int FLAG_BLOCK_UPDATE = 1;
public static final int FLAG_BLOCK_SYNC = 2;
public static final int BUCKET_VOLUME = 1000;
public static final int FLUID_PER_HONEY_DROP = 100;
public static final int[] SLOTS_NONE = new int[0];
@@ -63,7 +63,7 @@ public class Constants implements IForestryConstants {
public static final int APIARY_BREEDING_TIME = 100;
// Energy
public static final int ENGINE_TANK_CAPACITY = 10 * BUCKET_VOLUME;
public static final int ENGINE_TANK_CAPACITY = 10 * Fluid.BUCKET_VOLUME;
public static final int ENGINE_CYCLE_DURATION_WATER = 1000;
public static final int ENGINE_CYCLE_DURATION_JUICE = 2500;
public static final int ENGINE_CYCLE_DURATION_HONEY = 2500;
@@ -101,7 +101,7 @@ public class Constants implements IForestryConstants {
public static final int ENGINE_TIN_MAX_EU_BATTERY = 100;
// Factory
public static final int PROCESSOR_TANK_CAPACITY = 10 * BUCKET_VOLUME;
public static final int PROCESSOR_TANK_CAPACITY = 10 * Fluid.BUCKET_VOLUME;
public static final int MACHINE_MAX_ENERGY = 5000;
@@ -117,7 +117,7 @@ public class Constants implements IForestryConstants {
public static final float ICE_COOLING_MULTIPLIER = 6f; // multiple of water's cooling value
// Storage
public static final int RAINTANK_TANK_CAPACITY = 30 * BUCKET_VOLUME;
public static final int RAINTANK_TANK_CAPACITY = 30 * Fluid.BUCKET_VOLUME;
public static final int RAINTANK_AMOUNT_PER_UPDATE = 10;
public static final int RAINTANK_FILLING_TIME = 12;
public static final int CARPENTER_CRATING_CYCLES = 5;
@@ -33,11 +33,6 @@ public abstract class EntitySelector<T extends Entity> implements Predicate<T> {
T castEntity = entityClass.cast(entity);
return isEntityApplicableTyped(castEntity);
}
@Override
public boolean equals(Object obj) {
return super.equals(obj);
}
protected abstract boolean isEntityApplicableTyped(T entity);
}
@@ -10,7 +10,6 @@
******************************************************************************/
package forestry.core.entities;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLiquid;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
@@ -27,7 +26,9 @@ public class ParticleColoredDripParticle extends Particle {
private int bobTimer;
public ParticleColoredDripParticle(World world, double x, double y, double z, float red, float green, float blue) {
super(world, x, y, z);
super(world, x, y, z, 0.0D, 0.0D, 0.0D);
this.motionX = this.motionY = this.motionZ = 0.0D;
this.particleRed = red;
this.particleGreen = green;
this.particleBlue = blue;
@@ -37,6 +38,7 @@ public class ParticleColoredDripParticle extends Particle {
this.particleGravity = 0.06F;
this.bobTimer = 40;
this.particleMaxAge = (int) (64.0D / (Math.random() * 0.8D + 0.2D));
this.motionX = this.motionY = this.motionZ = 0.0D;
}
/**
@@ -74,15 +76,21 @@ public class ParticleColoredDripParticle extends Particle {
this.motionX *= 0.699999988079071D;
this.motionZ *= 0.699999988079071D;
}
IBlockState state = this.worldObj.getBlockState(new BlockPos(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)));
Block block = state.getBlock();
Material material = block.getMaterial(state);
BlockPos blockpos = new BlockPos(this.posX, this.posY, this.posZ);
IBlockState iblockstate = this.worldObj.getBlockState(blockpos);
Material material = iblockstate.getMaterial();
if (material.isLiquid() || material.isSolid()) {
double d0 = MathHelper.floor_double(this.posY) + 1 - BlockLiquid.getLiquidHeightPercent(block.getMetaFromState(state));
if (this.posY < d0) {
double d0 = 0.0D;
if (iblockstate.getBlock() instanceof BlockLiquid) {
d0 = BlockLiquid.getLiquidHeightPercent(iblockstate.getValue(BlockLiquid.LEVEL));
}
double d1 = (double) (MathHelper.floor_double(this.posY) + 1) - d0;
if (this.posY < d1) {
this.setExpired();
}
}
@@ -51,7 +51,7 @@ public class BlockForestryFluid extends BlockFluidClassic implements IItemModelR
}
public BlockForestryFluid(Fluids forestryFluid, int flammability, boolean flammable) {
this(forestryFluid.getFluid(), flammability, flammable, forestryFluid.getColor());
this(forestryFluid.getFluid(), flammability, flammable, forestryFluid.getParticleColor());
}
private BlockForestryFluid(Fluid fluid, int flammability, boolean flammable, Color color) {
@@ -119,8 +119,8 @@ public class BlockForestryFluid extends BlockFluidClassic implements IItemModelR
double px = d0 + rand.nextFloat();
double py = d1 - 1.05D;
double pz = d2 + rand.nextFloat();
Particle fx = new ParticleColoredDripParticle(worldIn, px, py, pz, color.getRed(), color.getGreen(), color.getBlue());
Particle fx = new ParticleColoredDripParticle(worldIn, px, py, pz, color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f);
FMLClientHandler.instance().getClient().effectRenderer.addEffect(fx);
}
}
@@ -14,16 +14,12 @@ import java.util.List;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IContainerListener;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidTank;
import net.minecraftforge.fluids.capability.templates.EmptyFluidHandler;
import forestry.core.fluids.tanks.FakeTank;
public class FakeTankManager implements ITankManager {
public class FakeTankManager extends EmptyFluidHandler implements ITankManager {
public static final FakeTankManager instance = new FakeTankManager();
private FakeTankManager() {
@@ -47,41 +43,21 @@ public class FakeTankManager implements ITankManager {
@Override
public IFluidTank getTank(int tankIndex) {
return FakeTank.INSTANCE;
return EmptyFluidHandler.INSTANCE;
}
@Override
public boolean canFillFluidType(FluidStack fluidStack) {
return false;
}
@Override
public boolean canDrainFluidType(FluidStack fluidStack) {
return false;
}
@Override
public void processTankUpdate(int tankIndex, FluidStack contents) {
}
@Override
public int fill(EnumFacing from, FluidStack resource, boolean doFill) {
return FakeTank.INSTANCE.fill(resource, doFill);
}
@Override
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) {
return FakeTank.INSTANCE.drain(resource.amount, doDrain);
}
@Override
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) {
return FakeTank.INSTANCE.drain(maxDrain, doDrain);
}
@Override
public boolean canFill(EnumFacing from, Fluid fluid) {
return false;
}
@Override
public boolean canDrain(EnumFacing from, Fluid fluid) {
return false;
}
@Override
public FluidTankInfo[] getTankInfo(EnumFacing from) {
return FakeTank.INFO;
}
}
@@ -10,101 +10,22 @@
******************************************************************************/
package forestry.core.fluids;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidContainerItem;
import net.minecraftforge.fluids.IFluidHandler;
import net.minecraftforge.fluids.FluidUtil;
import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.fluids.capability.IFluidTankProperties;
import forestry.core.PluginFluids;
import forestry.core.config.Constants;
import forestry.core.utils.InventoryUtil;
import forestry.core.utils.ItemStackUtil;
/**
* @author CovertJaguar <http://www.railcraft.info>
*/
public final class FluidHelper {
private FluidHelper() {
}
public static boolean handleRightClick(IFluidHandler tank, EnumFacing side, EntityPlayer player, boolean fill, boolean drain) {
if (player == null) {
return false;
}
ItemStack current = player.inventory.getCurrentItem();
if (current != null) {
FluidStack liquid = getFluidStackInContainer(current);
if (fill && liquid != null) {
int canUseAmount = tank.fill(side, liquid, false);
if (canUseAmount == 0) {
return false;
}
ItemStack drainedContainer = getDrainedContainer(current, canUseAmount);
if (ItemStackUtil.isIdenticalItem(current, drainedContainer)) {
return false;
}
int usedAmount = tank.fill(side, liquid, true);
if (usedAmount > 0) {
if (!player.capabilities.isCreativeMode) {
if (current.stackSize > 1) {
player.inventory.decrStackSize(player.inventory.currentItem, 1);
if (drainedContainer != null && !player.inventory.addItemStackToInventory(drainedContainer)) {
player.dropItem(drainedContainer, false);
}
} else {
player.inventory.setInventorySlotContents(player.inventory.currentItem, drainedContainer);
}
player.inventory.markDirty();
}
return true;
}
} else if (drain) {
FluidStack available = tank.drain(side, Integer.MAX_VALUE, false);
if (available != null) {
ItemStack filled = getFilledContainer(available, current);
liquid = getFluidStackInContainer(filled);
if (liquid != null) {
if (current.stackSize > 1) {
if (!player.inventory.addItemStackToInventory(filled)) {
return false;
}
player.inventory.setInventorySlotContents(player.inventory.currentItem, InventoryUtil.depleteItem(current));
player.inventory.markDirty();
} else {
player.inventory.setInventorySlotContents(player.inventory.currentItem, InventoryUtil.depleteItem(current));
player.inventory.setInventorySlotContents(player.inventory.currentItem, filled);
player.inventory.markDirty();
}
tank.drain(side, liquid.amount, true);
return true;
}
}
}
}
return false;
}
public static boolean areFluidStacksEqual(FluidStack fluidStack1, FluidStack fluidStack2) {
if (fluidStack1 == null) {
return fluidStack2 == null;
@@ -117,10 +38,6 @@ public final class FluidHelper {
SUCCESS, INVALID_INPUT, NO_FLUID, NO_SPACE
}
public static FillStatus fillContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill) {
return fillContainers(fluidHandler, inv, inputSlot, outputSlot, fluidToFill, true);
}
public static FillStatus fillContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill, boolean doFill) {
if (fluidToFill == null) {
return FillStatus.INVALID_INPUT;
@@ -132,30 +49,33 @@ public final class FluidHelper {
}
ItemStack output = inv.getStackInSlot(outputSlot);
int containerCapacity = getFluidCapacity(fluidToFill, input);
ItemStack filled = input.copy();
filled.stackSize = 1;
IFluidHandler fluidFilledHandler = FluidUtil.getFluidHandler(filled);
if (fluidFilledHandler == null) {
return FillStatus.INVALID_INPUT;
}
int containerCapacity = fluidFilledHandler.fill(new FluidStack(fluidToFill, Integer.MAX_VALUE), false);
if (containerCapacity <= 0) {
return FillStatus.INVALID_INPUT;
}
int fillAmount = containerCapacity;
if (input.getItem() instanceof IFluidContainerItem) {
fillAmount = Math.min(Constants.BUCKET_VOLUME, containerCapacity);
}
FluidStack canDrain = fluidHandler.drain(null, new FluidStack(fluidToFill, fillAmount), false);
FluidStack canDrain = fluidHandler.drain(new FluidStack(fluidToFill, containerCapacity), false);
if (canDrain == null || canDrain.amount == 0) {
return FillStatus.NO_FLUID;
}
ItemStack filled = getFilledContainer(canDrain, input);
if (filled == null) {
if (fluidFilledHandler.fill(canDrain, true) <= 0) {
return FillStatus.NO_FLUID; // standard containers will not fill if there isn't enough fluid
}
FluidStack fluidInContainer = getFluidStackInContainer(filled);
FluidStack fluidInContainer = fluidFilledHandler.drain(Integer.MAX_VALUE, false);
if (fluidInContainer == null) {
return FillStatus.INVALID_INPUT;
}
boolean moveToOutput = fluidInContainer.amount >= containerCapacity;
if (moveToOutput) {
if (output != null && (output.stackSize >= output.getMaxStackSize() || !InventoryUtil.isItemEqual(filled, output))) {
@@ -168,7 +88,7 @@ public final class FluidHelper {
}
if (doFill) {
fluidHandler.drain(null, canDrain, true);
fluidHandler.drain(canDrain, true);
if (moveToOutput) {
if (output == null) {
inv.setInventorySlotContents(outputSlot, filled);
@@ -184,101 +104,93 @@ public final class FluidHelper {
return FillStatus.SUCCESS;
}
public static boolean drainContainers(IFluidHandler fluidHandler, IInventory inv, int slot) {
return drainContainers(fluidHandler, inv, slot, slot);
}
public static boolean drainContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot) {
public static boolean drainContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot) {
ItemStack input = inv.getStackInSlot(inputSlot);
ItemStack output = inv.getStackInSlot(outputSlot);
if (input == null) {
return false;
}
FluidStack fluidInContainer = getFluidStackInContainer(input);
if (fluidInContainer == null) {
ItemStack drainedItemSimulated = FluidUtil.tryEmptyContainer(input, fluidHandler, Fluid.BUCKET_VOLUME, null, false);
if (drainedItemSimulated == null) {
return false;
}
if (input.getItem() instanceof IFluidContainerItem) {
if (fluidInContainer.amount > Constants.BUCKET_VOLUME) {
fluidInContainer.amount = Constants.BUCKET_VOLUME;
}
}
int used = fluidHandler.fill(null, fluidInContainer, false);
ItemStack drainedItem = getDrainedContainer(input, used);
if (ItemStack.areItemStacksEqual(input, drainedItem)) {
return false;
}
// consume forestry containers if there is only one slot
if (outputSlot == inputSlot && drainedItem != null) {
Item item = drainedItem.getItem();
if (PluginFluids.items.canEmpty == item || PluginFluids.items.waxCapsuleEmpty == item || PluginFluids.items.refractoryEmpty == item) {
drainedItem = null;
}
}
if (!hasRoomForDrainedContainer(input, output, drainedItem, inputSlot, outputSlot)) {
return false;
}
fluidHandler.fill(null, fluidInContainer, true);
if (drainedItem != null) {
if (outputSlot == inputSlot) {
inv.setInventorySlotContents(outputSlot, drainedItem);
if (input.stackSize == 1 || drainedItemSimulated.stackSize == 0) {
ItemStack drainedItem = FluidUtil.tryEmptyContainer(input, fluidHandler, Fluid.BUCKET_VOLUME, null, true);
if (drainedItem != null) {
if (drainedItem.stackSize > 0) {
inv.setInventorySlotContents(inputSlot, drainedItem);
} else {
inv.decrStackSize(inputSlot, 1);
}
return true;
}
}
if (output == null) {
inv.setInventorySlotContents(outputSlot, drainedItem);
} else {
output.stackSize++;
return false;
}
public static boolean isFillableContainerWithRoom(ItemStack container) {
IFluidHandler fluidHandler = FluidUtil.getFluidHandler(container);
if (fluidHandler == null) {
return false;
}
IFluidTankProperties[] tankProperties = fluidHandler.getTankProperties();
for (IFluidTankProperties properties : tankProperties) {
if (properties.canFill() && properties.getCapacity() > 0) {
FluidStack contents = properties.getContents();
if (contents == null) {
return true;
} else if (contents.amount < properties.getCapacity()) {
return true;
}
}
}
inv.decrStackSize(inputSlot, 1);
return false;
}
public static boolean isFillableEmptyContainer(ItemStack empty) {
IFluidHandler fluidHandler = FluidUtil.getFluidHandler(empty);
if (fluidHandler == null) {
return false;
}
IFluidTankProperties[] tankProperties = fluidHandler.getTankProperties();
for (IFluidTankProperties properties : tankProperties) {
if (!properties.canFill()) {
return false;
}
FluidStack contents = properties.getContents();
if (contents != null && contents.amount > 0) {
return false;
}
}
return true;
}
private static boolean hasRoomForDrainedContainer(ItemStack input, ItemStack output, ItemStack drainedItem, int inputSlot, int outputSlot) {
if (output == null || drainedItem == null) {
return true;
}
if (outputSlot == inputSlot) {
return input.stackSize == 1;
}
if (!ItemStackUtil.isIdenticalItem(output, drainedItem)) {
public static boolean isDrainableFilledContainer(ItemStack container) {
IFluidHandler fluidHandler = FluidUtil.getFluidHandler(container);
if (fluidHandler == null) {
return false;
}
return output.stackSize + drainedItem.stackSize <= output.getMaxStackSize();
}
IFluidTankProperties[] tankProperties = fluidHandler.getTankProperties();
for (IFluidTankProperties properties : tankProperties) {
if (!properties.canDrain()) {
return false;
}
public static boolean isEmptyContainer(ItemStack empty) {
Item item = empty.getItem();
if (item instanceof IFluidContainerItem) {
IFluidContainerItem containerItem = (IFluidContainerItem) item;
FluidStack fluid = containerItem.getFluid(empty);
return fluid == null || fluid.amount == 0;
FluidStack contents = properties.getContents();
if (contents == null || contents.amount < properties.getCapacity()) {
return false;
}
}
return FluidContainerRegistry.isEmptyContainer(empty);
}
public static boolean isFillableContainer(ItemStack container) {
FluidStack fluid = getFluidStackInContainer(container);
if (fluid == null || fluid.amount == 0) {
return isEmptyContainer(container);
}
int capacity = getFluidCapacity(fluid.getFluid(), container);
return fluid.amount < capacity;
return true;
}
public static ItemStack getDrainedContainer(ItemStack container, int drainAmount) {
@@ -290,127 +202,38 @@ public final class FluidHelper {
return container;
}
Item item = container.getItem();
if (item == null) {
container = container.copy();
container.stackSize = 1;
IFluidHandler fluidHandler = FluidUtil.getFluidHandler(container);
if (fluidHandler == null) {
return null;
}
if (item instanceof IFluidContainerItem) {
ItemStack drained = container.copy();
drained.stackSize = 1;
IFluidContainerItem containerItem = (IFluidContainerItem) item;
containerItem.drain(drained, drainAmount, true);
return drained;
} else {
int capacity = FluidContainerRegistry.getContainerCapacity(container);
if (capacity > 0) {
if (drainAmount < capacity) {
return container;
}
return FluidContainerRegistry.drainFluidContainer(container);
}
fluidHandler.drain(drainAmount, true);
if (container.stackSize <= 0) {
return null;
}
return container;
}
public static ItemStack getFilledContainer(FluidStack liquid, ItemStack stack) {
if (liquid == null || stack == null) {
return null;
}
stack = stack.copy();
stack.stackSize = 1;
IFluidHandler fluidHandler = FluidUtil.getFluidHandler(stack);
if (fluidHandler == null) {
return null;
}
if (fluidHandler.fill(liquid, true) > 0) {
return stack;
}
return null;
}
public static ItemStack getEmptyContainer(ItemStack container) {
if (container == null) {
return null;
}
FluidStack fluidStack = FluidHelper.getFluidStackInContainer(container);
if (fluidStack == null) {
return null;
}
return FluidHelper.getDrainedContainer(container, fluidStack.amount);
}
public static List<ItemStack> getAllFilledContainers(ItemStack empty) {
List<ItemStack> filledContainers = new ArrayList<>();
for (Fluid fluid : FluidRegistry.getRegisteredFluids().values()) {
ItemStack filledContainer = getFilledContainer(fluid, empty);
if (filledContainer != null) {
filledContainers.add(filledContainer);
}
}
return filledContainers;
}
public static ItemStack getFilledContainer(Fluid fluid, ItemStack empty) {
if (fluid == null) {
return null;
}
FluidStack fluidToFill = new FluidStack(fluid, Integer.MAX_VALUE);
return getFilledContainer(fluidToFill, empty);
}
public static ItemStack getFilledContainer(FluidStack liquid, ItemStack empty) {
if (liquid == null || empty == null) {
return null;
}
Item item = empty.getItem();
if (item instanceof IFluidContainerItem) {
ItemStack full = ItemStackUtil.createSplitStack(empty, 1);
IFluidContainerItem containerItem = (IFluidContainerItem) item;
containerItem.fill(full, liquid, true);
return full;
}
return FluidContainerRegistry.fillFluidContainer(liquid, empty);
}
public static FluidStack getFluidStackInContainer(ItemStack stack) {
if (stack == null) {
return null;
}
Item item = stack.getItem();
if (item instanceof IFluidContainerItem) {
IFluidContainerItem containerItem = (IFluidContainerItem) item;
return containerItem.getFluid(stack);
}
return FluidContainerRegistry.getFluidForFilledItem(stack);
}
public static Fluid getFluidInContainer(ItemStack stack) {
FluidStack fluidStack = getFluidStackInContainer(stack);
return fluidStack != null ? fluidStack.getFluid() : null;
}
public static boolean containsFluidStack(ItemStack stack, FluidStack fluidStack) {
Item item = stack.getItem();
if (item instanceof IFluidContainerItem) {
IFluidContainerItem containerItem = (IFluidContainerItem) item;
FluidStack contained = containerItem.getFluid(stack);
return contained != null && contained.containsFluid(fluidStack);
}
return FluidContainerRegistry.containsFluid(stack, fluidStack);
}
public static boolean containsFluid(ItemStack stack, Fluid fluid) {
return containsFluidStack(stack, new FluidStack(fluid, 1));
}
public static int getFluidCapacity(Fluid fluid, ItemStack container) {
if (container == null) {
return 0;
}
Item item = container.getItem();
if (item instanceof IFluidContainerItem) {
IFluidContainerItem containerItem = (IFluidContainerItem) item;
return containerItem.getCapacity(container);
}
if (fluid == null) {
return FluidContainerRegistry.getContainerCapacity(container);
} else {
return FluidContainerRegistry.getContainerCapacity(new FluidStack(fluid, Constants.BUCKET_VOLUME), container);
}
}
}
+20 -135
View File
@@ -15,7 +15,6 @@ import javax.annotation.Nullable;
import java.awt.Color;
import java.io.IOException;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
@@ -30,10 +29,11 @@ import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.relauncher.Side;
import forestry.core.items.DrinkProperties;
import forestry.core.items.EnumContainerType;
import forestry.core.proxy.Proxies;
import forestry.core.render.ForestryResource;
@@ -44,32 +44,12 @@ public enum Fluids {
public Block makeBlock() {
return new BlockForestryFluid(this, 300, true);
}
@Nonnull
@Override
public EnumSet<EnumContainerType> getContainerTypes() {
return EnumSet.of(
EnumContainerType.CAN,
EnumContainerType.CAPSULE,
EnumContainerType.REFRACTORY
);
}
},
BIOMASS(new Color(100, 132, 41), 400, 6560) {
@Override
public Block makeBlock() {
return new BlockForestryFluid(this, 100, true);
}
@Nonnull
@Override
public EnumSet<EnumContainerType> getContainerTypes() {
return EnumSet.of(
EnumContainerType.CAN,
EnumContainerType.CAPSULE,
EnumContainerType.REFRACTORY
);
}
},
GLASS(new Color(164, 164, 164), 2400, 10000) {
@Override
@@ -88,16 +68,6 @@ public enum Fluids {
return new BlockForestryFluid(this);
}
@Nonnull
@Override
public EnumSet<EnumContainerType> getContainerTypes() {
return EnumSet.of(
EnumContainerType.CAN,
EnumContainerType.CAPSULE,
EnumContainerType.REFRACTORY
);
}
@Override
public DrinkProperties getDrinkProperties() {
return new DrinkProperties(2, 0.2f, 64);
@@ -113,16 +83,6 @@ public enum Fluids {
public Block makeBlock() {
return new BlockForestryFluid(this);
}
@Nonnull
@Override
public EnumSet<EnumContainerType> getContainerTypes() {
return EnumSet.of(
EnumContainerType.CAN,
EnumContainerType.CAPSULE,
EnumContainerType.REFRACTORY
);
}
},
JUICE(new Color(168, 201, 114)) {
@Override
@@ -130,16 +90,6 @@ public enum Fluids {
return new BlockForestryFluid(this);
}
@Nonnull
@Override
public EnumSet<EnumContainerType> getContainerTypes() {
return EnumSet.of(
EnumContainerType.CAN,
EnumContainerType.CAPSULE,
EnumContainerType.REFRACTORY
);
}
@Override
public DrinkProperties getDrinkProperties() {
return new DrinkProperties(2, 0.2f, 32);
@@ -164,74 +114,14 @@ public enum Fluids {
public Block makeBlock() {
return new BlockForestryFluid(this, 2, true);
}
@Nonnull
@Override
public EnumSet<EnumContainerType> getContainerTypes() {
return EnumSet.of(
EnumContainerType.CAN,
EnumContainerType.CAPSULE,
EnumContainerType.REFRACTORY
);
}
},
SHORT_MEAD(new Color(239, 154, 56), 1000, 1200) {
@Override
public Block makeBlock() {
return new BlockForestryFluid(this);
}
},
// Vanilla
WATER(new Color(0x2432ec)) {
@Nonnull
@Override
public EnumSet<EnumContainerType> getContainerTypes() {
return EnumSet.of(
EnumContainerType.CAN,
EnumContainerType.CAPSULE,
EnumContainerType.REFRACTORY
);
}
},
LAVA(new Color(0xfd461f)) {
@Nonnull
@Override
public EnumSet<EnumContainerType> getContainerTypes() {
return EnumSet.of(
EnumContainerType.CAN,
EnumContainerType.REFRACTORY
);
}
},
// BuildCraft
FUEL(new Color(0xffff00)) {
@Nonnull
@Override
public EnumSet<EnumContainerType> getContainerTypes() {
return EnumSet.of(
EnumContainerType.CAN,
EnumContainerType.CAPSULE,
EnumContainerType.REFRACTORY
);
}
},
OIL(new Color(0x404040)) {
@Nonnull
@Override
public EnumSet<EnumContainerType> getContainerTypes() {
return EnumSet.of(
EnumContainerType.CAN,
EnumContainerType.CAPSULE,
EnumContainerType.REFRACTORY
);
}
},
// Railcraft
CREOSOTE(new Color(0x635c03)),
STEAM(new Color(0x91938F));
public static final Fluids[] FORESTRY_FLUIDs = {BIO_ETHANOL, BIOMASS, GLASS, FOR_HONEY, ICE, JUICE, MILK, SEED_OIL, SHORT_MEAD};
};
private static final Map<String, Fluids> tagToFluid = new HashMap<>();
static {
@@ -243,17 +133,17 @@ public enum Fluids {
private final String tag;
private final int density, viscosity;
@Nonnull
private final Color color;
private final Color particleColor;
private final ResourceLocation[] resources = new ResourceLocation[2];
Fluids(@Nonnull Color color) {
this(color, 1000, 1000);
Fluids(@Nonnull Color particleColor) {
this(particleColor, 1000, 1000);
}
Fluids(@Nonnull Color color, int density, int viscosity) {
Fluids(@Nonnull Color particleColor, int density, int viscosity) {
this.tag = name().toLowerCase(Locale.ENGLISH).replace('_', '.');
this.color = color;
this.particleColor = particleColor;
this.density = density;
this.viscosity = viscosity;
@@ -296,8 +186,8 @@ public enum Fluids {
}
@Nonnull
public final Color getColor() {
return color;
public final Color getParticleColor() {
return particleColor;
}
public final boolean is(Fluid fluid) {
@@ -309,7 +199,8 @@ public enum Fluids {
}
public final boolean isContained(ItemStack containerStack) {
return containerStack != null && FluidHelper.containsFluid(containerStack, getFluid());
FluidStack fluidStackInContainer = FluidUtil.getFluidContained(containerStack);
return fluidStackInContainer != null && fluidStackInContainer.getFluid() == getFluid();
}
public static boolean areEqual(Fluid fluid, FluidStack fluidStack) {
@@ -329,25 +220,19 @@ public enum Fluids {
return a.isFluidEqual(b);
}
@Nonnull
public static Color getFluidColor(FluidStack fluidStack) {
@Nullable
public static Fluids getFluidDefinition(FluidStack fluidStack) {
if (fluidStack != null) {
Fluid fluid = fluidStack.getFluid();
if (fluid != null) {
Fluids fluidDefinition = tagToFluid.get(fluid.getName());
if (fluidDefinition != null) {
return fluidDefinition.getColor();
return fluidDefinition;
}
}
}
return Fluids.WATER.getColor();
}
/** FluidBlock and Container registration */
@Nonnull
public EnumSet<EnumContainerType> getContainerTypes() {
return EnumSet.noneOf(EnumContainerType.class);
return null;
}
/**
@@ -367,7 +252,7 @@ public enum Fluids {
}
/**
* Get the properties for an ItemLiquidContainer before it gets registered.
* Get the properties for an ItemFluidContainerForestry before it gets registered.
*/
@Nullable
public DrinkProperties getDrinkProperties() {
@@ -16,8 +16,8 @@ import net.minecraft.inventory.Container;
import net.minecraft.inventory.IContainerListener;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidHandler;
import net.minecraftforge.fluids.IFluidTank;
import net.minecraftforge.fluids.capability.IFluidHandler;
public interface ITankManager extends IFluidHandler {
void containerAdded(Container container, IContainerListener crafter);
@@ -28,6 +28,10 @@ public interface ITankManager extends IFluidHandler {
IFluidTank getTank(int tankIndex);
boolean canFillFluidType(FluidStack fluidStack);
boolean canDrainFluidType(FluidStack fluidStack);
/**
* For updating tanks on the client
*/
@@ -1,69 +0,0 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.core.fluids;
import java.util.EnumMap;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBucket;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
import net.minecraftforge.fluids.FluidStack;
import forestry.core.PluginFluids;
import forestry.core.config.Constants;
import forestry.core.items.EnumContainerType;
import forestry.core.items.ItemLiquidContainer;
import forestry.core.utils.Log;
public class LiquidRegistryHelper {
private static final EnumMap<EnumContainerType, ItemLiquidContainer> emptyContainers = new EnumMap<>(EnumContainerType.class);
static {
emptyContainers.put(EnumContainerType.CAN, PluginFluids.items.canEmpty);
emptyContainers.put(EnumContainerType.CAPSULE, PluginFluids.items.waxCapsuleEmpty);
emptyContainers.put(EnumContainerType.REFRACTORY, PluginFluids.items.refractoryEmpty);
}
public static void registerLiquidContainer(Fluids fluid, ItemStack filled) {
Item item = filled.getItem();
ItemStack empty = null;
if (item.getContainerItem() instanceof ItemBucket) {
empty = new ItemStack(Items.BUCKET);
} else if (item instanceof ItemLiquidContainer) {
ItemLiquidContainer liquidContainer = (ItemLiquidContainer) item;
EnumContainerType containerType = liquidContainer.getType();
ItemLiquidContainer emptyContainer = emptyContainers.get(containerType);
empty = emptyContainer.getItemStack();
}
if (empty == null) {
Log.warning("Unable to inject liquid container: " + filled);
} else {
registerLiquidContainer(fluid, Constants.BUCKET_VOLUME, filled, empty);
}
}
public static void registerLiquidContainer(Fluids fluid, int volume, ItemStack filled, ItemStack empty) {
FluidStack contained = fluid.getFluid(volume);
if (contained == null) {
throw new IllegalArgumentException(String.format("Attempted to inject a liquid container for the non-existent liquid '%s'.", fluid));
}
FluidContainerData container = new FluidContainerData(contained, filled, empty);
FluidContainerRegistry.registerFluidContainer(container);
}
}
@@ -17,6 +17,7 @@ import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import forestry.api.core.INbtWritable;
@@ -48,7 +49,7 @@ public class PipetteContents implements INbtWritable {
}
public boolean isFull() {
return contents.amount >= 1000;
return contents.amount >= Fluid.BUCKET_VOLUME;
}
public void addTooltip(List<String> list) {
@@ -14,6 +14,7 @@ import com.google.common.collect.HashBasedTable;
import com.google.common.collect.Table;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
@@ -26,16 +27,16 @@ import net.minecraft.inventory.Container;
import net.minecraft.inventory.IContainerListener;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidTank;
import net.minecraftforge.fluids.capability.FluidTankPropertiesWrapper;
import net.minecraftforge.fluids.capability.IFluidTankProperties;
import net.minecraftforge.fluids.capability.templates.EmptyFluidHandler;
import forestry.api.core.INbtReadable;
import forestry.api.core.INbtWritable;
import forestry.core.fluids.tanks.FakeTank;
import forestry.core.fluids.tanks.StandardTank;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
@@ -206,14 +207,14 @@ public class TankManager implements ITankManager, ITankUpdateHandler, IStreamabl
}
@Override
public int fill(EnumFacing from, FluidStack resource, boolean doFill) {
public int fill(FluidStack resource, boolean doFill) {
for (StandardTank tank : tanks) {
if (tankAcceptsFluid(tank, resource)) {
return fill(tank.getTankIndex(), resource, doFill);
}
}
return FakeTank.INSTANCE.fill(resource, doFill);
return EmptyFluidHandler.INSTANCE.fill(resource, doFill);
}
public int fill(int tankIndex, FluidStack resource, boolean doFill) {
@@ -222,7 +223,7 @@ public class TankManager implements ITankManager, ITankUpdateHandler, IStreamabl
}
StandardTank tank = tanks.get(tankIndex);
if (!tank.canBeFilledExternally()) {
if (!tank.canFill()) {
return 0;
}
@@ -250,14 +251,15 @@ public class TankManager implements ITankManager, ITankUpdateHandler, IStreamabl
}
}
@Nullable
@Override
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) {
public FluidStack drain(int maxDrain, boolean doDrain) {
for (StandardTank tank : tanks) {
if (tankCanDrain(tank)) {
return drain(tank.getTankIndex(), maxDrain, doDrain);
}
}
return FakeTank.INSTANCE.drain(maxDrain, doDrain);
return EmptyFluidHandler.INSTANCE.drain(maxDrain, doDrain);
}
public FluidStack drain(int tankIndex, int maxDrain, boolean doDrain) {
@@ -266,13 +268,14 @@ public class TankManager implements ITankManager, ITankUpdateHandler, IStreamabl
}
StandardTank tank = tanks.get(tankIndex);
if (!tank.canBeDrainedExternally()) {
if (!tank.canDrain()) {
return null;
}
return tank.drain(maxDrain, doDrain);
}
@Override
public FluidStack drain(FluidStack resource, boolean doDrain) {
for (StandardTank tank : tanks) {
if (tankCanDrainFluid(tank, resource)) {
@@ -283,31 +286,12 @@ public class TankManager implements ITankManager, ITankUpdateHandler, IStreamabl
}
@Override
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) {
return drain(resource, doDrain);
}
@Override
public boolean canFill(EnumFacing from, Fluid fluid) {
return true;
}
@Override
public boolean canDrain(EnumFacing from, Fluid fluid) {
return true;
}
@Override
public FluidTankInfo[] getTankInfo(EnumFacing direction) {
FluidTankInfo[] info = new FluidTankInfo[tanks.size()];
public IFluidTankProperties[] getTankProperties() {
IFluidTankProperties[] properties = new IFluidTankProperties[tanks.size()];
for (int i = 0; i < tanks.size(); i++) {
info[i] = tanks.get(i).getInfo();
properties[i] = new FluidTankPropertiesWrapper(tanks.get(i));
}
return info;
}
public FluidTankInfo[] getTankInfo() {
return getTankInfo(null);
return properties;
}
public FluidTankInfo getTankInfo(int tankIndex) {
@@ -322,13 +306,29 @@ public class TankManager implements ITankManager, ITankUpdateHandler, IStreamabl
return tanks.get(tankIndex).getFluidAmount();
}
public boolean accepts(Fluid fluid) {
if (fluid == null) {
@Override
public boolean canFillFluidType(FluidStack fluidStack) {
if (fluidStack == null) {
return false;
}
for (StandardTank tank : tanks) {
if (tank.accepts(fluid)) {
if (tank.canFillFluidType(fluidStack)) {
return true;
}
}
return false;
}
@Override
public boolean canDrainFluidType(FluidStack fluidStack) {
if (fluidStack == null) {
return false;
}
for (StandardTank tank : tanks) {
if (tank.canDrainFluidType(fluidStack)) {
return true;
}
}
@@ -340,14 +340,14 @@ public class TankManager implements ITankManager, ITankUpdateHandler, IStreamabl
if (fluidStack == null) {
return false;
}
if (!tank.canBeFilledExternally()) {
if (!tank.canFill()) {
return false;
}
return tank.fill(fluidStack, false) > 0;
}
private static boolean tankCanDrain(StandardTank tank) {
if (!tank.canBeDrainedExternally()) {
if (!tank.canDrain()) {
return false;
}
FluidStack drained = tank.drain(1, false);
@@ -1,39 +0,0 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.core.fluids.tanks;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
/**
* @author CovertJaguar <http://www.railcraft.info>
*/
public final class FakeTank extends StandardTank {
public static final FakeTank INSTANCE = new FakeTank();
public static final FakeTank[] ARRAY = new FakeTank[]{INSTANCE};
public static final FluidTankInfo[] INFO = new FluidTankInfo[]{INSTANCE.getInfo()};
private FakeTank() {
super(1);
}
@Override
public int fill(FluidStack resource, boolean doFill) {
return 0;
}
@Override
public FluidStack drain(int maxDrain, boolean doDrain) {
return null;
}
}
@@ -16,7 +16,6 @@ import java.util.HashSet;
import java.util.Set;
import net.minecraft.item.EnumRarity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fluids.Fluid;
@@ -33,41 +32,38 @@ public class FilteredTank extends StandardTank {
private final Set<String> filters = new HashSet<>(); // FluidNames
public FilteredTank(int capacity, Fluid... filters) {
this(capacity, Arrays.asList(filters), null);
public FilteredTank(int capacity) {
super(capacity);
}
public FilteredTank(int capacity, Collection<Fluid> filters) {
this(capacity, filters, null);
public FilteredTank(int capacity, boolean canFill, boolean canDrain) {
super(capacity, canFill, canDrain);
}
public FilteredTank(int capacity, Collection<Fluid> filters, TileEntity tile) {
super(capacity, tile);
setFilters(filters);
public FilteredTank setFilters(Fluid... filters) {
return setFilters(Arrays.asList(filters));
}
public void setFilters(Collection<Fluid> filters) {
public FilteredTank setFilters(Collection<Fluid> filters) {
this.filters.clear();
for (Fluid fluid : filters) {
this.filters.add(fluid.getName());
}
return this;
}
@Override
public int fill(FluidStack resource, boolean doFill) {
if (liquidMatchesFilter(resource)) {
return super.fill(resource, doFill);
}
return 0;
public boolean canFillFluidType(FluidStack fluid) {
return fluidMatchesFilter(fluid);
}
@Override
public boolean accepts(Fluid fluid) {
return filters.contains(fluid.getName());
public boolean canDrainFluidType(FluidStack fluid) {
return fluidMatchesFilter(fluid);
}
private boolean liquidMatchesFilter(FluidStack resource) {
if (resource == null || filters == null) {
private boolean fluidMatchesFilter(FluidStack resource) {
if (resource == null || resource.getFluid() == null) {
return false;
}
return filters.contains(resource.getFluid().getName());
@@ -14,14 +14,12 @@ import javax.annotation.Nonnull;
import java.io.IOException;
import net.minecraft.item.EnumRarity;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
import forestry.core.fluids.FakeTankUpdateHandler;
import forestry.core.fluids.FluidHelper;
import forestry.core.fluids.ITankUpdateHandler;
import forestry.core.fluids.TankManager;
import forestry.core.gui.tooltips.ToolTip;
@@ -34,37 +32,21 @@ import forestry.core.utils.Translator;
* @author CovertJaguar <http://www.railcraft.info>
*/
public class StandardTank extends FluidTank implements IStreamable {
// defines how the tank responds to IFluidHandler requests
public enum TankMode {
DEFAULT, OUTPUT, INPUT, INTERNAL
}
public TankMode tankMode = TankMode.DEFAULT;
private static final int DEFAULT_COLOR = 0xFFFFFF;
@Nonnull
private ITankUpdateHandler tankUpdateHandler = FakeTankUpdateHandler.instance;
private int tankIndex;
public StandardTank(int capacity, boolean canFill, boolean canDrain) {
super(capacity);
setCanFill(canFill);
setCanDrain(canDrain);
}
public StandardTank(int capacity) {
super(capacity);
}
public StandardTank(FluidStack fluid, int capacity) {
this(capacity);
setFluid(fluid);
}
public StandardTank(int capacity, TileEntity tile) {
this(capacity);
this.tile = tile;
}
public StandardTank(FluidStack fluid, int capacity, TileEntity tile) {
this(capacity);
this.tile = tile;
setFluid(fluid);
}
public void setTankIndex(int index) {
this.tankIndex = index;
}
@@ -102,75 +84,17 @@ public class StandardTank extends FluidTank implements IStreamable {
}
@Override
public int fill(final FluidStack resource, final boolean doFill) {
if (resource == null) {
return 0;
}
if (resource.amount <= 0) {
return 0;
}
if (!accepts(resource.getFluid())) {
return 0;
}
int filled = super.fill(resource, doFill);
public int fillInternal(FluidStack resource, boolean doFill) {
int filled = super.fillInternal(resource, doFill);
if (doFill && filled > 0) {
tankUpdateHandler.updateTankLevels(this);
}
return filled;
}
public boolean accepts(Fluid fluid) {
return fluid != null;
}
@SuppressWarnings("incomplete-switch")
public boolean canBeFilledExternally() {
switch (tankMode) {
case DEFAULT:
case INPUT:
return true;
}
return false;
}
@SuppressWarnings("incomplete-switch")
public boolean canBeDrainedExternally() {
switch (tankMode) {
case DEFAULT:
case OUTPUT:
return true;
}
return false;
}
public boolean canFill(Fluid fluid, int amount) {
if (fluid == null) {
return false;
}
FluidStack fluidStack = new FluidStack(fluid, amount);
return canFill(fluidStack);
}
public boolean canFill(FluidStack fluidStack) {
return fill(fluidStack, false) == fluidStack.amount;
}
public boolean canDrain(int amount) {
FluidStack drained = drain(amount, false);
return drained != null && drained.amount == amount;
}
public boolean canDrain(FluidStack toDrain) {
FluidStack drained = drain(toDrain.amount, false);
return FluidHelper.areFluidStacksEqual(drained, toDrain);
}
@Override
public FluidStack drain(int maxDrain, boolean doDrain) {
if (maxDrain <= 0) {
return null;
}
FluidStack drained = super.drain(maxDrain, doDrain);
public FluidStack drainInternal(int maxDrain, boolean doDrain) {
FluidStack drained = super.drainInternal(maxDrain, doDrain);
if (doDrain && drained != null && drained.amount > 0) {
tankUpdateHandler.updateTankLevels(this);
}
@@ -17,19 +17,19 @@ public class GenericRatings {
public static String rateMetabolism(int metabolism) {
if (metabolism >= 19) {
return Translator.translateToLocal("Forestry.allele.highest");
return Translator.translateToLocal("forestry.allele.highest");
} else if (metabolism >= 16) {
return Translator.translateToLocal("Forestry.allele.higher");
return Translator.translateToLocal("forestry.allele.higher");
} else if (metabolism >= 13) {
return Translator.translateToLocal("Forestry.allele.high");
return Translator.translateToLocal("forestry.allele.high");
} else if (metabolism >= 10) {
return Translator.translateToLocal("Forestry.allele.average");
return Translator.translateToLocal("forestry.allele.average");
} else if (metabolism >= 7) {
return Translator.translateToLocal("Forestry.allele.slow");
return Translator.translateToLocal("forestry.allele.slow");
} else if (metabolism >= 4) {
return Translator.translateToLocal("Forestry.allele.slower");
return Translator.translateToLocal("forestry.allele.slower");
} else {
return Translator.translateToLocal("Forestry.allele.slowest");
return Translator.translateToLocal("forestry.allele.slowest");
}
}
@@ -115,11 +115,15 @@ public abstract class Genome implements IGenome {
* Quickly gets the species without loading the whole genome.
* We need this because the client uses the species for rendering.
*/
protected static IAlleleSpecies getSpeciesDirectly(ItemStack itemStack) {
public static IAlleleSpecies getSpeciesDirectly(ItemStack itemStack) {
NBTTagCompound nbtTagCompound = itemStack.getTagCompound();
if (nbtTagCompound == null) {
return null;
}
return getSpeciesDirectly(nbtTagCompound);
}
public static IAlleleSpecies getSpeciesDirectly(@Nonnull NBTTagCompound nbtTagCompound) {
NBTTagCompound genomeNBT = nbtTagCompound.getCompoundTag("Genome");
if (genomeNBT == null) {
@@ -9,9 +9,9 @@ import forestry.core.utils.Translator;
* For example, temperature tolerances or speeds are categories with several values.
*
* This class helps localization by allowing specific names like
* Forestry.allele.speed.fast
* forestry.allele.speed.fast
* and can fall back on generic names like
* Forestry.allele.fast
* forestry.allele.fast
*/
public abstract class AlleleCategorized extends Allele {
protected AlleleCategorized(String modId, String category, String valueName, boolean isDominant) {
@@ -16,7 +16,9 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.IFluidTank;
import forestry.api.core.IToolPipette;
@@ -60,17 +62,21 @@ public class ContainerLiquidTanksHelper<T extends TileEntity & ILiquidTankTile>
if (pipette.canPipette(itemstack) && liquidAmount > 0) {
if (liquidAmount > 0) {
FluidStack fillAmount = tank.drain(1000, false);
int filled = pipette.fill(itemstack, fillAmount, true);
tank.drain(filled, true);
player.updateHeldItem();
if (tank instanceof FluidTank) {
FluidStack fillAmount = ((FluidTank) tank).drainInternal(Fluid.BUCKET_VOLUME, false);
int filled = pipette.fill(itemstack, fillAmount, true);
tank.drain(filled, true);
player.updateHeldItem();
}
}
} else {
FluidStack potential = pipette.drain(itemstack, pipette.getCapacity(itemstack), false);
if (potential != null) {
int fill = tank.fill(potential, true);
pipette.drain(itemstack, fill, true);
player.updateHeldItem();
if (tank instanceof FluidTank) {
int fill = ((FluidTank) tank).fillInternal(potential, true);
pipette.drain(itemstack, fill, true);
player.updateHeldItem();
}
}
}
}
@@ -51,8 +51,6 @@ public class GuiAlyzer extends GuiForestry<ContainerAlyzer, IInventory> {
public static final int COLUMN_1 = 90;
public static final int COLUMN_2 = 155;
protected final Map<String, ItemStack> iconStacks = new HashMap<>();
public GuiAlyzer(EntityPlayer player, ItemInventoryAlyzer inventory) {
super(Constants.TEXTURE_PATH_GUI + "/portablealyzer.png", new ContainerAlyzer(inventory, player), inventory);
@@ -104,6 +102,8 @@ public class GuiAlyzer extends GuiForestry<ContainerAlyzer, IInventory> {
textLayout.drawLine(text0, textLayout.column0);
int columnwidth = textLayout.column2 - textLayout.column1 - 2;
Map<String, ItemStack> iconStacks = chromosome.getSpeciesRoot().getAlyzerPlugin().getIconStacks();
GuiUtil.drawItemStack(this, iconStacks.get(primary.getUID()), guiLeft + textLayout.column1 + columnwidth - 20, guiTop + 10);
GuiUtil.drawItemStack(this, iconStacks.get(secondary.getUID()), guiLeft + textLayout.column2 + columnwidth - 20, guiTop + 10);
@@ -335,6 +335,8 @@ public class GuiAlyzer extends GuiForestry<ContainerAlyzer, IInventory> {
public void drawMutationInfo(IMutation combination, IAllele species, int x, IBreedingTracker breedingTracker) {
Map<String, ItemStack> iconStacks = combination.getRoot().getAlyzerPlugin().getIconStacks();
ItemStack partnerBee = iconStacks.get(combination.getPartner(species).getUID());
widgetManager.add(new ItemStackWidget(widgetManager, x, textLayout.getLineY(), partnerBee));
@@ -154,27 +154,21 @@ public class InventoryAdapter implements IInventoryAdapter, IStreamable {
}
/* ISIDEDINVENTORY */
private int[][] slotMap;
private int[] slotMap;
@Override
public int[] getSlotsForFace(EnumFacing side) {
if (allowAutomation) {
return slotMap[side.ordinal()];
return slotMap;
}
return Constants.SLOTS_NONE;
}
private void configureSided() {
slotMap = new int[6][0];
int count = getSizeInventory();
int[] slots = new int[count];
slotMap = new int[count];
for (int i = 0; i < count; i++) {
slots[i] = i;
}
for (EnumFacing side : EnumFacing.VALUES) {
slotMap[side.getIndex()] = slots;
slotMap[i] = i;
}
}
@@ -13,12 +13,12 @@ package forestry.core.inventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil;
import forestry.api.arboriculture.TreeManager;
import forestry.api.core.ForestryAPI;
import forestry.api.genetics.AlleleManager;
import forestry.core.fluids.FluidHelper;
import forestry.core.tiles.TileAnalyzer;
import forestry.core.utils.GeneticsUtil;
import forestry.core.utils.SlotUtil;
@@ -41,8 +41,8 @@ public class InventoryAnalyzer extends InventoryAdapterTile<TileAnalyzer> {
if (SlotUtil.isSlotInRange(slotIndex, SLOT_INPUT_1, SLOT_INPUT_COUNT)) {
return AlleleManager.alleleRegistry.isIndividual(itemStack) || GeneticsUtil.getGeneticEquivalent(itemStack) != null;
} else if (slotIndex == SLOT_CAN) {
Fluid fluid = FluidHelper.getFluidInContainer(itemStack);
return tile.getTankManager().accepts(fluid);
FluidStack fluid = FluidUtil.getFluidContained(itemStack);
return tile.getTankManager().canFillFluidType(fluid);
}
return false;
@@ -0,0 +1,51 @@
package forestry.core.items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.templates.FluidHandlerItemStackSimple;
public class FluidHandlerItemForestry extends FluidHandlerItemStackSimple.Consumable {
private final EnumContainerType containerType;
public FluidHandlerItemForestry(ItemStack container, EnumContainerType containerType) {
super(container, Fluid.BUCKET_VOLUME);
this.containerType = containerType;
}
private boolean contentsAllowed(FluidStack fluidStack) {
if (fluidStack == null) {
return false;
}
Fluid fluid = fluidStack.getFluid();
if (fluid == null) {
return false;
}
switch (containerType) {
case CAPSULE:
return fluid.getTemperature(fluidStack) < 310.15; // melting point of wax in kelvin
default:
return true;
}
}
@Override
public boolean canFillFluidType(FluidStack fluid) {
return contentsAllowed(fluid);
}
@Override
public boolean canDrainFluidType(FluidStack fluid) {
return contentsAllowed(fluid);
}
@Override
protected void setFluid(FluidStack fluid) {
super.setFluid(fluid);
container.setItemDamage(1); // show the filled container model
}
}
@@ -58,18 +58,20 @@ public class ItemBlockForestry<B extends Block> extends ItemBlock {
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState) {
boolean placed = super.placeBlockAt(stack, player, world, pos, side, hitX, hitY, hitZ, newState);
if (block.hasTileEntity(newState)) {
if (stack.getItem() instanceof ItemBlockNBT && stack.hasTagCompound()) {
TileForestry tile = TileUtil.getTile(world, pos, TileForestry.class);
if (tile != null) {
tile.readFromNBT(stack.getTagCompound());
tile.setPos(pos);
if (placed) {
if (block.hasTileEntity(newState)) {
if (stack.getItem() instanceof ItemBlockNBT && stack.hasTagCompound()) {
TileForestry tile = TileUtil.getTile(world, pos, TileForestry.class);
if (tile != null) {
tile.readFromNBT(stack.getTagCompound());
tile.setPos(pos);
}
}
}
}
if (block instanceof BlockBase) {
((BlockBase) block).rotateAfterPlacement(player, world, pos, side);
if (block instanceof BlockBase) {
((BlockBase) block).rotateAfterPlacement(player, world, pos, side);
}
}
return placed;
@@ -0,0 +1,190 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.core.items;
import java.util.List;
import java.util.Locale;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.EnumAction;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.stats.StatList;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.FoodStats;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraft.world.World;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.core.IModelManager;
import forestry.core.CreativeTabForestry;
import forestry.core.config.Constants;
import forestry.core.fluids.Fluids;
import forestry.core.utils.Translator;
public class ItemFluidContainerForestry extends ItemForestry {
private final EnumContainerType type;
public ItemFluidContainerForestry(EnumContainerType type) {
super(CreativeTabForestry.tabForestry);
this.type = type;
}
/* Models */
@SideOnly(Side.CLIENT)
@Override
public void registerModel(Item item, IModelManager manager) {
String identifier = "liquids/" + type.toString().toLowerCase(Locale.ENGLISH);
manager.registerItemModel(item, 0, identifier + "_empty");
ModelLoader.setCustomModelResourceLocation(item, 1, new ModelResourceLocation(new ResourceLocation(Constants.MOD_ID, identifier), "inventory"));
}
@SideOnly(Side.CLIENT)
@Override
public void getSubItems(Item itemIn, CreativeTabs tab, List<ItemStack> subItems) {
// empty
subItems.add(new ItemStack(itemIn));
// filled
for (Fluid fluid : FluidRegistry.getRegisteredFluids().values()) {
ItemStack itemStack = new ItemStack(itemIn);
IFluidHandler fluidHandler = new FluidHandlerItemForestry(itemStack, type);
if (fluidHandler.fill(new FluidStack(fluid, Fluid.BUCKET_VOLUME), true) == Fluid.BUCKET_VOLUME) {
subItems.add(itemStack);
}
}
}
public EnumContainerType getType() {
return type;
}
protected FluidStack getContained(ItemStack itemStack) {
if (itemStack.stackSize != 1) {
itemStack = itemStack.copy();
itemStack.stackSize = 1;
}
IFluidHandler fluidHandler = new FluidHandlerItemForestry(itemStack, type);
return fluidHandler.drain(Integer.MAX_VALUE, false);
}
@Override
public String getItemStackDisplayName(ItemStack stack) {
Item item = stack.getItem();
if (item instanceof ItemFluidContainerForestry) {
FluidStack fluid = getContained(stack);
if (fluid != null) {
String exactTranslationKey = "item.for." + type.getName() + '.' + fluid.getFluid().getName() + ".name";
if (Translator.canTranslateToLocal(exactTranslationKey)) {
return Translator.translateToLocal(exactTranslationKey);
} else {
String grammarKey = "item.for." + type.getName() + ".grammar";
return Translator.translateToLocalFormatted(grammarKey, fluid.getLocalizedName());
}
} else {
String unlocalizedname = "item.for." + type.getName() + ".empty.name";
return Translator.translateToLocal(unlocalizedname);
}
}
return super.getItemStackDisplayName(stack);
}
/** DRINKS */
@Override
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving) {
DrinkProperties drinkProperties = getDrinkProperties(stack);
if (drinkProperties != null) {
if (entityLiving instanceof EntityPlayer && !((EntityPlayer) entityLiving).capabilities.isCreativeMode) {
EntityPlayer player = (EntityPlayer) entityLiving;
if (!player.capabilities.isCreativeMode) {
--stack.stackSize;
}
if (!worldIn.isRemote) {
FoodStats foodStats = player.getFoodStats();
foodStats.addStats(drinkProperties.getHealAmount(), drinkProperties.getSaturationModifier());
worldIn.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.PLAYERS, 0.5F, worldIn.rand.nextFloat() * 0.1F + 0.9F);
}
player.addStat(StatList.getObjectUseStats(this));
}
}
return stack;
}
protected DrinkProperties getDrinkProperties(ItemStack itemStack) {
FluidStack contained = getContained(itemStack);
if (contained != null) {
Fluids definition = Fluids.getFluidDefinition(contained);
if (definition != null) {
return definition.getDrinkProperties();
}
}
return null;
}
@Override
public int getMaxItemUseDuration(ItemStack itemstack) {
DrinkProperties drinkProperties = getDrinkProperties(itemstack);
if (drinkProperties != null) {
return drinkProperties.getMaxItemUseDuration();
} else {
return super.getMaxItemUseDuration(itemstack);
}
}
@Override
public EnumAction getItemUseAction(ItemStack itemstack) {
DrinkProperties drinkProperties = getDrinkProperties(itemstack);
if (drinkProperties != null) {
return EnumAction.DRINK;
} else {
return EnumAction.NONE;
}
}
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) {
DrinkProperties drinkProperties = getDrinkProperties(itemStackIn);
if (drinkProperties != null) {
if (playerIn.canEat(false)) {
playerIn.setActiveHand(hand);
return new ActionResult<>(EnumActionResult.SUCCESS, itemStackIn);
} else {
return new ActionResult<>(EnumActionResult.FAIL, itemStackIn);
}
} else {
return super.onItemRightClick(itemStackIn, worldIn, playerIn, hand);
}
}
@Override
public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt)
{
return new FluidHandlerItemForestry(stack, type);
}
}
Loaded 100 of 238 files, more files were not shown because too many files have changed in this diff. Show more