Finalized ARC
Finished 99% of the implementation work for the ARC and recipe system. Still need to populate the recipes (which will require textures for some items have have yet to be added).
This commit is contained in:
parent
9fa68e86ae
commit
1ead4ff820
56 changed files with 945 additions and 129 deletions
|
@ -452,6 +452,11 @@ public class BloodMagicRecipeRegistrar implements IBloodMagicRecipeRegistrar
|
|||
return ImmutableSet.copyOf(world.getRecipeManager().getRecipesForType(BloodMagicRecipeType.ARRAY));
|
||||
}
|
||||
|
||||
public Set<RecipeARC> getARCRecipes(World world)
|
||||
{
|
||||
return ImmutableSet.copyOf(world.getRecipeManager().getRecipesForType(BloodMagicRecipeType.ARC));
|
||||
}
|
||||
|
||||
public Set<RecipeAlchemyArray> getCraftingAlchemyArrayRecipes(World world)
|
||||
{
|
||||
Set<RecipeAlchemyArray> recipes = Set.copyOf(world.getRecipeManager().getRecipesForType(BloodMagicRecipeType.ARRAY));
|
||||
|
|
|
@ -117,6 +117,19 @@ public abstract class RecipeARC extends BloodMagicRecipe
|
|||
return list;
|
||||
}
|
||||
|
||||
public double[] getAllOutputChances()
|
||||
{
|
||||
int size = addedItems.size();
|
||||
|
||||
double[] chanceArray = new double[size];
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
chanceArray[i] = addedItems.get(i).getRight();
|
||||
}
|
||||
|
||||
return chanceArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(PacketBuffer buffer)
|
||||
{
|
||||
|
|
|
@ -88,20 +88,22 @@ public class ScreenAlchemicalReactionChamber extends ScreenBase<ContainerAlchemi
|
|||
ClientHandler.handleGuiTank(stack, tileARC.outputTank, this.guiLeft + 152, this.guiTop
|
||||
+ 15, 16, 63, 194, 1, 16, 63, mouseX, mouseY, background.toString(), null);
|
||||
|
||||
// int l = this.getCookProgressScaled(90);
|
||||
// this.blit(stack, i + 115, j + 14 + 90 - l, 176, 90 - l, 18, l);
|
||||
int w = this.getCookProgressScaled(38);
|
||||
System.out.println("Width: " + w);
|
||||
// FurnaceTileEntity d;
|
||||
this.blit(stack, i + 63, j + 44, 176, 90, w, 23);
|
||||
}
|
||||
|
||||
////
|
||||
// public int getCookProgressScaled(int scale)
|
||||
// {
|
||||
// double progress = ((TileSoulForge) tileSoulForge).getProgressForGui();
|
||||
//// if (tileSoulForge != null)
|
||||
//// {
|
||||
//// System.out.println("Tile is NOT null");
|
||||
//// }
|
||||
//// double progress = ((float) this.container.data.get(0)) / ((float) this.container.data.get(1));
|
||||
//// System.out.println(this.container.data.get(0));
|
||||
// return (int) (progress * scale);
|
||||
// }
|
||||
public int getCookProgressScaled(int scale)
|
||||
{
|
||||
double progress = ((TileAlchemicalReactionChamber) tileARC).getProgressForGui();
|
||||
// if (tileSoulForge != null)
|
||||
// {
|
||||
// System.out.println("Tile is NOT null");
|
||||
// }
|
||||
// double progress = ((float) this.container.data.get(0)) / ((float) this.container.data.get(1));
|
||||
// System.out.println(this.container.data.get(0));
|
||||
return (int) (progress * scale);
|
||||
}
|
||||
}
|
|
@ -50,6 +50,7 @@ public class GeneratorBaseRecipes extends BaseRecipeProvider
|
|||
ShapedRecipeBuilder.shapedRecipe(BloodMagicBlocks.BLANK_RITUAL_STONE.get(), 4).key('a', Tags.Items.OBSIDIAN).key('b', BloodMagicItems.REINFORCED_SLATE.get()).key('c', IngredientBloodOrb.fromOrb(BloodMagicItems.ORB_APPRENTICE.get())).patternLine("aba").patternLine("bcb").patternLine("aba").addCriterion("has_apprentice_orb", hasItem(BloodMagicItems.APPRENTICE_BLOOD_ORB.get())).build(consumer, BloodMagic.rl("ritual_stone_blank"));
|
||||
ShapedRecipeBuilder.shapedRecipe(BloodMagicBlocks.MASTER_RITUAL_STONE.get()).key('a', Tags.Items.OBSIDIAN).key('b', BloodMagicBlocks.BLANK_RITUAL_STONE.get()).key('c', IngredientBloodOrb.fromOrb(BloodMagicItems.ORB_MAGICIAN.get())).patternLine("aba").patternLine("bcb").patternLine("aba").addCriterion("has_magician_orb", hasItem(BloodMagicItems.MAGICIAN_BLOOD_ORB.get())).build(consumer, BloodMagic.rl("ritual_stone_master"));
|
||||
|
||||
ShapedRecipeBuilder.shapedRecipe(BloodMagicItems.PRIMITIVE_FURNACE_CELL.get()).key('c', Tags.Items.COBBLESTONE).key('f', Tags.Items.STORAGE_BLOCKS_COAL).key('s', Ingredient.fromItems(BloodMagicItems.SLATE.get())).key('o', IngredientBloodOrb.fromOrb(BloodMagicItems.ORB_MAGICIAN.get())).patternLine("csc").patternLine("cfc").patternLine("coc").addCriterion("has_magician_orb", hasItem(BloodMagicItems.MAGICIAN_BLOOD_ORB.get())).build(consumer, BloodMagic.rl("primitive_furnace_cell"));
|
||||
ShapedRecipeBuilder.shapedRecipe(BloodMagicItems.LAVA_CRYSTAL.get()).key('a', Tags.Items.GLASS).key('b', Items.LAVA_BUCKET).key('c', IngredientBloodOrb.fromOrb(BloodMagicItems.ORB_WEAK.get())).key('d', Tags.Items.OBSIDIAN).key('e', Tags.Items.GEMS_DIAMOND).patternLine("aba").patternLine("bcb").patternLine("ded").addCriterion("has_weak_orb", hasItem(BloodMagicItems.WEAK_BLOOD_ORB.get())).build(consumer, BloodMagic.rl("lava_crystal"));
|
||||
// ShapedRecipeBuilder.shapedRecipe(BloodMagicBlocks.SPEED_RUNE.get()).key('s', Items.GLASS).key('o', Ingredient.fromItems(Items.DIAMOND)).patternLine("sss").patternLine("sos").patternLine("sss").addCriterion("has_diamond", hasItem(Items.DIAMOND)).build(consumer, new ResourceLocation(BloodMagic.MODID, "speed_rune_from_standard"));
|
||||
// ShapedRecipeBuilder.shapedRecipe(BloodMagicBlocks.SPEED_RUNE.get()).key('s', Items.GLASS).key('o', IngredientBloodOrb.fromOrb(BloodMagicItems.ORB_WEAK.get())).patternLine("sss").patternLine("sos").patternLine("sss").addCriterion("has_diamond", hasItem(Items.DIAMOND)).build(consumer, new ResourceLocation(BloodMagic.MODID, "speed_rune_from_orb"));
|
||||
|
|
|
@ -5,10 +5,13 @@ import java.nio.file.Path;
|
|||
import net.minecraft.data.BlockTagsProvider;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.ItemTagsProvider;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.tags.ITag.INamedTag;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.common.item.BloodMagicItems;
|
||||
import wayoftime.bloodmagic.common.tags.BloodMagicTags;
|
||||
|
||||
public class GeneratorItemTags extends ItemTagsProvider
|
||||
|
@ -22,12 +25,22 @@ public class GeneratorItemTags extends ItemTagsProvider
|
|||
public void registerTags()
|
||||
{
|
||||
this.getOrCreateBuilder(BloodMagicTags.ARC_TOOL).add(Items.DIAMOND);
|
||||
this.registerTool(BloodMagicItems.AIR_INSCRIPTION_TOOL.get(), BloodMagicTags.ARC_TOOL_SIEVE);
|
||||
this.registerTool(BloodMagicItems.SANGUINE_REVERTER.get(), BloodMagicTags.ARC_TOOL_REVERTER);
|
||||
this.registerTool(BloodMagicItems.LAVA_CRYSTAL.get(), BloodMagicTags.ARC_TOOL_FURNACE);
|
||||
this.registerTool(BloodMagicItems.PRIMITIVE_FURNACE_CELL.get(), BloodMagicTags.ARC_TOOL_FURNACE);
|
||||
// this.getOrCreateBuilder(GOORESISTANT).addTag(BlockTags.DOORS);
|
||||
// this.getOrCreateBuilder(GOORESISTANT).addTag(BlockTags.BEDS);
|
||||
// this.getOrCreateBuilder(GOORESISTANT).add(Blocks.PISTON, Blocks.PISTON_HEAD, Blocks.STICKY_PISTON, Blocks.MOVING_PISTON);
|
||||
|
||||
}
|
||||
|
||||
public void registerTool(Item item, INamedTag<Item> tag)
|
||||
{
|
||||
this.getOrCreateBuilder(tag).add(item);
|
||||
this.getOrCreateBuilder(BloodMagicTags.ARC_TOOL).add(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves a Path for the location to save the given tag.
|
||||
*/
|
||||
|
|
|
@ -222,6 +222,11 @@ public class GeneratorLanguage extends LanguageProvider
|
|||
addItem(BloodMagicItems.BASE_RITUAL_DIVINER, "Ritual Diviner");
|
||||
addItem(BloodMagicItems.DUSK_RITUAL_DIVINER, "Ritual Diviner [Dusk]");
|
||||
|
||||
addItem(BloodMagicItems.WEAK_BLOOD_SHARD, "Weak Blood Shard");
|
||||
|
||||
addItem(BloodMagicItems.SANGUINE_REVERTER, "Sanguine Reverter");
|
||||
addItem(BloodMagicItems.PRIMITIVE_FURNACE_CELL, "Primitive Fuel Cell");
|
||||
|
||||
// addItem(BloodMagicItems , "");
|
||||
|
||||
// JEI
|
||||
|
|
|
@ -36,7 +36,7 @@ public class ARCRecipeBuilder extends BloodMagicRecipeBuilder<ARCRecipeBuilder>
|
|||
this.arcTool = arcTool;
|
||||
this.inputFluid = inputFluid;
|
||||
this.output = output;
|
||||
this.outputFluid = outputFluid;
|
||||
this.outputFluid = outputFluid == null ? FluidStack.EMPTY : outputFluid;
|
||||
}
|
||||
|
||||
public static ARCRecipeBuilder arc(Ingredient input, Ingredient arcTool, FluidStackIngredient inputFluid, ItemStack output, FluidStack outputFluid)
|
||||
|
@ -92,7 +92,7 @@ public class ARCRecipeBuilder extends BloodMagicRecipeBuilder<ARCRecipeBuilder>
|
|||
json.add(Constants.JSON.ADDEDOUTPUT, mainArray);
|
||||
}
|
||||
|
||||
if (outputFluid != null)
|
||||
if (outputFluid != null && !outputFluid.isEmpty())
|
||||
json.add(Constants.JSON.OUTPUT_FLUID, SerializerHelper.serializeFluidStack(outputFluid));
|
||||
|
||||
json.add(Constants.JSON.OUTPUT, SerializerHelper.serializeItemStack(output));
|
||||
|
|
|
@ -8,6 +8,7 @@ import net.minecraftforge.registries.DeferredRegister;
|
|||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
||||
import wayoftime.bloodmagic.common.item.arc.ItemARCToolBase;
|
||||
import wayoftime.bloodmagic.common.item.sigil.ItemSigilAir;
|
||||
import wayoftime.bloodmagic.common.item.sigil.ItemSigilBloodLight;
|
||||
import wayoftime.bloodmagic.common.item.sigil.ItemSigilDivination;
|
||||
|
@ -98,6 +99,7 @@ public class BloodMagicItems
|
|||
public static final RegistryObject<Item> ARCANE_ASHES = BASICITEMS.register("arcaneashes", () -> new ItemArcaneAshes());
|
||||
public static final RegistryObject<Item> DAGGER_OF_SACRIFICE = BASICITEMS.register("daggerofsacrifice", () -> new ItemDaggerOfSacrifice());
|
||||
public static final RegistryObject<Item> LAVA_CRYSTAL = BASICITEMS.register("lavacrystal", () -> new ItemLavaCrystal());
|
||||
public static final RegistryObject<Item> WEAK_BLOOD_SHARD = BASICITEMS.register("weakbloodshard", () -> new ItemBase());
|
||||
|
||||
// Ritual stuffs
|
||||
public static final RegistryObject<Item> WEAK_ACTIVATION_CRYSTAL = BASICITEMS.register("activationcrystalweak", () -> new ItemActivationCrystal(ItemActivationCrystal.CrystalType.WEAK));
|
||||
|
@ -136,4 +138,8 @@ public class BloodMagicItems
|
|||
|
||||
public static final RegistryObject<Item> SOUL_SNARE = BASICITEMS.register("soulsnare", ItemSoulSnare::new);
|
||||
public static final RegistryObject<Item> SENTIENT_SWORD = ITEMS.register("soulsword", () -> new ItemSentientSword());
|
||||
|
||||
// ARC Tools
|
||||
public static final RegistryObject<Item> SANGUINE_REVERTER = BASICITEMS.register("sanguinereverter", () -> new ItemARCToolBase(32, 2));
|
||||
public static final RegistryObject<Item> PRIMITIVE_FURNACE_CELL = BASICITEMS.register("furnacecell_primitive", () -> new ItemARCToolBase(128, 1.25));
|
||||
}
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
package wayoftime.bloodmagic.common.item;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IARCTool
|
||||
{
|
||||
|
||||
default double getCraftingSpeedMultiplier(ItemStack stack)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package wayoftime.bloodmagic.common.item.arc;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.common.item.IARCTool;
|
||||
|
||||
public class ItemARCToolBase extends Item implements IARCTool
|
||||
{
|
||||
private final double craftingMultiplier;
|
||||
|
||||
public ItemARCToolBase(int maxDamage, double craftingMultiplier)
|
||||
{
|
||||
super(new Item.Properties().maxStackSize(1).group(BloodMagic.TAB).maxDamage(maxDamage));
|
||||
this.craftingMultiplier = craftingMultiplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getCraftingSpeedMultiplier(ItemStack stack)
|
||||
{
|
||||
return craftingMultiplier;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
package wayoftime.bloodmagic.common.item.inventory;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
public class InventoryWrapper implements IInventory
|
||||
{
|
||||
protected int[] syncedSlots = new int[0];
|
||||
protected NonNullList<ItemStack> inventory;
|
||||
private int size;
|
||||
|
||||
public InventoryWrapper(int size)
|
||||
{
|
||||
this.inventory = NonNullList.withSize(size, ItemStack.EMPTY);
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear()
|
||||
{
|
||||
this.inventory = NonNullList.withSize(size, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
for (ItemStack stack : inventory) if (!stack.isEmpty())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int index)
|
||||
{
|
||||
return inventory.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int index, int count)
|
||||
{
|
||||
if (!getStackInSlot(index).isEmpty())
|
||||
{
|
||||
if (getStackInSlot(index).getCount() <= count)
|
||||
{
|
||||
ItemStack itemStack = inventory.get(index);
|
||||
inventory.set(index, ItemStack.EMPTY);
|
||||
markDirty();
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
ItemStack itemStack = inventory.get(index).split(count);
|
||||
markDirty();
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack removeStackFromSlot(int slot)
|
||||
{
|
||||
if (!inventory.get(slot).isEmpty())
|
||||
{
|
||||
ItemStack itemStack = inventory.get(slot);
|
||||
setInventorySlotContents(slot, ItemStack.EMPTY);
|
||||
return itemStack;
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack)
|
||||
{
|
||||
inventory.set(slot, stack);
|
||||
if (!stack.isEmpty() && stack.getCount() > getInventoryStackLimit())
|
||||
stack.setCount(getInventoryStackLimit());
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUsableByPlayer(PlayerEntity player)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package wayoftime.bloodmagic.common.item.sigil;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.IGrowable;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -64,7 +65,7 @@ public class ItemSigilGreenGrove extends ItemSigilToggleableBase
|
|||
|
||||
// if (!BloodMagicAPI.INSTANCE.getBlacklist().getGreenGrove().contains(state))
|
||||
{
|
||||
if (state.getBlock() instanceof IGrowable)
|
||||
if (state.getBlock() instanceof IGrowable && state.getBlock() != Blocks.GRASS_BLOCK)
|
||||
{
|
||||
if (worldIn.rand.nextInt(50) == 0)
|
||||
{
|
||||
|
|
|
@ -3,16 +3,12 @@ package wayoftime.bloodmagic.common.recipe;
|
|||
import java.util.function.Consumer;
|
||||
|
||||
import net.minecraft.data.IFinishedRecipe;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraftforge.common.Tags;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.api.event.recipes.FluidStackIngredient;
|
||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
||||
import wayoftime.bloodmagic.common.data.recipe.builder.ARCRecipeBuilder;
|
||||
import wayoftime.bloodmagic.common.item.BloodMagicItems;
|
||||
import wayoftime.bloodmagic.common.tags.BloodMagicTags;
|
||||
|
||||
public class ARCRecipeProvider implements ISubRecipeProvider
|
||||
{
|
||||
|
@ -20,7 +16,12 @@ public class ARCRecipeProvider implements ISubRecipeProvider
|
|||
public void addRecipes(Consumer<IFinishedRecipe> consumer)
|
||||
{
|
||||
String basePath = "arc/";
|
||||
ARCRecipeBuilder.arc(Ingredient.fromTag(Tags.Items.GEMS_DIAMOND), Ingredient.fromTag(Tags.Items.BONES), null, new ItemStack(BloodMagicBlocks.BLOOD_ALTAR.get()), null).addRandomOutput(new ItemStack(Items.DIAMOND), 0.5).build(consumer, BloodMagic.rl(basePath + "test1"));
|
||||
ARCRecipeBuilder.arc(Ingredient.fromTag(Tags.Items.GEMS_DIAMOND), Ingredient.fromItems(Items.ACACIA_BOAT), FluidStackIngredient.from(Fluids.LAVA, 1000), new ItemStack(BloodMagicBlocks.BLOOD_ALTAR.get()), new FluidStack(Fluids.WATER, 100)).build(consumer, BloodMagic.rl(basePath + "test2"));
|
||||
// ARCRecipeBuilder.arc(Ingredient.fromTag(Tags.Items.GEMS_DIAMOND), Ingredient.fromTag(Tags.Items.BONES), null, new ItemStack(BloodMagicBlocks.BLOOD_ALTAR.get()), null).addRandomOutput(new ItemStack(Items.DIAMOND, 2), 0.5).build(consumer, BloodMagic.rl(basePath + "test1"));
|
||||
// ARCRecipeBuilder.arc(Ingredient.fromTag(Tags.Items.GEMS_DIAMOND), Ingredient.fromTag(Tags.Items.BONES), null, new ItemStack(BloodMagicBlocks.BLOOD_ALTAR.get()), null).addRandomOutput(new ItemStack(Items.DIAMOND, 5), 0.5).build(consumer, BloodMagic.rl(basePath + "test3"));
|
||||
// ARCRecipeBuilder.arc(Ingredient.fromTag(Tags.Items.GEMS_DIAMOND), Ingredient.fromItems(Items.ACACIA_BOAT), FluidStackIngredient.from(Fluids.LAVA, 1000), new ItemStack(BloodMagicBlocks.BLOOD_ALTAR.get()), new FluidStack(Fluids.WATER, 100)).build(consumer, BloodMagic.rl(basePath + "test2"));
|
||||
// ARCRecipeBuilder.arc(Ingredient.fromTag(Tags.Items.NETHERRACK), Ingredient.fromTag(BloodMagicTags.ARC_TOOL_REVERTER), FluidStackIngredient.from(Fluids.LAVA, 1000), new ItemStack(BloodMagicBlocks.BLOOD_ALTAR.get()), new FluidStack(Fluids.WATER, 100)).addRandomOutput(new ItemStack(BloodMagicItems.SLATE.get()), 0.2).addRandomOutput(new ItemStack(BloodMagicItems.REINFORCED_SLATE.get()), 0.1).addRandomOutput(new ItemStack(BloodMagicItems.IMBUED_SLATE.get()), 0.001).build(consumer, BloodMagic.rl(basePath + "test4"));
|
||||
|
||||
ARCRecipeBuilder.arc(Ingredient.fromItems(BloodMagicItems.IMBUED_SLATE.get()), Ingredient.fromTag(BloodMagicTags.ARC_TOOL_REVERTER), null, new ItemStack(BloodMagicItems.WEAK_BLOOD_SHARD.get()), null).addRandomOutput(new ItemStack(BloodMagicItems.WEAK_BLOOD_SHARD.get()), 0.2).build(consumer, BloodMagic.rl(basePath + "weakbloodshard"));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,8 @@ public class TartaricForgeRecipeProvider implements ISubRecipeProvider
|
|||
TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.REAGENT_GROWTH.get()), 128, 20, Ingredient.fromTag(ItemTags.SAPLINGS), Ingredient.fromTag(ItemTags.SAPLINGS), Ingredient.fromItems(Items.SUGAR_CANE), Ingredient.fromItems(Items.SUGAR)).build(consumer, BloodMagic.rl(basePath + "reagent_growth"));
|
||||
TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.REAGENT_MAGNETISM.get()), 600, 10, Ingredient.fromTag(Tags.Items.STRING), Ingredient.fromTag(Tags.Items.INGOTS_GOLD), Ingredient.fromTag(Tags.Items.INGOTS_GOLD), Ingredient.fromTag(Tags.Items.STORAGE_BLOCKS_IRON)).build(consumer, BloodMagic.rl(basePath + "reagent_magnetism"));
|
||||
TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.REAGENT_FAST_MINER.get()), 128, 20, Ingredient.fromItems(Items.IRON_PICKAXE), Ingredient.fromItems(Items.IRON_AXE), Ingredient.fromItems(Items.IRON_SHOVEL), Ingredient.fromTag(Tags.Items.GUNPOWDER)).build(consumer, BloodMagic.rl(basePath + "reagent_fastminer"));
|
||||
|
||||
TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.SANGUINE_REVERTER.get()), 350, 30, Ingredient.fromItems(Items.SHEARS), Ingredient.fromTag(Tags.Items.STONE), Ingredient.fromItems(BloodMagicItems.IMBUED_SLATE.get()), Ingredient.fromTag(Tags.Items.INGOTS_IRON)).build(consumer, BloodMagic.rl(basePath + "sanguine_reverter"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -84,14 +84,15 @@ public class ARCRecipeSerializer<RECIPE extends RecipeARC> extends ForgeRegistry
|
|||
inputFluidIng = FluidStackIngredient.deserialize(inputFluid);
|
||||
}
|
||||
|
||||
FluidStack outputFluid = null;
|
||||
FluidStack outputFluidStack = FluidStack.EMPTY;
|
||||
|
||||
if (json.has(Constants.JSON.OUTPUT_FLUID))
|
||||
{
|
||||
outputFluid = SerializerHelper.deserializeFluid(json);
|
||||
JsonObject outputFluid = JSONUtils.getJsonObject(json, Constants.JSON.OUTPUT_FLUID).getAsJsonObject();
|
||||
outputFluidStack = SerializerHelper.deserializeFluid(outputFluid);
|
||||
}
|
||||
|
||||
return this.factory.create(recipeId, inputIng, toolIng, inputFluidIng, output, addedItems, outputFluid);
|
||||
return this.factory.create(recipeId, inputIng, toolIng, inputFluidIng, output, addedItems, outputFluidStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -9,4 +9,5 @@ public class BloodMagicTags
|
|||
public static final ITag.INamedTag<Item> ARC_TOOL = ItemTags.makeWrapperTag("bloodmagic:arc_tool");
|
||||
public static final ITag.INamedTag<Item> ARC_TOOL_FURNACE = ItemTags.makeWrapperTag("bloodmagic:arc_tool_furnace");
|
||||
public static final ITag.INamedTag<Item> ARC_TOOL_SIEVE = ItemTags.makeWrapperTag("bloodmagic:arc_tool_sieve");
|
||||
public static final ITag.INamedTag<Item> ARC_TOOL_REVERTER = ItemTags.makeWrapperTag("bloodmagic:arc_tool_reverter");
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@ package wayoftime.bloodmagic.compat.jei;
|
|||
|
||||
import java.util.Objects;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import mezz.jei.api.IModPlugin;
|
||||
import mezz.jei.api.JeiPlugin;
|
||||
import mezz.jei.api.helpers.IJeiHelpers;
|
||||
|
@ -11,12 +13,15 @@ import mezz.jei.api.registration.IRecipeRegistration;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipeType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.api.impl.BloodMagicAPI;
|
||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
||||
import wayoftime.bloodmagic.common.item.BloodMagicItems;
|
||||
import wayoftime.bloodmagic.compat.jei.altar.BloodAltarRecipeCategory;
|
||||
import wayoftime.bloodmagic.compat.jei.arc.ARCFurnaceRecipeCategory;
|
||||
import wayoftime.bloodmagic.compat.jei.arc.ARCRecipeCategory;
|
||||
import wayoftime.bloodmagic.compat.jei.array.AlchemyArrayCraftingCategory;
|
||||
import wayoftime.bloodmagic.compat.jei.forge.TartaricForgeRecipeCategory;
|
||||
|
||||
|
@ -33,6 +38,8 @@ public class BloodMagicJEIPlugin implements IModPlugin
|
|||
registration.addRecipeCatalyst(new ItemStack(BloodMagicBlocks.SOUL_FORGE.get()), TartaricForgeRecipeCategory.UID);
|
||||
registration.addRecipeCatalyst(new ItemStack(BloodMagicBlocks.BLOOD_ALTAR.get()), BloodAltarRecipeCategory.UID);
|
||||
registration.addRecipeCatalyst(new ItemStack(BloodMagicItems.ARCANE_ASHES.get()), AlchemyArrayCraftingCategory.UID);
|
||||
registration.addRecipeCatalyst(new ItemStack(BloodMagicBlocks.ALCHEMICAL_REACTION_CHAMBER.get()), ARCRecipeCategory.UID);
|
||||
registration.addRecipeCatalyst(new ItemStack(BloodMagicBlocks.ALCHEMICAL_REACTION_CHAMBER.get()), ARCFurnaceRecipeCategory.UID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -42,6 +49,8 @@ public class BloodMagicJEIPlugin implements IModPlugin
|
|||
registration.addRecipeCategories(new TartaricForgeRecipeCategory(registration.getJeiHelpers().getGuiHelper()));
|
||||
registration.addRecipeCategories(new BloodAltarRecipeCategory(registration.getJeiHelpers().getGuiHelper()));
|
||||
registration.addRecipeCategories(new AlchemyArrayCraftingCategory(registration.getJeiHelpers().getGuiHelper()));
|
||||
registration.addRecipeCategories(new ARCRecipeCategory(registration.getJeiHelpers().getGuiHelper()));
|
||||
registration.addRecipeCategories(new ARCFurnaceRecipeCategory(registration.getJeiHelpers().getGuiHelper()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -51,6 +60,8 @@ public class BloodMagicJEIPlugin implements IModPlugin
|
|||
registration.addRecipes(BloodMagicAPI.INSTANCE.getRecipeRegistrar().getTartaricForgeRecipes(world), TartaricForgeRecipeCategory.UID);
|
||||
registration.addRecipes(BloodMagicAPI.INSTANCE.getRecipeRegistrar().getAltarRecipes(world), BloodAltarRecipeCategory.UID);
|
||||
registration.addRecipes(BloodMagicAPI.INSTANCE.getRecipeRegistrar().getAlchemyArrayRecipes(world), AlchemyArrayCraftingCategory.UID);
|
||||
registration.addRecipes(BloodMagicAPI.INSTANCE.getRecipeRegistrar().getARCRecipes(world), ARCRecipeCategory.UID);
|
||||
registration.addRecipes(ImmutableSet.copyOf(world.getRecipeManager().getRecipesForType(IRecipeType.SMELTING)), ARCFurnaceRecipeCategory.UID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,114 @@
|
|||
package wayoftime.bloodmagic.compat.jei.arc;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
import mezz.jei.api.constants.VanillaTypes;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.gui.drawable.IDrawable;
|
||||
import mezz.jei.api.gui.ingredient.IGuiItemStackGroup;
|
||||
import mezz.jei.api.helpers.IGuiHelper;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.category.IRecipeCategory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.FurnaceRecipe;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
||||
import wayoftime.bloodmagic.common.tags.BloodMagicTags;
|
||||
import wayoftime.bloodmagic.util.Constants;
|
||||
import wayoftime.bloodmagic.util.handler.event.ClientHandler;
|
||||
import wayoftime.bloodmagic.util.helper.TextHelper;
|
||||
|
||||
public class ARCFurnaceRecipeCategory implements IRecipeCategory<FurnaceRecipe>
|
||||
{
|
||||
private static final int OUTPUT_SLOT = 0;
|
||||
private static final int INPUT_SLOT = 1;
|
||||
private static final int CATALYST_SLOT = 2;
|
||||
public static final ResourceLocation UID = BloodMagic.rl(Constants.Compat.JEI_CATEGORY_ARC + "furnace");
|
||||
public static final ResourceLocation BACKGROUNDRL = BloodMagic.rl("gui/jei/arc.png");
|
||||
|
||||
@Nonnull
|
||||
private final IDrawable background;
|
||||
private final IDrawable icon;
|
||||
// @Nonnull
|
||||
// private final ICraftingGridHelper craftingGridHelper;
|
||||
|
||||
public ARCFurnaceRecipeCategory(IGuiHelper guiHelper)
|
||||
{
|
||||
icon = guiHelper.createDrawableIngredient(new ItemStack(BloodMagicBlocks.ALCHEMICAL_REACTION_CHAMBER.get()));
|
||||
background = guiHelper.createDrawable(BACKGROUNDRL, 0, 0, 157, 43);
|
||||
// craftingGridHelper = guiHelper.createCraftingGridHelper(INPUT_SLOT);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ResourceLocation getUid()
|
||||
{
|
||||
return UID;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return TextHelper.localize("jei.bloodmagic.recipe.arcfurnace");
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IDrawable getBackground()
|
||||
{
|
||||
return background;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IDrawable getIcon()
|
||||
{
|
||||
return icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull FurnaceRecipe recipe, @Nonnull IIngredients ingredients)
|
||||
{
|
||||
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
|
||||
|
||||
recipeLayout.getItemStacks().init(OUTPUT_SLOT, false, 53, 16);
|
||||
recipeLayout.getItemStacks().init(INPUT_SLOT, true, 0, 5);
|
||||
recipeLayout.getItemStacks().init(CATALYST_SLOT, true, 21, 16);
|
||||
|
||||
guiItemStacks.set(ingredients);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends FurnaceRecipe> getRecipeClass()
|
||||
{
|
||||
return FurnaceRecipe.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIngredients(FurnaceRecipe recipe, IIngredients ingredients)
|
||||
{
|
||||
List<Ingredient> inputIngList = recipe.getIngredients();
|
||||
inputIngList.add(Ingredient.fromTag(BloodMagicTags.ARC_TOOL_FURNACE));
|
||||
ingredients.setInputIngredients(inputIngList);
|
||||
ingredients.setOutput(VanillaTypes.ITEM, recipe.getRecipeOutput());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(FurnaceRecipe recipe, MatrixStack matrixStack, double mouseX, double mouseY)
|
||||
{
|
||||
FluidStack outputStack = FluidStack.EMPTY;
|
||||
ClientHandler.handleGuiTank(matrixStack, outputStack, outputStack.getAmount(), 140, 7, 16, 36, 157, 6, 18, 38, (int) mouseX, (int) mouseY, BACKGROUNDRL.toString(), null);
|
||||
|
||||
FluidStack inputStack = FluidStack.EMPTY;
|
||||
ClientHandler.handleGuiTank(matrixStack, inputStack, inputStack.getAmount(), 1, 26, 16, 16, 175, 26, 18, 18, (int) mouseX, (int) mouseY, BACKGROUNDRL.toString(), null);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,172 @@
|
|||
package wayoftime.bloodmagic.compat.jei.arc;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
import mezz.jei.api.constants.VanillaTypes;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.gui.drawable.IDrawable;
|
||||
import mezz.jei.api.gui.ingredient.IGuiItemStackGroup;
|
||||
import mezz.jei.api.helpers.IGuiHelper;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.category.IRecipeCategory;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.api.impl.recipe.RecipeARC;
|
||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
||||
import wayoftime.bloodmagic.util.Constants;
|
||||
import wayoftime.bloodmagic.util.handler.event.ClientHandler;
|
||||
import wayoftime.bloodmagic.util.helper.TextHelper;
|
||||
|
||||
public class ARCRecipeCategory implements IRecipeCategory<RecipeARC>
|
||||
{
|
||||
private static final int OUTPUT_SLOT = 0;
|
||||
private static final int INPUT_SLOT = 4;
|
||||
private static final int CATALYST_SLOT = 5;
|
||||
public static final ResourceLocation UID = BloodMagic.rl(Constants.Compat.JEI_CATEGORY_ARC);
|
||||
public static final ResourceLocation BACKGROUNDRL = BloodMagic.rl("gui/jei/arc.png");
|
||||
|
||||
@Nonnull
|
||||
private final IDrawable background;
|
||||
private final IDrawable icon;
|
||||
// @Nonnull
|
||||
// private final ICraftingGridHelper craftingGridHelper;
|
||||
|
||||
public ARCRecipeCategory(IGuiHelper guiHelper)
|
||||
{
|
||||
icon = guiHelper.createDrawableIngredient(new ItemStack(BloodMagicBlocks.ALCHEMICAL_REACTION_CHAMBER.get()));
|
||||
background = guiHelper.createDrawable(BACKGROUNDRL, 0, 0, 157, 43);
|
||||
// craftingGridHelper = guiHelper.createCraftingGridHelper(INPUT_SLOT);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ResourceLocation getUid()
|
||||
{
|
||||
return UID;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return TextHelper.localize("jei.bloodmagic.recipe.arc");
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IDrawable getBackground()
|
||||
{
|
||||
return background;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IDrawable getIcon()
|
||||
{
|
||||
return icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull RecipeARC recipe, @Nonnull IIngredients ingredients)
|
||||
{
|
||||
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
|
||||
|
||||
recipeLayout.getItemStacks().init(OUTPUT_SLOT, false, 53, 16);
|
||||
recipeLayout.getItemStacks().init(OUTPUT_SLOT + 1, false, 53 + 22 * 1, 16);
|
||||
recipeLayout.getItemStacks().init(OUTPUT_SLOT + 2, false, 53 + 22 * 2, 16);
|
||||
recipeLayout.getItemStacks().init(OUTPUT_SLOT + 3, false, 53 + 22 * 3, 16);
|
||||
recipeLayout.getItemStacks().init(INPUT_SLOT, true, 0, 5);
|
||||
recipeLayout.getItemStacks().init(CATALYST_SLOT, true, 21, 16);
|
||||
|
||||
guiItemStacks.set(ingredients);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends RecipeARC> getRecipeClass()
|
||||
{
|
||||
return RecipeARC.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIngredients(RecipeARC recipe, IIngredients ingredients)
|
||||
{
|
||||
ingredients.setInputIngredients(recipe.getIngredients());
|
||||
ingredients.setOutputs(VanillaTypes.ITEM, recipe.getAllListedOutputs());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(RecipeARC recipe, MatrixStack matrixStack, double mouseX, double mouseY)
|
||||
{
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
double[] chanceArray = recipe.getAllOutputChances();
|
||||
|
||||
String[] infoString = new String[chanceArray.length];
|
||||
for (int i = 0; i < infoString.length; i++)
|
||||
{
|
||||
if (chanceArray[i] >= 1)
|
||||
{
|
||||
infoString[i] = "";
|
||||
} else if (chanceArray[i] < 0.01)
|
||||
{
|
||||
infoString[i] = "<1%";
|
||||
} else
|
||||
{
|
||||
infoString[i] = "" + (int) (chanceArray[i] * 100) + "%";
|
||||
}
|
||||
|
||||
mc.fontRenderer.drawStringWithShadow(matrixStack, infoString[i], 86 + 22 * i
|
||||
- mc.fontRenderer.getStringWidth(infoString[i]) / 2, 5, Color.white.getRGB());
|
||||
}
|
||||
|
||||
// if (recipe.getFluidOutput() != null && !recipe.getFluidOutput().isEmpty())
|
||||
{
|
||||
FluidStack outputStack = recipe.getFluidOutput();
|
||||
ClientHandler.handleGuiTank(matrixStack, outputStack, outputStack.getAmount(), 140, 7, 16, 36, 157, 6, 18, 38, (int) mouseX, (int) mouseY, BACKGROUNDRL.toString(), null);
|
||||
}
|
||||
|
||||
if (recipe.getFluidIngredient() != null)
|
||||
{
|
||||
List<FluidStack> inputFluids = recipe.getFluidIngredient().getRepresentations();
|
||||
FluidStack inputStack = inputFluids.get(0);
|
||||
ClientHandler.handleGuiTank(matrixStack, inputStack, inputStack.getAmount(), 1, 26, 16, 16, 175, 26, 18, 18, (int) mouseX, (int) mouseY, BACKGROUNDRL.toString(), null);
|
||||
}
|
||||
|
||||
// { TextHelper.localize("jei.bloodmagic.recipe.requiredtier", NumeralHelper.toRoman(recipe.getMinimumTier().toInt())),
|
||||
// TextHelper.localize("jei.bloodmagic.recipe.requiredlp", recipe.getSyphon()) };
|
||||
// mc.fontRenderer.drawString(matrixStack, infoString[0], 90
|
||||
// - mc.fontRenderer.getStringWidth(infoString[0]) / 2, 0, Color.gray.getRGB());
|
||||
// mc.fontRenderer.drawString(matrixStack, infoString[1], 90
|
||||
// - mc.fontRenderer.getStringWidth(infoString[1]) / 2, 10, Color.gray.getRGB());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ITextComponent> getTooltipStrings(RecipeARC recipe, double mouseX, double mouseY)
|
||||
{
|
||||
List<ITextComponent> tooltip = new ArrayList<>();
|
||||
FluidStack outputStack = recipe.getFluidOutput();
|
||||
if (!outputStack.isEmpty())
|
||||
{
|
||||
ClientHandler.handleGuiTank(null, outputStack, -1, 140, 8, 16, 34, 157, 7, 18, 36, (int) mouseX, (int) mouseY, BACKGROUNDRL.toString(), tooltip);
|
||||
}
|
||||
|
||||
if (recipe.getFluidIngredient() != null)
|
||||
{
|
||||
List<FluidStack> inputFluids = recipe.getFluidIngredient().getRepresentations();
|
||||
FluidStack inputStack = inputFluids.get(0);
|
||||
ClientHandler.handleGuiTank(null, inputStack, -1, 1, 26, 16, 16, 175, 26, 18, 18, (int) mouseX, (int) mouseY, BACKGROUNDRL.toString(), tooltip);
|
||||
}
|
||||
|
||||
return tooltip;
|
||||
}
|
||||
}
|
|
@ -2,13 +2,15 @@ package wayoftime.bloodmagic.tile;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.INamedContainerProvider;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.FurnaceRecipe;
|
||||
import net.minecraft.item.crafting.IRecipeType;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.ITickableTileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
|
@ -23,8 +25,12 @@ import net.minecraftforge.fluids.capability.IFluidHandlerItem;
|
|||
import net.minecraftforge.fluids.capability.templates.FluidTank;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import wayoftime.bloodmagic.api.event.recipes.FluidStackIngredient;
|
||||
import wayoftime.bloodmagic.api.impl.BloodMagicAPI;
|
||||
import wayoftime.bloodmagic.api.impl.recipe.RecipeARC;
|
||||
import wayoftime.bloodmagic.common.item.IARCTool;
|
||||
import wayoftime.bloodmagic.common.item.inventory.InventoryWrapper;
|
||||
import wayoftime.bloodmagic.common.tags.BloodMagicTags;
|
||||
import wayoftime.bloodmagic.tile.contailer.ContainerAlchemicalReactionChamber;
|
||||
import wayoftime.bloodmagic.util.Constants;
|
||||
import wayoftime.bloodmagic.util.MultiSlotItemHandler;
|
||||
|
@ -45,6 +51,7 @@ public class TileAlchemicalReactionChamber extends TileInventory implements ITic
|
|||
public FluidTank outputTank = new FluidTank(FluidAttributes.BUCKET_VOLUME * 20);
|
||||
|
||||
public double currentProgress = 0;
|
||||
public static final double DEFAULT_SPEED = 0.005;
|
||||
|
||||
public TileAlchemicalReactionChamber(TileEntityType<?> type)
|
||||
{
|
||||
|
@ -91,15 +98,17 @@ public class TileAlchemicalReactionChamber extends TileInventory implements ITic
|
|||
@Override
|
||||
public void tick()
|
||||
{
|
||||
if (world.isRemote)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// if (world.isRemote)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (world.getGameTime() % 20 == 0)
|
||||
{
|
||||
outputTank.fill(new FluidStack(Fluids.WATER, 100), FluidAction.EXECUTE);
|
||||
}
|
||||
// if (world.getGameTime() % 20 == 0)
|
||||
// {
|
||||
// outputTank.fill(new FluidStack(Fluids.WATER, 100), FluidAction.EXECUTE);
|
||||
// }
|
||||
|
||||
boolean outputChanged = false;
|
||||
|
||||
ItemStack fullBucketStack = this.getStackInSlot(INPUT_BUCKET_SLOT);
|
||||
ItemStack emptyBucketStack = this.getStackInSlot(OUTPUT_BUCKET_SLOT);
|
||||
|
@ -109,58 +118,63 @@ public class TileAlchemicalReactionChamber extends TileInventory implements ITic
|
|||
|
||||
MultiSlotItemHandler outputSlotHandler = new MultiSlotItemHandler(outputInventory, 64);
|
||||
|
||||
if (!fullBucketStack.isEmpty() && inputTank.getSpace() >= 1000)
|
||||
if (!world.isRemote)
|
||||
{
|
||||
ItemStack testFullBucketStack = ItemHandlerHelper.copyStackWithSize(fullBucketStack, 1);
|
||||
LazyOptional<IFluidHandlerItem> fluidHandlerWrapper = FluidUtil.getFluidHandler(testFullBucketStack);
|
||||
if (fluidHandlerWrapper.isPresent())
|
||||
if (!fullBucketStack.isEmpty() && inputTank.getSpace() >= 1000)
|
||||
{
|
||||
IFluidHandlerItem fluidHandler = fluidHandlerWrapper.resolve().get();
|
||||
FluidStack transferedStack = FluidUtil.tryFluidTransfer(inputTank, fluidHandler, 1000, false);
|
||||
if (!transferedStack.isEmpty())
|
||||
ItemStack testFullBucketStack = ItemHandlerHelper.copyStackWithSize(fullBucketStack, 1);
|
||||
LazyOptional<IFluidHandlerItem> fluidHandlerWrapper = FluidUtil.getFluidHandler(testFullBucketStack);
|
||||
if (fluidHandlerWrapper.isPresent())
|
||||
{
|
||||
fluidHandler.drain(transferedStack, FluidAction.EXECUTE);
|
||||
List<ItemStack> arrayList = new ArrayList<>();
|
||||
arrayList.add(fluidHandler.getContainer());
|
||||
if (outputSlotHandler.canTransferAllItemsToSlots(arrayList, true))
|
||||
IFluidHandlerItem fluidHandler = fluidHandlerWrapper.resolve().get();
|
||||
FluidStack transferedStack = FluidUtil.tryFluidTransfer(inputTank, fluidHandler, 1000, false);
|
||||
if (!transferedStack.isEmpty())
|
||||
{
|
||||
inputTank.fill(transferedStack, FluidAction.EXECUTE);
|
||||
outputSlotHandler.canTransferAllItemsToSlots(arrayList, false);
|
||||
if (fullBucketStack.getCount() > 1)
|
||||
fluidHandler.drain(transferedStack, FluidAction.EXECUTE);
|
||||
List<ItemStack> arrayList = new ArrayList<>();
|
||||
arrayList.add(fluidHandler.getContainer());
|
||||
if (outputSlotHandler.canTransferAllItemsToSlots(arrayList, true))
|
||||
{
|
||||
fullBucketStack.setCount(fullBucketStack.getCount() - 1);
|
||||
} else
|
||||
{
|
||||
setInventorySlotContents(INPUT_BUCKET_SLOT, ItemStack.EMPTY);
|
||||
outputChanged = true;
|
||||
inputTank.fill(transferedStack, FluidAction.EXECUTE);
|
||||
outputSlotHandler.canTransferAllItemsToSlots(arrayList, false);
|
||||
if (fullBucketStack.getCount() > 1)
|
||||
{
|
||||
fullBucketStack.setCount(fullBucketStack.getCount() - 1);
|
||||
} else
|
||||
{
|
||||
setInventorySlotContents(INPUT_BUCKET_SLOT, ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!emptyBucketStack.isEmpty() && outputTank.getFluidAmount() >= 1000)
|
||||
{
|
||||
ItemStack testEmptyBucketStack = ItemHandlerHelper.copyStackWithSize(emptyBucketStack, 1);
|
||||
LazyOptional<IFluidHandlerItem> fluidHandlerWrapper = FluidUtil.getFluidHandler(testEmptyBucketStack);
|
||||
if (fluidHandlerWrapper.isPresent())
|
||||
if (!emptyBucketStack.isEmpty() && outputTank.getFluidAmount() >= 1000)
|
||||
{
|
||||
IFluidHandlerItem fluidHandler = fluidHandlerWrapper.resolve().get();
|
||||
FluidStack transferedStack = FluidUtil.tryFluidTransfer(fluidHandler, outputTank, 1000, false);
|
||||
if (!transferedStack.isEmpty())
|
||||
ItemStack testEmptyBucketStack = ItemHandlerHelper.copyStackWithSize(emptyBucketStack, 1);
|
||||
LazyOptional<IFluidHandlerItem> fluidHandlerWrapper = FluidUtil.getFluidHandler(testEmptyBucketStack);
|
||||
if (fluidHandlerWrapper.isPresent())
|
||||
{
|
||||
fluidHandler.fill(transferedStack, FluidAction.EXECUTE);
|
||||
List<ItemStack> arrayList = new ArrayList<>();
|
||||
arrayList.add(fluidHandler.getContainer());
|
||||
if (outputSlotHandler.canTransferAllItemsToSlots(arrayList, true))
|
||||
IFluidHandlerItem fluidHandler = fluidHandlerWrapper.resolve().get();
|
||||
FluidStack transferedStack = FluidUtil.tryFluidTransfer(fluidHandler, outputTank, 1000, false);
|
||||
if (!transferedStack.isEmpty())
|
||||
{
|
||||
outputTank.drain(transferedStack, FluidAction.EXECUTE);
|
||||
outputSlotHandler.canTransferAllItemsToSlots(arrayList, false);
|
||||
if (emptyBucketStack.getCount() > 1)
|
||||
fluidHandler.fill(transferedStack, FluidAction.EXECUTE);
|
||||
List<ItemStack> arrayList = new ArrayList<>();
|
||||
arrayList.add(fluidHandler.getContainer());
|
||||
if (outputSlotHandler.canTransferAllItemsToSlots(arrayList, true))
|
||||
{
|
||||
emptyBucketStack.setCount(emptyBucketStack.getCount() - 1);
|
||||
} else
|
||||
{
|
||||
setInventorySlotContents(OUTPUT_BUCKET_SLOT, ItemStack.EMPTY);
|
||||
outputChanged = true;
|
||||
outputTank.drain(transferedStack, FluidAction.EXECUTE);
|
||||
outputSlotHandler.canTransferAllItemsToSlots(arrayList, false);
|
||||
if (emptyBucketStack.getCount() > 1)
|
||||
{
|
||||
emptyBucketStack.setCount(emptyBucketStack.getCount() - 1);
|
||||
} else
|
||||
{
|
||||
setInventorySlotContents(OUTPUT_BUCKET_SLOT, ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -169,16 +183,72 @@ public class TileAlchemicalReactionChamber extends TileInventory implements ITic
|
|||
|
||||
ItemStack inputStack = this.getStackInSlot(INPUT_SLOT);
|
||||
ItemStack toolStack = this.getStackInSlot(ARC_TOOL_SLOT);
|
||||
RecipeARC recipe = BloodMagicAPI.INSTANCE.getRecipeRegistrar().getARC(world, inputStack, toolStack, inputTank.getFluid());
|
||||
if (recipe != null && outputSlotHandler.canTransferAllItemsToSlots(recipe.getAllListedOutputs(), true))
|
||||
{
|
||||
// We have enough fluid (if applicable) and the theoretical outputs can fit.
|
||||
|
||||
double craftingMultiplier = 1;
|
||||
if (toolStack.getItem() instanceof IARCTool)
|
||||
{
|
||||
craftingMultiplier = ((IARCTool) toolStack.getItem()).getCraftingSpeedMultiplier(toolStack);
|
||||
}
|
||||
|
||||
for (int i = 0; i < NUM_OUTPUTS; i++)
|
||||
RecipeARC recipe = BloodMagicAPI.INSTANCE.getRecipeRegistrar().getARC(world, inputStack, toolStack, inputTank.getFluid());
|
||||
if (canCraft(recipe, outputSlotHandler))
|
||||
{
|
||||
this.setInventorySlotContents(OUTPUT_SLOT + i, outputSlotHandler.getStackInSlot(i));
|
||||
// We have enough fluid (if applicable) and the theoretical outputs can fit.
|
||||
currentProgress += craftingMultiplier * DEFAULT_SPEED;
|
||||
if (currentProgress >= 1)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
outputChanged = true;
|
||||
craftItem(recipe, outputSlotHandler);
|
||||
}
|
||||
|
||||
currentProgress = 0;
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (toolStack.getItem().isIn(BloodMagicTags.ARC_TOOL_FURNACE))
|
||||
{
|
||||
InventoryWrapper invWrapper = new InventoryWrapper(1);
|
||||
invWrapper.setInventorySlotContents(0, inputStack.copy());
|
||||
// ItemStack[] outputInventory = new ItemStack[]
|
||||
// { input };
|
||||
|
||||
// MultiSlotItemHandler outputSlotHandler = new MultiSlotItemHandler(outputInventory, 64);
|
||||
Optional<FurnaceRecipe> furnaceRecipe = world.getRecipeManager().getRecipe(IRecipeType.SMELTING, invWrapper, world);
|
||||
if (furnaceRecipe.isPresent())
|
||||
{
|
||||
ItemStack outputStack = furnaceRecipe.get().getCraftingResult(invWrapper);
|
||||
if (canCraftFurnace(outputStack, outputSlotHandler))
|
||||
{
|
||||
currentProgress += craftingMultiplier * DEFAULT_SPEED;
|
||||
if (currentProgress >= 1)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
craftFurnace(outputStack, outputSlotHandler);
|
||||
outputChanged = true;
|
||||
}
|
||||
|
||||
currentProgress = 0;
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
currentProgress = 0;
|
||||
}
|
||||
} else
|
||||
{
|
||||
currentProgress = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (outputChanged && !world.isRemote)
|
||||
{
|
||||
for (int i = 0; i < NUM_OUTPUTS; i++)
|
||||
{
|
||||
this.setInventorySlotContents(OUTPUT_SLOT + i, outputSlotHandler.getStackInSlot(i));
|
||||
}
|
||||
}
|
||||
|
||||
// FluidUtil.tryEmptyContainer(container, fluidDestination, maxAmount, player, doDrain)
|
||||
|
@ -189,6 +259,12 @@ public class TileAlchemicalReactionChamber extends TileInventory implements ITic
|
|||
if (recipe == null)
|
||||
return false;
|
||||
|
||||
FluidStackIngredient inputFluidIngredient = recipe.getFluidIngredient();
|
||||
if (inputFluidIngredient != null && !inputFluidIngredient.test(inputTank.getFluid()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (outputSlotHandler.canTransferAllItemsToSlots(recipe.getAllListedOutputs(), true))
|
||||
{
|
||||
FluidStack outputStack = recipe.getFluidOutput();
|
||||
|
@ -199,16 +275,37 @@ public class TileAlchemicalReactionChamber extends TileInventory implements ITic
|
|||
return false;
|
||||
}
|
||||
|
||||
public void craftItem(RecipeARC recipe, MultiSlotItemHandler outputSlotHandler)
|
||||
private void craftItem(RecipeARC recipe, MultiSlotItemHandler outputSlotHandler)
|
||||
{
|
||||
if (this.canCraft(recipe, outputSlotHandler))
|
||||
{
|
||||
if (recipe.getFluidIngredient() != null)
|
||||
{
|
||||
FluidStack inputStack = recipe.getFluidIngredient().getMatchingInstance(inputTank.getFluid());
|
||||
inputTank.drain(inputStack, FluidAction.EXECUTE);
|
||||
}
|
||||
|
||||
outputSlotHandler.canTransferAllItemsToSlots(recipe.getAllOutputs(world.rand), false);
|
||||
outputTank.fill(recipe.getFluidOutput().copy(), FluidAction.EXECUTE);
|
||||
consumeInventory();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean canCraftFurnace(ItemStack outputStack, MultiSlotItemHandler outputSlotHandler)
|
||||
{
|
||||
List<ItemStack> outputList = new ArrayList<>();
|
||||
outputList.add(outputStack);
|
||||
return outputSlotHandler.canTransferAllItemsToSlots(outputList, true);
|
||||
}
|
||||
|
||||
private void craftFurnace(ItemStack outputStack, MultiSlotItemHandler outputSlotHandler)
|
||||
{
|
||||
List<ItemStack> outputList = new ArrayList<>();
|
||||
outputList.add(outputStack);
|
||||
outputSlotHandler.canTransferAllItemsToSlots(outputList, false);
|
||||
consumeInventory();
|
||||
}
|
||||
|
||||
public void consumeInventory()
|
||||
{
|
||||
ItemStack inputStack = getStackInSlot(INPUT_SLOT);
|
||||
|
@ -266,6 +363,6 @@ public class TileAlchemicalReactionChamber extends TileInventory implements ITic
|
|||
|
||||
public double getProgressForGui()
|
||||
{
|
||||
return 0;
|
||||
return currentProgress;
|
||||
}
|
||||
}
|
|
@ -170,6 +170,7 @@ public class Constants
|
|||
public static final String JEI_CATEGORY_SOULFORGE = "soulforge";
|
||||
public static final String JEI_CATEGORY_ALCHEMYTABLE = "alchemytable";
|
||||
public static final String JEI_CATEGORY_ARMOURDOWNGRADE = "armourdowngrade";
|
||||
public static final String JEI_CATEGORY_ARC = "arc";
|
||||
|
||||
public static final String WAILA_CONFIG_ALTAR = BloodMagic.MODID + ".bloodaltar";
|
||||
public static final String WAILA_CONFIG_TELEPOSER = BloodMagic.MODID + ".teleposer";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue