More fixes 637

This commit is contained in:
modmuss50 2019-02-21 23:07:44 +00:00
parent f51222ac3e
commit 18b3535607
21 changed files with 96 additions and 240 deletions

View file

@ -24,138 +24,31 @@
package techreborn.api;
import net.minecraft.block.Block;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.item.crafting.ShapedRecipes;
import net.minecraft.item.crafting.ShapelessRecipes;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.common.crafting.CraftingHelper;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.ModContainer;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import org.apache.commons.lang3.Validate;
import java.util.HashMap;
public class RollingMachineRecipe {
public static final RollingMachineRecipe instance = new RollingMachineRecipe();
private static final HashMap<ResourceLocation, IRecipe> recipes = new HashMap<>();
public void addShapedOreRecipe(ResourceLocation resourceLocation, ItemStack outputItemStack, Object... objectInputs) {
Validate.notNull(outputItemStack);
Validate.notNull(outputItemStack.getItem());
if (objectInputs.length == 0) {
Validate.notNull(null); //Quick way to crash
}
recipes.put(resourceLocation, new ShapedOreRecipe(resourceLocation, outputItemStack, objectInputs));
throw new UnsupportedOperationException("Needs moving to json");
}
public void addShapelessOreRecipe(ResourceLocation resourceLocation, ItemStack outputItemStack, Object... objectInputs) {
Validate.notNull(outputItemStack);
Validate.notNull(outputItemStack.getItem());
if (objectInputs.length == 0) {
Validate.notNull(null); //Quick way to crash
}
recipes.put(resourceLocation, new ShapelessOreRecipe(resourceLocation, outputItemStack, objectInputs));
}
public static ResourceLocation getNameForRecipe(ItemStack output) {
ModContainer activeContainer = Loader.instance().activeModContainer();
ResourceLocation baseLoc = new ResourceLocation(activeContainer.getModId(), output.getItem().getRegistryName().getPath());
ResourceLocation recipeLoc = baseLoc;
int index = 0;
while (recipes.containsKey(recipeLoc)) {
index++;
recipeLoc = new ResourceLocation(activeContainer.getModId(), baseLoc.getPath() + "_" + index);
}
return recipeLoc;
}
public void addRecipe(ResourceLocation resourceLocation, ItemStack output, Object... components) {
String s = "";
int i = 0;
int j = 0;
int k = 0;
if (components[i] instanceof String[]) {
String as[] = (String[]) components[i++];
for (int l = 0; l < as.length; l++) {
String s2 = as[l];
k++;
j = s2.length();
s = (new StringBuilder()).append(s).append(s2).toString();
}
} else {
while (components[i] instanceof String) {
String s1 = (String) components[i++];
k++;
j = s1.length();
s = (new StringBuilder()).append(s).append(s1).toString();
}
}
HashMap<Character, ItemStack> hashmap = new HashMap<Character, ItemStack>();
for (; i < components.length; i += 2) {
Character character = (Character) components[i];
ItemStack itemstack1 = null;
if (components[i + 1] instanceof Item) {
itemstack1 = new ItemStack((Item) components[i + 1]);
} else if (components[i + 1] instanceof Block) {
itemstack1 = new ItemStack((Block) components[i + 1], 1, -1);
} else if (components[i + 1] instanceof ItemStack) {
itemstack1 = (ItemStack) components[i + 1];
}
hashmap.put(character, itemstack1);
}
NonNullList<Ingredient> recipeArray = NonNullList.create();
for (int i1 = 0; i1 < j * k; i1++) {
char c = s.charAt(i1);
if (hashmap.containsKey(c)) {
recipeArray.set(i1, CraftingHelper.getIngredient(((ItemStack) hashmap.get(c)).copy()));
} else {
recipeArray.set(i1, CraftingHelper.getIngredient(ItemStack.EMPTY));
}
}
recipes.put(resourceLocation, new ShapedRecipes("", j, k, recipeArray, output));
}
public void addShapelessRecipe(ResourceLocation resourceLocation, ItemStack output, Object... components) {
NonNullList<Ingredient> ingredients = NonNullList.create();
for (int j = 0; j < components.length; j++) {
ingredients.add(CraftingHelper.getIngredient(components[j]));
}
recipes.put(resourceLocation, new ShapelessRecipes("", output, ingredients));
throw new UnsupportedOperationException("Needs moving to json");
}
public ItemStack findMatchingRecipeOutput(InventoryCrafting inv, World world) {
for (IRecipe irecipe : recipes.values()) {
if (irecipe.matches(inv, world)) {
return irecipe.getCraftingResult(inv);
}
}
return ItemStack.EMPTY;
throw new UnsupportedOperationException("Needs moving to json");
}
public IRecipe findMatchingRecipe(InventoryCrafting inv, World world) {
for (IRecipe irecipe : recipes.values()) {
if (irecipe.matches(inv, world)) {
return irecipe;
}
}
return null;
}
public HashMap<ResourceLocation, IRecipe> getRecipeList() {
return recipes;
throw new UnsupportedOperationException("Needs moving to json");
}
}

View file

@ -111,7 +111,7 @@ public class FluidReplicatorRecipe implements Cloneable {
return false;
}
final BlockPos hole = tile.getPos().offset(tile.getFacing().getOpposite(), 2);
final Fluid fluid = FluidRegistry.lookupFluidForBlock(tile.getWorld().getBlockState(hole).getBlock());
final Fluid fluid = techreborn.utils.FluidUtils.fluidFromBlock(tile.getWorld().getBlockState(hole).getBlock());
if (fluid == null) {
return false;
}

View file

@ -64,7 +64,7 @@ public class GuiAESU extends GuiBase {
if(GuiBase.slotConfigType == SlotConfigType.NONE){
GlStateManager.pushMatrix();
GlStateManager.scale(0.6, 0.6, 1);
GlStateManager.scaled(0.6, 0.6, 1);
drawCentredString(PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) tile.getEnergy()) + "/"
+ PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) tile.getMaxPower()) + " "
+ PowerSystem.getDisplayPower().abbreviation, 35, 0, 58, layer);

View file

@ -25,13 +25,13 @@
package techreborn.client.keybindings;
import net.minecraft.client.settings.KeyBinding;
import org.lwjgl.input.Keyboard;
import org.lwjgl.glfw.GLFW;
public class KeyBindings {
public static final String CATEGORY = "keys.techreborn.category";
public static final String CONFIG = "keys.techreborn.config";
public static KeyBinding config = new KeyBinding(CONFIG, Keyboard.KEY_P, CATEGORY);
public static KeyBinding config = new KeyBinding(CONFIG, GLFW.GLFW_KEY_P, CATEGORY);
}

View file

@ -28,7 +28,6 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.Tag;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@ -41,7 +40,7 @@ import reborncore.common.registration.config.ConfigRegistry;
import reborncore.common.util.OreDrop;
import techreborn.TechReborn;
import techreborn.init.TRContent;
import techreborn.utils.OreDictUtils;
import techreborn.utils.TagUtils;
import java.util.List;
import java.util.Random;
@ -68,23 +67,23 @@ public class BlockBreakHandler {
IBlockState state = event.getState();
List<ItemStack> drops = event.getDrops();
Random random = new Random();
if (OreDictUtils.isOre(state, "oreRuby")) {
if (TagUtils.isOre(state, "oreRuby")) {
OreDrop redGarnet = new OreDrop(TRContent.Gems.RED_GARNET.getStack(), redGarnetDropChance, 1);
drops.add(redGarnet.getDrops(event.getFortuneLevel(), random));
}
else if (OreDictUtils.isOre(state, "oreSapphire")) {
else if (TagUtils.isOre(state, "oreSapphire")) {
OreDrop peridot = new OreDrop(TRContent.Gems.PERIDOT.getStack(), peridotDropChance, 1);
drops.add(peridot.getDrops(event.getFortuneLevel(), random));
}
else if (OreDictUtils.isOre(state, "oreSodalite")) {
else if (TagUtils.isOre(state, "oreSodalite")) {
OreDrop aluminium = new OreDrop(TRContent.Dusts.ALUMINUM.getStack(), aluminiumDropChance, 1);
drops.add(aluminium.getDrops(event.getFortuneLevel(), random));
}
else if (OreDictUtils.isOre(state, "oreCinnabar")) {
else if (TagUtils.isOre(state, "oreCinnabar")) {
OreDrop redstone = new OreDrop(new ItemStack(Items.REDSTONE), redstoneDropChance, 1);
drops.add(redstone.getDrops(event.getFortuneLevel(), random));
}
else if (OreDictUtils.isOre(state, "oreSphalerite")) {
else if (TagUtils.isOre(state, "oreSphalerite")) {
OreDrop yellowGarnet = new OreDrop(TRContent.Gems.YELLOW_GARNET.getStack(), yellowGarnetDropChance, 1);
drops.add(yellowGarnet.getDrops(event.getFortuneLevel(), random));
}

View file

@ -48,10 +48,10 @@ import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import static techreborn.utils.OreDictUtils.getDictData;
import static techreborn.utils.OreDictUtils.getDictOreOrEmpty;
import static techreborn.utils.OreDictUtils.isDictPrefixed;
import static techreborn.utils.OreDictUtils.joinDictName;
import static techreborn.utils.TagUtils.getDictData;
import static techreborn.utils.TagUtils.getDictOreOrEmpty;
import static techreborn.utils.TagUtils.isDictPrefixed;
import static techreborn.utils.TagUtils.joinDictName;
@RebornRegister(TechReborn.MOD_ID)
public class ModRecipes {

View file

@ -42,7 +42,7 @@ import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.powerSystem.PoweredItemContainerProvider;
import reborncore.common.powerSystem.forge.ForgePowerItemManager;
import reborncore.common.util.ItemUtils;
import techreborn.utils.OreDictUtils;
import techreborn.utils.TagUtils;
import javax.annotation.Nullable;
import java.util.Random;
@ -64,7 +64,7 @@ public class ItemJackhammer extends ItemPickaxe implements IEnergyItemInfo {
// ItemPickaxe
@Override
public float getDestroySpeed(ItemStack stack, IBlockState state) {
if ((OreDictUtils.isOre(state, "stone") || state.getBlock() == Blocks.STONE)
if ((TagUtils.isOre(state, "stone") || state.getBlock() == Blocks.STONE)
&& new ForgePowerItemManager(stack).getEnergyStored() >= cost) {
return efficiency;
} else {
@ -93,7 +93,7 @@ public class ItemJackhammer extends ItemPickaxe implements IEnergyItemInfo {
// Item
@Override
public boolean canHarvestBlock(final IBlockState state, final ItemStack stack) {
return OreDictUtils.isOre(state, "stone")
return TagUtils.isOre(state, "stone")
|| state.getMaterial() == Material.ROCK && new ForgePowerItemManager(stack).getEnergyStored() >= cost;
}

View file

@ -172,8 +172,8 @@ public class TileCable extends TileEntity
sendingFace.add(face);
}
}
} else if (tile.hasCapability(CapabilityEnergy.ENERGY, face.getOpposite())) {
IEnergyStorage energyTile = tile.getCapability(CapabilityEnergy.ENERGY, face.getOpposite());
} else if (tile.getCapability(CapabilityEnergy.ENERGY, face.getOpposite()).isPresent()) {
IEnergyStorage energyTile = tile.getCapability(CapabilityEnergy.ENERGY, face.getOpposite()).orElse(null);
if (energyTile != null && energyTile.canReceive()) {
acceptors.add(energyTile);
}

View file

@ -126,10 +126,10 @@ public class TileFusionControlComputer extends TilePowerAcceptor
*
* @param stack ItemStack ItemStack to insert
* @param slot int Slot ID to check
* @param oreDic boolean Should we use ore dictionary
* @param tags boolean Should we use tags
* @return boolean Returns true if ItemStack will fit into slot
*/
public boolean canFitStack(ItemStack stack, int slot, boolean oreDic) {// Checks to see if it can
public boolean canFitStack(ItemStack stack, int slot, boolean tags) {// Checks to see if it can
// fit the stack
if (stack.isEmpty()) {
return true;
@ -137,7 +137,7 @@ public class TileFusionControlComputer extends TilePowerAcceptor
if (inventory.getStackInSlot(slot).isEmpty()) {
return true;
}
if (ItemUtils.isItemEqual(inventory.getStackInSlot(slot), stack, true, true, oreDic)) {
if (ItemUtils.isItemEqual(inventory.getStackInSlot(slot), stack, true, tags)) {
if (stack.getCount() + inventory.getStackInSlot(slot).getCount() <= stack.getMaxStackSize()) {
return true;
}
@ -185,9 +185,9 @@ public class TileFusionControlComputer extends TilePowerAcceptor
}
private boolean validateReactorRecipeInputs(FusionReactorRecipe recipe, ItemStack slot1, ItemStack slot2) {
if (ItemUtils.isItemEqual(slot1, recipe.getTopInput(), true, true, true)) {
if (ItemUtils.isItemEqual(slot1, recipe.getTopInput(), true, true)) {
if (recipe.getBottomInput() != null) {
if (!ItemUtils.isItemEqual(slot2, recipe.getBottomInput(), true, true, true)) {
if (!ItemUtils.isItemEqual(slot2, recipe.getBottomInput(), true, true)) {
return false;
}
}

View file

@ -74,8 +74,8 @@ public class TileWaterMill extends TilePowerAcceptor implements IToolDrop {
public void checkForWater() {
waterblocks = 0;
for (EnumFacing facing : EnumFacing.HORIZONTALS) {
if (world.getBlockState(pos.offset(facing)).getBlock() == Blocks.WATER) {
for (EnumFacing facing : EnumFacing.values()) {
if (facing.getAxis().isHorizontal() && world.getBlockState(pos.offset(facing)).getBlock() == Blocks.WATER) {
waterblocks++;
}
}

View file

@ -30,6 +30,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.*;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.util.EnumFacing;
import reborncore.api.IToolDrop;
import reborncore.api.recipe.IBaseRecipeType;
@ -48,6 +49,7 @@ import reborncore.client.containerBuilder.IContainerProvider;
import reborncore.client.containerBuilder.builder.BuiltContainer;
import reborncore.client.containerBuilder.builder.ContainerBuilder;
import techreborn.init.TRTileEntities;
import techreborn.tiles.machine.tier1.TileElectricFurnace;
@RebornRegister(TechReborn.MOD_ID)
public class TileIronAlloyFurnace extends TileMachineBase
@ -77,54 +79,7 @@ public class TileIronAlloyFurnace extends TileMachineBase
if (stack.isEmpty()) {
return 0;
} else {
int burnTime = net.minecraftforge.event.ForgeEventFactory.getItemBurnTime(stack);
if (burnTime >= 0)
return burnTime;
Item item = stack.getItem();
if (item == Item.getItemFromBlock(Blocks.WOODEN_SLAB)) {
return 150;
} else if (item == Item.getItemFromBlock(Blocks.WOOL)) {
return 100;
} else if (item == Item.getItemFromBlock(Blocks.CARPET)) {
return 67;
} else if (item == Item.getItemFromBlock(Blocks.LADDER)) {
return 300;
} else if (item == Item.getItemFromBlock(Blocks.WOODEN_BUTTON)) {
return 100;
} else if (Block.getBlockFromItem(item).getDefaultState().getMaterial() == Material.WOOD) {
return 300;
} else if (item == Item.getItemFromBlock(Blocks.COAL_BLOCK)) {
return 16000;
} else if (item instanceof ItemTool && "WOOD".equals(((ItemTool) item).getToolMaterialName())) {
return 200;
} else if (item instanceof ItemSword && "WOOD".equals(((ItemSword) item).getToolMaterialName())) {
return 200;
} else if (item instanceof ItemHoe && "WOOD".equals(((ItemHoe) item).getMaterialName())) {
return 200;
} else if (item == Items.STICK) {
return 100;
} else if (item != Items.BOW && item != Items.FISHING_ROD) {
if (item == Items.SIGN) {
return 200;
} else if (item == Items.COAL) {
return 1600;
} else if (item == Items.LAVA_BUCKET) {
return 20000;
} else if (item != Item.getItemFromBlock(Blocks.SAPLING) && item != Items.BOWL) {
if (item == Items.BLAZE_ROD) {
return 2400;
} else if (item instanceof ItemDoor && item != Items.IRON_DOOR) {
return 200;
} else {
return item instanceof ItemBoat ? 400 : 0;
}
} else {
return 100;
}
} else {
return 300;
}
return TileEntityFurnace.getBurnTimes().getOrDefault(stack.getItem(), 0);
}
}
@ -174,11 +129,11 @@ public class TileIronAlloyFurnace extends TileMachineBase
}
for (final Object input : recipeType.getInputs()) {
boolean hasItem = false;
boolean useOreDict = input instanceof String || recipeType.useOreDic();
boolean useTags = input instanceof String || recipeType.useOreDic();
boolean checkSize = input instanceof ItemStack;
for (int inputslot = 0; inputslot < 2; inputslot++) {
if (ItemUtils.isInputEqual(input, inventory.getStackInSlot(inputslot), true, true,
useOreDict)) {
if (ItemUtils.isInputEqual(input, inventory.getStackInSlot(inputslot), true,
useTags)) {
ItemStack stack = RecipeTranslator.getStackFromObject(input);
if (!checkSize || inventory.getStackInSlot(inputslot).getCount() >= stack.getCount()) {
hasItem = true;
@ -255,7 +210,7 @@ public class TileIronAlloyFurnace extends TileMachineBase
for (Object input : recipeType.getInputs()) {
boolean useOreDict = input instanceof String || recipeType.useOreDic();
for (int inputSlot = 0; inputSlot < 2; inputSlot++) {
if (ItemUtils.isInputEqual(input, this.inventory.getStackInSlot(inputSlot), true, true, useOreDict)) {
if (ItemUtils.isInputEqual(input, this.inventory.getStackInSlot(inputSlot), true, useOreDict)) {
int count = 1;
if (input instanceof ItemStack) {
count = RecipeTranslator.getStackFromObject(input).getCount();
@ -342,11 +297,11 @@ public class TileIronAlloyFurnace extends TileMachineBase
.filterSlot(0, 47, 17,
stack -> RecipeHandler.recipeList.stream()
.anyMatch(recipe -> recipe instanceof AlloySmelterRecipe
&& ItemUtils.isInputEqual(recipe.getInputs().get(0), stack, true, true, true)))
&& ItemUtils.isInputEqual(recipe.getInputs().get(0), stack, true, true)))
.filterSlot(1, 65, 17,
stack -> RecipeHandler.recipeList.stream()
.anyMatch(recipe -> recipe instanceof AlloySmelterRecipe
&& ItemUtils.isInputEqual(recipe.getInputs().get(1), stack, true, true, true)))
&& ItemUtils.isInputEqual(recipe.getInputs().get(1), stack, true, true)))
.outputSlot(2, 116, 35).fuelSlot(3, 56, 53).syncIntegerValue(this::getBurnTime, this::setBurnTime)
.syncIntegerValue(this::getCookTime, this::setCookTime)
.syncIntegerValue(this::getCurrentItemBurnTime, this::setCurrentItemBurnTime).addInventory().create(this);

View file

@ -86,7 +86,7 @@ public class TileIronFurnace extends TileMachineBase
this.updateState();
}
if (this.fuel <= 0 && this.canSmelt()) {
this.fuel = this.fuelGague = (int) (TileEntityFurnace.getItemBurnTime(inventory.getStackInSlot(this.fuelslot)) * 1.25);
this.fuel = this.fuelGague = (int) (TileEntityFurnace.getBurnTimes().getOrDefault(inventory.getStackInSlot(this.fuelslot).getItem(), 0) * 1.25);
if (this.fuel > 0) {
// Fuel slot
ItemStack fuelStack = inventory.getStackInSlot(this.fuelslot);
@ -165,7 +165,7 @@ public class TileIronFurnace extends TileMachineBase
final IBlockState BlockStateContainer = this.world.getBlockState(this.pos);
if (BlockStateContainer.getBlock() instanceof BlockMachineBase) {
final BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock();
if (BlockStateContainer.getValue(BlockMachineBase.ACTIVE) != this.fuel > 0)
if (BlockStateContainer.get(BlockMachineBase.ACTIVE) != this.fuel > 0)
blockMachineBase.setActive(this.fuel > 0, this.world, this.pos);
}
}

View file

@ -82,7 +82,7 @@ public class TileFluidReplicator extends TileGenericMachine implements IContaine
// TileGenericMachine
@Override
public void update() {
public void tick() {
if (multiblockChecker == null) {
final BlockPos downCenter = pos.offset(getFacing().getOpposite(), 2);
multiblockChecker = new MultiblockChecker(world, downCenter);
@ -98,7 +98,7 @@ public class TileFluidReplicator extends TileGenericMachine implements IContaine
}
if (getMultiBlock()) {
super.update();
super.tick();
}
tank.compareAndUpdate();

View file

@ -66,14 +66,14 @@ public class TileImplosionCompressor extends TileGenericMachine implements ICont
// TileGenericMachine
@Override
public void update() {
public void tick() {
if (multiblockChecker == null) {
final BlockPos downCenter = pos.offset(getFacing().getOpposite(), 2);
multiblockChecker = new MultiblockChecker(world, downCenter);
}
if (!world.isRemote && getMutliBlock()){
super.update();
super.tick();
}
}

View file

@ -128,14 +128,14 @@ public class TileIndustrialBlastFurnace extends TileGenericMachine implements IC
// TileGenericMachine
@Override
public void update() {
public void tick() {
if (multiblockChecker == null) {
final BlockPos downCenter = pos.offset(getFacing().getOpposite(), 2);
multiblockChecker = new MultiblockChecker(world, downCenter);
}
if (!world.isRemote && getMutliBlock()){
super.update();
super.tick();
}
}

View file

@ -24,7 +24,6 @@
package techreborn.tiles.machine.multiblock;
import net.minecraft.block.BlockLiquid;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
@ -94,7 +93,7 @@ public class TileIndustrialGrinder extends TileGenericMachine implements IContai
private static IInventoryAccess<TileIndustrialGrinder> getInventoryAccess(){
return (slotID, stack, face, direction, tile) -> {
if(slotID == 1){
return stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null);
return stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null).isPresent();
}
return true;
};
@ -102,7 +101,7 @@ public class TileIndustrialGrinder extends TileGenericMachine implements IContai
// TilePowerAcceptor
@Override
public void update() {
public void tick() {
if (multiblockChecker == null) {
final BlockPos downCenter = pos.offset(getFacing().getOpposite(), 2).down();
multiblockChecker = new MultiblockChecker(world, downCenter);
@ -119,7 +118,7 @@ public class TileIndustrialGrinder extends TileGenericMachine implements IContai
}
if (!world.isRemote && getMultiBlock()) {
super.update();
super.tick();
}
tank.compareAndUpdate();

View file

@ -24,7 +24,6 @@
package techreborn.tiles.machine.multiblock;
import net.minecraft.block.BlockLiquid;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
@ -92,7 +91,7 @@ public class TileIndustrialSawmill extends TileGenericMachine implements IContai
// TileGenericMachine
@Override
public void update() {
public void tick() {
if (multiblockChecker == null) {
final BlockPos downCenter = pos.offset(getFacing().getOpposite(), 2).down();
multiblockChecker = new MultiblockChecker(world, downCenter);
@ -109,7 +108,7 @@ public class TileIndustrialSawmill extends TileGenericMachine implements IContai
}
if (!world.isRemote && getMutliBlock()) {
super.update();
super.tick();
}
tank.compareAndUpdate();
@ -139,7 +138,7 @@ public class TileIndustrialSawmill extends TileGenericMachine implements IContai
private static IInventoryAccess<TileIndustrialSawmill> getInventoryAccess(){
return (slotID, stack, face, direction, tile) -> {
if(direction == IInventoryAccess.AccessDirection.INSERT){
return stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null);
return stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null).isPresent();
}
return true;
};

View file

@ -62,9 +62,9 @@ public class TileVacuumFreezer extends TileGenericMachine implements IContainerP
// TileGenericMachine
@Override
public void update() {
public void tick() {
if (!world.isRemote && getMultiBlock()) {
super.update();
super.tick();
}
}

View file

@ -93,7 +93,7 @@ public class TilePlayerDectector extends TilePowerAcceptor implements IToolDrop
}
if (lastRedstone != redstone) {
WorldUtils.updateBlock(world, pos);
world.notifyNeighborsOfStateChange(pos, world.getBlockState(pos).getBlock(), true);
world.notifyNeighborsOfStateChange(pos, world.getBlockState(pos).getBlock());
}
}
}

View file

@ -0,0 +1,13 @@
package techreborn.utils;
import net.minecraft.block.Block;
import net.minecraftforge.fluids.Fluid;
public class FluidUtils {
public static Fluid fluidFromBlock(Block bLock){
throw new UnsupportedOperationException("needs coding");
}
}

View file

@ -26,15 +26,34 @@ package techreborn.utils;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.fluid.Fluid;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tags.Tag;
import net.minecraft.tags.TagCollection;
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;
import javax.annotation.Nonnull;
import java.util.List;
@Deprecated //needs to go and be repalced by a version for tags. Has some other stuff that might be useful in another class so im not removing it just yet
public class OreDictUtils {
public class TagUtils {
public static <T> boolean hasTag(T type, Tag<T> tag) {
return tag.contains(type);
}
public static TagCollection<Block> getAllBlockTags(World world) {
return world.getTags().getBlocks();
}
public static TagCollection<Item> getAllItemTags(World world) {
return world.getTags().getItems();
}
public static TagCollection<Fluid> getAllFluidTags(World world) {
return world.getTags().getFluids();
}
public static String toFirstLower(String string) {
if (string == null || string.isEmpty())
@ -80,44 +99,23 @@ public class OreDictUtils {
return false;
}
@Deprecated
@Nonnull
public static ItemStack getDictOreOrEmpty(String name, int amount) {
List<ItemStack> ores = OreDictionary.getOres(name);
if (ores.isEmpty())
return ItemStack.EMPTY;
ItemStack ore = ores.get(0).copy();
ore.setCount(amount);
return ore;
throw new UnsupportedOperationException("Move to tags");
}
public static boolean isOre(Block block, String oreName) {
return isOre(new ItemStack(Item.getItemFromBlock(block)), oreName);
}
@Deprecated
public static boolean isOre(IBlockState state, String oreName) {
return isOre(
new ItemStack(Item.getItemFromBlock(state.getBlock()), 1, state.getBlock().getMetaFromState(state)),
oreName);
throw new UnsupportedOperationException("Move to tags");
}
public static boolean isOre(Item item, String oreName) {
return isOre(new ItemStack(item), oreName);
}
@Deprecated
public static boolean isOre(
@Nonnull
ItemStack stack, String oreName) {
if (!stack.isEmpty() && oreName != null) {
int id = OreDictionary.getOreID(oreName);
int[] ids = OreDictionary.getOreIDs(stack);
for (int i : ids) {
if (id == i) {
return true;
}
}
}
return false;
throw new UnsupportedOperationException("Move to tags");
}
}