Compare commits

..
41 Commits
Author SHA1 Message Date
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
115 changed files with 1093 additions and 905 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.1950
forgeversion=12.17.0.1957
mcp_mappings=snapshot_20160525
jei_version=3.4.0.+
jei_version=3.6.0.+
ic2_version=2.5.5-ex19
version_major=5
version_minor=0
version_patch=7
version_patch=13
+1 -1
Submodule lang updated: 0e7f1e47f1...9be86d3c99.
+1
View File
@@ -57,6 +57,7 @@ import forestry.plugins.PluginManager;
+ "after:IC2@[2.3.235,);"
+ "after:Natura@[2.2.0,);"
+ "after:HardcoreEnderExpansion;"
+ "after:JEI@[3.6.0,);"
+ "after:basemetals;")
public class Forestry {
@@ -36,6 +36,12 @@ 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 */
@@ -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);
}
@@ -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();
}
@@ -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);
@@ -130,16 +130,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
@@ -275,9 +271,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,
@@ -287,19 +286,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();
@@ -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));
}
}
}
@@ -1,15 +1,20 @@
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 net.minecraft.nbt.NBTTagCompound;
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.INbtRegistry;
import mezz.jei.api.JEIPlugin;
@JEIPlugin
@@ -34,5 +39,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");
INbtRegistry nbtRegistry = registry.getJeiHelpers().getNbtRegistry();
nbtRegistry.registerNbtInterpreter(PluginApiculture.items.beeDroneGE, BeeNbtInterpreter.INSTANCE);
nbtRegistry.registerNbtInterpreter(PluginApiculture.items.beePrincessGE, BeeNbtInterpreter.INSTANCE);
nbtRegistry.registerNbtInterpreter(PluginApiculture.items.beeQueenGE, BeeNbtInterpreter.INSTANCE);
}
private static class BeeNbtInterpreter implements INbtRegistry.INbtInterpreter {
public static BeeNbtInterpreter INSTANCE = new BeeNbtInterpreter();
@Nullable
@Override
public String getSubtypeInfoFromNbt(@Nonnull NBTTagCompound nbtTagCompound) {
IAlleleSpecies species = BeeGenome.getSpeciesDirectly(nbtTagCompound);
return species == null ? null : species.getUID();
}
}
}
@@ -123,6 +123,13 @@ public class ParticleBeeExplore extends Particle {
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;
@@ -126,6 +126,13 @@ public class ParticleBeeRoundTrip extends Particle {
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");
@@ -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;
@@ -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() {
}
}
@@ -16,8 +16,4 @@ public class ProxyApicultureClient extends ProxyApiculture {
public static TextureAtlasSprite beeSprite;
@Override
public void initializeRendering() {
// TODO: remove unused bee entity model completely
}
}
@@ -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);
}
}
@@ -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;
@@ -47,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;
@@ -192,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)))
{
@@ -229,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){
@@ -312,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));
}
@@ -407,7 +406,7 @@ public abstract class BlockPile extends BlockStructure implements ITileEntityPro
@Nonnull
private List<ItemStack> getPileDrop(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
ArrayList<ItemStack> list = new ArrayList<ItemStack>();
List<ItemStack> list = new ArrayList<>();
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof ICharcoalPileComponent) {
ICharcoalPileComponent pile = (ICharcoalPileComponent) tile;
@@ -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");
@@ -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;
@@ -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;
@@ -32,6 +32,7 @@ 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;
@@ -61,6 +62,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 +135,8 @@ public class PluginCore extends BlankForestryPlugin {
AlleleHelper.instance.init();
Proxies.render.initRendering();
RecipeSorter.register("forestry:shaped", ShapedRecipeCustom.class, RecipeSorter.Category.SHAPED, "");
}
@Override
+18 -10
View File
@@ -10,6 +10,16 @@
******************************************************************************/
package forestry.core;
import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
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.ForgeRegistries;
import net.minecraftforge.fml.common.registry.GameRegistry;
import forestry.api.core.ForestryAPI;
import forestry.api.fuels.FuelManager;
import forestry.api.fuels.GeneratorFuel;
@@ -23,14 +33,6 @@ import forestry.core.utils.Log;
import forestry.plugins.BlankForestryPlugin;
import forestry.plugins.ForestryPlugin;
import forestry.plugins.ForestryPluginUids;
import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
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.GameRegistry;
@ForestryPlugin(pluginID = ForestryPluginUids.FLUIDS, name = "Fluids", author = "mezz", url = Constants.URL, unlocalizedDescription = "for.plugin.fluids.description")
public class PluginFluids extends BlankForestryPlugin {
@@ -62,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());
@@ -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>(){
@@ -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);
}
@@ -275,6 +275,7 @@ public class TankManager implements ITankManager, ITankUpdateHandler, IStreamabl
return tank.drain(maxDrain, doDrain);
}
@Override
public FluidStack drain(FluidStack resource, boolean doDrain) {
for (StandardTank tank : tanks) {
if (tankCanDrainFluid(tank, resource)) {
@@ -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) {
@@ -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));
@@ -132,7 +132,7 @@ public class ItemFluidContainerForestry extends ItemForestry implements IColored
if (!worldIn.isRemote) {
FoodStats foodStats = player.getFoodStats();
foodStats.addStats(drinkProperties.getHealAmount(), drinkProperties.getSaturationModifier());
worldIn.playSound((EntityPlayer) null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.PLAYERS, 0.5F, worldIn.rand.nextFloat() * 0.1F + 0.9F);
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));
@@ -178,7 +178,7 @@ public class ModelCrate extends BlankItemModel {
* Bake the crate model.
*/
private List<IBakedModel> bakeModel(ItemCrated crateItem, IBakedModel crateModel) {
List<IBakedModel> models = new ArrayList();
List<IBakedModel> models = new ArrayList<>();
IBakedModel containedModel = getModel(crateItem.getContained());
@@ -235,7 +235,7 @@ public class ModelCrate extends BlankItemModel {
@Override
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand) {
List<BakedQuad> quads = new ArrayList();
List<BakedQuad> quads = new ArrayList<>();
for(IBakedModel bakedModel : models){
quads.addAll(bakedModel.getQuads(null, side, rand++));
}
@@ -11,6 +11,7 @@
package forestry.core.models.baker;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -56,14 +57,14 @@ public class ModelBakerModel implements IModelBakerModel {
public ModelBakerModel(IModelState modelState) {
models = new ArrayList<>();
faceQuads = new HashMap<>();
faceQuads = new EnumMap<>(EnumFacing.class);
generalQuads = new ArrayList<>();
isGui3d = true;
isAmbientOcclusion = false;
setModelState(modelState);
for(EnumFacing face : EnumFacing.VALUES){
faceQuads.put(face, new ArrayList());
faceQuads.put(face, new ArrayList<>());
}
}
@@ -194,7 +194,7 @@ public abstract class MultiblockTileEntityForestry<T extends IMultiblockLogic> e
}
/* IMultiblockComponent */
@Nullable
@Nonnull
@Override
public final GameProfile getOwner() {
return owner;
@@ -23,7 +23,6 @@ import net.minecraft.client.resources.IResourceManager;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3i;
import net.minecraft.world.World;
import net.minecraftforge.common.animation.ITimeValue;
@@ -16,18 +16,6 @@ public class ForestryTooltipCallback implements ITooltipCallback<ItemStack> {
private final ArrayListMultimap<Integer, String> tooltips = ArrayListMultimap.create();
public void addToTooltip(int index, List<String> tooltip) {
tooltips.get(index).addAll(tooltip);
}
public void addToTooltip(int index, String tooltip) {
tooltips.get(index).add(tooltip);
}
public List<String> getTooltip(int index) {
return tooltips.get(index);
}
@Override
public void onTooltip(int index, boolean input, ItemStack ingredient, List<String> tooltip) {
List<String> tip = tooltips.get(index);
@@ -36,20 +24,18 @@ public class ForestryTooltipCallback implements ITooltipCallback<ItemStack> {
}
}
public void clearTooltip(){
tooltips.clear();
}
public void addChanceTooltip(int index, float chance) {
if (chance <= 0.0F) {
tooltips.get(index).add(TextFormatting.GRAY + String.format(Translator.translateToLocal("forestry.jei.chance"), Translator.translateToLocal("forestry.jei.chance.never")));
} else if (chance < 0.01F) {
tooltips.get(index).add(TextFormatting.GRAY + String.format(Translator.translateToLocal("forestry.jei.chance"), Translator.translateToLocal("forestry.jei.chance.lessThan1")));
} else if (chance != 1.0F) {
NumberFormat percentFormat = NumberFormat.getPercentInstance();
percentFormat.setMaximumFractionDigits(2);
tooltips.get(index).add(TextFormatting.GRAY + String.format(Translator.translateToLocal("forestry.jei.chance"), String.valueOf(percentFormat.format(chance))));
if (chance < 0) {
chance = 0;
} else if (chance > 1.0) {
chance = 1.0f;
}
NumberFormat percentFormat = NumberFormat.getPercentInstance();
percentFormat.setMaximumFractionDigits(2);
String chanceString = String.valueOf(percentFormat.format(chance));
tooltips.get(index).add(TextFormatting.GRAY + Translator.translateToLocalFormatted("for.jei.chance", chanceString));
}
}
@@ -12,11 +12,54 @@ package forestry.core.tiles;
import javax.annotation.Nonnull;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import net.minecraftforge.fluids.capability.IFluidTankProperties;
import forestry.core.fluids.ITankManager;
public interface ILiquidTankTile extends ILocatable {
public interface ILiquidTankTile extends ILocatable, IFluidHandler {
@Nonnull
ITankManager getTankManager();
@Override
default int fill(EnumFacing from, FluidStack resource, boolean doFill) {
return getTankManager().fill(resource, doFill);
}
@Override
default FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) {
return getTankManager().drain(resource, doDrain);
}
@Override
default FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) {
return getTankManager().drain(maxDrain, doDrain);
}
@Override
default boolean canFill(EnumFacing from, Fluid fluid) {
return getTankManager().canFillFluidType(new FluidStack(fluid, Fluid.BUCKET_VOLUME));
}
@Override
default boolean canDrain(EnumFacing from, Fluid fluid) {
return getTankManager().canDrainFluidType(new FluidStack(fluid, Fluid.BUCKET_VOLUME));
}
@Override
default FluidTankInfo[] getTankInfo(EnumFacing from) {
IFluidTankProperties[] tankProperties = getTankManager().getTankProperties();
FluidTankInfo[] tankInfos = new FluidTankInfo[tankProperties.length];
for (int i = 0; i < tankProperties.length; i++) {
IFluidTankProperties fluidTankProperties = tankProperties[i];
tankInfos[i] = new FluidTankInfo(fluidTankProperties.getContents(), fluidTankProperties.getCapacity());
}
return tankInfos;
}
}
@@ -15,6 +15,7 @@ import java.io.IOException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.AxisAlignedBB;
import forestry.api.genetics.ISpeciesRoot;
@@ -68,7 +69,7 @@ public abstract class TileNaturalistChest extends TileBase implements IPagedInve
prevLidAngle = lidAngle;
if (numPlayersUsing > 0 && lidAngle == 0.0F) {
playLidSound("random.chestopen");
playLidSound(SoundEvents.BLOCK_CHEST_OPEN);
}
if (numPlayersUsing == 0 && lidAngle > 0.0F || numPlayersUsing > 0 && lidAngle < 1.0F) {
@@ -83,13 +84,13 @@ public abstract class TileNaturalistChest extends TileBase implements IPagedInve
lidAngle = Math.max(Math.min(lidAngle, 1), 0);
if (lidAngle < 0.5F && oldAngle >= 0.5F) {
playLidSound("random.chestclosed");
playLidSound(SoundEvents.BLOCK_CHEST_CLOSE);
}
}
}
private void playLidSound(String sound) {
this.worldObj.playSound((EntityPlayer)null, getPos(), SoundEvents.BLOCK_CHEST_OPEN, SoundCategory.BLOCKS, 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F);
private void playLidSound(SoundEvent sound) {
this.worldObj.playSound(null, getPos(), sound, SoundCategory.BLOCKS, 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F);
}
@Override
@@ -23,12 +23,12 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.FMLControlledNamespacedRegistry;
import net.minecraftforge.fml.common.registry.GameData;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import net.minecraftforge.fml.common.registry.IForgeRegistry;
import net.minecraftforge.oredict.OreDictionary;
public abstract class ItemStackUtil {
@@ -68,8 +68,8 @@ public abstract class ItemStackUtil {
if (item == null) {
return null;
}
FMLControlledNamespacedRegistry<Item> itemRegistry = GameData.getItemRegistry();
return itemRegistry.getNameForObject(item);
IForgeRegistry<Item> itemRegistry = ForgeRegistries.ITEMS;
return itemRegistry.getKey(item);
}
/**
@@ -125,12 +125,8 @@ public abstract class ItemStackUtil {
if (itemName == null) {
return null;
}
FMLControlledNamespacedRegistry<Item> itemRegistry = GameData.getItemRegistry();
int registryID = itemRegistry.getId(itemName);
if (registryID == -1) {
return null;
}
return itemRegistry.getRaw(registryID);
IForgeRegistry<Item> itemRegistry = ForgeRegistries.ITEMS;
return itemRegistry.getValue(itemName);
}
/**
@@ -141,8 +137,8 @@ public abstract class ItemStackUtil {
if (block == null) {
return null;
}
FMLControlledNamespacedRegistry<Block> blockRegistry = GameData.getBlockRegistry();
return blockRegistry.getNameForObject(block);
IForgeRegistry<Block> blockRegistry = ForgeRegistries.BLOCKS;
return blockRegistry.getKey(block);
}
/**
@@ -169,12 +165,8 @@ public abstract class ItemStackUtil {
if (itemName == null) {
return null;
}
FMLControlledNamespacedRegistry<Block> blockRegistry = GameData.getBlockRegistry();
int registryID = blockRegistry.getId(itemName);
if (registryID == -1) {
return null;
}
return blockRegistry.getRaw(registryID);
IForgeRegistry<Block> blockRegistry = ForgeRegistries.BLOCKS;
return blockRegistry.getValue(itemName);
}
/**
@@ -1,12 +1,5 @@
package forestry.core.utils;
import javax.annotation.Nullable;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
public class OreDictUtil {
public static final String ORE_COPPER = "oreCopper";
public static final String ORE_TIN = "oreTin";
@@ -174,4 +174,59 @@ public class VillagerTradeLists {
recipeList.add(new MerchantRecipe(randomLog, new ItemStack(Items.EMERALD, emeraldsAmount), itemToSell));
}
}
public static class GiveItemForTwoItems implements EntityVillager.ITradeList {
@Nonnull
public ItemStack buyingItemStack;
@Nullable
public EntityVillager.PriceInfo buyingPriceInfo;
@Nonnull
public ItemStack buyingItemStackTwo;
@Nullable
public EntityVillager.PriceInfo buyingPriceItemTwoInfo;
@Nonnull
public ItemStack sellingItemstack;
@Nullable
public EntityVillager.PriceInfo sellingPriceInfo;
public GiveItemForTwoItems(
@Nonnull ItemStack buyingItemStack,
@Nullable EntityVillager.PriceInfo buyingPriceInfo,
@Nonnull ItemStack buyingItemStackTwo,
@Nullable EntityVillager.PriceInfo buyingPriceItemTwoInfo,
@Nonnull ItemStack sellingItemstack,
@Nullable EntityVillager.PriceInfo sellingPriceInfo) {
this.buyingItemStack = buyingItemStack;
this.buyingPriceInfo = buyingPriceInfo;
this.buyingItemStackTwo = buyingItemStackTwo;
this.buyingPriceItemTwoInfo = buyingPriceItemTwoInfo;
this.sellingItemstack = sellingItemstack;
this.sellingPriceInfo = sellingPriceInfo;
}
@Override
public void modifyMerchantRecipeList(MerchantRecipeList recipeList, 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);
}
int sellAmount = 1;
if (this.sellingPriceInfo != null) {
sellAmount = this.sellingPriceInfo.getPrice(random);
}
ItemStack buyItemStack = this.buyingItemStack.copy();
buyItemStack.stackSize = buyAmount;
ItemStack buyItemStackTwo = this.buyingItemStackTwo.copy();
buyItemStackTwo.stackSize = buyTwoAmount;
ItemStack sellItemStack = this.sellingItemstack.copy();
sellItemStack.stackSize = sellAmount;
recipeList.add(new MerchantRecipe(buyItemStack, buyItemStackTwo, sellItemStack));
}
}
}
@@ -14,9 +14,9 @@ import net.minecraft.entity.player.InventoryPlayer;
import forestry.core.config.Constants;
import forestry.core.gui.widgets.SocketWidget;
import forestry.core.render.EnumTankLevel;
import forestry.energy.tiles.TileEngineElectric;
// TODO: IC2 for 1.9
public class GuiEngineElectric extends GuiEngine<ContainerEngineElectric, TileEngineElectric> {
public GuiEngineElectric(InventoryPlayer inventory, TileEngineElectric tile) {
@@ -24,23 +24,23 @@ public class GuiEngineElectric extends GuiEngine<ContainerEngineElectric, TileEn
widgetManager.add(new SocketWidget(this.widgetManager, 30, 40, tile, 0));
}
// @Override
// protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
// super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
//
// TileEngineElectric engine = inventory;
// int storageHeight = engine.getStorageScaled(46);
// int storageMaxHeight = engine.getStorageScaled(100);
// EnumTankLevel rated = EnumTankLevel.rateTankLevel(storageMaxHeight);
//
// drawHealthMeter(guiLeft + 74, guiTop + 25, storageHeight, rated);
// }
//
// private void drawHealthMeter(int x, int y, int height, EnumTankLevel rated) {
// int i = 176 + rated.getLevelScaled(16);
// int k = 0;
//
// this.drawTexturedModalRect(x, y + 46 - height, i, k + 46 - height, 4, height);
// }
@Override
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
TileEngineElectric engine = inventory;
int storageHeight = engine.getStorageScaled(46);
int storageMaxHeight = engine.getStorageScaled(100);
EnumTankLevel rated = EnumTankLevel.rateTankLevel(storageMaxHeight);
drawHealthMeter(guiLeft + 74, guiTop + 25, storageHeight, rated);
}
private void drawHealthMeter(int x, int y, int height, EnumTankLevel rated) {
int i = 176 + rated.getLevelScaled(16);
int k = 0;
this.drawTexturedModalRect(x, y + 46 - height, i, k + 46 - height, 4, height);
}
}
@@ -17,7 +17,6 @@ import forestry.core.gui.GuiForestryTitled;
import forestry.core.gui.widgets.TankWidget;
import forestry.energy.tiles.TileEuGenerator;
// TODO: IC2 for 1.9
public class GuiGenerator extends GuiForestryTitled<ContainerGenerator, TileEuGenerator> {
public GuiGenerator(InventoryPlayer inventory, TileEuGenerator tile) {
@@ -25,14 +24,14 @@ public class GuiGenerator extends GuiForestryTitled<ContainerGenerator, TileEuGe
widgetManager.add(new TankWidget(this.widgetManager, 49, 17, 0));
}
// @Override
// protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
// super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
//
// int progress = inventory.getStoredScaled(49);
// if (progress > 0) {
// drawTexturedModalRect(guiLeft + 108, guiTop + 38, 176, 91, progress, 18);
// }
// }
@Override
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
int progress = inventory.getStoredScaled(49);
if (progress > 0) {
drawTexturedModalRect(guiLeft + 108, guiTop + 38, 176, 91, progress, 18);
}
}
}
@@ -15,7 +15,8 @@ import net.minecraft.item.ItemStack;
import forestry.core.inventory.InventoryAdapterTile;
import forestry.energy.tiles.TileEngineElectric;
// TODO: IC2 for 1.9
import ic2.api.item.ElectricItem;
public class InventoryEngineElectric extends InventoryAdapterTile<TileEngineElectric> {
public static final short SLOT_BATTERY = 0;
@@ -25,9 +26,9 @@ public class InventoryEngineElectric extends InventoryAdapterTile<TileEngineElec
@Override
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
// if (slotIndex == SLOT_BATTERY) {
// return ElectricItem.manager.getCharge(itemStack) > 0;
// }
if (slotIndex == SLOT_BATTERY) {
return ElectricItem.manager.getCharge(itemStack) > 0;
}
return false;
}
}
@@ -113,18 +113,18 @@ public class TileEngineBiogas extends TileEngine implements ISidedInventory, ILi
{
if (heatingTank.getFluidAmount() > 0 && Fluids.LAVA.is(heatingTank.getFluid())) {
addHeat(Constants.ENGINE_HEAT_VALUE_LAVA);
heatingTank.drain(1, true);
heatingTank.drainInternal(1, true);
}
}
// We need a minimum temperature to generate energy
if (heatStage > 0.2) {
if (burnTank.getFluidAmount() > 0) {
FluidStack drained = burnTank.drain(1, true);
FluidStack drained = burnTank.drainInternal(1, true);
currentOutput = determineFuelValue(drained.getFluid());
energyManager.generateEnergy(currentOutput);
} else {
FluidStack fuel = fuelTank.drain(Fluid.BUCKET_VOLUME, true);
FluidStack fuel = fuelTank.drainInternal(Fluid.BUCKET_VOLUME, true);
int burnTime = determineBurnTime(fuel.getFluid());
fuel.amount = burnTime;
burnTank.setCapacity(burnTime);
@@ -27,6 +27,7 @@ import forestry.api.circuits.ICircuitSocketType;
import forestry.api.core.IErrorLogic;
import forestry.core.circuits.ISocketable;
import forestry.core.config.Constants;
import forestry.core.errors.EnumErrorCode;
import forestry.core.inventory.InventoryAdapter;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
@@ -36,8 +37,10 @@ import forestry.core.tiles.TileEngine;
import forestry.energy.gui.ContainerEngineElectric;
import forestry.energy.gui.GuiEngineElectric;
import forestry.energy.inventory.InventoryEngineElectric;
import forestry.plugins.compat.PluginIC2;
import ic2.api.energy.prefab.BasicSink;
// TODO: IC2 for 1.9
public class TileEngineElectric extends TileEngine implements ISocketable, IInventory, IStreamableGui {
protected static class EuConfig {
@@ -55,16 +58,16 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve
private final InventoryAdapter sockets = new InventoryAdapter(1, "sockets");
private final EuConfig euConfig = new EuConfig();
// private BasicSink ic2EnergySink;
private BasicSink ic2EnergySink;
public TileEngineElectric() {
super("engine.tin", Constants.ENGINE_ELECTRIC_HEAT_MAX, 100000);
setInternalInventory(new InventoryEngineElectric(this));
// if (PluginIC2.instance.isAvailable()) {
// ic2EnergySink = new BasicSink(this, euConfig.euStorage, 3);
// }
if (PluginIC2.instance.isAvailable()) {
ic2EnergySink = new BasicSink(this, euConfig.euStorage, 3);
}
}
// / SAVING / LOADING
@@ -72,9 +75,9 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve
public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound);
// if (ic2EnergySink != null) {
// ic2EnergySink.readFromNBT(nbttagcompound);
// }
if (ic2EnergySink != null) {
ic2EnergySink.readFromNBT(nbttagcompound);
}
sockets.readFromNBT(nbttagcompound);
ItemStack chip = sockets.getStackInSlot(0);
@@ -91,27 +94,27 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
nbttagcompound = super.writeToNBT(nbttagcompound);
// if (ic2EnergySink != null) {
// ic2EnergySink.writeToNBT(nbttagcompound);
// }
if (ic2EnergySink != null) {
ic2EnergySink.writeToNBT(nbttagcompound);
}
sockets.writeToNBT(nbttagcompound);
return nbttagcompound;
}
@Override
public void onChunkUnload() {
// if (ic2EnergySink != null) {
// ic2EnergySink.onChunkUnload();
// }
if (ic2EnergySink != null) {
ic2EnergySink.onChunkUnload();
}
super.onChunkUnload();
}
@Override
public void invalidate() {
// if (ic2EnergySink != null) {
// ic2EnergySink.invalidate();
// }
if (ic2EnergySink != null) {
ic2EnergySink.invalidate();
}
super.invalidate();
}
@@ -159,11 +162,11 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve
IErrorLogic errorLogic = getErrorLogic();
// No work to be done if IC2 is unavailable.
// if (errorLogic.setCondition(ic2EnergySink == null, EnumErrorCode.NO_ENERGY_NET)) {
// return;
// }
//
// ic2EnergySink.update();
if (errorLogic.setCondition(ic2EnergySink == null, EnumErrorCode.NO_ENERGY_NET)) {
return;
}
ic2EnergySink.update();
super.updateServerSide();
@@ -180,8 +183,8 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve
return;
}
// boolean canUseEnergy = ic2EnergySink.canUseEnergy(euConfig.euForCycle);
// errorLogic.setCondition(!canUseEnergy, EnumErrorCode.NO_FUEL);
boolean canUseEnergy = ic2EnergySink.canUseEnergy(euConfig.euForCycle);
errorLogic.setCondition(!canUseEnergy, EnumErrorCode.NO_FUEL);
}
@Override
@@ -193,10 +196,10 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve
return;
}
// if (ic2EnergySink.useEnergy(euConfig.euForCycle)) {
// currentOutput = euConfig.rfPerCycle;
// energyManager.generateEnergy(euConfig.rfPerCycle);
// }
if (ic2EnergySink.useEnergy(euConfig.euForCycle)) {
currentOutput = euConfig.rfPerCycle;
energyManager.generateEnergy(euConfig.rfPerCycle);
}
}
@@ -205,23 +208,22 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve
return;
}
// ic2EnergySink.discharge(getStackInSlot(slot), euConfig.euForCycle * 3);
ic2EnergySink.discharge(getStackInSlot(slot), euConfig.euForCycle * 3);
}
// / STATE INFORMATION
@Override
protected boolean isBurning() {
// TODO: IC2 for 1.9
return mayBurn();// && ic2EnergySink != null && ic2EnergySink.canUseEnergy(euConfig.euForCycle);
return mayBurn() && ic2EnergySink != null && ic2EnergySink.canUseEnergy(euConfig.euForCycle);
}
// public int getStorageScaled(int i) {
// if (ic2EnergySink == null) {
// return 0;
// }
//
// return Math.min(i, (int) (ic2EnergySink.getEnergyStored() * i) / ic2EnergySink.getCapacity());
// }
public int getStorageScaled(int i) {
if (ic2EnergySink == null) {
return 0;
}
return Math.min(i, (int) (ic2EnergySink.getEnergyStored() * i) / ic2EnergySink.getCapacity());
}
// / SMP GUI
@Override
@@ -230,11 +232,11 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve
data.writeVarInt(heat);
sockets.writeData(data);
energyManager.writeData(data);
// final boolean hasIc2EnergySink = (ic2EnergySink != null);
// data.writeBoolean(hasIc2EnergySink);
// if (hasIc2EnergySink) {
// data.writeVarInt((int) ic2EnergySink.getEnergyStored());
// }
final boolean hasIc2EnergySink = (ic2EnergySink != null);
data.writeBoolean(hasIc2EnergySink);
if (hasIc2EnergySink) {
data.writeVarInt((int) ic2EnergySink.getEnergyStored());
}
}
@Override
@@ -243,11 +245,11 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve
heat = data.readVarInt();
sockets.readData(data);
energyManager.readData(data);
// final boolean hasIc2EnergySink = data.readBoolean();
// if (hasIc2EnergySink) {
// final int energyStored = data.readVarInt();
// ic2EnergySink.setEnergyStored(energyStored);
// }
final boolean hasIc2EnergySink = data.readBoolean();
if (hasIc2EnergySink) {
final int energyStored = data.readVarInt();
ic2EnergySink.setEnergyStored(energyStored);
}
}
@Override
@@ -266,9 +268,9 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve
euConfig.rfPerCycle += rfChange;
euConfig.euStorage += storageChange;
// if (ic2EnergySink != null) {
// ic2EnergySink.setCapacity(euConfig.euStorage);
// }
if (ic2EnergySink != null) {
ic2EnergySink.setCapacity(euConfig.euStorage);
}
}
/* ISocketable */
@@ -25,6 +25,7 @@ import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import forestry.api.core.IErrorLogic;
import forestry.api.fuels.FuelManager;
import forestry.api.fuels.GeneratorFuel;
import forestry.core.config.Constants;
import forestry.core.errors.EnumErrorCode;
import forestry.core.fluids.FluidHelper;
@@ -40,8 +41,10 @@ import forestry.core.tiles.TileBase;
import forestry.energy.gui.ContainerGenerator;
import forestry.energy.gui.GuiGenerator;
import forestry.energy.inventory.InventoryGenerator;
import forestry.plugins.compat.PluginIC2;
import ic2.api.energy.prefab.BasicSource;
// TODO: IC2 for 1.9
public class TileEuGenerator extends TileBase implements ISidedInventory, ILiquidTankTile, IRenderableTile {
private static final int maxEnergy = 30000;
@@ -50,7 +53,7 @@ public class TileEuGenerator extends TileBase implements ISidedInventory, ILiqui
private int tickCount = 0;
// private BasicSource ic2EnergySource;
private BasicSource ic2EnergySource;
public TileEuGenerator() {
super("generator");
@@ -62,9 +65,9 @@ public class TileEuGenerator extends TileBase implements ISidedInventory, ILiqui
tankManager = new TankManager(this, resourceTank);
// if (PluginIC2.instance.isAvailable()) {
// ic2EnergySource = new BasicSource(this, maxEnergy, 1);
// }
if (PluginIC2.instance.isAvailable()) {
ic2EnergySource = new BasicSource(this, maxEnergy, 1);
}
}
@Nonnull
@@ -72,9 +75,9 @@ public class TileEuGenerator extends TileBase implements ISidedInventory, ILiqui
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
nbttagcompound = super.writeToNBT(nbttagcompound);
// if (ic2EnergySource != null) {
// ic2EnergySource.writeToNBT(nbttagcompound);
// }
if (ic2EnergySource != null) {
ic2EnergySource.writeToNBT(nbttagcompound);
}
tankManager.writeToNBT(nbttagcompound);
return nbttagcompound;
@@ -84,9 +87,9 @@ public class TileEuGenerator extends TileBase implements ISidedInventory, ILiqui
public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound);
// if (ic2EnergySource != null) {
// ic2EnergySource.readFromNBT(nbttagcompound);
// }
if (ic2EnergySource != null) {
ic2EnergySource.readFromNBT(nbttagcompound);
}
tankManager.readFromNBT(nbttagcompound);
}
@@ -105,18 +108,18 @@ public class TileEuGenerator extends TileBase implements ISidedInventory, ILiqui
@Override
public void onChunkUnload() {
// if (ic2EnergySource != null) {
// ic2EnergySource.onChunkUnload();
// }
if (ic2EnergySource != null) {
ic2EnergySource.onChunkUnload();
}
super.onChunkUnload();
}
@Override
public void invalidate() {
// if (ic2EnergySource != null) {
// ic2EnergySource.invalidate();
// }
if (ic2EnergySource != null) {
ic2EnergySource.invalidate();
}
super.invalidate();
}
@@ -130,25 +133,25 @@ public class TileEuGenerator extends TileBase implements ISidedInventory, ILiqui
IErrorLogic errorLogic = getErrorLogic();
// No work to be done if IC2 is unavailable.
// if (errorLogic.setCondition(ic2EnergySource == null, EnumErrorCode.NO_ENERGY_NET)) {
// return;
// }
//
// ic2EnergySource.update();
//
// if (resourceTank.getFluidAmount() > 0) {
// GeneratorFuel fuel = FuelManager.generatorFuel.get(resourceTank.getFluid().getFluid());
// if (resourceTank.canDrainFluidType(fuel.fuelConsumed) && ic2EnergySource.getFreeCapacity() >= fuel.eu) {
// ic2EnergySource.addEnergy(fuel.eu);
// this.tickCount++;
//
// if (tickCount >= fuel.rate) {
// tickCount = 0;
// resourceTank.drain(fuel.fuelConsumed.amount, true);
// }
// }
//
// }
if (errorLogic.setCondition(ic2EnergySource == null, EnumErrorCode.NO_ENERGY_NET)) {
return;
}
ic2EnergySource.update();
if (resourceTank.getFluidAmount() > 0) {
GeneratorFuel fuel = FuelManager.generatorFuel.get(resourceTank.getFluid().getFluid());
if (resourceTank.canDrainFluidType(fuel.fuelConsumed) && ic2EnergySource.getFreeCapacity() >= fuel.eu) {
ic2EnergySource.addEnergy(fuel.eu);
this.tickCount++;
if (tickCount >= fuel.rate) {
tickCount = 0;
resourceTank.drain(fuel.fuelConsumed.amount, true);
}
}
}
boolean hasFuel = resourceTank.getFluidAmount() > 0;
errorLogic.setCondition(!hasFuel, EnumErrorCode.NO_FUEL);
@@ -162,13 +165,13 @@ public class TileEuGenerator extends TileBase implements ISidedInventory, ILiqui
return (resourceTank.getFluidAmount() * i) / Constants.PROCESSOR_TANK_CAPACITY;
}
// public int getStoredScaled(int i) {
// if (ic2EnergySource == null) {
// return 0;
// }
//
// return (int) (ic2EnergySource.getEnergyStored() * i) / maxEnergy;
// }
public int getStoredScaled(int i) {
if (ic2EnergySource == null) {
return 0;
}
return (int) (ic2EnergySource.getEnergyStored() * i) / maxEnergy;
}
@Override
public TankRenderInfo getResourceTankInfo() {
@@ -183,16 +186,16 @@ public class TileEuGenerator extends TileBase implements ISidedInventory, ILiqui
/* SMP GUI */
public void getGUINetworkData(int i, int j) {
if (i == 0) {
// if (ic2EnergySource != null) {
// ic2EnergySource.setEnergyStored(j);
// }
if (ic2EnergySource != null) {
ic2EnergySource.setEnergyStored(j);
}
}
}
public void sendGUINetworkData(Container container, IContainerListener iCrafting) {
// if (ic2EnergySource != null) {
// iCrafting.sendProgressBarUpdate(container, 0, (short) ic2EnergySource.getEnergyStored());
// }
if (ic2EnergySource != null) {
iCrafting.sendProgressBarUpdate(container, 0, (short) ic2EnergySource.getEnergyStored());
}
}
@Override
@@ -10,6 +10,8 @@
******************************************************************************/
package forestry.factory.recipes;
import javax.annotation.Nullable;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
@@ -21,10 +23,11 @@ public class SqueezerRecipe implements ISqueezerRecipe {
private final int processingTime;
private final ItemStack[] resources;
private final FluidStack fluidOutput;
@Nullable
private final ItemStack remnants;
private final float remnantsChance;
public SqueezerRecipe(int processingTime, ItemStack[] resources, FluidStack fluidOutput, ItemStack remnants, float remnantsChance) {
public SqueezerRecipe(int processingTime, ItemStack[] resources, FluidStack fluidOutput, @Nullable ItemStack remnants, float remnantsChance) {
this.processingTime = processingTime;
this.resources = resources;
this.fluidOutput = fluidOutput;
@@ -38,6 +41,7 @@ public class SqueezerRecipe implements ISqueezerRecipe {
}
@Override
@Nullable
public ItemStack getRemnants() {
return remnants;
}
@@ -22,6 +22,12 @@ public class BottlerRecipeHandler implements IRecipeHandler<BottlerRecipeWrapper
return ForestryRecipeCategoryUid.BOTTLER;
}
@Nonnull
@Override
public String getRecipeCategoryUid(@Nonnull BottlerRecipeWrapper recipe) {
return ForestryRecipeCategoryUid.BOTTLER;
}
@Nonnull
@Override
public IRecipeWrapper getRecipeWrapper(@Nonnull BottlerRecipeWrapper recipe) {
@@ -22,6 +22,12 @@ public class CarpenterRecipeHandler implements IRecipeHandler<CarpenterRecipeWra
return ForestryRecipeCategoryUid.CARPENTER;
}
@Nonnull
@Override
public String getRecipeCategoryUid(@Nonnull CarpenterRecipeWrapper recipe) {
return ForestryRecipeCategoryUid.CARPENTER;
}
@Nonnull
@Override
public IRecipeWrapper getRecipeWrapper(@Nonnull CarpenterRecipeWrapper recipe) {
@@ -5,6 +5,7 @@ import java.util.Comparator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Set;
import net.minecraft.client.Minecraft;
@@ -22,7 +23,6 @@ import mezz.jei.api.gui.IDrawableStatic;
import mezz.jei.api.gui.IGuiItemStackGroup;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.recipe.IRecipeWrapper;
import mezz.jei.gui.ingredients.GuiItemStackGroup;
public class CentrifugeRecipeCategory extends ForestryRecipeCategory {
@@ -41,8 +41,7 @@ public class CentrifugeRecipeCategory extends ForestryRecipeCategory {
private final static ResourceLocation guiTexture = new ForestryResource("textures/gui/centrifugesocket.png");
@Nonnull
private final IDrawableAnimated arrow;
private final ForestryTooltipCallback tooltip = new ForestryTooltipCallback();
public CentrifugeRecipeCategory(IGuiHelper guiHelper) {
super(guiHelper.createDrawable(guiTexture, 25, 18, 126, 54), "tile.for.centrifuge.name");
@@ -68,17 +67,17 @@ public class CentrifugeRecipeCategory extends ForestryRecipeCategory {
guiItemStacks.init(inputSlot, true, 4, 18);
guiItemStacks.setFromRecipe(inputSlot, recipeWrapper.getInputs());
CentrifugeRecipeWrapper centrifugeWrapper = (CentrifugeRecipeWrapper) recipeWrapper;
tooltip.clearTooltip();
setResults(centrifugeWrapper.getRecipe().getAllProducts(), (GuiItemStackGroup) guiItemStacks);
ForestryTooltipCallback tooltip = new ForestryTooltipCallback();
setResults(tooltip, centrifugeWrapper.getRecipe().getAllProducts(), guiItemStacks);
guiItemStacks.addTooltipCallback(tooltip);
}
private void setResults(Map<ItemStack, Float> outputs, GuiItemStackGroup guiItemStacks) {
private static void setResults(ForestryTooltipCallback tooltip, Map<ItemStack, Float> outputs, IGuiItemStackGroup guiItemStacks) {
Set<Entry<ItemStack, Float>> entrySet = outputs.entrySet();
if (entrySet.isEmpty()) {
return;
}
PriorityQueue<Entry<ItemStack, Float>> sortByChance = new PriorityQueue<>(entrySet.size(), highestChanceComparator);
Queue<Entry<ItemStack, Float>> sortByChance = new PriorityQueue<>(entrySet.size(), highestChanceComparator);
sortByChance.addAll(entrySet);
int i = 0;
@@ -89,10 +88,10 @@ public class CentrifugeRecipeCategory extends ForestryRecipeCategory {
}
int x = 72 + OUTPUTS[i][0] * 18;
int y = OUTPUTS[i][1] * 18;
int ID = outputSlot + i;
guiItemStacks.init(ID, false, x, y);
guiItemStacks.set(ID, stack.getKey());
tooltip.addChanceTooltip(ID + 1, stack.getValue());
int slotIndex = outputSlot + i;
guiItemStacks.init(slotIndex, false, x, y);
guiItemStacks.set(slotIndex, stack.getKey());
tooltip.addChanceTooltip(slotIndex, stack.getValue());
i++;
}
}
@@ -24,6 +24,12 @@ public class CentrifugeRecipeHandler implements IRecipeHandler<CentrifugeRecipeW
return ForestryRecipeCategoryUid.CENTRIFUGE;
}
@Nonnull
@Override
public String getRecipeCategoryUid(@Nonnull CentrifugeRecipeWrapper recipe) {
return ForestryRecipeCategoryUid.CENTRIFUGE;
}
@Nonnull
@Override
public IRecipeWrapper getRecipeWrapper(@Nonnull CentrifugeRecipeWrapper recipe) {
@@ -22,6 +22,12 @@ public class FabricatorRecipeHandler implements IRecipeHandler<FabricatorRecipeW
return ForestryRecipeCategoryUid.FABRICATOR;
}
@Nonnull
@Override
public String getRecipeCategoryUid(@Nonnull FabricatorRecipeWrapper recipe) {
return ForestryRecipeCategoryUid.FABRICATOR;
}
@Nonnull
@Override
public IRecipeWrapper getRecipeWrapper(@Nonnull FabricatorRecipeWrapper recipe) {
@@ -22,6 +22,12 @@ public class FermenterRecipeHandler implements IRecipeHandler<FermenterRecipeWra
return ForestryRecipeCategoryUid.FERMENTER;
}
@Nonnull
@Override
public String getRecipeCategoryUid(@Nonnull FermenterRecipeWrapper recipe) {
return ForestryRecipeCategoryUid.FERMENTER;
}
@Nonnull
@Override
public IRecipeWrapper getRecipeWrapper(@Nonnull FermenterRecipeWrapper recipe) {
@@ -22,6 +22,12 @@ public class MoistenerRecipeHandler implements IRecipeHandler<MoistenerRecipeWra
return ForestryRecipeCategoryUid.MOISTENER;
}
@Nonnull
@Override
public String getRecipeCategoryUid(@Nonnull MoistenerRecipeWrapper recipe) {
return ForestryRecipeCategoryUid.MOISTENER;
}
@Nonnull
@Override
public IRecipeWrapper getRecipeWrapper(@Nonnull MoistenerRecipeWrapper recipe) {
@@ -20,6 +20,12 @@ public class RainmakerRecipeHandler implements IRecipeHandler<RainmakerRecipeWra
return ForestryRecipeCategoryUid.RAINMAKER;
}
@Nonnull
@Override
public String getRecipeCategoryUid(@Nonnull RainmakerRecipeWrapper recipe) {
return ForestryRecipeCategoryUid.RAINMAKER;
}
@Nonnull
@Override
public IRecipeWrapper getRecipeWrapper(@Nonnull RainmakerRecipeWrapper recipe) {
@@ -35,8 +35,7 @@ public class SqueezerRecipeCategory extends ForestryRecipeCategory {
private final IDrawableAnimated arrow;
@Nonnull
private final IDrawable tankOverlay;
private final ForestryTooltipCallback tooltip = new ForestryTooltipCallback();
public SqueezerRecipeCategory(@Nonnull IGuiHelper guiHelper) {
super(guiHelper.createDrawable(guiTexture, 9, 16, 158, 62), "tile.for.squeezer.name");
@@ -70,7 +69,7 @@ public class SqueezerRecipeCategory extends ForestryRecipeCategory {
guiItemStacks.init(craftOutputSlot, false, 87, 43);
guiItemStacks.set(craftOutputSlot, wrapper.getOutputs());
tooltip.clearTooltip();
ForestryTooltipCallback tooltip = new ForestryTooltipCallback();
tooltip.addChanceTooltip(craftOutputSlot, chance);
setIngredients(guiItemStacks, wrapper.getInputs());
@@ -31,6 +31,12 @@ public class SqueezerRecipeHandler<R extends ForestryRecipeWrapper> implements I
return ForestryRecipeCategoryUid.SQUEEZER;
}
@Nonnull
@Override
public String getRecipeCategoryUid(@Nonnull R recipe) {
return ForestryRecipeCategoryUid.SQUEEZER;
}
@Nonnull
@Override
public IRecipeWrapper getRecipeWrapper(@Nonnull R recipe) {
@@ -45,16 +51,7 @@ public class SqueezerRecipeHandler<R extends ForestryRecipeWrapper> implements I
if (wrapper.getInputs() == null || wrapper.getInputs().isEmpty()) {
return false;
}
if (wrapper.getOutputs() == null || wrapper.getOutputs().isEmpty()) {
return false;
}
if (wrapper.getRecipe() instanceof ISqueezerContainerRecipe) {
ISqueezerContainerRecipe recipe = (ISqueezerContainerRecipe) wrapper.getRecipe();
return recipe.getProcessingTime() > 0 && recipe.getRemnantsChance() > 0;
} else {
ISqueezerRecipe recipe = (ISqueezerRecipe) wrapper.getRecipe();
return recipe.getProcessingTime() > 0 && recipe.getRemnantsChance() > 0;
}
return true;
}
}
@@ -34,7 +34,8 @@ public class SqueezerRecipeWrapper extends AbstractSqueezerRecipeWrapper<ISqueez
@Nonnull
@Override
public List<ItemStack> getOutputs() {
return Collections.singletonList(getRecipe().getRemnants());
ItemStack remnants = getRecipe().getRemnants();
return remnants == null ? Collections.emptyList() : Collections.singletonList(remnants);
}
@Override
@@ -22,6 +22,12 @@ public class StillRecipeHandler implements IRecipeHandler<StillRecipeWrapper> {
return ForestryRecipeCategoryUid.STILL;
}
@Nonnull
@Override
public String getRecipeCategoryUid(@Nonnull StillRecipeWrapper recipe) {
return ForestryRecipeCategoryUid.STILL;
}
@Nonnull
@Override
public IRecipeWrapper getRecipeWrapper(@Nonnull StillRecipeWrapper recipe) {
@@ -90,7 +90,7 @@ public class TileMillRainmaker extends TileMill {
@Override
public void activate() {
if (Proxies.render.hasRendering()) {
worldObj.playSound((EntityPlayer)null, getPos(), SoundEvents.ENTITY_LIGHTNING_THUNDER, SoundCategory.WEATHER, 10000.0F, 0.8F + worldObj.rand.nextFloat() * 0.2F);
worldObj.playSound(null, getPos(), SoundEvents.ENTITY_LIGHTNING_THUNDER, SoundCategory.WEATHER, 10000.0F, 0.8F + worldObj.rand.nextFloat() * 0.2F);
float f = getPos().getX() + 0.5F;
float f1 = getPos().getY() + 0.0F + worldObj.rand.nextFloat() * 6F / 16F;
@@ -40,7 +40,7 @@ public class FarmLogicSlot extends Widget {
if (getLogic() == null) {
return null;
}
return getLogic().getStack();
return getLogic().getIconItemStack();
}
@Override
@@ -1,68 +1,83 @@
package forestry.farming.logic;
// TODO: IC2 for 1.9
public class CropBasicIC2Crop {//extends Crop {
// private final TileEntity tileEntity;
//
// public CropBasicIC2Crop(World world, TileEntity tileEntity, Vect position) {
// super(world, position);
// this.tileEntity = tileEntity;
// }
//
// @Override
// protected boolean isCrop(Vect pos) {
// return canHarvestCrop(this.tileEntity);
// }
//
// @Override
// protected Collection<ItemStack> harvestBlock(Vect pos) {
// return getCropDrops(this.tileEntity);
// }
//
// /**
// * Check if there is an instance of ICropTile.
// * @param tileEntity tile entity to be checked.
// * @return true if there is an IC2 crop and false otherwise.
// */
// @Optional.Method(modid = PluginIC2.modId)
// public static boolean isIC2Crop(TileEntity tileEntity) {
// if (tileEntity instanceof ICropTile) {
// return true;
// }
// return false;
// }
//
// /**
// * Check if an IC2 crop is ready to be harvested.
// * @param tileEntity tile entity to be checked.
// * @return true if crop size is optimal for harvest and false otherwise.
// */
// @Optional.Method(modid = PluginIC2.modId)
// public static boolean canHarvestCrop(TileEntity tileEntity) {
// if (isIC2Crop(tileEntity)) {
// ICropTile crop = (ICropTile) tileEntity;
// if (crop.getCrop() == null) {
// return false;
// }
// if (crop.getCurrentSize() == crop.getCrop().getOptimalHarvestSize(crop)) {
// return true;
// }
// }
// return false;
// }
//
// /**
// * This function takes care of everything related to the harvesting of the
// * crop meaning it will calculate the drops and also do setSizeAfterHarvest().
// * @param tileEntity tile entity to be checked.
// * @return list containing the drops.
// */
// @Optional.Method(modid = PluginIC2.modId)
// private static List<ItemStack> getCropDrops(TileEntity tileEntity) {
// if (isIC2Crop(tileEntity)) {
// ICropTile crop = (ICropTile) tileEntity;
// return crop.performHarvest();
// }
// return null;
// }
import javax.annotation.Nonnull;
import java.util.Collection;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.Optional;
import forestry.plugins.compat.PluginIC2;
import ic2.api.crops.ICropTile;
public class CropBasicIC2Crop extends Crop {
private final TileEntity tileEntity;
public CropBasicIC2Crop(@Nonnull World world, @Nonnull TileEntity tileEntity, @Nonnull BlockPos position) {
super(world, position);
this.tileEntity = tileEntity;
}
@Override
protected boolean isCrop(World world, BlockPos pos) {
return canHarvestCrop(this.tileEntity);
}
@Override
protected Collection<ItemStack> harvestBlock(World world, BlockPos pos) {
return getCropDrops(this.tileEntity);
}
/**
* Check if there is an instance of ICropTile.
* @param tileEntity tile entity to be checked.
* @return true if there is an IC2 crop and false otherwise.
*/
@Optional.Method(modid = PluginIC2.modId)
public static boolean isIC2Crop(TileEntity tileEntity) {
if (tileEntity instanceof ICropTile) {
return true;
}
return false;
}
/**
* Check if an IC2 crop is ready to be harvested.
* @param tileEntity tile entity to be checked.
* @return true if crop size is optimal for harvest and false otherwise.
*/
@Optional.Method(modid = PluginIC2.modId)
public static boolean canHarvestCrop(TileEntity tileEntity) {
if (isIC2Crop(tileEntity)) {
ICropTile crop = (ICropTile) tileEntity;
if (crop.getCrop() == null) {
return false;
}
if (crop.getCurrentSize() == crop.getCrop().getOptimalHarvestSize(crop)) {
return true;
}
}
return false;
}
/**
* This function takes care of everything related to the harvesting of the
* crop meaning it will calculate the drops and also do setSizeAfterHarvest().
* @param tileEntity tile entity to be checked.
* @return list containing the drops.
*/
@Optional.Method(modid = PluginIC2.modId)
private static List<ItemStack> getCropDrops(TileEntity tileEntity) {
if (isIC2Crop(tileEntity)) {
ICropTile crop = (ICropTile) tileEntity;
return crop.performHarvest();
}
return null;
}
}
@@ -13,6 +13,7 @@ package forestry.farming.logic;
import java.util.ArrayList;
import java.util.Collection;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
@@ -26,8 +27,17 @@ import forestry.plugins.compat.PluginIC2;
public class CropRubber extends CropDestroy {
public CropRubber(World world, IBlockState blockState, BlockPos position) {
//TODO IC2 for 1.9: check that this is setting the right state for replanting.
super(world, blockState, position, blockState.getBlock().getDefaultState());
super(world, blockState, position, getReplantState(blockState));
}
/**
* Convert a "wet" rubber log blockstate into the dry version.
* Total hack since we don't have access to the blockstates.
*/
private static IBlockState getReplantState(IBlockState sappyState) {
Block block = sappyState.getBlock();
int sappyMeta = block.getMetaFromState(sappyState);
return block.getStateFromMeta(sappyMeta - 4);
}
@Override
@@ -19,7 +19,6 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
@@ -53,18 +52,7 @@ public abstract class FarmLogic implements IFarmLogic {
}
@Override
@SideOnly(Side.CLIENT)
public ItemStack getStack() {
return new ItemStack(getItem(), 1, getMetadata());
}
@SideOnly(Side.CLIENT)
public abstract Item getItem();
@SideOnly(Side.CLIENT)
public int getMetadata() {
return 0;
}
public abstract ItemStack getIconItemStack();
public abstract boolean isAcceptedWindfall(ItemStack stack);
@@ -20,14 +20,10 @@ import java.util.Stack;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.farming.FarmDirection;
import forestry.api.farming.Farmables;
import forestry.api.farming.ICrop;
@@ -48,11 +44,10 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous {
public String getName() {
return "Managed Arboretum";
}
@SideOnly(Side.CLIENT)
@Override
public Item getItem() {
return Item.getItemFromBlock(Blocks.SAPLING);
public ItemStack getIconItemStack() {
return new ItemStack(Blocks.SAPLING);
}
@Override
@@ -11,10 +11,7 @@
package forestry.farming.logic;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraft.item.ItemStack;
import forestry.api.farming.Farmables;
@@ -34,9 +31,7 @@ public class FarmLogicCereal extends FarmLogicCrops {
}
@Override
@SideOnly(Side.CLIENT)
public Item getItem() {
return Items.WHEAT;
public ItemStack getIconItemStack() {
return new ItemStack(Items.WHEAT);
}
}
@@ -25,15 +25,11 @@ import net.minecraft.block.BlockPlanks;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.farming.FarmDirection;
import forestry.api.farming.ICrop;
import forestry.api.farming.IFarmHousing;
@@ -43,15 +39,8 @@ public class FarmLogicCocoa extends FarmLogic {
private final IFarmable cocoa = new FarmableCocoa();
@Override
@SideOnly(Side.CLIENT)
public Item getItem() {
return Items.DYE;
}
@Override
@SideOnly(Side.CLIENT)
public int getMetadata() {
return 3;
public ItemStack getIconItemStack() {
return new ItemStack(Items.DYE, 1, 3);
}
@Override
@@ -16,14 +16,10 @@ import java.util.Stack;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.farming.FarmDirection;
import forestry.api.farming.Farmables;
import forestry.api.farming.ICrop;
@@ -43,9 +39,8 @@ public class FarmLogicEnder extends FarmLogicHomogeneous {
}
@Override
@SideOnly(Side.CLIENT)
public Item getItem() {
return Items.ENDER_EYE;
public ItemStack getIconItemStack() {
return new ItemStack(Items.ENDER_EYE);
}
@Override
@@ -15,14 +15,10 @@ import java.util.Stack;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.farming.FarmDirection;
import forestry.api.farming.Farmables;
import forestry.api.farming.ICrop;
@@ -39,9 +35,8 @@ public class FarmLogicGourd extends FarmLogic {
}
@Override
@SideOnly(Side.CLIENT)
public Item getItem() {
return Items.MELON;
public ItemStack getIconItemStack() {
return new ItemStack(Items.MELON);
}
@Override
@@ -16,14 +16,10 @@ import java.util.Stack;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.farming.FarmDirection;
import forestry.api.farming.Farmables;
import forestry.api.farming.ICrop;
@@ -43,9 +39,8 @@ public class FarmLogicInfernal extends FarmLogicHomogeneous {
}
@Override
@SideOnly(Side.CLIENT)
public Item getItem() {
return Items.NETHER_WART;
public ItemStack getIconItemStack() {
return new ItemStack(Items.NETHER_WART);
}
@Override
@@ -14,13 +14,9 @@ import java.util.ArrayList;
import java.util.Collection;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.farming.Farmables;
import forestry.api.farming.IFarmHousing;
@@ -40,9 +36,8 @@ public class FarmLogicMushroom extends FarmLogicArboreal {
}
@Override
@SideOnly(Side.CLIENT)
public Item getItem() {
return Item.getItemFromBlock(Blocks.RED_MUSHROOM);
public ItemStack getIconItemStack() {
return new ItemStack(Blocks.RED_MUSHROOM);
}
@Override
@@ -22,15 +22,11 @@ import java.util.Stack;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.farming.FarmDirection;
import forestry.api.farming.Farmables;
import forestry.api.farming.ICrop;
@@ -126,9 +122,8 @@ public class FarmLogicOrchard extends FarmLogic {
}
@Override
@SideOnly(Side.CLIENT)
public Item getItem() {
return PluginCore.items.fruits;
public ItemStack getIconItemStack() {
return new ItemStack(PluginCore.items.fruits);
}
@Override
@@ -15,14 +15,10 @@ import java.util.Stack;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.farming.FarmDirection;
import forestry.api.farming.ICrop;
import forestry.core.PluginCore;
@@ -89,9 +85,7 @@ public class FarmLogicPeat extends FarmLogicWatered {
}
@Override
@SideOnly(Side.CLIENT)
public Item getItem() {
return PluginCore.items.peat;
public ItemStack getIconItemStack() {
return new ItemStack(PluginCore.items.peat);
}
}
@@ -16,14 +16,10 @@ import java.util.Stack;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.farming.FarmDirection;
import forestry.api.farming.Farmables;
import forestry.api.farming.ICrop;
@@ -35,9 +31,8 @@ public class FarmLogicReeds extends FarmLogic {
private final Collection<IFarmable> germlings = Farmables.farmables.get("farmPoales");
@Override
@SideOnly(Side.CLIENT)
public Item getItem() {
return Items.REEDS;
public ItemStack getIconItemStack() {
return new ItemStack(Items.REEDS);
}
@Override
@@ -21,15 +21,10 @@ import java.util.Stack;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.farming.FarmDirection;
import forestry.api.farming.ICrop;
import forestry.api.farming.IFarmHousing;
@@ -39,23 +34,18 @@ import forestry.plugins.compat.PluginIC2;
public class FarmLogicRubber extends FarmLogic {
private boolean inActive;
private boolean active = true;
public FarmLogicRubber() {
if (PluginIC2.rubberWood == null || PluginIC2.resin == null) {
Log.warning("Failed to init a farm logic %s since IC2 was not found", getClass().getName());
inActive = true;
active = false;
}
}
@Override
@SideOnly(Side.CLIENT)
public Item getItem() {
if (!inActive) {
return PluginIC2.resin.getItem();
} else {
return Items.GUNPOWDER;
}
public ItemStack getIconItemStack() {
return PluginIC2.resin;
}
@Override
@@ -102,7 +92,7 @@ public class FarmLogicRubber extends FarmLogic {
@Override
public Collection<ICrop> harvest(World world, BlockPos pos, FarmDirection direction, int extent) {
if (inActive) {
if (!active) {
return null;
}
@@ -135,7 +125,7 @@ public class FarmLogicRubber extends FarmLogic {
}
int meta = block.getMetaFromState(blockState);
if (meta >= 2 && meta <= 5) {
if (meta >= 7 && meta <= 10) {
crops.push(new CropDestroy(world, blockState, position, null));
}
@@ -172,7 +162,7 @@ public class FarmLogicRubber extends FarmLogic {
Block block = blockState.getBlock();
if (ItemStackUtil.equals(block, PluginIC2.rubberWood)) {
int meta = block.getMetaFromState(blockState);
if (meta >= 2 && meta <= 5) {
if (meta >= 7 && meta <= 10) {
crops.push(new CropRubber(world, blockState, candidate));
}
candidates.add(candidate);
@@ -16,14 +16,10 @@ import java.util.Stack;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.farming.FarmDirection;
import forestry.api.farming.Farmables;
import forestry.api.farming.ICrop;
@@ -35,15 +31,8 @@ public class FarmLogicSucculent extends FarmLogic {
private final Collection<IFarmable> germlings = Farmables.farmables.get("farmSucculentes");
@Override
@SideOnly(Side.CLIENT)
public Item getItem() {
return Items.DYE;
}
@Override
@SideOnly(Side.CLIENT)
public int getMetadata() {
return 2;
public ItemStack getIconItemStack() {
return new ItemStack(Items.DYE, 1, 2);
}
@Override
@@ -11,10 +11,7 @@
package forestry.farming.logic;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraft.item.ItemStack;
import forestry.api.farming.Farmables;
@@ -25,9 +22,8 @@ public class FarmLogicVegetable extends FarmLogicCrops {
}
@Override
@SideOnly(Side.CLIENT)
public Item getItem() {
return Items.CARROT;
public ItemStack getIconItemStack() {
return new ItemStack(Items.CARROT);
}
@Override
Loaded 100 of 115 files, more files were not shown because too many files have changed in this diff. Show more