mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-18 11:29:23 +00:00
More null annotations
This commit is contained in:
1 parent
da8a833485
commit
a5daa93bf1
163 files changed
+952
-849
No files matched your search
@@ -261,14 +261,14 @@ public class Botany extends AbstractMod {
|
||||
return;
|
||||
}
|
||||
|
||||
if (player != null && heldItem != null) {
|
||||
if (heldItem != null) {
|
||||
Block block = world.getBlockState(pos).getBlock();
|
||||
int py = -1;
|
||||
if (block instanceof IBlockSoil && (world.isAirBlock(pos.up()) || block.isReplaceable(world, pos))) {
|
||||
py = 1;
|
||||
}
|
||||
if (py >= 0) {
|
||||
IFlower flower = BotanyCore.getFlowerRoot().getConversion(event.getEntityPlayer().getHeldItemMainhand());
|
||||
IFlower flower = BotanyCore.getFlowerRoot().getConversion(heldItem);
|
||||
if (flower != null && Gardening.plant(world, pos.add(0, py, 0), flower, player.getGameProfile()) && !player.capabilities.isCreativeMode) {
|
||||
--heldItem.stackSize;
|
||||
}
|
||||
|
||||
@@ -4,18 +4,17 @@ import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public enum EnumAcidity implements IStringSerializable {
|
||||
Acid(TextFormatting.RED),
|
||||
Neutral,
|
||||
Neutral(null),
|
||||
Alkaline(TextFormatting.AQUA);
|
||||
|
||||
@Nullable
|
||||
final TextFormatting color;
|
||||
|
||||
EnumAcidity() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
EnumAcidity(TextFormatting color) {
|
||||
EnumAcidity(@Nullable TextFormatting color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,18 +4,17 @@ import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public enum EnumMoisture implements IStringSerializable {
|
||||
Dry(TextFormatting.YELLOW),
|
||||
Normal,
|
||||
Normal(null),
|
||||
Damp(TextFormatting.DARK_BLUE);
|
||||
|
||||
@Nullable
|
||||
final TextFormatting color;
|
||||
|
||||
EnumMoisture() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
EnumMoisture(TextFormatting color) {
|
||||
EnumMoisture(@Nullable TextFormatting color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Locale;
|
||||
|
||||
public enum EnumSoilType implements IStringSerializable {
|
||||
@@ -11,13 +12,10 @@ public enum EnumSoilType implements IStringSerializable {
|
||||
LOAM(TextFormatting.GOLD),
|
||||
FLOWERBED(TextFormatting.LIGHT_PURPLE);
|
||||
|
||||
@Nullable
|
||||
final TextFormatting color;
|
||||
|
||||
EnumSoilType() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
EnumSoilType(TextFormatting color) {
|
||||
EnumSoilType(@Nullable TextFormatting color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
|
||||
@@ -167,6 +167,7 @@ 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);
|
||||
}
|
||||
|
||||
@@ -90,6 +90,7 @@ public class CeramicDesignSystem implements IDesignSystem {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public IDesignMaterial getMaterial(final ItemStack itemStack) {
|
||||
return (itemStack.getItem() == Item.getItemFromBlock(Botany.ceramic)) ? this.getMaterial(itemStack.getItemDamage()) : null;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ public class CeramicTileRecipe implements IRecipe {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ItemStack getCraftingResult(final InventoryCrafting inv) {
|
||||
final Item ceramicBlock = Item.getItemFromBlock(Botany.ceramic);
|
||||
final Item ceramicTile = Item.getItemFromBlock(Botany.ceramicTile);
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class PigmentRecipe implements IRecipe {
|
||||
@Override
|
||||
@@ -18,11 +19,13 @@ public class PigmentRecipe implements IRecipe {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ItemStack getRecipeOutput() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ItemStack getCraftingResult(final InventoryCrafting crafting) {
|
||||
int n = 0;
|
||||
ItemStack stack = null;
|
||||
|
||||
@@ -20,12 +20,10 @@ public class ItemCeramicBrick extends ItemBlock implements IColoredItem {
|
||||
@Override
|
||||
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
|
||||
CeramicBrickPair ceramic = new CeramicBrickPair(stack.getItemDamage());
|
||||
if(ceramic != null){
|
||||
if (tintIndex == 1) {
|
||||
return ceramic.colorFirst.getColor(false);
|
||||
}else if (tintIndex == 2) {
|
||||
return ceramic.colorSecond.getColor(false);
|
||||
}
|
||||
if (tintIndex == 1) {
|
||||
return ceramic.colorFirst.getColor(false);
|
||||
} else if (tintIndex == 2) {
|
||||
return ceramic.colorSecond.getColor(false);
|
||||
}
|
||||
return 16777215;
|
||||
}
|
||||
|
||||
@@ -7,9 +7,12 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class TileCeramicBrick extends TileEntity{
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class TileCeramicBrick extends TileEntity{
|
||||
@Nullable
|
||||
private EnumFlowerColor colorFirst;
|
||||
@Nullable
|
||||
private EnumFlowerColor colorSecond;
|
||||
|
||||
public void setColors(EnumFlowerColor colorFirst, EnumFlowerColor colorSecond) {
|
||||
|
||||
@@ -35,6 +35,7 @@ import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
@@ -68,6 +69,7 @@ public class BlockFlower extends BlockContainer implements IColoredBlock, IState
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos) {
|
||||
return null;
|
||||
}
|
||||
@@ -113,7 +115,9 @@ public class BlockFlower extends BlockContainer implements IColoredBlock, IState
|
||||
if (!BinnieCore.getBinnieProxy().isSimulating(world)) {
|
||||
if (flower != null && flower instanceof TileEntityFlower) {
|
||||
final IFlower f = BotanyCore.getFlowerRoot().getMember(stack);
|
||||
((TileEntityFlower) flower).setRender(new TileEntityFlower.RenderInfo(f, (TileEntityFlower) flower));
|
||||
if (f != null) {
|
||||
((TileEntityFlower) flower).setRender(new TileEntityFlower.RenderInfo(f, (TileEntityFlower) flower));
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import binnie.botany.api.IFlowerType;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
import binnie.botany.genetics.Flower;
|
||||
import binnie.core.BinnieCore;
|
||||
import com.google.common.base.Preconditions;
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
@@ -29,6 +30,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
@@ -40,6 +42,7 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemBotany extends Item implements IColoredItem, IItemModelRegister {
|
||||
@@ -77,7 +80,7 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister
|
||||
return false;
|
||||
}
|
||||
final IIndividual individual = this.getIndividual(itemstack);
|
||||
return individual != null && individual.getGenome() != null && individual.hasEffect();
|
||||
return individual != null && individual.hasEffect();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -86,7 +89,7 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister
|
||||
return;
|
||||
}
|
||||
IFlower individual = (IFlower) this.getIndividual(itemStack);
|
||||
if (individual == null || individual.getGenome() == null) {
|
||||
if (individual == null) {
|
||||
list.add(TextFormatting.DARK_RED + Binnie.LANGUAGE.localise("botany.flower.destroy"));
|
||||
return;
|
||||
}
|
||||
@@ -114,8 +117,13 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected IIndividual getIndividual(final ItemStack itemstack) {
|
||||
return new Flower(itemstack.getTagCompound());
|
||||
NBTTagCompound tagCompound = itemstack.getTagCompound();
|
||||
if (tagCompound == null) {
|
||||
return null;
|
||||
}
|
||||
return new Flower(tagCompound);
|
||||
}
|
||||
|
||||
private IAlleleFlowerSpecies getPrimarySpecies(final ItemStack itemstack) {
|
||||
@@ -132,7 +140,7 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister
|
||||
return Binnie.LANGUAGE.localise("item.botany.flower.corrupted.name");
|
||||
}
|
||||
IIndividual individual = this.getIndividual(itemstack);
|
||||
if (individual != null && individual.getGenome() != null) {
|
||||
if (individual != null) {
|
||||
return individual.getDisplayName() + (!tag.isEmpty() ? " " + Binnie.LANGUAGE.localise("item.botany." + tag + ".name") : "");
|
||||
}
|
||||
return Binnie.LANGUAGE.localise("item.botany.flower.corrupted.name");
|
||||
@@ -155,7 +163,7 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister
|
||||
@Override
|
||||
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
|
||||
IFlower flower = BotanyCore.getFlowerRoot().getMember(stack);
|
||||
if (flower == null || flower.getGenome() == null) {
|
||||
if (flower == null) {
|
||||
return 16777215;
|
||||
}
|
||||
return (tintIndex == 0) ? flower.getGenome().getStemColor().getColor(flower.isWilted()) : ((tintIndex == 1) ? flower.getGenome().getPrimaryColor().getColor(flower.isWilted()) : flower.getGenome().getSecondaryColor().getColor(flower.isWilted()));
|
||||
@@ -175,9 +183,7 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation(ItemStack stack) {
|
||||
IFlower flower = BotanyCore.getFlowerRoot().getMember(stack);
|
||||
if (flower == null || flower.getGenome() == null || flower.getGenome().getPrimary() == null) {
|
||||
return null;
|
||||
}
|
||||
Preconditions.checkNotNull(flower);
|
||||
IAlleleFlowerSpecies flowerSpecies = flower.getGenome().getPrimary();
|
||||
IFlowerType flowerType = flowerSpecies.getType();
|
||||
return flowerSpecies.getFlowerModel(type, flower.hasFlowered());
|
||||
|
||||
@@ -12,6 +12,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemInsulatedTube extends ItemCore implements IColoredItem {
|
||||
@@ -147,7 +148,7 @@ public class ItemInsulatedTube extends ItemCore implements IColoredItem {
|
||||
return new ItemStack(Blocks.STONE);
|
||||
}
|
||||
default: {
|
||||
return null;
|
||||
throw new IllegalStateException("Unknown insulated tube type: " + this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,11 +111,12 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
return super.writeToNBT(nbtCompound);
|
||||
}
|
||||
|
||||
public void create(final ItemStack stack, final GameProfile owner) {
|
||||
this.create(BotanyCore.getFlowerRoot().getMember(stack), owner);
|
||||
public void create(final ItemStack stack, @Nullable final GameProfile owner) {
|
||||
IFlower flower = BotanyCore.getFlowerRoot().getMember(stack);
|
||||
this.create(flower, owner);
|
||||
}
|
||||
|
||||
public void create(final IFlower flower, final GameProfile owner) {
|
||||
public void create(final IFlower flower, @Nullable final GameProfile owner) {
|
||||
this.flower = flower;
|
||||
if (this.flower.getAge() == 0) {
|
||||
this.flower.setFlowered(false);
|
||||
@@ -130,6 +131,7 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public IIndividual getPollen() {
|
||||
return this.getFlower();
|
||||
}
|
||||
@@ -323,6 +325,7 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ItemStack getItemStack() {
|
||||
if (this.flower == null) {
|
||||
return null;
|
||||
@@ -330,6 +333,7 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
return Binnie.GENETICS.getFlowerRoot().getMemberStack(this.getFlower(), EnumFlowerStage.getStage(getFlower()));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private TileEntityFlower getRoot() {
|
||||
if (this.getSection() == 0) {
|
||||
return null;
|
||||
@@ -600,6 +604,7 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
public void setErrorState(final IErrorState state) {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public IErrorState getErrorState() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import net.minecraftforge.oredict.RecipeSorter;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -158,18 +159,18 @@ public class ModuleGardening implements IInitializable {
|
||||
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(Botany.pigment, 2, EnumFlowerColor.Black.ordinal()), "pigment", "pigment", "dyeBlack"));
|
||||
ModuleGardening.queuedAcidFertilisers.put(BotanyItems.SulphurPowder.get(1), 1);
|
||||
ModuleGardening.queuedAcidFertilisers.put(BotanyItems.MulchPowder.get(1), 1);
|
||||
ModuleGardening.queuedAcidFertilisers.put(new ItemStack(GameRegistry.findItem("forestry", "mulch")), 2);
|
||||
ModuleGardening.queuedAcidFertilisers.put(Mods.Forestry.stack("mulch"), 2);
|
||||
for (final ItemStack stack : OreDictionary.getOres("dustSulfur")) {
|
||||
ModuleGardening.queuedAcidFertilisers.put(stack, 2);
|
||||
}
|
||||
ModuleGardening.queuedAlkalineFertilisers.put(BotanyItems.AshPowder.get(1), 1);
|
||||
ModuleGardening.queuedAlkalineFertilisers.put(BotanyItems.PulpPowder.get(1), 1);
|
||||
ModuleGardening.queuedAlkalineFertilisers.put(new ItemStack(GameRegistry.findItem("forestry", "ash")), 2);
|
||||
ModuleGardening.queuedAlkalineFertilisers.put(new ItemStack(GameRegistry.findItem("forestry", "woodPulp")), 2);
|
||||
ModuleGardening.queuedAlkalineFertilisers.put(Mods.Forestry.stack("ash"), 2);
|
||||
ModuleGardening.queuedAlkalineFertilisers.put(Mods.Forestry.stack( "woodPulp"), 2);
|
||||
ModuleGardening.queuedNutrientFertilisers.put(BotanyItems.CompostPowder.get(1), 1);
|
||||
ModuleGardening.queuedNutrientFertilisers.put(BotanyItems.FertiliserPowder.get(1), 1);
|
||||
ModuleGardening.queuedNutrientFertilisers.put(new ItemStack(GameRegistry.findItem("forestry", "fertilizerBio")), 2);
|
||||
ModuleGardening.queuedNutrientFertilisers.put(new ItemStack(GameRegistry.findItem("forestry", "fertilizerCompound")), 2);
|
||||
ModuleGardening.queuedNutrientFertilisers.put(Mods.Forestry.stack( "fertilizerBio"), 2);
|
||||
ModuleGardening.queuedNutrientFertilisers.put(Mods.Forestry.stack("fertilizerCompound"), 2);
|
||||
for (final Map.Entry<ItemStack, Integer> entry : ModuleGardening.queuedAcidFertilisers.entrySet()) {
|
||||
this.addAcidFertiliser(entry.getKey(), entry.getValue());
|
||||
}
|
||||
@@ -192,17 +193,15 @@ 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 null;
|
||||
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 new ItemStack(Gardening.getSoilBlock(EnumSoilType.values()[type]), 1, BlockSoil.getMeta(EnumAcidity.values()[pH], EnumMoisture.values()[moisture]));
|
||||
return null;
|
||||
}
|
||||
|
||||
private void addAcidFertiliser(final ItemStack stack, final int strengthMax) {
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
Gardening.fertiliserAcid.put(stack, strengthMax);
|
||||
for (int moisture = 0; moisture < 3; ++moisture) {
|
||||
for (int pH = 0; pH < 3; ++pH) {
|
||||
@@ -211,7 +210,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 (start != null && end != null) {
|
||||
end.stackSize = numOfBlocks;
|
||||
final Object[] stacks = new Object[numOfBlocks + 1];
|
||||
for (int i = 0; i < numOfBlocks; ++i) {
|
||||
@@ -228,9 +227,6 @@ public class ModuleGardening implements IInitializable {
|
||||
}
|
||||
|
||||
private void addAlkalineFertiliser(final ItemStack stack, final int strengthMax) {
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
Gardening.fertiliserAlkaline.put(stack, strengthMax);
|
||||
for (int moisture = 0; moisture < 3; ++moisture) {
|
||||
for (int pH = 0; pH < 3; ++pH) {
|
||||
@@ -256,9 +252,6 @@ public class ModuleGardening implements IInitializable {
|
||||
}
|
||||
|
||||
private void addNutrientFertiliser(final ItemStack stack, final int strengthMax) {
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
Gardening.fertiliserNutrient.put(stack, strengthMax);
|
||||
for (int moisture = 0; moisture < 3; ++moisture) {
|
||||
for (int pH = 0; pH < 3; ++pH) {
|
||||
|
||||
@@ -70,7 +70,7 @@ public class FlowerBreedingSystem extends BreedingSystem {
|
||||
@Override
|
||||
public boolean isDNAManipulable(final ItemStack member) {
|
||||
ISpeciesType type = this.getSpeciesRoot().getType(member);
|
||||
return isDNAManipulable(type);
|
||||
return type != null && isDNAManipulable(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,6 +26,7 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -941,6 +942,7 @@ public enum FlowerDefinition implements IFlowerDefinition {
|
||||
String binomial;
|
||||
String branchName;
|
||||
List<IAllele[]> variantTemplates;
|
||||
@Nullable
|
||||
IClassification branch;
|
||||
EnumFlowerColor primaryColor, secondaryColor;
|
||||
|
||||
@@ -996,7 +998,7 @@ public enum FlowerDefinition implements IFlowerDefinition {
|
||||
IAlleleFlowerSpeciesBuilder speciesBuilder = FlowerManager.flowerFactory.createSpecies(uid, unlocalizedName, "Binnie's Mod Team", unlocalizedDescription, isDominant, getBranch(), binomial, flowerType);
|
||||
setSpeciesProperties(speciesBuilder);
|
||||
this.species = speciesBuilder.build();
|
||||
if (branch != null) {
|
||||
if (this.branch != null) {
|
||||
this.branch.addMemberSpecies(species);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ import forestry.core.genetics.Genome;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class FlowerGenome extends Genome implements IFlowerGenome {
|
||||
public FlowerGenome(final NBTTagCompound nbttagcompound) {
|
||||
super(nbttagcompound);
|
||||
@@ -30,6 +32,7 @@ public class FlowerGenome extends Genome implements IFlowerGenome {
|
||||
super(chromosomes);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static IAlleleFlowerSpecies getSpecies(ItemStack itemStack) {
|
||||
if (!FlowerManager.flowerRoot.isMember(itemStack)) {
|
||||
return null;
|
||||
|
||||
@@ -79,7 +79,7 @@ class MothBreedingSystem extends BreedingSystem {
|
||||
@Override
|
||||
public boolean isDNAManipulable(final ItemStack member) {
|
||||
ISpeciesType type = this.getSpeciesRoot().getType(member);
|
||||
return isDNAManipulable(type);
|
||||
return type != null && isDNAManipulable(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package binnie.core.genetics;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import forestry.api.apiculture.DefaultBeeListener;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
@@ -10,14 +11,18 @@ import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.apiculture.IBeekeepingLogic;
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.apiculture.FakeBeekeepingLogic;
|
||||
import forestry.apiculture.InventoryBeeHousing;
|
||||
import forestry.core.errors.FakeErrorLogic;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Biomes;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
public class VirtualBeeHousing extends VirtualHousing implements IBeeHousing, IBeeModifier {
|
||||
ArrayList<IBeeModifier> beeModifier = new ArrayList<>();
|
||||
@@ -50,10 +55,12 @@ public class VirtualBeeHousing extends VirtualHousing implements IBeeHousing, IB
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ItemStack getQueen() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ItemStack getDrone() {
|
||||
return null;
|
||||
}
|
||||
@@ -125,7 +132,7 @@ public class VirtualBeeHousing extends VirtualHousing implements IBeeHousing, IB
|
||||
|
||||
@Override
|
||||
public IErrorLogic getErrorLogic() {
|
||||
return null;
|
||||
return FakeErrorLogic.instance;
|
||||
}
|
||||
|
||||
// TODO ??
|
||||
@@ -157,7 +164,7 @@ public class VirtualBeeHousing extends VirtualHousing implements IBeeHousing, IB
|
||||
// TODO ??
|
||||
@Override
|
||||
public Iterable<IBeeListener> getBeeListeners() {
|
||||
return null;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -167,7 +174,7 @@ public class VirtualBeeHousing extends VirtualHousing implements IBeeHousing, IB
|
||||
|
||||
@Override
|
||||
public IBeekeepingLogic getBeekeepingLogic() {
|
||||
return null;
|
||||
return FakeBeekeepingLogic.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,6 +11,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
class VirtualHousing implements IHousing {
|
||||
@@ -75,7 +76,7 @@ class VirtualHousing implements IHousing {
|
||||
}
|
||||
|
||||
public Set<IErrorState> getErrorStates() {
|
||||
return null;
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,17 +5,21 @@ import forestry.api.lepidopterology.IButterfly;
|
||||
import forestry.api.lepidopterology.IButterflyNursery;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class VirtualMothHousing extends VirtualHousing implements IButterflyNursery {
|
||||
public VirtualMothHousing(final EntityPlayer player) {
|
||||
super(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public IButterfly getCaterpillar() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public IIndividual getNanny() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public enum BinnieCoreGUI implements IBinnieGUID {
|
||||
return new WindowGenesis(player, null, side);
|
||||
}
|
||||
default: {
|
||||
return null;
|
||||
throw new IllegalArgumentException("Unknown GUI type: " + this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,9 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public interface IBinnieGUID extends IOrdinaled {
|
||||
Window getWindow(final EntityPlayer p0, final World p1, final int p2, final int p3, final int p4, final Side p5);
|
||||
@Nullable
|
||||
Window getWindow(final EntityPlayer player, final World world, final int x, final int y, final int z, final Side side);
|
||||
}
|
||||
@@ -4,8 +4,6 @@ import binnie.core.BinnieCore;
|
||||
import binnie.core.Mods;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
@@ -14,13 +12,13 @@ import javax.annotation.Nullable;
|
||||
|
||||
public enum FluidContainerType {
|
||||
CAPSULE,
|
||||
REFARACTORY,
|
||||
REFRACTORY,
|
||||
CAN,
|
||||
GLASS,
|
||||
CYLINDER;
|
||||
|
||||
@Nullable
|
||||
ItemFluidContainer item;
|
||||
private ItemFluidContainer item;
|
||||
|
||||
public int getMaxStackSize() {
|
||||
return 16;
|
||||
@@ -38,22 +36,22 @@ public enum FluidContainerType {
|
||||
return BinnieCore.getBinnieProxy().localise("item.container." + this.name().toLowerCase());
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return this.getEmpty() != null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ItemFluidContainer getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
public void setItem(ItemFluidContainer item) {
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
public ItemStack get(int amount){
|
||||
if(item == null){
|
||||
if (item == null){
|
||||
throw new IllegalArgumentException("Null container item: " + this);
|
||||
}
|
||||
return new ItemStack(item, amount);
|
||||
}
|
||||
|
||||
|
||||
public ItemStack getEmpty() {
|
||||
switch (this) {
|
||||
case CAN: {
|
||||
@@ -63,9 +61,14 @@ public enum FluidContainerType {
|
||||
return Mods.Forestry.stack("capsule");
|
||||
}
|
||||
case CYLINDER:
|
||||
case GLASS:
|
||||
return new ItemStack(item);
|
||||
case REFARACTORY: {
|
||||
case GLASS: {
|
||||
if (item != null) {
|
||||
return new ItemStack(item);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Null container item: " + this);
|
||||
}
|
||||
}
|
||||
case REFRACTORY: {
|
||||
return Mods.Forestry.stack("refractory");
|
||||
}
|
||||
default: {
|
||||
@@ -74,35 +77,16 @@ public enum FluidContainerType {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ItemStack getFilled(Fluid fluid) {
|
||||
ItemStack stack = getEmpty();
|
||||
if (stack != null) {
|
||||
stack = stack.copy();
|
||||
IFluidHandler fluidHandler = FluidUtil.getFluidHandler(stack);
|
||||
if (fluidHandler != null) {
|
||||
int fill = fluidHandler.fill(new FluidStack(fluid, Integer.MAX_VALUE), true);
|
||||
if (fill > 0) {
|
||||
return stack;
|
||||
}
|
||||
stack = stack.copy();
|
||||
IFluidHandler fluidHandler = FluidUtil.getFluidHandler(stack);
|
||||
if (fluidHandler != null) {
|
||||
int fill = fluidHandler.fill(new FluidStack(fluid, Integer.MAX_VALUE), true);
|
||||
if (fill > 0) {
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void registerContainerData(final IFluidType fluid) {
|
||||
if (!this.isActive()) {
|
||||
return;
|
||||
}
|
||||
ItemStack filled = getFilled(FluidRegistry.getFluid(fluid.getIdentifier().toLowerCase()));
|
||||
if(filled == null){
|
||||
filled = item.getContainer(fluid);
|
||||
}
|
||||
ItemStack empty = this.getEmpty();
|
||||
if (filled == null || empty == null || fluid.get(1000) == null) {
|
||||
return;
|
||||
}
|
||||
final FluidContainerRegistry.FluidContainerData data = new FluidContainerRegistry.FluidContainerData(fluid.get(1000), filled, empty);
|
||||
FluidContainerRegistry.registerFluidContainer(data);
|
||||
throw new IllegalStateException("Could not fill fluid handler for container: " + this);
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@ import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemFluidContainer extends ItemFood implements IItemModelRegister {
|
||||
@@ -40,7 +41,7 @@ public class ItemFluidContainer extends ItemFood implements IItemModelRegister {
|
||||
public ItemFluidContainer(FluidContainerType container) {
|
||||
super(0, false);
|
||||
this.container = container;
|
||||
container.item = this;
|
||||
container.setItem(this);
|
||||
this.maxStackSize = container.getMaxStackSize();
|
||||
this.setHasSubtypes(true);
|
||||
this.setUnlocalizedName("container" + container.getName());
|
||||
@@ -50,9 +51,6 @@ public class ItemFluidContainer extends ItemFood implements IItemModelRegister {
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(final ItemStack itemstack) {
|
||||
if (itemstack == null) {
|
||||
return "???";
|
||||
}
|
||||
FluidStack fluid = getContained(itemstack);
|
||||
if (fluid == null) {
|
||||
return "Empty " + container.getDisplayName();
|
||||
@@ -73,7 +71,8 @@ public class ItemFluidContainer extends ItemFood implements IItemModelRegister {
|
||||
subItems.add(getContainer(liquid));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
protected FluidStack getContained(ItemStack itemStack) {
|
||||
if (itemStack.stackSize != 1) {
|
||||
itemStack = itemStack.copy();
|
||||
|
||||
@@ -15,6 +15,7 @@ import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
@@ -26,7 +27,7 @@ public class ManagerLiquid extends ManagerBase {
|
||||
this.fluids = new LinkedHashMap<>();
|
||||
EnumContainerType.CAN.add(new BinnieContainerPermission(FluidContainerType.CAN));
|
||||
EnumContainerType.CAPSULE.add(new BinnieContainerPermission(FluidContainerType.CAPSULE));
|
||||
EnumContainerType.REFRACTORY.add(new BinnieContainerPermission(FluidContainerType.REFARACTORY));
|
||||
EnumContainerType.REFRACTORY.add(new BinnieContainerPermission(FluidContainerType.REFRACTORY));
|
||||
EnumContainerType.GLASS.add(new BinnieContainerPermission(FluidContainerType.GLASS));
|
||||
}
|
||||
|
||||
@@ -51,6 +52,7 @@ public class ManagerLiquid extends ManagerBase {
|
||||
return bFluid;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public FluidStack getFluidStack(final String name, final int amount) {
|
||||
return FluidRegistry.getFluidStack(name.toLowerCase(), amount);
|
||||
}
|
||||
@@ -61,13 +63,6 @@ public class ManagerLiquid extends ManagerBase {
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
for (final IFluidType fluid : this.fluids.values()) {
|
||||
for (final FluidContainerType container : FluidContainerType.values()) {
|
||||
if (container.isActive() && fluid.canPlaceIn(container)) {
|
||||
container.registerContainerData(fluid);
|
||||
}
|
||||
}
|
||||
}
|
||||
GameRegistry.addShapelessRecipe(FluidContainerType.GLASS.get(1), Items.GLASS_BOTTLE);
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(Items.GLASS_BOTTLE), FluidContainerType.GLASS.get(1));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(FluidContainerType.GLASS.get(3),
|
||||
|
||||
@@ -11,6 +11,7 @@ public interface IMachine extends IOwnable {
|
||||
|
||||
MachineUtil getMachineUtil();
|
||||
|
||||
@Nullable
|
||||
<T> T getInterface(Class<T> Interface);
|
||||
|
||||
void markDirty();
|
||||
|
||||
@@ -2,8 +2,11 @@ package binnie.core.machines;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
interface IOwnable {
|
||||
@Nullable
|
||||
GameProfile getOwner();
|
||||
|
||||
void setOwner(final GameProfile p0);
|
||||
void setOwner(final GameProfile owner);
|
||||
}
|
||||
@@ -33,8 +33,8 @@ import java.util.Map;
|
||||
|
||||
public class Machine implements INetworkedEntity, INbtReadable, INbtWritable, INetwork.TilePacketSync, IMachine, INetwork.GuiNBT {
|
||||
private MachinePackage machinePackage;
|
||||
private Map<Class<? extends MachineComponent>, List<MachineComponent>> componentInterfaceMap;
|
||||
private Map<Class<? extends MachineComponent>, MachineComponent> componentMap;
|
||||
private Map<Class<?>, List<MachineComponent>> componentInterfaceMap;
|
||||
private Map<Class<?>, MachineComponent> componentMap;
|
||||
private TileEntity tile;
|
||||
private boolean queuedInventoryUpdate;
|
||||
@Nullable
|
||||
@@ -55,7 +55,7 @@ public class Machine implements INetworkedEntity, INbtReadable, INbtWritable, IN
|
||||
Preconditions.checkNotNull(component, "Can't have a null machine component!");
|
||||
component.setMachine(this);
|
||||
this.componentMap.put(component.getClass(), component);
|
||||
for (final Class<? extends MachineComponent> inter : component.getComponentInterfaces()) {
|
||||
for (final Class<?> inter : component.getComponentInterfaces()) {
|
||||
if (!this.componentInterfaceMap.containsKey(inter)) {
|
||||
this.componentInterfaceMap.put(inter, new ArrayList<>());
|
||||
}
|
||||
@@ -67,15 +67,15 @@ public class Machine implements INetworkedEntity, INbtReadable, INbtWritable, IN
|
||||
return this.componentMap.values();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public <T extends MachineComponent> T getComponent(final Class<T> componentClass) {
|
||||
if (this.hasComponent(componentClass)) {
|
||||
return componentClass.cast(this.componentMap.get(componentClass));
|
||||
}
|
||||
return null;
|
||||
throw new IllegalArgumentException("No component found for " + componentClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T getInterface(final Class<T> interfaceClass) {
|
||||
if (this.hasInterface(interfaceClass)) {
|
||||
return this.getInterfaces(interfaceClass).get(0);
|
||||
@@ -88,12 +88,12 @@ public class Machine implements INetworkedEntity, INbtReadable, INbtWritable, IN
|
||||
return interfaceClass.cast(component);
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("No interface for : " + interfaceClass);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> List<T> getInterfaces(final Class<T> interfaceClass) {
|
||||
final ArrayList<T> interfaces = new ArrayList<>();
|
||||
final List<T> interfaces = new ArrayList<>();
|
||||
if (!this.hasInterface(interfaceClass)) {
|
||||
return interfaces;
|
||||
}
|
||||
@@ -107,7 +107,7 @@ public class Machine implements INetworkedEntity, INbtReadable, INbtWritable, IN
|
||||
return this.componentInterfaceMap.containsKey(interfaceClass);
|
||||
}
|
||||
|
||||
public boolean hasComponent(final Class<? extends MachineComponent> componentClass) {
|
||||
public boolean hasComponent(final Class<?> componentClass) {
|
||||
return this.componentMap.containsKey(componentClass);
|
||||
}
|
||||
|
||||
@@ -146,7 +146,8 @@ public class Machine implements INetworkedEntity, INbtReadable, INbtWritable, IN
|
||||
}
|
||||
|
||||
public void onRightClick(final World world, final EntityPlayer player, final BlockPos pos) {
|
||||
for (final IInteraction.RightClick component : this.getInterfaces(IInteraction.RightClick.class)) {
|
||||
List<IInteraction.RightClick> interfaces = this.getInterfaces(IInteraction.RightClick.class);
|
||||
for (final IInteraction.RightClick component : interfaces) {
|
||||
component.onRightClick(world, player, pos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class MachineComponent implements INbtReadable, INbtWritable {
|
||||
public void onUpdate() {
|
||||
}
|
||||
|
||||
public Class<? extends MachineComponent>[] getComponentInterfaces() {
|
||||
public Class<?>[] getComponentInterfaces() {
|
||||
return Binnie.MACHINE.getComponentInterfaces(this.getClass());
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class ManagerMachine extends ManagerBase {
|
||||
private Map<Class<?>, Class<? extends MachineComponent>[]> componentInterfaceMap;
|
||||
private Map<Class<?>, Class<?>[]> componentInterfaceMap;
|
||||
private Map<String, MachineGroup> machineGroups;
|
||||
private Map<Integer, Class<?>> networkIDToComponent;
|
||||
private Map<Class<?>, Integer> componentToNetworkID;
|
||||
@@ -84,7 +84,7 @@ public class ManagerMachine extends ManagerBase {
|
||||
BinnieCore.getBinnieProxy().registerTileEntity(TileEntityMachine.class, "binnie.tile.machine", rendererMachine);
|
||||
}
|
||||
|
||||
public Class<? extends MachineComponent>[] getComponentInterfaces(final Class<? extends MachineComponent> clss) {
|
||||
public Class<?>[] getComponentInterfaces(final Class<? extends MachineComponent> clss) {
|
||||
if (!this.componentInterfaceMap.containsKey(clss)) {
|
||||
this.registerComponentClass(clss);
|
||||
}
|
||||
|
||||
@@ -16,17 +16,19 @@ class DefaultInventory implements IInventoryMachine {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ItemStack getStackInSlot(final int i) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ItemStack decrStackSize(final int i, final int j) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@Nullable
|
||||
public ItemStack removeStackFromSlot(int index) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public class TileEntityMachineBase extends TileEntity implements IInventoryMachi
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(final int index, final ItemStack itemStack) {
|
||||
public void setInventorySlotContents(final int index, @Nullable final ItemStack itemStack) {
|
||||
this.getInventory().setInventorySlotContents(index, itemStack);
|
||||
}
|
||||
|
||||
@@ -113,29 +113,24 @@ public class TileEntityMachineBase extends TileEntity implements IInventoryMachi
|
||||
return this.getInventory().isItemValidForSlot(slot, itemStack);
|
||||
}
|
||||
|
||||
|
||||
//TODO Implement
|
||||
@Override
|
||||
public int getField(int id) {
|
||||
return 0;
|
||||
return this.getInventory().getField(id);
|
||||
}
|
||||
|
||||
//TODO Implement
|
||||
@Override
|
||||
public void setField(int id, int value) {
|
||||
|
||||
this.getInventory().setField(id, value);
|
||||
}
|
||||
|
||||
//TODO Implement
|
||||
@Override
|
||||
public int getFieldCount() {
|
||||
return 0;
|
||||
return this.getInventory().getFieldCount();
|
||||
}
|
||||
|
||||
//TODO Implement
|
||||
@Override
|
||||
public void clear() {
|
||||
|
||||
this.getInventory().clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -41,8 +41,9 @@ public abstract class BaseSlot<T> implements INbtWritable, INbtReadable, IValida
|
||||
|
||||
public abstract void setContent(final T content);
|
||||
|
||||
public void setValidator(final Validator<T> val) {
|
||||
public BaseSlot<T> setValidator(final Validator<T> val) {
|
||||
this.validator = val;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
|
||||
@@ -179,6 +179,7 @@ public class ComponentTankContainer extends MachineComponent implements ITankMac
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public FluidStack drain(final FluidStack resource, final boolean doDrain) {
|
||||
final int index = getTankIndexToDrain(from, null);
|
||||
if (tanks.containsKey(index)) {
|
||||
@@ -188,6 +189,7 @@ public class ComponentTankContainer extends MachineComponent implements ITankMac
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public final FluidStack drain(final int maxDrain, final boolean doDrain) {
|
||||
final int index = getTankIndexToDrain(from, null);
|
||||
if (tanks.containsKey(index)) {
|
||||
|
||||
@@ -6,7 +6,10 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class TankInfo implements INbtReadable, INbtWritable {
|
||||
@Nullable
|
||||
public FluidStack liquid;
|
||||
private float capacity;
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
|
||||
for (int k = 0; k < inv.getPageSize(); ++k) {
|
||||
slotsIDs[k] = i++;
|
||||
}
|
||||
new ControlSlotArray(thisPage, 8, 8, inv.getPageSize() / 5, 5).create(slotsIDs);
|
||||
new ControlSlotArray.Builder(thisPage, 8, 8, inv.getPageSize() / 5, 5).create(slotsIDs);
|
||||
}
|
||||
x += compartmentPageWidth;
|
||||
if (tabs2.length > 0) {
|
||||
@@ -379,7 +379,7 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
|
||||
this.slotGrid.deleteAllChildren();
|
||||
this.slotGrid.setSize(new IPoint(width, height));
|
||||
for (final int k : slotIds.keySet()) {
|
||||
new ControlSlot(this.slotGrid, x, y).assign(k);
|
||||
new ControlSlot.Builder(this.slotGrid, x, y).assign(k);
|
||||
x += 18;
|
||||
if (x >= 108) {
|
||||
x = 0;
|
||||
@@ -387,7 +387,8 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
|
||||
}
|
||||
}
|
||||
while (y < 108 || x != 0) {
|
||||
new ControlSlot(this.slotGrid, x, y);
|
||||
// TODO: what was this supposed to do?
|
||||
new ControlSlot.Builder(this.slotGrid, x, y);
|
||||
x += 18;
|
||||
if (x >= 108) {
|
||||
x = 0;
|
||||
|
||||
@@ -35,7 +35,7 @@ public class TransferRequest {
|
||||
private List<TransferSlot> insertedSlots;
|
||||
private List<Integer> insertedTanks;
|
||||
|
||||
public TransferRequest(final ItemStack toTransfer, final IInventory destination) {
|
||||
public TransferRequest(@Nullable final ItemStack toTransfer, final IInventory destination) {
|
||||
this.itemToTransfer = null;
|
||||
this.returnItem = null;
|
||||
this.targetSlots = new int[0];
|
||||
@@ -68,9 +68,6 @@ public class TransferRequest {
|
||||
|
||||
@Nullable
|
||||
public static ItemStack transferItemToInventory(final ItemStack item, final IInventory destination, final boolean doAdd) {
|
||||
if (item == null || destination == null) {
|
||||
return item;
|
||||
}
|
||||
ItemStack addition = item.copy();
|
||||
for (int i = 0; i < destination.getSizeInventory(); ++i) {
|
||||
addition = transferToInventory(addition, destination, new int[]{i}, doAdd, false);
|
||||
|
||||
@@ -4,6 +4,8 @@ import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
class TileEntityMultiblockMachine extends TileEntity {
|
||||
private boolean inStructure;
|
||||
private int tileX;
|
||||
@@ -14,10 +16,12 @@ class TileEntityMultiblockMachine extends TileEntity {
|
||||
return this.inStructure;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Machine getMachine() {
|
||||
return this.getMasterMachine();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Machine getMasterMachine() {
|
||||
if (!this.inStructure) {
|
||||
return null;
|
||||
|
||||
@@ -5,6 +5,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
|
||||
public class MessageCoordinates extends MessageBase {
|
||||
@@ -45,6 +46,7 @@ public class MessageCoordinates extends MessageBase {
|
||||
return new BlockPos(this.posX, this.posY, this.posZ);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public TileEntity getTileEntity(final World world) {
|
||||
return world.getTileEntity(getCoordinates());
|
||||
}
|
||||
|
||||
@@ -5,9 +5,11 @@ import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
|
||||
public class MessageUpdate extends MessageCoordinates {
|
||||
@Nullable
|
||||
public PacketPayload payload;
|
||||
|
||||
public MessageUpdate(final MessageBinnie message) {
|
||||
@@ -67,6 +69,7 @@ public class MessageUpdate extends MessageCoordinates {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public TileEntity getTarget(final World world) {
|
||||
return world.getTileEntity(getCoordinates());
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package binnie.core.util;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
@@ -10,19 +10,20 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
class FluidStackSet implements Set<FluidStack> {
|
||||
List<FluidStack> itemStacks;
|
||||
protected final List<FluidStack> fluidStacks;
|
||||
|
||||
FluidStackSet() {
|
||||
this.itemStacks = new ArrayList<>();
|
||||
this.fluidStacks = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.itemStacks.toString();
|
||||
return this.fluidStacks.toString();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected FluidStack getExisting(final FluidStack stack) {
|
||||
for (final FluidStack stack2 : this.itemStacks) {
|
||||
for (final FluidStack stack2 : this.fluidStacks) {
|
||||
if (stack2.isFluidEqual(stack)) {
|
||||
return stack2;
|
||||
}
|
||||
@@ -33,10 +34,10 @@ class FluidStackSet implements Set<FluidStack> {
|
||||
@Override
|
||||
public boolean add(final FluidStack e) {
|
||||
if (e != null) {
|
||||
if (this.getExisting(e) == null) {
|
||||
return this.itemStacks.add(e.copy());
|
||||
FluidStack existing = this.getExisting(e);
|
||||
if (existing == null) {
|
||||
return this.fluidStacks.add(e.copy());
|
||||
}
|
||||
final FluidStack existing = this.getExisting(e);
|
||||
existing.amount += e.amount;
|
||||
}
|
||||
return false;
|
||||
@@ -53,7 +54,7 @@ class FluidStackSet implements Set<FluidStack> {
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
this.itemStacks.clear();
|
||||
this.fluidStacks.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -72,12 +73,12 @@ class FluidStackSet implements Set<FluidStack> {
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return this.itemStacks.isEmpty();
|
||||
return this.fluidStacks.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<FluidStack> iterator() {
|
||||
return this.itemStacks.iterator();
|
||||
return this.fluidStacks.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -85,10 +86,10 @@ class FluidStackSet implements Set<FluidStack> {
|
||||
if (this.contains(o)) {
|
||||
final FluidStack r = (FluidStack) o;
|
||||
final FluidStack existing = this.getExisting(r);
|
||||
if (existing.amount > r.amount) {
|
||||
if (existing != null && existing.amount > r.amount) {
|
||||
existing.amount -= r.amount;
|
||||
} else {
|
||||
this.itemStacks.remove(existing);
|
||||
this.fluidStacks.remove(existing);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -106,21 +107,21 @@ class FluidStackSet implements Set<FluidStack> {
|
||||
|
||||
@Override
|
||||
public boolean retainAll(final Collection<?> c) {
|
||||
return this.itemStacks.retainAll(c);
|
||||
return this.fluidStacks.retainAll(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return this.itemStacks.size();
|
||||
return this.fluidStacks.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] toArray() {
|
||||
return this.itemStacks.toArray();
|
||||
return this.fluidStacks.toArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T[] toArray(final T[] a) {
|
||||
return this.itemStacks.toArray(a);
|
||||
return this.fluidStacks.toArray(a);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package binnie.core.util;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
@@ -20,6 +21,7 @@ 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)) {
|
||||
@@ -32,10 +34,10 @@ public class ItemStackSet implements Set<ItemStack> {
|
||||
@Override
|
||||
public boolean add(final ItemStack e) {
|
||||
if (e != null) {
|
||||
if (this.getExisting(e) == null) {
|
||||
ItemStack existing = this.getExisting(e);
|
||||
if (existing == null) {
|
||||
return this.itemStacks.add(e.copy());
|
||||
}
|
||||
final ItemStack existing = this.getExisting(e);
|
||||
existing.stackSize += e.stackSize;
|
||||
}
|
||||
return false;
|
||||
@@ -84,9 +86,8 @@ public class ItemStackSet implements Set<ItemStack> {
|
||||
if (this.contains(o)) {
|
||||
final ItemStack r = (ItemStack) o;
|
||||
final ItemStack existing = this.getExisting(r);
|
||||
if (existing.stackSize > r.stackSize) {
|
||||
final ItemStack itemStack = existing;
|
||||
itemStack.stackSize -= r.stackSize;
|
||||
if (existing != null && existing.stackSize > r.stackSize) {
|
||||
existing.stackSize -= r.stackSize;
|
||||
} else {
|
||||
this.itemStacks.remove(existing);
|
||||
}
|
||||
|
||||
@@ -13,9 +13,6 @@ import javax.annotation.Nullable;
|
||||
public class TileUtil {
|
||||
@Nullable
|
||||
public static <T extends TileEntity> T getTile(IBlockAccess world, BlockPos pos, Class<T> tileClass) {
|
||||
if (pos == null) {
|
||||
return null;
|
||||
}
|
||||
TileEntity tileEntity = world.getTileEntity(pos);
|
||||
if (tileClass.isInstance(tileEntity)) {
|
||||
return tileClass.cast(tileEntity);
|
||||
|
||||
@@ -5,7 +5,7 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
public class UniqueFluidStackSet extends FluidStackSet {
|
||||
@Override
|
||||
public boolean add(final FluidStack e) {
|
||||
return e != null && this.getExisting(e) == null && this.itemStacks.add(e.copy());
|
||||
return e != null && this.getExisting(e) == null && this.fluidStacks.add(e.copy());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -13,7 +13,7 @@ public class UniqueFluidStackSet extends FluidStackSet {
|
||||
if (this.contains(o)) {
|
||||
final FluidStack r = (FluidStack) o;
|
||||
final FluidStack existing = this.getExisting(r);
|
||||
this.itemStacks.remove(existing);
|
||||
this.fluidStacks.remove(existing);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -116,8 +116,8 @@ public class WindowFieldKit extends Window {
|
||||
new ControlPlayerInventory(this);
|
||||
final IPoint handGlass = new IPoint(16, 32);
|
||||
this.GlassControl = new ControlImage(this, handGlass.x(), handGlass.y(), new StandardTexture(0, 160, 96, 96, ExtraBeeTexture.GUIPunnett));
|
||||
new ControlSlot(this, handGlass.x() + 54, handGlass.y() + 26).assign(InventoryType.Window, 0);
|
||||
new ControlSlot(this, 208, 8).assign(InventoryType.Window, 1);
|
||||
new ControlSlot.Builder(this, handGlass.x() + 54, handGlass.y() + 26).assign(InventoryType.Window, 0);
|
||||
new ControlSlot.Builder(this, 208, 8).assign(InventoryType.Window, 1);
|
||||
(this.text = new ControlText(this, new IPoint(232, 13), "Paper")).setColour(2236962);
|
||||
(this.text = new ControlText(this, new IArea(0, 120, this.w(), 24), "", TextJustification.MiddleCenter)).setColour(2236962);
|
||||
this.chromo = new ControlChromosome(this, 150, 24);
|
||||
|
||||
@@ -10,6 +10,8 @@ import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -39,6 +41,13 @@ public class Control extends Widget implements ITooltipHelp, ITooltip {
|
||||
public void onUpdateClient() {
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IWidget getParent() {
|
||||
//noinspection ConstantConditions
|
||||
return super.getParent();
|
||||
}
|
||||
|
||||
public void addHelp(final String string) {
|
||||
this.helpStrings.add(string);
|
||||
}
|
||||
@@ -76,6 +85,6 @@ public class Control extends Widget implements ITooltipHelp, ITooltip {
|
||||
}
|
||||
|
||||
public Window getWindow() {
|
||||
return (Window) this.getSuperParent();
|
||||
return (Window) this.getTopParent();
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ public interface IWidget {
|
||||
|
||||
void deleteAllChildren();
|
||||
|
||||
ITopLevelWidget getSuperParent();
|
||||
ITopLevelWidget getTopParent();
|
||||
|
||||
boolean isTopLevel();
|
||||
|
||||
|
||||
@@ -150,14 +150,8 @@ public abstract class TopLevelWidget extends Widget implements ITopLevelWidget {
|
||||
final Deque<IWidget> queue = this.calculateMousedOverWidgets();
|
||||
while (!queue.isEmpty()) {
|
||||
final IWidget widget = queue.removeFirst();
|
||||
if (widget.isEnabled() && widget.isVisible()) {
|
||||
if (!widget.canMouseOver()) {
|
||||
continue;
|
||||
}
|
||||
if (widget.isEnabled() && widget.isVisible() && widget.canMouseOver() && widget.calculateIsMouseOver()) {
|
||||
return widget;
|
||||
}
|
||||
continue;
|
||||
if (widget.isEnabled() && widget.isVisible() && widget.canMouseOver() && widget.calculateIsMouseOver()) {
|
||||
return widget;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -9,7 +9,6 @@ import binnie.craftgui.events.EventWidget;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.ConcurrentModificationException;
|
||||
import java.util.List;
|
||||
|
||||
public class Widget implements IWidget {
|
||||
@@ -80,13 +79,17 @@ public class Widget implements IWidget {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public final IWidget getParent() {
|
||||
public IWidget getParent() {
|
||||
return this.parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ITopLevelWidget getSuperParent() {
|
||||
return (ITopLevelWidget) (this.parent == null ? this : this.parent.getSuperParent());
|
||||
public final ITopLevelWidget getTopParent() {
|
||||
if (this.parent == null) {
|
||||
return (ITopLevelWidget) this;
|
||||
} else {
|
||||
return this.parent.getTopParent();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -237,7 +240,7 @@ public class Widget implements IWidget {
|
||||
|
||||
@Override
|
||||
public final void callEvent(final Event event) {
|
||||
this.getSuperParent().recieveEvent(event);
|
||||
this.getTopParent().recieveEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -255,7 +258,7 @@ public class Widget implements IWidget {
|
||||
|
||||
@Override
|
||||
public final IPoint getMousePosition() {
|
||||
return this.getSuperParent().getAbsoluteMousePosition();
|
||||
return this.getTopParent().getAbsoluteMousePosition();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -297,7 +300,7 @@ public class Widget implements IWidget {
|
||||
if (!this.isVisible()) {
|
||||
return;
|
||||
}
|
||||
if (this.getSuperParent() == this) {
|
||||
if (this.getTopParent() == this) {
|
||||
((ITopLevelWidget) this).updateTopLevel();
|
||||
}
|
||||
this.onUpdateClient();
|
||||
@@ -386,17 +389,17 @@ public class Widget implements IWidget {
|
||||
|
||||
@Override
|
||||
public final boolean isFocused() {
|
||||
return this.getSuperParent().isFocused(this);
|
||||
return this.getTopParent().isFocused(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isDragged() {
|
||||
return this.getSuperParent().isDragged(this);
|
||||
return this.getTopParent().isDragged(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isMouseOver() {
|
||||
return this.getSuperParent().isMouseOver(this);
|
||||
return this.getTopParent().isMouseOver(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -437,7 +440,7 @@ public class Widget implements IWidget {
|
||||
|
||||
@Override
|
||||
public final void delete() {
|
||||
this.getSuperParent().widgetDeleted(this);
|
||||
this.getTopParent().widgetDeleted(this);
|
||||
this.onDelete();
|
||||
}
|
||||
|
||||
@@ -446,12 +449,11 @@ public class Widget implements IWidget {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nullable
|
||||
public <T> T getWidget(final Class<T> widgetClass) {
|
||||
for (final IWidget child : this.getWidgets()) {
|
||||
if (widgetClass.isInstance(child)) {
|
||||
return (T) child;
|
||||
return widgetClass.cast(child);
|
||||
}
|
||||
final T found = child.getWidget(widgetClass);
|
||||
if (found != null) {
|
||||
|
||||
@@ -2,6 +2,8 @@ package binnie.craftgui.events;
|
||||
|
||||
import binnie.craftgui.core.IWidget;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public abstract class EventHandler<E extends Event> {
|
||||
Class<E> eventClass;
|
||||
Origin origin;
|
||||
|
||||
@@ -16,6 +16,7 @@ import binnie.core.machines.transfer.TransferRequest;
|
||||
import binnie.core.network.packet.MessageContainerUpdate;
|
||||
import binnie.craftgui.minecraft.control.ControlSlot;
|
||||
import binnie.craftgui.minecraft.control.EnumHighlighting;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -79,33 +80,6 @@ public class ContainerCraftGUI extends Container {
|
||||
return this.window.isServer() ? Side.SERVER : Side.CLIENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Slot getSlot(final int index) {
|
||||
if (index < 0 || index >= this.inventorySlots.size()) {
|
||||
return null;
|
||||
}
|
||||
return this.inventorySlots.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStackInSlot(final int index, final ItemStack par2ItemStack) {
|
||||
Slot slot = this.getSlot(index);
|
||||
if (slot != null) {
|
||||
slot.putStack(par2ItemStack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStacksInSlots(final ItemStack[] par1ArrayOfItemStack) {
|
||||
for (int i = 0; i < par1ArrayOfItemStack.length; ++i) {
|
||||
Slot slot = this.getSlot(i);
|
||||
if (slot != null) {
|
||||
slot.putStack(par1ArrayOfItemStack[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(final EntityPlayer par1EntityPlayer) {
|
||||
this.crafters.remove(par1EntityPlayer);
|
||||
@@ -125,7 +99,6 @@ public class ContainerCraftGUI extends Container {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemStack slotClick(int slotNum, int dragType, ClickType clickType, EntityPlayer player) {
|
||||
@@ -134,11 +107,9 @@ public class ContainerCraftGUI extends Container {
|
||||
((CustomSlot) slot).onSlotClick(this, dragType, clickType, player);
|
||||
return player.inventory.getItemStack();
|
||||
}
|
||||
final ItemStack stack = super.slotClick(slotNum, dragType, clickType, player);
|
||||
return stack;
|
||||
return super.slotClick(slotNum, dragType, clickType, player);
|
||||
}
|
||||
|
||||
|
||||
public void sendNBTToClient(final String key, final NBTTagCompound nbt) {
|
||||
this.syncedNBT.put(key, nbt);
|
||||
}
|
||||
@@ -153,15 +124,14 @@ 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);
|
||||
if (request == null) {
|
||||
return null;
|
||||
}
|
||||
final ItemStack itemstack = request.transfer(true);
|
||||
final Slot shiftClickedSlot = this.inventorySlots.get(slotnumber);
|
||||
shiftClickedSlot.putStack(itemstack);
|
||||
@@ -170,9 +140,6 @@ public class ContainerCraftGUI extends Container {
|
||||
}
|
||||
|
||||
private TransferRequest getShiftClickRequest(final EntityPlayer player, final int slotnumber) {
|
||||
if (slotnumber < 0) {
|
||||
return null;
|
||||
}
|
||||
final Slot shiftClickedSlot = this.inventorySlots.get(slotnumber);
|
||||
ItemStack itemstack = null;
|
||||
if (shiftClickedSlot.getHasStack()) {
|
||||
@@ -201,12 +168,19 @@ public class ContainerCraftGUI extends Container {
|
||||
return request;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public final ItemStack tankClick(final EntityPlayer player, final int slotID) {
|
||||
if (player.inventory.getItemStack() == null) {
|
||||
IInventory inventory = this.window.getInventory();
|
||||
if (inventory == null) {
|
||||
return null;
|
||||
}
|
||||
ItemStack heldItem = player.inventory.getItemStack().copy();
|
||||
heldItem = new TransferRequest(heldItem, this.window.getInventory()).setOrigin(player.inventory).setTargetSlots(new int[0]).setTargetTanks(new int[]{slotID}).transfer(true);
|
||||
ItemStack heldItem = player.inventory.getItemStack();
|
||||
if (heldItem == null) {
|
||||
return null;
|
||||
}
|
||||
heldItem = heldItem.copy();
|
||||
TransferRequest transferRequest = new TransferRequest(heldItem, inventory).setOrigin(player.inventory).setTargetSlots(new int[0]).setTargetTanks(new int[]{slotID});
|
||||
heldItem = transferRequest.transfer(true);
|
||||
player.inventory.setItemStack(heldItem);
|
||||
if (player instanceof EntityPlayerMP) {
|
||||
((EntityPlayerMP) player).updateHeldItem();
|
||||
@@ -295,18 +269,6 @@ public class ContainerCraftGUI extends Container {
|
||||
this.syncedNBT.clear();
|
||||
}
|
||||
|
||||
//FIXME hack
|
||||
|
||||
/**
|
||||
* sets whether the player can craft in this inventory or not
|
||||
*/
|
||||
@Override
|
||||
public void setCanCraft(EntityPlayer player, boolean canCraft) {
|
||||
super.setCanCraft(player, canCraft);
|
||||
}
|
||||
//end
|
||||
|
||||
|
||||
private NBTTagCompound createErrorNBT(final IErrorStateSource error) {
|
||||
final NBTTagCompound nbt = new NBTTagCompound();
|
||||
ErrorState state = null;
|
||||
@@ -378,6 +340,7 @@ public class ContainerCraftGUI extends Container {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ErrorState getErrorState() {
|
||||
return this.error;
|
||||
}
|
||||
@@ -409,9 +372,6 @@ public class ContainerCraftGUI extends Container {
|
||||
private void onMouseOverSlot(final EntityPlayer player, final NBTTagCompound data) {
|
||||
final int slotnumber = data.getShort("slot");
|
||||
final TransferRequest request = this.getShiftClickRequest(player, slotnumber);
|
||||
if (request == null) {
|
||||
return;
|
||||
}
|
||||
request.transfer(false);
|
||||
final NBTTagCompound nbt = new NBTTagCompound();
|
||||
final List<Integer> slots = new ArrayList<>();
|
||||
@@ -437,11 +397,14 @@ public class ContainerCraftGUI extends Container {
|
||||
}
|
||||
}
|
||||
|
||||
private CustomSlot getSlot(final IInventory inventory, final int id) {
|
||||
for (final Object o : this.inventorySlots) {
|
||||
final CustomSlot slot = (CustomSlot) o;
|
||||
if (slot.inventory == inventory && slot.getSlotIndex() == id) {
|
||||
return slot;
|
||||
@Nullable
|
||||
private CustomSlot getSlot(@Nullable final IInventory inventory, final int id) {
|
||||
if (inventory != null) {
|
||||
for (final Object o : this.inventorySlots) {
|
||||
final CustomSlot slot = (CustomSlot) o;
|
||||
if (slot.inventory == inventory && slot.getSlotIndex() == id) {
|
||||
return slot;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -475,18 +438,22 @@ public class ContainerCraftGUI extends Container {
|
||||
}
|
||||
|
||||
protected IInventory getInventory(final InventoryType type) {
|
||||
if (type == InventoryType.Machine) {
|
||||
return this.window.getInventory();
|
||||
switch (type) {
|
||||
case Machine: {
|
||||
IInventory inventory = this.window.getInventory();
|
||||
Preconditions.checkState(inventory != null, "Window has no machine inventory: %s", this.window);
|
||||
return inventory;
|
||||
}
|
||||
case Player:
|
||||
return this.window.getPlayer().inventory;
|
||||
case Window:
|
||||
return this.window.getWindowInventory();
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown type: " + type);
|
||||
}
|
||||
if (type == InventoryType.Player) {
|
||||
return this.window.getPlayer().inventory;
|
||||
}
|
||||
if (type == InventoryType.Window) {
|
||||
return this.window.getWindowInventory();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Slot createServerSlot(final InventoryType type, final int index, final int slotNumber) {
|
||||
final IInventory inventory = this.getInventory(type);
|
||||
if (this.inventorySlots.get(slotNumber) != null) {
|
||||
|
||||
@@ -3,5 +3,5 @@ package binnie.craftgui.minecraft;
|
||||
import binnie.core.machines.transfer.TransferRequest;
|
||||
|
||||
public interface IWindowAffectsShiftClick {
|
||||
void alterRequest(final TransferRequest p0);
|
||||
void alterRequest(final TransferRequest request);
|
||||
}
|
||||
@@ -3,6 +3,5 @@ package binnie.craftgui.minecraft;
|
||||
public enum InventoryType {
|
||||
Player,
|
||||
Machine,
|
||||
Window,
|
||||
Custom;
|
||||
Window
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package binnie.craftgui.minecraft;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -96,6 +97,7 @@ class ListMap<T> implements List<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public T get(final int index) {
|
||||
return this.map.get(index);
|
||||
}
|
||||
@@ -112,6 +114,7 @@ class ListMap<T> implements List<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public T remove(final int index) {
|
||||
return null;
|
||||
}
|
||||
@@ -133,16 +136,16 @@ class ListMap<T> implements List<T> {
|
||||
|
||||
@Override
|
||||
public ListIterator<T> listIterator() {
|
||||
return null;
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListIterator<T> listIterator(final int index) {
|
||||
return null;
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<T> subList(final int fromIndex, final int toIndex) {
|
||||
return null;
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@ import binnie.craftgui.resource.StyleSheetManager;
|
||||
import binnie.craftgui.resource.Texture;
|
||||
import binnie.craftgui.resource.minecraft.CraftGUITexture;
|
||||
import binnie.craftgui.resource.minecraft.StandardTexture;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -46,7 +47,7 @@ import java.util.ArrayList;
|
||||
import java.util.Deque;
|
||||
|
||||
public abstract class Window extends TopLevelWidget implements INetwork.RecieveGuiNBT {
|
||||
@Nullable
|
||||
@Nullable // client side only
|
||||
private GuiCraftGUI gui;
|
||||
private ContainerCraftGUI container;
|
||||
private WindowInventory windowInventory;
|
||||
@@ -59,12 +60,54 @@ public abstract class Window extends TopLevelWidget implements INetwork.RecieveG
|
||||
@Nullable
|
||||
private StandardTexture bgText2;
|
||||
private boolean hasBeenInitialised;
|
||||
@Nullable
|
||||
private EntityPlayer player;
|
||||
@Nullable
|
||||
private IInventory entityInventory;
|
||||
private Side side;
|
||||
|
||||
public Window(final int width, final int height, final EntityPlayer player, @Nullable final IInventory inventory, final Side side) {
|
||||
this.titleButtonLeft = 8;
|
||||
this.titleButtonRight = 8;
|
||||
this.bgText1 = null;
|
||||
this.bgText2 = null;
|
||||
this.hasBeenInitialised = false;
|
||||
this.side = Side.CLIENT;
|
||||
this.side = side;
|
||||
this.player = player;
|
||||
this.entityInventory = inventory;
|
||||
this.container = new ContainerCraftGUI(this);
|
||||
this.windowInventory = new WindowInventory(this);
|
||||
if (side == Side.SERVER) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.setSize(new IPoint(width, height));
|
||||
this.gui = new GuiCraftGUI(this);
|
||||
for (final EnumHighlighting h : EnumHighlighting.values()) {
|
||||
ControlSlot.highlighting.put(h, new ArrayList<>());
|
||||
}
|
||||
CraftGUI.render.setStyleSheet(StyleSheetManager.getDefault());
|
||||
this.titleButtonLeft = -14;
|
||||
if (this.showHelpButton()) {
|
||||
new ControlHelp(this, this.titleButtonLeft += 22, 8);
|
||||
}
|
||||
String showInfoButton = this.showInfoButton();
|
||||
if (showInfoButton != null) {
|
||||
new ControlInfo(this, this.titleButtonLeft += 22, 8, showInfoButton);
|
||||
}
|
||||
this.addSelfEventHandler(new EventWidget.ChangeSize.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventWidget.ChangeSize event) {
|
||||
if (Window.this.isClient()) {
|
||||
Window.this.getGui().resize(Window.this.getSize());
|
||||
if (Window.this.title != null) {
|
||||
Window.this.title.setSize(new IPoint(Window.this.w(), Window.this.title.h()));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getTooltip(final Tooltip tooltip) {
|
||||
final Deque<IWidget> queue = this.calculateMousedOverWidgets();
|
||||
while (!queue.isEmpty()) {
|
||||
@@ -130,54 +173,13 @@ public abstract class Window extends TopLevelWidget implements INetwork.RecieveG
|
||||
return null;
|
||||
}
|
||||
|
||||
public Window(final int width, final int height, final EntityPlayer player, @Nullable final IInventory inventory, final Side side) {
|
||||
this.titleButtonLeft = 8;
|
||||
this.titleButtonRight = 8;
|
||||
this.bgText1 = null;
|
||||
this.bgText2 = null;
|
||||
this.hasBeenInitialised = false;
|
||||
this.side = Side.CLIENT;
|
||||
this.side = side;
|
||||
this.setInventories(player, inventory);
|
||||
this.container = new ContainerCraftGUI(this);
|
||||
this.windowInventory = new WindowInventory(this);
|
||||
if (side == Side.SERVER) {
|
||||
return;
|
||||
}
|
||||
this.setSize(new IPoint(width, height));
|
||||
this.gui = new GuiCraftGUI(this);
|
||||
for (final EnumHighlighting h : EnumHighlighting.values()) {
|
||||
ControlSlot.highlighting.put(h, new ArrayList<>());
|
||||
}
|
||||
CraftGUI.render.setStyleSheet(StyleSheetManager.getDefault());
|
||||
this.titleButtonLeft = -14;
|
||||
if (this.showHelpButton()) {
|
||||
new ControlHelp(this, this.titleButtonLeft += 22, 8);
|
||||
}
|
||||
String showInfoButton = this.showInfoButton();
|
||||
if (showInfoButton != null) {
|
||||
new ControlInfo(this, this.titleButtonLeft += 22, 8, showInfoButton);
|
||||
}
|
||||
this.addSelfEventHandler(new EventWidget.ChangeSize.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventWidget.ChangeSize event) {
|
||||
if (Window.this.isClient() && Window.this.getGui() != null) {
|
||||
Window.this.getGui().resize(Window.this.getSize());
|
||||
if (Window.this.title != null) {
|
||||
Window.this.title.setSize(new IPoint(Window.this.w(), Window.this.title.h()));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setTitle(final String title) {
|
||||
(this.title = new ControlTextCentered(this, 12, title)).setColour(4210752);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Nullable
|
||||
public final GuiCraftGUI getGui() {
|
||||
Preconditions.checkState(this.gui != null, "tried to get gui on server-side, should not be possible");
|
||||
return this.gui;
|
||||
}
|
||||
|
||||
@@ -239,10 +241,7 @@ public abstract class Window extends TopLevelWidget implements INetwork.RecieveG
|
||||
|
||||
@Nullable
|
||||
public ItemStack getHeldItemStack() {
|
||||
if (this.player != null) {
|
||||
return this.player.inventory.getItemStack();
|
||||
}
|
||||
return null;
|
||||
return this.player.inventory.getItemStack();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -250,18 +249,11 @@ public abstract class Window extends TopLevelWidget implements INetwork.RecieveG
|
||||
return this.entityInventory;
|
||||
}
|
||||
|
||||
public void setInventories(final EntityPlayer player2, @Nullable final IInventory inventory) {
|
||||
this.player = player2;
|
||||
this.entityInventory = inventory;
|
||||
}
|
||||
|
||||
public void onClose() {
|
||||
}
|
||||
|
||||
public void setHeldItemStack(final ItemStack stack) {
|
||||
if (this.player != null) {
|
||||
this.player.inventory.setItemStack(stack);
|
||||
}
|
||||
this.player.inventory.setItemStack(stack);
|
||||
}
|
||||
|
||||
public boolean isServer() {
|
||||
@@ -273,10 +265,7 @@ public abstract class Window extends TopLevelWidget implements INetwork.RecieveG
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
if (this.getPlayer() != null) {
|
||||
return this.getPlayer().worldObj;
|
||||
}
|
||||
return BinnieCore.getBinnieProxy().getWorld();
|
||||
return this.getPlayer().worldObj;
|
||||
}
|
||||
|
||||
public void onInventoryUpdate() {
|
||||
@@ -320,6 +309,6 @@ public abstract class Window extends TopLevelWidget implements INetwork.RecieveG
|
||||
}
|
||||
|
||||
public static <T extends Window> T get(final IWidget widget) {
|
||||
return (T) widget.getSuperParent();
|
||||
return (T) widget.getTopParent();
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,7 @@ public class WindowInventory implements IInventory {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ItemStack getStackInSlot(final int var1) {
|
||||
if (this.inventory.containsKey(var1)) {
|
||||
return this.inventory.get(var1);
|
||||
@@ -49,6 +50,7 @@ public class WindowInventory implements IInventory {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ItemStack decrStackSize(final int index, int amount) {
|
||||
if (this.inventory.containsKey(index)) {
|
||||
final ItemStack item = this.inventory.get(index);
|
||||
@@ -57,8 +59,7 @@ public class WindowInventory implements IInventory {
|
||||
if (amount > available) {
|
||||
amount = available;
|
||||
}
|
||||
final ItemStack itemStack = item;
|
||||
itemStack.stackSize -= amount;
|
||||
item.stackSize -= amount;
|
||||
output.stackSize = amount;
|
||||
if (item.stackSize == 0) {
|
||||
this.setInventorySlotContents(index, null);
|
||||
@@ -69,8 +70,8 @@ public class WindowInventory implements IInventory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(final int var1, final ItemStack var2) {
|
||||
this.inventory.put(var1, var2);
|
||||
public void setInventorySlotContents(final int index, @Nullable final ItemStack stack) {
|
||||
this.inventory.put(index, stack);
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
@@ -111,11 +112,11 @@ public class WindowInventory implements IInventory {
|
||||
return !this.disabledAutoDispenses.contains(i);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public SlotValidator getValidator(final int i) {
|
||||
return this.validators.get(i);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasCustomName() {
|
||||
return false;
|
||||
@@ -136,10 +137,9 @@ public class WindowInventory implements IInventory {
|
||||
return "window.inventory";
|
||||
}
|
||||
|
||||
//TODO INV
|
||||
@Override
|
||||
public void clear() {
|
||||
|
||||
this.inventory.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -160,10 +160,9 @@ public class WindowInventory implements IInventory {
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemStack removeStackFromSlot(int index) {
|
||||
return null;
|
||||
return this.inventory.remove(index);
|
||||
}
|
||||
|
||||
//TODO end inv
|
||||
@Override
|
||||
public ITextComponent getDisplayName() {
|
||||
return new TextComponentString("Inventory");
|
||||
|
||||
@@ -49,7 +49,7 @@ public class ControlItemDisplay extends Control implements ITooltip {
|
||||
return;
|
||||
}
|
||||
|
||||
final IPoint relativeToWindow = this.getAbsolutePosition().sub(this.getSuperParent().getPosition());
|
||||
final IPoint relativeToWindow = this.getAbsolutePosition().sub(this.getTopParent().getPosition());
|
||||
if (relativeToWindow.x() > Window.get(this).getSize().x() + 100 || relativeToWindow.y() > Window.get(this).getSize().y() + 100) {
|
||||
return;
|
||||
}
|
||||
@@ -67,7 +67,7 @@ public class ControlItemDisplay extends Control implements ITooltip {
|
||||
GlStateManager.enableAlpha();
|
||||
}
|
||||
|
||||
public void setItemStack(final ItemStack itemStack) {
|
||||
public void setItemStack(@Nullable final ItemStack itemStack) {
|
||||
this.itemStack = itemStack;
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ public class ControlItemDisplay extends Control implements ITooltip {
|
||||
@Override
|
||||
public void getTooltip(final Tooltip tooltip) {
|
||||
if (this.hastooltip && this.itemStack != null) {
|
||||
tooltip.add(this.itemStack.getTooltip(((Window) this.getSuperParent()).getPlayer(), false));
|
||||
tooltip.add(this.itemStack.getTooltip(((Window) this.getTopParent()).getPlayer(), false));
|
||||
}
|
||||
super.getTooltip(tooltip);
|
||||
}
|
||||
|
||||
@@ -78,21 +78,20 @@ public class ControlLiquidTank extends Control implements ITooltip {
|
||||
public void onRenderBackground(int guiWidth, int guiHeight) {
|
||||
CraftGUI.render.texture(this.horizontal ? CraftGUITexture.HorizontalLiquidTank : CraftGUITexture.LiquidTank, IPoint.ZERO);
|
||||
GuiCraftGUI gui = Window.get(this).getGui();
|
||||
if (gui != null) {
|
||||
if (this.isMouseOver() && gui.isHelpMode()) {
|
||||
final int c = -1442840576 + MinecraftTooltip.getOutline(Tooltip.Type.Help);
|
||||
RenderUtil.drawGradientRect(this.getArea().inset(1), c, c);
|
||||
} else if (ControlLiquidTank.tankError.contains(this.tankID)) {
|
||||
final int c = -1442840576 + MinecraftTooltip.getOutline(MinecraftTooltip.Type.Error);
|
||||
RenderUtil.drawGradientRect(this.getArea().inset(1), c, c);
|
||||
} else if (this.getSuperParent().getMousedOverWidget() == this) {
|
||||
if (gui.getDraggedItem() != null) {
|
||||
RenderUtil.drawGradientRect(this.getArea().inset(1), -1426089575, -1426089575);
|
||||
} else {
|
||||
RenderUtil.drawGradientRect(this.getArea().inset(1), -2130706433, -2130706433);
|
||||
}
|
||||
if (this.isMouseOver() && gui.isHelpMode()) {
|
||||
final int c = -1442840576 + MinecraftTooltip.getOutline(Tooltip.Type.Help);
|
||||
RenderUtil.drawGradientRect(this.getArea().inset(1), c, c);
|
||||
} else if (ControlLiquidTank.tankError.contains(this.tankID)) {
|
||||
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) {
|
||||
RenderUtil.drawGradientRect(this.getArea().inset(1), -1426089575, -1426089575);
|
||||
} else {
|
||||
RenderUtil.drawGradientRect(this.getArea().inset(1), -2130706433, -2130706433);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.isTankValid()) {
|
||||
final int height = this.horizontal ? 16 : 58;
|
||||
final int squaled = Math.round(height * (this.getTank().getAmount() / this.getTank().getCapacity()));
|
||||
@@ -134,7 +133,7 @@ public class ControlLiquidTank extends Control implements ITooltip {
|
||||
public void onRenderForeground(int guiWidth, int guiHeight) {
|
||||
CraftGUI.render.texture(this.horizontal ? CraftGUITexture.HorizontalLiquidTankOverlay : CraftGUITexture.LiquidTankOverlay, IPoint.ZERO);
|
||||
GuiCraftGUI gui = Window.get(this).getGui();
|
||||
if (this.isMouseOver() && gui != null && gui.isHelpMode()) {
|
||||
if (this.isMouseOver() && gui.isHelpMode()) {
|
||||
final IArea area = this.getArea();
|
||||
RenderUtil.setColour(MinecraftTooltip.getOutline(Tooltip.Type.Help));
|
||||
CraftGUI.render.texture(CraftGUITexture.Outline, area.outset(1));
|
||||
|
||||
@@ -6,33 +6,33 @@ import binnie.craftgui.minecraft.InventoryType;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ControlPlayerInventory extends Control {
|
||||
private List<ControlSlot> slots;
|
||||
private final List<ControlSlot> slots;
|
||||
|
||||
public ControlPlayerInventory(final IWidget parent, final boolean wide) {
|
||||
super(parent, parent.getSize().x() / 2 - (wide ? 110 : 81), parent.getSize().y() - (wide ? 54 : 76) - 12, wide ? 220 : 162, wide ? 54 : 76);
|
||||
this.slots = new ArrayList<>();
|
||||
for (int row = 0; row < 3; ++row) {
|
||||
for (int column = 0; column < 9; ++column) {
|
||||
final ControlSlot slot = new ControlSlot(this, (wide ? 58 : 0) + column * 18, row * 18);
|
||||
final ControlSlot slot = new ControlSlot.Builder(this, (wide ? 58 : 0) + column * 18, row * 18).assign(InventoryType.Player, 9 + column + row * 9);
|
||||
this.slots.add(slot);
|
||||
}
|
||||
}
|
||||
if (wide) {
|
||||
for (int i1 = 0; i1 < 9; ++i1) {
|
||||
final ControlSlot slot2 = new ControlSlot(this, i1 % 3 * 18, i1 / 3 * 18);
|
||||
final ControlSlot slot2 = new ControlSlot.Builder(this, i1 % 3 * 18, i1 / 3 * 18).assign(InventoryType.Player, i1);
|
||||
this.slots.add(slot2);
|
||||
}
|
||||
} else {
|
||||
for (int i1 = 0; i1 < 9; ++i1) {
|
||||
final ControlSlot slot2 = new ControlSlot(this, i1 * 18, 58);
|
||||
final ControlSlot slot2 = new ControlSlot.Builder(this, i1 * 18, 58).assign(InventoryType.Player, i1);
|
||||
this.slots.add(slot2);
|
||||
}
|
||||
}
|
||||
this.create();
|
||||
}
|
||||
|
||||
public ControlPlayerInventory(final IWidget parent) {
|
||||
@@ -44,30 +44,13 @@ public class ControlPlayerInventory extends Control {
|
||||
this.slots = new ArrayList<>();
|
||||
for (int row = 0; row < 6; ++row) {
|
||||
for (int column = 0; column < 6; ++column) {
|
||||
final ControlSlot slot = new ControlSlot(this, column * 18, row * 18);
|
||||
final ControlSlot slot = new ControlSlot.Builder(this, column * 18, row * 18).assign(InventoryType.Player, 9 + column + row * 9);
|
||||
this.slots.add(slot);
|
||||
}
|
||||
}
|
||||
this.create();
|
||||
}
|
||||
|
||||
public void create() {
|
||||
for (int row = 0; row < 3; ++row) {
|
||||
for (int column = 0; column < 9; ++column) {
|
||||
final ControlSlot slot = this.slots.get(column + row * 9);
|
||||
slot.assign(InventoryType.Player, 9 + column + row * 9);
|
||||
}
|
||||
}
|
||||
for (int i1 = 0; i1 < 9; ++i1) {
|
||||
final ControlSlot slot2 = this.slots.get(27 + i1);
|
||||
slot2.assign(InventoryType.Player, i1);
|
||||
}
|
||||
}
|
||||
|
||||
public void addItem(final ItemStack item) {
|
||||
if (item == null) {
|
||||
return;
|
||||
}
|
||||
public void addItem(@Nullable final ItemStack item) {
|
||||
for (final ControlSlot slot : this.slots) {
|
||||
if (!slot.slot.getHasStack()) {
|
||||
slot.slot.putStack(item);
|
||||
@@ -77,10 +60,12 @@ public class ControlPlayerInventory extends Control {
|
||||
|
||||
public void addInventory(final IInventory inventory) {
|
||||
for (int i = 0; i < inventory.getSizeInventory(); ++i) {
|
||||
this.addItem(inventory.getStackInSlot(i));
|
||||
ItemStack stackInSlot = inventory.getStackInSlot(i);
|
||||
this.addItem(stackInSlot);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ControlSlot getSlot(final int i) {
|
||||
if (i < 0 || i >= this.slots.size()) {
|
||||
return null;
|
||||
|
||||
@@ -11,6 +11,7 @@ import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.core.renderer.RenderUtil;
|
||||
import binnie.craftgui.events.EventMouse;
|
||||
import binnie.craftgui.minecraft.CustomSlot;
|
||||
import binnie.craftgui.minecraft.GuiCraftGUI;
|
||||
import binnie.craftgui.minecraft.InventoryType;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import binnie.craftgui.minecraft.WindowInventory;
|
||||
@@ -25,46 +26,69 @@ import net.minecraft.inventory.ClickType;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ControlSlot extends ControlSlotBase {
|
||||
public static Map<EnumHighlighting, List<Integer>> highlighting = new HashMap<>();
|
||||
public static final Map<EnumHighlighting, List<Integer>> highlighting = new EnumMap<>(EnumHighlighting.class);
|
||||
public static boolean shiftClickActive = false;
|
||||
public Slot slot;
|
||||
|
||||
public ControlSlot(final IWidget parent, final int x, final int y) {
|
||||
static {
|
||||
for (final EnumHighlighting h : EnumHighlighting.values()) {
|
||||
ControlSlot.highlighting.put(h, new ArrayList<>());
|
||||
}
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private final IWidget parent;
|
||||
private final int x;
|
||||
private final int y;
|
||||
|
||||
public Builder(final IWidget parent, final int x, final int y) {
|
||||
this.parent = parent;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public ControlSlot assign(final int index) {
|
||||
return assign(InventoryType.Machine, index);
|
||||
}
|
||||
|
||||
public ControlSlot assign(final InventoryType inventory, final int index) {
|
||||
Slot slot = ((Window) parent.getTopParent()).getContainer().getOrCreateSlot(inventory, index);
|
||||
return new ControlSlot(parent, x, y, slot);
|
||||
}
|
||||
}
|
||||
|
||||
public final Slot slot;
|
||||
|
||||
public ControlSlot(final IWidget parent, final int x, final int y, final Slot slot) {
|
||||
super(parent, x, y);
|
||||
this.slot = null;
|
||||
this.slot = slot;
|
||||
this.addSelfEventHandler(new EventMouse.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventMouse.Down event) {
|
||||
if (ControlSlot.this.slot != null) {
|
||||
final PlayerControllerMP playerController = ((Window) ControlSlot.this.getSuperParent()).getGui().getMinecraft().playerController;
|
||||
final int windowId = ((Window) ControlSlot.this.getSuperParent()).getContainer().windowId;
|
||||
final int slotNumber = ControlSlot.this.slot.slotNumber;
|
||||
final int button = event.getButton();
|
||||
Window.get(ControlSlot.this.getWidget()).getGui();
|
||||
playerController.windowClick(windowId, slotNumber, button, GuiScreen.isShiftKeyDown() ? ClickType.QUICK_MOVE : ClickType.PICKUP, ((Window) ControlSlot.this.getSuperParent()).getGui().getMinecraft().thePlayer);
|
||||
Window superParent = (Window) ControlSlot.this.getTopParent();
|
||||
GuiCraftGUI superParentGui = superParent.getGui();
|
||||
Minecraft minecraft = superParentGui.getMinecraft();
|
||||
final PlayerControllerMP playerController = minecraft.playerController;
|
||||
final int windowId = superParent.getContainer().windowId;
|
||||
final int slotNumber = ControlSlot.this.slot.slotNumber;
|
||||
final int button = event.getButton();
|
||||
Window.get(ControlSlot.this.getWidget()).getGui();
|
||||
if (playerController != null) {
|
||||
playerController.windowClick(windowId, slotNumber, button, GuiScreen.isShiftKeyDown() ? ClickType.QUICK_MOVE : ClickType.PICKUP, minecraft.thePlayer);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public ControlSlot(final IWidget parent, final int x, final int y, final Slot slot) {
|
||||
super(parent, x, y);
|
||||
this.slot = null;
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground(int guiWidth, int guiHeight) {
|
||||
CraftGUI.render.texture(CraftGUITexture.Slot, IPoint.ZERO);
|
||||
if (this.slot == null) {
|
||||
return;
|
||||
}
|
||||
final InventorySlot islot = this.getInventorySlot();
|
||||
if (islot != null) {
|
||||
SlotValidator validator = islot.getValidator();
|
||||
@@ -89,8 +113,9 @@ public class ControlSlot extends ControlSlotBase {
|
||||
final int c = -1442840576 + Math.min(highlight.getKey().getColour(), 16777215);
|
||||
RenderUtil.drawGradientRect(new IArea(1, 1, 16, 16), c, c);
|
||||
}
|
||||
if (!highlighted && this.getSuperParent().getMousedOverWidget() == this) {
|
||||
if (Window.get(this).getGui().getDraggedItem() != null && !this.slot.isItemValid(Window.get(this).getGui().getDraggedItem())) {
|
||||
if (!highlighted && this.getTopParent().getMousedOverWidget() == this) {
|
||||
GuiCraftGUI gui = Window.get(this).getGui();
|
||||
if (gui.getDraggedItem() != null && !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);
|
||||
@@ -100,9 +125,6 @@ public class ControlSlot extends ControlSlotBase {
|
||||
|
||||
@Override
|
||||
public void onRenderOverlay() {
|
||||
if (this.slot == null) {
|
||||
return;
|
||||
}
|
||||
boolean highlighted = false;
|
||||
for (final Map.Entry<EnumHighlighting, List<Integer>> highlight : ControlSlot.highlighting.entrySet()) {
|
||||
if (highlight.getKey() == EnumHighlighting.ShiftClick && !ControlSlot.shiftClickActive) {
|
||||
@@ -126,18 +148,13 @@ public class ControlSlot extends ControlSlotBase {
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
super.onUpdateClient();
|
||||
if (this.slot == null) {
|
||||
return;
|
||||
}
|
||||
if (this.isMouseOver() && GuiScreen.isShiftKeyDown()) {
|
||||
Window.get(this).getContainer().setMouseOverSlot(this.slot);
|
||||
ControlSlot.shiftClickActive = true;
|
||||
}
|
||||
if (Window.get(this).getGui().isHelpMode() && this.isMouseOver()) {
|
||||
for (final ControlSlot slot2 : this.getControlSlots()) {
|
||||
if (slot2.slot != null) {
|
||||
ControlSlot.highlighting.get(EnumHighlighting.Help).add(slot2.slot.slotNumber);
|
||||
}
|
||||
ControlSlot.highlighting.get(EnumHighlighting.Help).add(slot2.slot.slotNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -156,31 +173,13 @@ public class ControlSlot extends ControlSlotBase {
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
if (this.slot != null) {
|
||||
return this.slot.getStack();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ControlSlot assign(final int index) {
|
||||
return this.assign(InventoryType.Machine, index);
|
||||
}
|
||||
|
||||
public ControlSlot assign(final InventoryType inventory, final int index) {
|
||||
if (this.slot != null) {
|
||||
return this;
|
||||
}
|
||||
this.slot = ((Window) this.getSuperParent()).getContainer().getOrCreateSlot(inventory, index);
|
||||
return this;
|
||||
return this.slot.getStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getHelpTooltip(final Tooltip tooltip) {
|
||||
if (this.slot == null) {
|
||||
return;
|
||||
}
|
||||
final InventorySlot slot = this.getInventorySlot();
|
||||
if (this.getInventorySlot() != null) {
|
||||
if (slot != null) {
|
||||
tooltip.add(slot.getName());
|
||||
tooltip.add("Insert Side: " + MachineSide.asString(slot.getInputSides()));
|
||||
tooltip.add("Extract Side: " + MachineSide.asString(slot.getOutputSides()));
|
||||
@@ -196,13 +195,13 @@ public class ControlSlot extends ControlSlotBase {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public InventorySlot getInventorySlot() {
|
||||
return (this.slot instanceof CustomSlot) ? ((CustomSlot) this.slot).getInventorySlot() : null;
|
||||
}
|
||||
|
||||
static {
|
||||
for (final EnumHighlighting h : EnumHighlighting.values()) {
|
||||
ControlSlot.highlighting.put(h, new ArrayList<>());
|
||||
if (this.slot instanceof CustomSlot) {
|
||||
CustomSlot customSlot = (CustomSlot) this.slot;
|
||||
return customSlot.getInventorySlot();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package binnie.craftgui.minecraft.control;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.minecraft.InventoryType;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -10,24 +11,45 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class ControlSlotArray extends Control implements Iterable<ControlSlot> {
|
||||
private int rows;
|
||||
private int columns;
|
||||
private List<ControlSlot> slots;
|
||||
public static class Builder {
|
||||
private final IWidget parent;
|
||||
private final int x;
|
||||
private final int y;
|
||||
private final int columns;
|
||||
private final int rows;
|
||||
|
||||
public ControlSlotArray(final IWidget parent, final int x, final int y, final int columns, final int rows) {
|
||||
super(parent, x, y, columns * 18, rows * 18);
|
||||
this.slots = new ArrayList<>();
|
||||
this.rows = rows;
|
||||
this.columns = columns;
|
||||
for (int row = 0; row < rows; ++row) {
|
||||
for (int column = 0; column < columns; ++column) {
|
||||
this.slots.add(this.createSlot(column * 18, row * 18));
|
||||
public Builder(final IWidget parent, final int x, final int y, final int columns, final int rows) {
|
||||
this.parent = parent;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.columns = columns;
|
||||
this.rows = rows;
|
||||
}
|
||||
|
||||
public ControlSlotArray create(final int[] index) {
|
||||
return this.create(InventoryType.Machine, index);
|
||||
}
|
||||
|
||||
public ControlSlotArray create(final InventoryType type, final int[] index) {
|
||||
ControlSlotArray controlSlots = new ControlSlotArray(parent, x, y, columns, rows);
|
||||
int i = 0;
|
||||
for (int row = 0; row < rows; ++row) {
|
||||
for (int column = 0; column < columns; ++column) {
|
||||
ControlSlot.Builder slotBuilder = new ControlSlot.Builder(controlSlots, column * 18, row * 18);
|
||||
ControlSlot slot = slotBuilder.assign(type, index[i++]);
|
||||
controlSlots.slots.add(slot);
|
||||
}
|
||||
}
|
||||
|
||||
return controlSlots;
|
||||
}
|
||||
}
|
||||
|
||||
public ControlSlot createSlot(final int x, final int y) {
|
||||
return new ControlSlot(this, x, y);
|
||||
private List<ControlSlot> slots = new ArrayList<>();
|
||||
|
||||
private ControlSlotArray(final IWidget parent, final int x, final int y, final int columns, final int rows) {
|
||||
super(parent, x, y, columns * 18, rows * 18);
|
||||
this.slots = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void setItemStacks(final ItemStack[] array) {
|
||||
@@ -36,30 +58,17 @@ public class ControlSlotArray extends Control implements Iterable<ControlSlot> {
|
||||
if (i >= this.slots.size()) {
|
||||
return;
|
||||
}
|
||||
this.slots.get(i).slot.putStack(item);
|
||||
ControlSlot controlSlot = this.slots.get(i);
|
||||
Slot slot = controlSlot.slot;
|
||||
slot.putStack(item);
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
public ControlSlot getControlSlot(final int i) {
|
||||
if (i < 0 || i >= this.slots.size()) {
|
||||
return null;
|
||||
}
|
||||
return this.slots.get(i);
|
||||
}
|
||||
|
||||
public ControlSlotArray create(final int[] index) {
|
||||
return this.create(InventoryType.Machine, index);
|
||||
}
|
||||
|
||||
public ControlSlotArray create(final InventoryType type, final int[] index) {
|
||||
int i = 0;
|
||||
for (final ControlSlot slot : this.slots) {
|
||||
slot.assign(type, index[i++]);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<ControlSlot> iterator() {
|
||||
return this.slots.iterator();
|
||||
|
||||
@@ -14,6 +14,8 @@ import binnie.craftgui.minecraft.Window;
|
||||
import binnie.craftgui.resource.minecraft.CraftGUITexture;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public abstract class ControlSlotBase extends Control implements ITooltip {
|
||||
private ControlItemDisplay itemDisplay;
|
||||
|
||||
@@ -43,7 +45,7 @@ public abstract class ControlSlotBase extends Control implements ITooltip {
|
||||
public void onRenderBackground(int guiWidth, int guiHeight) {
|
||||
final int size = this.getSize().x();
|
||||
CraftGUI.render.texture(CraftGUITexture.Slot, this.getArea());
|
||||
if (this.getSuperParent().getMousedOverWidget() == this) {
|
||||
if (this.getTopParent().getMousedOverWidget() == this) {
|
||||
RenderUtil.drawGradientRect(new IArea(new IPoint(1, 1), this.getArea().size().sub(new IPoint(2, 2))), -2130706433, -2130706433);
|
||||
}
|
||||
}
|
||||
@@ -60,8 +62,9 @@ public abstract class ControlSlotBase extends Control implements ITooltip {
|
||||
if (item == null) {
|
||||
return;
|
||||
}
|
||||
tooltip.add(item.getTooltip(((Window) this.getSuperParent()).getPlayer(), false));
|
||||
tooltip.add(item.getTooltip(((Window) this.getTopParent()).getPlayer(), false));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public abstract ItemStack getItemStack();
|
||||
}
|
||||
@@ -6,6 +6,8 @@ import binnie.craftgui.controls.tab.ControlTabBar;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ControlTabIcon<T> extends ControlTab<T> {
|
||||
private ControlItemDisplay item;
|
||||
|
||||
@@ -15,6 +17,7 @@ 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();
|
||||
@@ -26,7 +29,8 @@ public class ControlTabIcon<T> extends ControlTab<T> {
|
||||
public void onUpdateClient() {
|
||||
super.onUpdateClient();
|
||||
this.item.setItemStack(this.getItemStack());
|
||||
final int x = ((ControlTabBar) this.getParent()).getDirection().x();
|
||||
ControlTabBar parent = (ControlTabBar) this.getParent();
|
||||
final int x = parent.getDirection().x();
|
||||
this.item.setOffset(new IPoint((this.isCurrentSelection() || this.isMouseOver()) ? 0 : (-4 * x), 0));
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ public class ControlDatabaseIndividualDisplay extends ControlItemDisplay impleme
|
||||
@Override
|
||||
public void onEvent(final EventMouse.Down event) {
|
||||
if (event.getButton() == 0 && ControlDatabaseIndividualDisplay.this.species != null && EnumDiscoveryState.Show == ControlDatabaseIndividualDisplay.this.discovered) {
|
||||
((WindowAbstractDatabase) ControlDatabaseIndividualDisplay.this.getSuperParent()).gotoSpeciesDelayed(ControlDatabaseIndividualDisplay.this.species);
|
||||
((WindowAbstractDatabase) ControlDatabaseIndividualDisplay.this.getTopParent()).gotoSpeciesDelayed(ControlDatabaseIndividualDisplay.this.species);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -30,7 +30,7 @@ class ControlMutationBox extends ControlListBox<IMutation> {
|
||||
this.species = species;
|
||||
this.index = 0;
|
||||
this.movePercentage(-100.0f);
|
||||
final BreedingSystem system = ((WindowAbstractDatabase) this.getSuperParent()).getBreedingSystem();
|
||||
final BreedingSystem system = ((WindowAbstractDatabase) this.getTopParent()).getBreedingSystem();
|
||||
final List<IMutation> discovered = system.getDiscoveredMutations(Window.get(this).getWorld(), Window.get(this).getUsername());
|
||||
if (species != null) {
|
||||
if (this.type == Type.Resultant) {
|
||||
|
||||
@@ -21,8 +21,8 @@ class ControlMutationItem extends ControlOption<IMutation> {
|
||||
this.itemWidget3 = new ControlDatabaseIndividualDisplay(this, 104, 4);
|
||||
this.addSymbol = new ControlMutationSymbol(this, 24, 4, 0);
|
||||
this.arrowSymbol = new ControlMutationSymbol(this, 64, 4, 1);
|
||||
final boolean isNEI = ((WindowAbstractDatabase) this.getSuperParent()).isNEI();
|
||||
final BreedingSystem system = ((WindowAbstractDatabase) this.getSuperParent()).getBreedingSystem();
|
||||
final boolean isNEI = ((WindowAbstractDatabase) this.getTopParent()).isNEI();
|
||||
final BreedingSystem system = ((WindowAbstractDatabase) this.getTopParent()).getBreedingSystem();
|
||||
if (this.getValue() != null) {
|
||||
final boolean isMutationDiscovered = system.isMutationDiscovered(this.getValue(), Window.get(this).getWorld(), Window.get(this).getUsername());
|
||||
IAlleleSpecies allele = null;
|
||||
|
||||
@@ -41,8 +41,8 @@ class ControlMutationSymbol extends Control implements ITooltip {
|
||||
|
||||
public void setValue(final IMutation value) {
|
||||
this.value = value;
|
||||
final boolean isNEI = ((WindowAbstractDatabase) this.getSuperParent()).isNEI();
|
||||
final BreedingSystem system = ((WindowAbstractDatabase) this.getSuperParent()).getBreedingSystem();
|
||||
final boolean isNEI = ((WindowAbstractDatabase) this.getTopParent()).isNEI();
|
||||
final BreedingSystem system = ((WindowAbstractDatabase) this.getTopParent()).getBreedingSystem();
|
||||
this.discovered = (isNEI || system.isMutationDiscovered(value, Window.get(this).getWorld(), Window.get(this).getUsername()));
|
||||
if (this.discovered) {
|
||||
this.setColour(16777215);
|
||||
@@ -56,7 +56,7 @@ class ControlMutationSymbol extends Control implements ITooltip {
|
||||
if (this.type == 1 && this.discovered) {
|
||||
final IAllele species1 = this.value.getAllele0();
|
||||
final IAllele species2 = this.value.getAllele1();
|
||||
final BreedingSystem system = ((WindowAbstractDatabase) this.getSuperParent()).getBreedingSystem();
|
||||
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) {
|
||||
|
||||
@@ -24,7 +24,7 @@ public class PageBranchSpecies extends PageBranch {
|
||||
@Override
|
||||
public void onEvent(final EventValueChanged event) {
|
||||
if (event.isOrigin(PageBranchSpecies.this.pageBranchSpecies_speciesList)) {
|
||||
((WindowAbstractDatabase) PageBranchSpecies.this.getSuperParent()).gotoSpecies((IAlleleSpecies) event.getValue());
|
||||
((WindowAbstractDatabase) PageBranchSpecies.this.getTopParent()).gotoSpecies((IAlleleSpecies) event.getValue());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -15,6 +15,6 @@ public class PageBreederStats extends Control {
|
||||
super(parent, 0, 0, w, h);
|
||||
this.player = player;
|
||||
final ControlText pageBranchOverview_branchName = new ControlTextCentered(this, 8, TextFormatting.UNDERLINE + Binnie.LANGUAGE.localise("binniecore.gui.database.breeder.stats"));
|
||||
final BreedingSystem system = ((WindowAbstractDatabase) this.getSuperParent()).getBreedingSystem();
|
||||
final BreedingSystem system = ((WindowAbstractDatabase) this.getTopParent()).getBreedingSystem();
|
||||
}
|
||||
}
|
||||
@@ -202,7 +202,7 @@ public abstract class WindowAbstractDatabase extends Window {
|
||||
public void onUpdateClient() {
|
||||
super.onUpdateClient();
|
||||
if (this.gotoSpecies != null) {
|
||||
((WindowAbstractDatabase) this.getSuperParent()).gotoSpecies(this.gotoSpecies);
|
||||
((WindowAbstractDatabase) this.getTopParent()).gotoSpecies(this.gotoSpecies);
|
||||
this.gotoSpecies = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,10 @@ import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.core.geometry.IBorder;
|
||||
import binnie.craftgui.core.geometry.Position;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class Texture {
|
||||
@Nullable
|
||||
public static final Texture NULL = null;
|
||||
IArea area;
|
||||
IBorder padding;
|
||||
|
||||
@@ -11,6 +11,8 @@ import forestry.api.core.Tabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ItemHiveFrame extends Item implements IHiveFrame, IBeeModifier, IItemModelRegister {
|
||||
EnumHiveFrame frame;
|
||||
|
||||
@@ -53,6 +55,7 @@ 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()) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemIndustrialFrame extends Item {
|
||||
@@ -53,10 +54,12 @@ public class ItemIndustrialFrame extends Item {
|
||||
this.setUnlocalizedName("industrialFrame");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static IndustrialFrame getFrame(final ItemStack stack) {
|
||||
if (stack == null || !stack.hasTagCompound() || !stack.getTagCompound().hasKey("frame")) {
|
||||
NBTTagCompound tagCompound = stack.getTagCompound();
|
||||
if (tagCompound == null || !tagCompound.hasKey("frame")) {
|
||||
return null;
|
||||
}
|
||||
return IndustrialFrame.values()[stack.getTagCompound().getInteger("frame")];
|
||||
return IndustrialFrame.values()[tagCompound.getInteger("frame")];
|
||||
}
|
||||
}
|
||||
@@ -31,8 +31,7 @@ public class AlvearyFrame {
|
||||
public void createMachine(final Machine machine) {
|
||||
new ComponentExtraBeeGUI(machine, ExtraBeeGUID.AlvearyFrame);
|
||||
final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
inventory.addSlot(AlvearyFrame.slotFrame, "frame");
|
||||
inventory.getSlot(AlvearyFrame.slotFrame).setValidator(new SlotValidatorFrame());
|
||||
inventory.addSlot(AlvearyFrame.slotFrame, "frame").setValidator(new SlotValidatorFrame());
|
||||
new ComponentFrameModifier(machine);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,8 +60,7 @@ public class AlvearyMutator {
|
||||
public void createMachine(final Machine machine) {
|
||||
new ComponentExtraBeeGUI(machine, ExtraBeeGUID.AlvearyMutator);
|
||||
final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
inventory.addSlot(AlvearyMutator.slotMutator, "mutator");
|
||||
inventory.getSlot(AlvearyMutator.slotMutator).setValidator(new SlotValidatorMutator());
|
||||
inventory.addSlot(AlvearyMutator.slotMutator, "mutator").setValidator(new SlotValidatorMutator());
|
||||
new ComponentMutatorModifier(machine);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,8 +39,7 @@ public class AlvearyStimulator {
|
||||
public void createMachine(final Machine machine) {
|
||||
new ComponentExtraBeeGUI(machine, ExtraBeeGUID.AlvearyStimulator);
|
||||
final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
inventory.addSlot(AlvearyStimulator.slotCircuit, "circuit");
|
||||
inventory.getSlot(AlvearyStimulator.slotCircuit).setValidator(new SlotValidatorCircuit());
|
||||
inventory.addSlot(AlvearyStimulator.slotCircuit, "circuit").setValidator(new SlotValidatorCircuit());
|
||||
final ComponentPowerReceptor power = new ComponentPowerReceptor(machine);
|
||||
new ComponentStimulatorModifier(machine);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,8 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public enum ExtraBeeGUID implements IBinnieGUID {
|
||||
Database,
|
||||
DatabaseNEI,
|
||||
@@ -24,6 +26,7 @@ public enum ExtraBeeGUID implements IBinnieGUID {
|
||||
AlvearyHatchery;
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Window getWindow(final EntityPlayer player, final World world, final int x, final int y, final int z, final Side side) {
|
||||
Window window = null;
|
||||
final TileEntity tileEntity = world.getTileEntity(new BlockPos(x, y, z));
|
||||
|
||||
@@ -12,6 +12,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public enum ExtraBeeItems implements IItemMiscProvider {
|
||||
@@ -48,7 +49,9 @@ public enum ExtraBeeItems implements IItemMiscProvider {
|
||||
|
||||
String name;
|
||||
String modelPath;
|
||||
@Nullable
|
||||
String metalString;
|
||||
@Nullable
|
||||
String gemString;
|
||||
|
||||
public static void init() {
|
||||
|
||||
@@ -6,6 +6,7 @@ import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.api.genetics.IClassification;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -271,6 +272,7 @@ public enum ExtraBeesBranch implements IClassification {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public IClassification[] getMemberGroups() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package binnie.extrabees.gui;
|
||||
|
||||
import binnie.core.AbstractMod;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import binnie.craftgui.minecraft.control.ControlPlayerInventory;
|
||||
import binnie.craftgui.minecraft.control.ControlSlot;
|
||||
@@ -11,17 +9,17 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class WindowAlvearyFrame extends Window {
|
||||
Machine machine;
|
||||
ControlPlayerInventory playerInventory;
|
||||
|
||||
public WindowAlvearyFrame(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
super(176, 144, player, inventory, side);
|
||||
this.machine = ((TileEntityMachine) inventory).getMachine();
|
||||
}
|
||||
|
||||
public static Window create(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
if (player == null || inventory == null) {
|
||||
@Nullable
|
||||
public static Window create(final EntityPlayer player, @Nullable final IInventory inventory, final Side side) {
|
||||
if (inventory == null) {
|
||||
return null;
|
||||
}
|
||||
return new WindowAlvearyFrame(player, inventory, side);
|
||||
@@ -30,9 +28,8 @@ public class WindowAlvearyFrame extends Window {
|
||||
@Override
|
||||
public void initialiseClient() {
|
||||
this.setTitle("Frame Housing");
|
||||
this.playerInventory = new ControlPlayerInventory(this);
|
||||
final ControlSlot slot = new ControlSlot(this, 79, 30);
|
||||
slot.assign(0);
|
||||
ControlPlayerInventory playerInventory = new ControlPlayerInventory(this);
|
||||
new ControlSlot.Builder(this, 79, 30).assign(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,17 +12,16 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
public class WindowAlvearyHatchery extends Window {
|
||||
Machine machine;
|
||||
ControlPlayerInventory playerInventory;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class WindowAlvearyHatchery extends Window {
|
||||
public WindowAlvearyHatchery(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
super(176, 144, player, inventory, side);
|
||||
this.machine = ((TileEntityMachine) inventory).getMachine();
|
||||
}
|
||||
|
||||
public static Window create(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
if (player == null || inventory == null) {
|
||||
@Nullable
|
||||
public static Window create(final EntityPlayer player, @Nullable final IInventory inventory, final Side side) {
|
||||
if (inventory == null) {
|
||||
return null;
|
||||
}
|
||||
return new WindowAlvearyHatchery(player, inventory, side);
|
||||
@@ -31,8 +30,8 @@ public class WindowAlvearyHatchery extends Window {
|
||||
@Override
|
||||
public void initialiseClient() {
|
||||
this.setTitle("Hatchery");
|
||||
this.playerInventory = new ControlPlayerInventory(this);
|
||||
final ControlSlotArray slot = new ControlSlotArray(this, 43, 30, 5, 1);
|
||||
ControlPlayerInventory playerInventory = new ControlPlayerInventory(this);
|
||||
final ControlSlotArray.Builder slot = new ControlSlotArray.Builder(this, 43, 30, 5, 1);
|
||||
slot.create(AlvearyHatchery.slotLarvae);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,27 +12,19 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
public class WindowAlvearyIndustrialFrame extends Window {
|
||||
Machine machine;
|
||||
ControlPlayerInventory playerInventory;
|
||||
|
||||
public WindowAlvearyIndustrialFrame(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
super(176, 144, player, inventory, side);
|
||||
this.machine = ((TileEntityMachine) inventory).getMachine();
|
||||
}
|
||||
|
||||
public static Window create(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
if (player == null || inventory == null) {
|
||||
return null;
|
||||
}
|
||||
return new WindowAlvearyIndustrialFrame(player, inventory, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialiseClient() {
|
||||
this.setTitle("Industrial Frame Housing");
|
||||
this.playerInventory = new ControlPlayerInventory(this);
|
||||
final ControlSlot slot = new ControlSlot(this, 79, 30);
|
||||
slot.assign(0);
|
||||
ControlPlayerInventory playerInventory = new ControlPlayerInventory(this);
|
||||
new ControlSlot.Builder(this, 79, 30).assign(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,17 +17,16 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
public class WindowAlvearyMutator extends Window {
|
||||
Machine machine;
|
||||
ControlPlayerInventory playerInventory;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class WindowAlvearyMutator extends Window {
|
||||
public WindowAlvearyMutator(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
super(176, 176, player, inventory, side);
|
||||
this.machine = ((TileEntityMachine) inventory).getMachine();
|
||||
}
|
||||
|
||||
public static Window create(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
if (player == null || inventory == null) {
|
||||
@Nullable
|
||||
public static Window create(final EntityPlayer player, @Nullable final IInventory inventory, final Side side) {
|
||||
if (inventory == null) {
|
||||
return null;
|
||||
}
|
||||
return new WindowAlvearyMutator(player, inventory, side);
|
||||
@@ -36,9 +35,8 @@ public class WindowAlvearyMutator extends Window {
|
||||
@Override
|
||||
public void initialiseClient() {
|
||||
this.setTitle("Mutator");
|
||||
this.playerInventory = new ControlPlayerInventory(this);
|
||||
final ControlSlot slot = new ControlSlot(this, 79, 30);
|
||||
slot.assign(0);
|
||||
new ControlPlayerInventory(this);
|
||||
new ControlSlot.Builder(this, 79, 30).assign(0);
|
||||
new ControlText(this, new IArea(0, 52, this.w(), 16), "Possible Mutagens:", TextJustification.MiddleCenter).setColour(5592405);
|
||||
final int size = AlvearyMutator.getMutagens().size();
|
||||
final int w = size * 18;
|
||||
|
||||
@@ -14,17 +14,16 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
public class WindowAlvearyStimulator extends Window {
|
||||
Machine machine;
|
||||
ControlPlayerInventory playerInventory;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class WindowAlvearyStimulator extends Window {
|
||||
public WindowAlvearyStimulator(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
super(176, 144, player, inventory, side);
|
||||
this.machine = ((TileEntityMachine) inventory).getMachine();
|
||||
}
|
||||
|
||||
public static Window create(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
if (player == null || inventory == null) {
|
||||
@Nullable
|
||||
public static Window create(final EntityPlayer player, @Nullable final IInventory inventory, final Side side) {
|
||||
if (inventory == null) {
|
||||
return null;
|
||||
}
|
||||
return new WindowAlvearyStimulator(player, inventory, side);
|
||||
@@ -34,9 +33,8 @@ public class WindowAlvearyStimulator extends Window {
|
||||
public void initialiseClient() {
|
||||
this.setTitle("Stimulator");
|
||||
new ControlEnergyBar(this, 75, 29, 60, 16, Position.Left);
|
||||
final ControlSlot slot = new ControlSlot(this, 41, 28);
|
||||
slot.assign(AlvearyStimulator.slotCircuit);
|
||||
this.playerInventory = new ControlPlayerInventory(this);
|
||||
new ControlSlot.Builder(this, 41, 28).assign(AlvearyStimulator.slotCircuit);
|
||||
new ControlPlayerInventory(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -63,7 +63,7 @@ public enum ExtraBeeLiquid implements ILiquidType {
|
||||
|
||||
@Override
|
||||
public boolean showInCreative(final FluidContainerType container) {
|
||||
return container == FluidContainerType.CAN || container == FluidContainerType.CAPSULE || container == FluidContainerType.REFARACTORY;
|
||||
return container == FluidContainerType.CAN || container == FluidContainerType.CAPSULE || container == FluidContainerType.REFRACTORY;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,6 +8,8 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public enum EnumHoneyDrop implements IItemEnum {
|
||||
ENERGY(10242418, 14905713, ""),
|
||||
ACID(4961601, 4841020, "acid"),
|
||||
@@ -39,14 +41,13 @@ public enum EnumHoneyDrop implements IItemEnum {
|
||||
MAGENTA(15040472, 16711884, "for.honey"),
|
||||
LIGHTGRAY(10066329, 13224393, "for.honey");
|
||||
|
||||
int[] colour;
|
||||
String liquidName;
|
||||
ItemStack remenant;
|
||||
public boolean deprecated;
|
||||
private int[] colour;
|
||||
private String liquidName;
|
||||
@Nullable
|
||||
private ItemStack remnant;
|
||||
|
||||
public void addRemenant(final ItemStack stack) {
|
||||
this.remenant = stack;
|
||||
this.deprecated = true;
|
||||
public void addRemnant(final ItemStack stack) {
|
||||
this.remnant = stack;
|
||||
}
|
||||
|
||||
EnumHoneyDrop() {
|
||||
@@ -54,23 +55,21 @@ public enum EnumHoneyDrop implements IItemEnum {
|
||||
}
|
||||
|
||||
EnumHoneyDrop(final int colour, final int colour2, final String liquid) {
|
||||
this.liquidName = "";
|
||||
this.remenant = null;
|
||||
this.deprecated = false;
|
||||
this.remnant = null;
|
||||
this.colour = new int[]{colour, colour2};
|
||||
this.liquidName = liquid;
|
||||
}
|
||||
|
||||
public void addRecipe() {
|
||||
final FluidStack liquid = Binnie.LIQUID.getFluidStack(this.liquidName, 200);
|
||||
final FluidStack liquid = Binnie.LIQUID.getFluidStack(this.getLiquidName(), 200);
|
||||
if (liquid != null) {
|
||||
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{this.get(1)}, liquid, this.remenant, 100);
|
||||
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{this.get(1)}, liquid, this.getRemnant(), 100);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return !this.deprecated && (this.liquidName == null || FluidRegistry.isFluidRegistered(this.liquidName));
|
||||
return this.remnant != null && FluidRegistry.isFluidRegistered(this.getLiquidName());
|
||||
}
|
||||
|
||||
public static EnumHoneyDrop get(final ItemStack itemStack) {
|
||||
@@ -90,4 +89,17 @@ public enum EnumHoneyDrop implements IItemEnum {
|
||||
public String getName(final ItemStack stack) {
|
||||
return ExtraBees.proxy.localise("item.honeydrop." + this.name().toLowerCase());
|
||||
}
|
||||
|
||||
public int[] getColour() {
|
||||
return colour;
|
||||
}
|
||||
|
||||
public String getLiquidName() {
|
||||
return liquidName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ItemStack getRemnant() {
|
||||
return remnant;
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,8 @@ import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ItemHoneyComb extends ItemProduct implements IColoredItem {
|
||||
|
||||
public ItemHoneyComb() {
|
||||
@@ -214,10 +216,11 @@ public class ItemHoneyComb extends ItemProduct implements IColoredItem {
|
||||
}
|
||||
}
|
||||
type.addProduct(drop.get(1), 1.00f);
|
||||
drop.addRemenant(dye);
|
||||
drop.addRemnant(dye);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static ItemStack getOreDictionary(final String string) {
|
||||
if (OreDictionary.getOres(string).size() > 0) {
|
||||
return OreDictionary.getOres(string).get(0);
|
||||
@@ -228,13 +231,11 @@ public class ItemHoneyComb extends ItemProduct implements IColoredItem {
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
|
||||
if (EnumHoneyComb.get(stack) == null) {
|
||||
return 16777215;
|
||||
}
|
||||
EnumHoneyComb honeyComb = EnumHoneyComb.get(stack);
|
||||
if (tintIndex == 1) {
|
||||
return EnumHoneyComb.get(stack).colour[0];
|
||||
return honeyComb.colour[0];
|
||||
}
|
||||
return EnumHoneyComb.get(stack).colour[1];
|
||||
return honeyComb.colour[1];
|
||||
}
|
||||
|
||||
public enum VanillaComb {
|
||||
|
||||
@@ -18,9 +18,9 @@ public class ItemHoneyDrop extends ItemProduct implements IColoredItem {
|
||||
@Override
|
||||
public int getColorFromItemstack(ItemStack itemStack, int tintIndex) {
|
||||
if (tintIndex == 0) {
|
||||
return EnumHoneyDrop.get(itemStack).colour[0];
|
||||
return EnumHoneyDrop.get(itemStack).getColour()[0];
|
||||
}
|
||||
return EnumHoneyDrop.get(itemStack).colour[1];
|
||||
return EnumHoneyDrop.get(itemStack).getColour()[1];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,9 +24,6 @@ public class HiveDrop implements IHiveDrop {
|
||||
|
||||
public HiveDrop(IAllele[] template, final ItemStack[] bonus, final int chance) {
|
||||
this.additional = new ArrayList<>();
|
||||
if (template == null) {
|
||||
template = Binnie.GENETICS.getBeeRoot().getDefaultTemplate();
|
||||
}
|
||||
this.template = template;
|
||||
this.chance = chance;
|
||||
Collections.addAll(this.additional, bonus);
|
||||
|
||||
@@ -4,6 +4,8 @@ import binnie.Binnie;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
||||
public enum Glassware {
|
||||
BeerMug(16, 10, 14),
|
||||
@@ -28,7 +30,7 @@ public enum Glassware {
|
||||
// public IIcon glass;
|
||||
// public IIcon contents;
|
||||
|
||||
public String getName(final String liquid) {
|
||||
public String getName(@Nullable final String liquid) {
|
||||
if (liquid == null) {
|
||||
return ExtraTrees.proxy.localise("item.glassware." + this.name().toLowerCase());
|
||||
}
|
||||
|
||||
@@ -3,12 +3,14 @@ package binnie.extratrees.alcohol.drink;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class DrinkManager {
|
||||
static Map<String, IDrinkLiquid> drinkLiquids = new HashMap<>();
|
||||
|
||||
@Nullable
|
||||
public static IDrinkLiquid getLiquid(final String id) {
|
||||
return DrinkManager.drinkLiquids.get(id.toLowerCase());
|
||||
}
|
||||
@@ -17,10 +19,12 @@ public class DrinkManager {
|
||||
DrinkManager.drinkLiquids.put(liquid.getIdentifier(), liquid);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static IDrinkLiquid getLiquid(final Fluid fluid) {
|
||||
return getLiquid(fluid.getName());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static IDrinkLiquid getLiquid(final FluidStack fluid) {
|
||||
return getLiquid(fluid.getFluid());
|
||||
}
|
||||
|
||||
@@ -14,8 +14,10 @@ import net.minecraftforge.fluids.IFluidContainerItem;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
// TODO use capabilities and remove IFluidContainerItem
|
||||
public class ItemDrink extends ItemFood implements IFluidContainerItem {
|
||||
public ItemDrink() {
|
||||
super(0, 0.0f, false);
|
||||
@@ -28,13 +30,14 @@ public class ItemDrink extends ItemFood implements IFluidContainerItem {
|
||||
}
|
||||
|
||||
public Glassware getGlassware(final ItemStack container) {
|
||||
if (!container.hasTagCompound() || !container.getTagCompound().hasKey("glassware")) {
|
||||
NBTTagCompound nbt = container.getTagCompound();
|
||||
if (nbt == null || !nbt.hasKey("glassware")) {
|
||||
return Glassware.BeerMug;
|
||||
}
|
||||
return Glassware.values()[container.getTagCompound().getShort("glassware")];
|
||||
return Glassware.values()[nbt.getShort("glassware")];
|
||||
}
|
||||
|
||||
public ItemStack getStack(final Glassware glass, final FluidStack fluid) {
|
||||
public ItemStack getStack(final Glassware glass, @Nullable final FluidStack fluid) {
|
||||
final ItemStack stack = new ItemStack(this);
|
||||
this.saveGlassware(glass, stack);
|
||||
this.saveFluid(fluid, stack);
|
||||
@@ -42,17 +45,21 @@ public class ItemDrink extends ItemFood implements IFluidContainerItem {
|
||||
}
|
||||
|
||||
public void saveGlassware(final Glassware container, final ItemStack stack) {
|
||||
if (!stack.hasTagCompound()) {
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
NBTTagCompound nbt = stack.getTagCompound();
|
||||
if (nbt == null) {
|
||||
nbt = new NBTTagCompound();
|
||||
stack.setTagCompound(nbt);
|
||||
}
|
||||
stack.getTagCompound().setShort("glassware", (short) container.ordinal());
|
||||
nbt.setShort("glassware", (short) container.ordinal());
|
||||
}
|
||||
|
||||
public void saveFluid(final FluidStack fluid, final ItemStack stack) {
|
||||
if (!stack.hasTagCompound()) {
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
public void saveFluid(@Nullable final FluidStack fluid, final ItemStack stack) {
|
||||
NBTTagCompound nbt = stack.getTagCompound();
|
||||
if (nbt == null) {
|
||||
nbt = new NBTTagCompound();
|
||||
stack.setTagCompound(nbt);
|
||||
}
|
||||
final NBTTagCompound nbt = stack.getTagCompound();
|
||||
|
||||
if (fluid == null) {
|
||||
nbt.removeTag("fluid");
|
||||
} else {
|
||||
@@ -63,6 +70,7 @@ public class ItemDrink extends ItemFood implements IFluidContainerItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public FluidStack getFluid(final ItemStack container) {
|
||||
if (container.getTagCompound() == null || !container.getTagCompound().hasKey("fluid")) {
|
||||
return null;
|
||||
@@ -109,6 +117,7 @@ public class ItemDrink extends ItemFood implements IFluidContainerItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public FluidStack drain(final ItemStack container, final int maxDrain, final boolean doDrain) {
|
||||
if (!container.hasTagCompound()) {
|
||||
return null;
|
||||
@@ -143,8 +152,20 @@ public class ItemDrink extends ItemFood implements IFluidContainerItem {
|
||||
@Override
|
||||
public String getItemStackDisplayName(final ItemStack stack) {
|
||||
final FluidStack fluid = this.getFluid(stack);
|
||||
final IDrinkLiquid liquid = (fluid == null) ? null : DrinkManager.getLiquid(fluid.getFluid());
|
||||
return this.getGlassware(stack).getName((liquid == null) ? null : liquid.getName());
|
||||
final IDrinkLiquid liquid;
|
||||
if (fluid == null) {
|
||||
liquid = null;
|
||||
} else {
|
||||
liquid = DrinkManager.getLiquid(fluid.getFluid());
|
||||
}
|
||||
|
||||
final String liquidName;
|
||||
if (liquid == null) {
|
||||
liquidName = null;
|
||||
} else {
|
||||
liquidName = liquid.getName();
|
||||
}
|
||||
return this.getGlassware(stack).getName(liquidName);
|
||||
}
|
||||
|
||||
// @Override
|
||||
|
||||
@@ -25,5 +25,6 @@ public interface IDesignSystem {
|
||||
|
||||
ItemStack getAdhesive();
|
||||
|
||||
@Nullable
|
||||
IDesignMaterial getMaterial(final ItemStack p0);
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package binnie.extratrees.block;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import binnie.Constants;
|
||||
import binnie.extratrees.block.property.PropertyETType;
|
||||
@@ -101,15 +102,6 @@ public abstract class BlockETDecorativeLeaves extends Block implements IItemMode
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos) {
|
||||
ETTreeDefinition treeDefinition = blockState.getValue(getVariant());
|
||||
if (TreeDefinition.Willow.equals(treeDefinition)) {
|
||||
return null;
|
||||
}
|
||||
return super.getCollisionBoundingBox(blockState, worldIn, pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called When an Entity Collided with the Block
|
||||
*/
|
||||
|
||||
@@ -21,6 +21,7 @@ import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockETDoor extends BlockDoor implements IBlockMetadata {
|
||||
@@ -285,6 +286,7 @@ public class BlockETDoor extends BlockDoor implements IBlockMetadata {
|
||||
// }
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
|
||||
return BlockMetadata.getPickBlock(world, pos);
|
||||
}
|
||||
|
||||
@@ -53,9 +53,9 @@ public enum EnumETLog implements IWoodType {
|
||||
Shrub("Shrub", PlankType.VanillaPlanks.OAK);
|
||||
|
||||
public static final EnumETLog[] VALUES = values();
|
||||
|
||||
String name;
|
||||
IPlankType plank;
|
||||
|
||||
private final String name;
|
||||
private final IPlankType plank;
|
||||
|
||||
EnumETLog(final String name, final IPlankType plank) {
|
||||
this.name = name;
|
||||
@@ -138,7 +138,7 @@ public enum EnumETLog implements IWoodType {
|
||||
public String getPlankTexture() {
|
||||
return plank.getPlankTextureName();
|
||||
}
|
||||
|
||||
|
||||
public IPlankType getPlank() {
|
||||
return plank;
|
||||
}
|
||||
|
||||
@@ -44,6 +44,8 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import net.minecraftforge.oredict.RecipeSorter;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
||||
public class ModuleBlocks implements IInitializable {
|
||||
// public static int hedgeRenderID;
|
||||
@@ -280,10 +282,7 @@ public class ModuleBlocks implements IInitializable {
|
||||
final ItemStack doorSolid = WoodManager.getDoor(plank2, DoorType.Solid);
|
||||
final ItemStack doorSplit = WoodManager.getDoor(plank2, DoorType.Double);
|
||||
final ItemStack doorFull = WoodManager.getDoor(plank2, DoorType.Full);
|
||||
if (planks2 != null) {
|
||||
if (gate == null) {
|
||||
continue;
|
||||
}
|
||||
if (planks2 != null && gate != null) {
|
||||
gate.stackSize = 1;
|
||||
GameRegistry.addRecipe(gate.copy(), "fpf", 'f', fenceNormal.copy(), 'p', planks2.copy());
|
||||
fenceNormal.stackSize = 4;
|
||||
@@ -317,9 +316,6 @@ public class ModuleBlocks implements IInitializable {
|
||||
|
||||
public static ItemStack getDecorativeLeaves(String speciesUid) {
|
||||
ItemStack itemStack = ExtraTrees.blocks().speciesToLeavesDecorative.get(speciesUid);
|
||||
if (itemStack == null) {
|
||||
return null;
|
||||
}
|
||||
return itemStack.copy();
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class WoodManager {
|
||||
public static String getDisplayName(IWoodTyped wood, IWoodType woodType) {
|
||||
@@ -61,15 +62,14 @@ public class WoodManager {
|
||||
return (index < 0) ? 0 : index;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static FenceType getFenceType(final ItemStack stack) {
|
||||
final FenceDescription desc = getFenceDescription(stack);
|
||||
return (desc == null) ? null : desc.getFenceType();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static FenceDescription getFenceDescription(final ItemStack stack) {
|
||||
if (stack == null) {
|
||||
return null;
|
||||
}
|
||||
if (stack.getItem() == Item.getItemFromBlock(ExtraTrees.blocks().blockMultiFence)) {
|
||||
final int damage = TileEntityMetadata.getItemDamage(stack);
|
||||
return getFenceDescription(damage);
|
||||
@@ -77,10 +77,9 @@ public class WoodManager {
|
||||
for (final IPlankType type : getAllPlankTypes()) {
|
||||
if (type instanceof IFenceProvider) {
|
||||
final ItemStack f = ((IFenceProvider) type).getFence();
|
||||
if (f != null && ItemStack.areItemStacksEqual(stack, f)) {
|
||||
if (ItemStack.areItemStacksEqual(stack, f)) {
|
||||
return new FenceDescription(new FenceType(0), type, type);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -138,9 +137,10 @@ public class WoodManager {
|
||||
return list;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static IPlankType get(final ItemStack species) {
|
||||
for (final IPlankType type : getAllPlankTypes()) {
|
||||
if (type.getStack() != null && type.getStack().isItemEqual(species)) {
|
||||
if (type.getStack().isItemEqual(species)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
Loaded 100 of 163 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user