Clean up more null/nonnull, refactor gui ledgers

This commit is contained in:
mezz committed 2016-12-26 08:08:08 -08:00
1 parent b2d4e6eaba
commit 35f9b95f37
124 files changed
+827 -655

No files matched your search

@@ -5,6 +5,8 @@
******************************************************************************/
package forestry.api.apiculture;
import javax.annotation.Nullable;
/**
* Easily extendable default IBeeModifier.
* By itself, this IBeeModifier does nothing.
@@ -23,7 +25,7 @@ public class DefaultBeeModifier implements IBeeModifier {
}
@Override
public float getLifespanModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) {
public float getLifespanModifier(IBeeGenome genome, @Nullable IBeeGenome mate, float currentModifier) {
return 1.0f;
}
@@ -14,6 +14,7 @@ import forestry.api.genetics.IEffectData;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IIndividualLiving;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraft.world.biome.Biome;
/**
@@ -72,16 +73,16 @@ public interface IBee extends IIndividualLiving {
List<Biome> getSuitableBiomes();
ItemStack[] getProduceList();
NonNullList<ItemStack> getProduceList();
ItemStack[] getSpecialtyList();
NonNullList<ItemStack> getSpecialtyList();
List<ItemStack> produceStacks(IBeeHousing housing);
NonNullList<ItemStack> produceStacks(IBeeHousing housing);
@Nullable
IBee spawnPrincess(IBeeHousing housing);
IBee[] spawnDrones(IBeeHousing housing);
List<IBee> spawnDrones(IBeeHousing housing);
void plantFlowerRandom(IBeeHousing housing);
@@ -5,6 +5,8 @@
******************************************************************************/
package forestry.api.apiculture;
import javax.annotation.Nullable;
public interface IBeeModifier {
/**
* @param genome Genome of the bee this modifier is called for.
@@ -26,7 +28,7 @@ public interface IBeeModifier {
* @param currentModifier Current modifier.
* @return Float used to modify the life span of queens.
*/
float getLifespanModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier);
float getLifespanModifier(IBeeGenome genome, @Nullable IBeeGenome mate, float currentModifier);
/**
* @param genome Genome of the bee this modifier is called for.
@@ -24,9 +24,10 @@ public interface IBeeRoot extends ISpeciesRoot {
boolean isMember(ItemStack stack);
/**
* @return {@link IBee} pattern parsed from the passed stack's nbt data.
* @return {@link IBee} pattern parsed from the passed stack's nbt data. Null if the ItemStack is not a valid member.
*/
@Override
@Nullable
IBee getMember(ItemStack stack);
@Override
@@ -36,7 +36,7 @@ public interface ITree extends IIndividual, ITreeGenData {
/**
* @since Forestry 4.0
*/
ITree[] getSaplings(World world, GameProfile playerProfile, BlockPos pos, float modifier);
ITree[] getSaplings(World world, @Nullable GameProfile playerProfile, BlockPos pos, float modifier);
// Products, Chance
Map<ItemStack, Float> getProducts();
@@ -24,6 +24,7 @@ public interface ITreeRoot extends ISpeciesRootPollinatable {
boolean isMember(ItemStack itemstack);
@Override
@Nullable
ITree getMember(ItemStack itemstack);
@Override
@@ -18,6 +18,7 @@ public interface ICircuitRegistry {
void registerCircuit(ICircuit circuit);
@Nullable
ICircuit getCircuit(String uid);
ICircuitLibrary getCircuitLibrary(World world, String playerName);
@@ -27,6 +28,7 @@ public interface ICircuitRegistry {
void registerLayout(ICircuitLayout layout);
@Nullable
ICircuitLayout getLayout(String uid);
ICircuitLayout getDefaultLayout();
@@ -5,9 +5,8 @@
******************************************************************************/
package forestry.api.genetics;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@@ -32,5 +31,5 @@ public interface IFlowerProvider {
*
* @return Array of itemstacks being the (modified or unmodified) produce.
*/
List<ItemStack> affectProducts(World world, IIndividual individual, BlockPos pos, List<ItemStack> products);
NonNullList<ItemStack> affectProducts(World world, IIndividual individual, BlockPos pos, NonNullList<ItemStack> products);
}
@@ -61,6 +61,7 @@ public interface ISpeciesRoot {
*/
boolean isMember(IIndividual individual);
@Nullable
IIndividual getMember(ItemStack stack);
IIndividual getMember(NBTTagCompound compound);
@@ -22,6 +22,7 @@ public interface IButterflyRoot extends ISpeciesRoot {
boolean isMember(ItemStack stack);
@Override
@Nullable
IButterfly getMember(ItemStack stack);
@Override
@@ -5,8 +5,6 @@
******************************************************************************/
package forestry.api.mail;
import javax.annotation.Nullable;
import com.mojang.authlib.GameProfile;
import forestry.api.core.INbtWritable;
@@ -18,6 +16,5 @@ public interface IMailAddress extends INbtWritable {
boolean isValid();
@Nullable
GameProfile getPlayerProfile();
}
@@ -21,7 +21,7 @@ public class ArmorApiaristHelper implements IArmorApiaristHelper {
@Override
public boolean isArmorApiarist(ItemStack stack, EntityLivingBase entity, String cause, boolean doProtect) {
if (stack == null) {
if (stack.isEmpty()) {
return false;
}
@@ -10,6 +10,8 @@
******************************************************************************/
package forestry.apiculture;
import javax.annotation.Nullable;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeeModifier;
@@ -40,7 +42,7 @@ public class BeeHousingModifier implements IBeeModifier {
}
@Override
public float getLifespanModifier(IBeeGenome genome, IBeeGenome mate, final float currentModifier) {
public float getLifespanModifier(IBeeGenome genome, @Nullable IBeeGenome mate, final float currentModifier) {
float modifierValue = 1.0f;
for (IBeeModifier modifier : beeHousing.getBeeModifiers()) {
modifierValue *= modifier.getLifespanModifier(genome, mate, modifierValue * currentModifier);
@@ -10,6 +10,8 @@
******************************************************************************/
package forestry.apiculture;
import javax.annotation.Nullable;
import forestry.api.apiculture.DefaultBeeModifier;
import forestry.api.apiculture.IBeeGenome;
@@ -25,7 +27,7 @@ public class BeehouseBeeModifier extends DefaultBeeModifier {
}
@Override
public float getLifespanModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) {
public float getLifespanModifier(IBeeGenome genome, @Nullable IBeeGenome mate, float currentModifier) {
return 3.0f;
}
@@ -63,7 +63,6 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
private int beeProgressMax;
private int queenWorkCycleThrottle;
@Nullable
private IEffectData effectData[] = new IEffectData[2];
private final Stack<ItemStack> spawn = new Stack<>();
@@ -429,7 +428,7 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
}
// Drones
IBee[] drones = queen.spawnDrones(beeHousing);
List<IBee> drones = queen.spawnDrones(beeHousing);
for (IBee drone : drones) {
ItemStack droneStack = BeeManager.beeRoot.getMemberStack(drone, EnumBeeType.DRONE);
breedingTracker.registerDrone(drone);
@@ -488,10 +487,7 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
@Override
public boolean canDoBeeFX() {
if (Proxies.common.getClientInstance().isGamePaused()) {
return false;
}
return active;
return !Proxies.common.getClientInstance().isGamePaused() && active;
}
@Override
@@ -1,5 +1,6 @@
package forestry.apiculture.compat;
import com.google.common.base.Preconditions;
import forestry.api.apiculture.BeeManager;
import forestry.api.genetics.IAlleleSpecies;
import forestry.apiculture.PluginApiculture;
@@ -16,6 +17,7 @@ public class ApicultureJeiPlugin extends BlankModPlugin {
@Override
public void registerItemSubtypes(ISubtypeRegistry subtypeRegistry) {
ItemRegistryApiculture items = PluginApiculture.items;
Preconditions.checkNotNull(items);
ISubtypeRegistry.ISubtypeInterpreter beeSubtypeInterpreter = itemStack -> {
IAlleleSpecies species = Genome.getSpeciesDirectly(BeeManager.beeRoot, itemStack);
@@ -30,6 +32,7 @@ public class ApicultureJeiPlugin extends BlankModPlugin {
@Override
public void register(IModRegistry registry) {
ItemRegistryApiculture items = PluginApiculture.items;
Preconditions.checkNotNull(items);
JeiUtil.addDescription(registry, "frames",
items.frameImpregnated,
@@ -27,7 +27,6 @@ import forestry.apiculture.gui.ContainerMinecartBeehouse;
import forestry.apiculture.gui.GuiBeeHousing;
import forestry.apiculture.inventory.IApiaryInventory;
import forestry.apiculture.inventory.InventoryApiary;
import forestry.core.config.Config;
import forestry.core.inventory.IInventoryAdapter;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
@@ -51,8 +50,8 @@ public class EntityMinecartApiary extends EntityMinecartBeeHousingBase implement
}
@Override
public List<String> getHints() {
return Config.hints.get("apiary");
public String getHintKey() {
return "apiary";
}
@Override
@@ -22,7 +22,7 @@ import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.core.ForestryAPI;
import forestry.api.core.IErrorLogic;
import forestry.apiculture.gui.IGuiBeeHousingInventory;
import forestry.apiculture.gui.IGuiBeeHousingDelegate;
import forestry.apiculture.network.packets.PacketBeeLogicEntityRequest;
import forestry.apiculture.tiles.TileBeeHousingBase;
import forestry.core.entities.EntityMinecartContainerForestry;
@@ -45,7 +45,7 @@ import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
public abstract class EntityMinecartBeeHousingBase extends EntityMinecartContainerForestry implements IBeeHousing, IOwnedTile, IGuiBeeHousingInventory, IClimatised, IStreamableGui {
public abstract class EntityMinecartBeeHousingBase extends EntityMinecartContainerForestry implements IBeeHousing, IOwnedTile, IGuiBeeHousingDelegate, IClimatised, IStreamableGui {
private static final DataParameter<Optional<GameProfile>> OWNER = EntityDataManager.createKey(EntityMinecart.class, GameProfileDataSerializer.INSTANCE);
private static final Random random = new Random();
@@ -11,7 +11,6 @@
package forestry.apiculture.entities;
import java.util.Collections;
import java.util.List;
import forestry.api.apiculture.DefaultBeeListener;
import forestry.api.apiculture.IBeeHousingInventory;
@@ -22,7 +21,6 @@ import forestry.apiculture.InventoryBeeHousing;
import forestry.apiculture.PluginApiculture;
import forestry.apiculture.gui.ContainerMinecartBeehouse;
import forestry.apiculture.gui.GuiBeeHousing;
import forestry.core.config.Config;
import forestry.core.inventory.IInventoryAdapter;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
@@ -46,8 +44,8 @@ public class EntityMinecartBeehouse extends EntityMinecartBeeHousingBase {
}
@Override
public List<String> getHints() {
return Config.hints.get("bee.house");
public String getHintKey() {
return "bee.house";
}
@Override
@@ -10,14 +10,13 @@
******************************************************************************/
package forestry.apiculture.flowers;
import java.util.List;
import forestry.api.apiculture.FlowerManager;
import forestry.api.genetics.ICheckPollinatable;
import forestry.api.genetics.IFlowerProvider;
import forestry.api.genetics.IIndividual;
import forestry.core.utils.Translator;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.EnumPlantType;
@@ -58,7 +57,7 @@ public class FlowerProvider implements IFlowerProvider {
}
@Override
public List<ItemStack> affectProducts(World world, IIndividual individual, BlockPos pos, List<ItemStack> products) {
public NonNullList<ItemStack> affectProducts(World world, IIndividual individual, BlockPos pos, NonNullList<ItemStack> products) {
return products;
}
@@ -18,6 +18,7 @@ import java.util.Random;
import java.util.Set;
import java.util.TreeMap;
import com.google.common.base.Preconditions;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.HashMultimap;
import forestry.api.apiculture.BeeManager;
@@ -31,7 +32,6 @@ import forestry.api.genetics.IFlowerGrowthHelper;
import forestry.api.genetics.IFlowerGrowthRule;
import forestry.api.genetics.IFlowerRegistry;
import forestry.api.genetics.IIndividual;
import forestry.core.utils.Log;
import forestry.core.utils.VectUtil;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
@@ -95,9 +95,9 @@ public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelpe
@Override
public void registerPlantableFlower(IBlockState blockState, double weight, String... flowerTypes) {
if (blockState == null) {
return;
}
Preconditions.checkNotNull(blockState);
Preconditions.checkArgument(blockState.getBlock() != Blocks.AIR, "Tried to register AIR as a flower. Bad idea.");
if (weight <= 0.0) {
weight = 0.0;
}
@@ -105,16 +105,10 @@ public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelpe
weight = 1.0;
}
if (blockState.getBlock() == Blocks.AIR) {
Log.error("Tried to register AIR as a flower. Bad idea.");
}
Flower newFlower = new Flower(blockState, weight);
for (String flowerType : flowerTypes) {
if (flowerType == null) {
throw new NullPointerException("Tried to register flower with null type. " + blockState);
}
Preconditions.checkNotNull(flowerType, "Tried to register flower with null type. " + blockState);
Set<Flower> flowers = this.plantableFlowers.get(flowerType);
flowers.add(newFlower);
@@ -219,9 +213,7 @@ public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelpe
@Override
public void registerGrowthRule(IFlowerGrowthRule rule, String... flowerTypes) {
if (rule == null) {
return;
}
Preconditions.checkNotNull(rule);
for (String flowerType : flowerTypes) {
this.growthRules.get(flowerType).add(rule);
@@ -12,6 +12,7 @@ package forestry.apiculture.genetics;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -58,6 +59,7 @@ import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3i;
import net.minecraft.util.text.TextFormatting;
@@ -417,8 +419,8 @@ public class Bee extends IndividualLiving implements IBee {
// / PRODUCTION
@Override
public ItemStack[] getProduceList() {
ArrayList<ItemStack> products = new ArrayList<>();
public NonNullList<ItemStack> getProduceList() {
NonNullList<ItemStack> products = NonNullList.create();
IAlleleBeeSpecies primary = genome.getPrimary();
IAlleleBeeSpecies secondary = genome.getSecondary();
@@ -443,21 +445,25 @@ public class Bee extends IndividualLiving implements IBee {
}
return products.toArray(new ItemStack[products.size()]);
return products;
}
@Override
public ItemStack[] getSpecialtyList() {
public NonNullList<ItemStack> getSpecialtyList() {
Set<ItemStack> specialties = genome.getPrimary().getSpecialtyChances().keySet();
return specialties.toArray(new ItemStack[specialties.size()]);
NonNullList<ItemStack> specialtyList = NonNullList.create();
for (ItemStack specialty : specialties) {
specialtyList.add(specialty);
}
return specialtyList;
}
@Override
public List<ItemStack> produceStacks(IBeeHousing housing) {
public NonNullList<ItemStack> produceStacks(IBeeHousing housing) {
World world = housing.getWorldObj();
IBeekeepingMode mode = BeeManager.beeRoot.getBeekeepingMode(world);
List<ItemStack> products = new ArrayList<>();
NonNullList<ItemStack> products = NonNullList.create();
IAlleleBeeSpecies primary = genome.getPrimary();
IAlleleBeeSpecies secondary = genome.getSecondary();
@@ -518,14 +524,13 @@ public class Bee extends IndividualLiving implements IBee {
}
@Override
@Nullable
public IBee[] spawnDrones(IBeeHousing housing) {
public List<IBee> spawnDrones(IBeeHousing housing) {
World world = housing.getWorldObj();
// We need a mated queen to produce offspring.
if (mate == null) {
return new IBee[]{};
return Collections.emptyList();
}
List<IBee> bees = new ArrayList<>();
@@ -543,11 +548,7 @@ public class Bee extends IndividualLiving implements IBee {
bees.add(offspring);
}
if (!bees.isEmpty()) {
return bees.toArray(new IBee[bees.size()]);
} else {
return null;
}
return bees;
}
private IBee createOffspring(IBeeHousing housing, IBeeGenome mate, int generation) {
@@ -38,9 +38,7 @@ public class BeeAlyzerPlugin implements IAlyzerPlugin {
PluginApiculture.items.beeDroneGE.addCreativeItems(beeList, false);
for (ItemStack beeStack : beeList) {
IAlleleBeeSpecies species = BeeGenome.getSpecies(beeStack);
if (species != null) {
iconStacks.put(species.getUID(), beeStack);
}
iconStacks.put(species.getUID(), beeStack);
}
}
@@ -50,9 +48,6 @@ public class BeeAlyzerPlugin implements IAlyzerPlugin {
if (gui instanceof GuiAlyzer) {
GuiAlyzer guiAlyzer = (GuiAlyzer) gui;
IBee bee = BeeManager.beeRoot.getMember(itemStack);
if (bee == null) {
return;
}
EnumBeeType type = BeeManager.beeRoot.getType(itemStack);
if (type == null) {
return;
@@ -108,9 +103,6 @@ public class BeeAlyzerPlugin implements IAlyzerPlugin {
if (gui instanceof GuiAlyzer) {
GuiAlyzer guiAlyzer = (GuiAlyzer) gui;
IBee bee = BeeManager.beeRoot.getMember(itemStack);
if (bee == null) {
return;
}
EnumBeeType type = BeeManager.beeRoot.getType(itemStack);
TextLayoutHelper textLayout = guiAlyzer.getTextLayout();
@@ -215,9 +207,6 @@ public class BeeAlyzerPlugin implements IAlyzerPlugin {
if (gui instanceof GuiAlyzer) {
GuiAlyzer guiAlyzer = (GuiAlyzer) gui;
IBee bee = BeeManager.beeRoot.getMember(itemStack);
if (bee == null) {
return;
}
TextLayoutHelper textLayout = guiAlyzer.getTextLayout();
WidgetManager widgetManager = guiAlyzer.getWidgetManager();
@@ -10,6 +10,7 @@
******************************************************************************/
package forestry.apiculture.genetics;
import com.google.common.base.Preconditions;
import forestry.api.apiculture.IAlleleBeeSpeciesBuilder;
import forestry.api.apiculture.IBeeFactory;
import forestry.api.genetics.IClassification;
@@ -17,7 +18,23 @@ import forestry.apiculture.genetics.alleles.AlleleBeeSpecies;
public class BeeFactory implements IBeeFactory {
@Override
public IAlleleBeeSpeciesBuilder createSpecies(String uid, boolean dominant, String authority, String unlocalizedName, String unlocalizedDescription, IClassification branch, String binomial, int primaryColor, int secondaryColor) {
public IAlleleBeeSpeciesBuilder createSpecies(
String uid,
boolean dominant,
String authority,
String unlocalizedName,
String unlocalizedDescription,
IClassification branch,
String binomial,
int primaryColor,
int secondaryColor) {
Preconditions.checkNotNull(uid);
Preconditions.checkNotNull(authority);
Preconditions.checkNotNull(unlocalizedName);
Preconditions.checkNotNull(unlocalizedDescription);
Preconditions.checkNotNull(branch);
Preconditions.checkNotNull(binomial);
return new AlleleBeeSpecies(uid, unlocalizedName, authority, unlocalizedDescription, dominant, branch, binomial, primaryColor, secondaryColor);
}
@@ -187,9 +187,11 @@ public class BeeRoot extends SpeciesRoot implements IBeeRoot {
}
@Override
@Nullable
public IBee getMember(ItemStack stack) {
Preconditions.checkArgument(isMember(stack), "ItemStack must be a bee.");
Preconditions.checkArgument(stack.getTagCompound() != null, "ItemStack must have a tag compound.");
if (!isMember(stack) || stack.getTagCompound() == null) {
return null;
}
return new Bee(stack.getTagCompound());
}
@@ -10,6 +10,7 @@
******************************************************************************/
package forestry.apiculture.genetics;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
@@ -151,7 +152,7 @@ public class BeekeepingMode implements IBeekeepingMode {
}
@Override
public float getLifespanModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) {
public float getLifespanModifier(IBeeGenome genome, @Nullable IBeeGenome mate, float currentModifier) {
return this.lifespanModifier;
}
@@ -11,6 +11,7 @@
package forestry.apiculture.genetics;
import javax.annotation.Nullable;
import java.util.EnumMap;
import java.util.Locale;
import forestry.api.apiculture.EnumBeeType;
@@ -34,7 +35,7 @@ public class DefaultBeeModelProvider implements IBeeModelProvider {
@SideOnly(Side.CLIENT)
@Nullable
private static ModelResourceLocation[] models;
private static EnumMap<EnumBeeType, ModelResourceLocation> models;
@Override
@SideOnly(Side.CLIENT)
@@ -44,16 +45,16 @@ public class DefaultBeeModelProvider implements IBeeModelProvider {
String beeTypeNameBase = beeIconDir + beeType.toString().toLowerCase(Locale.ENGLISH);
if (models == null) {
models = new ModelResourceLocation[EnumBeeType.values().length];
models = new EnumMap<>(EnumBeeType.class);
}
models[beeType.ordinal()] = manager.getModelLocation(beeTypeNameBase);
models.put(beeType, manager.getModelLocation(beeTypeNameBase));
ModelBakery.registerItemVariants(item, new ResourceLocation("forestry:" + beeTypeNameBase));
}
@Override
@SideOnly(Side.CLIENT)
public ModelResourceLocation getModel(EnumBeeType type) {
return models[type.ordinal()];
return models.get(type);
}
}
@@ -122,7 +122,7 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
/* RESEARCH */
@Override
public float getResearchSuitability(ItemStack itemstack) {
if (itemstack == null) {
if (itemstack.isEmpty()) {
return 0f;
}
@@ -17,19 +17,20 @@ import forestry.core.gui.GuiForestryTitled;
import forestry.core.render.EnumTankLevel;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiAlveary extends GuiForestryTitled<ContainerAlveary, TileAlveary> {
public class GuiAlveary extends GuiForestryTitled<ContainerAlveary> {
private final TileAlveary tile;
public GuiAlveary(InventoryPlayer inventory, TileAlveary tile) {
super(Constants.TEXTURE_PATH_GUI + "/alveary.png", new ContainerAlveary(inventory, tile), tile);
ySize = 190;
this.tile = tile;
this.ySize = 190;
}
@Override
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
IAlvearyControllerInternal alvearyController = inventory.getMultiblockLogic().getController();
IAlvearyControllerInternal alvearyController = tile.getMultiblockLogic().getController();
drawHealthMeter(guiLeft + 20, guiTop + 37, alvearyController.getHealthScaled(46), EnumTankLevel.rateTankLevel(alvearyController.getHealthScaled(100)));
}
@@ -39,4 +40,12 @@ public class GuiAlveary extends GuiForestryTitled<ContainerAlveary, TileAlveary>
this.drawTexturedModalRect(x, y + 46 - height, i, k + 46 - height, 4, height);
}
@Override
protected void addLedgers() {
addErrorLedger(tile);
addClimateLedger(tile);
addHintLedger("apiary");
addOwnerLedger(tile);
}
}
@@ -16,12 +16,18 @@ import forestry.core.gui.GuiForestryTitled;
import forestry.core.gui.widgets.TankWidget;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiAlvearyHygroregulator extends GuiForestryTitled<ContainerAlvearyHygroregulator, TileAlvearyHygroregulator> {
public class GuiAlvearyHygroregulator extends GuiForestryTitled<ContainerAlvearyHygroregulator> {
private final TileAlvearyHygroregulator tile;
public GuiAlvearyHygroregulator(InventoryPlayer inventory, TileAlvearyHygroregulator tile) {
super(Constants.TEXTURE_PATH_GUI + "/hygroregulator.png", new ContainerAlvearyHygroregulator(inventory, tile), tile);
this.tile = tile;
widgetManager.add(new TankWidget(this.widgetManager, 104, 17, 0));
}
@Override
protected void addLedgers() {
addErrorLedger(tile);
}
}
@@ -15,10 +15,16 @@ import forestry.core.config.Constants;
import forestry.core.gui.GuiForestryTitled;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiAlvearySieve extends GuiForestryTitled<ContainerAlvearySieve, TileAlvearySieve> {
public class GuiAlvearySieve extends GuiForestryTitled<ContainerAlvearySieve> {
private final TileAlvearySieve tile;
public GuiAlvearySieve(InventoryPlayer inventory, TileAlvearySieve tile) {
super(Constants.TEXTURE_PATH_GUI + "/sieve.png", new ContainerAlvearySieve(inventory, tile), tile);
this.tile = tile;
}
@Override
protected void addLedgers() {
addErrorLedger(tile);
}
}
@@ -15,10 +15,16 @@ import forestry.core.config.Constants;
import forestry.core.gui.GuiForestryTitled;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiAlvearySwarmer extends GuiForestryTitled<ContainerAlvearySwarmer, TileAlvearySwarmer> {
public class GuiAlvearySwarmer extends GuiForestryTitled<ContainerAlvearySwarmer> {
private final TileAlvearySwarmer tile;
public GuiAlvearySwarmer(InventoryPlayer inventory, TileAlvearySwarmer tile) {
super(Constants.TEXTURE_PATH_GUI + "/swarmer.png", new ContainerAlvearySwarmer(inventory, tile), tile);
this.tile = tile;
}
@Override
protected void addLedgers() {
addErrorLedger(tile);
}
}
@@ -15,7 +15,8 @@ import forestry.core.gui.GuiForestryTitled;
import forestry.core.render.EnumTankLevel;
import net.minecraft.inventory.Container;
public class GuiBeeHousing<C extends Container & IContainerBeeHousing> extends GuiForestryTitled<C, IGuiBeeHousingInventory> {
public class GuiBeeHousing<C extends Container & IContainerBeeHousing> extends GuiForestryTitled<C> {
private final IGuiBeeHousingDelegate delegate;
public enum Icon {
APIARY("/apiary.png"),
@@ -28,16 +29,17 @@ public class GuiBeeHousing<C extends Container & IContainerBeeHousing> extends G
}
}
public GuiBeeHousing(IGuiBeeHousingInventory tile, C container, Icon icon) {
super(Constants.TEXTURE_PATH_GUI + icon.path, container, tile);
ySize = 190;
public GuiBeeHousing(IGuiBeeHousingDelegate delegate, C container, Icon icon) {
super(Constants.TEXTURE_PATH_GUI + icon.path, container, delegate);
this.delegate = delegate;
this.ySize = 190;
}
@Override
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
drawHealthMeter(guiLeft + 20, guiTop + 37, inventory.getHealthScaled(46), EnumTankLevel.rateTankLevel(inventory.getHealthScaled(100)));
drawHealthMeter(guiLeft + 20, guiTop + 37, delegate.getHealthScaled(46), EnumTankLevel.rateTankLevel(delegate.getHealthScaled(100)));
}
private void drawHealthMeter(int x, int y, int height, EnumTankLevel rated) {
@@ -47,4 +49,11 @@ public class GuiBeeHousing<C extends Container & IContainerBeeHousing> extends G
this.drawTexturedModalRect(x, y + 46 - height, i, k + 46 - height, 4, height);
}
@Override
protected void addLedgers() {
addErrorLedger(delegate);
addClimateLedger(delegate);
addHintLedger(delegate.getHintKey());
addOwnerLedger(delegate);
}
}
@@ -28,7 +28,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.common.BiomeDictionary;
public class GuiHabitatLocator extends GuiForestry<ContainerHabitatLocator, ItemInventoryHabitatLocator> {
public class GuiHabitatLocator extends GuiForestry<ContainerHabitatLocator> {
private static final LinkedListMultimap<String, BiomeDictionary.Type> habitats = LinkedListMultimap.create();
static {
@@ -46,14 +46,16 @@ public class GuiHabitatLocator extends GuiForestry<ContainerHabitatLocator, Item
habitats.put("End", BiomeDictionary.Type.END);
}
private final ItemInventoryHabitatLocator itemInventory;
private final List<HabitatSlot> habitatSlots = new ArrayList<>(habitats.size());
private int startX;
private int startY;
public GuiHabitatLocator(EntityPlayer player, ItemInventoryHabitatLocator item) {
super(Constants.TEXTURE_PATH_GUI + "/biomefinder.png", new ContainerHabitatLocator(player, item), item);
public GuiHabitatLocator(EntityPlayer player, ItemInventoryHabitatLocator itemInventory) {
super(Constants.TEXTURE_PATH_GUI + "/biomefinder.png", new ContainerHabitatLocator(player, itemInventory));
this.itemInventory = itemInventory;
xSize = 176;
ySize = 184;
@@ -85,7 +87,7 @@ public class GuiHabitatLocator extends GuiForestry<ContainerHabitatLocator, Item
// Set active according to valid biomes.
Set<BiomeDictionary.Type> activeBiomeTypes = new HashSet<>();
for (Biome biome : inventory.getBiomesToSearch()) {
for (Biome biome : itemInventory.getBiomesToSearch()) {
Set<BiomeDictionary.Type> biomeTypes = BiomeDictionary.getTypes(biome);
activeBiomeTypes.addAll(biomeTypes);
}
@@ -107,4 +109,10 @@ public class GuiHabitatLocator extends GuiForestry<ContainerHabitatLocator, Item
startX = (this.width - this.xSize) / 2;
startY = (this.height - this.ySize) / 2;
}
@Override
protected void addLedgers() {
addErrorLedger(itemInventory);
addHintLedger("habitat.locator");
}
}
@@ -29,18 +29,19 @@ import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
public class GuiImprinter extends GuiForestry<ContainerImprinter, ItemInventoryImprinter> {
public class GuiImprinter extends GuiForestry<ContainerImprinter> {
private final ItemInventoryImprinter itemInventory;
private int startX;
private int startY;
private final Map<String, ItemStack> iconStacks = new HashMap<>();
public GuiImprinter(InventoryPlayer inventoryplayer, ItemInventoryImprinter inventory) {
super(Constants.TEXTURE_PATH_GUI + "/imprinter.png", new ContainerImprinter(inventoryplayer, inventory), inventory);
public GuiImprinter(InventoryPlayer inventoryplayer, ItemInventoryImprinter itemInventory) {
super(Constants.TEXTURE_PATH_GUI + "/imprinter.png", new ContainerImprinter(inventoryplayer, itemInventory));
xSize = 176;
ySize = 185;
this.itemInventory = itemInventory;
this.xSize = 176;
this.ySize = 185;
NonNullList<ItemStack> beeList = NonNullList.create();
PluginApiculture.items.beeDroneGE.addCreativeItems(beeList, false);
@@ -59,11 +60,11 @@ public class GuiImprinter extends GuiForestry<ContainerImprinter, ItemInventoryI
int offset = (138 - fontRendererObj.getStringWidth(Translator.translateToLocal("for.gui.imprinter.name"))) / 2;
fontRendererObj.drawString(Translator.translateToLocal("for.gui.imprinter.name"), startX + 8 + offset, startY + 16, ColourProperties.INSTANCE.get("gui.screen"));
IAlleleBeeSpecies primary = inventory.getPrimary();
IAlleleBeeSpecies primary = itemInventory.getPrimary();
drawBeeSpeciesIcon(primary, startX + 12, startY + 32);
fontRendererObj.drawString(primary.getName(), startX + 32, startY + 36, ColourProperties.INSTANCE.get("gui.screen"));
IAlleleBeeSpecies secondary = inventory.getSecondary();
IAlleleBeeSpecies secondary = itemInventory.getSecondary();
drawBeeSpeciesIcon(secondary, startX + 12, startY + 52);
fontRendererObj.drawString(secondary.getName(), startX + 32, startY + 56, ColourProperties.INSTANCE.get("gui.screen"));
@@ -128,4 +129,9 @@ public class GuiImprinter extends GuiForestry<ContainerImprinter, ItemInventoryI
private static void sendSelectionChange(int index, int advance) {
Proxies.net.sendToServer(new PacketGuiSelectRequest(index, advance));
}
@Override
protected void addLedgers() {
}
}
@@ -1,21 +1,25 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.gui;
import forestry.core.tiles.ITitled;
import net.minecraft.inventory.IInventory;
public interface IGuiBeeHousingInventory extends ITitled, IInventory {
/**
* Returns scaled queen health or breeding progress
*/
int getHealthScaled(int i);
}
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.gui;
import forestry.api.core.IErrorLogicSource;
import forestry.core.owner.IOwnedTile;
import forestry.core.tiles.IClimatised;
import forestry.core.tiles.ITitled;
public interface IGuiBeeHousingDelegate extends ITitled, IErrorLogicSource, IOwnedTile, IClimatised {
/**
* Returns scaled queen health or breeding progress
*/
int getHealthScaled(int i);
String getHintKey();
}
@@ -10,7 +10,6 @@
******************************************************************************/
package forestry.apiculture.inventory;
import java.util.List;
import java.util.Set;
import com.google.common.collect.ImmutableSet;
@@ -21,16 +20,14 @@ import forestry.api.core.IErrorState;
import forestry.apiculture.PluginApiculture;
import forestry.apiculture.items.HabitatLocatorLogic;
import forestry.apiculture.items.ItemHabitatLocator;
import forestry.core.config.Config;
import forestry.core.errors.EnumErrorCode;
import forestry.core.gui.IHintSource;
import forestry.core.inventory.ItemInventory;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.biome.Biome;
public class ItemInventoryHabitatLocator extends ItemInventory implements IErrorSource, IHintSource {
public class ItemInventoryHabitatLocator extends ItemInventory implements IErrorSource {
private static final short SLOT_ENERGY = 2;
private static final short SLOT_SPECIMEN = 0;
@@ -72,7 +69,8 @@ public class ItemInventoryHabitatLocator extends ItemInventory implements IError
setInventorySlotContents(SLOT_SPECIMEN, ItemStack.EMPTY);
}
IBee bee = BeeManager.beeRoot.getMember(getStackInSlot(SLOT_ANALYZED));
ItemStack analyzed = getStackInSlot(SLOT_ANALYZED);
IBee bee = BeeManager.beeRoot.getMember(analyzed);
if (bee != null) {
locatorLogic.startBiomeSearch(bee, player);
}
@@ -82,12 +80,6 @@ public class ItemInventoryHabitatLocator extends ItemInventory implements IError
return locatorLogic.getTargetBiomes();
}
/* IHintSource */
@Override
public List<String> getHints() {
return Config.hints.get("habitat.locator");
}
/* IErrorSource */
@Override
public ImmutableSet<IErrorState> getErrorStates() {
@@ -11,7 +11,6 @@
package forestry.apiculture.multiblock;
import java.io.IOException;
import java.util.List;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeeHousingInventory;
@@ -26,8 +25,6 @@ import forestry.api.multiblock.IMultiblockController;
import forestry.apiculture.blocks.BlockAlvearyType;
import forestry.apiculture.gui.ContainerAlveary;
import forestry.apiculture.gui.GuiAlveary;
import forestry.core.config.Config;
import forestry.core.gui.IHintSource;
import forestry.core.inventory.IInventoryAdapter;
import forestry.core.multiblock.MultiblockTileEntityForestry;
import forestry.core.network.IStreamableGui;
@@ -43,7 +40,7 @@ import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
public abstract class TileAlveary extends MultiblockTileEntityForestry<MultiblockLogicAlveary> implements IBeeHousing, IAlvearyComponent, IOwnedTile, IStreamableGui, ITitled, IClimatised, IHintSource {
public abstract class TileAlveary extends MultiblockTileEntityForestry<MultiblockLogicAlveary> implements IBeeHousing, IAlvearyComponent, IOwnedTile, IStreamableGui, ITitled, IClimatised {
private final String unlocalizedTitle;
protected TileAlveary() {
@@ -157,12 +154,6 @@ public abstract class TileAlveary extends MultiblockTileEntityForestry<Multibloc
return unlocalizedTitle;
}
/* IHintSource */
@Override
public List<String> getHints() {
return Config.hints.get("apiary");
}
/* IClimatised */
@Override
public float getExactTemperature() {
@@ -74,10 +74,10 @@ public class TileAlvearySieve extends TileAlveary implements IAlvearyComponent.B
return false;
}
ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(pollen.getClass());
ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(pollen);
ItemStack pollenStack = speciesRoot.getMemberStack(pollen, EnumGermlingType.POLLEN);
if (pollenStack != null) {
if (!pollenStack.isEmpty()) {
inventory.storePollenStack(pollenStack);
return true;
}
@@ -20,7 +20,7 @@ import forestry.api.climate.IClimatePosition;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.core.ForestryAPI;
import forestry.apiculture.gui.IGuiBeeHousingInventory;
import forestry.apiculture.gui.IGuiBeeHousingDelegate;
import forestry.core.network.IStreamableGui;
import forestry.core.network.PacketBufferForestry;
import forestry.core.owner.IOwnedTile;
@@ -35,7 +35,8 @@ import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
public abstract class TileBeeHousingBase extends TileBase implements IBeeHousing, IOwnedTile, IClimatised, IGuiBeeHousingInventory, IStreamableGui {
public abstract class TileBeeHousingBase extends TileBase implements IBeeHousing, IOwnedTile, IClimatised, IGuiBeeHousingDelegate, IStreamableGui {
private final String hintKey;
private final OwnerHandler ownerHandler = new OwnerHandler();
private final IBeekeepingLogic beeLogic;
@@ -43,10 +44,15 @@ public abstract class TileBeeHousingBase extends TileBase implements IBeeHousing
private int breedingProgressPercent = 0;
protected TileBeeHousingBase(String hintKey) {
super(hintKey);
this.hintKey = hintKey;
this.beeLogic = BeeManager.beeRoot.createBeekeepingLogic(this);
}
@Override
public String getHintKey() {
return hintKey;
}
@Override
public IBeekeepingLogic getBeekeepingLogic() {
return beeLogic;
@@ -65,46 +65,18 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
private static final Random random = new Random();
private final Materials materials;
private int averageGroundLevel = -1;
private IBlockState planks;
private IBlockState slabs;
private IBlockState logs;
private IBlockState stairs;
private IBlockState fence;
private IBlockState door;
private IBlockState fenceGate;
@SuppressWarnings("unused")
public VillageApiaristHouse() {
createBuildingBlocks(random);
this.materials = new Materials(random);
}
public VillageApiaristHouse(StructureVillagePieces.Start startPiece, int componentType, Random random, StructureBoundingBox boundingBox, EnumFacing facing) {
super(startPiece, componentType, random, boundingBox, facing);
createBuildingBlocks(random);
}
private void createBuildingBlocks(Random random) {
IWoodType woodType;
boolean fireproof;
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.ARBORICULTURE)) {
woodType = EnumForestryWoodType.getRandom(random);
fireproof = random.nextInt(4) == 0;
} else {
woodType = EnumVanillaWoodType.getRandom(random);
fireproof = false;
}
IWoodAccess woodAccess = TreeManager.woodAccess;
this.logs = woodAccess.getBlock(woodType, WoodBlockKind.LOG, fireproof).withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X);
this.planks = woodAccess.getBlock(woodType, WoodBlockKind.PLANKS, fireproof);
this.slabs = woodAccess.getBlock(woodType, WoodBlockKind.SLAB, fireproof);
this.stairs = woodAccess.getBlock(woodType, WoodBlockKind.STAIRS, fireproof);
this.fence = woodAccess.getBlock(woodType, WoodBlockKind.FENCE, fireproof);
this.door = woodAccess.getBlock(woodType, WoodBlockKind.DOOR, false);
this.fenceGate = woodAccess.getBlock(woodType, WoodBlockKind.FENCE_GATE, fireproof);
this.materials = new Materials(random);
}
@Nullable
@@ -136,13 +108,13 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
buildGarden(world, structBoundingBox);
// Garden fence
fillWithBlocks(world, structBoundingBox, 1, 1, 6, 1, 1, 10, fence, fence, false);
fillWithBlocks(world, structBoundingBox, 8, 1, 6, 8, 1, 10, fence, fence, false);
fillWithBlocks(world, structBoundingBox, 2, 1, 10, 7, 1, 10, fence, fence, false);
fillWithBlocks(world, structBoundingBox, 1, 1, 6, 1, 1, 10, materials.fence, materials.fence, false);
fillWithBlocks(world, structBoundingBox, 8, 1, 6, 8, 1, 10, materials.fence, materials.fence, false);
fillWithBlocks(world, structBoundingBox, 2, 1, 10, 7, 1, 10, materials.fence, materials.fence, false);
setBlockState(world, fenceGate.withProperty(BlockHorizontal.FACING, EnumFacing.EAST), 8, 1, 8, structBoundingBox);
setBlockState(world, fenceGate.withProperty(BlockHorizontal.FACING, EnumFacing.EAST), 1, 1, 8, structBoundingBox);
setBlockState(world, fenceGate.withProperty(BlockHorizontal.FACING, EnumFacing.NORTH), 4, 1, 10, structBoundingBox);
setBlockState(world, materials.fenceGate.withProperty(BlockHorizontal.FACING, EnumFacing.EAST), 8, 1, 8, structBoundingBox);
setBlockState(world, materials.fenceGate.withProperty(BlockHorizontal.FACING, EnumFacing.EAST), 1, 1, 8, structBoundingBox);
setBlockState(world, materials.fenceGate.withProperty(BlockHorizontal.FACING, EnumFacing.NORTH), 4, 1, 10, structBoundingBox);
// Flowers
plantFlowerGarden(world, structBoundingBox, 2, 1, 5, 7, 1, 9);
@@ -151,10 +123,10 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
buildApiaries(world, structBoundingBox);
// Floor
IBlockState slabFloor = slabs.withProperty(BlockSlab.HALF, BlockSlab.EnumBlockHalf.BOTTOM);
IBlockState slabFloor = materials.slabs.withProperty(BlockSlab.HALF, BlockSlab.EnumBlockHalf.BOTTOM);
fillWithBlocks(world, structBoundingBox, 2, 0, 1, 6, 0, 4, slabFloor, slabFloor, false);
fillWithBlocks(world, structBoundingBox, 1, 0, 1, 1, 0, 4, planks, planks, false);
fillWithBlocks(world, structBoundingBox, 7, 0, 1, 7, 0, 4, planks, planks, false);
fillWithBlocks(world, structBoundingBox, 1, 0, 1, 1, 0, 4, materials.planks, materials.planks, false);
fillWithBlocks(world, structBoundingBox, 7, 0, 1, 7, 0, 4, materials.planks, materials.planks, false);
IBlockState cobblestoneState = Blocks.COBBLESTONE.getDefaultState();
fillWithBlocks(world, structBoundingBox, 0, 0, 0, 0, 2, 5, cobblestoneState, cobblestoneState, false);
@@ -162,33 +134,33 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
fillWithBlocks(world, structBoundingBox, 1, 0, 0, 7, 1, 0, cobblestoneState, cobblestoneState, false);
fillWithBlocks(world, structBoundingBox, 1, 0, 5, 7, 1, 5, cobblestoneState, cobblestoneState, false);
fillWithBlocks(world, structBoundingBox, 0, 3, 0, 0, 3, 5, planks, planks, false);
fillWithBlocks(world, structBoundingBox, 8, 3, 0, 8, 3, 5, planks, planks, false);
fillWithBlocks(world, structBoundingBox, 1, 2, 0, 7, 3, 0, planks, planks, false);
fillWithBlocks(world, structBoundingBox, 1, 2, 5, 7, 3, 5, planks, planks, false);
fillWithBlocks(world, structBoundingBox, 0, 3, 0, 0, 3, 5, materials.planks, materials.planks, false);
fillWithBlocks(world, structBoundingBox, 8, 3, 0, 8, 3, 5, materials.planks, materials.planks, false);
fillWithBlocks(world, structBoundingBox, 1, 2, 0, 7, 3, 0, materials.planks, materials.planks, false);
fillWithBlocks(world, structBoundingBox, 1, 2, 5, 7, 3, 5, materials.planks, materials.planks, false);
// Ceiling
IBlockState slabCeiling = slabs.withProperty(BlockSlab.HALF, BlockSlab.EnumBlockHalf.TOP);
IBlockState slabCeiling = materials.slabs.withProperty(BlockSlab.HALF, BlockSlab.EnumBlockHalf.TOP);
fillWithBlocks(world, structBoundingBox, 1, 4, 1, 7, 4, 4, slabCeiling, slabCeiling, false);
IBlockState logBracing = logs.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X);
IBlockState logBracing = materials.logs.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X);
fillWithBlocks(world, structBoundingBox, 0, 4, 1, 8, 4, 1, logBracing, logBracing, false);
fillWithBlocks(world, structBoundingBox, 0, 4, 4, 8, 4, 4, logBracing, logBracing, false);
fillWithBlocks(world, structBoundingBox, 0, 5, 2, 8, 5, 3, planks, planks, false);
fillWithBlocks(world, structBoundingBox, 0, 5, 2, 8, 5, 3, materials.planks, materials.planks, false);
setBlockState(world, planks, 0, 4, 2, structBoundingBox);
setBlockState(world, planks, 0, 4, 3, structBoundingBox);
setBlockState(world, planks, 8, 4, 2, structBoundingBox);
setBlockState(world, planks, 8, 4, 3, structBoundingBox);
setBlockState(world, materials.planks, 0, 4, 2, structBoundingBox);
setBlockState(world, materials.planks, 0, 4, 3, structBoundingBox);
setBlockState(world, materials.planks, 8, 4, 2, structBoundingBox);
setBlockState(world, materials.planks, 8, 4, 3, structBoundingBox);
buildRoof(world, structBoundingBox);
// sides of windows
setBlockState(world, planks, 0, 2, 1, structBoundingBox);
setBlockState(world, planks, 0, 2, 4, structBoundingBox);
setBlockState(world, planks, 8, 2, 1, structBoundingBox);
setBlockState(world, planks, 8, 2, 4, structBoundingBox);
setBlockState(world, materials.planks, 0, 2, 1, structBoundingBox);
setBlockState(world, materials.planks, 0, 2, 4, structBoundingBox);
setBlockState(world, materials.planks, 8, 2, 1, structBoundingBox);
setBlockState(world, materials.planks, 8, 2, 4, structBoundingBox);
IBlockState glassPaneState = Blocks.GLASS_PANE.getDefaultState();
@@ -196,7 +168,7 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
setBlockState(world, glassPaneState, 0, 2, 2, structBoundingBox);
setBlockState(world, glassPaneState, 0, 2, 3, structBoundingBox);
// stairs over window
IBlockState eastStairs = stairs.withProperty(BlockStairs.FACING, EnumFacing.EAST);
IBlockState eastStairs = materials.stairs.withProperty(BlockStairs.FACING, EnumFacing.EAST);
setBlockState(world, eastStairs, -1, 3, 2, structBoundingBox);
setBlockState(world, eastStairs, -1, 3, 3, structBoundingBox);
@@ -204,7 +176,7 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
setBlockState(world, glassPaneState, 8, 2, 2, structBoundingBox);
setBlockState(world, glassPaneState, 8, 2, 3, structBoundingBox);
// stairs over window
IBlockState westStairs = stairs.withProperty(BlockStairs.FACING, EnumFacing.WEST);
IBlockState westStairs = materials.stairs.withProperty(BlockStairs.FACING, EnumFacing.WEST);
setBlockState(world, westStairs, 9, 3, 2, structBoundingBox);
setBlockState(world, westStairs, 9, 3, 3, structBoundingBox);
@@ -225,13 +197,13 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
IBlockState airState = Blocks.AIR.getDefaultState();
this.setBlockState(world, this.door.withProperty(BlockDoor.FACING, EnumFacing.NORTH), 2, 1, 0, structBoundingBox);
this.setBlockState(world, this.door.withProperty(BlockDoor.FACING, EnumFacing.NORTH).withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER), 2, 2, 0, structBoundingBox);
this.setBlockState(world, materials.door.withProperty(BlockDoor.FACING, EnumFacing.NORTH), 2, 1, 0, structBoundingBox);
this.setBlockState(world, materials.door.withProperty(BlockDoor.FACING, EnumFacing.NORTH).withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER), 2, 2, 0, structBoundingBox);
this.setBlockState(world, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, EnumFacing.NORTH), 2, 3, 1, structBoundingBox);
if (isAirBlockAtCurrentPosition(world, new BlockPos(2, 0, -1), structBoundingBox) && !isAirBlockAtCurrentPosition(world, new BlockPos(2, -1, -1), structBoundingBox)) {
setBlockState(world, stairs.withProperty(BlockStairs.FACING, EnumFacing.NORTH), 2, 0, -1, structBoundingBox);
setBlockState(world, materials.stairs.withProperty(BlockStairs.FACING, EnumFacing.NORTH), 2, 0, -1, structBoundingBox);
}
setBlockState(world, airState, 6, 1, 5, structBoundingBox);
@@ -239,8 +211,8 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
this.setBlockState(world, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, EnumFacing.SOUTH), 6, 3, 4, structBoundingBox);
this.setBlockState(world, this.door.withProperty(BlockDoor.FACING, EnumFacing.SOUTH), 6, 1, 5, structBoundingBox);
this.setBlockState(world, this.door.withProperty(BlockDoor.FACING, EnumFacing.SOUTH).withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER), 6, 2, 5, structBoundingBox);
this.setBlockState(world, materials.door.withProperty(BlockDoor.FACING, EnumFacing.SOUTH), 6, 1, 5, structBoundingBox);
this.setBlockState(world, materials.door.withProperty(BlockDoor.FACING, EnumFacing.SOUTH).withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER), 6, 2, 5, structBoundingBox);
for (int i = 0; i < 5; ++i) {
for (int j = 0; j < 9; ++j) {
@@ -252,10 +224,10 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
generateChest(world, structBoundingBox, random, 7, 1, 3, Constants.VILLAGE_NATURALIST_LOOT_KEY);
// Inside Corners
fillWithBlocks(world, structBoundingBox, 1, 1, 1, 1, 3, 1, fence, fence, false);
fillWithBlocks(world, structBoundingBox, 1, 1, 4, 1, 3, 4, fence, fence, false);
fillWithBlocks(world, structBoundingBox, 7, 1, 1, 7, 3, 1, fence, fence, false);
fillWithBlocks(world, structBoundingBox, 7, 1, 4, 7, 3, 4, fence, fence, false);
fillWithBlocks(world, structBoundingBox, 1, 1, 1, 1, 3, 1, materials.fence, materials.fence, false);
fillWithBlocks(world, structBoundingBox, 1, 1, 4, 1, 3, 4, materials.fence, materials.fence, false);
fillWithBlocks(world, structBoundingBox, 7, 1, 1, 7, 3, 1, materials.fence, materials.fence, false);
fillWithBlocks(world, structBoundingBox, 7, 1, 4, 7, 3, 4, materials.fence, materials.fence, false);
spawnVillagers(world, boundingBox, 2, 1, 2, 2);
@@ -265,10 +237,10 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
private void buildRoof(World world, StructureBoundingBox structBoundingBox) {
for (int z = -1; z <= 2; ++z) {
for (int x = 0; x <= 8; ++x) {
IBlockState northStairs = stairs.withProperty(BlockStairs.FACING, EnumFacing.NORTH);
IBlockState northStairs = materials.stairs.withProperty(BlockStairs.FACING, EnumFacing.NORTH);
setBlockState(world, northStairs, x, 4 + z, z, structBoundingBox);
IBlockState southStairs = stairs.withProperty(BlockStairs.FACING, EnumFacing.SOUTH);
IBlockState southStairs = materials.stairs.withProperty(BlockStairs.FACING, EnumFacing.SOUTH);
setBlockState(world, southStairs, x, 4 + z, 5 - z, structBoundingBox);
}
}
@@ -415,4 +387,36 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
IBlockState blockStateFromPos = getBlockStateFromPos(world, pos.getX(), pos.getY(), pos.getZ(), box);
return blockStateFromPos.getBlock().isAir(blockStateFromPos, world, pos);
}
private static class Materials {
public final IBlockState planks;
public final IBlockState slabs;
public final IBlockState logs;
public final IBlockState stairs;
public final IBlockState fence;
public final IBlockState door;
public final IBlockState fenceGate;
public Materials(Random random) {
IWoodType woodType;
boolean fireproof;
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.ARBORICULTURE)) {
woodType = EnumForestryWoodType.getRandom(random);
fireproof = random.nextInt(4) == 0;
} else {
woodType = EnumVanillaWoodType.getRandom(random);
fireproof = false;
}
IWoodAccess woodAccess = TreeManager.woodAccess;
this.logs = woodAccess.getBlock(woodType, WoodBlockKind.LOG, fireproof).withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X);
this.planks = woodAccess.getBlock(woodType, WoodBlockKind.PLANKS, fireproof);
this.slabs = woodAccess.getBlock(woodType, WoodBlockKind.SLAB, fireproof);
this.stairs = woodAccess.getBlock(woodType, WoodBlockKind.STAIRS, fireproof);
this.fence = woodAccess.getBlock(woodType, WoodBlockKind.FENCE, fireproof);
this.door = woodAccess.getBlock(woodType, WoodBlockKind.DOOR, false);
this.fenceGate = woodAccess.getBlock(woodType, WoodBlockKind.FENCE_GATE, fireproof);
}
}
}
@@ -1,5 +1,6 @@
package forestry.arboriculture.compat;
import com.google.common.base.Preconditions;
import forestry.arboriculture.PluginArboriculture;
import forestry.arboriculture.items.ItemRegistryArboriculture;
import forestry.core.utils.JeiUtil;
@@ -12,6 +13,7 @@ public class ArboricultureJeiPlugin extends BlankModPlugin {
@Override
public void register(IModRegistry registry) {
ItemRegistryArboriculture items = PluginArboriculture.items;
Preconditions.checkNotNull(items);
JeiUtil.addDescription(registry,
items.grafter,
@@ -67,7 +67,7 @@ public class Tree extends Individual implements ITree, IPlantable {
if (nbttagcompound.hasKey("Genome")) {
this.genome = new TreeGenome(nbttagcompound.getCompoundTag("Genome"));
} else {
this.genome = TreeDefinition.Oak.getGenome();
throw new IllegalArgumentException("Nbt has no Genome " + nbttagcompound);
}
if (nbttagcompound.hasKey("Mate")) {
@@ -279,7 +279,7 @@ public class Tree extends Individual implements ITree, IPlantable {
/* REPRODUCTION */
@Override
public ITree[] getSaplings(World world, GameProfile playerProfile, BlockPos pos, float modifier) {
public ITree[] getSaplings(World world, @Nullable GameProfile playerProfile, BlockPos pos, float modifier) {
ArrayList<ITree> prod = new ArrayList<>();
float chance = genome.getFertility() * modifier;
@@ -295,7 +295,7 @@ public class Tree extends Individual implements ITree, IPlantable {
return prod.toArray(new ITree[prod.size()]);
}
private ITree createOffspring(World world, ITreeGenome mate, GameProfile playerProfile, BlockPos pos) {
private ITree createOffspring(World world, ITreeGenome mate, @Nullable GameProfile playerProfile, BlockPos pos) {
IChromosome[] chromosomes = new IChromosome[genome.getChromosomes().length];
IChromosome[] parent1 = genome.getChromosomes();
IChromosome[] parent2 = mate.getChromosomes();
@@ -44,7 +44,9 @@ import forestry.api.genetics.IPollinatable;
import forestry.api.genetics.ISpeciesType;
import forestry.arboriculture.PluginArboriculture;
import forestry.arboriculture.blocks.BlockFruitPod;
import forestry.arboriculture.blocks.BlockRegistryArboriculture;
import forestry.arboriculture.blocks.BlockSapling;
import forestry.arboriculture.items.ItemRegistryArboriculture;
import forestry.arboriculture.tiles.TileFruitPod;
import forestry.arboriculture.tiles.TileSapling;
import forestry.core.config.Config;
@@ -75,7 +77,7 @@ public class TreeRoot extends SpeciesRoot implements ITreeRoot {
private static ITreekeepingMode activeTreekeepingMode;
public static final List<ITree> treeTemplates = new ArrayList<>();
private final ArrayList<ITreekeepingMode> treekeepingModes = new ArrayList<>();
private final List<ITreekeepingMode> treekeepingModes = new ArrayList<>();
public TreeRoot() {
setResearchSuitability(new ItemStack(Blocks.SAPLING, 1, OreDictionary.WILDCARD_VALUE), 1.0f);
@@ -129,12 +131,13 @@ public class TreeRoot extends SpeciesRoot implements ITreeRoot {
if (stack.isEmpty()) {
return null;
}
ItemRegistryArboriculture items = PluginArboriculture.items;
Preconditions.checkState(items != null);
Item item = stack.getItem();
if (PluginArboriculture.items.sapling == item) {
if (items.sapling == item) {
return EnumGermlingType.SAPLING;
} else if (PluginArboriculture.items.pollenFertile == item) {
} else if (items.pollenFertile == item) {
return EnumGermlingType.POLLEN;
}
@@ -157,10 +160,12 @@ public class TreeRoot extends SpeciesRoot implements ITreeRoot {
}
@Override
@Nullable
public ITree getMember(ItemStack itemstack) {
itemstack = GeneticsUtil.convertToGeneticEquivalent(itemstack);
Preconditions.checkArgument(isMember(itemstack), "ItemStack must be a tree.");
Preconditions.checkArgument(itemstack.getTagCompound() != null, "ItemStack must have a tag compound.");
if (!isMember(itemstack) || itemstack.getTagCompound() == null) {
return null;
}
return new Tree(itemstack.getTagCompound());
}
@@ -179,14 +184,16 @@ public class TreeRoot extends SpeciesRoot implements ITreeRoot {
public ItemStack getMemberStack(IIndividual tree, ISpeciesType type) {
Preconditions.checkArgument(tree instanceof ITree, "individual is not a tree");
Preconditions.checkArgument(type instanceof EnumGermlingType, "type is not an EnumGermlingType");
ItemRegistryArboriculture items = PluginArboriculture.items;
Preconditions.checkState(items != null);
Item germlingItem;
switch ((EnumGermlingType) type) {
case SAPLING:
germlingItem = PluginArboriculture.items.sapling;
germlingItem = items.sapling;
break;
case POLLEN:
germlingItem = PluginArboriculture.items.pollenFertile;
germlingItem = items.pollenFertile;
break;
default:
throw new RuntimeException("Cannot instantiate a tree of type " + type);
@@ -204,8 +211,10 @@ public class TreeRoot extends SpeciesRoot implements ITreeRoot {
@Override
public boolean plantSapling(World world, ITree tree, GameProfile owner, BlockPos pos) {
BlockRegistryArboriculture blocks = PluginArboriculture.blocks;
Preconditions.checkState(blocks != null);
IBlockState state = PluginArboriculture.blocks.saplingGE.getDefaultState().withProperty(BlockSapling.TREE, tree.getGenome().getPrimary());
IBlockState state = blocks.saplingGE.getDefaultState().withProperty(BlockSapling.TREE, tree.getGenome().getPrimary());
boolean placed = world.setBlockState(pos, state);
if (!placed) {
return false;
@@ -213,7 +222,7 @@ public class TreeRoot extends SpeciesRoot implements ITreeRoot {
IBlockState blockState = world.getBlockState(pos);
Block block = blockState.getBlock();
if (PluginArboriculture.blocks.saplingGE != block) {
if (blocks.saplingGE != block) {
return false;
}
@@ -234,36 +243,36 @@ public class TreeRoot extends SpeciesRoot implements ITreeRoot {
@Override
public boolean setFruitBlock(World world, ITreeGenome genome, IAlleleFruit allele, float sappiness, BlockPos pos) {
BlockRegistryArboriculture blocks = PluginArboriculture.blocks;
Preconditions.checkState(blocks != null);
EnumFacing facing = BlockUtil.getValidPodFacing(world, pos);
if (facing == null) {
return false;
}
if (facing != null) {
BlockFruitPod fruitPod = PluginArboriculture.blocks.getFruitPod(allele);
if (fruitPod == null) {
return false;
}
BlockFruitPod fruitPod = blocks.getFruitPod(allele);
if (fruitPod != null) {
IBlockState state = fruitPod.getDefaultState().withProperty(BlockHorizontal.FACING, facing);
boolean placed = world.setBlockState(pos, state);
if (!placed) {
return false;
}
IBlockState state = fruitPod.getDefaultState().withProperty(BlockHorizontal.FACING, facing);
boolean placed = world.setBlockState(pos, state);
if (placed) {
Block block = world.getBlockState(pos).getBlock();
if (fruitPod != block) {
return false;
}
Block block = world.getBlockState(pos).getBlock();
if (fruitPod == block) {
TileFruitPod pod = TileUtil.getTile(world, pos, TileFruitPod.class);
if (pod == null) {
world.setBlockToAir(pos);
return false;
TileFruitPod pod = TileUtil.getTile(world, pos, TileFruitPod.class);
if (pod != null) {
pod.setProperties(genome, allele, sappiness);
world.markBlockRangeForRenderUpdate(pos, pos);
return true;
} else {
world.setBlockToAir(pos);
return false;
}
}
}
}
}
pod.setProperties(genome, allele, sappiness);
world.markBlockRangeForRenderUpdate(pos, pos);
return true;
return false;
}
/* GENOME CONVERSIONS */
@@ -10,6 +10,7 @@
******************************************************************************/
package forestry.core.circuits;
import javax.annotation.Nullable;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -73,6 +74,7 @@ public class CircuitRegistry implements ICircuitRegistry {
}
@Override
@Nullable
public ICircuitLayout getLayout(String uid) {
if (layoutMap.containsKey(uid)) {
return layoutMap.get(uid);
@@ -93,6 +95,7 @@ public class CircuitRegistry implements ICircuitRegistry {
}
@Override
@Nullable
public ICircuit getCircuit(String uid) {
return circuitMap.get(uid);
}
@@ -2,6 +2,7 @@ package forestry.core.circuits;
import forestry.api.circuits.ICircuit;
@SuppressWarnings({"unused", "NullableProblems"})
public class Circuits {
public static ICircuit energyElectricChoke1;
public static ICircuit energyElectricEfficiency1;
@@ -26,13 +26,15 @@ import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
public class GuiSolderingIron extends GuiForestry<ContainerSolderingIron, ItemInventorySolderingIron> {
public class GuiSolderingIron extends GuiForestry<ContainerSolderingIron> {
private final ItemInventorySolderingIron itemInventory;
public GuiSolderingIron(EntityPlayer player, ItemInventorySolderingIron inventory) {
super(Constants.TEXTURE_PATH_GUI + "/solder.png", new ContainerSolderingIron(player, inventory), inventory);
public GuiSolderingIron(EntityPlayer player, ItemInventorySolderingIron itemInventory) {
super(Constants.TEXTURE_PATH_GUI + "/solder.png", new ContainerSolderingIron(player, itemInventory));
xSize = 176;
ySize = 205;
this.itemInventory = itemInventory;
this.xSize = 176;
this.ySize = 205;
}
@Override
@@ -45,7 +47,7 @@ public class GuiSolderingIron extends GuiForestry<ContainerSolderingIron, ItemIn
for (int i = 0; i < 4; i++) {
String description;
ItemStack tube = inventory.getStackInSlot(i + 2);
ItemStack tube = itemInventory.getStackInSlot(i + 2);
CircuitRecipe recipe = SolderManager.getMatchingRecipe(layout, tube);
if (recipe == null) {
description = "(" + Translator.translateToLocal("for.gui.noeffect") + ")";
@@ -87,4 +89,9 @@ public class GuiSolderingIron extends GuiForestry<ContainerSolderingIron, ItemIn
}
}
@Override
protected void addLedgers() {
addErrorLedger(itemInventory);
addHintLedger("soldering.iron");
}
}
@@ -14,6 +14,7 @@ import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
import com.google.common.base.Preconditions;
import forestry.api.circuits.ICircuit;
import forestry.api.circuits.ICircuitLayout;
import forestry.api.circuits.ISolderManager;
@@ -24,15 +25,10 @@ public class SolderManager implements ISolderManager {
@Override
public void addRecipe(ICircuitLayout layout, ItemStack resource, ICircuit circuit) {
if (layout == null) {
throw new IllegalArgumentException("layout may not be null");
}
if (resource == null) {
throw new IllegalArgumentException("resource may not be null");
}
if (circuit == null) {
throw new IllegalArgumentException("circuit may not be null");
}
Preconditions.checkNotNull(layout, "layout may not be null");
Preconditions.checkNotNull(resource, "resource may not be null");
Preconditions.checkNotNull(circuit, "circuit may not be null");
recipes.add(new CircuitRecipe(layout, resource, circuit));
}
@@ -46,13 +42,14 @@ public class SolderManager implements ISolderManager {
}
@Nullable
public static CircuitRecipe getMatchingRecipe(ICircuitLayout layout, ItemStack resource) {
for (CircuitRecipe recipe : recipes) {
if (recipe.matches(layout, resource)) {
return recipe;
public static CircuitRecipe getMatchingRecipe(@Nullable ICircuitLayout layout, ItemStack resource) {
if (layout != null) {
for (CircuitRecipe recipe : recipes) {
if (recipe.matches(layout, resource)) {
return recipe;
}
}
}
return null;
}
}
@@ -12,7 +12,6 @@ package forestry.core.entities;
import forestry.core.gui.GuiHandler;
import forestry.core.gui.IGuiHandlerEntity;
import forestry.core.gui.IHintSource;
import forestry.core.tiles.ITitled;
import forestry.core.utils.Translator;
import net.minecraft.block.Block;
@@ -26,7 +25,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.minecart.MinecartInteractEvent;
public abstract class EntityMinecartForestry extends EntityMinecart implements ITitled, IHintSource, IGuiHandlerEntity {
public abstract class EntityMinecartForestry extends EntityMinecart implements ITitled, IGuiHandlerEntity {
@SuppressWarnings("unused")
public EntityMinecartForestry(World world) {
@@ -162,9 +162,7 @@ public class AlleleRegistry implements IAlleleRegistry {
alleleMap.put(allele.getUID(), allele);
if (allele instanceof IAlleleSpecies) {
IClassification branch = ((IAlleleSpecies) allele).getBranch();
if (branch != null) {
branch.addMemberSpecies((IAlleleSpecies) allele);
}
branch.addMemberSpecies((IAlleleSpecies) allele);
}
for (IAlleleHandler handler : this.alleleHandlers) {
+26 -9
View File
@@ -11,6 +11,8 @@
package forestry.core.gui;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Stack;
@@ -21,6 +23,7 @@ import forestry.api.genetics.EnumTolerance;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IAlleleSpecies;
import forestry.api.genetics.IAlleleTolerance;
import forestry.api.genetics.IAlyzerPlugin;
import forestry.api.genetics.IBreedingTracker;
import forestry.api.genetics.IChromosomeType;
import forestry.api.genetics.IClassification;
@@ -31,7 +34,6 @@ import forestry.api.genetics.IMutation;
import forestry.api.genetics.ISpeciesRoot;
import forestry.core.config.Constants;
import forestry.core.genetics.mutations.EnumMutateChance;
import forestry.core.gui.ledgers.LedgerManager;
import forestry.core.gui.widgets.ItemStackWidget;
import forestry.core.gui.widgets.WidgetManager;
import forestry.core.inventory.ItemInventoryAlyzer;
@@ -41,19 +43,21 @@ import forestry.core.utils.Translator;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import org.apache.commons.lang3.StringUtils;
public class GuiAlyzer extends GuiForestry<ContainerAlyzer, IInventory> {
public class GuiAlyzer extends GuiForestry<ContainerAlyzer> {
public static final int COLUMN_0 = 12;
public static final int COLUMN_1 = 90;
public static final int COLUMN_2 = 155;
public GuiAlyzer(EntityPlayer player, ItemInventoryAlyzer inventory) {
super(Constants.TEXTURE_PATH_GUI + "/portablealyzer.png", new ContainerAlyzer(inventory, player), inventory);
private final ItemInventoryAlyzer itemInventory;
public GuiAlyzer(EntityPlayer player, ItemInventoryAlyzer itemInventory) {
super(Constants.TEXTURE_PATH_GUI + "/portablealyzer.png", new ContainerAlyzer(itemInventory, player));
this.itemInventory = itemInventory;
this.xSize = 246;
this.ySize = 238;
}
@@ -136,7 +140,7 @@ public class GuiAlyzer extends GuiForestry<ContainerAlyzer, IInventory> {
return;
}
ItemStack stackInSlot = inventory.getStackInSlot(specimenSlot);
ItemStack stackInSlot = itemInventory.getStackInSlot(specimenSlot);
ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(stackInSlot);
if (speciesRoot == null) {
return;
@@ -173,7 +177,7 @@ public class GuiAlyzer extends GuiForestry<ContainerAlyzer, IInventory> {
private int getSpecimenSlot() {
for (int k = ItemInventoryAlyzer.SLOT_SPECIMEN; k <= ItemInventoryAlyzer.SLOT_ANALYZE_5; k++) {
ItemStack stackInSlot = inventory.getStackInSlot(k);
ItemStack stackInSlot = itemInventory.getStackInSlot(k);
if (stackInSlot.isEmpty()) {
continue;
}
@@ -475,8 +479,21 @@ public class GuiAlyzer extends GuiForestry<ContainerAlyzer, IInventory> {
return widgetManager;
}
public LedgerManager getLedgerManager() {
return ledgerManager;
@Override
protected void addLedgers() {
addErrorLedger(itemInventory);
addHintLedger(getHints());
}
public List<String> getHints() {
ItemStack specimen = itemInventory.getSpecimen();
if (!specimen.isEmpty()) {
ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(specimen);
if (speciesRoot != null) {
IAlyzerPlugin alyzerPlugin = speciesRoot.getAlyzerPlugin();
return alyzerPlugin.getHints();
}
}
return Collections.emptyList();
}
}
@@ -16,18 +16,20 @@ import forestry.core.render.EnumTankLevel;
import forestry.core.tiles.TileAnalyzer;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiAnalyzer extends GuiForestryTitled<ContainerAnalyzer, TileAnalyzer> {
public class GuiAnalyzer extends GuiForestryTitled<ContainerAnalyzer> {
private final TileAnalyzer tile;
public GuiAnalyzer(InventoryPlayer inventory, TileAnalyzer tile) {
super(Constants.TEXTURE_PATH_GUI + "/alyzer.png", new ContainerAnalyzer(inventory, tile), tile);
ySize = 176;
widgetManager.add(new TankWidget(this.widgetManager, 95, 24, 0));
this.tile = tile;
this.ySize = 176;
this.widgetManager.add(new TankWidget(this.widgetManager, 95, 24, 0));
}
@Override
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
drawAnalyzeMeter(guiLeft + 64, guiTop + 30, inventory.getProgressScaled(46), EnumTankLevel.rateTankLevel(inventory.getProgressScaled(100)));
drawAnalyzeMeter(guiLeft + 64, guiTop + 30, tile.getProgressScaled(46), EnumTankLevel.rateTankLevel(tile.getProgressScaled(100)));
}
private void drawAnalyzeMeter(int x, int y, int height, EnumTankLevel rated) {
@@ -36,4 +38,10 @@ public class GuiAnalyzer extends GuiForestryTitled<ContainerAnalyzer, TileAnalyz
drawTexturedModalRect(x, y + 46 - height, i, k + 46 - height, 4, height);
}
@Override
protected void addLedgers() {
addErrorLedger(tile);
addHintLedger("analyzer");
}
}
@@ -8,10 +8,10 @@ import forestry.core.render.ColourProperties;
import forestry.core.utils.Translator;
import net.minecraft.entity.player.EntityPlayer;
public class GuiCamouflageSprayCan extends GuiForestry<ContainerCamouflageSprayCan, ItemInventoryCamouflageSprayCan> {
public class GuiCamouflageSprayCan extends GuiForestry<ContainerCamouflageSprayCan> {
public GuiCamouflageSprayCan(EntityPlayer player, ItemInventoryCamouflageSprayCan inventory) {
super(Constants.TEXTURE_PATH_GUI + "/camouflage_spray_can.png", new ContainerCamouflageSprayCan(inventory, player.inventory), inventory);
super(Constants.TEXTURE_PATH_GUI + "/camouflage_spray_can.png", new ContainerCamouflageSprayCan(inventory, player.inventory));
widgetManager.add(new WidgetCamouflageSlot(widgetManager, 80, 39, inventory, CamouflageManager.NONE));
}
@@ -26,4 +26,9 @@ public class GuiCamouflageSprayCan extends GuiForestry<ContainerCamouflageSprayC
bindTexture(textureFile);
}
@Override
protected void addLedgers() {
}
}
@@ -25,17 +25,19 @@ import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TextFormatting;
public class GuiEscritoire extends GuiForestry<ContainerEscritoire, TileEscritoire> {
public class GuiEscritoire extends GuiForestry<ContainerEscritoire> {
private final ItemStack LEVEL_ITEM = new ItemStack(Items.PAPER);
private final EscritoireTextSource textSource = new EscritoireTextSource();
private final TileEscritoire tile;
public GuiEscritoire(EntityPlayer player, TileEscritoire tile) {
super(Constants.TEXTURE_PATH_GUI + "/escritoire.png", new ContainerEscritoire(player, tile), tile);
super(Constants.TEXTURE_PATH_GUI + "/escritoire.png", new ContainerEscritoire(player, tile));
xSize = 228;
ySize = 235;
this.tile = tile;
this.xSize = 228;
this.ySize = 235;
widgetManager.add(new ProbeButton(this, widgetManager, 14, 16));
this.widgetManager.add(new ProbeButton(this, widgetManager, 14, 16));
EscritoireGame game = tile.getGame();
@@ -80,7 +82,7 @@ public class GuiEscritoire extends GuiForestry<ContainerEscritoire, TileEscritoi
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
for (int i = 0; i <= inventory.getGame().getBountyLevel() / 4; i++) {
for (int i = 0; i <= tile.getGame().getBountyLevel() / 4; i++) {
GuiUtil.drawItemStack(this, LEVEL_ITEM, guiLeft + 170 + i * 8, guiTop + 7);
}
@@ -92,13 +94,19 @@ public class GuiEscritoire extends GuiForestry<ContainerEscritoire, TileEscritoi
textLayout.newLine();
textLayout.newLine();
String format = TextFormatting.UNDERLINE + TextFormatting.ITALIC.toString();
int attemptNo = EscritoireGame.BOUNTY_MAX - inventory.getGame().getBountyLevel();
int attemptNo = EscritoireGame.BOUNTY_MAX - tile.getGame().getBountyLevel();
String attemptNoString = Translator.translateToLocalFormatted("for.gui.escritoire.attempt.number", attemptNo);
textLayout.drawLine(format + attemptNoString, 170, ColourProperties.INSTANCE.get("gui.mail.lettertext"));
textLayout.newLine();
String escritoireText = textSource.getText(inventory.getGame());
String escritoireText = textSource.getText(tile.getGame());
textLayout.drawSplitLine(escritoireText, 170, 90, ColourProperties.INSTANCE.get("gui.mail.lettertext"));
}
textLayout.endPage();
}
@Override
protected void addLedgers() {
addErrorLedger(tile);
addHintLedger("escritoire");
}
}
@@ -31,23 +31,19 @@ import forestry.core.proxy.Proxies;
import forestry.core.render.ColourProperties;
import forestry.core.render.ForestryResource;
import forestry.core.tiles.IClimatised;
import forestry.core.tiles.IPowerHandler;
import forestry.core.tiles.TileEngine;
import forestry.energy.EnergyManager;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidTank;
public abstract class GuiForestry<C extends Container, I extends IInventory> extends GuiContainer {
@Nullable
protected final I inventory;
public abstract class GuiForestry<C extends Container> extends GuiContainer {
protected final C container;
public final ResourceLocation textureFile;
@@ -55,11 +51,11 @@ public abstract class GuiForestry<C extends Container, I extends IInventory> ext
protected final LedgerManager ledgerManager;
protected final TextLayoutHelper textLayout;
protected GuiForestry(String texture, C container, @Nullable I inventory) {
this(new ForestryResource(texture), container, inventory);
protected GuiForestry(String texture, C container) {
this(new ForestryResource(texture), container);
}
protected GuiForestry(ResourceLocation texture, C container, @Nullable I inventory) {
protected GuiForestry(ResourceLocation texture, C container) {
super(container);
this.widgetManager = new WidgetManager(this);
@@ -67,7 +63,6 @@ public abstract class GuiForestry<C extends Container, I extends IInventory> ext
this.textureFile = texture;
this.inventory = inventory;
this.container = container;
this.textLayout = new TextLayoutHelper(this, ColourProperties.INSTANCE);
@@ -82,46 +77,47 @@ public abstract class GuiForestry<C extends Container, I extends IInventory> ext
this.ledgerManager.setMaxWidth(maxLedgerWidth);
this.ledgerManager.clear();
addLedgers();
}
protected void addLedgers() {
if (inventory instanceof IErrorSource) {
ledgerManager.add((IErrorSource) inventory);
}
protected abstract void addLedgers();
if (inventory instanceof IErrorLogicSource) {
IErrorLogicSource errorLogicSource = (IErrorLogicSource) inventory;
ledgerManager.add(errorLogicSource.getErrorLogic());
}
protected final void addErrorLedger(IErrorSource errorSource) {
ledgerManager.add(errorSource);
}
if (inventory instanceof IClimatised) {
ledgerManager.add(new ClimateLedger(ledgerManager, (IClimatised) inventory));
}
protected final void addErrorLedger(IErrorLogicSource errorSource) {
ledgerManager.add(errorSource.getErrorLogic());
}
protected final void addClimateLedger(IClimatised climatised) {
ledgerManager.add(new ClimateLedger(ledgerManager, climatised));
}
protected final void addPowerLedger(EnergyManager energyManager) {
if (Config.enableEnergyStat) {
if (inventory instanceof IPowerHandler && !(inventory instanceof TileEngine)) {
IPowerHandler powerHandler = (IPowerHandler) this.inventory;
if (powerHandler.getEnergyManager().getMaxEnergyStored() > 0) {
ledgerManager.add(new PowerLedger(ledgerManager, powerHandler));
}
}
ledgerManager.add(new PowerLedger(ledgerManager, energyManager));
}
}
if (Config.enableHints && inventory instanceof IHintSource) {
IHintSource hintSource = (IHintSource) inventory;
List<String> hints = hintSource.getHints();
if (!hints.isEmpty()) {
ledgerManager.add(new HintLedger(ledgerManager, hintSource));
}
protected final void addHintLedger(String hintsKey) {
if (Config.enableHints) {
List<String> hints = Config.hints.get(hintsKey);
ledgerManager.add(new HintLedger(ledgerManager, hints));
}
}
if (inventory instanceof IOwnedTile) {
ledgerManager.add(new OwnerLedger(ledgerManager, (IOwnedTile) inventory));
protected final void addHintLedger(List<String> hints) {
if (Config.enableHints) {
ledgerManager.add(new HintLedger(ledgerManager, hints));
}
}
protected final void addOwnerLedger(IOwnedTile ownedTile) {
ledgerManager.add(new OwnerLedger(ledgerManager, ownedTile));
}
@Override
public void onGuiClosed() {
super.onGuiClosed();
@@ -147,7 +143,7 @@ public abstract class GuiForestry<C extends Container, I extends IInventory> ext
@Override
protected void mouseReleased(int mouseX, int mouseY, int state) {
if(widgetManager.handleMouseRelease(mouseX, mouseY, state)){
if (widgetManager.handleMouseRelease(mouseX, mouseY, state)) {
return;
}
super.mouseReleased(mouseX, mouseY, state);
@@ -14,19 +14,20 @@ import forestry.core.render.ColourProperties;
import forestry.core.tiles.ITitled;
import forestry.core.utils.Translator;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
public abstract class GuiForestryTitled<C extends Container, I extends ITitled & IInventory> extends GuiForestry<C, I> {
public abstract class GuiForestryTitled<C extends Container> extends GuiForestry<C> {
private final String unlocalizedTitle;
protected GuiForestryTitled(String texture, C container, I inventory) {
super(texture, container, inventory);
protected GuiForestryTitled(String texture, C container, ITitled titled) {
super(texture, container);
this.unlocalizedTitle = titled.getUnlocalizedTitle();
}
@Override
protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
String name = Translator.translateToLocal(inventory.getUnlocalizedTitle());
String name = Translator.translateToLocal(this.unlocalizedTitle);
textLayout.line = 6;
textLayout.drawCenteredLine(name, 0, ColourProperties.INSTANCE.get("gui.title"));
bindTexture(textureFile);
@@ -36,14 +36,14 @@ import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class GuiNaturalistInventory extends GuiForestry<Container, IPagedInventory> {
public class GuiNaturalistInventory extends GuiForestry<Container> {
private final ISpeciesRoot speciesRoot;
private final IBreedingTracker breedingTracker;
private final HashMap<String, ItemStack> iconStacks = new HashMap<>();
private final int pageCurrent, pageMax;
public GuiNaturalistInventory(ISpeciesRoot speciesRoot, EntityPlayer player, Container container, IPagedInventory inventory, int page, int maxPages) {
super(Constants.TEXTURE_PATH_GUI + "/apiaristinventory.png", container, inventory);
public GuiNaturalistInventory(ISpeciesRoot speciesRoot, EntityPlayer player, Container container, int page, int maxPages) {
super(Constants.TEXTURE_PATH_GUI + "/apiaristinventory.png", container);
this.speciesRoot = speciesRoot;
@@ -250,4 +250,9 @@ public class GuiNaturalistInventory extends GuiForestry<Container, IPagedInvento
Proxies.render.bindTexture(textureFile);
drawTexturedModalRect(guiLeft + x, guiTop + textLayout.getLineY(), column, line, 16, 16);
}
@Override
protected void addLedgers() {
addHintLedger("naturalist.chest");
}
}
@@ -1,17 +0,0 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.core.gui;
import java.util.List;
public interface IHintSource {
List<String> getHints();
}
@@ -13,7 +13,6 @@ package forestry.core.gui.ledgers;
import java.util.List;
import java.util.Random;
import forestry.core.gui.IHintSource;
import forestry.core.proxy.Proxies;
import forestry.core.render.TextureManager;
import forestry.core.utils.Translator;
@@ -25,9 +24,8 @@ public class HintLedger extends Ledger {
private final String hintString;
private final String hintTooltip;
public HintLedger(LedgerManager manager, IHintSource tile) {
public HintLedger(LedgerManager manager, List<String> hints) {
super(manager, "hint");
List<String> hints = tile.getHints();
int position = new Random().nextInt(hints.size());
String hint = hints.get(position);
@@ -11,17 +11,15 @@
package forestry.core.gui.ledgers;
import forestry.core.render.TextureManager;
import forestry.core.tiles.IPowerHandler;
import forestry.core.utils.Translator;
import forestry.energy.EnergyManager;
public class PowerLedger extends Ledger {
private final EnergyManager energyManager;
private final IPowerHandler tile;
public PowerLedger(LedgerManager manager, IPowerHandler tile) {
public PowerLedger(LedgerManager manager, EnergyManager energyManager) {
super(manager, "power");
this.tile = tile;
this.energyManager = energyManager;
maxHeight = 94;
}
@@ -40,8 +38,6 @@ public class PowerLedger extends Ledger {
int xHeader = x + 22;
int xBody = x + 12;
EnergyManager energyManager = tile.getEnergyManager();
drawHeader(Translator.translateToLocal("for.gui.energy"), xHeader, y + 8);
drawSubheader(Translator.translateToLocal("for.gui.stored") + ':', xBody, y + 20);
@@ -56,7 +52,7 @@ public class PowerLedger extends Ledger {
@Override
public String getTooltip() {
return tile.getEnergyManager().getEnergyStored() + " RF";
return energyManager.getEnergyStored() + " RF";
}
}
@@ -10,22 +10,17 @@
******************************************************************************/
package forestry.core.inventory;
import java.util.Collections;
import java.util.List;
import com.google.common.collect.ImmutableSet;
import forestry.api.core.ForestryAPI;
import forestry.api.core.IErrorSource;
import forestry.api.core.IErrorState;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAlyzerPlugin;
import forestry.api.genetics.IBreedingTracker;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.ISpeciesRoot;
import forestry.apiculture.PluginApiculture;
import forestry.apiculture.items.ItemRegistryApiculture;
import forestry.core.errors.EnumErrorCode;
import forestry.core.gui.IHintSource;
import forestry.core.utils.GeneticsUtil;
import forestry.plugins.ForestryPluginUids;
import net.minecraft.entity.player.EntityPlayer;
@@ -33,7 +28,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class ItemInventoryAlyzer extends ItemInventory implements IErrorSource, IHintSource {
public class ItemInventoryAlyzer extends ItemInventory implements IErrorSource {
public static final int SLOT_ENERGY = 0;
public static final int SLOT_SPECIMEN = 1;
public static final int SLOT_ANALYZE_1 = 2;
@@ -172,18 +167,4 @@ public class ItemInventoryAlyzer extends ItemInventory implements IErrorSource,
public boolean hasSpecimen() {
return !getSpecimen().isEmpty();
}
/* IHintSource */
@Override
public List<String> getHints() {
ItemStack specimen = getSpecimen();
if (!specimen.isEmpty()) {
ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(specimen);
if (speciesRoot != null) {
IAlyzerPlugin alyzerPlugin = speciesRoot.getAlyzerPlugin();
return alyzerPlugin.getHints();
}
}
return Collections.emptyList();
}
}
@@ -10,7 +10,7 @@
******************************************************************************/
package forestry.core.inventory;
import java.util.List;
import javax.annotation.Nullable;
import com.google.common.collect.ImmutableSet;
import forestry.api.circuits.ChipsetManager;
@@ -23,15 +23,13 @@ import forestry.core.circuits.CircuitRegistry;
import forestry.core.circuits.EnumCircuitBoardType;
import forestry.core.circuits.ItemCircuitBoard;
import forestry.core.circuits.SolderManager;
import forestry.core.config.Config;
import forestry.core.errors.EnumErrorCode;
import forestry.core.gui.IHintSource;
import forestry.core.utils.datastructures.RevolvingList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class ItemInventorySolderingIron extends ItemInventory implements IErrorSource, IHintSource {
public class ItemInventorySolderingIron extends ItemInventory implements IErrorSource {
private final RevolvingList<ICircuitLayout> layouts = new RevolvingList<>(ChipsetManager.circuitRegistry.getRegisteredLayouts().values());
@@ -51,6 +49,7 @@ public class ItemInventorySolderingIron extends ItemInventory implements IErrorS
return 1;
}
@Nullable
public ICircuitLayout getLayout() {
return layouts.getCurrent();
}
@@ -186,9 +185,4 @@ public class ItemInventorySolderingIron extends ItemInventory implements IErrorS
}
return false;
}
@Override
public List<String> getHints() {
return Config.hints.get("soldering.iron");
}
}
@@ -103,6 +103,7 @@ public final class AdjacentTileCache {
return source.getPos().getX() + side.getFrontOffsetX() == target.getPos().getX() && source.getPos().getY() + side.getFrontOffsetY() == target.getPos().getY() && source.getPos().getZ() + side.getFrontOffsetZ() == target.getPos().getZ();
}
@Nullable
public TileEntity getTileOnSide(EnumFacing side) {
int s = side.ordinal();
if (cache[s] != null) {
@@ -59,7 +59,7 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui
/* CONSTRUCTOR */
public TileAnalyzer() {
super("analyzer", 800, Constants.MACHINE_MAX_ENERGY);
super(800, Constants.MACHINE_MAX_ENERGY);
setInternalInventory(new InventoryAnalyzer(this));
resourceTank = new FilteredTank(Constants.PROCESSOR_TANK_CAPACITY).setFilters(Fluids.FOR_HONEY.getFluid());
tankManager = new TankManager(this, resourceTank);
@@ -10,14 +10,8 @@
******************************************************************************/
package forestry.core.tiles;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
import forestry.core.blocks.BlockBase;
import forestry.core.config.Config;
import forestry.core.gui.GuiHandler;
import forestry.core.gui.IHintSource;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
@@ -25,27 +19,12 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public abstract class TileBase extends TileForestry implements IHintSource {
protected final List<String> hints;
protected TileBase(@Nullable String hintKey) {
this.hints = new ArrayList<>(Config.hints.get(hintKey));
}
public abstract class TileBase extends TileForestry {
public void openGui(EntityPlayer player, ItemStack heldItem) {
GuiHandler.openGui(player, this);
}
public boolean canDrainWithBucket() {
return false;
}
/* IHintSource */
@Override
public final List<String> getHints() {
return hints;
}
@Override
public String getUnlocalizedTitle() {
Block block = getBlockType();
@@ -16,7 +16,6 @@ import java.io.IOException;
import forestry.api.core.IErrorLogic;
import forestry.apiculture.network.packets.PacketActiveUpdate;
import forestry.core.blocks.BlockBase;
import forestry.core.config.Config;
import forestry.core.config.Constants;
import forestry.core.errors.EnumErrorCode;
import forestry.core.network.IStreamableGui;
@@ -52,15 +51,18 @@ public abstract class TileEngine extends TileBase implements IActivatable, IStre
protected boolean forceCooldown = false;
public float progress;
protected final EnergyManager energyManager;
private final String hintKey;
protected TileEngine(@Nullable String hintKey, int maxHeat, int maxEnergy) {
super(hintKey);
protected TileEngine(String hintKey, int maxHeat, int maxEnergy) {
this.hintKey = hintKey;
this.maxHeat = maxHeat;
energyManager = new EnergyManager(2000, maxEnergy);
energyManager.setExternalMode(EnergyTransferMode.EXTRACT);
}
hints.addAll(Config.hints.get("engine"));
public String getHintKey() {
return hintKey;
}
protected void addHeat(int i) {
@@ -37,7 +37,6 @@ public class TileEscritoire extends TileBase implements ISidedInventory, ISlotPi
private ItemStack individualOnDisplayClient = ItemStack.EMPTY;
public TileEscritoire() {
super("escritoire");
setInternalInventory(new InventoryEscritoire(this));
}
@@ -10,7 +10,6 @@
******************************************************************************/
package forestry.core.tiles;
import javax.annotation.Nullable;
import java.io.IOException;
import forestry.core.network.PacketBufferForestry;
@@ -22,8 +21,7 @@ public abstract class TileMill extends TileBase {
public int charge = 0;
public float progress;
protected TileMill(@Nullable String hintKey) {
super(hintKey);
protected TileMill() {
speed = 0.01F;
}
@@ -35,7 +35,6 @@ public abstract class TileNaturalistChest extends TileBase implements IPagedInve
private int numPlayersUsing;
public TileNaturalistChest(ISpeciesRoot speciesRoot) {
super("naturalist.chest");
this.speciesRoot = speciesRoot;
setInternalInventory(new InventoryNaturalistChest(this, speciesRoot));
}
@@ -112,7 +111,7 @@ public abstract class TileNaturalistChest extends TileBase implements IPagedInve
@Override
public Object getGui(EntityPlayer player, int page) {
ContainerNaturalistInventory container = new ContainerNaturalistInventory(player.inventory, this, page);
return new GuiNaturalistInventory(speciesRoot, player, container, this, page, 5);
return new GuiNaturalistInventory(speciesRoot, player, container, page, 5);
}
@Override
@@ -15,7 +15,6 @@ import java.io.IOException;
import forestry.api.core.IErrorLogic;
import forestry.core.circuits.ISpeedUpgradable;
import forestry.core.config.Config;
import forestry.core.errors.EnumErrorCode;
import forestry.core.network.IStreamableGui;
import forestry.core.network.PacketBufferForestry;
@@ -43,14 +42,15 @@ public abstract class TilePowered extends TileBase implements IRenderableTile, I
// the number of work ticks that this tile has had no power
private int noPowerTime = 0;
protected TilePowered(String hintKey, int maxTransfer, int capacity) {
super(hintKey);
protected TilePowered(int maxTransfer, int capacity) {
this.energyManager = new EnergyManager(maxTransfer, capacity);
this.energyManager.setExternalMode(EnergyTransferMode.RECEIVE);
this.ticksPerWorkCycle = 4;
}
hints.addAll(Config.hints.get("powered.machine"));
public EnergyManager getEnergyManager() {
return energyManager;
}
public int getWorkCounter() {
@@ -1,5 +1,7 @@
package forestry.energy;
import javax.annotation.Nullable;
import forestry.api.core.ForestryAPI;
import forestry.core.tiles.TileEngine;
import forestry.energy.compat.tesla.TeslaHelper;
@@ -87,8 +89,8 @@ public class EnergyHelper {
return sendEnergy(energyManager, orientation, tile, Integer.MAX_VALUE, true) > 0;
}
public static boolean isEnergyReceiverOrEngine(EnumFacing side, TileEntity tile) {
if(tile == null){
public static boolean isEnergyReceiverOrEngine(EnumFacing side, @Nullable TileEntity tile) {
if (tile == null) {
return false;
}
if (tile instanceof TileEngine) { // engine chaining
@@ -17,10 +17,12 @@ import forestry.core.tiles.TileEngine;
import forestry.core.utils.Translator;
import net.minecraft.inventory.Container;
public abstract class GuiEngine<C extends Container, I extends TileEngine> extends GuiForestryTitled<C, I> {
public abstract class GuiEngine<C extends Container, I extends TileEngine> extends GuiForestryTitled<C> {
protected final I tile;
protected GuiEngine(String texture, C container, I tile) {
super(texture, container, tile);
this.tile = tile;
}
@Override
@@ -52,19 +54,25 @@ public abstract class GuiEngine<C extends Container, I extends TileEngine> exten
drawHeader(Translator.translateToLocal("for.gui.energy"), x + 22, y + 8);
drawSubheader(Translator.translateToLocal("for.gui.currentOutput") + ':', x + 22, y + 20);
drawText(inventory.getCurrentOutput() + " RF/t", x + 22, y + 32);
drawText(tile.getCurrentOutput() + " RF/t", x + 22, y + 32);
drawSubheader(Translator.translateToLocal("for.gui.stored") + ':', x + 22, y + 44);
drawText(inventory.getEnergyManager().getEnergyStored() + " RF", x + 22, y + 56);
drawText(tile.getEnergyManager().getEnergyStored() + " RF", x + 22, y + 56);
drawSubheader(Translator.translateToLocal("for.gui.heat") + ':', x + 22, y + 68);
drawText((double) inventory.getHeat() / (double) 10 + 20.0 + " C", x + 22, y + 80);
drawText((double) tile.getHeat() / (double) 10 + 20.0 + " C", x + 22, y + 80);
}
@Override
public String getTooltip() {
return inventory.getCurrentOutput() + " RF/t";
return tile.getCurrentOutput() + " RF/t";
}
}
@Override
protected void addLedgers() {
addErrorLedger(tile);
addHintLedger(tile.getHintKey());
ledgerManager.add(new EngineLedger());
}
}
@@ -28,7 +28,7 @@ public class GuiEngineBiogas extends GuiEngine<ContainerEngineBiogas, TileEngine
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
int temperature = inventory.getOperatingTemperatureScaled(16);
int temperature = tile.getOperatingTemperatureScaled(16);
if (temperature > 16) {
temperature = 16;
}
@@ -24,10 +24,8 @@ public class GuiEnginePeat extends GuiEngine<ContainerEnginePeat, TileEnginePeat
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
TileEnginePeat engine = inventory;
int progress;
if (engine.isBurning()) {
progress = engine.getBurnTimeRemainingScaled(12);
if (tile.isBurning()) {
int progress = tile.getBurnTimeRemainingScaled(12);
this.drawTexturedModalRect(guiLeft + 45, guiTop + 27 + 12 - progress, 176, 12 - progress, 14, progress + 2);
}
}
@@ -38,7 +38,7 @@ public class TileEngineClockwork extends TileEngine {
private short delay = 0;
public TileEngineClockwork() {
super(null, ENGINE_CLOCKWORK_HEAT_MAX, 10000);
super("", ENGINE_CLOCKWORK_HEAT_MAX, 10000);
}
@Override
@@ -20,10 +20,12 @@ import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiBottler extends GuiForestryTitled<ContainerBottler, TileBottler> {
public class GuiBottler extends GuiForestryTitled<ContainerBottler> {
private final TileBottler tile;
public GuiBottler(InventoryPlayer inventory, TileBottler processor) {
super(Constants.TEXTURE_PATH_GUI + "/bottler.png", new ContainerBottler(inventory, processor), processor);
public GuiBottler(InventoryPlayer inventory, TileBottler tile) {
super(Constants.TEXTURE_PATH_GUI + "/bottler.png", new ContainerBottler(inventory, tile), tile);
this.tile = tile;
widgetManager.add(new TankWidget(this.widgetManager, 80, 14, 0));
}
@@ -46,14 +48,14 @@ public class GuiBottler extends GuiForestryTitled<ContainerBottler, TileBottler>
}
GlStateManager.popMatrix();
String name = Translator.translateToLocal(inventory.getUnlocalizedTitle());
String name = Translator.translateToLocal(tile.getUnlocalizedTitle());
textLayout.line = 5;
textLayout.drawCenteredLine(name, 0, ColourProperties.INSTANCE.get("gui.title"));
bindTexture(textureFile);
bindTexture(textureFile);
TileBottler bottler = inventory;
TileBottler bottler = tile;
int progressArrow = bottler.getProgressScaled(22);
if (progressArrow > 0) {
if (bottler.isFillRecipe) {
@@ -63,4 +65,11 @@ public class GuiBottler extends GuiForestryTitled<ContainerBottler, TileBottler>
}
}
}
@Override
protected void addLedgers() {
addErrorLedger(tile);
addHintLedger("bottler");
addPowerLedger(tile.getEnergyManager());
}
}
@@ -16,20 +16,28 @@ import forestry.core.gui.widgets.TankWidget;
import forestry.factory.tiles.TileCarpenter;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiCarpenter extends GuiForestryTitled<ContainerCarpenter, TileCarpenter> {
public class GuiCarpenter extends GuiForestryTitled<ContainerCarpenter> {
private final TileCarpenter tile;
public GuiCarpenter(InventoryPlayer inventory, TileCarpenter tile) {
super(Constants.TEXTURE_PATH_GUI + "/carpenter.png", new ContainerCarpenter(inventory, tile), tile);
this.ySize = 218;
widgetManager.add(new TankWidget(this.widgetManager, 150, 17, 0));
this.tile = tile;
this.ySize = 218;
this.widgetManager.add(new TankWidget(this.widgetManager, 150, 17, 0));
}
@Override
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
int progressScaled = inventory.getProgressScaled(16);
int progressScaled = tile.getProgressScaled(16);
drawTexturedModalRect(guiLeft + 98, guiTop + 51 + 16 - progressScaled, 176, 60 + 16 - progressScaled, 4, progressScaled);
}
@Override
protected void addLedgers() {
addErrorLedger(tile);
addPowerLedger(tile.getEnergyManager());
addHintLedger("carpenter");
}
}
@@ -16,10 +16,12 @@ import forestry.core.gui.widgets.SocketWidget;
import forestry.factory.tiles.TileCentrifuge;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiCentrifuge extends GuiForestryTitled<ContainerCentrifuge, TileCentrifuge> {
public class GuiCentrifuge extends GuiForestryTitled<ContainerCentrifuge> {
private final TileCentrifuge tile;
public GuiCentrifuge(InventoryPlayer inventory, TileCentrifuge tile) {
super(Constants.TEXTURE_PATH_GUI + "/centrifugesocket2.png", new ContainerCentrifuge(inventory, tile), tile);
this.tile = tile;
widgetManager.add(new SocketWidget(this.widgetManager, 79, 37, tile, 0));
}
@@ -27,8 +29,15 @@ public class GuiCentrifuge extends GuiForestryTitled<ContainerCentrifuge, TileCe
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
int progress = inventory.getProgressScaled(16);
int progress = tile.getProgressScaled(16);
drawTexturedModalRect(guiLeft + 43, guiTop + 36 + 17 - progress, 176, 17 - progress, 4, progress);
drawTexturedModalRect(guiLeft + 67, guiTop + 36 + 17 - progress, 176, 17 - progress, 4, progress);
}
@Override
protected void addLedgers() {
addErrorLedger(tile);
addHintLedger("centrifuge");
addPowerLedger(tile.getEnergyManager());
}
}
@@ -16,28 +16,35 @@ import forestry.core.gui.widgets.ReservoirWidget;
import forestry.factory.tiles.TileFabricator;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiFabricator extends GuiForestryTitled<ContainerFabricator, TileFabricator> {
public class GuiFabricator extends GuiForestryTitled<ContainerFabricator> {
private final TileFabricator tile;
public GuiFabricator(InventoryPlayer player, TileFabricator tile) {
super(Constants.TEXTURE_PATH_GUI + "/fabricator.png", new ContainerFabricator(player, tile), tile);
this.tile = tile;
this.ySize = 211;
widgetManager.add(new ReservoirWidget(this.widgetManager, 26, 48, 0));
this.widgetManager.add(new ReservoirWidget(this.widgetManager, 26, 48, 0));
}
@Override
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
TileFabricator fabricator = inventory;
int heatScaled = fabricator.getHeatScaled(52);
int heatScaled = tile.getHeatScaled(52);
if (heatScaled > 0) {
drawTexturedModalRect(guiLeft + 55, guiTop + 17 + 52 - heatScaled, 192, 52 - heatScaled, 4, heatScaled);
}
int meltingPointScaled = fabricator.getMeltingPointScaled(52);
int meltingPointScaled = tile.getMeltingPointScaled(52);
if (meltingPointScaled > 0) {
drawTexturedModalRect(guiLeft + 52, guiTop + 15 + 52 - meltingPointScaled, 196, 0, 10, 5);
}
}
@Override
protected void addLedgers() {
addErrorLedger(tile);
addPowerLedger(tile.getEnergyManager());
addHintLedger("fabricator");
}
}
@@ -16,10 +16,12 @@ import forestry.core.gui.widgets.TankWidget;
import forestry.factory.tiles.TileFermenter;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiFermenter extends GuiForestryTitled<ContainerFermenter, TileFermenter> {
public class GuiFermenter extends GuiForestryTitled<ContainerFermenter> {
private final TileFermenter tile;
public GuiFermenter(InventoryPlayer inventory, TileFermenter tile) {
super(Constants.TEXTURE_PATH_GUI + "/fermenter.png", new ContainerFermenter(inventory, tile), tile);
this.tile = tile;
widgetManager.add(new TankWidget(this.widgetManager, 35, 19, 0));
widgetManager.add(new TankWidget(this.widgetManager, 125, 19, 1));
}
@@ -29,16 +31,22 @@ public class GuiFermenter extends GuiForestryTitled<ContainerFermenter, TileFerm
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
// Fuel remaining
int fuelRemain = inventory.getBurnTimeRemainingScaled(16);
int fuelRemain = tile.getBurnTimeRemainingScaled(16);
if (fuelRemain > 0) {
drawTexturedModalRect(guiLeft + 98, guiTop + 46 + 17 - fuelRemain, 176, 78 + 17 - fuelRemain, 4, fuelRemain);
}
// Raw bio mush remaining
int bioRemain = inventory.getFermentationProgressScaled(16);
int bioRemain = tile.getFermentationProgressScaled(16);
if (bioRemain > 0) {
drawTexturedModalRect(guiLeft + 74, guiTop + 32 + 17 - bioRemain, 176, 60 + 17 - bioRemain, 4, bioRemain);
}
}
@Override
protected void addLedgers() {
addErrorLedger(tile);
addHintLedger("fermenter");
addPowerLedger(tile.getEnergyManager());
}
}
@@ -16,10 +16,12 @@ import forestry.core.gui.widgets.TankWidget;
import forestry.factory.tiles.TileMoistener;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiMoistener extends GuiForestryTitled<ContainerMoistener, TileMoistener> {
public class GuiMoistener extends GuiForestryTitled<ContainerMoistener> {
private final TileMoistener tile;
public GuiMoistener(InventoryPlayer inventory, TileMoistener tile) {
super(Constants.TEXTURE_PATH_GUI + "/moistener.png", new ContainerMoistener(inventory, tile), tile);
this.tile = tile;
widgetManager.add(new TankWidget(this.widgetManager, 16, 16, 0));
}
@@ -28,16 +30,21 @@ public class GuiMoistener extends GuiForestryTitled<ContainerMoistener, TileMois
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
// Mycelium production progress
if (inventory.isProducing()) {
int i1 = inventory.getProductionProgressScaled(16);
if (tile.isProducing()) {
int i1 = tile.getProductionProgressScaled(16);
drawTexturedModalRect(guiLeft + 124, guiTop + 36, 176, 74, 16 - i1, 16);
}
// Resource consumption progress
if (inventory.isWorking()) {
int i1 = inventory.getConsumptionProgressScaled(54);
if (tile.isWorking()) {
int i1 = tile.getConsumptionProgressScaled(54);
drawTexturedModalRect(guiLeft + 93, guiTop + 18 + i1, 176, 92 + i1, 29, 54 - i1);
}
}
@Override
protected void addLedgers() {
addErrorLedger(tile);
addHintLedger("moistener");
}
}
@@ -16,10 +16,12 @@ import forestry.core.gui.widgets.TankWidget;
import forestry.factory.tiles.TileRaintank;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiRaintank extends GuiForestryTitled<ContainerRaintank, TileRaintank> {
public class GuiRaintank extends GuiForestryTitled<ContainerRaintank> {
private final TileRaintank tile;
public GuiRaintank(InventoryPlayer inventory, TileRaintank tile) {
super(Constants.TEXTURE_PATH_GUI + "/raintank.png", new ContainerRaintank(inventory, tile), tile);
this.tile = tile;
widgetManager.add(new TankWidget(this.widgetManager, 53, 17, 0));
}
@@ -27,9 +29,15 @@ public class GuiRaintank extends GuiForestryTitled<ContainerRaintank, TileRainta
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
if (inventory.isFilling()) {
int progress = inventory.getFillProgressScaled(24);
if (tile.isFilling()) {
int progress = tile.getFillProgressScaled(24);
drawTexturedModalRect(guiLeft + 80, guiTop + 39, 176, 74, progress, 16);
}
}
@Override
protected void addLedgers() {
addErrorLedger(tile);
addHintLedger("raintank");
}
}
@@ -17,20 +17,28 @@ import forestry.core.gui.widgets.TankWidget;
import forestry.factory.tiles.TileSqueezer;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiSqueezer extends GuiForestryTitled<ContainerSqueezer, TileSqueezer> {
public class GuiSqueezer extends GuiForestryTitled<ContainerSqueezer> {
private final TileSqueezer tile;
public GuiSqueezer(InventoryPlayer inventory, TileSqueezer tile) {
super(Constants.TEXTURE_PATH_GUI + "/squeezersocket.png", new ContainerSqueezer(inventory, tile), tile);
this.tile = tile;
widgetManager.add(new TankWidget(this.widgetManager, 122, 18, 0));
widgetManager.add(new SocketWidget(this.widgetManager, 75, 20, tile, 0));
}
@Override
protected void drawWidgets() {
int progress = inventory.getProgressScaled(43);
int progress = tile.getProgressScaled(43);
drawTexturedModalRect(75, 41, 176, 60, progress, 18);
super.drawWidgets();
}
@Override
protected void addLedgers() {
addErrorLedger(tile);
addPowerLedger(tile.getEnergyManager());
addHintLedger("squeezer");
}
}
@@ -16,10 +16,12 @@ import forestry.core.gui.widgets.TankWidget;
import forestry.factory.tiles.TileStill;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiStill extends GuiForestryTitled<ContainerStill, TileStill> {
public class GuiStill extends GuiForestryTitled<ContainerStill> {
private final TileStill tile;
public GuiStill(InventoryPlayer inventory, TileStill tile) {
super(Constants.TEXTURE_PATH_GUI + "/still.png", new ContainerStill(inventory, tile), tile);
this.tile = tile;
widgetManager.add(new TankWidget(this.widgetManager, 35, 15, 0));
widgetManager.add(new TankWidget(this.widgetManager, 125, 15, 1));
}
@@ -27,14 +29,19 @@ public class GuiStill extends GuiForestryTitled<ContainerStill, TileStill> {
@Override
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
TileStill still = inventory;
drawTexturedModalRect(guiLeft + 81, guiTop + 57, 176, 60, 14, 14);
if (still.getWorkCounter() > 0) {
int massRemaining = still.getProgressScaled(16);
if (tile.getWorkCounter() > 0) {
int massRemaining = tile.getProgressScaled(16);
drawTexturedModalRect(guiLeft + 84, guiTop + 17 + massRemaining, 176, 74 + massRemaining, 4, 17 - massRemaining);
}
}
@Override
protected void addLedgers() {
addErrorLedger(tile);
addHintLedger("still");
addPowerLedger(tile.getEnergyManager());
}
}
@@ -23,14 +23,17 @@ import forestry.factory.tiles.TileWorktable;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.EntityPlayer;
public class GuiWorktable extends GuiForestryTitled<ContainerWorktable, TileWorktable> {
public class GuiWorktable extends GuiForestryTitled<ContainerWorktable> {
private static final int SPACING = 18;
private final TileWorktable tile;
private boolean hasRecipeConflict = false;
public GuiWorktable(EntityPlayer player, TileWorktable tile) {
super(Constants.TEXTURE_PATH_GUI + "/worktable2.png", new ContainerWorktable(player, tile), tile);
this.tile = tile;
ySize = 218;
this.ySize = 218;
RecipeMemory recipeMemory = tile.getMemory();
@@ -51,8 +54,8 @@ public class GuiWorktable extends GuiForestryTitled<ContainerWorktable, TileWork
public void updateScreen() {
super.updateScreen();
if (hasRecipeConflict != inventory.hasRecipeConflict()) {
hasRecipeConflict = inventory.hasRecipeConflict();
if (hasRecipeConflict != tile.hasRecipeConflict()) {
hasRecipeConflict = tile.hasRecipeConflict();
if (hasRecipeConflict) {
addButtons();
} else {
@@ -72,4 +75,10 @@ public class GuiWorktable extends GuiForestryTitled<ContainerWorktable, TileWork
Proxies.net.sendToServer(new PacketGuiSelectRequest(id, 0));
Proxies.common.playButtonClick();
}
@Override
protected void addLedgers() {
addErrorLedger(tile);
addHintLedger("worktable");
}
}
@@ -4,6 +4,7 @@ import javax.annotation.Nullable;
import java.awt.Rectangle;
import java.util.List;
import com.google.common.base.Preconditions;
import forestry.core.gui.GuiForestry;
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
import forestry.core.utils.JeiUtil;
@@ -116,6 +117,7 @@ public class FactoryJeiPlugin extends BlankModPlugin {
registry.addRecipeClickArea(GuiStill.class, 73, 17, 33, 57, ForestryRecipeCategoryUid.STILL);
BlockRegistryFactory blocks = PluginFactory.blocks;
Preconditions.checkNotNull(blocks);
registry.addRecipeCategoryCraftingItem(new ItemStack(blocks.bottler), ForestryRecipeCategoryUid.BOTTLER);
registry.addRecipeCategoryCraftingItem(new ItemStack(blocks.carpenter), ForestryRecipeCategoryUid.CARPENTER);
@@ -151,7 +153,7 @@ public class FactoryJeiPlugin extends BlankModPlugin {
@Nullable
@Override
public List<Rectangle> getGuiExtraAreas(GuiForestry guiContainer) {
return ((GuiForestry<?, ?>) guiContainer).getExtraGuiAreas();
return ((GuiForestry<?>) guiContainer).getExtraGuiAreas();
}
@Nullable
@@ -63,7 +63,7 @@ public class TileBottler extends TilePowered implements ISidedInventory, ILiquid
public boolean isFillRecipe;
public TileBottler() {
super("bottler", 1100, 4000);
super(1100, 4000);
setInternalInventory(new InventoryBottler(this));
@@ -63,7 +63,7 @@ public class TileCarpenter extends TilePowered implements ISidedInventory, ILiqu
}
public TileCarpenter() {
super("carpenter", 1100, 4000);
super(1100, 4000);
setEnergyPerWorkCycle(ENERGY_PER_WORK_CYCLE);
resourceTank = new FilteredTank(Constants.PROCESSOR_TANK_CAPACITY).setFilters(CarpenterRecipeManager.getRecipeFluids());
@@ -55,7 +55,7 @@ public class TileCentrifuge extends TilePowered implements ISocketable, ISidedIn
private final Stack<ItemStack> pendingProducts = new Stack<>();
public TileCentrifuge() {
super("centrifuge", 800, Constants.MACHINE_MAX_ENERGY);
super(800, Constants.MACHINE_MAX_ENERGY);
setInternalInventory(new InventoryCentrifuge(this));
craftPreviewInventory = new InventoryCraftResult();
}
@@ -61,7 +61,7 @@ public class TileFabricator extends TilePowered implements ISlotPickupWatcher, I
private int meltingPoint = 0;
public TileFabricator() {
super("fabricator", 1100, 3300);
super(1100, 3300);
setEnergyPerWorkCycle(200);
craftingInventory = new InventoryGhostCrafting<>(this, InventoryGhostCrafting.SLOT_CRAFTING_COUNT);
setInternalInventory(new InventoryFabricator(this));
@@ -58,7 +58,7 @@ public class TileFermenter extends TilePowered implements ISidedInventory, ILiqu
private int fuelCurrentFerment = 0;
public TileFermenter() {
super("fermenter", 2000, 8000);
super(2000, 8000);
setEnergyPerWorkCycle(4200);
setInternalInventory(new InventoryFermenter(this));
@@ -28,7 +28,6 @@ public class TileMillRainmaker extends TileMill {
private boolean reverse;
public TileMillRainmaker() {
super(null);
speed = 0.01f;
setInternalInventory(new InventoryRainmaker(this));
}
@@ -62,7 +62,6 @@ public class TileMoistener extends TileBase implements ISidedInventory, ILiquidT
private ItemStack pendingProduct;
public TileMoistener() {
super("moistener");
setInternalInventory(new InventoryMoistener(this));
resourceTank = new FilteredTank(Constants.PROCESSOR_TANK_CAPACITY).setFilters(FluidRegistry.WATER);
tankManager = new TankManager(this, resourceTank);
@@ -60,7 +60,6 @@ public class TileRaintank extends TileBase implements ISidedInventory, ILiquidTa
private int fillingProgress;
public TileRaintank() {
super("raintank");
setInternalInventory(new InventoryRaintank(this));
resourceTank = new FilteredTank(Constants.RAINTANK_TANK_CAPACITY).setFilters(FluidRegistry.WATER);
@@ -59,7 +59,7 @@ public class TileSqueezer extends TilePowered implements ISocketable, ISidedInve
private ISqueezerRecipe currentRecipe;
public TileSqueezer() {
super("squeezer", 1100, Constants.MACHINE_MAX_ENERGY);
super(1100, Constants.MACHINE_MAX_ENERGY);
this.inventory = new InventorySqueezer(this);
setInternalInventory(this.inventory);
this.productTank = new StandardTank(Constants.PROCESSOR_TANK_CAPACITY, false, true);
@@ -50,7 +50,7 @@ public class TileStill extends TilePowered implements ISidedInventory, ILiquidTa
private FluidStack bufferedLiquid;
public TileStill() {
super("still", 1100, 8000);
super(1100, 8000);
setInternalInventory(new InventoryStill(this));
resourceTank = new FilteredTank(Constants.PROCESSOR_TANK_CAPACITY, true, false);
resourceTank.setFilters(StillRecipeManager.recipeFluidInputs);
@@ -45,7 +45,6 @@ public class TileWorktable extends TileBase implements ICrafterWorktable {
private MemorizedRecipe currentRecipe;
public TileWorktable() {
super("worktable");
setInternalInventory(new InventoryWorktable(this));
craftingDisplay = new InventoryGhostCrafting<>(this, 10);
@@ -13,23 +13,24 @@ package forestry.farming.gui;
import forestry.api.farming.FarmDirection;
import forestry.core.config.Constants;
import forestry.core.gui.GuiForestryTitled;
import forestry.core.gui.ledgers.ClimateLedger;
import forestry.core.gui.widgets.SocketWidget;
import forestry.core.gui.widgets.TankWidget;
import forestry.farming.multiblock.IFarmControllerInternal;
import forestry.farming.tiles.TileFarm;
import net.minecraft.entity.player.EntityPlayer;
public class GuiFarm extends GuiForestryTitled<ContainerFarm, TileFarm> {
public class GuiFarm extends GuiForestryTitled<ContainerFarm> {
private final TileFarm tile;
public GuiFarm(EntityPlayer player, TileFarm tile) {
super(Constants.TEXTURE_PATH_GUI + "/mfarm.png", new ContainerFarm(player.inventory, tile), tile);
this.tile = tile;
widgetManager.add(new TankWidget(widgetManager, 15, 19, 0).setOverlayOrigin(216, 18));
widgetManager.add(new SocketWidget(widgetManager, 69, 40, tile, 0));
IFarmControllerInternal farmController = inventory.getMultiblockLogic().getController();
IFarmControllerInternal farmController = tile.getMultiblockLogic().getController();
widgetManager.add(new FarmLogicSlot(farmController, widgetManager, 69, 22, FarmDirection.NORTH));
widgetManager.add(new FarmLogicSlot(farmController, widgetManager, 69, 58, FarmDirection.SOUTH));
@@ -42,10 +43,12 @@ public class GuiFarm extends GuiForestryTitled<ContainerFarm, TileFarm> {
@Override
protected void addLedgers() {
IFarmControllerInternal farmController = inventory.getMultiblockLogic().getController();
ledgerManager.add(new ClimateLedger(ledgerManager, farmController));
IFarmControllerInternal farmController = tile.getMultiblockLogic().getController();
addErrorLedger(farmController);
addClimateLedger(farmController);
ledgerManager.add(new FarmLedger(ledgerManager, farmController.getFarmLedgerDelegate()));
super.addLedgers();
addHintLedger("farm");
}
@Override
@@ -53,7 +56,7 @@ public class GuiFarm extends GuiForestryTitled<ContainerFarm, TileFarm> {
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
// Fuel remaining
int fertilizerRemain = inventory.getMultiblockLogic().getController().getStoredFertilizerScaled(16);
int fertilizerRemain = tile.getMultiblockLogic().getController().getStoredFertilizerScaled(16);
if (fertilizerRemain > 0) {
drawTexturedModalRect(guiLeft + 81, guiTop + 94 + 17 - fertilizerRemain, xSize, 17 - fertilizerRemain, 4, fertilizerRemain);
}
@@ -11,7 +11,6 @@
package forestry.farming.tiles;
import java.io.IOException;
import java.util.List;
import forestry.api.circuits.ICircuitSocketType;
import forestry.api.core.IErrorLogic;
@@ -19,8 +18,6 @@ import forestry.api.core.IErrorLogicSource;
import forestry.api.multiblock.IFarmComponent;
import forestry.api.multiblock.IMultiblockController;
import forestry.core.circuits.ISocketable;
import forestry.core.config.Config;
import forestry.core.gui.IHintSource;
import forestry.core.inventory.IInventoryAdapter;
import forestry.core.multiblock.MultiblockTileEntityForestry;
import forestry.core.network.IStreamableGui;
@@ -40,7 +37,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public abstract class TileFarm extends MultiblockTileEntityForestry<MultiblockLogicFarm> implements IFarmComponent, IHintSource, ISocketable, IStreamableGui, IErrorLogicSource, IOwnedTile, ITitled {
public abstract class TileFarm extends MultiblockTileEntityForestry<MultiblockLogicFarm> implements IFarmComponent, ISocketable, IStreamableGui, IErrorLogicSource, IOwnedTile, ITitled {
private EnumFarmBlockTexture farmBlockTexture = EnumFarmBlockTexture.BRICK_STONE;
protected TileFarm() {
@@ -115,12 +112,6 @@ public abstract class TileFarm extends MultiblockTileEntityForestry<MultiblockLo
setFarmBlockTexture(farmBlockTexture);
}
/* IHintSource */
@Override
public List<String> getHints() {
return Config.hints.get("farm");
}
/* ISocketable */
@Override
public int getSocketCount() {
@@ -17,24 +17,25 @@ import forestry.core.render.ColourProperties;
import forestry.food.inventory.ItemInventoryInfuser;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiInfuser extends GuiForestry<ContainerInfuser, ItemInventoryInfuser> {
public class GuiInfuser extends GuiForestry<ContainerInfuser> {
private final ItemInventoryInfuser itemInventory;
private int startX;
private int startY;
public GuiInfuser(InventoryPlayer inventoryplayer, ItemInventoryInfuser inventory) {
super(Constants.TEXTURE_PATH_GUI + "/infuser.png", new ContainerInfuser(inventoryplayer, inventory), inventory);
public GuiInfuser(InventoryPlayer inventoryplayer, ItemInventoryInfuser itemInventory) {
super(Constants.TEXTURE_PATH_GUI + "/infuser.png", new ContainerInfuser(inventoryplayer, itemInventory));
xSize = 176;
ySize = 185;
this.itemInventory = itemInventory;
this.xSize = 176;
this.ySize = 185;
}
@Override
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
for (int l = 2; l < inventory.getSizeInventory(); l++) {
String description = BeverageManager.ingredientManager.getDescription(inventory.getStackInSlot(l));
for (int l = 2; l < itemInventory.getSizeInventory(); l++) {
String description = BeverageManager.ingredientManager.getDescription(itemInventory.getStackInSlot(l));
if (description == null) {
description = "(No effect)";
}
@@ -51,4 +52,9 @@ public class GuiInfuser extends GuiForestry<ContainerInfuser, ItemInventoryInfus
startX = (this.width - this.xSize) / 2;
startY = (this.height - this.ySize) / 2;
}
@Override
protected void addLedgers() {
}
}
Loaded 100 of 124 files, more files were not shown because too many files have changed in this diff. Show more