Added Pam's Harvestcraft support as well as a bit of stuff to help with ritual activation/deactivation.

This commit is contained in:
WayofTime 2014-09-23 19:28:05 -04:00
parent 5983ff4130
commit dcecd05b85
11 changed files with 316 additions and 34 deletions

View file

@ -66,6 +66,7 @@ import WayofTime.alchemicalWizardry.common.entity.mob.EntityWingedFireDemon;
import WayofTime.alchemicalWizardry.common.harvest.BloodMagicHarvestHandler;
import WayofTime.alchemicalWizardry.common.harvest.CactusReedHarvestHandler;
import WayofTime.alchemicalWizardry.common.harvest.GourdHarvestHandler;
import WayofTime.alchemicalWizardry.common.harvest.PamHarvestCompatRegistry;
import WayofTime.alchemicalWizardry.common.items.ItemRitualDiviner;
import WayofTime.alchemicalWizardry.common.items.sigil.SigilOfHolding;
import WayofTime.alchemicalWizardry.common.items.thaumcraft.ItemSanguineArmour;
@ -161,7 +162,7 @@ import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
@Mod(modid = "AWWayofTime", name = "AlchemicalWizardry", version = "v1.2.0Beta16")
@Mod(modid = "AWWayofTime", name = "AlchemicalWizardry", version = "v1.2.0Beta21")
//@NetworkMod(clientSideRequired = true, serverSideRequired = false, channels = {"BloodAltar", "particle", "SetLifeEssence", "GetLifeEssence", "Ritual", "GetAltarEssence", "TESocket", "TEWritingTable", "CustomParticle", "SetPlayerVel", "SetPlayerPos", "TEPedestal", "TEPlinth", "TETeleposer", "InfiniteLPPath", "TEOrientor"}, packetHandler = PacketHandler.class)
public class AlchemicalWizardry
@ -969,6 +970,12 @@ public class AlchemicalWizardry
this.isForestryLoaded = false;
}
if(Loader.isModLoaded("harvestcraft"))
{
PamHarvestCompatRegistry.registerPamHandlers();
System.out.println("Loaded Harvestcraft Handlers!");
}
BloodMagicConfiguration.loadBlacklist();
}

View file

@ -12,7 +12,6 @@ public class HarvestRegistry
public static void registerHarvestHandler(IHarvestHandler handler)
{
System.out.println("Heeeeelllooooo");
handlerList.add(handler);
}

View file

@ -2,6 +2,7 @@ package WayofTime.alchemicalWizardry.api.rituals;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.common.util.ForgeDirection;
import WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent;
import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentStack;
@ -9,6 +10,16 @@ import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentStack;
public abstract class RitualEffect
{
public abstract void performEffect(IMasterRitualStone ritualStone);
public boolean startRitual(IMasterRitualStone ritualStone, EntityPlayer player)
{
return true;
}
public void onRitualBroken(IMasterRitualStone ritualStone)
{
}
public abstract int getCostPerRefresh();

View file

@ -6,6 +6,7 @@ import java.util.List;
import java.util.Map;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.common.renderer.MRSRenderer;
@ -309,6 +310,32 @@ public class Rituals
}
}
}
public static boolean startRitual(IMasterRitualStone ritualStone, String ritualID, EntityPlayer player)
{
if(ritualMap.containsKey(ritualID))
{
Rituals ritual = ritualMap.get(ritualID);
if(ritual != null && ritual.effect != null)
{
return ritual.effect.startRitual(ritualStone, player);
}
}
return false;
}
public static void onRitualBroken(IMasterRitualStone ritualStone, String ritualID)
{
if(ritualMap.containsKey(ritualID))
{
Rituals ritual = ritualMap.get(ritualID);
if(ritual != null && ritual.effect != null)
{
ritual.effect.onRitualBroken(ritualStone);
}
}
}
public static int getNumberOfRituals()
{

View file

@ -1,6 +1,7 @@
package WayofTime.alchemicalWizardry.api.soulNetwork;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import java.util.UUID;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@ -10,8 +11,25 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import com.mojang.authlib.GameProfile;
public class SoulNetworkHandler
{
public static UUID getUUIDFromPlayer(EntityPlayer player)
{
return player.getPersistentID();
}
public static EntityPlayer getPlayerFromUUID(UUID uuid)
{
MinecraftServer server = MinecraftServer.getServer();
GameProfile gameProfile;
gameProfile = server.func_152358_ax().func_152652_a(uuid);
// LogHelper.info("player is " + gameProfile.getName() + " : " + gameProfile.getId());
return null;
}
public static int syphonFromNetwork(ItemStack ist, int damageToBeDone)
{
if (ist.getTagCompound() != null && !(ist.getTagCompound().getString("ownerName").equals("")))

View file

@ -32,6 +32,18 @@ public class BlockMasterStone extends BlockContainer
{
this.blockIcon = iconRegister.registerIcon("AlchemicalWizardry:MasterStone");
}
@Override
public void onBlockHarvested(World world, int x, int y, int z, int meta, EntityPlayer player)
{
TileEntity tile = world.getTileEntity(x, y, z);
if(tile instanceof TEMasterStone)
{
((TEMasterStone) tile).useOnRitualBroken();
}
super.onBlockHarvested(world, x, y, z, meta, player);
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int idk, float what, float these, float are)

View file

@ -0,0 +1,74 @@
package WayofTime.alchemicalWizardry.common.harvest;
import java.util.List;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.IPlantable;
import WayofTime.alchemicalWizardry.api.harvest.IHarvestHandler;
public class GenericPamSeedlessFruitHarvestHandler implements IHarvestHandler
{
public Block harvestBlock;
public int harvestMeta;
public int resetMeta;
public GenericPamSeedlessFruitHarvestHandler(String block, int harvestMeta, int resetMeta)
{
this.harvestBlock = getBlockForString(block);
this.harvestMeta = harvestMeta;
this.resetMeta = resetMeta;
}
public boolean isHarvesterValid()
{
return harvestBlock != null;
}
public static Block getBlockForString(String str)
{
String[] parts = str.split(":");
String modId = parts[0];
String name = parts[1];
return GameRegistry.findBlock(modId, name);
}
public static Item getItemForString(String str)
{
String[] parts = str.split(":");
String modId = parts[0];
String name = parts[1];
return GameRegistry.findItem(modId, name);
}
public boolean canHandleBlock(Block block)
{
return block == harvestBlock;
}
public int getHarvestMeta(Block block)
{
return harvestMeta;
}
@Override
public boolean harvestAndPlant(World world, int xCoord, int yCoord, int zCoord, Block block, int meta)
{
if(!this.canHandleBlock(block) || meta != this.getHarvestMeta(block))
{
return false;
}
world.func_147480_a(xCoord, yCoord, zCoord, true);
world.setBlock(xCoord, yCoord, zCoord, harvestBlock, resetMeta, 3);
return true;
}
}

View file

@ -33,6 +33,11 @@ public class GenericSeededHarvestHandler implements IHarvestHandler
}
}
public boolean isHarvesterValid()
{
return harvestBlock != null && harvestSeed != null;
}
public static Block getBlockForString(String str)
{
String[] parts = str.split(":");
@ -129,23 +134,6 @@ public class GenericSeededHarvestHandler implements IHarvestHandler
public IPlantable getSeedItem(Block block)
{
if(block == Blocks.wheat)
{
return (IPlantable) Items.wheat_seeds;
}
if(block == Blocks.carrots)
{
return (IPlantable) Items.carrot;
}
if(block == Blocks.potatoes)
{
return (IPlantable) Items.potato;
}
if(block == Blocks.nether_wart)
{
return (IPlantable) Items.nether_wart;
}
return null;
return harvestSeed;
}
}

View file

@ -0,0 +1,125 @@
package WayofTime.alchemicalWizardry.common.harvest;
import WayofTime.alchemicalWizardry.api.harvest.HarvestRegistry;
public class PamHarvestCompatRegistry
{
public static void registerPamHandlers()
{
registerSeededHandler("blackberry", 7);
registerSeededHandler("blueberry", 7);
registerSeededHandler("candleberry", 7);
registerSeededHandler("raspberry", 7);
registerSeededHandler("strawberry", 7);
registerSeededHandler("cactusfruit", 7);
registerSeededHandler("asparagus", 7);
registerSeededHandler("barley", 7);
registerSeededHandler("oats", 7);
registerSeededHandler("rye", 7);
registerSeededHandler("corn", 7);
registerSeededHandler("bambooshoot", 7);
registerSeededHandler("cantaloupe", 7);
registerSeededHandler("cucumber", 7);
registerSeededHandler("windersquash", 7);
registerSeededHandler("zucchini", 7);
registerSeededHandler("beat", 7);
registerSeededHandler("onion", 7);
registerSeededHandler("parsnip", 7);
registerSeededHandler("peanut", 7);
registerSeededHandler("radish", 7);
registerSeededHandler("rutabaga", 7);
registerSeededHandler("sweetpotato", 7);
registerSeededHandler("turnip", 7);
registerSeededHandler("rhubarb", 7);
registerSeededHandler("celery", 7);
registerSeededHandler("garlic", 7);
registerSeededHandler("ginger", 7);
registerSeededHandler("spiceleaf", 7);
registerSeededHandler("tealeaf", 7);
registerSeededHandler("coffeebean", 7);
registerSeededHandler("mustardseeds", 7);
registerSeededHandler("brocolli", 7);
registerSeededHandler("cauliflower", 7);
registerSeededHandler("leek", 7);
registerSeededHandler("lettuce", 7);
registerSeededHandler("scallion", 7);
registerSeededHandler("artichoke", 7);
registerSeededHandler("brusselsprout", 7);
registerSeededHandler("cabbage", 7);
registerSeededHandler("whitemushroom", 7);
registerSeededHandler("bean", 7);
registerSeededHandler("soybean", 7);
registerSeededHandler("bellpepper", 7);
registerSeededHandler("chili", 7);
registerSeededHandler("eggplant", 7);
registerSeededHandler("pamokra", 7);
registerSeededHandler("peas", 7);
registerSeededHandler("tomato", 7);
registerSeededHandler("cotton", 7);
registerSeededHandler("pineapple", 7);
registerSeededHandler("grape", 7);
registerSeededHandler("kiwi", 7);
registerSeededHandler("cranberry", 7);
registerSeededHandler("rice", 7);
registerSeededHandler("seaweed", 7);
registerFruitHandler("apple", 7, 0);
registerFruitHandler("Almond", 7, 0);
registerFruitHandler("Apricot", 7, 0);
registerFruitHandler("Avocado", 7, 0);
registerFruitHandler("Banana", 7, 0);
registerFruitHandler("Cashew", 7, 0);
registerFruitHandler("Cherry", 7, 0);
registerFruitHandler("Chestnut", 7, 0);
registerFruitHandler("Cinnamon", 7, 0);
registerFruitHandler("Coconut", 7, 0);
registerFruitHandler("Date", 7, 0);
registerFruitHandler("Dragonfruit", 7, 0);
registerFruitHandler("Durian", 7, 0);
registerFruitHandler("Fig", 7, 0);
registerFruitHandler("Grapefruit", 7, 0);
registerFruitHandler("Lemon", 7, 0);
registerFruitHandler("Lime", 7, 0);
registerFruitHandler("Maple", 7, 0);
registerFruitHandler("Mango", 7, 0);
registerFruitHandler("Nutmeg", 7, 0);
registerFruitHandler("Olive", 7, 0);
registerFruitHandler("Orange", 7, 0);
registerFruitHandler("Papaya", 7, 0);
registerFruitHandler("Paperbark", 7, 0);
registerFruitHandler("Peach", 7, 0);
registerFruitHandler("Pear", 7, 0);
registerFruitHandler("Pecan", 7, 0);
registerFruitHandler("Peppercorn", 7, 0);
registerFruitHandler("Persimmon", 7, 0);
registerFruitHandler("Pistachio", 7, 0);
registerFruitHandler("Plum", 7, 0);
registerFruitHandler("Pomegranate", 7, 0);
registerFruitHandler("Starfruit", 7, 0);
registerFruitHandler("Vanillabean", 7, 0);
registerFruitHandler("Walnut", 7, 0);
}
public static void registerSeededHandler(String name, int meta)
{
String block = "harvestcraft:pam" + name + "Crop";
String seed = "harvestcraft:" + name + "Item";
GenericSeededHarvestHandler handler = new GenericSeededHarvestHandler(block, meta, seed);
if(handler.isHarvesterValid())
{
HarvestRegistry.registerHarvestHandler(handler);
}
}
public static void registerFruitHandler(String name, int harvestMeta, int resetMeta)
{
String block = "harvestcraft:pam" + name;
GenericPamSeedlessFruitHarvestHandler handler = new GenericPamSeedlessFruitHarvestHandler(block, harvestMeta, resetMeta);
if(handler.isHarvesterValid())
{
HarvestRegistry.registerHarvestHandler(handler);
}
}
}

View file

@ -22,6 +22,7 @@ public class RitualEffectGrowth extends RitualEffect
private static final int aquasalusDrain = 10;
private static final int terraeDrain = 20;
private static final int orbisTerraeDrain = 20;
private static final int virtusDrain = 10;
@Override
public void performEffect(IMasterRitualStone ritualStone)
@ -49,6 +50,7 @@ public class RitualEffectGrowth extends RitualEffect
{
boolean hasTerrae = this.canDrainReagent(ritualStone, ReagentRegistry.terraeReagent, terraeDrain, false);
boolean hasOrbisTerrae = this.canDrainReagent(ritualStone, ReagentRegistry.orbisTerraeReagent, orbisTerraeDrain, false);
boolean hasVirtus = this.canDrainReagent(ritualStone, ReagentRegistry.virtusReagent, virtusDrain, false);
int speed = this.getSpeedForReagents(hasTerrae, hasOrbisTerrae);
if (world.getWorldTime() % speed != 0)
@ -58,7 +60,7 @@ public class RitualEffectGrowth extends RitualEffect
if(this.canDrainReagent(ritualStone, ReagentRegistry.aquasalusReagent, aquasalusDrain, false))
{
int hydrationRange = 1;
int hydrationRange = hasVirtus ? 4 : 1;
for(int i=-hydrationRange; i<=hydrationRange; i++)
{
for(int j=-hydrationRange; j<=hydrationRange; j++)
@ -76,9 +78,10 @@ public class RitualEffectGrowth extends RitualEffect
int flag = 0;
for (int i = -1; i <= 1; i++)
int range = hasVirtus ? 4 : 1;
for (int i = -range; i <= range; i++)
{
for (int j = -1; j <= 1; j++)
for (int j = -range; j <= range; j++)
{
Block block = world.getBlock(x + i, y + 2, z + j);
@ -95,8 +98,12 @@ public class RitualEffectGrowth extends RitualEffect
if (flag > 0)
{
this.canDrainReagent(ritualStone, ReagentRegistry.terraeReagent, terraeDrain, true);
this.canDrainReagent(ritualStone, ReagentRegistry.orbisTerraeReagent, orbisTerraeDrain, true);
if(hasTerrae)
this.canDrainReagent(ritualStone, ReagentRegistry.terraeReagent, terraeDrain, true);
if(hasOrbisTerrae)
this.canDrainReagent(ritualStone, ReagentRegistry.orbisTerraeReagent, orbisTerraeDrain, true);
if(hasVirtus)
this.canDrainReagent(ritualStone, ReagentRegistry.virtusReagent, virtusDrain, true);
data.currentEssence = currentEssence - this.getCostPerRefresh()*flag;
data.markDirty();

View file

@ -216,15 +216,23 @@ public class TEMasterStone extends TileEntity implements IMasterRitualStone
if (!world.isRemote)
{
data.currentEssence = currentEssence - Rituals.getCostForActivation(testRitual);
data.markDirty();
player.addChatMessage(new ChatComponentText("A rush of energy flows through the ritual!"));
if(!Rituals.startRitual(this, testRitual, player))
{
player.addChatMessage(new ChatComponentText("The ritual appears to actively resist you!"));
return;
}else
{
data.currentEssence = currentEssence - Rituals.getCostForActivation(testRitual);
data.markDirty();
player.addChatMessage(new ChatComponentText("A rush of energy flows through the ritual!"));
for (int i = 0; i < 12; i++)
{
SpellHelper.sendIndexedParticleToAllAround(world, xCoord, yCoord, zCoord, 20, worldObj.provider.dimensionId, 1, xCoord, yCoord, zCoord);
}
for (int i = 0; i < 12; i++)
{
SpellHelper.sendIndexedParticleToAllAround(world, xCoord, yCoord, zCoord, 20, worldObj.provider.dimensionId, 1, xCoord, yCoord, zCoord);
}
}
}
cooldown = Rituals.getInitialCooldown(testRitual);
@ -241,6 +249,11 @@ public class TEMasterStone extends TileEntity implements IMasterRitualStone
this.owner = owner;
}
public void useOnRitualBroken()
{
Rituals.onRitualBroken(this, this.currentRitualString);
}
@Override
public void updateEntity()
{
@ -271,6 +284,7 @@ public class TEMasterStone extends TileEntity implements IMasterRitualStone
if (!testRunes)
{
Rituals.onRitualBroken(this, currentRitualString);
isActive = false;
currentRitualString = "";
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);