Compare commits

..
2 Commits
Author SHA1 Message Date
Martin Robertz 6a3b0e1a70 update 2024-05-03 23:15:46 +02:00
Guillaume Mercier 232148ac42 Add new rune to reduce the delay between crafts (#51)
* add layout.json to gitignore

* Add quickness rune

This rune reduces the delay between consecutive crafts. This is done by essentially scheduling a recipe check every time a recipe completes. Using something like a world accelerator will have no effect on the frequency and the runes themselves do not increase the frequency at which the altar naturally checks for updates.

This commit also addresses a couple other issues with the altar.
- since the altar was using the world time and not the world age, some mechanics were impossible to trigger if you set doDaylightCycle to false.
- For example it was impossible to start a craft if the time wasn't set to a multiple of 100.

(cherry picked from commit e14b1f23c9)
2024-05-03 23:14:44 +02:00
21 changed files with 177 additions and 261 deletions

No files matched your search

+11 -11
View File
@@ -23,19 +23,19 @@
*/
dependencies {
api("com.github.GTNewHorizons:waila:1.8.2:dev")
api("com.github.GTNewHorizons:NotEnoughItems:2.6.46-GTNH:dev")
compileOnly("com.github.GTNewHorizons:GT5-Unofficial:5.09.50.73:dev") {transitive = false }
compileOnly("com.github.GTNewHorizons:Botania:1.11.5-GTNH:api") {transitive = false }
compileOnly("com.github.GTNewHorizons:ForestryMC:4.9.19:api") {transitive = false }
compileOnly("com.github.GTNewHorizons:ForgeMultipart:1.5.0:dev") {transitive = false }
api("com.github.GTNewHorizons:waila:1.7.3:dev")
api("com.github.GTNewHorizons:NotEnoughItems:2.5.27-GTNH:dev")
compileOnly("com.github.GTNewHorizons:GT5-Unofficial:5.09.45.165:dev") {transitive = false }
compileOnly("com.github.GTNewHorizons:Botania:1.10.12-GTNH:api") {transitive = false }
compileOnly("com.github.GTNewHorizons:ForestryMC:4.8.9:api") {transitive = false }
compileOnly("com.github.GTNewHorizons:ForgeMultipart:1.4.8:dev") {transitive = false }
compileOnly("com.github.GTNewHorizons:Chisel:2.14.1-GTNH:api") {transitive = false }
compileOnly("com.github.GTNewHorizons:Chisel:2.15.3-GTNH:api") {transitive = false }
compileOnly("com.github.GTNewHorizons:ZenScript:1.0.0-GTNH") {transitive = false }
compileOnly("com.github.GTNewHorizons:CraftTweaker:3.4.0:dev") {transitive = false }
compileOnly("com.github.GTNewHorizons:CraftTweaker:3.3.1:dev") {transitive = false }
compileOnly("thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev") {transitive = false }
compileOnly("curse.maven:guide-api-228832:2287185") {transitive = false }
+1 -12
View File
@@ -85,11 +85,6 @@ accessTransformersFile = NEI_at.cfg
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
usesMixins = false
# Set to a non-empty string to configure mixins in a separate source set under src/VALUE, instead of src/main.
# This can speed up compile times thanks to not running the mixin annotation processor on all input sources.
# Mixin classes will have access to "main" classes, but not the other way around.
separateMixinSourceSet =
# Adds some debug arguments like verbose output and class export.
usesMixinDebug = false
@@ -122,15 +117,9 @@ minimizeShadowedDependencies = true
# If disabled, won't rename the shadowed classes.
relocateShadowedDependencies = true
# Adds CurseMaven, Modrinth, and some more well-known 1.7.10 repositories.
# Adds the GTNH maven, CurseMaven, Modrinth, and some more well-known 1.7.10 repositories.
includeWellKnownRepositories = true
# A list of repositories to exclude from the includeWellKnownRepositories setting. Should be a space separated
# list of strings, with the acceptable keys being(case does not matter):
# cursemaven
# modrinth
excludeWellKnownRepositories =
# Change these to your Maven coordinates if you want to publish to a custom Maven repository instead of the default GTNH Maven.
# Authenticate with the MAVEN_USER and MAVEN_PASSWORD environment variables.
# If you need a more complex setup disable maven publishing here and add a publishing repository to addon.gradle.
Binary file not shown.
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Vendored
+2 -5
View File
@@ -15,8 +15,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
#
@@ -57,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -86,8 +84,7 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Vendored
-2
View File
@@ -13,8 +13,6 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
+1 -1
View File
@@ -17,7 +17,7 @@ pluginManagement {
}
plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.29'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.22'
}
@@ -718,9 +718,8 @@ public class AlchemicalWizardry {
proxy.registerEntities();
proxy.registerEntityTrackers();
proxy.registerEvents();
if (Loader.isModLoaded("Waila")) {
BloodMagicWailaPlugin.init();
}
BloodMagicWailaPlugin.init();
// ItemStacks used for crafting go here
ItemStack lapisStack = new ItemStack(Items.dye, 1, 4);
ItemStack lavaBucketStack = new ItemStack(Items.lava_bucket);
@@ -14,7 +14,6 @@ import WayofTime.alchemicalWizardry.api.event.AddToNetworkEvent;
import WayofTime.alchemicalWizardry.api.event.ItemBindEvent;
import WayofTime.alchemicalWizardry.api.event.ItemDrainInContainerEvent;
import WayofTime.alchemicalWizardry.api.event.ItemDrainNetworkEvent;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.Event;
import cpw.mods.fml.common.eventhandler.Event.Result;
@@ -36,12 +35,11 @@ public class SoulNetworkHandler {
}
public static int getCurrentMaxOrb(String ownerName) {
MinecraftServer mcServer = FMLCommonHandler.instance().getMinecraftServerInstance();
if (mcServer == null) {
if (MinecraftServer.getServer() == null) {
return 0;
}
World world = mcServer.worldServers[0];
World world = MinecraftServer.getServer().worldServers[0];
LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, ownerName);
if (data == null) {
@@ -53,12 +51,11 @@ public class SoulNetworkHandler {
}
public static void setMaxOrbToMax(String ownerName, int maxOrb) {
MinecraftServer mcServer = FMLCommonHandler.instance().getMinecraftServerInstance();
if (mcServer == null) {
if (MinecraftServer.getServer() == null) {
return;
}
World world = mcServer.worldServers[0];
World world = MinecraftServer.getServer().worldServers[0];
LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, ownerName);
if (data == null) {
@@ -99,7 +96,7 @@ public class SoulNetworkHandler {
}
public static int syphonFromNetwork(String ownerName, int damageToBeDone) {
MinecraftServer mcServer = FMLCommonHandler.instance().getMinecraftServerInstance();
MinecraftServer mcServer = MinecraftServer.getServer();
if (mcServer == null || mcServer.worldServers.length == 0) {
return 0;
}
@@ -195,12 +192,11 @@ public class SoulNetworkHandler {
}
public static boolean canSyphonFromOnlyNetwork(String ownerName, int damageToBeDone) {
MinecraftServer mcServer = FMLCommonHandler.instance().getMinecraftServerInstance();
if (mcServer == null) {
if (MinecraftServer.getServer() == null) {
return false;
}
World world = mcServer.worldServers[0];
World world = MinecraftServer.getServer().worldServers[0];
LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, ownerName);
if (data == null) {
@@ -212,12 +208,11 @@ public class SoulNetworkHandler {
}
public static int getCurrentEssence(String ownerName) {
MinecraftServer mcServer = FMLCommonHandler.instance().getMinecraftServerInstance();
if (mcServer == null) {
if (MinecraftServer.getServer() == null) {
return 0;
}
World world = mcServer.worldServers[0];
World world = MinecraftServer.getServer().worldServers[0];
LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, ownerName);
if (data == null) {
@@ -229,12 +224,11 @@ public class SoulNetworkHandler {
}
public static void setCurrentEssence(String ownerName, int essence) {
MinecraftServer mcServer = FMLCommonHandler.instance().getMinecraftServerInstance();
if (mcServer == null) {
if (MinecraftServer.getServer() == null) {
return;
}
World world = mcServer.worldServers[0];
World world = MinecraftServer.getServer().worldServers[0];
LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, ownerName);
if (data == null) {
@@ -261,12 +255,11 @@ public class SoulNetworkHandler {
return 0;
}
MinecraftServer mcServer = FMLCommonHandler.instance().getMinecraftServerInstance();
if (mcServer == null) {
if (MinecraftServer.getServer() == null) {
return 0;
}
World world = mcServer.worldServers[0];
World world = MinecraftServer.getServer().worldServers[0];
LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, event.ownerNetwork);
if (data == null) {
@@ -355,11 +348,10 @@ public class SoulNetworkHandler {
}
public static EntityPlayer getPlayerForUsername(String str) {
MinecraftServer mcServer = FMLCommonHandler.instance().getMinecraftServerInstance();
if (mcServer == null) {
if (MinecraftServer.getServer() == null) {
return null;
}
return mcServer.getConfigurationManager().func_152612_a(str);
return MinecraftServer.getServer().getConfigurationManager().func_152612_a(str);
}
public static void causeNauseaToPlayer(ItemStack stack) {
@@ -31,7 +31,6 @@ public class NEIMeteorRecipeHandler extends TemplateRecipeHandler {
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;
@@ -41,13 +40,9 @@ public class NEIMeteorRecipeHandler extends TemplateRecipeHandler {
int row = 0;
int col = 0;
float totalComponentWeight = meteor.getTotalListWeight(meteor.componentList);
int fillerChance = meteor.fillerChance;
float totalMeteorWeight = meteor.getTotalMeteorWeight();
List<MeteorParadigmComponent> sortedComponents = new ArrayList<>(meteor.componentList);
sortedComponents.sort(Comparator.comparingInt(c -> -c.getWeight()));
float fillerRatio = (float) (fillerChance / 100.0);
float componentRatio = 1 - fillerRatio;
sortedComponents.sort(Comparator.comparingInt(c -> -c.getChance()));
for (MeteorParadigmComponent component : sortedComponents) {
ItemStack stack = component.getValidBlockParadigm();
@@ -55,7 +50,7 @@ public class NEIMeteorRecipeHandler extends TemplateRecipeHandler {
int yPos = 37 + 18 * row;
List<String> tooltips = new ArrayList<>();
float chance = component.getWeight() / totalComponentWeight * componentRatio;
float chance = component.getChance() / totalMeteorWeight;
tooltips.add(I18n.format("nei.recipe.meteor.chance", getFormattedChance(chance)));
tooltips.add(I18n.format("nei.recipe.meteor.amount", getEstimatedAmount(chance, meteor.radius)));
this.outputs.add(new TooltipStack(stack, xPos, yPos, tooltips));
@@ -66,45 +61,10 @@ public class NEIMeteorRecipeHandler extends TemplateRecipeHandler {
row++;
}
if (matchItem(focusStack, stack)) {
if (focusStack != null && matchItem(focusStack, stack)) {
this.focus = new Point(xPos - 1, yPos - 1);
}
}
if (fillerChance > 0) {
if (col != 0) {
col = 0;
row++;
}
List<MeteorParadigmComponent> sortedFiller = new ArrayList<>(meteor.fillerList);
sortedFiller.sort(Comparator.comparingInt(c -> -c.getWeight()));
float totalFillerWeight = meteor.getTotalListWeight(meteor.fillerList);
for (MeteorParadigmComponent filler : sortedFiller) {
ItemStack stack = filler.getValidBlockParadigm();
int xPos = 3 + 18 * col;
int yPos = 37 + 18 * row;
List<String> tooltips = new ArrayList<>();
float chance = filler.getWeight() / totalFillerWeight * fillerRatio;
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"));
this.outputs.add(new TooltipStack(stack, xPos, yPos, tooltips));
col++;
if (col > 8) {
col = 0;
row++;
}
if (matchItem(focusStack, stack)) {
this.focus = new Point(xPos - 1, yPos - 1);
}
}
}
this.radius = meteor.radius;
this.cost = meteor.cost;
}
@@ -155,9 +115,6 @@ public class NEIMeteorRecipeHandler extends TemplateRecipeHandler {
if (meteor.componentList.stream().anyMatch(m -> matchItem(result, m.getValidBlockParadigm()))) {
arecipes.add(new CachedMeteorRecipe(meteor, result));
}
if (meteor.fillerList.stream().anyMatch(m -> matchItem(result, m.getValidBlockParadigm()))) {
arecipes.add(new CachedMeteorRecipe(meteor, result));
}
}
}
@@ -248,6 +205,6 @@ public class NEIMeteorRecipeHandler extends TemplateRecipeHandler {
}
private int getEstimatedAmount(float chance, int radius) {
return (int) Math.ceil(4f / 3 * Math.PI * Math.pow(radius + 0.5, 3) * chance);
return (int) Math.ceil(4f / 3 * Math.PI * Math.pow(radius, 3) * chance);
}
}
@@ -106,24 +106,26 @@ public class RenderHelper {
GL11.glPushMatrix();
int xSize = 32;
int ySize = 32;
int amount = Math.max((int) (256 * ((double) (maxAmount - lpAmount) / maxAmount)), 0);
int x = (lpBarX - xSize / 2) * 8;
int y = (lpBarY - ySize / 2) * 8;
ResourceLocation test2 = new ResourceLocation("alchemicalwizardry", "textures/gui/container1.png");
GL11.glColor4f(1, 0, 0, 1.0F);
GL11.glEnable(GL11.GL_BLEND);
mc.renderEngine.bindTexture(test2);
mc.getTextureManager().bindTexture(test2);
GL11.glScalef(1f / 8f, 1f / 8f, 1f / 8f);
GL11.glPushMatrix();
drawTexturedModalRect(x, y + amount, 0, amount, 256, 256 - amount);
GL11.glPopMatrix();
ResourceLocation test = new ResourceLocation("alchemicalwizardry", "textures/gui/lpVial.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(test);
GL11.glPushMatrix();
mc.getTextureManager().bindTexture(test);
drawTexturedModalRect(x, y, 0, 0, 256, 256);
GL11.glPopMatrix();
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
}
@@ -11,7 +11,6 @@ import net.minecraft.server.MinecraftServer;
import WayofTime.alchemicalWizardry.ModItems;
import WayofTime.alchemicalWizardry.common.items.LavaCrystal;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.IFuelHandler;
public class AlchemicalWizardryFuelHandler implements IFuelHandler {
@@ -36,12 +35,11 @@ public class AlchemicalWizardryFuelHandler implements IFuelHandler {
return 0;
}
MinecraftServer mcServer = FMLCommonHandler.instance().getMinecraftServerInstance();
if (mcServer == null) {
if (MinecraftServer.getServer() == null) {
return 0;
}
if (mcServer.getConfigurationManager() == null) {
if (MinecraftServer.getServer().getConfigurationManager() == null) {
return 0;
}
@@ -5,6 +5,7 @@ import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraft.world.WorldProvider;
@@ -12,7 +13,6 @@ import net.minecraftforge.common.DimensionManager;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.api.soulNetwork.LifeEssenceNetwork;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -72,7 +72,7 @@ public class LavaCrystal extends EnergyItems {
if (itemStack.getTagCompound() != null && !(itemStack.getTagCompound().getString("ownerName").equals(""))) {
String ownerName = itemStack.getTagCompound().getString("ownerName");
if (FMLCommonHandler.instance().getMinecraftServerInstance() == null) {
if (MinecraftServer.getServer() == null) {
return false;
}
@@ -8,9 +8,9 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -75,8 +75,7 @@ public class TelepositionFocus extends EnergyItems {
}
public World getWorld(ItemStack itemStack) {
return FMLCommonHandler.instance().getMinecraftServerInstance()
.worldServerForDimension(getDimensionID(itemStack));
return DimensionManager.getWorld(getDimensionID(itemStack));
}
public int xCoord(ItemStack itemStack) {
@@ -21,9 +21,10 @@ public class RitualEffectWellOfSuffering extends RitualEffect {
public static final int timeDelay = 25;
public static final int amount = AlchemicalWizardry.lpPerSacrificeWellOfSuffering;
public static final int tennebraeDrain = 5;
public static final int potentiaDrain = 10;
public static final int offensaDrain = 3;
private static final int tennebraeDrain = 5;
private static final int potentiaDrain = 10;
private static final int offensaDrain = 3;
@Override
public void performEffect(IMasterRitualStone ritualStone) {
@@ -35,7 +36,7 @@ public class RitualEffectWellOfSuffering extends RitualEffect {
int y = ritualStone.getYCoord();
int z = ritualStone.getZCoord();
if (world.getWorldTime() % timeDelay != 0) {
if (world.getWorldTime() % this.timeDelay != 0) {
return;
}
@@ -61,8 +62,13 @@ public class RitualEffectWellOfSuffering extends RitualEffect {
int d0 = 10;
int vertRange = hasPotentia ? 20 : 10;
AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox(x, y, z, (x + 1), (y + 1), (z + 1))
.expand(d0, vertRange, d0);
AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox(
(double) x,
(double) y,
(double) z,
(double) (x + 1),
(double) (y + 1),
(double) (z + 1)).expand(d0, vertRange, d0);
List<EntityLivingBase> list = world.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb);
int entityCount = 0;
@@ -87,7 +93,7 @@ public class RitualEffectWellOfSuffering extends RitualEffect {
&& this.canDrainReagent(ritualStone, ReagentRegistry.tenebraeReagent, tennebraeDrain, true);
entityCount++;
tileAltar.sacrificialDaggerCall(amount * (hasTennebrae ? 2 : 1) * (hasOffensa ? 2 : 1), true);
tileAltar.sacrificialDaggerCall(this.amount * (hasTennebrae ? 2 : 1) * (hasOffensa ? 2 : 1), true);
}
}
@@ -106,7 +112,7 @@ public class RitualEffectWellOfSuffering extends RitualEffect {
@Override
public List<RitualComponent> getRitualComponentList() {
ArrayList<RitualComponent> wellOfSufferingRitual = new ArrayList<>();
ArrayList<RitualComponent> wellOfSufferingRitual = new ArrayList();
wellOfSufferingRitual.add(new RitualComponent(1, 0, 1, RitualComponent.FIRE));
wellOfSufferingRitual.add(new RitualComponent(-1, 0, 1, RitualComponent.FIRE));
wellOfSufferingRitual.add(new RitualComponent(1, 0, -1, RitualComponent.FIRE));
@@ -10,20 +10,17 @@ import net.minecraft.item.ItemStack;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonSyntaxException;
import cpw.mods.fml.common.registry.GameRegistry;
public class Meteor {
private String[] ores;
private int radius;
private int cost;
private String focusModId;
private String focusName;
private int focusMeta;
private String[] filler;
private int fillerChance;
public String[] ores;
public int radius;
public int cost;
public String focusModId;
public String focusName;
public int focusMeta;
public static void loadConfig() {
Gson gson = new GsonBuilder().setPrettyPrinting().create();
@@ -38,11 +35,9 @@ public class Meteor {
findItemStack(m.focusModId, m.focusName, m.focusMeta),
m.ores,
m.radius,
m.cost,
m.filler,
m.fillerChance);
m.cost);
}
} catch (FileNotFoundException | JsonSyntaxException e) {
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
@@ -16,28 +16,21 @@ import net.minecraftforge.oredict.OreDictionary;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import cpw.mods.fml.common.Optional;
import cpw.mods.fml.common.registry.GameRegistry;
import gregtech.common.blocks.TileEntityOres;
import gregtech.common.blocks.GT_TileEntity_Ores;
public class MeteorParadigm {
public List<MeteorParadigmComponent> componentList = new ArrayList<>();
public List<MeteorParadigmComponent> fillerList = new ArrayList<>();
public ItemStack focusStack;
public int radius;
public int cost;
public int fillerChance; // Out of 100
public static Random rand = new Random();
public MeteorParadigm(ItemStack focusStack, int radius, int cost) {
new MeteorParadigm(focusStack, radius, cost, 0);
}
public MeteorParadigm(ItemStack focusStack, int radius, int cost, int fillerChance) {
this.focusStack = focusStack;
this.radius = radius;
this.cost = cost;
this.fillerChance = fillerChance;
}
// modId:itemName:meta:weight
@@ -45,13 +38,12 @@ public class MeteorParadigm {
// OREDICT:oreDictName:weight
private static final Pattern oredictPattern = Pattern.compile("OREDICT:(.*):(\\d+)");
public static List<MeteorParadigmComponent> parseStringArray(String[] blockArray) {
List<MeteorParadigmComponent> addList = new ArrayList<>();
for (int i = 0; i < blockArray.length; ++i) {
String blockName = blockArray[i];
public void parseStringArray(String[] oreArray) {
for (int i = 0; i < oreArray.length; ++i) {
String oreName = oreArray[i];
boolean success = false;
Matcher matcher = itemNamePattern.matcher(blockName);
Matcher matcher = itemNamePattern.matcher(oreName);
if (matcher.matches()) {
String modID = matcher.group(1);
String itemName = matcher.group(2);
@@ -61,18 +53,18 @@ public class MeteorParadigm {
ItemStack stack = GameRegistry.findItemStack(modID, itemName, 1);
if (stack != null && stack.getItem() instanceof ItemBlock) {
stack.setItemDamage(meta);
addList.add(new MeteorParadigmComponent(stack, weight));
componentList.add(new MeteorParadigmComponent(stack, weight));
success = true;
}
} else if ((matcher = oredictPattern.matcher(blockName)).matches()) {
} else if ((matcher = oredictPattern.matcher(oreName)).matches()) {
String oreDict = matcher.group(1);
int weight = Integer.parseInt(matcher.group(2));
List<ItemStack> list = OreDictionary.getOres(oreDict);
for (ItemStack stack : list) {
if (stack != null && stack.getItem() instanceof ItemBlock) {
addList.add(new MeteorParadigmComponent(stack, weight));
componentList.add(new MeteorParadigmComponent(stack, weight));
success = true;
break;
}
@@ -80,13 +72,13 @@ public class MeteorParadigm {
} else {
// Legacy config
String oreDict = blockName;
int weight = Integer.parseInt(blockArray[++i]);
String oreDict = oreName;
int weight = Integer.parseInt(oreArray[++i]);
List<ItemStack> list = OreDictionary.getOres(oreDict);
for (ItemStack stack : list) {
if (stack != null && stack.getItem() instanceof ItemBlock) {
addList.add(new MeteorParadigmComponent(stack, weight));
componentList.add(new MeteorParadigmComponent(stack, weight));
success = true;
break;
}
@@ -94,18 +86,17 @@ public class MeteorParadigm {
}
if (!success) {
AlchemicalWizardry.logger.warn("Unable to add Meteor Paradigm \"" + blockName + "\"");
AlchemicalWizardry.logger.warn("Unable to add Meteor Paradigm \"" + oreName + "\"");
}
}
return addList;
}
public int getTotalListWeight(List<MeteorParadigmComponent> blockList) {
int totalWeight = 0;
for (MeteorParadigmComponent mpc : blockList) {
totalWeight += mpc.getWeight();
public int getTotalMeteorWeight() {
int totalMeteorWeight = 0;
for (MeteorParadigmComponent mpc : componentList) {
totalMeteorWeight += mpc.getChance();
}
return totalWeight;
return totalMeteorWeight;
}
public void createMeteorImpact(World world, int x, int y, int z, boolean[] flags) {
@@ -124,41 +115,22 @@ public class MeteorParadigm {
}
int newRadius = radius;
int fillerChance = this.fillerChance;
if (hasOrbisTerrae) {
newRadius += 2;
fillerChance *= 1.12;
} else if (hasTerrae) {
newRadius += 1;
fillerChance *= 1.06;
}
if (fillerChance > 100) {
fillerChance = 100;
}
world.createExplosion(null, x, y, z, newRadius * 4, AlchemicalWizardry.doMeteorsDestroyBlocks);
List<MeteorParadigmComponent> fillerList;
float iceChance = hasCrystallos ? 1 : 0;
float soulChance = hasIncendium ? 1 : 0;
float obsidChance = hasTennebrae ? 1 : 0;
if (hasCrystallos || hasIncendium || hasTennebrae) {
fillerList = new ArrayList<>();
if (hasCrystallos) {
fillerList.add(new MeteorParadigmComponent(new ItemStack(Blocks.ice), 180)); // 180 = 2^2 * 3^2 * 5
}
if (hasIncendium) {
fillerList.add(new MeteorParadigmComponent(new ItemStack(Blocks.netherrack), 60));
fillerList.add(new MeteorParadigmComponent(new ItemStack(Blocks.soul_sand), 60));
fillerList.add(new MeteorParadigmComponent(new ItemStack(Blocks.glowstone), 60));
}
if (hasTennebrae) {
fillerList.add(new MeteorParadigmComponent(new ItemStack(Blocks.obsidian), 180));
}
} else {
fillerList = this.fillerList;
}
float totalChance = iceChance + soulChance + obsidChance;
int totalComponentWeight = getTotalListWeight(componentList);
int totalFillerWeight = getTotalListWeight(fillerList);
int totalMeteorWeight = getTotalMeteorWeight();
for (int i = -newRadius; i <= newRadius; i++) {
for (int j = -newRadius; j <= newRadius; j++) {
@@ -171,30 +143,75 @@ public class MeteorParadigm {
continue;
}
if (fillerChance <= 0 || world.rand.nextInt(100) >= fillerChance) {
setMeteorBlock(x + i, y + j, z + k, world, componentList, totalComponentWeight);
} else {
setMeteorBlock(x + i, y + j, z + k, world, fillerList, totalFillerWeight);
int randNum = world.rand.nextInt(totalMeteorWeight);
boolean hasPlacedBlock = false;
for (MeteorParadigmComponent mpc : componentList) {
randNum -= mpc.getChance();
if (randNum < 0) {
ItemStack blockStack = mpc.getValidBlockParadigm();
if (blockStack != null && blockStack.getItem() instanceof ItemBlock) {
((ItemBlock) blockStack.getItem()).placeBlockAt(
blockStack,
null,
world,
x + i,
y + j,
z + k,
0,
0,
0,
0,
blockStack.getItemDamage());
if (AlchemicalWizardry.isGregTechLoaded)
setGTOresNaturalIfNeeded(world, x + i, y + j, z + k);
world.markBlockForUpdate(x + i, y + j, z + k);
hasPlacedBlock = true;
break;
}
// world.setBlock(x + i, y + j, z + k,
// Block.getBlockById(Item.getIdFromItem(blockStack.getItem())), blockStack.getItemDamage(),
// 3);
// hasPlacedBlock = true;
// break;
}
}
}
}
}
}
private void setMeteorBlock(int x, int y, int z, World world, List<MeteorParadigmComponent> blockList,
int totalListWeight) {
int randNum = world.rand.nextInt(totalListWeight);
for (MeteorParadigmComponent mpc : blockList) {
randNum -= mpc.getWeight();
if (!hasPlacedBlock) {
float randChance = rand.nextFloat() * totalChance;
if (randNum < 0) {
ItemStack blockStack = mpc.getValidBlockParadigm();
if (blockStack != null && blockStack.getItem() instanceof ItemBlock) {
((ItemBlock) blockStack.getItem())
.placeBlockAt(blockStack, null, world, x, y, z, 0, 0, 0, 0, blockStack.getItemDamage());
if (AlchemicalWizardry.isGregTechLoaded) setGTOresNaturalIfNeeded(world, x, y, z);
world.markBlockForUpdate(x, y, z);
break;
if (randChance < iceChance) {
world.setBlock(x + i, y + j, z + k, Blocks.ice, 0, 3);
} else {
randChance -= iceChance;
if (randChance < soulChance) {
switch (rand.nextInt(3)) {
case 0:
world.setBlock(x + i, y + j, z + k, Blocks.soul_sand, 0, 3);
break;
case 1:
world.setBlock(x + i, y + j, z + k, Blocks.glowstone, 0, 3);
break;
case 2:
world.setBlock(x + i, y + j, z + k, Blocks.netherrack, 0, 3);
break;
}
} else {
randChance -= soulChance;
if (randChance < obsidChance) {
world.setBlock(x + i, y + j, z + k, Blocks.obsidian, 0, 3);
} else {
randChance -= obsidChance;
world.setBlock(x + i, y + j, z + k, Blocks.stone, 0, 3);
}
}
}
}
}
}
}
@@ -203,8 +220,8 @@ public class MeteorParadigm {
@Optional.Method(modid = "gregtech")
private static void setGTOresNaturalIfNeeded(World world, int x, int y, int z) {
final TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityOres) {
((TileEntityOres) tileEntity).mNatural = true;
if (tileEntity instanceof GT_TileEntity_Ores) {
((GT_TileEntity_Ores) tileEntity).mNatural = true;
}
}
}
@@ -4,16 +4,16 @@ import net.minecraft.item.ItemStack;
public class MeteorParadigmComponent {
protected int weight;
protected int chance;
protected ItemStack itemStack;
public MeteorParadigmComponent(ItemStack stack, int weight) {
public MeteorParadigmComponent(ItemStack stack, int chance) {
this.itemStack = stack;
this.weight = weight;
this.chance = chance;
}
public int getWeight() {
return this.weight;
public int getChance() {
return this.chance;
}
public ItemStack getValidBlockParadigm() {
@@ -3,7 +3,6 @@ package WayofTime.alchemicalWizardry.common.summoning.meteor;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;
@@ -16,20 +15,10 @@ public class MeteorRegistry {
paradigmList.add(paradigm);
}
public static void registerMeteorParadigm(ItemStack stack, String[] componentList, int radius, int cost) {
registerMeteorParadigm(stack, componentList, radius, cost, null, 0);
}
public static void registerMeteorParadigm(ItemStack stack, String[] componentList, int radius, int cost,
String[] fillerList, int fillerChance) {
if (stack != null && componentList != null) {
MeteorParadigm meteor = new MeteorParadigm(stack, radius, cost, fillerChance);
meteor.componentList = MeteorParadigm.parseStringArray(componentList);
if (fillerList != null && fillerList.length > 0) {
meteor.fillerList = MeteorParadigm.parseStringArray(fillerList);
} else {
meteor.fillerList.add(new MeteorParadigmComponent(new ItemStack(Blocks.stone), 1));
}
public static void registerMeteorParadigm(ItemStack stack, String[] oreList, int radius, int cost) {
if (stack != null && oreList != null) {
MeteorParadigm meteor = new MeteorParadigm(stack, radius, cost);
meteor.parseStringArray(oreList);
paradigmList.add(meteor);
}
}
@@ -41,19 +41,6 @@ public class FallingTower {
MineTweakerAPI.apply(new Add(toStack(stack), radius, cost, components.split("\\s*,\\s*")));
}
@ZenMethod
public static void addFocus(IItemStack stack, int radius, int cost, String components, String filler,
int fillerChance) {
MineTweakerAPI.apply(
new Add(
toStack(stack),
radius,
cost,
components.split("\\s*,\\s*"),
filler.split("\\s*,\\s*"),
fillerChance));
}
@ZenMethod
public static void removeFocus(IItemStack output) {
MineTweakerAPI.apply(new Remove(toStack(output)));
@@ -64,16 +51,8 @@ public class FallingTower {
private MeteorParadigm paradigm;
public Add(ItemStack stack, int radius, int cost, String[] components) {
new Add(stack, radius, cost, components, null, 0);
}
public Add(ItemStack stack, int radius, int cost, String[] components, String[] filler, int fillerChance) {
paradigm = new MeteorParadigm(stack, radius, cost);
paradigm.componentList = MeteorParadigm.parseStringArray(components);
if (filler != null) {
paradigm.fillerList = MeteorParadigm.parseStringArray(filler);
}
paradigm.fillerChance = fillerChance;
paradigm.parseStringArray(components);
}
@Override
@@ -267,7 +267,6 @@ nei.recipe.meteor.cost=Cost: %s LP
nei.recipe.meteor.radius=Radius: %s
nei.recipe.meteor.chance=Chance: %s%%
nei.recipe.meteor.amount=Estimated amount: %s
nei.recipe.meteor.filler=§7Filler block
#Rituals
ritual.AW001Water.name=Ritual of the Full Spring