Fix some null warnings

This commit is contained in:
mezz committed 2016-10-20 23:51:14 -07:00
1 parent c6783e573c
commit 3178aa890d
22 files changed
+114 -95

No files matched your search

@@ -37,7 +37,7 @@ public enum Position {
return Position.Bottom;
}
default: {
return null;
throw new IllegalStateException();
}
}
}
@@ -27,10 +27,7 @@ public class ControlBreweryProgress extends ControlProgressBase {
public void onRenderBackground() {
CraftGUI.Render.texture(ControlBreweryProgress.Brewery, new IPoint(0.0f, 0.0f));
final Brewery.ComponentBreweryLogic logic = Machine.getInterface(Brewery.ComponentBreweryLogic.class, Window.get(this).getInventory());
if (logic.currentCrafting == null) {
return;
}
if (logic.currentCrafting.currentInput == null) {
if (logic == null || logic.currentCrafting == null || logic.currentCrafting.currentInput == null) {
return;
}
final int fermentedHeight = (int) (32.0f * logic.getProgress() / 100.0f);
@@ -41,9 +41,12 @@ public class ControlDistilleryProgress extends ControlProgressBase {
@Override
public void onRenderForeground() {
final int level = Machine.getInterface(Distillery.ComponentDistilleryLogic.class, Window.get(this).getInventory()).level;
CraftGUI.Render.texture(ControlDistilleryProgress.Output, new IPoint(47.0f, 14 + level * 15));
CraftGUI.Render.texture(ControlDistilleryProgress.DistilleryOverlay, new IPoint(0.0f, 0.0f));
Distillery.ComponentDistilleryLogic distilleryLogic = Machine.getInterface(Distillery.ComponentDistilleryLogic.class, Window.get(this).getInventory());
if (distilleryLogic != null) {
final int level = distilleryLogic.level;
CraftGUI.Render.texture(ControlDistilleryProgress.Output, new IPoint(47.0f, 14 + level * 15));
CraftGUI.Render.texture(ControlDistilleryProgress.DistilleryOverlay, new IPoint(0.0f, 0.0f));
}
}
protected ControlDistilleryProgress(final IWidget parent, final float x, final float y) {
@@ -11,6 +11,7 @@ import binnie.craftgui.resource.Texture;
import binnie.craftgui.resource.minecraft.StandardTexture;
import binnie.extratrees.core.ExtraTreeTexture;
import binnie.extratrees.machines.Press;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fluids.Fluid;
@@ -23,7 +24,11 @@ public class ControlFruitPressProgress extends ControlProgressBase {
@Override
public void onRenderBackground() {
CraftGUI.Render.texture(ControlFruitPressProgress.PressSlot, new IPoint(3.0f, 52.0f));
final ItemStack input = Window.get(this).getContainer().getSlotFromInventory(Window.get(this).getInventory(), Press.slotCurrent).getStack();
Slot slotFromInventory = Window.get(this).getContainer().getSlotFromInventory(Window.get(this).getInventory(), Press.slotCurrent);
if (slotFromInventory == null) {
return;
}
final ItemStack input = slotFromInventory.getStack();
if (input == null || Press.getOutput(input) == null) {
return;
}
@@ -31,6 +31,9 @@ public class ControlRecipeSlot extends ControlSlotBase {
@Override
public ItemStack getItemStack() {
final IComponentRecipe recipe = Machine.getInterface(IComponentRecipe.class, Window.get(this).getInventory());
return recipe.isRecipe() ? recipe.getProduct() : null;
if (recipe != null && recipe.isRecipe()) {
return recipe.getProduct();
}
return null;
}
}
@@ -160,10 +160,13 @@ public class ContainerCraftGUI extends Container {
if (slotnumber < 0) {
return null;
}
final Slot shiftClickedSlot = (Slot) this.inventorySlots.get(slotnumber);
final Slot shiftClickedSlot = this.inventorySlots.get(slotnumber);
ItemStack itemstack = null;
if (shiftClickedSlot.getHasStack()) {
itemstack = shiftClickedSlot.getStack().copy();
ItemStack shiftClickedStack = shiftClickedSlot.getStack();
if (shiftClickedStack != null) {
itemstack = shiftClickedStack.copy();
}
}
final IInventory playerInventory = player.inventory;
final IInventory containerInventory = this.window.getInventory();
@@ -265,7 +268,7 @@ public class ContainerCraftGUI extends Container {
}
if (shouldSend) {
//TODO INVENTORY
this.crafters.stream().filter(entityPlayer -> entityPlayer instanceof EntityPlayerMP).forEach(entityPlayer -> {
this.crafters.stream().filter(Objects::nonNull).forEach(entityPlayer -> {
System.out.println("send to:" + entityPlayer.getDisplayName().getUnformattedText());
BinnieCore.proxy.sendToPlayer(new MessageContainerUpdate(nbt.getValue()), (EntityPlayerMP) entityPlayer);
});