Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make meteor reagents completely configurable and add some new options to their functionality. #63

Merged
merged 8 commits into from
Jan 18, 2025
Merged
Original file line number Diff line number Diff line change
@@ -251,6 +251,7 @@
import WayofTime.alchemicalWizardry.common.spell.simple.SpellWindGust;
import WayofTime.alchemicalWizardry.common.summoning.SummoningHelperAW;
import WayofTime.alchemicalWizardry.common.summoning.meteor.Meteor;
import WayofTime.alchemicalWizardry.common.summoning.meteor.MeteorReagentRegistry;
import WayofTime.alchemicalWizardry.common.tileEntity.TEAlchemicCalcinator;
import WayofTime.alchemicalWizardry.common.tileEntity.TEAltar;
import WayofTime.alchemicalWizardry.common.tileEntity.TEBellJar;
@@ -3321,6 +3322,7 @@ public void postInit(FMLPostInitializationEvent event) {

DemonVillageLootRegistry.init();
Meteor.loadConfig();
MeteorReagentRegistry.loadConfig();

this.initCompressionHandlers();
}
@@ -4504,7 +4506,7 @@ public String[] getGeneratedStrings(String itemName) {
return strings;
}

@Mod.EventHandler
@EventHandler
public void initCommands(FMLServerStartingEvent event) {
event.registerServerCommand(new CommandBloodMagic());
}
Original file line number Diff line number Diff line change
@@ -16,6 +16,9 @@

import org.lwjgl.opengl.GL11;

import com.google.common.base.Joiner;

import WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent;
import WayofTime.alchemicalWizardry.common.summoning.meteor.MeteorParadigm;
import WayofTime.alchemicalWizardry.common.summoning.meteor.MeteorParadigmComponent;
import WayofTime.alchemicalWizardry.common.summoning.meteor.MeteorRegistry;
@@ -31,7 +34,6 @@ public class CachedMeteorRecipe extends CachedRecipe {

private final List<PositionedStack> input = new ArrayList<>();
private final List<PositionedStack> outputs = new ArrayList<>();
private final List<PositionedStack> filler = new ArrayList<>();
private final int cost;
private final int radius;
private Point focus;
@@ -50,14 +52,17 @@ public CachedMeteorRecipe(MeteorParadigm meteor, ItemStack focusStack) {
float componentRatio = 1 - fillerRatio;

for (MeteorParadigmComponent component : sortedComponents) {
ItemStack stack = component.getValidBlockParadigm();
ItemStack stack = component.getBlock();
int xPos = 3 + 18 * col;
int yPos = 37 + 18 * row;

List<String> tooltips = new ArrayList<>();
float chance = component.getWeight() / totalComponentWeight * componentRatio;
tooltips.add(I18n.format("nei.recipe.meteor.chance", getFormattedChance(chance)));
tooltips.add(I18n.format("nei.recipe.meteor.amount", getEstimatedAmount(chance, meteor.radius)));
if (!component.getRequiredReagents().isEmpty()) {
tooltips.add(I18n.format("nei.recipe.meteor.reagent", getReagentStrings(component)));
}
this.outputs.add(new TooltipStack(stack, xPos, yPos, tooltips));

col++;
@@ -82,7 +87,7 @@ public CachedMeteorRecipe(MeteorParadigm meteor, ItemStack focusStack) {
float totalFillerWeight = meteor.getTotalListWeight(meteor.fillerList);

for (MeteorParadigmComponent filler : sortedFiller) {
ItemStack stack = filler.getValidBlockParadigm();
ItemStack stack = filler.getBlock();
int xPos = 3 + 18 * col;
int yPos = 37 + 18 * row;

@@ -91,6 +96,9 @@ public CachedMeteorRecipe(MeteorParadigm meteor, ItemStack focusStack) {
tooltips.add(I18n.format("nei.recipe.meteor.chance", getFormattedChance(chance)));
tooltips.add(I18n.format("nei.recipe.meteor.amount", getEstimatedAmount(chance, meteor.radius)));
tooltips.add(I18n.format("nei.recipe.meteor.filler"));
if (!filler.getRequiredReagents().isEmpty()) {
tooltips.add(I18n.format("nei.recipe.meteor.reagent", getReagentStrings(filler)));
}
this.outputs.add(new TooltipStack(stack, xPos, yPos, tooltips));

col++;
@@ -109,6 +117,15 @@ public CachedMeteorRecipe(MeteorParadigm meteor, ItemStack focusStack) {
this.cost = meteor.cost;
}

private String getReagentStrings(MeteorParadigmComponent component) {
ArrayList<Reagent> reagents = component.getRequiredReagents();
ArrayList<String> reagentNames = new ArrayList<>();
for (Reagent r : reagents) {
reagentNames.add(r.name);
}
return Joiner.on(", ").join(reagentNames);
}

@Override
public List<PositionedStack> getIngredients() {
return this.input;
@@ -152,10 +169,10 @@ public void loadCraftingRecipes(String outputId, Object... results) {
@Override
public void loadCraftingRecipes(ItemStack result) {
for (MeteorParadigm meteor : getSortedMeteors()) {
if (meteor.componentList.stream().anyMatch(m -> matchItem(result, m.getValidBlockParadigm()))) {
if (meteor.componentList.stream().anyMatch(m -> matchItem(result, m.getBlock()))) {
arecipes.add(new CachedMeteorRecipe(meteor, result));
}
if (meteor.fillerList.stream().anyMatch(m -> matchItem(result, m.getValidBlockParadigm()))) {
if (meteor.fillerList.stream().anyMatch(m -> matchItem(result, m.getBlock()))) {
arecipes.add(new CachedMeteorRecipe(meteor, result));
}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
package WayofTime.alchemicalWizardry.common.entity.projectile;

import java.util.ArrayList;

import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;

import WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent;
import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentRegistry;
import WayofTime.alchemicalWizardry.common.summoning.meteor.MeteorRegistry;

public class EntityMeteor extends EnergyBlastProjectile {

private int meteorID;

public boolean hasTerrae;
public boolean hasOrbisTerrae;
public boolean hasCrystallos;
public boolean hasIncendium;
public boolean hasTennebrae;
public ArrayList<Reagent> reagentList = new ArrayList<>();

public EntityMeteor(World par1World) {
super(par1World);
@@ -33,23 +33,23 @@ public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) {
super.writeEntityToNBT(par1NBTTagCompound);

par1NBTTagCompound.setInteger("meteorID", meteorID);
par1NBTTagCompound.setBoolean("hasTerrae", hasTerrae);
par1NBTTagCompound.setBoolean("hasOrbisTerrae", hasOrbisTerrae);
par1NBTTagCompound.setBoolean("hasCrystallos", hasCrystallos);
par1NBTTagCompound.setBoolean("hasIncendium", hasIncendium);
par1NBTTagCompound.setBoolean("hasTennebrae", hasTennebrae);

for (Reagent r : reagentList) {
par1NBTTagCompound.setBoolean("reagent." + r.name, true);
}

}

@Override
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {
super.readEntityFromNBT(par1NBTTagCompound);

meteorID = par1NBTTagCompound.getInteger("meteorID");
hasTerrae = par1NBTTagCompound.getBoolean("hasTerrae");
hasOrbisTerrae = par1NBTTagCompound.getBoolean("hasOrbisTerrae");
hasIncendium = par1NBTTagCompound.getBoolean("hasIncendium");
hasCrystallos = par1NBTTagCompound.getBoolean("hasCrystallos");
hasTennebrae = par1NBTTagCompound.getBoolean("hasTennebrae");
for (Reagent r : ReagentRegistry.reagentList.values()) {
if (par1NBTTagCompound.getBoolean("reagent." + r.name)) {
reagentList.add(r);
}
}
}

@Override
@@ -66,27 +66,16 @@ public void onImpact(MovingObjectPosition mop) {
if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY && mop.entityHit != null) {
this.onImpact(mop.entityHit);
} else if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
MeteorRegistry.createMeteorImpact(
worldObj,
mop.blockX,
mop.blockY,
mop.blockZ,
this.meteorID,
new boolean[] { hasTerrae, hasOrbisTerrae, hasCrystallos, hasIncendium, hasTennebrae });
MeteorRegistry.createMeteorImpact(worldObj, mop.blockX, mop.blockY, mop.blockZ, this.meteorID, reagentList);
}

this.setDead();
}

@Override
public void onImpact(Entity mop) {
MeteorRegistry.createMeteorImpact(
worldObj,
(int) this.posX,
(int) this.posY,
(int) this.posZ,
meteorID,
new boolean[] { hasTerrae, hasOrbisTerrae, hasCrystallos, hasIncendium, hasTennebrae });
MeteorRegistry
.createMeteorImpact(worldObj, (int) this.posX, (int) this.posY, (int) this.posZ, meteorID, reagentList);

this.setDead();
}
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@
import net.minecraft.world.World;

import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent;
import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentRegistry;
import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone;
import WayofTime.alchemicalWizardry.api.rituals.RitualComponent;
@@ -56,20 +57,10 @@ public void performEffect(IMasterRitualStone ritualStone) {
EntityMeteor meteor = new EntityMeteor(world, x + 0.5f, 257, z + 0.5f, meteorID);
meteor.motionY = -1.0f;

if (this.canDrainReagent(ritualStone, ReagentRegistry.terraeReagent, 1000, true)) {
meteor.hasTerrae = true;
}
if (this.canDrainReagent(ritualStone, ReagentRegistry.orbisTerraeReagent, 1000, true)) {
meteor.hasOrbisTerrae = true;
}
if (this.canDrainReagent(ritualStone, ReagentRegistry.crystallosReagent, 1000, true)) {
meteor.hasCrystallos = true;
}
if (this.canDrainReagent(ritualStone, ReagentRegistry.incendiumReagent, 1000, true)) {
meteor.hasIncendium = true;
}
if (this.canDrainReagent(ritualStone, ReagentRegistry.tenebraeReagent, 1000, true)) {
meteor.hasTennebrae = true;
for (Reagent r : ReagentRegistry.reagentList.values()) {
if (this.canDrainReagent(ritualStone, r, 1000, true)) {
meteor.reagentList.add(r);
}
}

entityItem.setDead();
Original file line number Diff line number Diff line change
@@ -16,12 +16,12 @@

public class Meteor {

private String[] ores;
private int radius;
private int cost;
private String focusModId;
private String focusName;
private int focusMeta;
public String[] ores;
public int radius;
public int cost;
public String focusModId;
public String focusName;
public int focusMeta;
private String[] filler;
private int fillerChance;

@@ -32,6 +32,9 @@ public static void loadConfig() {
if (files != null) {
try {
for (File f : files) {
if (f.isDirectory()) {
continue;
}
BufferedReader br = new BufferedReader(new FileReader(f));
Meteor m = gson.fromJson(br, Meteor.class);
MeteorRegistry.registerMeteorParadigm(
Loading