Updates for 1.11. Running but missing textures.

This commit is contained in:
mezz committed 2017-02-09 01:41:06 -08:00
1 parent 424fdaaf48
commit f660f213f6
185 files changed
+959 -783

No files matched your search

+7 -5
View File
@@ -164,7 +164,7 @@ public class Botany extends AbstractMod {
EntityPlayer player = event.getEntityPlayer();
if (player != null) {
ItemStack heldItem = player.getHeldItemMainhand();
if (heldItem != null) {
if (!heldItem.isEmpty()) {
TileEntity tile = event.getWorld().getTileEntity(event.getPos());
if (tile instanceof TileEntityFlower) {
TileEntityFlower flower = (TileEntityFlower) tile;
@@ -195,7 +195,7 @@ public class Botany extends AbstractMod {
EntityPlayer player = event.getEntityPlayer();
if (player != null) {
ItemStack heldItem = player.getHeldItemMainhand();
if (heldItem != null) {
if (!heldItem.isEmpty()) {
Block block = world.getBlockState(event.getPos()).getBlock();
if (!Gardening.isSoil(block)) {
pos = pos.down();
@@ -245,9 +245,11 @@ public class Botany extends AbstractMod {
if (!Gardening.isSoil(block)) {
return;
}
IFlower flower = BotanyCore.getFlowerRoot().getConversion(event.getItemInHand());
EntityPlayer player = event.getPlayer();
ItemStack heldItem = player.getHeldItem(event.getHand());
IFlower flower = BotanyCore.getFlowerRoot().getConversion(heldItem);
if (flower != null) {
Gardening.plant(world, pos, flower, event.getPlayer().getGameProfile());
Gardening.plant(world, pos, flower, player.getGameProfile());
}
}
@@ -261,7 +263,7 @@ public class Botany extends AbstractMod {
return;
}
if (heldItem != null) {
if (!heldItem.isEmpty()) {
Block block = world.getBlockState(pos).getBlock();
int py = -1;
if (block instanceof IBlockSoil && (world.isAirBlock(pos.up()) || block.isReplaceable(world, pos))) {
@@ -9,6 +9,8 @@ import forestry.api.genetics.IAlleleTolerance;
import forestry.api.genetics.IChromosomeType;
import forestry.api.genetics.ISpeciesRoot;
import java.util.Locale;
public enum EnumFlowerChromosome implements IChromosomeType {
SPECIES(IAlleleFlowerSpecies.class),
PRIMARY(IAlleleInteger.class),
@@ -36,7 +38,7 @@ public enum EnumFlowerChromosome implements IChromosomeType {
@Override
public String getName() {
return this.toString().toLowerCase();
return this.toString().toLowerCase(Locale.ENGLISH);
}
@Override
@@ -4,10 +4,13 @@ import forestry.api.genetics.IIndividual;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nullable;
public interface IFlower extends IIndividual {
@Override
IFlowerGenome getGenome();
@Nullable
IFlowerGenome getMate();
void mate(final IFlower flower);
@@ -168,7 +168,6 @@ public class BlockStainedGlass extends Block implements IBlockMetadata, IColored
}
@Override
@Nullable
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
return BlockMetadata.getPickBlock(world, pos);
}
@@ -14,6 +14,8 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
import java.util.HashMap;
@@ -56,6 +58,7 @@ public class CeramicDesignSystem implements IDesignSystem {
@Override
@Nullable
@SideOnly(Side.CLIENT)
public TextureAtlasSprite getPrimarySprite(IPattern pattern) {
if (pattern instanceof EnumPattern) {
return this.primary.get(((EnumPattern) pattern).ordinal());
@@ -65,6 +68,7 @@ public class CeramicDesignSystem implements IDesignSystem {
@Override
@Nullable
@SideOnly(Side.CLIENT)
public TextureAtlasSprite getSecondarySprite(IPattern pattern) {
if (pattern instanceof EnumPattern) {
return this.secondary.get(((EnumPattern) pattern).ordinal());
@@ -73,6 +77,7 @@ public class CeramicDesignSystem implements IDesignSystem {
}
@Override
@SideOnly(Side.CLIENT)
public void registerSprites() {
for (EnumPattern pattern : EnumPattern.values()) {
this.primary.put(pattern.ordinal(), TextureManager.registerSprite(new ResourceLocation(getMod().getModID(), getTexturePath() + "/" + pattern.toString().toLowerCase() + ".0")));
@@ -51,7 +51,7 @@ public class CeramicTileRecipe implements IRecipe {
}
for (CeramicBrickType type : CeramicBrickType.VALUES) {
ItemStack result = type.getRecipe(stacks);
if (result != null) {
if (!result.isEmpty()) {
return result;
}
}
@@ -28,8 +28,7 @@ public class CeramicBrickPair {
}
public ItemStack getStack(int i) {
ItemStack s = new ItemStack(Botany.ceramicBrick, i, this.ordinal());
return s;
return new ItemStack(Botany.ceramicBrick, i, this.ordinal());
}
public CeramicBrickPair(int id) {
@@ -16,11 +16,10 @@ import javax.annotation.Nullable;
public enum CeramicBrickType implements IStringSerializable {
Tile("tile", "Ceramic Tile"){
@Nullable
@Override
public ItemStack getRecipe(List<ItemStack> stacks) {
if (stacks.size() != 4) {
return null;
return ItemStack.EMPTY;
}
int mortars = 0;
int blocks = 0;
@@ -30,7 +29,7 @@ public enum CeramicBrickType implements IStringSerializable {
++mortars;
} else {
if (stack.getItem() != Item.getItemFromBlock(Botany.ceramic)) {
return null;
return ItemStack.EMPTY;
}
++blocks;
final int color = TileEntityMetadata.getItemDamage(stack);
@@ -38,35 +37,31 @@ public enum CeramicBrickType implements IStringSerializable {
blockColor = color;
} else {
if (blockColor != color) {
return null;
return ItemStack.EMPTY;
}
continue;
}
}
}
if (mortars != 1) {
return null;
return ItemStack.EMPTY;
}
final EnumFlowerColor c = EnumFlowerColor.get(blockColor);
return new CeramicBrickPair(c, c, CeramicBrickType.Tile).getStack(3);
}
},
Brick("brick", "Ceramic Bricks"){
@Nullable
@Override
public ItemStack getRecipe(List<ItemStack> stacks) {
return getBrickRecipe(this, stacks);
}
},
StripeBrick("brickstripe", "Striped Ceramic Bricks"){
@Nullable
@Override
public ItemStack getRecipe(List<ItemStack> stacks) {
return getBrickRecipe(this, stacks);
}
},
LargeBrick("bricklarge", "Large Ceramic Bricks"){
@Nullable
@Override
public ItemStack getRecipe(List<ItemStack> stacks) {
if (stacks.size() == 1) {
@@ -76,21 +71,21 @@ public enum CeramicBrickType implements IStringSerializable {
type3.type = this;
return type3.getStack(1);
}
return null;
return ItemStack.EMPTY;
} else {
if (stacks.size() != 3) {
return null;
return ItemStack.EMPTY;
}
final int[] colors = {-1, -1};
int a = 0;
int b = 0;
for (final ItemStack stack4 : stacks) {
if (stack4.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) {
return null;
return ItemStack.EMPTY;
}
final CeramicBrickPair type4 = new CeramicBrickPair(stack4);
if (type4.type != CeramicBrickType.Tile) {
return null;
return ItemStack.EMPTY;
}
final int color5 = type4.colorFirst.ordinal();
if (colors[0] == -1) {
@@ -103,7 +98,7 @@ public enum CeramicBrickType implements IStringSerializable {
++b;
} else {
if (colors[1] != color5) {
return null;
return ItemStack.EMPTY;
}
++b;
}
@@ -116,28 +111,27 @@ public enum CeramicBrickType implements IStringSerializable {
}
},
Split("split", "Split Ceramic Tile"){
@Nullable
@Override
public ItemStack getRecipe(List<ItemStack> stacks) {
if (stacks.size() != 4) {
return null;
return ItemStack.EMPTY;
}
final int[] colors = {-1, -1};
int altCounter = 0;
for (final ItemStack stack2 : stacks) {
final int alt = (altCounter != 0 && altCounter != 3) ? 1 : 0;
if (stack2.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) {
return null;
return ItemStack.EMPTY;
}
final CeramicBrickPair type = new CeramicBrickPair(stack2);
if (type.type != CeramicBrickType.Tile) {
return null;
return ItemStack.EMPTY;
}
final int color2 = type.colorFirst.ordinal();
if (colors[alt] == -1) {
colors[alt] = color2;
} else if (colors[alt] != color2) {
return null;
return ItemStack.EMPTY;
}
++altCounter;
}
@@ -145,20 +139,19 @@ public enum CeramicBrickType implements IStringSerializable {
}
},
Chequered("cheque", "Chequered Ceramic Tile"){
@Nullable
@Override
public ItemStack getRecipe(List<ItemStack> stacks) {
if (stacks.size() != 4) {
return null;
return ItemStack.EMPTY;
}
final int[] colors = {-1, -1};
for (final ItemStack stack2 : stacks) {
if (stack2.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) {
return null;
return ItemStack.EMPTY;
}
final CeramicBrickPair type2 = new CeramicBrickPair(stack2);
if (type2.type != CeramicBrickType.Split) {
return null;
return ItemStack.EMPTY;
}
final int color3 = type2.colorFirst.ordinal();
final int color4 = type2.colorSecond.ordinal();
@@ -167,70 +160,65 @@ public enum CeramicBrickType implements IStringSerializable {
colors[1] = color4;
} else {
if (colors[0] != color3 || colors[1] != color4) {
return null;
return ItemStack.EMPTY;
}
continue;
}
}
return new CeramicBrickPair(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), CeramicBrickType.Chequered).getStack(4);
}
},
Mixed("mixed", "Mixed Ceramic Tile"){
@Nullable
@Override
public ItemStack getRecipe(List<ItemStack> stacks) {
if (stacks.size() != 4) {
return null;
return ItemStack.EMPTY;
}
final int[] colors = {-1, -1};
for (final ItemStack stack2 : stacks) {
if (stack2.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) {
return null;
return ItemStack.EMPTY;
}
final CeramicBrickPair type2 = new CeramicBrickPair(stack2);
if (type2.isTwoColors()) {
return null;
return ItemStack.EMPTY;
}
final int color3 = type2.colorFirst.ordinal();
if (type2.type == CeramicBrickType.Split) {
if (colors[1] != -1) {
return null;
return ItemStack.EMPTY;
}
colors[1] = color3;
} else {
if (type2.type != CeramicBrickType.Chequered) {
return null;
return ItemStack.EMPTY;
}
if (colors[0] == -1) {
colors[0] = color3;
} else if (colors[0] != color3) {
return null;
return ItemStack.EMPTY;
}
}
final int color4 = type2.colorSecond.ordinal();
}
if (colors[0] == -1 || colors[1] == -1) {
return null;
return ItemStack.EMPTY;
}
return new CeramicBrickPair(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), CeramicBrickType.Mixed).getStack(4);
}
},
VerticalBrick("verticalbrick", "Vertical Ceramic Bricks"){
@Nullable
@Override
public ItemStack getRecipe(List<ItemStack> stacks) {
return getVerticalBrickRecipe(stacks);
}
},
VerticalStripeBrick("verticalbrickstripe", "Vertical Striped Ceramic Bricks"){
@Nullable
@Override
public ItemStack getRecipe(List<ItemStack> stacks) {
return getVerticalBrickRecipe(stacks);
}
},
VerticalLargeBrick("verticalbricklarge", "Large Vertical Ceramic Bricks"){
@Nullable
@Override
public ItemStack getRecipe(List<ItemStack> stacks) {
return getVerticalBrickRecipe(stacks);
@@ -257,13 +245,11 @@ public enum CeramicBrickType implements IStringSerializable {
return this != CeramicBrickType.Tile;
}
@Nullable
public abstract ItemStack getRecipe(List<ItemStack> stacks);
@Nullable
protected ItemStack getVerticalBrickRecipe(List<ItemStack> stacks){
if (stacks.size() != 1) {
return null;
return ItemStack.EMPTY;
}
final ItemStack stack5 = stacks.get(0);
final CeramicBrickPair type = new CeramicBrickPair(stack5);
@@ -279,10 +265,9 @@ public enum CeramicBrickType implements IStringSerializable {
type.type = CeramicBrickType.VerticalStripeBrick;
return type.getStack(1);
}
return null;
return ItemStack.EMPTY;
}
@Nullable
protected ItemStack getBrickRecipe(CeramicBrickType ceramicType, List<ItemStack> stacks){
if (stacks.size() == 1) {
final ItemStack stack5 = stacks.get(0);
@@ -295,20 +280,17 @@ public enum CeramicBrickType implements IStringSerializable {
type.type = ceramicType;
return type.getStack(1);
}
return null;
} else {
if (stacks.size() != 4) {
return null;
}
return ItemStack.EMPTY;
} else if (stacks.size() == 4) {
final int[] colors = {-1, -1};
for (int index2 = 0; index2 < stacks.size(); ++index2) {
final ItemStack stack4 = stacks.get(index2);
if (stack4.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) {
return null;
return ItemStack.EMPTY;
}
final CeramicBrickPair type4 = new CeramicBrickPair(stack4);
if (type4.type != CeramicBrickType.LargeBrick) {
return null;
return ItemStack.EMPTY;
}
final int color5 = type4.colorFirst.ordinal();
final int color6 = type4.colorSecond.ordinal();
@@ -320,10 +302,12 @@ public enum CeramicBrickType implements IStringSerializable {
colors[alt2] = color5;
colors[1 - alt2] = color6;
} else if (colors[alt2] != color5 || colors[1 - alt2] != color6) {
return null;
return ItemStack.EMPTY;
}
}
return new CeramicBrickPair(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), ceramicType).getStack(4);
} else {
return ItemStack.EMPTY;
}
}
@@ -5,6 +5,8 @@ import binnie.core.resource.BinnieResource;
import binnie.core.resource.IBinnieTexture;
import binnie.core.resource.ResourceType;
import binnie.extrabees.ExtraBees;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public enum BotanyTexture implements IBinnieTexture {
;
@@ -17,6 +19,7 @@ public enum BotanyTexture implements IBinnieTexture {
}
@Override
@SideOnly(Side.CLIENT)
public BinnieResource getTexture() {
return Binnie.RESOURCE.getPNG(ExtraBees.instance, this.type, this.texture);
}
@@ -4,7 +4,9 @@ import binnie.Binnie;
import binnie.botany.api.EnumAcidity;
import binnie.botany.api.EnumMoisture;
import binnie.core.circuits.BinnieCircuit;
import com.google.common.base.Preconditions;
import forestry.api.circuits.ChipsetManager;
import forestry.api.circuits.ICircuitLayout;
import forestry.api.farming.FarmDirection;
import forestry.api.farming.IFarmHousing;
import net.minecraft.item.ItemStack;
@@ -17,7 +19,7 @@ public class CircuitGarden extends BinnieCircuit {
private GardenLogic logic;
public CircuitGarden(EnumMoisture moisture, @Nullable EnumAcidity ph, boolean manual, boolean fertilised, ItemStack recipe, ItemStack icon) {
super(getName(moisture, ph, manual, fertilised), 4, manual ? ChipsetManager.circuitRegistry.getLayout("forestry.farms.manual") : ChipsetManager.circuitRegistry.getLayout("forestry.farms.managed"), recipe);
super(getName(moisture, ph, manual, fertilised), 4, getLayout(manual), recipe);
this.isManual = manual;
this.logic = new GardenLogic(moisture, ph, this.isManual, fertilised, icon, Binnie.LANGUAGE.localise(this.getUnlocalizedName()));
StringBuilder info = new StringBuilder("Flowers (")
@@ -41,6 +43,13 @@ public class CircuitGarden extends BinnieCircuit {
this.addTooltipString(info.toString());
}
private static ICircuitLayout getLayout(boolean manual) {
String layoutUid = manual ? "forestry.farms.manual" : "forestry.farms.managed";
ICircuitLayout layout = ChipsetManager.circuitRegistry.getLayout(layoutUid);
Preconditions.checkState(layout != null, "Couldn't find Forestry circuit layout %s.", layoutUid);
return layout;
}
private static String getName(EnumMoisture moisture, @Nullable EnumAcidity ph, boolean manual, boolean fertilised) {
String name = "garden." + moisture.getName();
if (ph != null) {
@@ -109,7 +109,7 @@ public class GardenLogic extends FarmLogic {
EnumAcidity pH = soil.getPH(world, position);
if (pH.ordinal() < this.acidity.ordinal()) {
ItemStack stack = this.getAvailableAlkaline(housing);
if (stack != null && soil.setPH(world, position, EnumAcidity.values()[pH.ordinal() + 1])) {
if (!stack.isEmpty() && soil.setPH(world, position, EnumAcidity.values()[pH.ordinal() + 1])) {
NonNullList<ItemStack> resources = NonNullList.create();
resources.add(stack);
housing.getFarmInventory().removeResources(resources);
@@ -118,7 +118,7 @@ public class GardenLogic extends FarmLogic {
}
if (pH.ordinal() > this.acidity.ordinal()) {
final ItemStack stack = this.getAvailableAcid(housing);
if (stack != null && soil.setPH(world, position, EnumAcidity.values()[pH.ordinal() - 1])) {
if (!stack.isEmpty() && soil.setPH(world, position, EnumAcidity.values()[pH.ordinal() - 1])) {
NonNullList<ItemStack> resources = NonNullList.create();
resources.add(stack);
housing.getFarmInventory().removeResources(resources);
@@ -129,7 +129,7 @@ public class GardenLogic extends FarmLogic {
if (!this.isAirBlock(world, position) && !BlockUtil.isReplaceableBlock(getBlockState(world, position), world, position)) {
ItemStack block = this.getAsItemStack(world, position);
ItemStack loam = this.getAvailableLoam(housing);
if (this.isWaste(block) && loam != null) {
if (this.isWaste(block) && !loam.isEmpty()) {
this.produce.addAll(Blocks.DIRT.getDrops(world, position, Block.getBlockFromItem(block.getItem()).getStateFromMeta(block.getItemDamage()), 0));
this.setBlock(world, position, Blocks.AIR, 0);
return trySetSoil(world, position, loam, housing);
@@ -184,7 +184,6 @@ public class GardenLogic extends FarmLogic {
return false;
}
@Nullable
private ItemStack getAvailableLoam(IFarmHousing housing) {
EnumMoisture[] moistures;
if (this.moisture == EnumMoisture.Damp) {
@@ -214,16 +213,16 @@ public class GardenLogic extends FarmLogic {
if (housing.getFarmInventory().hasResources(resources)) {
return new ItemStack(Blocks.DIRT);
}
return null;
return ItemStack.EMPTY;
}
private boolean trySetSoil(World world, BlockPos position, IFarmHousing housing) {
return this.trySetSoil(world, position, this.getAvailableLoam(housing), housing);
}
private boolean trySetSoil(World world, BlockPos position, @Nullable ItemStack loam, IFarmHousing housing) {
private boolean trySetSoil(World world, BlockPos position, ItemStack loam, IFarmHousing housing) {
ItemStack copy = loam;
if (loam != null) {
if (!loam.isEmpty()) {
if (loam.getItem() == Item.getItemFromBlock(Blocks.DIRT)) {
loam = new ItemStack(Botany.soil, 0, 4);
}
@@ -326,7 +325,6 @@ public class GardenLogic extends FarmLogic {
return false;
}
@Nullable
public ItemStack getAvailableAcid(IFarmHousing housing) {
for (final ItemStack stack : Gardening.getAcidFertilisers()) {
if (!stack.isEmpty()) {
@@ -337,10 +335,9 @@ public class GardenLogic extends FarmLogic {
}
}
}
return null;
return ItemStack.EMPTY;
}
@Nullable
public ItemStack getAvailableAlkaline(IFarmHousing housing) {
for (final ItemStack stack : Gardening.getAlkalineFertilisers()) {
if (!stack.isEmpty()) {
@@ -351,7 +348,7 @@ public class GardenLogic extends FarmLogic {
}
}
}
return null;
return ItemStack.EMPTY;
}
}
@@ -27,6 +27,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
@@ -35,6 +36,7 @@ import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
@@ -246,12 +248,12 @@ public class BlockFlower extends BlockContainer implements IColoredBlock, IState
}
@Override
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
ArrayList<ItemStack> drops = new ArrayList<>();
public NonNullList<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
NonNullList<ItemStack> drops = NonNullList.create();
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityFlower && ((TileEntityFlower) tile).getSection() == 0) {
ItemStack flower = ((TileEntityFlower) tile).getItemStack();
if (flower != null) {
if (!flower.isEmpty()) {
drops.add(flower);
}
}
@@ -325,12 +325,12 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
}
}
@Nullable
public ItemStack getItemStack() {
if (this.flower == null) {
return null;
IFlower flower = this.getFlower();
if (flower == null) {
return ItemStack.EMPTY;
}
return Binnie.GENETICS.getFlowerRoot().getMemberStack(this.getFlower(), EnumFlowerStage.getStage(getFlower()));
return Binnie.GENETICS.getFlowerRoot().getMemberStack(flower, EnumFlowerStage.getStage(flower));
}
@Nullable
@@ -153,7 +153,7 @@ public class Gardening {
public static boolean isAcidFertiliser(final ItemStack itemstack) {
for (final ItemStack stack : getAcidFertilisers()) {
if (stack != null && stack.isItemEqual(itemstack)) {
if (!stack.isEmpty() && stack.isItemEqual(itemstack)) {
return true;
}
}
@@ -162,7 +162,7 @@ public class Gardening {
public static boolean isAlkalineFertiliser(final ItemStack itemstack) {
for (final ItemStack stack : getAlkalineFertilisers()) {
if (stack != null && stack.isItemEqual(itemstack)) {
if (!stack.isEmpty() && stack.isItemEqual(itemstack)) {
return true;
}
}
@@ -171,7 +171,7 @@ public class Gardening {
public static boolean isNutrientFertiliser(final ItemStack itemstack) {
for (final ItemStack stack : getNutrientFertilisers()) {
if (stack != null && stack.isItemEqual(itemstack)) {
if (!stack.isEmpty() && stack.isItemEqual(itemstack)) {
return true;
}
}
@@ -138,7 +138,7 @@ public class ModuleGardening implements IInitializable {
for (int insulate = 0; insulate < 6; ++insulate) {
final ItemStack tubes = new ItemStack(Botany.insulatedTube, 2, mat + 128 * insulate);
final ItemStack insulateStack = ItemInsulatedTube.getInsulateStack(tubes);
final ItemStack forestryTube = new ItemStack(Mods.Forestry.item("thermionicTubes"), 1, mat);
final ItemStack forestryTube = new ItemStack(Mods.Forestry.item("thermionic_tubes"), 1, mat);
GameRegistry.addShapelessRecipe(tubes, forestryTube, forestryTube, insulateStack);
}
}
@@ -151,9 +151,9 @@ public class ModuleGardening implements IInitializable {
GameRegistry.addShapelessRecipe(BotanyItems.Weedkiller.get(4), new ItemStack(Items.SPIDER_EYE), new ItemStack(Items.WHEAT_SEEDS), new ItemStack(Items.WHEAT_SEEDS), new ItemStack(Items.WHEAT_SEEDS));
GameRegistry.addShapelessRecipe(BotanyItems.AshPowder.get(4), Mods.Forestry.stack("ash"));
GameRegistry.addShapelessRecipe(BotanyItems.MulchPowder.get(4), Mods.Forestry.stack("mulch"));
GameRegistry.addShapelessRecipe(BotanyItems.CompostPowder.get(4), Mods.Forestry.stack("fertilizerBio"));
GameRegistry.addShapelessRecipe(BotanyItems.FertiliserPowder.get(4), Mods.Forestry.stack("fertilizerCompound"));
GameRegistry.addShapelessRecipe(BotanyItems.PulpPowder.get(4), Mods.Forestry.stack("woodPulp"));
GameRegistry.addShapelessRecipe(BotanyItems.CompostPowder.get(4), Mods.Forestry.stack("fertilizer_bio"));
GameRegistry.addShapelessRecipe(BotanyItems.FertiliserPowder.get(4), Mods.Forestry.stack("fertilizer_compound"));
GameRegistry.addShapelessRecipe(BotanyItems.PulpPowder.get(4), Mods.Forestry.stack("wood_pulp"));
GameRegistry.addRecipe(new ShapelessOreRecipe(BotanyItems.SulphurPowder.get(4), "dustSulphur"));
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(Botany.pigment, 2, EnumFlowerColor.Black.ordinal()), "pigment", "pigment", "dyeBlack"));
ModuleGardening.queuedAcidFertilisers.put(BotanyItems.SulphurPowder.get(1), 1);
@@ -165,11 +165,11 @@ public class ModuleGardening implements IInitializable {
ModuleGardening.queuedAlkalineFertilisers.put(BotanyItems.AshPowder.get(1), 1);
ModuleGardening.queuedAlkalineFertilisers.put(BotanyItems.PulpPowder.get(1), 1);
ModuleGardening.queuedAlkalineFertilisers.put(Mods.Forestry.stack("ash"), 2);
ModuleGardening.queuedAlkalineFertilisers.put(Mods.Forestry.stack( "woodPulp"), 2);
ModuleGardening.queuedAlkalineFertilisers.put(Mods.Forestry.stack( "wood_pulp"), 2);
ModuleGardening.queuedNutrientFertilisers.put(BotanyItems.CompostPowder.get(1), 1);
ModuleGardening.queuedNutrientFertilisers.put(BotanyItems.FertiliserPowder.get(1), 1);
ModuleGardening.queuedNutrientFertilisers.put(Mods.Forestry.stack( "fertilizerBio"), 2);
ModuleGardening.queuedNutrientFertilisers.put(Mods.Forestry.stack("fertilizerCompound"), 2);
ModuleGardening.queuedNutrientFertilisers.put(Mods.Forestry.stack( "fertilizer_bio"), 2);
ModuleGardening.queuedNutrientFertilisers.put(Mods.Forestry.stack("fertilizer_compound"), 2);
for (final Map.Entry<ItemStack, Integer> entry : ModuleGardening.queuedAcidFertilisers.entrySet()) {
this.addAcidFertiliser(entry.getKey(), entry.getValue());
}
@@ -192,12 +192,11 @@ public class ModuleGardening implements IInitializable {
GameRegistry.addRecipe(new PigmentRecipe());
}
@Nullable
private ItemStack getStack(final int type, final int pH, final int moisture) {
if (type >= 0 && type <= 2 && pH >= 0 && pH <= 2 && moisture >= 0 && moisture <= 2) {
return new ItemStack(Gardening.getSoilBlock(EnumSoilType.values()[type]), 1, BlockSoil.getMeta(EnumAcidity.values()[pH], EnumMoisture.values()[moisture]));
}
return null;
return ItemStack.EMPTY;
}
private void addAcidFertiliser(final ItemStack stack, final int strengthMax) {
@@ -209,7 +208,7 @@ public class ModuleGardening implements IInitializable {
for (int strength = 1; strength < strengthMax; ++strength) {
final ItemStack start = this.getStack(type, pH, moisture);
final ItemStack end = this.getStack(type, pH - strength, moisture);
if (start != null && end != null) {
if (!start.isEmpty() && !end.isEmpty()) {
end.setCount(numOfBlocks);
final Object[] stacks = new Object[numOfBlocks + 1];
for (int i = 0; i < numOfBlocks; ++i) {
@@ -234,7 +233,7 @@ public class ModuleGardening implements IInitializable {
for (int strength = 1; strength < strengthMax; ++strength) {
final ItemStack start = this.getStack(type, pH, moisture);
final ItemStack end = this.getStack(type, pH + strength, moisture);
if (end != null) {
if (!end.isEmpty()) {
end.setCount(numOfBlocks);
final Object[] stacks = new Object[numOfBlocks + 1];
for (int i = 0; i < numOfBlocks; ++i) {
@@ -259,7 +258,7 @@ public class ModuleGardening implements IInitializable {
for (int strength = 1; strength < strengthMax; ++strength) {
final ItemStack start = this.getStack(type, pH, moisture);
final ItemStack end = this.getStack(type + strength, pH, moisture);
if (end != null) {
if (!end.isEmpty()) {
end.setCount(numOfBlocks);
final Object[] stacks = new Object[numOfBlocks + 1];
for (int i = 0; i < numOfBlocks; ++i) {
@@ -11,6 +11,7 @@ import binnie.core.genetics.ForestryAllele;
import binnie.core.genetics.Tolerance;
import binnie.extrabees.ExtraBees;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IAlleleSpecies;
import forestry.api.genetics.IBreedingTracker;
import forestry.api.genetics.IChromosomeType;
import forestry.api.genetics.IIndividual;
@@ -29,7 +30,7 @@ public class FlowerBreedingSystem extends BreedingSystem {
}
@Override
public float getChance(final IMutation mutation, final EntityPlayer player, final IAllele species1, final IAllele species2) {
public float getChance(final IMutation mutation, final EntityPlayer player, final IAlleleSpecies species1, final IAlleleSpecies species2) {
return mutation.getBaseChance();
}
@@ -15,10 +15,14 @@ import binnie.botany.api.IFlowerMutationBuilder;
import binnie.botany.api.IFlowerRoot;
import binnie.botany.api.IFlowerType;
import binnie.botany.core.BotanyCore;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.arboriculture.EnumTreeChromosome;
import forestry.api.core.EnumTemperature;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.AlleleSpeciesRegisterEvent;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IAlleleRegistry;
import forestry.api.genetics.IChromosomeType;
import forestry.api.genetics.IClassification;
import forestry.core.genetics.alleles.AlleleHelper;
import forestry.core.genetics.alleles.EnumAllele;
@@ -29,6 +33,7 @@ import net.minecraftforge.common.MinecraftForge;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
public enum FlowerDefinition implements IFlowerDefinition {
@@ -1089,6 +1094,14 @@ public enum FlowerDefinition implements IFlowerDefinition {
}
private void init() {
markAllelesAsValid(EnumBeeChromosome.FERTILITY, EnumFlowerChromosome.FERTILITY);
markAllelesAsValid(EnumBeeChromosome.TERRITORY, EnumFlowerChromosome.TERRITORY);
markAllelesAsValid(EnumBeeChromosome.LIFESPAN, EnumFlowerChromosome.LIFESPAN);
markAllelesAsValid(EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumFlowerChromosome.TEMPERATURE_TOLERANCE);
markAllelesAsValid(EnumBeeChromosome.HUMIDITY_TOLERANCE, EnumFlowerChromosome.HUMIDITY_TOLERANCE);
markAllelesAsValid(EnumBeeChromosome.HUMIDITY_TOLERANCE, EnumFlowerChromosome.PH_TOLERANCE);
markAllelesAsValid(EnumTreeChromosome.SAPPINESS, EnumFlowerChromosome.SAPPINESS);
template = Arrays.copyOf(FlowerTemplates.getDefaultTemplate(), EnumFlowerChromosome.values().length);
AlleleHelper.getInstance().set(template, EnumFlowerChromosome.SPECIES, species);
AlleleHelper.getInstance().set(template, EnumFlowerChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.BOTH_1);
@@ -1104,6 +1117,14 @@ public enum FlowerDefinition implements IFlowerDefinition {
}
}
private static void markAllelesAsValid(IChromosomeType existingType, IChromosomeType newType) {
IAlleleRegistry alleleRegistry = AlleleManager.alleleRegistry;
Collection<IAllele> alleles = alleleRegistry.getRegisteredAlleles(existingType);
for (IAllele allele : alleles) {
alleleRegistry.addValidAlleleTypes(allele, newType);
}
}
protected final IFlowerMutationBuilder registerMutation(final FlowerDefinition parent1, final FlowerDefinition parent2, final int chance) {
return FlowerManager.flowerFactory.createMutation(parent1.species, parent2.species, getTemplate(), chance);
}
@@ -64,7 +64,7 @@ public class FlowerRoot extends SpeciesRoot implements IFlowerRoot {
@Override
public boolean isMember(final ItemStack stack) {
return stack != null && this.getType(stack) != null;
return !stack.isEmpty() && this.getType(stack) != null;
}
@Override
@@ -105,10 +105,9 @@ public class FlowerRoot extends SpeciesRoot implements IFlowerRoot {
}
@Override
@Nullable
public ItemStack getMemberStack(IIndividual flower, ISpeciesType type) {
if (!this.isMember(flower)) {
return null;
return ItemStack.EMPTY;
}
Item flowerItem = Botany.flowerItem;
if (type == EnumFlowerStage.SEED) {
@@ -51,7 +51,7 @@ public class ModuleGenetics implements IInitializable {
@Override
public void postInit() {
FlowerManager.flowerRegistry.registerAcceptableFlower(Botany.flower, "flowersVanilla");
RecipeManagers.carpenterManager.addRecipe(100, Binnie.LIQUID.getFluidStack("water", 2000), null, new ItemStack(Botany.database),
RecipeManagers.carpenterManager.addRecipe(100, Binnie.LIQUID.getFluidStack("water", 2000), ItemStack.EMPTY, new ItemStack(Botany.database),
"X#X",
"YEY",
"RDR",
@@ -24,7 +24,7 @@ public enum PacketID implements IPacketID {
NBTTagCompound data = packet.getTagCompound();
EntityPlayer player = BinnieCore.getBinnieProxy().getPlayer();
String info = "";
if (data.hasNoTags()) {
if (data == null || data.hasNoTags()) {
info += Binnie.LANGUAGE.localise("botany.flowers.species.not.discover");
} else {
IAlleleFlowerSpecies primary = (IAlleleFlowerSpecies) AlleleManager.alleleRegistry.getAllele(data.getString("Species"));
+1 -1
View File
@@ -52,7 +52,7 @@ import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
@Mod(modid = Constants.CORE_MOD_ID, name = "Binnie Core", useMetadata = true, dependencies = "required-after:forestry")
@Mod(modid = Constants.CORE_MOD_ID, name = "Binnie Core", useMetadata = true, dependencies = "required-after:forestry@[5.3.1.34,)")
public final class BinnieCore extends AbstractMod {
public BinnieCore() {
+3 -6
View File
@@ -40,29 +40,26 @@ public class Mods {
return ForgeRegistries.BLOCKS.getValue(key);
}
@Nullable
public ItemStack stack(final String name) {
Item item = this.item(name);
if (item == null) {
return null;
return ItemStack.EMPTY;
}
return new ItemStack(item);
}
@Nullable
public ItemStack stack(final String name, final int amount) {
Item item = this.item(name);
if (item == null) {
return null;
return ItemStack.EMPTY;
}
return new ItemStack(item, amount);
}
@Nullable
public ItemStack stack(final String name, final int amount, final int meta) {
Item item = this.item(name);
if (item == null) {
return null;
return ItemStack.EMPTY;
}
return new ItemStack(item, amount, meta);
}
@@ -1,5 +1,6 @@
package binnie.core.block;
import binnie.core.BinnieCore;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
@@ -8,18 +9,15 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import binnie.core.BinnieCore;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
public class BlockMetadata extends BlockContainer implements IBlockMetadata {
static int temporyMeta = -1;
@@ -49,7 +47,6 @@ public class BlockMetadata extends BlockContainer implements IBlockMetadata {
}
@Override
@Nullable
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
return getPickBlock(world, pos);
}
@@ -70,22 +67,22 @@ public class BlockMetadata extends BlockContainer implements IBlockMetadata {
return getMetaFromState(state);
}
@Nullable
public static ItemStack getBlockDropped(IBlockMetadata block, IBlockAccess world, BlockPos pos) {
TileEntityMetadata tile = TileEntityMetadata.getTile(world, pos);
if (tile != null && !tile.hasDroppedBlock()) {
int meta = block.getDroppedMeta(world.getBlockState(pos), tile.getTileMetadata());
return TileEntityMetadata.getItemStack((Block) block, meta);
}
return null;
return ItemStack.EMPTY;
}
public static List<ItemStack> getBlockDroppedAsList(IBlockMetadata block, IBlockAccess world, BlockPos pos) {
public static NonNullList<ItemStack> getBlockDroppedAsList(IBlockMetadata block, IBlockAccess world, BlockPos pos) {
ItemStack drop = getBlockDropped(block, world, pos);
if(drop != null){
return Collections.singletonList(getBlockDropped(block, world, pos));
NonNullList<ItemStack> list = NonNullList.create();
if (!drop.isEmpty()) {
list.add(drop);
}
return Collections.emptyList();
return list;
}
public static boolean breakBlock(IBlockMetadata blockMetadata, @Nullable EntityPlayer player, World world, BlockPos pos) {
@@ -107,7 +104,6 @@ public class BlockMetadata extends BlockContainer implements IBlockMetadata {
return hasBeenBroken;
}
@Nullable
public static ItemStack getPickBlock(World world, BlockPos pos) {
Block block = world.getBlockState(pos).getBlock();
return getBlockDropped((IBlockMetadata) block, world, pos);
@@ -19,7 +19,7 @@ public class BinnieCircuit implements ICircuit {
this.uid = "binnie.circuit." + uid;
this.limit = limit;
ChipsetManager.circuitRegistry.registerCircuit(this);
if (itemStack != null) {
if (!itemStack.isEmpty()) {
ChipsetManager.solderManager.addRecipe(layout, itemStack, this);
}
}
@@ -10,6 +10,7 @@ import forestry.api.apiculture.IApiaristTracker;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeMutation;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IAlleleSpecies;
import forestry.api.genetics.IBreedingTracker;
import forestry.api.genetics.IChromosomeType;
import forestry.api.genetics.IMutation;
@@ -28,14 +29,14 @@ class BeeBreedingSystem extends BreedingSystem {
}
@Override
public float getChance(final IMutation mutation, final EntityPlayer player, final IAllele species1, final IAllele species2) {
public float getChance(final IMutation mutation, final EntityPlayer player, final IAlleleSpecies species1, final IAlleleSpecies species2) {
return ((IBeeMutation) mutation).
getChance(new VirtualBeeHousing(player),
(IAlleleBeeSpecies) species1,
(IAlleleBeeSpecies) species2,
(IBeeGenome) this.getSpeciesRoot().
templateAsGenome(this.getSpeciesRoot().getTemplate(species1.getUID())),
(IBeeGenome) this.getSpeciesRoot().templateAsGenome(this.getSpeciesRoot().getTemplate(species2.getUID())));
templateAsGenome(this.getSpeciesRoot().getTemplate(species1)),
(IBeeGenome) this.getSpeciesRoot().templateAsGenome(this.getSpeciesRoot().getTemplate(species2)));
}
@Override
@@ -151,21 +151,18 @@ public abstract class BreedingSystem implements IItemStackRepresentitive {
this.allBranches.add(branch);
}
}
if (this.getSpeciesRoot().getMutations(false) != null) {
List<? extends IMutation> speciesMutations = this.getSpeciesRoot().getMutations(false);
if (!speciesMutations.isEmpty()) {
final Set<IMutation> mutations = new LinkedHashSet<>();
mutations.addAll(this.getSpeciesRoot().getMutations(false));
mutations.addAll(speciesMutations);
if (this == Binnie.GENETICS.beeBreedingSystem) {
mutations.addAll(ExtraBeeMutation.mutations);
}
for (final IMutation mutation : mutations) {
this.allMutations.add(mutation);
final Set<IAlleleSpecies> participatingSpecies = new LinkedHashSet<>();
if (mutation.getAllele0() != null) {
participatingSpecies.add(mutation.getAllele0());
}
if (mutation.getAllele1() != null) {
participatingSpecies.add(mutation.getAllele1());
}
participatingSpecies.add(mutation.getAllele0());
participatingSpecies.add(mutation.getAllele1());
for (final IAlleleSpecies species3 : participatingSpecies) {
this.allFurtherMutations.get(species3).add(mutation);
if (this.allActiveSpecies.contains(species3)) {
@@ -333,7 +330,7 @@ public abstract class BreedingSystem implements IItemStackRepresentitive {
// return this.iconDiscovered.getIcon();
// }
public abstract float getChance(final IMutation p0, final EntityPlayer p1, final IAllele p2, final IAllele p3);
public abstract float getChance(final IMutation p0, final EntityPlayer p1, final IAlleleSpecies p2, final IAlleleSpecies p3);
public abstract Class<? extends IBreedingTracker> getTrackerClass();
@@ -472,7 +469,11 @@ public abstract class BreedingSystem implements IItemStackRepresentitive {
public abstract void addExtraAlleles(final IChromosomeType p0, final TreeSet<IAllele> p1);
public ItemStack getConversionStack(final ItemStack stack) {
return this.getSpeciesRoot().getMemberStack(this.getConversion(stack), this.getDefaultType());
IIndividual conversion = this.getConversion(stack);
if (conversion == null) {
return ItemStack.EMPTY;
}
return this.getSpeciesRoot().getMemberStack(conversion, this.getDefaultType());
}
public final Collection<IChromosomeType> getActiveKaryotype() {
@@ -480,14 +481,28 @@ public abstract class BreedingSystem implements IItemStackRepresentitive {
}
public ItemStack getDefaultMember(final String uid) {
return this.getSpeciesRoot().getMemberStack(this.getIndividual(uid), this.getDefaultType());
IIndividual individual = this.getIndividual(uid);
if (individual == null) {
return ItemStack.EMPTY;
}
return this.getSpeciesRoot().getMemberStack(individual, this.getDefaultType());
}
@Nullable
public IIndividual getIndividual(final String uid) {
return this.getSpeciesRoot().templateAsIndividual(this.getSpeciesRoot().getTemplate(uid));
IAllele[] template = this.getSpeciesRoot().getTemplate(uid);
if (template == null) {
return null;
}
return this.getSpeciesRoot().templateAsIndividual(template);
}
@Nullable
public IGenome getGenome(final String uid) {
return this.getSpeciesRoot().templateAsGenome(this.getSpeciesRoot().getTemplate(uid));
IAllele[] template = this.getSpeciesRoot().getTemplate(uid);
if (template == null) {
return null;
}
return this.getSpeciesRoot().templateAsGenome(template);
}
}
@@ -29,7 +29,7 @@ interface IBreedingMessage {
}
}
if (root != null) {
this.stack = root.getMemberStack(root.templateAsIndividual(root.getTemplate(species.getUID())), EnumBeeType.DRONE);
this.stack = root.getMemberStack(root.templateAsIndividual(root.getTemplate(species)), EnumBeeType.DRONE);
}
}
@@ -64,7 +64,7 @@ interface IBreedingMessage {
}
}
if (root != null) {
this.stack = root.getMemberStack(root.templateAsIndividual(root.getTemplate(species.getUID())), EnumBeeType.DRONE);
this.stack = root.getMemberStack(root.templateAsIndividual(root.getTemplate(species)), EnumBeeType.DRONE);
}
}
@@ -21,6 +21,7 @@ import forestry.api.genetics.IChromosomeType;
import forestry.api.genetics.IGenome;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.ISpeciesRoot;
import forestry.api.lepidopterology.ButterflyManager;
import forestry.api.lepidopterology.IButterflyRoot;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
@@ -85,7 +86,7 @@ public class ManagerGenetics extends ManagerBase {
}
public IButterflyRoot getButterflyRoot() {
return (IButterflyRoot) AlleleManager.alleleRegistry.getSpeciesRoot("rootButterflies");
return ButterflyManager.butterflyRoot;
}
public IFlowerRoot getFlowerRoot() {
@@ -130,8 +131,8 @@ public class ManagerGenetics extends ManagerBase {
}
@Nullable
public BreedingSystem getConversionSystem(@Nullable final ItemStack stack) {
if (stack != null) {
public BreedingSystem getConversionSystem(final ItemStack stack) {
if (!stack.isEmpty()) {
for (final BreedingSystem system : this.getActiveSystems()) {
if (system.getConversion(stack) != null) {
return system;
@@ -141,15 +142,14 @@ public class ManagerGenetics extends ManagerBase {
return null;
}
@Nullable
public ItemStack getConversionStack(@Nullable final ItemStack stack) {
if (stack != null) {
public ItemStack getConversionStack(final ItemStack stack) {
if (!stack.isEmpty()) {
final BreedingSystem system = this.getConversionSystem(stack);
if (system != null) {
return system.getConversionStack(stack);
}
}
return null;
return ItemStack.EMPTY;
}
@Nullable
@@ -5,6 +5,7 @@ import binnie.core.BinnieCore;
import binnie.extratrees.ExtraTrees;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IAlleleInteger;
import forestry.api.genetics.IAlleleSpecies;
import forestry.api.genetics.IBreedingTracker;
import forestry.api.genetics.IChromosomeType;
import forestry.api.genetics.IMutation;
@@ -25,7 +26,7 @@ class MothBreedingSystem extends BreedingSystem {
}
@Override
public float getChance(final IMutation mutation, final EntityPlayer player, final IAllele species1, final IAllele species2) {
public float getChance(final IMutation mutation, final EntityPlayer player, final IAlleleSpecies species1, final IAlleleSpecies species2) {
return 0.0f;
}
@@ -56,9 +56,10 @@ public class TreeBreedingSystem extends BreedingSystem {
}
@Override
public float getChance(final IMutation mutation, final EntityPlayer player, final IAllele species1, final IAllele species2) {
final ITreeGenome genome0 = (ITreeGenome) this.getSpeciesRoot().templateAsGenome(this.getSpeciesRoot().getTemplate(species1.getUID()));
final ITreeGenome genome2 = (ITreeGenome) this.getSpeciesRoot().templateAsGenome(this.getSpeciesRoot().getTemplate(species2.getUID()));
public float getChance(final IMutation mutation, final EntityPlayer player, final IAlleleSpecies species1, final IAlleleSpecies species2) {
ISpeciesRoot speciesRoot = this.getSpeciesRoot();
final ITreeGenome genome0 = (ITreeGenome) speciesRoot.templateAsGenome(speciesRoot.getTemplate(species1));
final ITreeGenome genome2 = (ITreeGenome) speciesRoot.templateAsGenome(speciesRoot.getTemplate(species2));
return ((ITreeMutation) mutation).getChance(player.world, player.getPosition(), (IAlleleTreeSpecies) species1, (IAlleleTreeSpecies) species2, genome0, genome2);
}
@@ -95,11 +96,11 @@ public class TreeBreedingSystem extends BreedingSystem {
this.discoveredWoods.clear();
for (final IAlleleSpecies species : this.getDiscoveredSpecies(tracker)) {
final IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
final ITreeGenome genome = (ITreeGenome) this.getSpeciesRoot().templateAsGenome(this.getSpeciesRoot().getTemplate(tSpecies.getUID()));
final ITreeGenome genome = (ITreeGenome) this.getSpeciesRoot().templateAsGenome(this.getSpeciesRoot().getTemplate(tSpecies));
IAlleleTreeSpecies treeSpecies = genome.getPrimary();
final ItemStack wood = treeSpecies.getWoodProvider().getWoodStack();
if (wood != null) {
if (!wood.isEmpty()) {
this.discoveredWoods.add(wood);
}
@@ -121,11 +122,11 @@ public class TreeBreedingSystem extends BreedingSystem {
super.calculateArrays();
for (final IAlleleSpecies species : this.allActiveSpecies) {
final IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
final ITreeGenome genome = (ITreeGenome) this.getSpeciesRoot().templateAsGenome(this.getSpeciesRoot().getTemplate(tSpecies.getUID()));
final ITreeGenome genome = (ITreeGenome) this.getSpeciesRoot().templateAsGenome(this.getSpeciesRoot().getTemplate(tSpecies));
IAlleleTreeSpecies treeSpecies = genome.getPrimary();
final ItemStack wood = treeSpecies.getWoodProvider().getWoodStack();
if (wood != null) {
if (!wood.isEmpty()) {
this.allWoods.add(wood);
}
@@ -145,7 +146,7 @@ public class TreeBreedingSystem extends BreedingSystem {
final List<IAlleleSpecies> found = new ArrayList<>();
for (final IAlleleSpecies species : set) {
final IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
final ITreeGenome genome = (ITreeGenome) this.getSpeciesRoot().templateAsGenome(this.getSpeciesRoot().getTemplate(tSpecies.getUID()));
final ITreeGenome genome = (ITreeGenome) this.getSpeciesRoot().templateAsGenome(this.getSpeciesRoot().getTemplate(tSpecies));
for (final ItemStack fruit2 : genome.getFruitProvider().getProducts().keySet()) {
if (fruit2.isItemEqual(fruit)) {
found.add(species);
@@ -161,7 +162,7 @@ public class TreeBreedingSystem extends BreedingSystem {
final Set<IFruitFamily> providers = new HashSet<>();
for (final IAlleleSpecies species : set) {
final IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
final ITreeGenome genome = (ITreeGenome) this.getSpeciesRoot().templateAsGenome(this.getSpeciesRoot().getTemplate(tSpecies.getUID()));
final ITreeGenome genome = (ITreeGenome) this.getSpeciesRoot().templateAsGenome(this.getSpeciesRoot().getTemplate(tSpecies));
for (final ItemStack fruit2 : genome.getFruitProvider().getProducts().keySet()) {
if (fruit2.isItemEqual(fruit)) {
providers.add(genome.getFruitProvider().getFamily());
@@ -185,7 +186,7 @@ public class TreeBreedingSystem extends BreedingSystem {
final List<IAlleleSpecies> found = new ArrayList<>();
for (final IAlleleSpecies species : set) {
IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
ITreeGenome genome = TreeManager.treeRoot.templateAsGenome(TreeManager.treeRoot.getTemplate(tSpecies.getUID()));
ITreeGenome genome = TreeManager.treeRoot.templateAsGenome(TreeManager.treeRoot.getTemplate(tSpecies));
IAlleleTreeSpecies treeSpecies = genome.getPrimary();
final ItemStack woodStack = treeSpecies.getWoodProvider().getWoodStack();
@@ -204,10 +205,11 @@ public class TreeBreedingSystem extends BreedingSystem {
final List<IAlleleSpecies> found = new ArrayList<>();
for (final IAlleleSpecies species : set) {
final IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
ITreeGenome genome = TreeManager.treeRoot.templateAsGenome(TreeManager.treeRoot.getTemplate(tSpecies.getUID()));
ITreeGenome genome = TreeManager.treeRoot.templateAsGenome(TreeManager.treeRoot.getTemplate(tSpecies));
IAlleleTreeSpecies treeSpecies = genome.getPrimary();
final ItemStack woodStack = treeSpecies.getWoodProvider().getWoodStack();
if (LumbermillRecipes.getPlankProduct(woodStack) != null && fruit.isItemEqual(LumbermillRecipes.getPlankProduct(woodStack))) {
ItemStack plankProduct = LumbermillRecipes.getPlankProduct(woodStack);
if (!plankProduct.isEmpty() && fruit.isItemEqual(plankProduct)) {
found.add(species);
}
}
@@ -221,7 +223,7 @@ public class TreeBreedingSystem extends BreedingSystem {
}
@Override
public boolean isDNAManipulable(ISpeciesType type) {
public boolean isDNAManipulable(@Nullable ISpeciesType type) {
return type == EnumGermlingType.POLLEN;
}
@@ -55,14 +55,12 @@ public class VirtualBeeHousing extends VirtualHousing implements IBeeHousing, IB
return 1.0f;
}
@Nullable
public ItemStack getQueen() {
return null;
return ItemStack.EMPTY;
}
@Nullable
public ItemStack getDrone() {
return null;
return ItemStack.EMPTY;
}
public void setQueen(final ItemStack itemstack) {
@@ -50,12 +50,12 @@ public class ModuleItems implements IInitializable {
if (player != null) {
ItemStack heldItem = player.getHeldItemMainhand();
if (heldItem != null && heldItem.getItem() == BinnieCore.getFieldKit() && player.isSneaking()) {
if (!heldItem.isEmpty() && heldItem.getItem() == BinnieCore.getFieldKit() && player.isSneaking()) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityFlower) {
TileEntityFlower tileFlower = (TileEntityFlower) tile;
IFlower flower = tileFlower.getFlower();
if (flower != null && flower.getGenome() != null) {
if (flower != null) {
IFlowerGenome flowerGenome = flower.getGenome();
NBTTagCompound info = new NBTTagCompound();
info.setString("Species", flowerGenome.getPrimary().getUID());
@@ -109,9 +109,11 @@ public class ItemFluidContainer extends ItemFood implements IItemModelRegister {
protected void onFoodEaten(final ItemStack itemStack, final World world, final EntityPlayer player) {
if (!world.isRemote) {
FluidStack fluid = getContained(itemStack);
final IDrinkLiquid liquid = DrinkManager.getLiquid(fluid);
if (liquid != null) {
AlcoholEffect.makeDrunk(player, liquid.getABV() * fluid.amount);
if (fluid != null) {
final IDrinkLiquid liquid = DrinkManager.getLiquid(fluid);
if (liquid != null) {
AlcoholEffect.makeDrunk(player, liquid.getABV() * fluid.amount);
}
}
}
}
@@ -2,7 +2,10 @@ package binnie.core.machines;
import binnie.core.network.IOrdinaled;
import javax.annotation.Nullable;
public interface IMachineType extends IOrdinaled {
@Nullable
Class<? extends MachinePackage> getPackageClass();
boolean isActive();
@@ -23,6 +23,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
import java.util.ArrayList;
@@ -163,9 +164,7 @@ public class Machine implements INetworkedEntity, INbtReadable, INbtWritable, IN
component.onUpdate();
}
} else {
for (IRender.DisplayTick renders : this.getInterfaces(IRender.DisplayTick.class)) {
renders.onDisplayTick(this.getWorld(), this.getTileEntity().getPos(), this.getWorld().rand);
}
updateClient();
}
if (this.queuedInventoryUpdate) {
for (final MachineComponent component : this.getComponents()) {
@@ -175,6 +174,13 @@ public class Machine implements INetworkedEntity, INbtReadable, INbtWritable, IN
}
}
@SideOnly(Side.CLIENT)
private void updateClient() {
for (IRender.DisplayTick renders : this.getInterfaces(IRender.DisplayTick.class)) {
renders.onDisplayTick(this.getWorld(), this.getTileEntity().getPos(), this.getWorld().rand);
}
}
public IInventory getInventory() {
return this.getInterface(IInventory.class);
}
@@ -2,6 +2,8 @@ package binnie.core.machines;
import binnie.Binnie;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public abstract class MachinePackage {
private String uid;
@@ -27,7 +29,8 @@ public abstract class MachinePackage {
public abstract TileEntity createTileEntity();
public abstract void register();
@SideOnly(Side.CLIENT)
public abstract void renderMachine(Machine machine, double x, double y, double z, float partialTicks, int destroyStage);//, final RenderBlocks p5);
public final String getDisplayName() {
@@ -9,11 +9,11 @@ import binnie.core.machines.power.PowerSystem;
import binnie.core.util.ItemStackSet;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidTank;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
@@ -38,7 +38,7 @@ public class MachineUtil {
}
public boolean isSlotEmpty(final int slot) {
return this.getInventory().getStackInSlot(slot) == null;
return this.getInventory().getStackInSlot(slot).isEmpty();
}
public IFluidTank getTank(final int id) {
@@ -51,21 +51,19 @@ public class MachineUtil {
return amount <= space;
}
@Nullable
public ItemStack getStack(final int slot) {
return this.getInventory().getStackInSlot(slot);
}
public void deleteStack(final int slot) {
this.setStack(slot, null);
this.setStack(slot, ItemStack.EMPTY);
}
@Nullable
public ItemStack decreaseStack(final int slot, final int amount) {
return this.getInventory().decrStackSize(slot, amount);
}
public void setStack(final int slot, @Nullable final ItemStack stack) {
public void setStack(final int slot, final ItemStack stack) {
this.getInventory().setInventorySlotContents(slot, stack);
}
@@ -76,7 +74,7 @@ public class MachineUtil {
public void addStack(final int slot, final ItemStack addition) {
final ItemStack merge = this.getStack(slot);
if (merge == null) {
if (merge.isEmpty()) {
this.setStack(slot, addition);
} else {
if (merge.isItemEqual(addition) && merge.getCount() + addition.getCount() <= merge.getMaxStackSize()) {
@@ -101,7 +99,7 @@ public class MachineUtil {
if (damage < 0) {
item.setItemDamage(Math.max(0, item.getItemDamage() + damage));
} else if (item.attemptDamageItem(damage, new Random())) {
this.setStack(slot, null);
this.setStack(slot, ItemStack.EMPTY);
}
this.setStack(slot, item);
}
@@ -123,7 +121,7 @@ public class MachineUtil {
final ItemStack[] stacks = new ItemStack[slots.length];
for (int i = 0; i < slots.length; ++i) {
ItemStack stack = this.getStack(slots[i]);
if (copy && stack != null) {
if (copy && !stack.isEmpty()) {
stack = stack.copy();
}
stacks[i] = stack;
@@ -145,12 +143,12 @@ public class MachineUtil {
return false;
}
List<ItemStack> requiredStacks = this.getNonNullStacks(recipe, true);
List<ItemStack> requiredStacks = this.getNonEmptyStacks(recipe, true);
for (ItemStack requiredStack : requiredStacks) {
IInventory inventory = this.getInventory();
for (int slot : inventorySlots) {
ItemStack stackInSlot = this.getStack(slot);
if (stackInSlot != null && ItemStack.areItemsEqual(requiredStack, stackInSlot) && ItemStack.areItemStackTagsEqual(requiredStack, stackInSlot)) {
if (!stackInSlot.isEmpty() && ItemStack.areItemsEqual(requiredStack, stackInSlot) && ItemStack.areItemStackTagsEqual(requiredStack, stackInSlot)) {
if (requiredStack.getCount() >= stackInSlot.getCount()) {
requiredStack.shrink(stackInSlot.getCount());
inventory.removeStackFromSlot(slot);
@@ -195,14 +193,14 @@ public class MachineUtil {
return this.machine.getInterface(IProcess.class);
}
public List<ItemStack> getNonNullStacks(final int[] slots) {
return getNonNullStacks(slots, false);
public NonNullList<ItemStack> getNonEmptyStacks(final int[] slots) {
return getNonEmptyStacks(slots, false);
}
public List<ItemStack> getNonNullStacks(final int[] slots, boolean copy) {
final List<ItemStack> stacks = new ArrayList<>();
public NonNullList<ItemStack> getNonEmptyStacks(final int[] slots, boolean copy) {
final NonNullList<ItemStack> stacks = NonNullList.create();
for (final ItemStack stack : this.getStacks(slots, copy)) {
if (stack != null) {
if (!stack.isEmpty()) {
stacks.add(stack);
}
}
@@ -35,7 +35,7 @@ class DefaultInventory implements IInventory {
}
@Override
public void setInventorySlotContents(final int i, @Nullable final ItemStack itemstack) {
public void setInventorySlotContents(final int i, final ItemStack itemstack) {
}
@Override
@@ -7,9 +7,7 @@ import javax.annotation.Nullable;
public interface IComponentRecipe {
boolean isRecipe();
@Nullable
ItemStack doRecipe(final boolean takeItem);
@Nullable
ItemStack getProduct();
}
@@ -87,7 +87,7 @@ public class ComponentChargedSlots extends MachineComponent implements INetwork.
@Override
public void onUpdate() {
for (final int slot : this.charges.keySet()) {
if (this.getCharge(slot) <= 0.0f && this.getUtil().decreaseStack(slot, 1) != null) {
if (this.getCharge(slot) <= 0.0f && !this.getUtil().decreaseStack(slot, 1).isEmpty()) {
this.setCharge(slot, 1.0f);
}
}
@@ -27,7 +27,7 @@ public class ComponentInventorySlots extends ComponentInventory implements IInve
@Override
public void clear() {
for (InventorySlot slot : this.inventory.values()) {
slot.setContent(null);
slot.setContent(ItemStack.EMPTY);
}
}
@@ -46,12 +46,11 @@ public class ComponentInventorySlots extends ComponentInventory implements IInve
return 0;
}
@Nullable
@Override
public ItemStack removeStackFromSlot(int index) {
InventorySlot inventorySlot = this.inventory.get(index);
ItemStack content = inventorySlot.getContent();
inventorySlot.setContent(null);
ItemStack content = inventorySlot.getItemStack();
inventorySlot.setContent(ItemStack.EMPTY);
return content;
}
@@ -70,28 +69,26 @@ public class ComponentInventorySlots extends ComponentInventory implements IInve
}
@Override
@Nullable
public ItemStack getStackInSlot(final int index) {
if (this.inventory.containsKey(index)) {
return this.inventory.get(index).getContent();
return this.inventory.get(index).getItemStack();
}
return null;
return ItemStack.EMPTY;
}
@Override
@Nullable
public ItemStack decrStackSize(final int index, final int amount) {
if (this.inventory.containsKey(index)) {
final ItemStack stack = this.inventory.get(index).decrStackSize(amount);
this.markDirty();
return stack;
}
return null;
return ItemStack.EMPTY;
}
@Override
public void setInventorySlotContents(final int index, @Nullable final ItemStack itemStack) {
if (this.inventory.containsKey(index) && (itemStack == null || this.inventory.get(index).isValid(itemStack))) {
public void setInventorySlotContents(final int index, final ItemStack itemStack) {
if (this.inventory.containsKey(index) && (itemStack.isEmpty() || this.inventory.get(index).isValid(itemStack))) {
this.inventory.get(index).setContent(itemStack);
}
this.markDirty();
@@ -100,9 +97,9 @@ public class ComponentInventorySlots extends ComponentInventory implements IInve
protected void transferItem(final int indexFrom, final int indexTo) {
if (this.inventory.containsKey(indexFrom) && this.inventory.containsKey(indexTo)) {
final InventorySlot slotFrom = this.inventory.get(indexFrom);
final ItemStack oldStack = slotFrom.getContent();
final ItemStack newStack = oldStack == null ? null : oldStack.copy();
slotFrom.setContent(null);
final ItemStack oldStack = slotFrom.getItemStack();
final ItemStack newStack = oldStack.isEmpty() ? ItemStack.EMPTY : oldStack.copy();
slotFrom.setContent(ItemStack.EMPTY);
this.inventory.get(indexTo).setContent(newStack);
}
this.markDirty();
@@ -226,8 +223,8 @@ public class ComponentInventorySlots extends ComponentInventory implements IInve
@Override
public void onDestruction() {
for (final InventorySlot slot : this.inventory.values()) {
final ItemStack stack = slot.getContent();
if (!slot.isRecipe() && stack != null) {
final ItemStack stack = slot.getItemStack();
if (!slot.isRecipe() && !stack.isEmpty()) {
final float f = this.getMachine().getWorld().rand.nextFloat() * 0.8f + 0.1f;
final float f2 = this.getMachine().getWorld().rand.nextFloat() * 0.8f + 0.1f;
final float f3 = this.getMachine().getWorld().rand.nextFloat() * 0.8f + 0.1f;
@@ -101,11 +101,11 @@ public class ComponentInventoryTransfer extends MachineComponent {
@Override
protected void doTransfer(final IInventory inv) {
if (inv.getStackInSlot(this.destination) == null) {
if (inv.getStackInSlot(this.destination).isEmpty()) {
for (final int i : this.buffer) {
if (inv.getStackInSlot(i) != null) {
if (!inv.getStackInSlot(i).isEmpty()) {
final ItemStack newStack = inv.decrStackSize(i, this.limit);
if (newStack != null) {
if (!newStack.isEmpty()) {
inv.setInventorySlotContents(this.destination, newStack);
return;
}
@@ -128,7 +128,7 @@ public class ComponentInventoryTransfer extends MachineComponent {
@Override
protected void doTransfer(final IInventory inv) {
ItemStack stackInSlot = inv.getStackInSlot(this.source);
if (stackInSlot != null) {
if (!stackInSlot.isEmpty()) {
TransferRequest transferRequest = new TransferRequest(stackInSlot, inv).setTargetSlots(this.destination).ignoreValidation();
ItemStack transfer = transferRequest.transfer(true);
inv.setInventorySlotContents(this.source, transfer);
@@ -138,7 +138,7 @@ public class ComponentInventoryTransfer extends MachineComponent {
@Override
protected boolean fulfilled(final IInventory inv) {
final ItemStack stack = inv.getStackInSlot(this.source);
return stack != null && (this.condition == null || this.condition.fulfilled(stack));
return !stack.isEmpty() && (this.condition == null || this.condition.fulfilled(stack));
}
}
@@ -8,40 +8,42 @@ import net.minecraft.nbt.NBTTagCompound;
import javax.annotation.Nullable;
public class InventorySlot extends BaseSlot<ItemStack> {
@Nullable
private ItemStack itemStack;
private Type type;
public InventorySlot(final int index, final String unlocName) {
super(index, unlocName);
this.itemStack = null;
this.itemStack = ItemStack.EMPTY;
this.type = Type.Standard;
}
@Override
@Nullable
public ItemStack getContent() {
return this.itemStack.isEmpty() ? null : this.itemStack;
}
public ItemStack getItemStack() {
return this.itemStack;
}
@Nullable
public ItemStack getItemStack() {
return this.getContent();
@Override
public boolean isEmpty() {
return this.itemStack.isEmpty();
}
@Override
public void setContent(@Nullable final ItemStack itemStack) {
public void setContent(final ItemStack itemStack) {
this.itemStack = itemStack;
}
@Nullable
public ItemStack decrStackSize(final int amount) {
if (this.itemStack == null) {
return null;
if (this.itemStack.isEmpty()) {
return ItemStack.EMPTY;
}
if (this.itemStack.getCount() <= amount) {
final ItemStack returnStack = this.itemStack.copy();
this.itemStack = null;
this.itemStack = ItemStack.EMPTY;
return returnStack;
}
final ItemStack returnStack = this.itemStack.copy();
@@ -57,14 +59,14 @@ public class InventorySlot extends BaseSlot<ItemStack> {
final NBTTagCompound itemNBT = slotNBT.getCompoundTag("item");
this.itemStack = new ItemStack(itemNBT);
} else {
this.itemStack = null;
this.itemStack = ItemStack.EMPTY;
}
}
@Override
public NBTTagCompound writeToNBT(final NBTTagCompound slotNBT) {
final NBTTagCompound itemNBT = new NBTTagCompound();
if (this.itemStack != null) {
if (!this.itemStack.isEmpty()) {
this.itemStack.writeToNBT(itemNBT);
}
slotNBT.setTag("item", itemNBT);
@@ -31,7 +31,10 @@ public enum PowerSystem {
}
public ItemStack saveTo(final ItemStack stack) {
final NBTTagCompound tag = stack.hasTagCompound() ? stack.getTagCompound() : new NBTTagCompound();
NBTTagCompound tag = stack.getTagCompound();
if (tag == null) {
tag = new NBTTagCompound();
}
tag.setByte("power-system", (byte) this.ordinal());
stack.setTagCompound(tag);
return stack;
@@ -9,6 +9,8 @@ import binnie.core.resource.BinnieResource;
import binnie.core.resource.IBinnieTexture;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
enum Compartment implements IMachineType {
Compartment(StandardCompartment.PackageCompartment.class),
@@ -56,6 +58,7 @@ enum Compartment implements IMachineType {
}
@Override
@SideOnly(Side.CLIENT)
public void renderMachine(Machine machine, double x, double y, double z, float partialTicks, int destroyStage) {
MachineRendererCompartment.instance.renderMachine(machine, 16777215, renderTexture, x, y, z, partialTicks);
}
@@ -49,6 +49,7 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
import java.util.Arrays;
@@ -153,6 +154,7 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
final ControlPage thisPage = page[p2];
final Panel panel = new Panel(thisPage, 0, 0, thisPage.w(), thisPage.h(), MinecraftGUI.PanelType.Black) {
@Override
@SideOnly(Side.CLIENT)
public void onRenderForeground(int guiWidth, int guiHeight) {
final Texture iTexture = CraftGUI.render.getTexture(CraftGUITexture.TabOutline);
RenderUtil.setColour(WindowCompartment.this.getTab(WindowCompartment.this.panels.get(this)).getColor().getColour());
@@ -307,6 +309,7 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
public void initialise() {
final ControlScrollableContent<IWidget> scroll = new ControlScrollableContent<IWidget>(this, 124, 16, 116, 92, 6) {
@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
RenderUtil.setColour(11184810);
CraftGUI.render.texture(CraftGUITexture.Outline, this.getArea().inset(new IBorder(0, 6, 0, 0)));
@@ -352,7 +355,7 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
final IInventory inv = WindowCompartment.this.getInventory();
for (int i = 0; i < inv.getSizeInventory(); ++i) {
final ItemStack stack = inv.getStackInSlot(i);
if (stack != null) {
if (!stack.isEmpty()) {
final String name = stack.getDisplayName().toLowerCase();
if (this.textSearch == null || name.contains(this.textSearch)) {
if (this.includeBlocks || Block.getBlockFromItem(stack.getItem()) == Blocks.AIR) {
@@ -400,11 +403,13 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
}
@Override
@SideOnly(Side.CLIENT)
public void onUpdateClient() {
super.onUpdateClient();
this.updateTabs();
}
@SideOnly(Side.CLIENT)
public void updateTabs() {
this.tabName.setValue(this.getCurrentTab().getName());
this.tabIcon.setItemStack(this.getCurrentTab().getIcon());
@@ -8,20 +8,18 @@ import binnie.core.machines.power.ITankMachine;
import com.google.common.base.Preconditions;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil;
import net.minecraftforge.fluids.IFluidTank;
import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
public class TransferRequest {
@Nullable
private ItemStack itemToTransfer;
@Nullable
private ItemStack returnItem;
@Nullable
private IInventory origin;
@@ -34,9 +32,9 @@ public class TransferRequest {
private List<TransferSlot> insertedSlots;
private List<Integer> insertedTanks;
public TransferRequest(@Nullable final ItemStack toTransfer, final IInventory destination) {
this.itemToTransfer = null;
this.returnItem = null;
public TransferRequest(final ItemStack toTransfer, final IInventory destination) {
this.itemToTransfer = ItemStack.EMPTY;
this.returnItem = ItemStack.EMPTY;
this.targetSlots = new int[0];
this.targetTanks = new int[0];
this.transferLiquids = true;
@@ -54,7 +52,7 @@ public class TransferRequest {
targetTanks[j] = j;
}
}
if (toTransfer != null) {
if (!toTransfer.isEmpty()) {
this.setItemToTransfer(toTransfer.copy());
this.setReturnItem(toTransfer.copy());
}
@@ -65,39 +63,34 @@ public class TransferRequest {
this.transferLiquids = true;
}
@Nullable
public static ItemStack transferItemToInventory(final ItemStack item, final IInventory destination, final boolean doAdd) {
ItemStack addition = item.copy();
for (int i = 0; i < destination.getSizeInventory(); ++i) {
addition = transferToInventory(addition, destination, new int[]{i}, doAdd, false);
if (addition == null) {
return null;
if (addition.isEmpty()) {
return ItemStack.EMPTY;
}
}
return addition;
}
@Nullable
public static ItemStack transferToInventory(ItemStack item, final IInventory destination, final int[] targetSlots, final boolean doAdd, final boolean ignoreValidation) {
ItemStack returnItem = item;
for (final int i : targetSlots) {
if (destination.isItemValidForSlot(i, returnItem) || ignoreValidation) {
ItemStack stackInSlot = destination.getStackInSlot(i);
if (stackInSlot == null) {
if (stackInSlot.isEmpty()) {
if (doAdd) {
destination.setInventorySlotContents(i, returnItem.copy());
}
return null;
return ItemStack.EMPTY;
}
if (returnItem.isStackable()) {
final ItemStack merged = stackInSlot.copy();
final ItemStack[] newStacks = mergeStacks(returnItem.copy(), merged.copy());
returnItem = newStacks[0];
final NonNullList<ItemStack> newStacks = mergeStacks(returnItem.copy(), merged.copy());
returnItem = newStacks.get(0);
if (doAdd) {
destination.setInventorySlotContents(i, newStacks[1]);
}
if (returnItem == null) {
return null;
destination.setInventorySlotContents(i, newStacks.get(1));
}
}
}
@@ -109,7 +102,7 @@ public class TransferRequest {
this.itemToTransfer = itemToTransfer;
}
private void setReturnItem(@Nullable final ItemStack returnItem) {
private void setReturnItem(final ItemStack returnItem) {
this.returnItem = returnItem;
}
@@ -137,32 +130,30 @@ public class TransferRequest {
return this;
}
@Nullable
public ItemStack getReturnItem() {
return this.returnItem;
}
@Nullable
public ItemStack transfer(final boolean doAdd) {
ItemStack item = this.returnItem;
if (item == null || this.destination == null || this.origin == null) {
return null;
if (item.isEmpty() || this.destination == null || this.origin == null) {
return ItemStack.EMPTY;
}
if (this.transferLiquids && this.destination instanceof ITankMachine) {
ItemStack itemIn = item.copy();
for (final int tankID : this.targetTanks) {
item = transferToTank(item, this.origin, (ITankMachine) this.destination, tankID, doAdd);
if (item == null || !ItemStack.areItemStacksEqual(item, itemIn)) {
if (item.isEmpty() || !ItemStack.areItemStacksEqual(item, itemIn)) {
break;
}
item = transferFromTank(item, this.origin, (ITankMachine) this.destination, tankID, doAdd);
if (item == null || !ItemStack.areItemStacksEqual(item, itemIn)) {
if (item.isEmpty() || !ItemStack.areItemStacksEqual(item, itemIn)) {
break;
}
}
}
if (item != null) {
if (!item.isEmpty()) {
for (final int slot : this.targetSlots) {
if (this.destination.isItemValidForSlot(slot, item) || this.ignoreReadOnly) {
if (this.destination instanceof IInventorySlots) {
@@ -172,26 +163,26 @@ public class TransferRequest {
}
}
ItemStack stackInSlot = this.destination.getStackInSlot(slot);
if (stackInSlot != null) {
if (!stackInSlot.isEmpty()) {
if (item.isStackable()) {
final ItemStack merged = stackInSlot.copy();
final ItemStack[] newStacks = mergeStacks(item.copy(), merged.copy());
item = newStacks[0];
if (!areItemsEqual(merged, newStacks[1])) {
final NonNullList<ItemStack> newStacks = mergeStacks(item.copy(), merged.copy());
item = newStacks.get(0);
if (!areItemsEqual(merged, newStacks.get(1))) {
this.insertedSlots.add(new TransferSlot(slot, this.destination));
}
if (doAdd) {
this.destination.setInventorySlotContents(slot, newStacks[1]);
this.destination.setInventorySlotContents(slot, newStacks.get(1));
}
if (item == null) {
return null;
if (item.isEmpty()) {
return ItemStack.EMPTY;
}
}
}
}
}
}
if (item != null) {
if (!item.isEmpty()) {
for (final int slot : this.targetSlots) {
if (this.destination.isItemValidForSlot(slot, item) || this.ignoreReadOnly) {
if (this.destination instanceof IInventorySlots) {
@@ -200,12 +191,12 @@ public class TransferRequest {
continue;
}
}
if (this.destination.getStackInSlot(slot) == null) {
if (this.destination.getStackInSlot(slot).isEmpty()) {
this.insertedSlots.add(new TransferSlot(slot, this.destination));
if (doAdd) {
this.destination.setInventorySlotContents(slot, item.copy());
}
return null;
return ItemStack.EMPTY;
}
}
}
@@ -218,7 +209,7 @@ public class TransferRequest {
return ItemStack.areItemStackTagsEqual(itemstack, merged) && itemstack.isItemEqual(merged);
}
public static ItemStack[] mergeStacks(ItemStack itemstack, final ItemStack merged) {
public static NonNullList<ItemStack> mergeStacks(ItemStack itemstack, final ItemStack merged) {
if (areItemsEqual(itemstack, merged)) {
final int space = merged.getMaxStackSize() - merged.getCount();
if (space > 0) {
@@ -231,10 +222,12 @@ public class TransferRequest {
}
}
}
return new ItemStack[]{itemstack, merged};
NonNullList<ItemStack> result = NonNullList.create();
result.add(itemstack);
result.add(merged);
return result;
}
@Nullable
public static ItemStack transferToTank(final ItemStack itemStack, final IInventory origin, final ITankMachine destination, final int tankID, final boolean doAdd) {
Preconditions.checkNotNull(itemStack);
Preconditions.checkArgument(itemStack.getCount() >= 1);
@@ -242,8 +235,7 @@ public class TransferRequest {
final ItemStack singleCopy = itemStack.copy();
singleCopy.setCount(1);
// TODO 1.11: use IFluidHandlerItem
final IFluidHandler fluidHandler = FluidUtil.getFluidHandler(singleCopy);
final IFluidHandlerItem fluidHandler = FluidUtil.getFluidHandler(singleCopy);
if (fluidHandler != null) {
final FluidStack containerLiquid = fluidHandler.drain(Integer.MAX_VALUE, false);
@@ -255,24 +247,20 @@ public class TransferRequest {
final int amountAdded = tank.fill(containerLiquid, false);
// TODO 1.11: use IFluidHandlerItem
fluidHandler.drain(amountAdded, true);
ItemStack drainedContainer = fluidHandler.getContainer();
if (singleCopy.getCount() == 0 || transferItemToInventory(singleCopy, origin, false) == null) {
if (drainedContainer.isEmpty() || transferItemToInventory(singleCopy, origin, false).isEmpty()) {
if (doAdd) {
tank.fill(containerLiquid, true);
if (singleCopy.getCount() > 0) {
transferItemToInventory(singleCopy, origin, true);
if (!drainedContainer.isEmpty()) {
transferItemToInventory(drainedContainer, origin, true);
}
}
if (itemStack.getCount() == 1) {
return null;
} else {
final ItemStack leftover = itemStack.copy();
leftover.shrink(1);
return leftover;
}
final ItemStack leftover = itemStack.copy();
leftover.shrink(1);
return leftover;
}
}
}
@@ -280,7 +268,6 @@ public class TransferRequest {
return itemStack;
}
@Nullable
private static ItemStack transferFromTank(ItemStack itemStack, final IInventory origin, final ITankMachine destination, final int tankID, final boolean doAdd) {
Preconditions.checkNotNull(itemStack);
Preconditions.checkArgument(itemStack.getCount() >= 1);
@@ -290,30 +277,25 @@ public class TransferRequest {
if (fluid != null) {
final ItemStack singleCopy = itemStack.copy();
singleCopy.setCount(1);
// TODO 1.11: use IFluidHandlerItem
IFluidHandler fluidHandler = FluidUtil.getFluidHandler(singleCopy);
IFluidHandlerItem fluidHandler = FluidUtil.getFluidHandler(singleCopy);
if (fluidHandler != null) {
final int fillAmount = fluidHandler.fill(fluid, true);
if (fillAmount > 0) {
final FluidStack fillFluid = tank.drain(fillAmount, false);
if (fillFluid != null) {
// TODO 1.11: use IFluidHandlerItem
fluidHandler.fill(fillFluid, true);
if (singleCopy.getCount() == 0 || transferItemToInventory(singleCopy, origin, false) == null) {
ItemStack filledContainer = fluidHandler.getContainer();
if (filledContainer.isEmpty() || transferItemToInventory(singleCopy, origin, false).isEmpty()) {
if (doAdd) {
tank.drain(fillFluid.amount, true);
if (singleCopy.getCount() > 0) {
transferItemToInventory(singleCopy, origin, true);
if (!filledContainer.isEmpty()) {
transferItemToInventory(filledContainer, origin, true);
}
}
if (itemStack.getCount() == 1) {
return null;
} else {
ItemStack leftover = itemStack.copy();
leftover.shrink(1);
return leftover;
}
ItemStack leftover = itemStack.copy();
leftover.shrink(1);
return leftover;
}
}
}
@@ -341,7 +323,6 @@ public class TransferRequest {
return this.destination;
}
@Nullable
public ItemStack getItemToTransfer() {
return this.itemToTransfer;
}
@@ -1,5 +1,9 @@
package binnie.core.resource;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public interface IBinnieTexture {
@SideOnly(Side.CLIENT)
BinnieResource getTexture();
}
@@ -5,6 +5,8 @@ import binnie.core.BinnieCore;
import binnie.core.resource.BinnieResource;
import binnie.core.resource.IBinnieTexture;
import binnie.core.resource.ResourceType;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public enum BinnieCoreTexture implements IBinnieTexture {
Compartment(ResourceType.Tile, "Compartment"),
@@ -25,6 +27,7 @@ public enum BinnieCoreTexture implements IBinnieTexture {
}
@Override
@SideOnly(Side.CLIENT)
public BinnieResource getTexture() {
return Binnie.RESOURCE.getPNG(BinnieCore.getInstance(), this.type, this.texture);
}
@@ -4,6 +4,6 @@ import net.minecraft.inventory.IInventory;
public class TriggerInventory {
private static Boolean isSlotEmpty(final IInventory inventory, final int slot) {
return inventory.getStackInSlot(slot) != null;
return !inventory.getStackInSlot(slot).isEmpty();
}
}
@@ -39,7 +39,7 @@ public class FakeCraftingWorld extends World {
private FakeCraftingWorld() {
super(saveHandler, worldInfo, worldProvider, new Profiler(), true);
this.provider.setWorld(this);
this.mapStorage = new FakeMapStorage();
this.mapStorage = new FakeMapStorage(saveHandler);
}
@Override
@@ -1,13 +1,14 @@
package binnie.core.util;
import net.minecraft.world.WorldSavedData;
import net.minecraft.world.storage.ISaveHandler;
import net.minecraft.world.storage.MapStorage;
import javax.annotation.Nullable;
public class FakeMapStorage extends MapStorage {
public FakeMapStorage() {
super(null);
public FakeMapStorage(ISaveHandler fakeSaveHandler) {
super(fakeSaveHandler);
}
@Override
@@ -26,7 +26,7 @@ public class FakeSaveHandler implements ISaveHandler {
@Override
public IChunkLoader getChunkLoader(WorldProvider provider)
{
return null;
throw new UnsupportedOperationException();
}
@Override
@@ -42,7 +42,7 @@ public class FakeSaveHandler implements ISaveHandler {
@Override
public IPlayerFileData getPlayerNBTManager()
{
return null;
throw new UnsupportedOperationException();
}
@Override
@@ -53,18 +53,18 @@ public class FakeSaveHandler implements ISaveHandler {
@Override
public File getMapFileFromName(String mapName)
{
return null;
throw new UnsupportedOperationException();
}
@Override
public File getWorldDirectory()
{
return null;
throw new UnsupportedOperationException();
}
@Override
public TemplateManager getStructureTemplateManager()
{
return null;
throw new UnsupportedOperationException();
}
}
@@ -21,21 +21,20 @@ public class ItemStackSet implements Set<ItemStack> {
return this.itemStacks.toString();
}
@Nullable
protected ItemStack getExisting(final ItemStack stack) {
for (final ItemStack stack2 : this.itemStacks) {
if (ItemStack.areItemsEqual(stack2, stack) && ItemStack.areItemStackTagsEqual(stack2, stack)) {
return stack2;
}
}
return null;
return ItemStack.EMPTY;
}
@Override
public boolean add(final ItemStack e) {
if (e != null) {
ItemStack existing = this.getExisting(e);
if (existing == null) {
if (existing.isEmpty()) {
return this.itemStacks.add(e.copy());
}
existing.grow(e.getCount());
@@ -59,7 +58,7 @@ public class ItemStackSet implements Set<ItemStack> {
@Override
public boolean contains(final Object o) {
return o instanceof ItemStack && this.getExisting((ItemStack) o) != null;
return o instanceof ItemStack && !this.getExisting((ItemStack) o).isEmpty();
}
@Override
@@ -86,7 +85,7 @@ public class ItemStackSet implements Set<ItemStack> {
if (this.contains(o)) {
final ItemStack r = (ItemStack) o;
final ItemStack existing = this.getExisting(r);
if (existing != null && existing.getCount() > r.getCount()) {
if (!existing.isEmpty() && existing.getCount() > r.getCount()) {
existing.shrink(r.getCount());
} else {
this.itemStacks.remove(existing);
@@ -5,7 +5,7 @@ import net.minecraft.item.ItemStack;
public class UniqueItemStackSet extends ItemStackSet {
@Override
public boolean add(final ItemStack e) {
return e != null && this.getExisting(e) == null && this.itemStacks.add(e.copy());
return !e.isEmpty() && this.getExisting(e).isEmpty() && this.itemStacks.add(e.copy());
}
@Override
@@ -34,6 +34,7 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
import java.util.ArrayList;
@@ -54,8 +55,6 @@ public class WindowFieldKit extends Window {
private float analyseProgress;
private boolean isAnalysing;
private Map<IChromosomeType, String> info;
@Nullable
private ItemStack prev;
public WindowFieldKit(final EntityPlayer player, @Nullable final IInventory inventory, final Side side) {
super(280, 230, player, inventory, side);
@@ -67,7 +66,6 @@ public class WindowFieldKit extends Window {
this.analyseProgress = 1;
this.isAnalysing = false;
this.info = new HashMap<>();
this.prev = null;
}
@Override
@@ -146,6 +144,7 @@ public class WindowFieldKit extends Window {
}
@Override
@SideOnly(Side.CLIENT)
public void onUpdateClient() {
super.onUpdateClient();
if (this.isAnalysing) {
@@ -154,7 +153,7 @@ public class WindowFieldKit extends Window {
this.isAnalysing = false;
this.analyseProgress = 1;
final ItemStack stack = this.getWindowInventory().getStackInSlot(0);
if (stack != null) {
if (!stack.isEmpty()) {
this.sendClientAction("analyse", new NBTTagCompound());
}
this.refreshSpecies();
@@ -171,7 +170,7 @@ public class WindowFieldKit extends Window {
private void refreshSpecies() {
final ItemStack item = this.getWindowInventory().getStackInSlot(0);
if (item == null || !AlleleManager.alleleRegistry.isIndividual(item)) {
if (item.isEmpty() || !AlleleManager.alleleRegistry.isIndividual(item)) {
return;
}
final IIndividual ind = AlleleManager.alleleRegistry.getIndividual(item);
@@ -214,10 +213,9 @@ public class WindowFieldKit extends Window {
}
if (this.isClient()) {
final ItemStack item = this.getWindowInventory().getStackInSlot(0);
this.prev = item;
this.text.setValue("");
if (item != null && !Analyser.isAnalysed(item)) {
if (this.getWindowInventory().getStackInSlot(1) == null) {
if (!item.isEmpty() && !Analyser.isAnalysed(item)) {
if (this.getWindowInventory().getStackInSlot(1).isEmpty()) {
this.text.setValue("No Paper!");
this.isAnalysing = false;
this.analyseProgress = 1;
@@ -228,7 +226,7 @@ public class WindowFieldKit extends Window {
return;
}
}
} else if (item != null) {
} else if (!item.isEmpty()) {
this.isAnalysing = false;
this.analyseProgress = 1;
this.refreshSpecies();
@@ -139,9 +139,11 @@ public class WindowGenesis extends Window {
return;
}
final IChromosomeType chromo = ((Gene) event.value).getChromosome();
WindowGenesis.this.template[chromo.ordinal()] = ((Gene) event.value).getAllele();
if (chromo == ((Gene) event.value).getSpeciesRoot().getSpeciesChromosomeType()) {
WindowGenesis.this.template = ((Gene) event.value).getSpeciesRoot().getTemplate(((Gene) event.value).getAllele().getUID());
IAllele allele = ((Gene) event.value).getAllele();
WindowGenesis.this.template[chromo.ordinal()] = allele;
ISpeciesRoot speciesRoot = ((Gene) event.value).getSpeciesRoot();
if (chromo == speciesRoot.getSpeciesChromosomeType()) {
WindowGenesis.this.template = speciesRoot.getTemplate(allele.getUID());
}
WindowGenesis.this.refreshTemplate(chromo);
}
@@ -199,10 +201,10 @@ public class WindowGenesis extends Window {
if (side == Side.SERVER && name.equals("genesis")) {
final ItemStack stack = new ItemStack(action);
final InventoryPlayer playerInv = player.inventory;
if (stack == null) {
if (stack.isEmpty()) {
return;
}
if (playerInv.getItemStack() == null) {
if (playerInv.getItemStack().isEmpty()) {
playerInv.setItemStack(stack);
} else if (playerInv.getItemStack().isItemEqual(stack) && ItemStack.areItemStackTagsEqual(playerInv.getItemStack(), stack)) {
final int fit = stack.getMaxStackSize() - (stack.getCount() + playerInv.getItemStack().getCount());
@@ -12,7 +12,10 @@ import binnie.craftgui.events.EventTextEdit;
import binnie.craftgui.events.EventWidget;
import binnie.craftgui.resource.minecraft.CraftGUITexture;
import net.minecraft.client.gui.GuiTextField;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ControlTextEdit extends Control implements IControlValue<String> {
GuiTextField field;
private String cachedValue;
@@ -18,11 +18,14 @@ import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fml.client.config.GuiUtils;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
@SideOnly(Side.CLIENT)
public class RenderUtil {
private RenderUtil() {
@@ -87,10 +87,10 @@ public class ContainerCraftGUI extends Container {
for (int i = 0; i < inventory.getSizeInventory(); ++i) {
if (inventory.dispenseOnClose(i)) {
ItemStack stack = inventory.getStackInSlot(i);
if (stack != null) {
if (!stack.isEmpty()) {
TransferRequest transferRequest = new TransferRequest(stack, par1EntityPlayer.inventory);
stack = transferRequest.transfer(true);
if (stack != null) {
if (!stack.isEmpty()) {
par1EntityPlayer.dropItem(stack, false);
}
}
@@ -123,27 +123,25 @@ public class ContainerCraftGUI extends Container {
}
@Override
@Nullable
public final ItemStack transferStackInSlot(final EntityPlayer player, final int slotID) {
return this.shiftClick(player, slotID);
}
@Nullable
private ItemStack shiftClick(final EntityPlayer player, final int slotnumber) {
final TransferRequest request = this.getShiftClickRequest(player, slotnumber);
final ItemStack itemstack = request.transfer(true);
final Slot shiftClickedSlot = this.inventorySlots.get(slotnumber);
shiftClickedSlot.putStack(itemstack);
shiftClickedSlot.onSlotChanged();
return null;
return ItemStack.EMPTY;
}
private TransferRequest getShiftClickRequest(final EntityPlayer player, final int slotnumber) {
final Slot shiftClickedSlot = this.inventorySlots.get(slotnumber);
ItemStack itemstack = null;
ItemStack itemstack = ItemStack.EMPTY;
if (shiftClickedSlot.getHasStack()) {
ItemStack shiftClickedStack = shiftClickedSlot.getStack();
if (shiftClickedStack != null) {
if (!shiftClickedStack.isEmpty()) {
itemstack = shiftClickedStack.copy();
}
}
@@ -174,7 +172,7 @@ public class ContainerCraftGUI extends Container {
return null;
}
ItemStack heldItem = player.inventory.getItemStack();
if (heldItem == null) {
if (heldItem.isEmpty()) {
return null;
}
heldItem = heldItem.copy();
@@ -461,7 +459,7 @@ public class ContainerCraftGUI extends Container {
final Slot slot = new CustomSlot(inventory, index);
slot.slotNumber = slotNumber;
this.inventorySlots.add(slotNumber, slot);
this.inventoryItemStacks.add(slotNumber, null);
this.inventoryItemStacks.add(slotNumber, ItemStack.EMPTY);
return slot;
}
}
@@ -13,8 +13,8 @@ import javax.annotation.Nullable;
public class CustomSlot extends Slot {
@Override
public boolean isItemValid(@Nullable final ItemStack stack) {
return stack != null && this.inventory.isItemValidForSlot(this.getSlotIndex(), stack);
public boolean isItemValid(final ItemStack stack) {
return !stack.isEmpty() && this.inventory.isItemValidForSlot(this.getSlotIndex(), stack);
}
public CustomSlot(final IInventory inventory, final int index) {
@@ -38,8 +38,8 @@ public class CustomSlot extends Slot {
public void onSlotClick(final ContainerCraftGUI container, final int dragType, final ClickType modifier, final EntityPlayer player) {
ItemStack stack = player.inventory.getItemStack();
//TODO modifier==mouseButton2?
if (stack == null || modifier == ClickType.PICKUP_ALL) {
this.putStack(null);
if (stack.isEmpty() || modifier == ClickType.PICKUP_ALL) {
this.putStack(ItemStack.EMPTY);
} else {
stack = stack.copy();
stack.setCount(1);
@@ -31,7 +31,6 @@ import java.util.List;
public class GuiCraftGUI extends GuiContainer {
IPoint mousePos;
private Window window;
@Nullable
private ItemStack draggedItem;
@Override
@@ -47,6 +46,7 @@ public class GuiCraftGUI extends GuiContainer {
super(window.getContainer());
this.mousePos = IPoint.ZERO;
this.window = window;
this.draggedItem = ItemStack.EMPTY;
this.resize(window.getSize());
}
@@ -65,7 +65,6 @@ public class GuiCraftGUI extends GuiContainer {
this.window.initGui();
}
@Nullable
public ItemStack getDraggedItem() {
return this.draggedItem;
}
@@ -213,6 +213,7 @@ public abstract class Window extends TopLevelWidget implements INetwork.RecieveG
}
@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
RenderUtil.setColour(16777215);
if (this.getBackground1() != null) {
@@ -226,7 +227,9 @@ public abstract class Window extends TopLevelWidget implements INetwork.RecieveG
}
@Override
@SideOnly(Side.CLIENT)
public void onUpdateClient() {
super.onUpdateClient();
ControlSlot.highlighting.get(EnumHighlighting.Help).clear();
ControlSlot.shiftClickActive = false;
}
@@ -239,7 +242,6 @@ public abstract class Window extends TopLevelWidget implements INetwork.RecieveG
return this.getPlayer().getGameProfile();
}
@Nullable
public ItemStack getHeldItemStack() {
return this.player.inventory.getItemStack();
}
@@ -13,6 +13,8 @@ import binnie.craftgui.minecraft.MinecraftTooltip;
import binnie.craftgui.minecraft.Window;
import binnie.craftgui.resource.minecraft.CraftGUITexture;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
@@ -22,6 +24,7 @@ public class ControlErrorState extends Control implements ITooltip {
private int type;
@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
Object texture = CraftGUITexture.StateWarning;
if (this.errorState == null) {
@@ -33,6 +36,7 @@ public class ControlErrorState extends Control implements ITooltip {
super.onRenderBackground(guiWidth, guiHeight);
}
@Nullable
public ErrorState getError() {
return Window.get(this).getContainer().getErrorState();
}
@@ -10,11 +10,13 @@ import binnie.craftgui.core.renderer.RenderUtil;
import binnie.craftgui.minecraft.Window;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.opencl.CL;
import javax.annotation.Nullable;
public class ControlItemDisplay extends Control implements ITooltip {
@Nullable
private ItemStack itemStack;
public boolean hastooltip;
private boolean rotating;
@@ -38,14 +40,15 @@ public class ControlItemDisplay extends Control implements ITooltip {
public ControlItemDisplay(final IWidget parent, final int x, final int y, final int size) {
super(parent, x, y, size, size);
this.itemStack = null;
this.itemStack = ItemStack.EMPTY;
this.hastooltip = false;
this.rotating = false;
}
@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
if (this.itemStack == null) {
if (this.itemStack.isEmpty()) {
return;
}
@@ -67,18 +70,18 @@ public class ControlItemDisplay extends Control implements ITooltip {
GlStateManager.enableAlpha();
}
public void setItemStack(@Nullable final ItemStack itemStack) {
public void setItemStack(final ItemStack itemStack) {
this.itemStack = itemStack;
}
@Nullable
public ItemStack getItemStack() {
return this.itemStack;
}
@Override
@SideOnly(Side.CLIENT)
public void getTooltip(final Tooltip tooltip) {
if (this.hastooltip && this.itemStack != null) {
if (this.hastooltip && !this.itemStack.isEmpty()) {
tooltip.add(this.itemStack.getTooltip(((Window) this.getTopParent()).getPlayer(), false));
}
super.getTooltip(tooltip);
@@ -25,6 +25,8 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.opengl.GL11;
import javax.annotation.Nullable;
@@ -75,6 +77,7 @@ public class ControlLiquidTank extends Control implements ITooltip {
}
@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
CraftGUI.render.texture(this.horizontal ? CraftGUITexture.HorizontalLiquidTank : CraftGUITexture.LiquidTank, IPoint.ZERO);
GuiCraftGUI gui = Window.get(this).getGui();
@@ -85,7 +88,7 @@ public class ControlLiquidTank extends Control implements ITooltip {
final int c = -1442840576 + MinecraftTooltip.getOutline(MinecraftTooltip.Type.Error);
RenderUtil.drawGradientRect(this.getArea().inset(1), c, c);
} else if (this.getTopParent().getMousedOverWidget() == this) {
if (gui.getDraggedItem() != null) {
if (!gui.getDraggedItem().isEmpty()) {
RenderUtil.drawGradientRect(this.getArea().inset(1), -1426089575, -1426089575);
} else {
RenderUtil.drawGradientRect(this.getArea().inset(1), -2130706433, -2130706433);
@@ -130,6 +133,7 @@ public class ControlLiquidTank extends Control implements ITooltip {
}
@Override
@SideOnly(Side.CLIENT)
public void onRenderForeground(int guiWidth, int guiHeight) {
CraftGUI.render.texture(this.horizontal ? CraftGUITexture.HorizontalLiquidTankOverlay : CraftGUITexture.LiquidTankOverlay, IPoint.ZERO);
GuiCraftGUI gui = Window.get(this).getGui();
@@ -50,7 +50,7 @@ public class ControlPlayerInventory extends Control {
}
}
public void addItem(@Nullable final ItemStack item) {
public void addItem(final ItemStack item) {
for (final ControlSlot slot : this.slots) {
if (!slot.slot.getHasStack()) {
slot.slot.putStack(item);
@@ -13,6 +13,8 @@ import binnie.craftgui.core.renderer.RenderUtil;
import binnie.craftgui.resource.Texture;
import binnie.craftgui.resource.minecraft.CraftGUITexture;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class ControlSlide extends Control {
private IArea expanded;
@@ -35,6 +37,7 @@ public class ControlSlide extends Control {
}
@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
super.onRenderBackground(guiWidth, guiHeight);
if (this.label != null) {
@@ -119,7 +119,7 @@ public class ControlSlot extends ControlSlotBase {
}
if (!highlighted && this.getTopParent().getMousedOverWidget() == this) {
GuiCraftGUI gui = Window.get(this).getGui();
if (gui.getDraggedItem() != null && !this.slot.isItemValid(gui.getDraggedItem())) {
if (!gui.getDraggedItem().isEmpty() && !this.slot.isItemValid(gui.getDraggedItem())) {
RenderUtil.drawGradientRect(new IArea(1, 1, 16, 16), -1426089575, -1426089575);
} else {
RenderUtil.drawGradientRect(new IArea(1, 1, 16, 16), -2130706433, -2130706433);
@@ -32,9 +32,7 @@ public abstract class ControlSlotBase extends Control implements ITooltip {
this.addSelfEventHandler(new EventWidget.ChangeSize.Handler() {
@Override
public void onEvent(final EventWidget.ChangeSize event) {
if (ControlSlotBase.this.itemDisplay != null) {
ControlSlotBase.this.itemDisplay.setSize(ControlSlotBase.this.getSize().sub(new IPoint(2, 2)));
}
ControlSlotBase.this.itemDisplay.setSize(ControlSlotBase.this.getSize().sub(new IPoint(2, 2)));
}
});
}
@@ -61,14 +59,14 @@ public abstract class ControlSlotBase extends Control implements ITooltip {
}
@Override
@SideOnly(Side.CLIENT)
public void getTooltip(final Tooltip tooltip) {
final ItemStack item = this.getItemStack();
if (item == null) {
if (item.isEmpty()) {
return;
}
tooltip.add(item.getTooltip(((Window) this.getTopParent()).getPlayer(), false));
}
@Nullable
public abstract ItemStack getItemStack();
}
@@ -5,6 +5,8 @@ import binnie.craftgui.controls.tab.ControlTab;
import binnie.craftgui.controls.tab.ControlTabBar;
import binnie.craftgui.core.geometry.IPoint;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
@@ -17,15 +19,15 @@ public class ControlTabIcon<T> extends ControlTab<T> {
this.item.hastooltip = false;
}
@Nullable
public ItemStack getItemStack() {
if (this.value instanceof IItemStackRepresentitive) {
return ((IItemStackRepresentitive) this.value).getItemStackRepresentitive();
}
return null;
return ItemStack.EMPTY;
}
@Override
@SideOnly(Side.CLIENT)
public void onUpdateClient() {
super.onUpdateClient();
this.item.setItemStack(this.getItemStack());
@@ -6,6 +6,6 @@ import forestry.api.genetics.IClassification;
class ControlBranchBoxOption extends ControlTextOption<IClassification> {
public ControlBranchBoxOption(final ControlList<IClassification> controlList, final IClassification option, final int y) {
super(controlList, option, (option.getName() == null) ? option.getScientific() : (option.getName().contains(".") ? option.getScientific() : option.getName()), y);
super(controlList, option, option.getName().contains(".") ? option.getScientific() : option.getName(), y);
}
}
@@ -10,6 +10,7 @@ import binnie.craftgui.events.EventMouse;
import binnie.craftgui.minecraft.Window;
import binnie.craftgui.minecraft.control.ControlItemDisplay;
import com.mojang.authlib.GameProfile;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IAlleleSpecies;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.ISpeciesRoot;
@@ -28,7 +29,8 @@ public class ControlDatabaseIndividualDisplay extends ControlItemDisplay impleme
public void setSpecies(final IAlleleSpecies species, EnumDiscoveryState state) {
final ISpeciesRoot speciesRoot = Binnie.GENETICS.getSpeciesRoot(species);
final BreedingSystem system = Binnie.GENETICS.getSystem(speciesRoot);
final IIndividual ind = system.getSpeciesRoot().templateAsIndividual(system.getSpeciesRoot().getTemplate(species.getUID()));
final IAllele[] template = system.getSpeciesRoot().getTemplate(species);
final IIndividual ind = system.getSpeciesRoot().templateAsIndividual(template);
super.setItemStack(system.getSpeciesRoot().getMemberStack(ind, system.getDefaultType()));
this.species = species;
final GameProfile username = Window.get(this).getUsername();
@@ -13,7 +13,10 @@ import binnie.craftgui.resource.Texture;
import binnie.craftgui.resource.minecraft.CraftGUITextureSheet;
import binnie.craftgui.resource.minecraft.StandardTexture;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IAlleleSpecies;
import forestry.api.genetics.IMutation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
class ControlMutationSymbol extends Control implements ITooltip {
private static Texture MutationPlus = new StandardTexture(2, 94, 16, 16, CraftGUITextureSheet.Controls2);
@@ -23,6 +26,7 @@ class ControlMutationSymbol extends Control implements ITooltip {
private int type;
@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
super.onRenderBackground(guiWidth, guiHeight);
if (this.type == 0) {
@@ -54,15 +58,13 @@ class ControlMutationSymbol extends Control implements ITooltip {
@Override
public void getTooltip(final Tooltip tooltip) {
if (this.type == 1 && this.discovered) {
final IAllele species1 = this.value.getAllele0();
final IAllele species2 = this.value.getAllele1();
final IAlleleSpecies species1 = this.value.getAllele0();
final IAlleleSpecies species2 = this.value.getAllele1();
final BreedingSystem system = ((WindowAbstractDatabase) this.getTopParent()).getBreedingSystem();
final float chance = system.getChance(this.value, Window.get(this).getPlayer(), species1, species2);
tooltip.add("Current Chance - " + chance + "%");
if (this.value.getSpecialConditions() != null) {
for (final String string : this.value.getSpecialConditions()) {
tooltip.add(string);
}
for (final String string : this.value.getSpecialConditions()) {
tooltip.add(string);
}
}
}
@@ -39,8 +39,8 @@ public class PageSpeciesOverview extends PageSpecies {
public void onValueChanged(final IAlleleSpecies species) {
this.controlInd1.setSpecies(species, EnumDiscoveryState.Show);
this.controlInd2.setSpecies(species, EnumDiscoveryState.Show);
final String branchBinomial = (species.getBranch() != null) ? species.getBranch().getScientific() : "<Unknown>";
final String branchName = (species.getBranch() != null) ? species.getBranch().getName() : "Unknown";
final String branchBinomial = species.getBranch().getScientific();
final String branchName = species.getBranch().getName();
this.controlName.setValue(TextFormatting.UNDERLINE + species.getName());
this.controlScientific.setValue(TextFormatting.ITALIC + branchBinomial + " " + species.getBinomial());
this.controlAuthority.setValue(Binnie.LANGUAGE.localise("binniecore.gui.database.discovered") + ": " + TextFormatting.BOLD + species.getAuthority());
@@ -29,6 +29,7 @@ import forestry.api.genetics.IClassification;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.fml.relauncher.Side;
import javax.annotation.Nullable;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
@@ -44,9 +45,13 @@ public abstract class WindowAbstractDatabase extends Window {
private Map<IDatabaseMode, ModeWidgets> modes;
boolean isNEI;
private BreedingSystem system;
@Nullable
private Panel panelInformation;
@Nullable
private Panel panelSearch;
@Nullable
private ControlPages<IDatabaseMode> modePages;
@Nullable
private IAlleleSpecies gotoSpecies;
public void changeMode(final IDatabaseMode mode) {
@@ -1,9 +1,10 @@
package binnie.craftgui.resource.minecraft;
import binnie.core.BinnieCore;
import binnie.core.resource.BinnieResource;
import binnie.core.resource.IBinnieTexture;
import binnie.craftgui.core.CraftGUI;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public enum CraftGUITextureSheet implements IBinnieTexture {
Controls2("controls"),
@@ -22,10 +23,8 @@ public enum CraftGUITextureSheet implements IBinnieTexture {
}
@Override
@SideOnly(Side.CLIENT)
public BinnieResource getTexture() {
if (BinnieCore.getBinnieProxy().isServer()) {
return null;
}
return CraftGUI.resourceManager.getTextureSheet(this.name).getTexture();
}
}
@@ -3,6 +3,8 @@ package binnie.craftgui.resource.minecraft;
import binnie.core.resource.BinnieResource;
import binnie.core.resource.IBinnieTexture;
import binnie.core.resource.ResourceType;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
class ParsedTextureSheet implements IBinnieTexture {
private String name;
@@ -16,6 +18,7 @@ class ParsedTextureSheet implements IBinnieTexture {
}
@Override
@SideOnly(Side.CLIENT)
public BinnieResource getTexture() {
return new BinnieResource(this.modid, ResourceType.GUI, this.path);
}
@@ -38,10 +38,10 @@ public enum EnumHiveFrame implements IHiveFrame, IBeeModifier {
EnumHiveFrame.Clay.logic.setModifier(EnumBeeModifier.Mutation, 0.5f, 0.2f);
EnumHiveFrame.Clay.logic.setModifier(EnumBeeModifier.Production, 0.75f, 0.2f);
EnumHiveFrame.Debug.logic.setModifier(EnumBeeModifier.Lifespan, 1.0E-4f, 1.0E-4f);
GameRegistry.addRecipe(new ItemStack(EnumHiveFrame.Cocoa.item), " c ", "cFc", " c ", 'F', Mods.Forestry.stack("frameImpregnated"), 'c', new ItemStack(Items.DYE, 1, 3));
GameRegistry.addShapelessRecipe(new ItemStack(EnumHiveFrame.Cage.item), Mods.Forestry.stack("frameImpregnated"), Blocks.IRON_BARS);
GameRegistry.addShapelessRecipe(new ItemStack(EnumHiveFrame.Soul.item), Mods.Forestry.stack("frameImpregnated"), Blocks.SOUL_SAND);
GameRegistry.addRecipe(new ItemStack(EnumHiveFrame.Clay.item), " c ", "cFc", " c ", 'F', Mods.Forestry.stack("frameImpregnated"), 'c', Items.CLAY_BALL);
GameRegistry.addRecipe(new ItemStack(EnumHiveFrame.Cocoa.item), " c ", "cFc", " c ", 'F', Mods.Forestry.stack("frame_impregnated"), 'c', new ItemStack(Items.DYE, 1, 3));
GameRegistry.addShapelessRecipe(new ItemStack(EnumHiveFrame.Cage.item), Mods.Forestry.stack("frame_impregnated"), Blocks.IRON_BARS);
GameRegistry.addShapelessRecipe(new ItemStack(EnumHiveFrame.Soul.item), Mods.Forestry.stack("frame_impregnated"), Blocks.SOUL_SAND);
GameRegistry.addRecipe(new ItemStack(EnumHiveFrame.Clay.item), " c ", "cFc", " c ", 'F', Mods.Forestry.stack("frame_impregnated"), 'c', Items.CLAY_BALL);
}
private final Item item;
@@ -67,11 +67,10 @@ public enum EnumHiveFrame implements IHiveFrame, IBeeModifier {
}
@Override
@Nullable
public ItemStack frameUsed(final IBeeHousing house, final ItemStack frame, final IBee queen, final int wear) {
frame.setItemDamage(frame.getItemDamage() + wear);
if (frame.getItemDamage() >= frame.getMaxDamage()) {
return null;
return ItemStack.EMPTY;
}
return frame;
}
@@ -87,7 +86,7 @@ public enum EnumHiveFrame implements IHiveFrame, IBeeModifier {
}
@Override
public float getLifespanModifier(final IBeeGenome genome, final IBeeGenome mate, final float currentModifier) {
public float getLifespanModifier(final IBeeGenome genome, @Nullable final IBeeGenome mate, final float currentModifier) {
return this.logic.getModifier(EnumBeeModifier.Lifespan, currentModifier);
}
@@ -10,6 +10,8 @@ import forestry.api.core.IModelManager;
import forestry.api.core.Tabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
@@ -30,6 +32,7 @@ public class ItemHiveFrame extends Item implements IHiveFrame, IBeeModifier, IIt
}
@Override
@SideOnly(Side.CLIENT)
public void registerModel(Item item, IModelManager manager) {
manager.registerItemModel(item, 0, "frames/" + getRegistryName().getResourcePath());
}
@@ -45,7 +48,7 @@ public class ItemHiveFrame extends Item implements IHiveFrame, IBeeModifier, IIt
}
@Override
public float getLifespanModifier(final IBeeGenome genome, final IBeeGenome mate, final float currentModifier) {
public float getLifespanModifier(final IBeeGenome genome, @Nullable final IBeeGenome mate, final float currentModifier) {
return this.frame.getLifespanModifier(genome, mate, currentModifier);
}
@@ -55,11 +58,10 @@ public class ItemHiveFrame extends Item implements IHiveFrame, IBeeModifier, IIt
}
@Override
@Nullable
public ItemStack frameUsed(final IBeeHousing housing, final ItemStack frame, final IBee queen, final int wear) {
frame.setItemDamage(frame.getItemDamage() + wear);
if (frame.getItemDamage() >= frame.getMaxDamage()) {
return null;
return ItemStack.EMPTY;
}
return frame;
}
@@ -50,7 +50,7 @@ public class ModuleApiary implements IInitializable {
public void postInit() {
EnumHiveFrame.init();
Block alveary = Mods.Forestry.block("alveary.plain");
Item thermionicTubes = Mods.Forestry.item("thermionicTubes");
Item thermionicTubes = Mods.Forestry.item("thermionic_tubes");
Item chipsets = Mods.Forestry.item("chipsets");
GameRegistry.addRecipe(AlvearyMachine.Mutator.get(1), "g g", " a ", "t t", 'g', Items.GOLD_INGOT, 'a', alveary, 't', new ItemStack(thermionicTubes, 1, 5));
@@ -129,7 +129,7 @@ public class TileExtraBeeAlveary extends TileEntityMachine implements IAlvearyCo
}
@Override
public float getLifespanModifier(final IBeeGenome genome, final IBeeGenome mate, final float currentModifier) {
public float getLifespanModifier(final IBeeGenome genome, @Nullable final IBeeGenome mate, final float currentModifier) {
return (this.getBeeModifier() == null) ? 1.0f : this.getBeeModifier().getLifespanModifier(genome, mate, currentModifier);
}
@@ -10,10 +10,14 @@ import binnie.extrabees.apiary.ComponentExtraBeeGUI;
import binnie.extrabees.apiary.TileExtraBeeAlveary;
import binnie.extrabees.core.ExtraBeeGUID;
import binnie.extrabees.core.ExtraBeeTexture;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeListener;
import forestry.api.apiculture.IBeeModifier;
import forestry.api.apiculture.IBeeRoot;
import forestry.api.apiculture.IHiveFrame;
import forestry.api.multiblock.IAlvearyController;
import forestry.api.multiblock.IMultiblockLogicAlveary;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
@@ -43,7 +47,7 @@ public class AlvearyFrame {
@Override
public boolean isValid(final ItemStack itemStack) {
return itemStack != null && itemStack.getItem() instanceof IHiveFrame;
return !itemStack.isEmpty() && itemStack.getItem() instanceof IHiveFrame;
}
@Override
@@ -59,18 +63,27 @@ public class AlvearyFrame {
@Override
public void wearOutEquipment(final int amount) {
if (this.getHiveFrame() == null) {
return;
IHiveFrame hiveFrame = this.getHiveFrame();
if (hiveFrame != null) {
final World world = this.getMachine().getTileEntity().getWorld();
IBeeRoot beeRoot = Binnie.GENETICS.getBeeRoot();
IMultiblockLogicAlveary multiblockLogic = ((TileExtraBeeAlveary) this.getMachine().getTileEntity()).getMultiblockLogic();
IAlvearyController alvearyController = multiblockLogic.getController();
ItemStack queenStack = alvearyController.getBeeInventory().getQueen();
IBee queen = beeRoot.getMember(queenStack);
if (queen != null) {
final int wear = Math.round(amount * 5 * beeRoot.getBeekeepingMode(world).getWearModifier());
ItemStack frame = this.getInventory().getStackInSlot(AlvearyFrame.slotFrame);
ItemStack frameUsed = hiveFrame.frameUsed(alvearyController, frame, queen, wear);
this.getInventory().setInventorySlotContents(AlvearyFrame.slotFrame, frameUsed);
}
}
final World world = this.getMachine().getTileEntity().getWorld();
final int wear = Math.round(amount * 5 * Binnie.GENETICS.getBeeRoot().getBeekeepingMode(world).getWearModifier());
this.getInventory().setInventorySlotContents(AlvearyFrame.slotFrame, this.getHiveFrame().frameUsed(((TileExtraBeeAlveary) this.getMachine().getTileEntity()).getMultiblockLogic().getController(), this.getInventory().getStackInSlot(AlvearyFrame.slotFrame), null, wear));
}
@Nullable
public IHiveFrame getHiveFrame() {
ItemStack stackInSlot = this.getInventory().getStackInSlot(AlvearyFrame.slotFrame);
if (stackInSlot != null) {
if (!stackInSlot.isEmpty()) {
return (IHiveFrame) stackInSlot.getItem();
}
return null;
@@ -87,7 +100,7 @@ public class AlvearyFrame {
}
@Override
public float getLifespanModifier(final IBeeGenome genome, final IBeeGenome mate, final float currentModifier) {
public float getLifespanModifier(final IBeeGenome genome, @Nullable final IBeeGenome mate, final float currentModifier) {
return (this.getHiveFrame() == null) ? 1.0f : this.getHiveFrame().getBeeModifier().getLifespanModifier(genome, mate, currentModifier);
}
@@ -70,7 +70,7 @@ public class AlvearyHatchery {
final IBeeHousing house = ((TileExtraBeeAlveary) tile).getMultiblockLogic().getController();
if (house != null && !house.getErrorLogic().hasErrors()) {
final ItemStack queenStack = house.getBeeInventory().getQueen();
final IBee queen = (queenStack == null) ? null : Binnie.GENETICS.getBeeRoot().getMember(queenStack);
final IBee queen = (queenStack.isEmpty()) ? null : Binnie.GENETICS.getBeeRoot().getMember(queenStack);
if (queen != null) {
final ItemStack larvae = Binnie.GENETICS.getBeeRoot().getMemberStack(Binnie.GENETICS.getBeeRoot().getBee(queen.getGenome()), EnumBeeType.LARVAE);
new TransferRequest(larvae, this.getInventory()).transfer(true);
@@ -28,8 +28,8 @@ public class AlvearyMutator {
return getMutationMult(item) > 0.0f;
}
public static float getMutationMult(@Nullable final ItemStack item) {
if (item == null) {
public static float getMutationMult(final ItemStack item) {
if (item.isEmpty()) {
return 1.0f;
}
for (final ItemStack comp : AlvearyMutator.mutations.keySet()) {
@@ -40,8 +40,8 @@ public class AlvearyMutator {
return 1.0f;
}
public static void addMutationItem(@Nullable final ItemStack item, final float chance) {
if (item == null) {
public static void addMutationItem(final ItemStack item, final float chance) {
if (item.isEmpty()) {
return;
}
AlvearyMutator.mutations.put(item, chance);
@@ -52,7 +52,7 @@ public class AlvearyStimulator {
@Override
public boolean isValid(final ItemStack itemStack) {
return itemStack != null && ChipsetManager.circuitRegistry.isChipset(itemStack);
return !itemStack.isEmpty() && ChipsetManager.circuitRegistry.isChipset(itemStack);
}
@Override
@@ -241,7 +241,7 @@ public class AlvearyStimulator {
CircuitType type;
public StimulatorCircuit(final CircuitType type, final ICircuitLayout layout) {
super("stimulator." + type.toString().toLowerCase(), 4, layout, Mods.Forestry.item("thermionicTubes"), type.recipe);
super("stimulator." + type.toString().toLowerCase(), 4, layout, Mods.Forestry.item("thermionic_tubes"), type.recipe);
this.type = type;
}
@@ -107,7 +107,7 @@ public enum ExtraBeeItems implements IItemMiscProvider {
if (woodGear != null) {
gear = new ItemStack(woodGear, 1);
}
RecipeManagers.carpenterManager.addRecipe(100, Binnie.LIQUID.getFluidStack("for.honey", 500), null, ExtraBeeItems.ScentedGear.get(1), " j ", "bgb", " p ", 'j', Mods.Forestry.item("royalJelly"), 'b', Mods.Forestry.item("beeswax"), 'p', Mods.Forestry.item("pollen"), 'g', gear);
RecipeManagers.carpenterManager.addRecipe(100, Binnie.LIQUID.getFluidStack("for.honey", 500), ItemStack.EMPTY, ExtraBeeItems.ScentedGear.get(1), " j ", "bgb", " p ", 'j', Mods.Forestry.item("royal_jelly"), 'b', Mods.Forestry.item("beeswax"), 'p', Mods.Forestry.item("pollen"), 'g', gear);
}
ExtraBeeItems(String name, String modelPath) {
@@ -5,6 +5,8 @@ import binnie.core.resource.BinnieResource;
import binnie.core.resource.IBinnieTexture;
import binnie.core.resource.ResourceType;
import binnie.extrabees.ExtraBees;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public enum ExtraBeeTexture implements IBinnieTexture {
AlvearyMutator(ResourceType.Tile, "alveary/AlvearyMutator"),
@@ -29,6 +31,7 @@ public enum ExtraBeeTexture implements IBinnieTexture {
}
@Override
@SideOnly(Side.CLIENT)
public BinnieResource getTexture() {
return Binnie.RESOURCE.getPNG(ExtraBees.instance, this.type, this.texture);
}
@@ -2,6 +2,7 @@ package binnie.extrabees.genetics;
import binnie.Binnie;
import binnie.core.genetics.ForestryAllele;
import com.google.common.base.Preconditions;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBeeGenome;
@@ -25,9 +26,7 @@ public class ExtraBeeMutation implements IBeeMutation {
public static List<IBeeMutation> mutations = new ArrayList<>();
@Nullable
MutationRequirement req;
@Nullable
IAlleleBeeSpecies species0;
@Nullable
IAlleleBeeSpecies species1;
IAllele[] template;
int chance;
@@ -204,18 +203,16 @@ public class ExtraBeeMutation implements IBeeMutation {
}
public ExtraBeeMutation(final IAlleleBeeSpecies allele0, final IAlleleBeeSpecies allele1, final IAllele[] mutation, final int chance, @Nullable final MutationRequirement req) {
this.species0 = null;
this.species1 = null;
this.template = new IAllele[0];
Preconditions.checkNotNull(allele0);
Preconditions.checkNotNull(allele1);
Preconditions.checkNotNull(mutation);
this.chance = 80;
this.chance = chance;
this.req = req;
this.species0 = allele0;
this.species1 = allele1;
this.template = mutation;
if (this.species0 != null && this.species1 != null && this.template != null) {
ExtraBeeMutation.mutations.add(this);
}
ExtraBeeMutation.mutations.add(this);
}
@Override
@@ -255,10 +252,6 @@ public class ExtraBeeMutation implements IBeeMutation {
@Override
public float getChance(final IBeeHousing housing, final IAlleleBeeSpecies allele0, final IAlleleBeeSpecies allele1, final IBeeGenome genome0, final IBeeGenome genome1) {
if (this.species0 == null || this.species1 == null || allele0 == null || allele1 == null) {
return 0.0f;
}
final World world = housing.getWorldObj();
final Biome biome = housing.getBiome();
if (this.req != null && !this.req.fufilled(housing, allele0, allele1, genome0, genome1)) {
@@ -85,7 +85,7 @@ public enum ExtraBeesBranch implements IClassification {
}
}
public static void doInit() {
public static void setSpeciesBranches() {
final IClassification frozenBranch = AlleleManager.alleleRegistry.getClassification("genus.bees.frozen");
if (frozenBranch != null) {
frozenBranch.addMemberSpecies(ExtraBeesSpecies.ARTIC);
@@ -301,8 +301,8 @@ public enum ExtraBeesSpecies implements IAlleleBeeSpecies {
}
}
public void addProduct(@Nullable final ItemStack product, final Float chance) {
if (product == null) {
public void addProduct(final ItemStack product, final Float chance) {
if (product.isEmpty()) {
this.setState(State.Inactive);
} else {
this.products.put(product, chance);
@@ -319,8 +319,8 @@ public enum ExtraBeesSpecies implements IAlleleBeeSpecies {
}
}
public void addSpecialty(@Nullable final ItemStack product, final Float chance) {
if (product == null) {
public void addSpecialty(final ItemStack product, final Float chance) {
if (product.isEmpty()) {
this.setState(State.Inactive);
} else {
this.specialties.put(product, chance);
@@ -1064,7 +1064,7 @@ public enum ExtraBeesSpecies implements IAlleleBeeSpecies {
@Override
public float getResearchSuitability(final ItemStack itemstack) {
if (itemstack == null) {
if (itemstack.isEmpty()) {
return 0.0f;
}
for (final ItemStack stack : this.products.keySet()) {
@@ -1080,13 +1080,13 @@ public enum ExtraBeesSpecies implements IAlleleBeeSpecies {
if (itemstack.getItem() == Items.GLASS_BOTTLE) {
return 0.9f;
}
if (itemstack.getItem() == Mods.Forestry.item("honeyDrop")) {
if (itemstack.getItem() == Mods.Forestry.item("honey_drop")) {
return 0.5f;
}
if (itemstack.getItem() == Mods.Forestry.item("honeydew")) {
return 0.7f;
}
if (itemstack.getItem() == Mods.Forestry.item("beeComb")) {
if (itemstack.getItem() == Mods.Forestry.item("bee_comb")) {
return 0.4f;
}
if (AlleleManager.alleleRegistry.isIndividual(itemstack)) {
@@ -19,6 +19,7 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
public class ModuleGenetics implements IInitializable {
@Override
public void preInit() {
ExtraBeesBranch.setSpeciesBranches();
for (final ExtraBeesSpecies species : ExtraBeesSpecies.values()) {
AlleleManager.alleleRegistry.registerAllele(species);
}
@@ -34,7 +35,6 @@ public class ModuleGenetics implements IInitializable {
ExtraBeesFlowers.doInit();
ExtraBeesSpecies.doInit();
ExtraBeeMutation.doInit();
ExtraBeesBranch.doInit();
}
@Override
@@ -47,11 +47,11 @@ public class ModuleGenetics implements IInitializable {
++ebSpeciesCount;
}
}
RecipeManagers.carpenterManager.addRecipe(100, Binnie.LIQUID.getFluidStack("water", 2000), null, new ItemStack(ExtraBees.dictionary), "X#X", "YEY", "RDR", '#', Blocks.GLASS_PANE, 'X', Items.GOLD_INGOT, 'Y', "ingotTin", 'R', Items.REDSTONE, 'D', Items.DIAMOND, 'E', Items.EMERALD);
RecipeManagers.carpenterManager.addRecipe(100, Binnie.LIQUID.getFluidStack("water", 2000), ItemStack.EMPTY, new ItemStack(ExtraBees.dictionary), "X#X", "YEY", "RDR", '#', Blocks.GLASS_PANE, 'X', Items.GOLD_INGOT, 'Y', "ingotTin", 'R', Items.REDSTONE, 'D', Items.DIAMOND, 'E', Items.EMERALD);
}
public static IGenome getGenome(final IAlleleBeeSpecies allele0) {
return Binnie.GENETICS.getBeeRoot().templateAsGenome(Binnie.GENETICS.getBeeRoot().getTemplate(allele0.getUID()));
return Binnie.GENETICS.getBeeRoot().templateAsGenome(Binnie.GENETICS.getBeeRoot().getTemplate(allele0));
}
// public static ItemStack getBeeIcon(final IAlleleBeeSpecies species) {
@@ -60,7 +60,7 @@ public class ControlBiomes extends Control implements ITooltip {
if (species == null) {
return;
}
final IBeeGenome genome = Binnie.GENETICS.getBeeRoot().templateAsGenome(Binnie.GENETICS.getBeeRoot().getTemplate(species.getUID()));
final IBeeGenome genome = Binnie.GENETICS.getBeeRoot().templateAsGenome(Binnie.GENETICS.getBeeRoot().getTemplate(species));
final IBee bee = Binnie.GENETICS.getBeeRoot().getBee(genome);
}
}
@@ -15,6 +15,7 @@ import forestry.api.apiculture.IBeeGenome;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.genetics.EnumTolerance;
import forestry.api.genetics.IAllele;
import java.util.ArrayList;
import java.util.List;
@@ -90,13 +91,14 @@ public class ControlClimateBar extends Control implements ITooltip {
}
int main;
EnumTolerance tolerance;
final IAllele[] template = Binnie.GENETICS.getBeeRoot().getTemplate(species);
final IBeeGenome genome = Binnie.GENETICS.getBeeRoot().templateAsGenome(template);
if (!this.isHumidity) {
main = species.getTemperature().ordinal() - 1;
final IBeeGenome genome = Binnie.GENETICS.getBeeRoot().templateAsGenome(Binnie.GENETICS.getBeeRoot().getTemplate(species.getUID()));
tolerance = genome.getToleranceTemp();
} else {
main = species.getHumidity().ordinal();
final IBeeGenome genome = Binnie.GENETICS.getBeeRoot().templateAsGenome(Binnie.GENETICS.getBeeRoot().getTemplate(species.getUID()));
tolerance = genome.getToleranceHumid();
}
this.tolerated.add(main);
@@ -15,10 +15,13 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraftforge.fml.relauncher.Side;
import javax.annotation.Nullable;
public class WindowPunnettSquare extends Window {
ControlSlot bee1;
ControlSlot bee2;
ControlPunnett punnett;
@Nullable
ISpeciesRoot root;
public static Window create(final EntityPlayer player, final IInventory inventory, final Side side) {
@@ -144,15 +144,15 @@ public enum EnumHoneyComb implements IItemEnum {
return ExtraBees.proxy.localise("item.comb." + this.name().toLowerCase());
}
public boolean addProduct(@Nullable final ItemStack item, final Float chance) {
if (item == null) {
public boolean addProduct(final ItemStack item, final Float chance) {
if (item.isEmpty()) {
return false;
}
this.products.put(item.copy(), chance);
return true;
}
public void tryAddProduct(@Nullable final ItemStack item, final Float chance) {
public void tryAddProduct(final ItemStack item, final Float chance) {
this.active = this.addProduct(item, chance);
}
@@ -25,7 +25,7 @@ public class ItemHoneyComb extends ItemProduct implements IColoredItem {
public static void addSubtypes() {
final ItemStack beeswax = Mods.Forestry.stack("beeswax");
final ItemStack honeyDrop = Mods.Forestry.stack("honeyDrop");
final ItemStack honeyDrop = Mods.Forestry.stack("honey_drop");
OreDictionary.registerOre("ingotIron", Items.IRON_INGOT);
OreDictionary.registerOre("ingotGold", Items.GOLD_INGOT);
OreDictionary.registerOre("gemDiamond", Items.DIAMOND);
@@ -150,7 +150,7 @@ public class ItemHoneyComb extends ItemProduct implements IColoredItem {
EnumHoneyComb.SALTPETER.addProduct(honeyDrop, 0.25f);
EnumHoneyComb.SALTPETER.tryAddProduct(getOreDictionary("dustSaltpeter"), 1.00f);
EnumHoneyComb.COMPOST.addProduct(honeyDrop, 0.25f);
EnumHoneyComb.COMPOST.tryAddProduct(Mods.Forestry.stack("fertilizerBio"), 1.00f);
EnumHoneyComb.COMPOST.tryAddProduct(Mods.Forestry.stack("fertilizer_bio"), 1.00f);
EnumHoneyComb.SAWDUST.addProduct(honeyDrop, 0.25f);
if (!OreDictionary.getOres("dustSawdust").isEmpty()) {
EnumHoneyComb.SAWDUST.tryAddProduct(OreDictionary.getOres("dustSawdust").get(0), 1.00f);
@@ -220,12 +220,11 @@ public class ItemHoneyComb extends ItemProduct implements IColoredItem {
}
}
@Nullable
private static ItemStack getOreDictionary(final String string) {
if (OreDictionary.getOres(string).size() > 0) {
return OreDictionary.getOres(string).get(0);
}
return null;
return ItemStack.EMPTY;
}
@SideOnly(Side.CLIENT)
@@ -258,7 +257,7 @@ public class ItemHoneyComb extends ItemProduct implements IColoredItem {
QUARTZ;
public ItemStack get() {
return Mods.Forestry.stack("beeCombs", 1, this.ordinal());
return Mods.Forestry.stack("bee_combs", 1, this.ordinal());
}
}
}
@@ -42,7 +42,7 @@ public class ModuleProducts implements IInitializable {
@Override
public void postInit() {
GameRegistry.addRecipe(new ItemStack(ExtraBees.honeyCrystalEmpty), "#@#", "@#@", "#@#", '@', Mods.Forestry.stack("honeyDrop"), '#', EnumHoneyDrop.ENERGY.get(1));
GameRegistry.addRecipe(new ItemStack(ExtraBees.honeyCrystalEmpty), "#@#", "@#@", "#@#", '@', Mods.Forestry.stack("honey_drop"), '#', EnumHoneyDrop.ENERGY.get(1));
for (final EnumHoneyComb info : EnumHoneyComb.values()) {
info.addRecipe();
}
@@ -9,7 +9,10 @@ import net.minecraft.block.Block;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ExtraBeesProxyClient extends ExtraBeesProxy {
public static ModelManager modelManager = new ModelManager(Constants.EXTRA_BEES_MOD_ID);
@@ -2,16 +2,21 @@ package binnie.extratrees.api;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
public interface IDesignSystem {
@Nullable
@SideOnly(Side.CLIENT)
TextureAtlasSprite getPrimarySprite(final IPattern pattern);
@Nullable
@SideOnly(Side.CLIENT)
TextureAtlasSprite getSecondarySprite(final IPattern pattern);
@SideOnly(Side.CLIENT)
void registerSprites();
IDesignMaterial getDefaultMaterial();
Loaded 100 of 185 files, more files were not shown because too many files have changed in this diff. Show more