Skip to content

Commit

Permalink
+ Added some cast checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Buuz135 committed Jul 30, 2017
1 parent b33324f commit 4ec21f7
Show file tree
Hide file tree
Showing 36 changed files with 95 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.buuz135.industrial.proxy.FluidsRegistry;
import com.buuz135.industrial.tile.WorkingAreaElectricMachine;
import com.buuz135.industrial.tile.block.AnimalByproductRecolectorBlock;
import com.buuz135.industrial.tile.block.CustomOrientedBlock;
import com.buuz135.industrial.utils.WorkUtils;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.util.math.AxisAlignedBB;
Expand All @@ -30,7 +30,7 @@ protected void initializeInventories() {

@Override
public float work() {
if (((CustomOrientedBlock) this.getBlockType()).isWorkDisabled()) return 0;
if (WorkUtils.isDisabled(this.getBlockType())) return 0;

AxisAlignedBB area = getWorkingArea();
List<EntityAgeable> animals = this.world.getEntitiesWithinAABB(EntityAgeable.class, area);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.buuz135.industrial.item.addon.AdultFilterAddonItem;
import com.buuz135.industrial.tile.WorkingAreaElectricMachine;
import com.buuz135.industrial.tile.block.CustomOrientedBlock;
import com.buuz135.industrial.utils.WorkUtils;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.AxisAlignedBB;
Expand All @@ -19,7 +19,7 @@ public AnimalIndependenceSelectorTile() {

@Override
public float work() {
if (((CustomOrientedBlock) this.getBlockType()).isWorkDisabled()) return 0;
if (WorkUtils.isDisabled(this.getBlockType())) return 0;

AxisAlignedBB area = getWorkingArea();
List<EntityAgeable> animals = this.world.getEntitiesWithinAABB(EntityAgeable.class, area);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.buuz135.industrial.proxy.FluidsRegistry;
import com.buuz135.industrial.tile.CustomColoredItemHandler;
import com.buuz135.industrial.tile.WorkingAreaElectricMachine;
import com.buuz135.industrial.tile.block.CustomOrientedBlock;
import com.buuz135.industrial.utils.WorkUtils;
import net.minecraft.entity.passive.EntityCow;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.init.Items;
Expand Down Expand Up @@ -59,7 +59,7 @@ public boolean canExtractItem(int slot) {

@Override
public float work() {
if (((CustomOrientedBlock) this.getBlockType()).isWorkDisabled()) return 0;
if (WorkUtils.isDisabled(this.getBlockType())) return 0;
List<EntitySheep> animals = this.world.getEntitiesWithinAABB(EntitySheep.class, getWorkingArea());
for (EntitySheep sheep : animals) {
if (!sheep.getSheared()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import com.buuz135.industrial.proxy.ItemRegistry;
import com.buuz135.industrial.tile.CustomColoredItemHandler;
import com.buuz135.industrial.tile.WorkingAreaElectricMachine;
import com.buuz135.industrial.tile.block.CustomOrientedBlock;
import com.buuz135.industrial.utils.BlockUtils;
import com.buuz135.industrial.utils.WorkUtils;
import net.minecraft.init.Items;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemDye;
Expand Down Expand Up @@ -58,7 +58,7 @@ public boolean canExtractItem(int slot) {

@Override
public float work() {
if (((CustomOrientedBlock) this.getBlockType()).isWorkDisabled()) return 0;
if (WorkUtils.isDisabled(this.getBlockType())) return 0;
List<BlockPos> blockPos = BlockUtils.getBlockPosInAABB(getWorkingArea());
boolean needsToIncrease = true;
if (pointer >= blockPos.size()) pointer = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import com.buuz135.industrial.tile.CustomColoredItemHandler;
import com.buuz135.industrial.tile.WorkingAreaElectricMachine;
import com.buuz135.industrial.tile.block.CropRecolectorBlock;
import com.buuz135.industrial.tile.block.CustomOrientedBlock;
import com.buuz135.industrial.utils.BlockUtils;
import com.buuz135.industrial.utils.ItemStackUtils;
import com.buuz135.industrial.utils.WorkUtils;
import net.minecraft.block.BlockCactus;
import net.minecraft.block.BlockCrops;
import net.minecraft.block.BlockNetherWart;
Expand Down Expand Up @@ -77,7 +77,7 @@ public AxisAlignedBB getWorkingArea() {

@Override
public float work() {
if (((CustomOrientedBlock) this.getBlockType()).isWorkDisabled()) return 0;
if (WorkUtils.isDisabled(this.getBlockType())) return 0;
if (ItemStackUtils.isInventoryFull(outItems)) return 0;
List<BlockPos> blockPos = BlockUtils.getBlockPosInAABB(getWorkingArea());
boolean needPointerIncrease = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import com.buuz135.industrial.proxy.client.infopiece.CropSowerFilterInfoPiece;
import com.buuz135.industrial.tile.CustomColoredItemHandler;
import com.buuz135.industrial.tile.WorkingAreaElectricMachine;
import com.buuz135.industrial.tile.block.CustomOrientedBlock;
import com.buuz135.industrial.utils.BlockUtils;
import com.buuz135.industrial.utils.ItemStackUtils;
import com.buuz135.industrial.utils.WorkUtils;
import net.minecraft.init.Blocks;
import net.minecraft.item.*;
import net.minecraft.nbt.NBTTagCompound;
Expand Down Expand Up @@ -92,7 +92,7 @@ public AxisAlignedBB getWorkingArea() {

@Override
public float work() {
if (((CustomOrientedBlock) this.getBlockType()).isWorkDisabled()) return 0;
if (WorkUtils.isDisabled(this.getBlockType())) return 0;
List<BlockPos> blockPos = BlockUtils.getBlockPosInAABB(getWorkingArea());
++pointer;
if (pointer >= blockPos.size()) pointer = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import com.buuz135.industrial.proxy.CommonProxy;
import com.buuz135.industrial.proxy.FluidsRegistry;
import com.buuz135.industrial.tile.WorkingAreaElectricMachine;
import com.buuz135.industrial.tile.block.CustomOrientedBlock;
import com.buuz135.industrial.tile.block.MobSlaughterFactoryBlock;
import com.buuz135.industrial.utils.WorkUtils;
import net.minecraft.entity.EntityLiving;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.util.EnumFacing;
Expand Down Expand Up @@ -39,7 +39,7 @@ public AxisAlignedBB getWorkingArea() {

@Override
public float work() {
if (((CustomOrientedBlock) this.getBlockType()).isWorkDisabled()) return 0;
if (WorkUtils.isDisabled(this.getBlockType())) return 0;

AxisAlignedBB area = getWorkingArea();
List<EntityLiving> mobs = this.getWorld().getEntitiesWithinAABB(EntityLiving.class, area);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.buuz135.industrial.proxy.ItemRegistry;
import com.buuz135.industrial.tile.CustomColoredItemHandler;
import com.buuz135.industrial.tile.CustomElectricMachine;
import com.buuz135.industrial.tile.block.CustomOrientedBlock;
import com.buuz135.industrial.utils.WorkUtils;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.IFluidTank;
Expand Down Expand Up @@ -47,7 +47,7 @@ public boolean canExtractItem(int slot) {

@Override
protected float performWork() {
if (((CustomOrientedBlock) this.getBlockType()).isWorkDisabled()) return 0;
if (WorkUtils.isDisabled(this.getBlockType())) return 0;

ItemStack stack = new ItemStack(ItemRegistry.fertilizer, 1);
if (sewage.getFluid() != null && sewage.drain(2000, false).amount == 2000 && ItemHandlerHelper.insertItem(outFertilizer, stack, true).isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import com.buuz135.industrial.proxy.FluidsRegistry;
import com.buuz135.industrial.tile.CustomColoredItemHandler;
import com.buuz135.industrial.tile.CustomElectricMachine;
import com.buuz135.industrial.tile.block.CustomOrientedBlock;
import com.buuz135.industrial.tile.block.SludgeRefinerBlock;
import com.buuz135.industrial.utils.ItemStackWeightedItem;
import com.buuz135.industrial.utils.WorkUtils;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemStack;
import net.minecraft.util.WeightedRandom;
Expand Down Expand Up @@ -49,7 +49,7 @@ public boolean canExtractItem(int slot) {

@Override
protected float performWork() {
if (((CustomOrientedBlock) this.getBlockType()).isWorkDisabled()) return 0;
if (WorkUtils.isDisabled(this.getBlockType())) return 0;

if (tank.getFluid() != null && tank.getFluidAmount() >= 1000) {
SludgeRefinerBlock block = (SludgeRefinerBlock) this.getBlockType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.buuz135.industrial.tile.CustomColoredItemHandler;
import com.buuz135.industrial.tile.CustomElectricMachine;
import com.buuz135.industrial.utils.WorkUtils;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.EnumDyeColor;
Expand Down Expand Up @@ -67,6 +68,7 @@ public boolean canExtractItem(int slot) {

@Override
protected float performWork() {
if (WorkUtils.isDisabled(this.getBlockType())) return 0;
ItemStack stack = getFirstItem();
if (!stack.isEmpty() && waterTank.getFluidAmount() >= 500 && ItemHandlerHelper.insertItem(output, stack.copy(), true).isEmpty()) {
ItemStack out = stack.copy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.buuz135.industrial.tile.CustomColoredItemHandler;
import com.buuz135.industrial.tile.WorkingAreaElectricMachine;
import com.buuz135.industrial.tile.block.CustomOrientedBlock;
import com.buuz135.industrial.utils.BlockUtils;
import com.buuz135.industrial.utils.WorkUtils;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemStack;
Expand Down Expand Up @@ -51,7 +51,7 @@ public boolean canExtractItem(int slot) {

@Override
public float work() {
if (((CustomOrientedBlock) this.getBlockType()).isWorkDisabled()) return 0;
if (WorkUtils.isDisabled(this.getBlockType())) return 0;
if (this.world.rand.nextBoolean() && this.world.rand.nextBoolean()) return 1;
List<BlockPos> blockPos = BlockUtils.getBlockPosInAABB(getWorkingArea());
boolean allWaterSources = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.buuz135.industrial.tile.CustomColoredItemHandler;
import com.buuz135.industrial.tile.CustomElectricMachine;
import com.buuz135.industrial.tile.block.BioReactorBlock;
import com.buuz135.industrial.tile.block.CustomOrientedBlock;
import com.buuz135.industrial.utils.WorkUtils;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
Expand Down Expand Up @@ -66,7 +66,7 @@ public List<IGuiContainerPiece> getGuiContainerPieces(BasicTeslaGuiContainer con

@Override
protected float performWork() {
if (((CustomOrientedBlock) this.getBlockType()).isWorkDisabled()) return 0;
if (WorkUtils.isDisabled(this.getBlockType())) return 0;

if (getEfficiency() < 0) return 0;
FluidStack stack = new FluidStack(FluidsRegistry.BIOFUEL, getProducedAmountItem() * getItemAmount());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.buuz135.industrial.proxy.FluidsRegistry;
import com.buuz135.industrial.tile.CustomGeneratorMachine;
import com.buuz135.industrial.tile.block.CustomOrientedBlock;
import com.buuz135.industrial.utils.WorkUtils;
import net.minecraft.item.EnumDyeColor;
import net.minecraftforge.fluids.IFluidTank;
import net.ndrei.teslacorelib.inventory.BoundingRectangle;
Expand All @@ -23,7 +23,7 @@ protected void initializeInventories() {

@Override
protected long consumeFuel() {
if (((CustomOrientedBlock) this.getBlockType()).isWorkDisabled()) return 0;
if (WorkUtils.isDisabled(this.getBlockType())) return 0;
if (tank.getFluid() != null && tank.getFluidAmount() > 1) {
tank.drain(1, true);
return 160 * 7;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.buuz135.industrial.tile.generator;

import com.buuz135.industrial.tile.CustomElectricMachine;
import com.buuz135.industrial.tile.block.CustomOrientedBlock;
import com.buuz135.industrial.utils.WorkUtils;
import net.minecraft.init.Items;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemStack;
Expand Down Expand Up @@ -29,7 +29,7 @@ protected void initializeInventories() {

@Override
protected float performWork() {
if (((CustomOrientedBlock) this.getBlockType()).isWorkDisabled()) return 0;
if (WorkUtils.isDisabled(this.getBlockType())) return 0;

if (tank.getFluid() == null || tank.getFluidAmount() <= 7000) {
tank.fill(new FluidStack(FluidRegistry.LAVA, 1000), true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.buuz135.industrial.proxy.client.infopiece.PetrifiedFuelInfoPiece;
import com.buuz135.industrial.tile.CustomGeneratorMachine;
import com.buuz135.industrial.tile.block.CustomOrientedBlock;
import com.buuz135.industrial.utils.WorkUtils;
import net.minecraft.init.Items;
import net.minecraft.inventory.Slot;
import net.minecraft.item.EnumDyeColor;
Expand Down Expand Up @@ -94,7 +94,7 @@ public ItemStack getFirstFuel(boolean replace) {

@Override
public long consumeFuel() { //TODO fix buckets
if (((CustomOrientedBlock) this.getBlockType()).isWorkDisabled()) return 0;
if (WorkUtils.isDisabled(this.getBlockType())) return 0;
ItemStack temp = this.getFirstFuel(true);
if (temp.isEmpty()) {
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.buuz135.industrial.proxy.FluidsRegistry;
import com.buuz135.industrial.tile.CustomColoredItemHandler;
import com.buuz135.industrial.tile.CustomElectricMachine;
import com.buuz135.industrial.tile.block.CustomOrientedBlock;
import com.buuz135.industrial.utils.WorkUtils;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.init.Items;
Expand Down Expand Up @@ -120,7 +120,7 @@ public boolean canWork() {

@Override
protected float performWork() {
if (((CustomOrientedBlock) this.getBlockType()).isWorkDisabled()) return 0;
if (WorkUtils.isDisabled(this.getBlockType())) return 0;
//EnchantmentHelper.buildEnchantmentList(this.world.rand,ItemStack.EMPTY,30, true); //TODO the auto enchanting
if (!canWork()) return 0;
int xp = (int) (getLevels() * 100);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.buuz135.industrial.tile.CustomColoredItemHandler;
import com.buuz135.industrial.tile.CustomElectricMachine;
import com.buuz135.industrial.tile.block.CustomOrientedBlock;
import com.buuz135.industrial.utils.WorkUtils;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentData;
import net.minecraft.init.Items;
Expand Down Expand Up @@ -126,7 +126,7 @@ private ItemStack getItem() {

@Override
protected float performWork() {
if (((CustomOrientedBlock) this.getBlockType()).isWorkDisabled()) return 0;
if (WorkUtils.isDisabled(this.getBlockType())) return 0;

if (!hasBooks() || getItem().isEmpty()) return 0;
ItemStack enchantedItem = getItem();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.buuz135.industrial.proxy.FluidsRegistry;
import com.buuz135.industrial.tile.CustomColoredItemHandler;
import com.buuz135.industrial.tile.CustomElectricMachine;
import com.buuz135.industrial.tile.block.CustomOrientedBlock;
import com.buuz135.industrial.utils.WorkUtils;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemStack;
Expand Down Expand Up @@ -66,7 +66,7 @@ public boolean canExtractItem(int slot) {

@Override
protected float performWork() {
if (((CustomOrientedBlock) this.getBlockType()).isWorkDisabled()) return 0;//enchantment_invoker
if (WorkUtils.isDisabled(this.getBlockType())) return 0;//enchantment_invoker

ItemStack stack = getFirstItem();
if (essenceTank.getFluidAmount() >= 3000 && !stack.isEmpty() && ItemHandlerHelper.insertItem(output, stack, true).isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.buuz135.industrial.tile.CustomColoredItemHandler;
import com.buuz135.industrial.tile.CustomElectricMachine;
import com.buuz135.industrial.tile.block.CustomOrientedBlock;
import com.buuz135.industrial.utils.WorkUtils;
import net.minecraft.init.Items;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemStack;
Expand Down Expand Up @@ -104,7 +104,7 @@ public ItemStack getFirstItem() {

@Override
protected float performWork() {
if (((CustomOrientedBlock) this.getBlockType()).isWorkDisabled()) return 0;
if (WorkUtils.isDisabled(this.getBlockType())) return 0;

ItemStack stack = getFirstItem();
if (stack.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import com.buuz135.industrial.tile.CustomColoredItemHandler;
import com.buuz135.industrial.tile.CustomElectricMachine;
import com.buuz135.industrial.tile.block.CustomOrientedBlock;
import com.buuz135.industrial.utils.ItemStackUtils;
import com.buuz135.industrial.utils.Reference;
import com.buuz135.industrial.utils.WorkUtils;
import net.minecraft.init.Items;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemStack;
Expand Down Expand Up @@ -180,7 +180,7 @@ public void drawMiddleLayer(BasicTeslaGuiContainer container, int guiX, int guiY

@Override
public float performWork() {
if (((CustomOrientedBlock) this.getBlockType()).isWorkDisabled()) return 0;
if (WorkUtils.isDisabled(this.getBlockType())) return 0;
if (action > 5) action = 0;
if (action != 0 && outputPotions.getStackInSlot(0).isEmpty() && outputPotions.getStackInSlot(1).isEmpty() && outputPotions.getStackInSlot(2).isEmpty()) {
action = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.buuz135.industrial.proxy.BlockRegistry;
import com.buuz135.industrial.tile.CustomColoredItemHandler;
import com.buuz135.industrial.tile.block.CustomOrientedBlock;
import com.buuz135.industrial.utils.WorkUtils;
import net.minecraft.inventory.InventoryHelper;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.Item;
Expand Down Expand Up @@ -115,7 +115,7 @@ public void dropItems() {

@Override
protected void innerUpdate() {
if (((CustomOrientedBlock) this.getBlockType()).isWorkDisabled()) return;
if (WorkUtils.isDisabled(this.getBlockType())) return;
for (int i = 0; i < 9; ++i) {
ItemStack stack = storage.getStackInSlot(i);
if (!stack.isEmpty()) {
Expand Down
Loading

0 comments on commit 4ec21f7

Please sign in to comment.