Compare commits

...
6 Commits
Author SHA1 Message Date
Maya d821098d4e update 2025-04-08 23:43:52 -05:00
koolkrafter5andMaya 8762c24331 Ritual of Speed bugfix and cleanup (#70)
Co-authored-by: Maya <[email protected]>
2025-04-09 04:42:00 +00:00
koolkrafter5andMaya a1f62e0db6 NEI Meteor Oredict Support (#69)
Co-authored-by: Maya <[email protected]>
2025-04-08 19:57:01 +00:00
koolkrafter5 242312bee5 Config to Allow Altar Components to be Any Block (#68) 2025-04-08 14:52:16 -05:00
Martin Robertz c0b4b797c8 update 2025-01-22 18:39:05 +01:00
koolkrafter5 bd584c6d52 New TypeAdapter for ItemStack (#67) 2025-01-21 23:59:50 -06:00
17 changed files with 213 additions and 161 deletions

No files matched your search

+1 -1
View File
@@ -27,4 +27,4 @@ whitelist.json
*.iws *.iws
src/main/resources/mixins.*.json src/main/resources/mixins.*.json
*.bat *.bat
/layout.json layout.json
+6 -6
View File
@@ -23,19 +23,19 @@
*/ */
dependencies { dependencies {
api("com.github.GTNewHorizons:waila:1.8.2:dev") api("com.github.GTNewHorizons:waila:1.8.4:dev")
api("com.github.GTNewHorizons:NotEnoughItems:2.7.23-GTNH:dev") api("com.github.GTNewHorizons:NotEnoughItems:2.7.34-GTNH:dev")
compileOnly("com.github.GTNewHorizons:GT5-Unofficial:5.09.51.85:dev") {transitive = false } compileOnly("com.github.GTNewHorizons:GT5-Unofficial:5.09.51.227:dev") {transitive = false }
compileOnly("com.github.GTNewHorizons:Botania:1.12.5-GTNH:api") {transitive = false } compileOnly("com.github.GTNewHorizons:Botania:1.12.6-GTNH:api") {transitive = false }
compileOnly("com.github.GTNewHorizons:ForestryMC:4.10.1:api") {transitive = false } compileOnly("com.github.GTNewHorizons:ForestryMC:4.10.5:api") {transitive = false }
compileOnly("com.github.GTNewHorizons:ForgeMultipart:1.6.2:dev") {transitive = false } compileOnly("com.github.GTNewHorizons:ForgeMultipart:1.6.2:dev") {transitive = false }
compileOnly("com.github.GTNewHorizons:Chisel:2.16.2-GTNH:api") {transitive = false } compileOnly("com.github.GTNewHorizons:Chisel:2.16.2-GTNH:api") {transitive = false }
compileOnly("com.github.GTNewHorizons:ZenScript:1.0.0-GTNH") {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.4.1:dev") {transitive = false }
compileOnly("thaumcraft:Thaumcraft:1.7.10-4.2.3.5: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 } compileOnly("curse.maven:guide-api-228832:2287185") {transitive = false }
+1 -1
View File
@@ -14,7 +14,7 @@ modId = AWWayofTime
modGroup = WayofTime.alchemicalWizardry modGroup = WayofTime.alchemicalWizardry
# Whether to use modGroup as the maven publishing group. # Whether to use modGroup as the maven publishing group.
# Due to a history of using JitPack, the default is com.github.GTNewHorizons for all mods. # When false, com.github.GTNewHorizons is used.
useModGroupForPublishing = false useModGroupForPublishing = false
# Updates your build.gradle and settings.gradle automatically whenever an update is available. # Updates your build.gradle and settings.gradle automatically whenever an update is available.
Binary file not shown.
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
networkTimeout=10000 networkTimeout=10000
validateDistributionUrl=true validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
Vendored
+2 -3
View File
@@ -86,8 +86,7 @@ done
# shellcheck disable=SC2034 # shellcheck disable=SC2034
APP_BASE_NAME=${0##*/} APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) # 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 APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum MAX_FD=maximum
@@ -206,7 +205,7 @@ fi
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command: # Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped. # and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line. # treated as '${Hostname}' itself on the command line.
+1 -1
View File
@@ -17,7 +17,7 @@ pluginManagement {
} }
plugins { plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.31' id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.38'
} }
@@ -665,10 +665,19 @@ public class BloodMagicConfiguration {
new BlockStack(ModBlocks.bloodRune, 6) }); new BlockStack(ModBlocks.bloodRune, 6) });
AlchemicalWizardry.specialAltarBlock = getAltarRunesForTier( AlchemicalWizardry.specialAltarBlock = getAltarRunesForTier(
"specialBlocks", "specialBlocks",
new BlockStack[] { new BlockStack(Blocks.stonebrick, 0), new BlockStack(Blocks.glowstone, 0), new BlockStack[] { new BlockStack(Blocks.air, 0), new BlockStack(Blocks.glowstone, 0),
new BlockStack(Blocks.stonebrick, 0), new BlockStack(ModBlocks.largeBloodStoneBrick, 0), new BlockStack(Blocks.air, 0), new BlockStack(ModBlocks.largeBloodStoneBrick, 0),
new BlockStack(Blocks.beacon, 0), new BlockStack(Blocks.stonebrick, 0), new BlockStack(Blocks.beacon, 0), new BlockStack(Blocks.air, 0),
new BlockStack(ModBlocks.blockCrystal, 0) }); new BlockStack(ModBlocks.blockCrystal, 0) },
"Set the special blocks for the altar with the format mod:block(:meta) in the following order:\n"
+ "Tier 3 pillar\n"
+ "Tier 3 cap\n"
+ "Tier 4 pillar\n"
+ "Tier 4 cap\n"
+ "Tier 5 beacon\n"
+ "Tier 6 pillar\n"
+ "Tier 6 cap\n"
+ "Set any of these to minecraft:air to allow for that component to be any block EXCEPT air (e.g., let any block be used for a pillar).");
config.save(); config.save();
} }
@@ -808,12 +817,16 @@ public class BloodMagicConfiguration {
} }
private static BlockStack[] getAltarRunesForTier(String tierName, BlockStack[] defaultValues) { private static BlockStack[] getAltarRunesForTier(String tierName, BlockStack[] defaultValues) {
return getAltarRunesForTier(tierName, defaultValues, "");
}
private static BlockStack[] getAltarRunesForTier(String tierName, BlockStack[] defaultValues, String comment) {
String[] defaultNames = new String[defaultValues.length]; String[] defaultNames = new String[defaultValues.length];
for (int i = 0; i < defaultValues.length; i++) { for (int i = 0; i < defaultValues.length; i++) {
defaultNames[i] = Block.blockRegistry.getNameForObject(defaultValues[i].getBlock()) + ":" defaultNames[i] = Block.blockRegistry.getNameForObject(defaultValues[i].getBlock()) + ":"
+ defaultValues[i].getMeta(); + defaultValues[i].getMeta();
} }
Property property = config.get("rune overrides", tierName, defaultNames); Property property = config.get("rune overrides", tierName, defaultNames, comment);
String[] names = property.getStringList(); String[] names = property.getStringList();
if (names.length != defaultNames.length) { if (names.length != defaultNames.length) {
property.set(defaultNames); property.set(defaultNames);
@@ -13,6 +13,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n; import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.oredict.OreDictionary;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
@@ -173,7 +174,7 @@ public class NEIMeteorRecipeHandler extends TemplateRecipeHandler {
if (meteor.ores.stream().anyMatch(m -> matchItem(result, m.getBlock()))) { if (meteor.ores.stream().anyMatch(m -> matchItem(result, m.getBlock()))) {
arecipes.add(new CachedMeteorRecipe(meteor, result)); arecipes.add(new CachedMeteorRecipe(meteor, result));
} }
if (meteor.filler.stream().anyMatch(m -> matchItem(result, m.getBlock()))) { if (meteor.fillerChance > 0 && meteor.filler.stream().anyMatch(m -> matchItem(result, m.getBlock()))) {
arecipes.add(new CachedMeteorRecipe(meteor, result)); arecipes.add(new CachedMeteorRecipe(meteor, result));
} }
} }
@@ -193,11 +194,34 @@ public class NEIMeteorRecipeHandler extends TemplateRecipeHandler {
if (NEIServerUtils.areStacksSameTypeCrafting(compared, compareTo)) { if (NEIServerUtils.areStacksSameTypeCrafting(compared, compareTo)) {
return true; return true;
} }
// ignore ore variants (like basalt ore)
// Ignore GregTech ore variants (like basalt ore)
if (compared.getUnlocalizedName().startsWith("gt.blockores") if (compared.getUnlocalizedName().startsWith("gt.blockores")
&& compareTo.getUnlocalizedName().startsWith("gt.blockores")) { && compareTo.getUnlocalizedName().startsWith("gt.blockores")) {
return compared.getItemDamage() % 1000 == compareTo.getItemDamage() % 1000; return compared.getItemDamage() % 1000 == compareTo.getItemDamage() % 1000;
} }
// Check oredicts for ores. Checks for direct matches (oreIron with oreIron) as well as IC2/GT crushed ores
// (crushedGold with oreGold), EFR raw ores (rawCopper with oreCopper (although those all seem to have oreX
// anyways)), and GT:NH raw ores (rawOreDiamond with oreDiamond).
String[] prefixes = { "crushed", "rawOre", "raw" };
for (int i : OreDictionary.getOreIDs(compareTo)) {
String s1 = OreDictionary.getOreName(i);
if (s1.startsWith("ore")) {
for (int j : OreDictionary.getOreIDs(compared)) {
if (i == j) {
return true;
}
String s2 = OreDictionary.getOreName(j);
for (String prefix : prefixes) {
if (i == OreDictionary.getOreID(s2.replaceFirst("^" + prefix, "ore"))) {
return true;
}
}
}
}
}
return false; return false;
} }
@@ -5,6 +5,7 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
@@ -65,9 +66,14 @@ public class UpgradedAltars {
private static boolean checkAltarComponent(AltarComponent altarComponent, IBlockAccess world, int x, int y, int z, private static boolean checkAltarComponent(AltarComponent altarComponent, IBlockAccess world, int x, int y, int z,
int altarTier) { int altarTier) {
Block block = world.getBlock(x + altarComponent.getX(), y + altarComponent.getY(), z + altarComponent.getZ()); int compX = x + altarComponent.getX();
int metadata = world int compY = y + altarComponent.getY();
.getBlockMetadata(x + altarComponent.getX(), y + altarComponent.getY(), z + altarComponent.getZ()); int compZ = z + altarComponent.getZ();
if (altarComponent.getBlock() == Blocks.air) {
return !world.isAirBlock(compX, compY, compZ);
}
Block block = world.getBlock(compX, compY, compZ);
int metadata = world.getBlockMetadata(compX, compY, compZ);
if (altarComponent.isBloodRune()) { if (altarComponent.isBloodRune()) {
boolean result = false; boolean result = false;
BlockStack[] runes = getRuneOverrides(altarTier); BlockStack[] runes = getRuneOverrides(altarTier);
@@ -18,10 +18,15 @@ import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
public class RitualEffectLeap extends RitualEffect { public class RitualEffectLeap extends RitualEffect {
// Throws mobs with twice the horizontal speed
public static final int aetherDrain = 10; public static final int aetherDrain = 10;
// Throws mobs with half the vertical speed
public static final int terraeDrain = 10; public static final int terraeDrain = 10;
// Grants 3 seconds of fall immunity
public static final int reductusDrain = 10; public static final int reductusDrain = 10;
// Only throws adults (and non-sneaking players)
public static final int tenebraeDrain = 10; public static final int tenebraeDrain = 10;
// Only throws babies (and non-sneaking players)
public static final int sanctusDrain = 10; public static final int sanctusDrain = 10;
@Override @Override
@@ -39,152 +44,107 @@ public class RitualEffectLeap extends RitualEffect {
List<EntityLivingBase> livingList = SpellHelper List<EntityLivingBase> livingList = SpellHelper
.getLivingEntitiesInRange(world, x + 0.5, y + 0.5, z + 0.5, range, range); .getLivingEntitiesInRange(world, x + 0.5, y + 0.5, z + 0.5, range, range);
if (livingList == null) { if (livingList == null || livingList.isEmpty()) {
return; return;
} }
if (currentEssence < this.getCostPerRefresh() * livingList.size()) { if (currentEssence < this.getCostPerRefresh() * livingList.size()) {
SoulNetworkHandler.causeNauseaToPlayer(owner); SoulNetworkHandler.causeNauseaToPlayer(owner);
} else { return;
boolean hasAether = this.canDrainReagent(ritualStone, ReagentRegistry.aetherReagent, aetherDrain, false); }
boolean hasTerrae = this.canDrainReagent(ritualStone, ReagentRegistry.terraeReagent, terraeDrain, false);
boolean hasReductus = this
.canDrainReagent(ritualStone, ReagentRegistry.reductusReagent, reductusDrain, false);
boolean hasTenebrae = this
.canDrainReagent(ritualStone, ReagentRegistry.tenebraeReagent, tenebraeDrain, false);
boolean hasSanctus = this.canDrainReagent(ritualStone, ReagentRegistry.sanctusReagent, sanctusDrain, false);
int direction = ritualStone.getDirection(); boolean hasAether = true;
boolean hasTerrae = true;
boolean hasReductus = true;
boolean hasTenebrae = true;
boolean hasSanctus = true;
int flag = 0; int direction = ritualStone.getDirection();
for (EntityLivingBase livingEntity : livingList) { int count = 0;
if (livingEntity.isSneaking()) {
continue; for (EntityLivingBase livingEntity : livingList) {
if (livingEntity.isSneaking()) {
continue;
}
hasReductus = hasReductus
&& this.canDrainReagent(ritualStone, ReagentRegistry.reductusReagent, reductusDrain, false);
hasTenebrae = hasTenebrae
&& this.canDrainReagent(ritualStone, ReagentRegistry.tenebraeReagent, tenebraeDrain, false);
hasSanctus = hasSanctus
&& this.canDrainReagent(ritualStone, ReagentRegistry.sanctusReagent, sanctusDrain, false);
// Sanctus only makes it work on children and tenebrae only with adults.
// Both being present prevents the ritual from working for any NPCs.
if (((hasSanctus && !livingEntity.isChild()) || (hasTenebrae && livingEntity.isChild()))
&& !(livingEntity instanceof EntityPlayer)) {
continue;
}
hasAether = hasAether
&& this.canDrainReagent(ritualStone, ReagentRegistry.aetherReagent, aetherDrain, true);
hasTerrae = hasTerrae
&& this.canDrainReagent(ritualStone, ReagentRegistry.terraeReagent, terraeDrain, true);
double motionY = hasTerrae ? 0.6 : 1.2;
double speed = hasAether ? 6.0 : 3.0;
livingEntity.motionY = motionY;
livingEntity.fallDistance = 0;
count++;
if (livingEntity instanceof EntityPlayer) {
switch (direction) {
case 1:
SpellHelper.setPlayerSpeedFromServer((EntityPlayer) livingEntity, 0, motionY, -speed);
break;
case 2:
SpellHelper.setPlayerSpeedFromServer((EntityPlayer) livingEntity, speed, motionY, 0);
break;
case 3:
SpellHelper.setPlayerSpeedFromServer((EntityPlayer) livingEntity, 0, motionY, speed);
break;
case 4:
SpellHelper.setPlayerSpeedFromServer((EntityPlayer) livingEntity, -speed, motionY, 0);
break;
}
} else {
switch (direction) {
case 1:
livingEntity.motionX = 0.0;
livingEntity.motionZ = -speed;
break;
case 2:
livingEntity.motionX = speed;
livingEntity.motionZ = 0.0;
break;
case 3:
livingEntity.motionX = 0.0;
livingEntity.motionZ = speed;
break;
case 4:
livingEntity.motionX = -speed;
livingEntity.motionZ = 0.0;
break;
} }
hasAether = hasAether if (hasTenebrae) {
&& this.canDrainReagent(ritualStone, ReagentRegistry.aetherReagent, aetherDrain, false); this.canDrainReagent(ritualStone, ReagentRegistry.tenebraeReagent, tenebraeDrain, true);
hasTerrae = hasTerrae } else if (hasSanctus) {
&& this.canDrainReagent(ritualStone, ReagentRegistry.terraeReagent, terraeDrain, false); this.canDrainReagent(ritualStone, ReagentRegistry.sanctusReagent, sanctusDrain, true);
hasReductus = hasReductus
&& this.canDrainReagent(ritualStone, ReagentRegistry.reductusReagent, reductusDrain, false);
hasTenebrae = hasTenebrae
&& this.canDrainReagent(ritualStone, ReagentRegistry.tenebraeReagent, tenebraeDrain, false);
hasSanctus = hasSanctus
&& this.canDrainReagent(ritualStone, ReagentRegistry.sanctusReagent, sanctusDrain, false);
double motionY = hasTerrae ? 0.6 : 1.2;
double speed = hasAether ? 6.0 : 3.0;
if (!(hasTenebrae || hasSanctus) || livingEntity instanceof EntityPlayer) {
livingEntity.motionY = motionY;
livingEntity.fallDistance = 0;
if (livingEntity instanceof EntityPlayer) {
switch (direction) {
case 1:
SpellHelper.setPlayerSpeedFromServer((EntityPlayer) livingEntity, 0, motionY, -speed);
break;
case 2:
SpellHelper.setPlayerSpeedFromServer((EntityPlayer) livingEntity, speed, motionY, 0);
break;
case 3:
SpellHelper.setPlayerSpeedFromServer((EntityPlayer) livingEntity, 0, motionY, speed);
break;
case 4:
SpellHelper.setPlayerSpeedFromServer((EntityPlayer) livingEntity, -speed, motionY, 0);
break;
}
} else {
livingEntity.motionY = motionY;
switch (direction) {
case 1:
livingEntity.motionX = 0.0;
livingEntity.motionZ = -speed;
break;
case 2:
livingEntity.motionX = speed;
livingEntity.motionZ = 0.0;
break;
case 3:
livingEntity.motionX = 0.0;
livingEntity.motionZ = -speed;
break;
case 4:
livingEntity.motionX = -speed;
livingEntity.motionZ = 0.0;
break;
}
}
flag++;
} else {
if ((hasSanctus && !livingEntity.isChild()) || (hasTenebrae && livingEntity.isChild())) {
continue;
}
livingEntity.motionY = motionY;
switch (direction) {
case 1:
livingEntity.motionX = 0.0;
livingEntity.motionZ = -speed;
break;
case 2:
livingEntity.motionX = speed;
livingEntity.motionZ = 0.0;
break;
case 3:
livingEntity.motionX = 0.0;
livingEntity.motionZ = -speed;
break;
case 4:
livingEntity.motionX = -speed;
livingEntity.motionZ = 0.0;
break;
}
if (hasTenebrae) {
this.canDrainReagent(ritualStone, ReagentRegistry.tenebraeReagent, tenebraeDrain, true);
}
if (hasSanctus) {
this.canDrainReagent(ritualStone, ReagentRegistry.sanctusReagent, sanctusDrain, true);
}
livingEntity.fallDistance = 0;
flag++;
}
if (hasAether) {
this.canDrainReagent(ritualStone, ReagentRegistry.aetherReagent, aetherDrain, true);
}
if (hasTerrae) {
this.canDrainReagent(ritualStone, ReagentRegistry.terraeReagent, terraeDrain, true);
}
if (hasReductus) {
if (!livingEntity.isPotionActive(AlchemicalWizardry.customPotionFeatherFall)) {
livingEntity.addPotionEffect(
new PotionEffect(AlchemicalWizardry.customPotionFeatherFall.id, 3 * 20, 0));
this.canDrainReagent(ritualStone, ReagentRegistry.reductusReagent, reductusDrain, true);
}
} }
} }
if (flag > 0) { if (hasReductus && !livingEntity.isPotionActive(AlchemicalWizardry.customPotionFeatherFall)) {
SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh() * flag); livingEntity
.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionFeatherFall.id, 3 * 20, 0));
this.canDrainReagent(ritualStone, ReagentRegistry.reductusReagent, reductusDrain, true);
} }
} }
if (count > 0) {
SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh() * count);
}
} }
@Override @Override
@@ -194,7 +154,7 @@ public class RitualEffectLeap extends RitualEffect {
@Override @Override
public List<RitualComponent> getRitualComponentList() { public List<RitualComponent> getRitualComponentList() {
ArrayList<RitualComponent> leapingRitual = new ArrayList(); ArrayList<RitualComponent> leapingRitual = new ArrayList<>();
leapingRitual.add(new RitualComponent(0, 0, -2, RitualComponent.DUSK)); leapingRitual.add(new RitualComponent(0, 0, -2, RitualComponent.DUSK));
leapingRitual.add(new RitualComponent(1, 0, -1, RitualComponent.AIR)); leapingRitual.add(new RitualComponent(1, 0, -1, RitualComponent.AIR));
leapingRitual.add(new RitualComponent(-1, 0, -1, RitualComponent.AIR)); leapingRitual.add(new RitualComponent(-1, 0, -1, RitualComponent.AIR));
@@ -0,0 +1,46 @@
package WayofTime.alchemicalWizardry.common.summoning.meteor;
import java.io.IOException;
import net.minecraft.item.ItemStack;
import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import cpw.mods.fml.common.registry.GameRegistry;
class ItemStackAdapter extends TypeAdapter<ItemStack> {
@Override
public ItemStack read(JsonReader reader) throws IOException {
String str = reader.nextString();
String[] input = str.split(":");
if (input.length < 2) {
AlchemicalWizardry.logger
.warn("Unable to read item stack \"{}\". Valid format is \"modid:name(:meta optional)\"", str);
return null;
}
ItemStack itemStack = GameRegistry.findItemStack(input[0], input[1], 1);
if (itemStack == null) {
AlchemicalWizardry.logger.warn("Unable to find item stack \"{}\".", str);
return null;
}
if (input.length < 3) {
return itemStack;
}
try {
itemStack.setItemDamage(Integer.parseInt(input[2]));
} catch (NumberFormatException e) {
AlchemicalWizardry.logger
.warn("Invalid metadata value {} for item stack {}:{}", input[2], input[0], input[1]);
}
return itemStack;
}
@Override
public void write(JsonWriter writer, ItemStack mpc) throws IOException {
// Not implemented because it is not needed.
}
}
@@ -8,7 +8,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import net.minecraft.init.Items;
import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
@@ -27,7 +26,7 @@ public class Meteor {
public int radius; public int radius;
public int cost; public int cost;
public float fillerChance; // Out of 100.0 public float fillerChance; // Out of 100.0
public transient ItemStack focusItem; public ItemStack focusItem;
private String focusModId; private String focusModId;
private String focusName; private String focusName;
private int focusMeta; private int focusMeta;
@@ -203,13 +202,17 @@ public class Meteor {
} }
/** /**
* Construct the focus item for this meteor from its modid, name, and metadata * Construct the focus item for this meteor from its modid, name, and metadata if using the old config format.
*/ */
private void buildFocusItem() { private void buildFocusItem() {
if (this.focusItem != null) return; if (this.focusItem != null) return;
this.focusItem = GameRegistry.findItemStack(this.focusModId, this.focusName, 1); this.focusItem = GameRegistry.findItemStack(this.focusModId, this.focusName, 1);
if (this.focusItem == null) return; if (this.focusItem == null) return;
Items.feather.setDamage(this.focusItem, this.focusMeta); this.focusItem.setItemDamage(this.focusMeta);
AlchemicalWizardry.logger.warn(
"Setting focusModId, focusName, and focusMeta individually in meteor"
+ "configs has been deprecated. Set \"focusItem\" with format \"modId:name(:meta optional)\""
+ " instead.");
} }
/** /**
@@ -14,7 +14,7 @@ class MeteorComponentAdapter extends TypeAdapter<MeteorComponent> {
} }
@Override @Override
public void write(JsonWriter writer, MeteorComponent mpc) throws IOException { public void write(JsonWriter writer, MeteorComponent component) throws IOException {
// Not implemented because it is not needed. // Not implemented because it is not needed.
} }
} }
@@ -24,7 +24,8 @@ public class MeteorRegistry {
public static void loadConfig() { public static void loadConfig() {
Gson gson = new GsonBuilder().setPrettyPrinting() Gson gson = new GsonBuilder().setPrettyPrinting()
.registerTypeAdapter(MeteorComponent.class, new MeteorComponentAdapter()).create(); .registerTypeAdapter(MeteorComponent.class, new MeteorComponentAdapter())
.registerTypeAdapter(ItemStack.class, new ItemStackAdapter()).create();
File file = new File("config/BloodMagic/meteors"); File file = new File("config/BloodMagic/meteors");
File[] files = file.listFiles(); File[] files = file.listFiles();
if (files != null) { if (files != null) {