mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-22 05:02:34 +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
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,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 BlockETFenceGate extends BlockFenceGate implements IBlockMetadata {
|
||||
@@ -127,6 +128,7 @@ public class BlockETFenceGate extends BlockFenceGate implements IBlockMetadata {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
|
||||
return BlockMetadata.getPickBlock(world, pos);
|
||||
}
|
||||
@@ -138,6 +140,6 @@ public class BlockETFenceGate extends BlockFenceGate implements IBlockMetadata {
|
||||
|
||||
@Override
|
||||
public boolean isPassable(IBlockAccess worldIn, BlockPos pos){
|
||||
return worldIn.getBlockState(pos).getValue(OPEN).booleanValue();
|
||||
return worldIn.getBlockState(pos).getValue(OPEN);
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,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 BlockFence extends net.minecraft.block.BlockFence implements IBlockMetadata, IBlockFence {
|
||||
@@ -170,6 +171,7 @@ public class BlockFence extends net.minecraft.block.BlockFence implements IBlock
|
||||
// }
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
|
||||
return BlockMetadata.getPickBlock(world, pos);
|
||||
}
|
||||
|
||||
@@ -10,9 +10,11 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class MultiFenceRecipeEmbedded implements IRecipe {
|
||||
ItemStack cached;
|
||||
@Nullable
|
||||
private ItemStack cached;
|
||||
|
||||
@Override
|
||||
public boolean matches(final InventoryCrafting inv, final World world) {
|
||||
@@ -29,8 +31,9 @@ public class MultiFenceRecipeEmbedded implements IRecipe {
|
||||
if (type != null && type2 != null) {
|
||||
if (type.equals(type2)) {
|
||||
final IPlankType pType = WoodManager.get(b);
|
||||
if (WoodManager.getFenceDescription(a).getPlankType() == pType) {
|
||||
this.cached = WoodManager.getFence(WoodManager.getFenceDescription(a).getPlankType(), WoodManager.getFenceDescription(a).getSecondaryPlankType(), new FenceType(type.size, type.solid, true), 2);
|
||||
FenceDescription fenceDescription = WoodManager.getFenceDescription(a);
|
||||
if (fenceDescription != null && fenceDescription.getPlankType() == pType) {
|
||||
this.cached = WoodManager.getFence(fenceDescription.getPlankType(), fenceDescription.getSecondaryPlankType(), new FenceType(type.size, type.solid, true), 2);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,11 +10,13 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MultiFenceRecipeSize implements IRecipe {
|
||||
ItemStack cached;
|
||||
@Nullable
|
||||
private ItemStack cached;
|
||||
|
||||
@Override
|
||||
public boolean matches(final InventoryCrafting inv, final World world) {
|
||||
|
||||
@@ -9,9 +9,11 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class MultiFenceRecipeSolid implements IRecipe {
|
||||
ItemStack cached;
|
||||
@Nullable
|
||||
private ItemStack cached;
|
||||
|
||||
@Override
|
||||
public boolean matches(final InventoryCrafting inv, final World world) {
|
||||
@@ -28,7 +30,8 @@ public class MultiFenceRecipeSolid implements IRecipe {
|
||||
final FenceType type3 = WoodManager.getFenceType(c);
|
||||
if (type != null && type2 != null && type3 != null && type.equals(type2)) {
|
||||
if (type.equals(type3)) {
|
||||
this.cached = WoodManager.getFence(WoodManager.getFenceDescription(a).getPlankType(), WoodManager.getFenceDescription(a).getSecondaryPlankType(), new FenceType(type.size, true, type.solid), 2);
|
||||
FenceDescription fenceDescription = WoodManager.getFenceDescription(a);
|
||||
this.cached = WoodManager.getFence(fenceDescription.getPlankType(), fenceDescription.getSecondaryPlankType(), new FenceType(type.size, true, type.solid), 2);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public enum DesignSystem implements IDesignSystem {
|
||||
return PlankType.ExtraTreePlanks.Fir;
|
||||
}
|
||||
default: {
|
||||
return null;
|
||||
throw new IllegalStateException("Unknown design system: " + this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -55,7 +55,7 @@ public enum DesignSystem implements IDesignSystem {
|
||||
return PlankType.ExtraTreePlanks.Whitebeam;
|
||||
}
|
||||
default: {
|
||||
return null;
|
||||
throw new IllegalStateException("Unknown design system: " + this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -71,7 +71,7 @@ public enum DesignSystem implements IDesignSystem {
|
||||
return CarpentryManager.carpentryInterface.getWoodMaterial(id);
|
||||
}
|
||||
default: {
|
||||
return null;
|
||||
throw new IllegalStateException("Unknown design system: " + this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,7 +86,7 @@ public enum DesignSystem implements IDesignSystem {
|
||||
return CarpentryManager.carpentryInterface.getCarpentryWoodIndex(id);
|
||||
}
|
||||
default: {
|
||||
return 0;
|
||||
throw new IllegalStateException("Unknown design system: " + this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -100,12 +100,13 @@ public enum DesignSystem implements IDesignSystem {
|
||||
return "patterns";
|
||||
}
|
||||
default: {
|
||||
return "";
|
||||
throw new IllegalStateException("Unknown design system: " + this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public IDesignMaterial getMaterial(final ItemStack stack) {
|
||||
switch (this) {
|
||||
case Glass: {
|
||||
@@ -115,7 +116,7 @@ public enum DesignSystem implements IDesignSystem {
|
||||
return CarpentryManager.carpentryInterface.getWoodMaterial(stack);
|
||||
}
|
||||
default: {
|
||||
return null;
|
||||
throw new IllegalStateException("Unknown design system: " + this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -130,7 +131,7 @@ public enum DesignSystem implements IDesignSystem {
|
||||
return ExtraTreeItems.WoodWax.get(1);
|
||||
}
|
||||
default: {
|
||||
return null;
|
||||
throw new IllegalStateException("Unknown design system: " + this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import binnie.extratrees.api.IDesignMaterial;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -58,10 +59,8 @@ public class GlassType implements IDesignMaterial {
|
||||
return GlassType.types.get(id);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static IDesignMaterial get(final ItemStack stack) {
|
||||
if (stack == null) {
|
||||
return null;
|
||||
}
|
||||
for (final Map.Entry<Integer, GlassType> entry : GlassType.types.entrySet()) {
|
||||
if (stack.isItemEqual(entry.getValue().getStack())) {
|
||||
return entry.getValue();
|
||||
|
||||
@@ -371,9 +371,9 @@ public class AlleleETFruit extends AlleleCategorized implements IAlleleFruit, IF
|
||||
@Nullable
|
||||
@Override
|
||||
public ResourceLocation getSprite(ITreeGenome genome, IBlockAccess world, BlockPos pos, int ripeningTime) {
|
||||
if(sprite != null){
|
||||
if (sprite != null) {
|
||||
return sprite.getLocation();
|
||||
}else{
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -437,9 +437,9 @@ public class AlleleETFruit extends AlleleCategorized implements IAlleleFruit, IF
|
||||
@Nullable
|
||||
@Override
|
||||
public String getModelName() {
|
||||
if(pod != null){
|
||||
if (pod != null) {
|
||||
return pod.name();
|
||||
}else{
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -523,9 +523,9 @@ public class AlleleETFruit extends AlleleCategorized implements IAlleleFruit, IF
|
||||
@Nullable
|
||||
@Override
|
||||
public ResourceLocation getDecorativeSprite() {
|
||||
if(sprite != null){
|
||||
if (sprite != null) {
|
||||
return sprite.getLocation();
|
||||
}else{
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import binnie.Constants;
|
||||
import binnie.core.genetics.ForestryAllele;
|
||||
import binnie.extratrees.block.EnumETLog;
|
||||
import binnie.extratrees.gen.*;
|
||||
import com.google.common.base.Preconditions;
|
||||
import forestry.api.arboriculture.*;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
@@ -2258,9 +2259,7 @@ public enum ETTreeDefinition implements IStringSerializable, ITreeDefinition, IT
|
||||
}
|
||||
|
||||
public <T extends Enum<T> & IChromosomeType> void set(T chromosomeType, IAllele allele) {
|
||||
if (allele == null) {
|
||||
throw new NullPointerException("Allele must not be null");
|
||||
}
|
||||
Preconditions.checkNotNull(allele, "Allele must not be null");
|
||||
if (!chromosomeType.getAlleleClass().isInstance(allele)) {
|
||||
throw new IllegalArgumentException("Allele is the wrong type. Expected: " + chromosomeType + " Got: " + allele);
|
||||
}
|
||||
|
||||
@@ -41,11 +41,13 @@ public class ExtraTreeGrowthProvider implements IAlleleGrowth, IGrowthProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getDescription() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String[] getInfo() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -48,18 +48,13 @@ public class ItemETFood extends ItemFood implements IItemModelRegister {
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) {
|
||||
IItemMiscProvider item = this.getItem(stack.getItemDamage());
|
||||
if (item != null) {
|
||||
item.addInformation(tooltip);
|
||||
}
|
||||
item.addInformation(tooltip);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(final ItemStack stack) {
|
||||
IItemMiscProvider item = this.getItem(stack.getItemDamage());
|
||||
if(item != null){
|
||||
return item.getName(stack);
|
||||
}
|
||||
return "null";
|
||||
return item.getName(stack);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@@ -12,6 +12,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public enum KitchenMachine implements IMachineType {
|
||||
// TODO implement
|
||||
Worktop(null),
|
||||
Cupboard(null),
|
||||
BottleRack(BottleRack.PackageBottleRack.class);
|
||||
|
||||
@@ -50,7 +50,7 @@ public class ControlFluidDisplay extends Control implements ITooltip {
|
||||
if (this.fluidStack == null) {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class ControlSlotFluid 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,12 +9,18 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class WindowBottleRack extends Window {
|
||||
public WindowBottleRack(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
super(248, 180, player, inventory, side);
|
||||
}
|
||||
|
||||
public static Window create(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
@Nullable
|
||||
public static Window create(final EntityPlayer player, @Nullable final IInventory inventory, final Side side) {
|
||||
if (inventory == null) {
|
||||
return null;
|
||||
}
|
||||
return new WindowBottleRack(player, inventory, side);
|
||||
}
|
||||
|
||||
|
||||
@@ -170,6 +170,7 @@ public abstract class Designer {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ErrorState canWork() {
|
||||
if (this.getUtil().isSlotEmpty(Designer.beeswaxSlot)) {
|
||||
return new ErrorState.NoItem("Requires Adhesive to Function", Designer.beeswaxSlot);
|
||||
@@ -178,6 +179,7 @@ public abstract class Designer {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ErrorState canProgress() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import binnie.core.machines.TileEntityMachine;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.core.machines.inventory.ComponentTankContainer;
|
||||
import binnie.core.machines.inventory.MachineSide;
|
||||
import binnie.core.machines.inventory.TankSlot;
|
||||
import binnie.core.machines.inventory.TankValidator;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
import binnie.core.machines.power.ComponentProcessSetCost;
|
||||
@@ -18,18 +19,17 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Infuser {
|
||||
public static int tankInput = 0;
|
||||
public static int tankOutput = 1;
|
||||
public static final int tankInput = 0;
|
||||
public static final int tankOutput = 1;
|
||||
static Map<Fluid, FluidStack> recipes = new HashMap<>();
|
||||
|
||||
@Nullable
|
||||
public static FluidStack getOutput(final FluidStack fluid, final ItemStack stack) {
|
||||
if (fluid == null) {
|
||||
return null;
|
||||
}
|
||||
return Infuser.recipes.get(fluid.getFluid());
|
||||
}
|
||||
|
||||
@@ -60,13 +60,16 @@ public class Infuser {
|
||||
new ExtraTreeMachine.ComponentExtraTreeGUI(machine, ExtraTreesGUID.Infuser);
|
||||
final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
final ComponentTankContainer tanks = new ComponentTankContainer(machine);
|
||||
tanks.addTank(Infuser.tankInput, "input", 5000);
|
||||
tanks.getTankSlot(Infuser.tankInput).setValidator(new TankValidatorInfuserInput());
|
||||
tanks.getTankSlot(Infuser.tankInput).setOutputSides(MachineSide.TopAndBottom);
|
||||
tanks.addTank(Infuser.tankOutput, "output", 5000);
|
||||
tanks.getTankSlot(Infuser.tankOutput).setValidator(new TankValidatorInfuserOutput());
|
||||
tanks.getTankSlot(Infuser.tankOutput).setReadOnly();
|
||||
tanks.getTankSlot(Infuser.tankOutput).setOutputSides(MachineSide.Sides);
|
||||
|
||||
final TankSlot input = tanks.addTank(Infuser.tankInput, "input", 5000);
|
||||
input.setValidator(new TankValidatorInfuserInput());
|
||||
input.setOutputSides(MachineSide.TopAndBottom);
|
||||
|
||||
final TankSlot output = tanks.addTank(Infuser.tankOutput, "output", 5000);
|
||||
output.setValidator(new TankValidatorInfuserOutput());
|
||||
output.setReadOnly();
|
||||
output.setOutputSides(MachineSide.Sides);
|
||||
|
||||
new ComponentPowerReceptor(machine);
|
||||
new ComponentInfuserLogic(machine);
|
||||
}
|
||||
@@ -108,23 +111,31 @@ public class Infuser {
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (!this.getUtil().isTankEmpty(Infuser.tankOutput) && this.getOutput() != null && !this.getOutput().isFluidEqual(this.getUtil().getFluid(Infuser.tankOutput))) {
|
||||
FluidStack outputTankFluid = this.getUtil().getFluid(Infuser.tankOutput);
|
||||
if (!this.getUtil().isTankEmpty(Infuser.tankOutput) && this.getOutput() != null && !this.getOutput().isFluidEqual(outputTankFluid)) {
|
||||
return new ErrorState.Tank("No Room", "No room for liquid", new int[]{Infuser.tankOutput});
|
||||
}
|
||||
if (this.getUtil().getFluid(Infuser.tankOutput) != null && !this.getUtil().getFluid(Infuser.tankOutput).isFluidEqual(this.getOutput())) {
|
||||
if (outputTankFluid != null && !outputTankFluid.isFluidEqual(this.getOutput())) {
|
||||
return new ErrorState.TankSpace("Different fluid in tank", Infuser.tankOutput);
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private FluidStack getOutput() {
|
||||
return Infuser.getOutput(this.getUtil().getFluid(Infuser.tankInput), this.infusing);
|
||||
FluidStack fluid = this.getUtil().getFluid(Infuser.tankInput);
|
||||
if (fluid == null) {
|
||||
return null;
|
||||
}
|
||||
return Infuser.getOutput(fluid, this.infusing);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
final FluidStack output = this.getOutput().copy();
|
||||
this.getUtil().fillTank(Infuser.tankOutput, output);
|
||||
final FluidStack output = this.getOutput();
|
||||
if (output != null) {
|
||||
this.getUtil().fillTank(Infuser.tankOutput, output.copy());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,6 +12,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -20,6 +21,7 @@ public class TileEntityNursery extends TileEntityMachine implements IButterflyNu
|
||||
super(pack);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
IButterflyNursery getNursery() {
|
||||
return this.getMachine().getInterface(IButterflyNursery.class);
|
||||
}
|
||||
@@ -36,12 +38,12 @@ public class TileEntityNursery extends TileEntityMachine implements IButterflyNu
|
||||
|
||||
@Override
|
||||
public EnumTemperature getTemperature() {
|
||||
return null;
|
||||
return EnumTemperature.NORMAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumHumidity getHumidity() {
|
||||
return null;
|
||||
return EnumHumidity.NORMAL;
|
||||
}
|
||||
|
||||
public boolean addProduct(final ItemStack product, final boolean all) {
|
||||
@@ -49,19 +51,23 @@ public class TileEntityNursery extends TileEntityMachine implements IButterflyNu
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public IButterfly getCaterpillar() {
|
||||
return this.hasNursery() ? this.getNursery().getCaterpillar() : null;
|
||||
IButterflyNursery nursery = this.getNursery();
|
||||
return nursery != null ? nursery.getCaterpillar() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public IIndividual getNanny() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCaterpillar(final IButterfly butterfly) {
|
||||
if (this.hasNursery()) {
|
||||
this.getNursery().setCaterpillar(butterfly);
|
||||
IButterflyNursery nursery = this.getNursery();
|
||||
if (nursery != null) {
|
||||
nursery.setCaterpillar(butterfly);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,6 +84,7 @@ public class TileEntityNursery extends TileEntityMachine implements IButterflyNu
|
||||
public void setErrorState(final IErrorState state) {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public IErrorState getErrorState() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.core.machines.inventory.ComponentTankContainer;
|
||||
import binnie.core.machines.inventory.InventorySlot;
|
||||
import binnie.core.machines.inventory.MachineSide;
|
||||
import binnie.core.machines.inventory.TankSlot;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
import binnie.craftgui.minecraft.IMachineInformation;
|
||||
import binnie.extratrees.core.ExtraTreeTexture;
|
||||
@@ -41,22 +42,24 @@ public class BreweryMachine extends ExtraTreeMachine.PackageExtraTreeMachine imp
|
||||
for (final InventorySlot slot : inventory.getSlots(SLOTS_INVENTORY)) {
|
||||
slot.forbidExtraction();
|
||||
}
|
||||
inventory.addSlot(SLOT_YEAST, "yeast");
|
||||
inventory.getSlot(SLOT_YEAST).setValidator(new SlotValidatorBreweryYeast());
|
||||
inventory.getSlot(SLOT_YEAST).setType(InventorySlot.Type.Recipe);
|
||||
|
||||
inventory.addSlot(SLOT_RECIPE_INPUT, "ingredient");
|
||||
inventory.getSlot(SLOT_RECIPE_INPUT).setValidator(new SlotValidatorBreweryIngredient());
|
||||
inventory.getSlot(SLOT_RECIPE_INPUT).setType(InventorySlot.Type.Recipe);
|
||||
final InventorySlot yeast = inventory.addSlot(SLOT_YEAST, "yeast");
|
||||
yeast.setValidator(new SlotValidatorBreweryYeast());
|
||||
yeast.setType(InventorySlot.Type.Recipe);
|
||||
|
||||
final InventorySlot ingredient = inventory.addSlot(SLOT_RECIPE_INPUT, "ingredient");
|
||||
ingredient.setValidator(new SlotValidatorBreweryIngredient());
|
||||
ingredient.setType(InventorySlot.Type.Recipe);
|
||||
|
||||
final ComponentTankContainer tanks = new ComponentTankContainer(machine);
|
||||
tanks.addTank(TANK_INPUT, "input", 5000);
|
||||
tanks.getTankSlot(TANK_INPUT).setValidator(new TankValidatorFermentInput());
|
||||
tanks.getTankSlot(TANK_INPUT).setOutputSides(MachineSide.TopAndBottom);
|
||||
tanks.addTank(TANK_OUTPUT, "output", 5000);
|
||||
tanks.getTankSlot(TANK_OUTPUT).setValidator(new TankValidatorFermentOutput());
|
||||
tanks.getTankSlot(TANK_OUTPUT).forbidInsertion();
|
||||
tanks.getTankSlot(TANK_OUTPUT).setOutputSides(MachineSide.Sides);
|
||||
TankSlot input = tanks.addTank(TANK_INPUT, "input", 5000);
|
||||
input.setValidator(new TankValidatorFermentInput());
|
||||
input.setOutputSides(MachineSide.TopAndBottom);
|
||||
|
||||
final TankSlot output = tanks.addTank(TANK_OUTPUT, "output", 5000);
|
||||
output.setValidator(new TankValidatorFermentOutput());
|
||||
output.forbidInsertion();
|
||||
output.setOutputSides(MachineSide.Sides);
|
||||
|
||||
new ComponentPowerReceptor(machine);
|
||||
new BreweryLogic(machine);
|
||||
|
||||
@@ -11,6 +11,8 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ControlRecipeSlot extends ControlSlotBase {
|
||||
public ControlRecipeSlot(final IWidget parent, final int x, final int y) {
|
||||
super(parent, x, y, 50);
|
||||
@@ -29,6 +31,7 @@ public class ControlRecipeSlot extends ControlSlotBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ItemStack getItemStack() {
|
||||
final IComponentRecipe recipe = Machine.getInterface(IComponentRecipe.class, Window.get(this).getInventory());
|
||||
if (recipe != null && recipe.isRecipe()) {
|
||||
|
||||
@@ -134,6 +134,7 @@ public class ControlTileSelect extends Control implements IControlValue<IDesign>
|
||||
if (tile == null) {
|
||||
return;
|
||||
}
|
||||
// TODO: why is recipe unused here?
|
||||
final Designer.ComponentWoodworkerRecipe recipe = tile.getMachine().getComponent(Designer.ComponentWoodworkerRecipe.class);
|
||||
final NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setShort("d", (short) CarpentryManager.carpentryInterface.getDesignIndex(ControlTile.this.getValue()));
|
||||
@@ -159,7 +160,7 @@ public class ControlTileSelect extends Control implements IControlValue<IDesign>
|
||||
|
||||
@Override
|
||||
public void onRenderForeground(int guiWidth, int guiHeight) {
|
||||
final ItemStack image = ((WindowWoodworker) this.getSuperParent()).getDesignerType().getDisplayStack(this.getValue());
|
||||
final ItemStack image = ((WindowWoodworker) this.getTopParent()).getDesignerType().getDisplayStack(this.getValue());
|
||||
RenderUtil.drawItem(new IPoint(1, 1), image);
|
||||
if (((IControlValue) this.getParent()).getValue() != this.getValue()) {
|
||||
if (Window.get(this).getMousedOverWidget() == this) {
|
||||
|
||||
@@ -16,6 +16,8 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class WindowBrewery extends Window {
|
||||
public WindowBrewery(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
super(228, 218, player, inventory, side);
|
||||
@@ -34,19 +36,23 @@ public class WindowBrewery extends Window {
|
||||
@Override
|
||||
public void initialiseClient() {
|
||||
this.setTitle(Machine.getMachine(this.getInventory()).getPackage().getDisplayName());
|
||||
new ControlSlotArray(this, 42, 32, 1, 3).create(BreweryMachine.SLOT_RECIPE_GRAINS);
|
||||
new ControlSlot(this, 16, 41).assign(BreweryMachine.SLOT_RECIPE_INPUT);
|
||||
new ControlSlot(this, 105, 77).assign(BreweryMachine.SLOT_YEAST);
|
||||
new ControlSlotArray.Builder(this, 42, 32, 1, 3).create(BreweryMachine.SLOT_RECIPE_GRAINS);
|
||||
new ControlSlot.Builder(this, 16, 41).assign(BreweryMachine.SLOT_RECIPE_INPUT);
|
||||
new ControlSlot.Builder(this, 105, 77).assign(BreweryMachine.SLOT_YEAST);
|
||||
new ControlLiquidTank(this, 76, 32).setTankID(BreweryMachine.TANK_INPUT);
|
||||
new ControlLiquidTank(this, 162, 32).setTankID(BreweryMachine.TANK_OUTPUT);
|
||||
new ControlEnergyBar(this, 196, 32, 16, 60, Position.Bottom);
|
||||
new ControlBreweryProgress(this, 110, 32);
|
||||
new ControlSlotArray(this, this.getSize().x() / 2 - 81, 104, 9, 1).create(BreweryMachine.SLOTS_INVENTORY);
|
||||
new ControlSlotArray.Builder(this, this.getSize().x() / 2 - 81, 104, 9, 1).create(BreweryMachine.SLOTS_INVENTORY);
|
||||
new ControlPlayerInventory(this);
|
||||
new ControlErrorState(this, 133, 79);
|
||||
}
|
||||
|
||||
public static Window create(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
@Nullable
|
||||
public static Window create(final EntityPlayer player, @Nullable final IInventory inventory, final Side side) {
|
||||
if (inventory == null) {
|
||||
return null;
|
||||
}
|
||||
return new WindowBrewery(player, inventory, side);
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,8 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class WindowDistillery extends Window {
|
||||
public WindowDistillery(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
super(224, 192, player, inventory, side);
|
||||
@@ -44,7 +46,11 @@ public class WindowDistillery extends Window {
|
||||
new ControlErrorState(this, x + 21, 62);
|
||||
}
|
||||
|
||||
public static Window create(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
@Nullable
|
||||
public static Window create(final EntityPlayer player, @Nullable final IInventory inventory, final Side side) {
|
||||
if (inventory == null) {
|
||||
return null;
|
||||
}
|
||||
return new WindowDistillery(player, inventory, side);
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,8 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class WindowLumbermill extends Window {
|
||||
public WindowLumbermill(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
super(220, 192, player, inventory, side);
|
||||
@@ -33,10 +35,10 @@ public class WindowLumbermill extends Window {
|
||||
@Override
|
||||
public void initialiseClient() {
|
||||
this.setTitle(Machine.getMachine(this.getInventory()).getPackage().getDisplayName());
|
||||
new ControlSlot(this, 42, 43).assign(LumbermillMachine.SLOT_LOG);
|
||||
new ControlSlot(this, 148, 43).assign(LumbermillMachine.SLOT_PLANKS);
|
||||
new ControlSlot(this, 172, 28).assign(LumbermillMachine.SLOT_BARK);
|
||||
new ControlSlot(this, 172, 58).assign(LumbermillMachine.SLOT_SAWDUST);
|
||||
new ControlSlot.Builder(this, 42, 43).assign(LumbermillMachine.SLOT_LOG);
|
||||
new ControlSlot.Builder(this, 148, 43).assign(LumbermillMachine.SLOT_PLANKS);
|
||||
new ControlSlot.Builder(this, 172, 28).assign(LumbermillMachine.SLOT_BARK);
|
||||
new ControlSlot.Builder(this, 172, 58).assign(LumbermillMachine.SLOT_SAWDUST);
|
||||
new ControlLumbermillProgress(this, 70, 43);
|
||||
new ControlLiquidTank(this, 16, 32);
|
||||
new ControlEnergyBar(this, 8, 112, 16, 60, Position.Bottom);
|
||||
@@ -44,7 +46,11 @@ public class WindowLumbermill extends Window {
|
||||
new ControlErrorState(this, 95, 73);
|
||||
}
|
||||
|
||||
public static Window create(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
@Nullable
|
||||
public static Window create(final EntityPlayer player, @Nullable final IInventory inventory, final Side side) {
|
||||
if (inventory == null) {
|
||||
return null;
|
||||
}
|
||||
return new WindowLumbermill(player, inventory, side);
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,8 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class WindowPress extends Window {
|
||||
public WindowPress(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
super(194, 192, player, inventory, side);
|
||||
@@ -37,16 +39,20 @@ public class WindowPress extends Window {
|
||||
@Override
|
||||
public void initialiseClient() {
|
||||
this.setTitle(Machine.getMachine(this.getInventory()).getPackage().getDisplayName());
|
||||
new ControlSlot(this, 24, 52).assign(FruitPressMachine.SLOT_FRUIT);
|
||||
new ControlSlot.Builder(this, 24, 52).assign(FruitPressMachine.SLOT_FRUIT);
|
||||
new ControlLiquidTank(this, 99, 32).setTankID(FruitPressMachine.TANK_OUTPUT);
|
||||
new ControlEnergyBar(this, 154, 32, 16, 60, Position.Bottom);
|
||||
new ControlPlayerInventory(this);
|
||||
new ControlErrorState(this, 128, 54);
|
||||
new ControlFruitPressProgress(this, 62, 24);
|
||||
((Window) this.getSuperParent()).getContainer().getOrCreateSlot(InventoryType.Machine, FruitPressMachine.SLOT_CURRENT);
|
||||
((Window) this.getTopParent()).getContainer().getOrCreateSlot(InventoryType.Machine, FruitPressMachine.SLOT_CURRENT);
|
||||
}
|
||||
|
||||
public static Window create(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
@Nullable
|
||||
public static Window create(final EntityPlayer player, @Nullable final IInventory inventory, final Side side) {
|
||||
if (inventory == null) {
|
||||
return null;
|
||||
}
|
||||
return new WindowPress(player, inventory, side);
|
||||
}
|
||||
|
||||
@@ -54,10 +60,10 @@ public class WindowPress extends Window {
|
||||
public void recieveGuiNBT(final Side side, final EntityPlayer player, final String name, final NBTTagCompound action) {
|
||||
final FruitPressLogic logic = Machine.getInterface(FruitPressLogic.class, this.getInventory());
|
||||
super.recieveGuiNBT(side, player, name, action);
|
||||
if (side == Side.SERVER && name.equals("fruitpress-click")) {
|
||||
if (logic.canWork() == null && (logic.canProgress() == null || logic.canProgress() instanceof ErrorState.InsufficientPower)) {
|
||||
if (logic != null && side == Side.SERVER) {
|
||||
if (name.equals("fruitpress-click") && logic.canWork() == null && (logic.canProgress() == null || logic.canProgress() instanceof ErrorState.InsufficientPower)) {
|
||||
logic.alterProgress(2.0f);
|
||||
} else if (side == Side.SERVER && name.equals("clear-fruit")) {
|
||||
} else if (name.equals("clear-fruit")) {
|
||||
logic.setProgress(0.0f);
|
||||
this.getInventory().setInventorySlotContents(FruitPressMachine.SLOT_CURRENT, null);
|
||||
}
|
||||
|
||||
@@ -8,8 +8,10 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class WindowSetSquare extends Window {
|
||||
public WindowSetSquare(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
public WindowSetSquare(final EntityPlayer player, @Nullable final IInventory inventory, final Side side) {
|
||||
super(150, 150, player, inventory, side);
|
||||
}
|
||||
|
||||
@@ -20,6 +22,7 @@ public class WindowSetSquare extends Window {
|
||||
|
||||
@Override
|
||||
protected String getBackgroundTextureName() {
|
||||
// TODO background should not be null
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class WindowWoodworker extends Window {
|
||||
ControlTextEdit textEdit;
|
||||
ControlTileSelect tileSelect;
|
||||
@@ -39,12 +41,9 @@ public class WindowWoodworker extends Window {
|
||||
new ControlPlayerInventory(this).setPosition(new IPoint(14, 96));
|
||||
new ControlErrorState(this, 76, 65);
|
||||
if (this.getInventory() != null) {
|
||||
final ControlSlot slotWood1 = new ControlSlot(this, 22, 34);
|
||||
slotWood1.assign(Designer.design1Slot);
|
||||
final ControlSlot slotWood2 = new ControlSlot(this, 62, 34);
|
||||
slotWood2.assign(Designer.design2Slot);
|
||||
final ControlSlot slotBeeswax = new ControlSlot(this, 42, 64);
|
||||
slotBeeswax.assign(Designer.beeswaxSlot);
|
||||
final ControlSlot slotWood1 = new ControlSlot.Builder(this, 22, 34).assign(Designer.design1Slot);
|
||||
final ControlSlot slotWood2 = new ControlSlot.Builder(this, 62, 34).assign(Designer.design2Slot);
|
||||
final ControlSlot slotBeeswax = new ControlSlot.Builder(this, 42, 64).assign(Designer.beeswaxSlot);
|
||||
final ControlRecipeSlot slotFinished = new ControlRecipeSlot(this, 112, 34);
|
||||
}
|
||||
}
|
||||
@@ -59,7 +58,11 @@ public class WindowWoodworker extends Window {
|
||||
}.setOrigin(EventHandler.Origin.DirectChild, this));
|
||||
}
|
||||
|
||||
public static Window create(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
@Nullable
|
||||
public static Window create(final EntityPlayer player, @Nullable final IInventory inventory, final Side side) {
|
||||
if (inventory == null) {
|
||||
return null;
|
||||
}
|
||||
return new WindowWoodworker(player, inventory, side);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import binnie.core.machines.TileEntityMachine;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.core.machines.inventory.ComponentTankContainer;
|
||||
import binnie.core.machines.inventory.MachineSide;
|
||||
import binnie.core.machines.inventory.TankSlot;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
import binnie.craftgui.minecraft.IMachineInformation;
|
||||
import binnie.extratrees.core.ExtraTreeTexture;
|
||||
@@ -25,13 +26,16 @@ public class DistilleryMachine extends ExtraTreeMachine.PackageExtraTreeMachine
|
||||
new ExtraTreeMachine.ComponentExtraTreeGUI(machine, ExtraTreesGUID.Distillery);
|
||||
final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
final ComponentTankContainer tanks = new ComponentTankContainer(machine);
|
||||
tanks.addTank(TANK_INPUT, "input", 5000);
|
||||
tanks.getTankSlot(TANK_INPUT).setValidator(new TankValidatorDistilleryInput());
|
||||
tanks.getTankSlot(TANK_INPUT).setOutputSides(MachineSide.TopAndBottom);
|
||||
tanks.addTank(TANK_OUTPUT, "output", 5000);
|
||||
tanks.getTankSlot(TANK_OUTPUT).setValidator(new TankValidatorDistilleryOutput());
|
||||
tanks.getTankSlot(TANK_OUTPUT).setReadOnly();
|
||||
tanks.getTankSlot(TANK_OUTPUT).setOutputSides(MachineSide.Sides);
|
||||
|
||||
final TankSlot input = tanks.addTank(TANK_INPUT, "input", 5000);
|
||||
input.setValidator(new TankValidatorDistilleryInput());
|
||||
input.setOutputSides(MachineSide.TopAndBottom);
|
||||
|
||||
final TankSlot output = tanks.addTank(TANK_OUTPUT, "output", 5000);
|
||||
output.setValidator(new TankValidatorDistilleryOutput());
|
||||
output.setReadOnly();
|
||||
output.setOutputSides(MachineSide.Sides);
|
||||
|
||||
new ComponentPowerReceptor(machine);
|
||||
new DistilleryLogic(machine);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,9 @@ public class FruitPressLogic extends ComponentProcessSetCost implements IProcess
|
||||
if (!this.getUtil().spaceInTank(FruitPressMachine.TANK_OUTPUT, 5)) {
|
||||
return new ErrorState.TankSpace("No room in tank", FruitPressMachine.TANK_OUTPUT);
|
||||
}
|
||||
if (this.getUtil().getFluid(FruitPressMachine.TANK_OUTPUT) != null && !this.getUtil().getFluid(FruitPressMachine.TANK_OUTPUT).isFluidEqual(FruitPressRecipes.getOutput(this.getUtil().getStack(FruitPressMachine.SLOT_CURRENT)))) {
|
||||
FluidStack fluidOutputTank = this.getUtil().getFluid(FruitPressMachine.TANK_OUTPUT);
|
||||
FluidStack recipeOutput = FruitPressRecipes.getOutput(this.getUtil().getStack(FruitPressMachine.SLOT_CURRENT));
|
||||
if (fluidOutputTank != null && !fluidOutputTank.isFluidEqual(recipeOutput)) {
|
||||
return new ErrorState.TankSpace("Different fluid in tank", FruitPressMachine.TANK_OUTPUT);
|
||||
}
|
||||
return super.canProgress();
|
||||
|
||||
@@ -5,6 +5,7 @@ import binnie.core.machines.TileEntityMachine;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.core.machines.inventory.ComponentInventoryTransfer;
|
||||
import binnie.core.machines.inventory.ComponentTankContainer;
|
||||
import binnie.core.machines.inventory.InventorySlot;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
import binnie.craftgui.minecraft.IMachineInformation;
|
||||
import binnie.extratrees.core.ExtraTreeTexture;
|
||||
@@ -26,12 +27,14 @@ public class FruitPressMachine extends ExtraTreeMachine.PackageExtraTreeMachine
|
||||
public void createMachine(final Machine machine) {
|
||||
new ExtraTreeMachine.ComponentExtraTreeGUI(machine, ExtraTreesGUID.Press);
|
||||
final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
inventory.addSlot(SLOT_FRUIT, "input");
|
||||
inventory.getSlot(SLOT_FRUIT).setValidator(new SlotValidatorSqueezable());
|
||||
inventory.getSlot(SLOT_FRUIT).forbidExtraction();
|
||||
inventory.addSlot(SLOT_CURRENT, "process");
|
||||
inventory.getSlot(SLOT_CURRENT).setValidator(new SlotValidatorSqueezable());
|
||||
inventory.getSlot(SLOT_CURRENT).forbidInteraction();
|
||||
final InventorySlot input = inventory.addSlot(SLOT_FRUIT, "input");
|
||||
input.setValidator(new SlotValidatorSqueezable());
|
||||
input.forbidExtraction();
|
||||
|
||||
final InventorySlot process = inventory.addSlot(SLOT_CURRENT, "process");
|
||||
process.setValidator(new SlotValidatorSqueezable());
|
||||
process.forbidInteraction();
|
||||
|
||||
final ComponentTankContainer tanks = new ComponentTankContainer(machine);
|
||||
tanks.addTank(TANK_OUTPUT, "output", TANK_OUTPUT_CAPACITY);
|
||||
new ComponentPowerReceptor(machine);
|
||||
|
||||
@@ -18,10 +18,10 @@ public class LumbermillLogic extends ComponentProcessSetCost implements IProcess
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (this.getUtil().isSlotEmpty(LumbermillMachine.SLOT_LOG)) {
|
||||
ItemStack logStack = this.getUtil().getStack(LumbermillMachine.SLOT_LOG);
|
||||
if (logStack == null) {
|
||||
return new ErrorState.NoItem("No Wood", LumbermillMachine.SLOT_LOG);
|
||||
}
|
||||
ItemStack logStack = this.getUtil().getStack(LumbermillMachine.SLOT_LOG);
|
||||
final ItemStack plankResult = LumbermillRecipes.getPlankProduct(logStack);
|
||||
if (!this.getUtil().isSlotEmpty(LumbermillMachine.SLOT_PLANKS) && plankResult != null) {
|
||||
final ItemStack currentPlank = this.getUtil().getStack(LumbermillMachine.SLOT_PLANKS);
|
||||
|
||||
@@ -4,6 +4,8 @@ import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.core.machines.inventory.ComponentTankContainer;
|
||||
import binnie.core.machines.inventory.InventorySlot;
|
||||
import binnie.core.machines.inventory.TankSlot;
|
||||
import binnie.core.machines.inventory.TankValidator;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
import binnie.craftgui.minecraft.IMachineInformation;
|
||||
@@ -13,12 +15,12 @@ import binnie.extratrees.machines.ExtraTreeMachine;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class LumbermillMachine extends ExtraTreeMachine.PackageExtraTreeMachine implements IMachineInformation {
|
||||
public static int SLOT_LOG = 0;
|
||||
public static int SLOT_PLANKS = 1;
|
||||
public static int SLOT_BARK = 2;
|
||||
public static int SLOT_SAWDUST = 3;
|
||||
public static int TANK_WATER = 0;
|
||||
public static int TANK_WATER_CAPACITY = 10000;
|
||||
public static final int SLOT_LOG = 0;
|
||||
public static final int SLOT_PLANKS = 1;
|
||||
public static final int SLOT_BARK = 2;
|
||||
public static final int SLOT_SAWDUST = 3;
|
||||
public static final int TANK_WATER = 0;
|
||||
public static final int TANK_WATER_CAPACITY = 10000;
|
||||
|
||||
public LumbermillMachine() {
|
||||
super("lumbermill", ExtraTreeTexture.lumbermillTexture, true);
|
||||
@@ -28,18 +30,19 @@ public class LumbermillMachine extends ExtraTreeMachine.PackageExtraTreeMachine
|
||||
public void createMachine(final Machine machine) {
|
||||
new ExtraTreeMachine.ComponentExtraTreeGUI(machine, ExtraTreesGUID.Lumbermill);
|
||||
final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
inventory.addSlot(SLOT_LOG, "input");
|
||||
inventory.getSlot(SLOT_LOG).setValidator(new SlotValidatorLog());
|
||||
inventory.getSlot(SLOT_LOG).forbidExtraction();
|
||||
inventory.addSlot(SLOT_PLANKS, "output");
|
||||
inventory.addSlot(SLOT_BARK, "byproduct");
|
||||
inventory.addSlot(SLOT_SAWDUST, "byproduct");
|
||||
inventory.getSlot(SLOT_PLANKS).setReadOnly();
|
||||
inventory.getSlot(SLOT_BARK).setReadOnly();
|
||||
inventory.getSlot(SLOT_SAWDUST).setReadOnly();
|
||||
|
||||
InventorySlot slotLog = inventory.addSlot(SLOT_LOG, "input");
|
||||
slotLog.setValidator(new SlotValidatorLog());
|
||||
slotLog.forbidExtraction();
|
||||
|
||||
inventory.addSlot(SLOT_PLANKS, "output").setReadOnly();
|
||||
inventory.addSlot(SLOT_BARK, "byproduct").setReadOnly();
|
||||
inventory.addSlot(SLOT_SAWDUST, "byproduct").setReadOnly();
|
||||
|
||||
final ComponentTankContainer tanks = new ComponentTankContainer(machine);
|
||||
tanks.addTank(TANK_WATER, "input", TANK_WATER_CAPACITY);
|
||||
tanks.getTankSlot(TANK_WATER).setValidator(new TankValidator.Basic("water"));
|
||||
TankSlot tankWater = tanks.addTank(TANK_WATER, "input", TANK_WATER_CAPACITY);
|
||||
tankWater.setValidator(new TankValidator.Basic("water"));
|
||||
|
||||
new ComponentPowerReceptor(machine);
|
||||
new LumbermillLogic(machine);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ public class BlockTypeLog extends BlockType {
|
||||
ITreeGenData treeGenData;
|
||||
|
||||
public BlockTypeLog(ITreeGenData treeGenData) {
|
||||
// TODO why is block param null here?
|
||||
super(null, 0);
|
||||
this.treeGenData = treeGenData;
|
||||
}
|
||||
|
||||
@@ -1,19 +1,9 @@
|
||||
package binnie.extratrees.worldgen;
|
||||
|
||||
import forestry.api.world.ITreeGenData;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
||||
public class BlockTypeVoid extends BlockType {
|
||||
public BlockTypeVoid() {
|
||||
super(null, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlock(final World world, final ITreeGenData tree, final BlockPos pos) {
|
||||
world.setBlockToAir(pos);
|
||||
if (world.getTileEntity(pos) != null) {
|
||||
world.removeTileEntity(pos);
|
||||
}
|
||||
super(Blocks.AIR, 0);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user