Add Handlers for Ritual of Crushing (#1469)
* Add Handlers for Ritual of Crushing Fixes the crushing ritual's corrosive will augment. * Simplify Handler Class Use Primitives, ensure return value is non-null * Make the Handler Handle Draining Per Use * Revert "Make the Handler Handle Draining Per Use" This reverts commit bacaa610febc5a609a7a891ceed41b0e0fb2f05d.
This commit is contained in:
parent
6b1e9f4014
commit
297771af81
|
@ -91,6 +91,7 @@ public class BloodMagic {
|
||||||
|
|
||||||
ModRecipes.init();
|
ModRecipes.init();
|
||||||
ModRituals.initHarvestHandlers();
|
ModRituals.initHarvestHandlers();
|
||||||
|
ModRituals.initCuttingFluids();
|
||||||
MeteorConfigHandler.init(new File(configDir, "meteors"));
|
MeteorConfigHandler.init(new File(configDir, "meteors"));
|
||||||
ModArmourTrackers.init();
|
ModArmourTrackers.init();
|
||||||
NetworkRegistry.INSTANCE.registerGuiHandler(BloodMagic.instance, new GuiHandler());
|
NetworkRegistry.INSTANCE.registerGuiHandler(BloodMagic.instance, new GuiHandler());
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package WayofTime.bloodmagic.registry;
|
package WayofTime.bloodmagic.registry;
|
||||||
|
|
||||||
|
import WayofTime.bloodmagic.item.alchemy.ItemCuttingFluid;
|
||||||
|
import WayofTime.bloodmagic.ritual.crushing.CrushingHandlerCuttingFluid;
|
||||||
|
import WayofTime.bloodmagic.ritual.crushing.CrushingRegistry;
|
||||||
import WayofTime.bloodmagic.ritual.harvest.HarvestRegistry;
|
import WayofTime.bloodmagic.ritual.harvest.HarvestRegistry;
|
||||||
import WayofTime.bloodmagic.ritual.harvest.HarvestHandlerPlantable;
|
import WayofTime.bloodmagic.ritual.harvest.HarvestHandlerPlantable;
|
||||||
import WayofTime.bloodmagic.ritual.harvest.HarvestHandlerStem;
|
import WayofTime.bloodmagic.ritual.harvest.HarvestHandlerStem;
|
||||||
|
@ -19,4 +22,10 @@ public class ModRituals
|
||||||
HarvestRegistry.registerHandler(new HarvestHandlerTall());
|
HarvestRegistry.registerHandler(new HarvestHandlerTall());
|
||||||
HarvestRegistry.registerHandler(new HarvestHandlerStem());
|
HarvestRegistry.registerHandler(new HarvestHandlerStem());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void initCuttingFluids()
|
||||||
|
{
|
||||||
|
CrushingRegistry.registerCuttingFluid(new CrushingHandlerCuttingFluid(ItemCuttingFluid.FluidType.BASIC.getStack(), 250, 0.5));
|
||||||
|
CrushingRegistry.registerCuttingFluid(new CrushingHandlerCuttingFluid(ItemCuttingFluid.FluidType.EXPLOSIVE.getStack(), 25, 0.05));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
package WayofTime.bloodmagic.ritual.crushing;
|
||||||
|
|
||||||
|
import WayofTime.bloodmagic.api.impl.BloodMagicAPI;
|
||||||
|
import WayofTime.bloodmagic.api.impl.recipe.RecipeAlchemyTable;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CrushingHandlerCuttingFluid implements ICrushingHandler {
|
||||||
|
|
||||||
|
private int lpDrain;
|
||||||
|
|
||||||
|
private double willDrain;
|
||||||
|
|
||||||
|
private ItemStack cuttingStack;
|
||||||
|
|
||||||
|
public CrushingHandlerCuttingFluid(ItemStack cuttingStack, int lpDrain, double willDrain) {
|
||||||
|
this.lpDrain = lpDrain;
|
||||||
|
this.willDrain = willDrain;
|
||||||
|
this.cuttingStack = cuttingStack;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nonnull
|
||||||
|
public ItemStack getRecipeOutput(ItemStack inputStack, World world, BlockPos pos) {
|
||||||
|
List<ItemStack> inputList = new ArrayList<>();
|
||||||
|
inputList.add(cuttingStack);
|
||||||
|
inputList.add(inputStack.copy());
|
||||||
|
RecipeAlchemyTable recipeAlchemyTable = BloodMagicAPI.INSTANCE.getRecipeRegistrar().getAlchemyTable(inputList);
|
||||||
|
|
||||||
|
if (recipeAlchemyTable != null) {
|
||||||
|
return recipeAlchemyTable.getOutput().copy();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ItemStack.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getWillDrain() {
|
||||||
|
return willDrain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLpDrain() {
|
||||||
|
return lpDrain;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package WayofTime.bloodmagic.ritual.crushing;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
|
||||||
|
public class CrushingRegistry {
|
||||||
|
|
||||||
|
private static List<ICrushingHandler> crushingHandlerList = new ArrayList<>();
|
||||||
|
|
||||||
|
public static void registerCuttingFluid(ICrushingHandler handler) {
|
||||||
|
crushingHandlerList.add(handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<ICrushingHandler> getCrushingHandlerList() {
|
||||||
|
return crushingHandlerList;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package WayofTime.bloodmagic.ritual.crushing;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
public interface ICrushingHandler {
|
||||||
|
@Nonnull
|
||||||
|
ItemStack getRecipeOutput(ItemStack input, World world, BlockPos pos);
|
||||||
|
int getLpDrain();
|
||||||
|
double getWillDrain();
|
||||||
|
}
|
|
@ -5,6 +5,8 @@ import WayofTime.bloodmagic.compress.CompressionRegistry;
|
||||||
import WayofTime.bloodmagic.recipe.alchemyTable.AlchemyTableRecipe;
|
import WayofTime.bloodmagic.recipe.alchemyTable.AlchemyTableRecipe;
|
||||||
import WayofTime.bloodmagic.core.registry.AlchemyTableRecipeRegistry;
|
import WayofTime.bloodmagic.core.registry.AlchemyTableRecipeRegistry;
|
||||||
import WayofTime.bloodmagic.ritual.*;
|
import WayofTime.bloodmagic.ritual.*;
|
||||||
|
import WayofTime.bloodmagic.ritual.crushing.CrushingRegistry;
|
||||||
|
import WayofTime.bloodmagic.ritual.crushing.ICrushingHandler;
|
||||||
import WayofTime.bloodmagic.soul.EnumDemonWillType;
|
import WayofTime.bloodmagic.soul.EnumDemonWillType;
|
||||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks;
|
import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks;
|
||||||
import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler;
|
import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler;
|
||||||
|
@ -117,29 +119,19 @@ public class RitualCrushing extends Ritual {
|
||||||
|
|
||||||
ItemStack copyStack = checkStack.copy();
|
ItemStack copyStack = checkStack.copy();
|
||||||
|
|
||||||
for (Entry<ItemStack, Integer> entry : cuttingFluidLPMap.entrySet()) {
|
for (ICrushingHandler handler : CrushingRegistry.getCrushingHandlerList()) {
|
||||||
ItemStack cuttingStack = entry.getKey();
|
int lpDrain = handler.getLpDrain();
|
||||||
int lpDrain = entry.getValue();
|
double willDrain = handler.getWillDrain();
|
||||||
double willDrain = cuttingFluidWillMap.containsKey(cuttingStack) ? cuttingFluidWillMap.get(cuttingStack) : 0;
|
|
||||||
|
|
||||||
if (corrosiveWill < willDrain || currentEssence < lpDrain + getRefreshCost()) {
|
if (corrosiveWill < willDrain || currentEssence < lpDrain + getRefreshCost()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
cuttingStack = cuttingStack.copy();
|
ItemStack result = handler.getRecipeOutput(copyStack, world, pos);
|
||||||
List<ItemStack> input = new ArrayList<>();
|
|
||||||
input.add(cuttingStack);
|
|
||||||
input.add(copyStack);
|
|
||||||
|
|
||||||
AlchemyTableRecipe recipe = AlchemyTableRecipeRegistry.getMatchingRecipe(input, world, pos);
|
if (result.isEmpty()) {
|
||||||
if (recipe == null) {
|
continue;
|
||||||
continue;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack result = recipe.getRecipeOutput(input);
|
|
||||||
if (result.isEmpty()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tile != null) {
|
if (tile != null) {
|
||||||
result = Utils.insertStackIntoTile(result, tile, EnumFacing.DOWN);
|
result = Utils.insertStackIntoTile(result, tile, EnumFacing.DOWN);
|
||||||
|
@ -158,6 +150,7 @@ public class RitualCrushing extends Ritual {
|
||||||
|
|
||||||
isBlockClaimed = true;
|
isBlockClaimed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isBlockClaimed && isSilkTouch && block.canSilkHarvest(world, newPos, state, getFakePlayer((WorldServer) world))) {
|
if (!isBlockClaimed && isSilkTouch && block.canSilkHarvest(world, newPos, state, getFakePlayer((WorldServer) world))) {
|
||||||
|
|
Loading…
Reference in a new issue