mirror of
https://github.com/GTNewHorizons/BloodMagic.git
synced 2026-11-27 07:13:14 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1e4e8abb57 | ||
|
|
0c361f2482 | ||
|
|
d299b0a1b0 | ||
|
|
927e531af8 | ||
|
|
395f258893 | ||
|
|
56a268bcda | ||
|
|
329016558a | ||
|
|
dc710016aa | ||
|
|
78e3ca73a5 | ||
|
|
1c2a3049b6 | ||
|
|
0f380724f9 | ||
|
|
749b205a26 | ||
|
|
e0505b0726 | ||
|
|
c9272dc1c5 | ||
|
|
a1e224cf53 | ||
|
|
63a294bd54 | ||
|
|
447e8f5831 | ||
|
|
43925d2a3a | ||
|
|
0e3fd9f00a | ||
|
|
e234b53bfc | ||
|
|
f686f6f827 | ||
|
|
77969bb205 | ||
|
|
00c9c9bf49 | ||
|
|
62efdaf29d | ||
|
|
e40bde9c84 | ||
|
|
421478e6fa | ||
|
|
c99578e04d |
No files matched your search
@@ -3,9 +3,9 @@ name: Build and test
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ master, main ]
|
||||
branches: [ master, main, release/** ]
|
||||
push:
|
||||
branches: [ master, main ]
|
||||
branches: [ master, main, release/** ]
|
||||
|
||||
jobs:
|
||||
build-and-test:
|
||||
|
||||
@@ -41,4 +41,6 @@ dependencies {
|
||||
compileOnly("curse.maven:guide-api-228832:2287185") {transitive = false }
|
||||
compileOnly("curse.maven:endlessids-665730:7585931") {transitive = false }
|
||||
compileOnly("com.github.GTNewHorizons:StructureLib:1.4.45:dev")
|
||||
|
||||
compileOnly("com.ruling_0:MaterialLib:0.24.0-mu:dev") {transitive = false }
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
// Add any additional repositories for your dependencies here
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
}
|
||||
@@ -86,7 +86,6 @@ import WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon.EntityM
|
||||
import WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon.EntityMinorDemonGruntGuardianWind;
|
||||
import WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon.EntityMinorDemonGruntIce;
|
||||
import WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon.EntityMinorDemonGruntWind;
|
||||
import WayofTime.alchemicalWizardry.common.demonVillage.loot.DemonVillageLootRegistry;
|
||||
import WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.TEDemonChest;
|
||||
import WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.TEDemonPortal;
|
||||
import WayofTime.alchemicalWizardry.common.entity.mob.EntityAirElemental;
|
||||
@@ -3344,10 +3343,9 @@ public class AlchemicalWizardry {
|
||||
BloodMagicConfiguration.blacklistRituals();
|
||||
BloodMagicConfiguration.loadCustomLPValues();
|
||||
|
||||
DemonVillageLootRegistry.init();
|
||||
|
||||
MeteorRegistry.loadConfig();
|
||||
MeteorReagentRegistry.loadConfig();
|
||||
MeteorRegistry.logMaterialLibTally();
|
||||
|
||||
this.initCompressionHandlers();
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ public class BloodMagicConfiguration {
|
||||
The block to use for filler in meteors if none is provided in the meteor's config file and that
|
||||
meteor's fillerChance is greater than 0. Also used as a fallback for empty ore lists in meteor configs.
|
||||
Specify the block with the format:
|
||||
"modId:itemName:meta"
|
||||
"modId:itemName:meta", or "ml:material:shape" for a MaterialLib block.
|
||||
Defaults to minecraft:stone:0 if no block is provided or the provided block cannot be found.""");
|
||||
MeteorComponent.setDefaultMeteorBlock();
|
||||
AlchemicalWizardry.allowedCrushedOresArray = config.get(
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package WayofTime.alchemicalWizardry.api.alchemy;
|
||||
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class AlchemyRecipe {
|
||||
|
||||
private static final int MAX_INPUT_SLOTS = 5;
|
||||
|
||||
private final ItemStack output;
|
||||
private final ItemStack[] recipe;
|
||||
private final int bloodOrbLevel;
|
||||
@@ -23,35 +24,13 @@ public class AlchemyRecipe {
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemStack[] recipe;
|
||||
|
||||
if (items.length < 5) {
|
||||
if (items.length < MAX_INPUT_SLOTS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.recipe.length != 5) {
|
||||
ItemStack[] newRecipe = new ItemStack[5];
|
||||
boolean[] checkList = new boolean[MAX_INPUT_SLOTS];
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (i + 1 > this.recipe.length) {
|
||||
newRecipe[i] = null;
|
||||
} else {
|
||||
newRecipe[i] = this.recipe[i];
|
||||
}
|
||||
}
|
||||
|
||||
recipe = newRecipe;
|
||||
} else {
|
||||
recipe = this.recipe;
|
||||
}
|
||||
|
||||
boolean[] checkList = new boolean[5];
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
checkList[i] = false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
for (int i = 0; i < Math.min(recipe.length, MAX_INPUT_SLOTS); i++) {
|
||||
ItemStack recipeItemStack = recipe[i];
|
||||
|
||||
if (recipeItemStack == null) {
|
||||
@@ -60,7 +39,7 @@ public class AlchemyRecipe {
|
||||
|
||||
boolean test = false;
|
||||
|
||||
for (int j = 0; j < 5; j++) {
|
||||
for (int j = 0; j < MAX_INPUT_SLOTS; j++) {
|
||||
if (checkList[j]) {
|
||||
continue;
|
||||
}
|
||||
@@ -71,20 +50,6 @@ public class AlchemyRecipe {
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean quickTest = false;
|
||||
|
||||
if (recipeItemStack.getItem() instanceof ItemBlock) {
|
||||
if (checkedItemStack.getItem() instanceof ItemBlock) {
|
||||
quickTest = true;
|
||||
}
|
||||
} else if (!(checkedItemStack.getItem() instanceof ItemBlock)) {
|
||||
quickTest = true;
|
||||
}
|
||||
|
||||
if (!quickTest) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((checkedItemStack.getItemDamage() == recipeItemStack.getItemDamage()
|
||||
|| OreDictionary.WILDCARD_VALUE == recipeItemStack.getItemDamage())
|
||||
&& checkedItemStack.getItem() == recipeItemStack.getItem()) {
|
||||
|
||||
@@ -15,7 +15,7 @@ public class AlchemyRecipeRegistry {
|
||||
recipes.add(new AlchemyRecipe(output, amountNeeded, recipe, bloodOrbLevel));
|
||||
}
|
||||
|
||||
public static ItemStack getResult(ItemStack[] recipe, ItemStack bloodOrb) {
|
||||
public static AlchemyRecipe findRecipe(ItemStack[] recipe, ItemStack bloodOrb) {
|
||||
if (bloodOrb == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -28,31 +28,23 @@ public class AlchemyRecipeRegistry {
|
||||
|
||||
for (AlchemyRecipe ar : recipes) {
|
||||
if (ar.doesRecipeMatch(recipe, bloodOrbLevel)) {
|
||||
return (ar.getResult());
|
||||
return ar;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ItemStack getResult(ItemStack[] recipe, ItemStack bloodOrb) {
|
||||
AlchemyRecipe ar = findRecipe(recipe, bloodOrb);
|
||||
|
||||
return ar == null ? null : ar.getResult();
|
||||
}
|
||||
|
||||
public static int getAmountNeeded(ItemStack[] recipe, ItemStack bloodOrb) {
|
||||
if (bloodOrb == null) {
|
||||
return 0;
|
||||
}
|
||||
AlchemyRecipe ar = findRecipe(recipe, bloodOrb);
|
||||
|
||||
if (!(bloodOrb.getItem() instanceof IBloodOrb)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bloodOrbLevel = ((IBloodOrb) bloodOrb.getItem()).getOrbLevel();
|
||||
|
||||
for (AlchemyRecipe ar : recipes) {
|
||||
if (ar.doesRecipeMatch(recipe, bloodOrbLevel)) {
|
||||
return (ar.getAmountNeeded());
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ar == null ? 0 : ar.getAmountNeeded();
|
||||
}
|
||||
|
||||
public static ItemStack[] getRecipeForItemStack(ItemStack itemStack) {
|
||||
|
||||
@@ -214,12 +214,6 @@ public class NEIMeteorRecipeHandler extends TemplateRecipeHandler {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Ignore GregTech ore variants (like basalt ore)
|
||||
if (compared.getUnlocalizedName().startsWith("gt.blockores")
|
||||
&& compareTo.getUnlocalizedName().startsWith("gt.blockores")) {
|
||||
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).
|
||||
|
||||
@@ -11,6 +11,7 @@ import java.util.stream.IntStream;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
@@ -34,6 +35,7 @@ import WayofTime.alchemicalWizardry.common.tileEntity.TESocket;
|
||||
import WayofTime.alchemicalWizardry.common.tileEntity.TETeleposer;
|
||||
import WayofTime.alchemicalWizardry.common.tileEntity.TEWritingTable;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import cpw.mods.fml.common.network.FMLEmbeddedChannel;
|
||||
import cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec;
|
||||
import cpw.mods.fml.common.network.FMLOutboundHandler;
|
||||
@@ -106,7 +108,7 @@ public enum NewPacketHandler {
|
||||
World world = AlchemicalWizardry.proxy.getClientWorld();
|
||||
TileEntity te = world.getTileEntity(msg.x, msg.y, msg.z);
|
||||
if (te instanceof TEAltar altar) {
|
||||
altar.handlePacketData(msg.items, msg.fluids, msg.capacity);
|
||||
altar.handlePacketData(msg.itemStack, msg.fluids, msg.capacity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -317,7 +319,7 @@ public enum NewPacketHandler {
|
||||
int y;
|
||||
int z;
|
||||
|
||||
int[] items;
|
||||
ItemStack itemStack;
|
||||
int[] fluids;
|
||||
int capacity;
|
||||
}
|
||||
@@ -482,11 +484,7 @@ public enum NewPacketHandler {
|
||||
target.writeInt(m.y);
|
||||
target.writeInt(m.z);
|
||||
|
||||
target.writeBoolean(m.items != null);
|
||||
if (m.items != null) {
|
||||
int[] items = m.items;
|
||||
Arrays.stream(items).forEach(target::writeInt);
|
||||
}
|
||||
ByteBufUtils.writeItemStack(target, m.itemStack);
|
||||
|
||||
target.writeBoolean(m.fluids != null);
|
||||
if (m.fluids != null) {
|
||||
@@ -658,13 +656,8 @@ public enum NewPacketHandler {
|
||||
m.x = dat.readInt();
|
||||
m.y = dat.readInt();
|
||||
m.z = dat.readInt();
|
||||
boolean hasStacks = dat.readBoolean();
|
||||
|
||||
m.items = new int[TEAltar.sizeInv * 3];
|
||||
if (hasStacks) {
|
||||
m.items = new int[TEAltar.sizeInv * 3];
|
||||
IntStream.range(0, m.items.length).forEach(i -> m.items[i] = dat.readInt());
|
||||
}
|
||||
m.itemStack = ByteBufUtils.readItemStack(dat);
|
||||
|
||||
boolean hasFluids = dat.readBoolean();
|
||||
m.fluids = new int[6];
|
||||
@@ -841,7 +834,7 @@ public enum NewPacketHandler {
|
||||
msg.x = tileAltar.xCoord;
|
||||
msg.y = tileAltar.yCoord;
|
||||
msg.z = tileAltar.zCoord;
|
||||
msg.items = tileAltar.buildIntDataList();
|
||||
msg.itemStack = tileAltar.getStackInSlot(0);
|
||||
msg.fluids = tileAltar.buildFluidList();
|
||||
msg.capacity = tileAltar.getCapacity();
|
||||
|
||||
|
||||
@@ -6,9 +6,6 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Facing;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
@@ -72,34 +69,7 @@ public class SpectralBlock extends BlockContainer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int idk, float what,
|
||||
float these, float are) {
|
||||
if (player.isSneaking()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemStack playerItem = player.getCurrentEquippedItem();
|
||||
|
||||
if (playerItem != null) {
|
||||
if (playerItem.getItem() instanceof ItemBlock) {
|
||||
world.setBlock(
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
((ItemBlock) (playerItem.getItem())).field_150939_a,
|
||||
playerItem.getItemDamage(),
|
||||
3);
|
||||
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
playerItem.stackSize--;
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isReplaceable(IBlockAccess world, int x, int y, int z) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+7
-1
@@ -13,8 +13,13 @@ import WayofTime.alchemicalWizardry.ModItems;
|
||||
public class DemonVillageLootRegistry {
|
||||
|
||||
public static ArrayList<WeightedRandomChestContent> list1 = new ArrayList<>();
|
||||
private static boolean built = false;
|
||||
|
||||
public static void init() {
|
||||
/// Copies the dungeon and desert-pyramid loot on first use rather than while loading, so the copy carries every
|
||||
/// change other mods make to those tables during loading.
|
||||
private static void build() {
|
||||
if (built) return;
|
||||
built = true;
|
||||
String[] tier1Strings = new String[] { ChestGenHooks.DUNGEON_CHEST, ChestGenHooks.PYRAMID_DESERT_CHEST };
|
||||
for (String str : tier1Strings) {
|
||||
WeightedRandomChestContent[] contents = ChestGenHooks.getItems(str, new Random());
|
||||
@@ -30,6 +35,7 @@ public class DemonVillageLootRegistry {
|
||||
}
|
||||
|
||||
public static void populateChest(IInventory tile, int tier) {
|
||||
build();
|
||||
WeightedRandomChestContent
|
||||
.generateChestContents(new Random(), toArray(list1), tile, tile.getSizeInventory() / 3);
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ public class BoundAxe extends ItemAxe implements IBindable {
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
setEnergyUsed(5);
|
||||
this.setHarvestLevel("axe", 7);
|
||||
setMaxDamage(0);
|
||||
}
|
||||
|
||||
public void setEnergyUsed(int i) {
|
||||
@@ -143,7 +144,6 @@ public class BoundAxe extends ItemAxe implements IBindable {
|
||||
}
|
||||
|
||||
checkPassiveDrain(item, world, player);
|
||||
item.setItemDamage(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,7 +28,6 @@ import WayofTime.alchemicalWizardry.common.ItemType;
|
||||
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import gregtech.common.blocks.GTBlockOre;
|
||||
|
||||
public class BoundPickaxe extends ItemPickaxe implements IBindable {
|
||||
|
||||
@@ -49,6 +48,7 @@ public class BoundPickaxe extends ItemPickaxe implements IBindable {
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
this.setEnergyUsed(5);
|
||||
setHarvestLevel("pickaxe", 7);
|
||||
setMaxDamage(0);
|
||||
}
|
||||
|
||||
public void setEnergyUsed(int i) {
|
||||
@@ -124,13 +124,7 @@ public class BoundPickaxe extends ItemPickaxe implements IBindable {
|
||||
if (silkTouch && block.canSilkHarvest(world, player, x, y, z, meta)) {
|
||||
dropMultiset.add(new ItemType(block, meta));
|
||||
} else {
|
||||
ArrayList<ItemStack> itemDropList;
|
||||
if (AlchemicalWizardry.isGregTech5UnofficialNewHorizonsLoaded
|
||||
&& block instanceof GTBlockOre ore) {
|
||||
itemDropList = ore.getDropsForPlayer(world, x, y, z, meta, fortuneLvl, player);
|
||||
} else {
|
||||
itemDropList = block.getDrops(world, x, y, z, meta, fortuneLvl);
|
||||
}
|
||||
ArrayList<ItemStack> itemDropList = block.getDrops(world, x, y, z, meta, fortuneLvl);
|
||||
|
||||
if (itemDropList != null) {
|
||||
for (ItemStack stack : itemDropList)
|
||||
@@ -183,7 +177,6 @@ public class BoundPickaxe extends ItemPickaxe implements IBindable {
|
||||
}
|
||||
|
||||
checkPassiveDrain(item, world, player);
|
||||
item.setItemDamage(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,7 +11,6 @@ import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemSpade;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.util.Vec3;
|
||||
@@ -46,6 +45,7 @@ public class BoundShovel extends ItemSpade implements IBindable {
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
setEnergyUsed(5);
|
||||
setHarvestLevel("shovel", 7);
|
||||
setMaxDamage(0);
|
||||
}
|
||||
|
||||
public void setEnergyUsed(int i) {
|
||||
@@ -145,13 +145,7 @@ public class BoundShovel extends ItemSpade implements IBindable {
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.getTagCompound() == null) {
|
||||
item.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
checkPassiveDrain(item, world, player);
|
||||
|
||||
item.setItemDamage(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,7 +34,7 @@ public class EnergySword extends ItemSword implements IBindable {
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
setEnergyUsed(50);
|
||||
setFull3D();
|
||||
setMaxDamage(100);
|
||||
setMaxDamage(0);
|
||||
}
|
||||
|
||||
public void setEnergyUsed(int i) {
|
||||
@@ -106,7 +106,6 @@ public class EnergySword extends ItemSword implements IBindable {
|
||||
}
|
||||
|
||||
checkPassiveDrain(item, world, player);
|
||||
item.setItemDamage(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,7 +23,6 @@ import WayofTime.alchemicalWizardry.api.rituals.RitualEffect;
|
||||
import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
|
||||
import WayofTime.alchemicalWizardry.common.ItemType;
|
||||
import WayofTime.alchemicalWizardry.common.block.BlockTeleposer;
|
||||
import gregtech.common.blocks.GTBlockOre;
|
||||
|
||||
public class RitualEffectMagnetic extends RitualEffect {
|
||||
|
||||
@@ -35,8 +34,7 @@ public class RitualEffectMagnetic extends RitualEffect {
|
||||
|
||||
public static boolean isBlockOre(Block block, int meta) {
|
||||
// Special case for lit redstone ore
|
||||
if (block instanceof BlockOre || block instanceof BlockRedstoneOre
|
||||
|| (AlchemicalWizardry.isGregTech5UnofficialNewHorizonsLoaded && block instanceof GTBlockOre)) {
|
||||
if (block instanceof BlockOre || block instanceof BlockRedstoneOre) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+13
@@ -22,6 +22,19 @@ class ItemStackAdapter extends TypeAdapter<ItemStack> {
|
||||
.warn("Unable to read item stack \"{}\". Valid format is \"modid:name(:meta optional)\"", str);
|
||||
return null;
|
||||
}
|
||||
if (input[0].equals("ml")) {
|
||||
if (input.length != 3) {
|
||||
AlchemicalWizardry.logger.warn(
|
||||
"Unable to read item stack \"{}\". Valid MaterialLib format is \"ml:material:shape\"",
|
||||
str);
|
||||
return null;
|
||||
}
|
||||
ItemStack resolved = MeteorRegistry.resolveMaterialLibStack(input[1], input[2]);
|
||||
if (resolved == null) {
|
||||
AlchemicalWizardry.logger.warn("Unable to find item stack \"{}\".", str);
|
||||
}
|
||||
return resolved;
|
||||
}
|
||||
ItemStack itemStack = GameRegistry.findItemStack(input[0], input[1], 1);
|
||||
if (itemStack == null) {
|
||||
AlchemicalWizardry.logger.warn("Unable to find item stack \"{}\".", str);
|
||||
|
||||
+46
-3
@@ -18,13 +18,19 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
||||
public class MeteorComponent {
|
||||
|
||||
private final int weight;
|
||||
private final ItemStack itemStack;
|
||||
private ItemStack itemStack;
|
||||
private final String materialName;
|
||||
private final String shapeToken;
|
||||
private final ArrayList<Reagent> reagent;
|
||||
public static MeteorComponent defaultMeteorBlock;
|
||||
|
||||
public static void setDefaultMeteorBlock() {
|
||||
String string = AlchemicalWizardry.defaultMeteorBlock;
|
||||
String[] split = string.split(":");
|
||||
if (split.length == 3 && split[0].equals("ml")) {
|
||||
defaultMeteorBlock = new MeteorComponent(split[1], split[2]);
|
||||
return;
|
||||
}
|
||||
ItemStack stack = null;
|
||||
if (!string.isEmpty() && split.length >= 3) {
|
||||
stack = GameRegistry.findItemStack(split[0], split[1], 1);
|
||||
@@ -43,10 +49,22 @@ public class MeteorComponent {
|
||||
|
||||
public MeteorComponent(ItemStack stack, int weight, ArrayList<Reagent> reagent) {
|
||||
this.itemStack = stack;
|
||||
this.materialName = null;
|
||||
this.shapeToken = null;
|
||||
this.weight = weight;
|
||||
this.reagent = reagent;
|
||||
}
|
||||
|
||||
/// The default meteor block named as `ml:<Material>:<shape>`. Its stack is resolved on the first [#getBlock]
|
||||
/// call -- the config is read at preInit, before MaterialLib resolves its shapes.
|
||||
private MeteorComponent(String materialName, String shapeToken) {
|
||||
this.itemStack = null;
|
||||
this.materialName = materialName;
|
||||
this.shapeToken = shapeToken;
|
||||
this.weight = 1;
|
||||
this.reagent = new ArrayList<>();
|
||||
}
|
||||
|
||||
public static List<MeteorComponent> parseStringArray(String[] blockArray) {
|
||||
List<MeteorComponent> addList = new ArrayList<>();
|
||||
if (blockArray == null) {
|
||||
@@ -65,10 +83,25 @@ public class MeteorComponent {
|
||||
private static final Pattern itemNamePattern = Pattern.compile("(.*):(.*):(\\d+):(\\d+)(:.*)?");
|
||||
// OREDICT:oreDictName:weight(:reagent1, reagent2, ... optional)
|
||||
private static final Pattern oredictPattern = Pattern.compile("OREDICT:(.*):(\\d+)(:.*)?");
|
||||
// ml:material:shape:weight(:reagent1, reagent2, ... optional)
|
||||
private static final Pattern materialLibPattern = Pattern.compile("ml:([^:]+):([^:]+):(\\d+)(:.*)?");
|
||||
|
||||
public static MeteorComponent parseString(String blockName) {
|
||||
Matcher matcher = itemNamePattern.matcher(blockName);
|
||||
Matcher matcher = materialLibPattern.matcher(blockName);
|
||||
if (matcher.matches()) {
|
||||
String materialName = matcher.group(1);
|
||||
String shapeToken = matcher.group(2);
|
||||
int weight = Integer.parseInt(matcher.group(3));
|
||||
String reagent = matcher.group(4);
|
||||
|
||||
ArrayList<Reagent> reagentList = MeteorReagent.parseReagents(reagent, blockName);
|
||||
|
||||
ItemStack stack = MeteorRegistry.resolveMaterialLibStack(materialName, shapeToken);
|
||||
if (stack != null && stack.getItem() instanceof ItemBlock) {
|
||||
return new MeteorComponent(stack, weight, reagentList);
|
||||
}
|
||||
|
||||
} else if ((matcher = itemNamePattern.matcher(blockName)).matches()) {
|
||||
String modID = matcher.group(1);
|
||||
String itemName = matcher.group(2);
|
||||
int meta = Integer.parseInt(matcher.group(3));
|
||||
@@ -100,7 +133,7 @@ public class MeteorComponent {
|
||||
}
|
||||
AlchemicalWizardry.logger.warn("Unable to add Meteor Component \"{}\"", blockName);
|
||||
AlchemicalWizardry.logger.warn(
|
||||
"Valid formats are \"modId:itemName:meta:weight(:reagent1, reagent2, ... optional)\" and \"OREDICT:oreDictName:weight(:reagent1, reagent2, ... optional)\".");
|
||||
"Valid formats are \"modId:itemName:meta:weight(:reagent1, reagent2, ... optional)\", \"OREDICT:oreDictName:weight(:reagent1, reagent2, ... optional)\" and \"ml:material:shape:weight(:reagent1, reagent2, ... optional)\".");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -117,6 +150,16 @@ public class MeteorComponent {
|
||||
}
|
||||
|
||||
public ItemStack getBlock() {
|
||||
if (itemStack == null && materialName != null) {
|
||||
itemStack = MeteorRegistry.resolveMaterialLibStack(materialName, shapeToken);
|
||||
if (itemStack == null || !(itemStack.getItem() instanceof ItemBlock)) {
|
||||
AlchemicalWizardry.logger.warn(
|
||||
"Unable to use \"ml:{}:{}\" as the default meteor block, falling back to stone.",
|
||||
materialName,
|
||||
shapeToken);
|
||||
itemStack = new ItemStack(Blocks.stone);
|
||||
}
|
||||
}
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
|
||||
+28
@@ -17,11 +17,39 @@ import com.google.gson.JsonSyntaxException;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent;
|
||||
import WayofTime.alchemicalWizardry.compat.materiallib.MaterialLibStacks;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
|
||||
public class MeteorRegistry {
|
||||
|
||||
public static List<Meteor> meteorList = new ArrayList<>();
|
||||
|
||||
private static int materialLibResolved;
|
||||
private static int materialLibInvalid;
|
||||
|
||||
/// The stack a `ml:<Material>:<shape>` entry names, or null when MaterialLib is absent or the entry resolves to
|
||||
/// nothing. Counts the outcome into the tally [#logMaterialLibTally] reports.
|
||||
static ItemStack resolveMaterialLibStack(String materialName, String shapeToken) {
|
||||
ItemStack stack = Loader.isModLoaded("materiallib") ? MaterialLibStacks.getStack(materialName, shapeToken)
|
||||
: null;
|
||||
if (stack == null) {
|
||||
materialLibInvalid++;
|
||||
} else {
|
||||
materialLibResolved++;
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
/// Logs the `ml:` entry tally and clears it. Call once every config that can carry such entries is loaded.
|
||||
public static void logMaterialLibTally() {
|
||||
if (materialLibResolved + materialLibInvalid > 0) {
|
||||
AlchemicalWizardry.logger
|
||||
.info("Resolved {} MaterialLib entries ({} invalid)", materialLibResolved, materialLibInvalid);
|
||||
}
|
||||
materialLibResolved = 0;
|
||||
materialLibInvalid = 0;
|
||||
}
|
||||
|
||||
public static void loadConfig() {
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting()
|
||||
.registerTypeAdapter(MeteorComponent.class, new MeteorComponentAdapter())
|
||||
|
||||
@@ -5,7 +5,6 @@ import java.util.List;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.Packet;
|
||||
@@ -718,19 +717,8 @@ public class TEAltar extends TEInventory implements IFluidTank, IFluidHandler, I
|
||||
return NewPacketHandler.getPacket(this);
|
||||
}
|
||||
|
||||
public void handlePacketData(int[] intData, int[] fluidData, int capacity) {
|
||||
if (intData == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (intData.length == 3) {
|
||||
if (intData[2] != 0) {
|
||||
ItemStack is = new ItemStack(Item.getItemById(intData[0]), intData[2], intData[1]);
|
||||
inv[0] = is;
|
||||
} else {
|
||||
inv[0] = null;
|
||||
}
|
||||
}
|
||||
public void handlePacketData(ItemStack itemStack, int[] fluidData, int capacity) {
|
||||
inv[0] = itemStack == null ? null : itemStack.copy();
|
||||
|
||||
FluidStack flMain = new FluidStack(fluidData[0], fluidData[1]);
|
||||
FluidStack flIn = new FluidStack(fluidData[2], fluidData[3]);
|
||||
@@ -743,25 +731,6 @@ public class TEAltar extends TEInventory implements IFluidTank, IFluidHandler, I
|
||||
this.capacity = capacity;
|
||||
}
|
||||
|
||||
public int[] buildIntDataList() {
|
||||
int[] sortList = new int[3]; // 1 * 3
|
||||
int pos = 0;
|
||||
|
||||
for (ItemStack is : inv) {
|
||||
if (is != null) {
|
||||
sortList[pos++] = Item.getIdFromItem(is.getItem());
|
||||
sortList[pos++] = is.getItemDamage();
|
||||
sortList[pos++] = is.stackSize;
|
||||
} else {
|
||||
sortList[pos++] = 0;
|
||||
sortList[pos++] = 0;
|
||||
sortList[pos++] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return sortList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startCycle() {
|
||||
if (worldObj != null) {
|
||||
|
||||
@@ -540,14 +540,22 @@ public class TEWritingTable extends TEInventory implements ISidedInventory, IBlo
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!isRecipeValid()) {
|
||||
ItemStack[] composedRecipe = new ItemStack[5];
|
||||
|
||||
System.arraycopy(inv, 1, composedRecipe, 0, 5);
|
||||
|
||||
AlchemyRecipe recipe = AlchemyRecipeRegistry.findRecipe(composedRecipe, inv[0]);
|
||||
|
||||
if (recipe == null) {
|
||||
progress = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack result = recipe.getResult();
|
||||
|
||||
if (progress <= 0) {
|
||||
progress = 0;
|
||||
amountUsed = this.getAmountNeeded(getStackInSlot(0));
|
||||
amountUsed = recipe.getAmountNeeded();
|
||||
|
||||
if (worldObj != null) {
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
@@ -580,60 +588,50 @@ public class TEWritingTable extends TEInventory implements ISidedInventory, IBlo
|
||||
|
||||
if (progress >= progressNeeded) {
|
||||
progress = 0;
|
||||
this.setInventorySlotContents(6, getResultingItemStack());
|
||||
this.setInventorySlotContents(6, result.copy());
|
||||
|
||||
ItemStack[] composedRecipe = new ItemStack[5];
|
||||
|
||||
System.arraycopy(inv, 1, composedRecipe, 0, 5);
|
||||
|
||||
this.decrementSlots(this.getRecipeForItems(composedRecipe, inv[0]));
|
||||
this.decrementSlots(recipe.getRecipe());
|
||||
|
||||
if (worldObj != null) {
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
} else if (getStackInSlot(6).getItem() == getResultingItemStack().getItem()
|
||||
&& getResultingItemStack().stackSize
|
||||
<= (getStackInSlot(6).getMaxStackSize() - getStackInSlot(6).stackSize)) {
|
||||
if (worldTime % 4 == 0) {
|
||||
SpellHelper.sendIndexedParticleToAllAround(
|
||||
worldObj,
|
||||
xCoord,
|
||||
yCoord,
|
||||
zCoord,
|
||||
20,
|
||||
worldObj.provider.dimensionId,
|
||||
1,
|
||||
xCoord,
|
||||
yCoord,
|
||||
zCoord);
|
||||
}
|
||||
} else if (getStackInSlot(6).getItem() == result.getItem()
|
||||
&& result.stackSize <= (getStackInSlot(6).getMaxStackSize() - getStackInSlot(6).stackSize)) {
|
||||
if (worldTime % 4 == 0) {
|
||||
SpellHelper.sendIndexedParticleToAllAround(
|
||||
worldObj,
|
||||
xCoord,
|
||||
yCoord,
|
||||
zCoord,
|
||||
20,
|
||||
worldObj.provider.dimensionId,
|
||||
1,
|
||||
xCoord,
|
||||
yCoord,
|
||||
zCoord);
|
||||
}
|
||||
|
||||
if (!SoulNetworkHandler.syphonFromNetworkWhileInContainer(
|
||||
getStackInSlot(0),
|
||||
amountUsed * acceleration)) {
|
||||
return;
|
||||
}
|
||||
if (!SoulNetworkHandler
|
||||
.syphonFromNetworkWhileInContainer(getStackInSlot(0), amountUsed * acceleration)) {
|
||||
return;
|
||||
}
|
||||
|
||||
progress += acceleration;
|
||||
progress += acceleration;
|
||||
|
||||
if (progress >= progressNeeded) {
|
||||
progress = 0;
|
||||
ItemStack result = getResultingItemStack().copy();
|
||||
result.stackSize += getStackInSlot(6).stackSize;
|
||||
this.setInventorySlotContents(6, result);
|
||||
if (progress >= progressNeeded) {
|
||||
progress = 0;
|
||||
ItemStack mergedResult = result.copy();
|
||||
mergedResult.stackSize += getStackInSlot(6).stackSize;
|
||||
this.setInventorySlotContents(6, mergedResult);
|
||||
|
||||
ItemStack[] composedRecipe = new ItemStack[5];
|
||||
this.decrementSlots(recipe.getRecipe());
|
||||
|
||||
System.arraycopy(inv, 1, composedRecipe, 0, 5);
|
||||
|
||||
this.decrementSlots(this.getRecipeForItems(composedRecipe, inv[0]));
|
||||
|
||||
if (worldObj != null) {
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
if (worldObj != null) {
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -667,26 +665,6 @@ public class TEWritingTable extends TEInventory implements ISidedInventory, IBlo
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack[] getRecipeForItems(ItemStack[] recipe, ItemStack bloodOrb) {
|
||||
if (bloodOrb == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!(bloodOrb.getItem() instanceof IBloodOrb)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int bloodOrbLevel = ((IBloodOrb) bloodOrb.getItem()).getOrbLevel();
|
||||
|
||||
for (AlchemyRecipe ar : AlchemyRecipeRegistry.recipes) {
|
||||
if (ar.doesRecipeMatch(recipe, bloodOrbLevel)) {
|
||||
return ar.getRecipe();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getSpeedIncrease() {
|
||||
return accelerationTime > 0 ? 5 : 1;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package WayofTime.alchemicalWizardry.compat.materiallib;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.ruling_0.materiallib.api.StackResolver;
|
||||
|
||||
/// Resolves a MaterialLib item from a material name and a shape token.
|
||||
///
|
||||
/// MaterialLib types are named only in this class, so it loads only where `materiallib` is present.
|
||||
public final class MaterialLibStacks {
|
||||
|
||||
private MaterialLibStacks() {}
|
||||
|
||||
/// A single item of the named material in the named shape; see [StackResolver#getStack] for the naming rules and
|
||||
/// the null cases.
|
||||
public static ItemStack getStack(String materialName, String shapeToken) {
|
||||
return StackResolver.getStack(materialName, shapeToken, 1);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user