Fix to Full Stomach ritual, adding new system for summoning registry

This commit is contained in:
WayofTime 2014-10-19 19:34:51 -04:00
parent 3360a4d85c
commit dc1357739b
15 changed files with 270 additions and 249 deletions

View file

@ -14,6 +14,7 @@ import WayofTime.alchemicalWizardry.common.*;
import WayofTime.alchemicalWizardry.common.alchemy.CombinedPotionRegistry; import WayofTime.alchemicalWizardry.common.alchemy.CombinedPotionRegistry;
import WayofTime.alchemicalWizardry.common.block.ArmourForge; import WayofTime.alchemicalWizardry.common.block.ArmourForge;
import WayofTime.alchemicalWizardry.common.bloodAltarUpgrade.UpgradedAltars; import WayofTime.alchemicalWizardry.common.bloodAltarUpgrade.UpgradedAltars;
import WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.TEDemonPortal;
import WayofTime.alchemicalWizardry.common.entity.mob.*; import WayofTime.alchemicalWizardry.common.entity.mob.*;
import WayofTime.alchemicalWizardry.common.harvest.BloodMagicHarvestHandler; import WayofTime.alchemicalWizardry.common.harvest.BloodMagicHarvestHandler;
import WayofTime.alchemicalWizardry.common.harvest.CactusReedHarvestHandler; import WayofTime.alchemicalWizardry.common.harvest.CactusReedHarvestHandler;
@ -163,20 +164,20 @@ public class AlchemicalWizardry
public static int greaterLengtheningCatalystDungeonChance; public static int greaterLengtheningCatalystDungeonChance;
//Mob IDs //Mob IDs
public static int entityFallenAngelID = 20; public static String entityFallenAngelID = "AW001FallenAngel";
public static int entityLowerGuardianID = 21; public static String entityLowerGuardianID = "AW001";
public static int entityBileDemonID = 22; public static String entityBileDemonID = "AW001";
public static int entityWingedFireDemonID = 23; public static String entityWingedFireDemonID = "AW001";
public static int entitySmallEarthGolemID = 24; public static String entitySmallEarthGolemID = "AW001";
public static int entityIceDemonID = 25; public static String entityIceDemonID = "AW001";
public static int entityBoulderFistID = 26; public static String entityBoulderFistID = "AW001";
public static int entityShadeID = 27; public static String entityShadeID = "AW001";
public static int entityAirElementalID = 28; public static String entityAirElementalID = "AW001";
public static int entityWaterElementalID = 29; public static String entityWaterElementalID = "AW001";
public static int entityEarthElementalID = 30; public static String entityEarthElementalID = "AW001";
public static int entityFireElementalID = 31; public static String entityFireElementalID = "AW001";
public static int entityShadeElementalID = 32; public static String entityShadeElementalID = "AW001";
public static int entityHolyElementalID = 33; public static String entityHolyElementalID = "AW001";
public static Fluid lifeEssenceFluid; public static Fluid lifeEssenceFluid;
@ -606,20 +607,20 @@ public class AlchemicalWizardry
SummoningRegistry.registerSummon(new SummoningHelperAW(this.entityHolyElementalID), new ItemStack[]{sanctusStack, sanctusStack, sanctusStack, sanctusStack, sanctusStack, sanctusStack}, new ItemStack[]{}, new ItemStack[]{}, 0, 4); SummoningRegistry.registerSummon(new SummoningHelperAW(this.entityHolyElementalID), new ItemStack[]{sanctusStack, sanctusStack, sanctusStack, sanctusStack, sanctusStack, sanctusStack}, new ItemStack[]{}, new ItemStack[]{}, 0, 4);
//Custom mobs //Custom mobs
EntityRegistry.registerModEntity(EntityFallenAngel.class, "FallenAngel", this.entityFallenAngelID, this, 80, 3, true); EntityRegistry.registerModEntity(EntityFallenAngel.class, "FallenAngel", 20, this, 80, 3, true);
EntityRegistry.registerModEntity(EntityLowerGuardian.class, "LowerGuardian", this.entityLowerGuardianID, this, 80, 3, true); EntityRegistry.registerModEntity(EntityLowerGuardian.class, "LowerGuardian", 21, this, 80, 3, true);
EntityRegistry.registerModEntity(EntityBileDemon.class, "BileDemon", this.entityBileDemonID, this, 80, 3, true); EntityRegistry.registerModEntity(EntityBileDemon.class, "BileDemon", 22, this, 80, 3, true);
EntityRegistry.registerModEntity(EntityWingedFireDemon.class, "WingedFireDemon", this.entityWingedFireDemonID, this, 80, 3, true); EntityRegistry.registerModEntity(EntityWingedFireDemon.class, "WingedFireDemon", 23, this, 80, 3, true);
EntityRegistry.registerModEntity(EntitySmallEarthGolem.class, "SmallEarthGolem", this.entitySmallEarthGolemID, this, 80, 3, true); EntityRegistry.registerModEntity(EntitySmallEarthGolem.class, "SmallEarthGolem", 24, this, 80, 3, true);
EntityRegistry.registerModEntity(EntityIceDemon.class, "IceDemon", this.entityIceDemonID, this, 80, 3, true); EntityRegistry.registerModEntity(EntityIceDemon.class, "IceDemon", 25, this, 80, 3, true);
EntityRegistry.registerModEntity(EntityBoulderFist.class, "BoulderFist", this.entityBoulderFistID, this, 80, 3, true); EntityRegistry.registerModEntity(EntityBoulderFist.class, "BoulderFist", 26, this, 80, 3, true);
EntityRegistry.registerModEntity(EntityShade.class, "Shade", this.entityShadeID, this, 80, 3, true); EntityRegistry.registerModEntity(EntityShade.class, "Shade", 27, this, 80, 3, true);
EntityRegistry.registerModEntity(EntityAirElemental.class, "AirElemental", this.entityAirElementalID, this, 120, 3, true); EntityRegistry.registerModEntity(EntityAirElemental.class, "AirElemental", 28, this, 120, 3, true);
EntityRegistry.registerModEntity(EntityWaterElemental.class, "WaterElemental", this.entityWaterElementalID, this, 120, 3, true); EntityRegistry.registerModEntity(EntityWaterElemental.class, "WaterElemental", 29, this, 120, 3, true);
EntityRegistry.registerModEntity(EntityEarthElemental.class, "EarthElemental", this.entityEarthElementalID, this, 120, 3, true); EntityRegistry.registerModEntity(EntityEarthElemental.class, "EarthElemental", 30, this, 120, 3, true);
EntityRegistry.registerModEntity(EntityFireElemental.class, "FireElemental", this.entityFireElementalID, this, 120, 3, true); EntityRegistry.registerModEntity(EntityFireElemental.class, "FireElemental", 31, this, 120, 3, true);
EntityRegistry.registerModEntity(EntityShadeElemental.class, "ShadeElemental", this.entityShadeElementalID, this, 120, 3, true); EntityRegistry.registerModEntity(EntityShadeElemental.class, "ShadeElemental", 32, this, 120, 3, true);
EntityRegistry.registerModEntity(EntityHolyElemental.class, "HolyElemental", this.entityHolyElementalID, this, 120, 3, true); EntityRegistry.registerModEntity(EntityHolyElemental.class, "HolyElemental", 33, this, 120, 3, true);
ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST).addItem(new WeightedRandomChestContent(new ItemStack(ModItems.standardBindingAgent), 1, 3, this.standardBindingAgentDungeonChance)); ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST).addItem(new WeightedRandomChestContent(new ItemStack(ModItems.standardBindingAgent), 1, 3, this.standardBindingAgentDungeonChance));
ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST).addItem(new WeightedRandomChestContent(new ItemStack(ModItems.mundanePowerCatalyst), 1, 1, this.mundanePowerCatalystDungeonChance)); ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST).addItem(new WeightedRandomChestContent(new ItemStack(ModItems.mundanePowerCatalyst), 1, 1, this.mundanePowerCatalystDungeonChance));

View file

@ -5,16 +5,16 @@ import net.minecraft.world.World;
public abstract class SummoningHelper public abstract class SummoningHelper
{ {
protected int id; protected String id;
public SummoningHelper(int id) public SummoningHelper(String id)
{ {
this.id = id; this.id = id;
} }
public abstract EntityLivingBase getEntity(World worldObj); public abstract EntityLivingBase getEntity(World worldObj);
public int getSummoningHelperID() public String getSummoningHelperID()
{ {
return id; return id;
} }

View file

@ -55,11 +55,11 @@ public class SummoningRegistry
return null; return null;
} }
public static EntityLivingBase getEntityWithID(World worldObj, int id) public static EntityLivingBase getEntityWithID(World worldObj, String id)
{ {
for (SummoningRegistryComponent src : summoningList) for (SummoningRegistryComponent src : summoningList)
{ {
if (src.getSummoningHelperID() == id) if (src.getSummoningHelperID().equals(id))
{ {
return src.getEntity(worldObj); return src.getEntity(worldObj);
} }

View file

@ -224,7 +224,7 @@ public class SummoningRegistryComponent
} }
} }
public int getSummoningHelperID() public String getSummoningHelperID()
{ {
return this.summoningHelper.getSummoningHelperID(); return this.summoningHelper.getSummoningHelperID();
} }

View file

@ -21,6 +21,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource; import net.minecraft.util.DamageSource;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
import net.minecraftforge.event.AnvilUpdateEvent;
import net.minecraftforge.event.entity.living.EnderTeleportEvent; import net.minecraftforge.event.entity.living.EnderTeleportEvent;
import net.minecraftforge.event.entity.living.LivingAttackEvent; import net.minecraftforge.event.entity.living.LivingAttackEvent;
import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent; import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent;
@ -29,13 +30,15 @@ import net.minecraftforge.event.entity.living.LivingSpawnEvent.CheckSpawn;
import vazkii.botania.api.internal.IManaBurst; import vazkii.botania.api.internal.IManaBurst;
import WayofTime.alchemicalWizardry.AlchemicalWizardry; import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.entity.projectile.EnergyBlastProjectile; import WayofTime.alchemicalWizardry.common.entity.projectile.EnergyBlastProjectile;
import WayofTime.alchemicalWizardry.common.items.BoundArmour;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper; import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import WayofTime.alchemicalWizardry.common.tileEntity.TEMasterStone; import WayofTime.alchemicalWizardry.common.tileEntity.TEMasterStone;
import cpw.mods.fml.common.ObfuscationReflectionHelper; import cpw.mods.fml.common.ObfuscationReflectionHelper;
import cpw.mods.fml.common.Optional;
import cpw.mods.fml.common.eventhandler.Event.Result; import cpw.mods.fml.common.eventhandler.Event.Result;
import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerRespawnEvent; import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerRespawnEvent;
import cpw.mods.fml.common.Optional; import cpw.mods.fml.common.registry.GameRegistry;
public class AlchemicalWizardryEventHooks public class AlchemicalWizardryEventHooks
{ {
@ -46,6 +49,16 @@ public class AlchemicalWizardryEventHooks
public static Map<Integer, List<CoordAndRange>> respawnMap = new HashMap(); public static Map<Integer, List<CoordAndRange>> respawnMap = new HashMap();
public static Map<Integer, List<CoordAndRange>> forceSpawnMap = new HashMap(); public static Map<Integer, List<CoordAndRange>> forceSpawnMap = new HashMap();
@SubscribeEvent
public void onAnvilUpdateEvent(AnvilUpdateEvent event)
{
if(event.isCancelable() && event.left != null && event.left.getItem() instanceof BoundArmour && event.right != null)
{
event.setCanceled(true);
}
}
@SubscribeEvent @SubscribeEvent
public void onPlayerDamageEvent(LivingAttackEvent event) public void onPlayerDamageEvent(LivingAttackEvent event)
{ {
@ -108,6 +121,7 @@ public class AlchemicalWizardryEventHooks
if (event.entityLiving instanceof EntityCreeper) if (event.entityLiving instanceof EntityCreeper)
{ {
GameRegistry d;
return; return;
} }

View file

@ -1,7 +1,7 @@
package WayofTime.alchemicalWizardry.common.block; package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.AlchemicalWizardry; import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.tileEntity.TEDemonPortal; import WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.TEDemonPortal;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;

View file

@ -1,4 +1,4 @@
package WayofTime.alchemicalWizardry.common.tileEntity; package WayofTime.alchemicalWizardry.common.demonVillage.tileEntity;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
@ -39,8 +39,9 @@ public class TEDemonPortal extends TileEntity
public static int buildingGridDelay = 25; public static int buildingGridDelay = 25;
public static int roadGridDelay = 10; public static int roadGridDelay = 10;
public static int demonHoardDelay = 10;
public static int[] tierCostList = new int[]{1000, 50000, 55000}; public static int[] tierCostList = new int[]{1000, 5000, 10000};
public static List<DemonBuilding> buildingList = new ArrayList(); public static List<DemonBuilding> buildingList = new ArrayList();
public Random rand = new Random(); public Random rand = new Random();
@ -56,7 +57,10 @@ public class TEDemonPortal extends TileEntity
public int houseCooldown; public int houseCooldown;
public int roadCooldown; public int roadCooldown;
public int tier; //Tier of the demon portal - Should select buildings 2 below to this public int tier; //Tier of the demon portal - Should select buildings 2 below to this
public int totalPoints; public int demonHouseCooldown;
public int demonHoardCooldown;
public float pointPool;
public String nextDemonPortalName = ""; public String nextDemonPortalName = "";
public ForgeDirection nextDemonPortalDirection = ForgeDirection.DOWN; public ForgeDirection nextDemonPortalDirection = ForgeDirection.DOWN;
@ -93,13 +97,14 @@ public class TEDemonPortal extends TileEntity
this.tier = 0; this.tier = 0;
} }
public void decreaseRandomCooldown(int amount) public boolean decreaseRandomCooldown(int amount)
{ {
float totalChance = 0; float totalChance = 0;
Map<String, Float> map = new HashMap(); Map<String, Float> map = new HashMap();
map.put("roadChance", 0.3f); map.put("roadChance", 0.6f);
map.put("houseChance", 0.6f); map.put("houseChance", 0.3f);
map.put("demonPortalChance", 0.5f);
String action = ""; String action = "";
@ -125,11 +130,28 @@ public class TEDemonPortal extends TileEntity
if(action.equals("roadChance")) if(action.equals("roadChance"))
{ {
roadCooldown -= amount; if(roadCooldown > 0)
{
roadCooldown -= amount;
}else
{
return false;
}
}else if(action.equals("houseChance")) }else if(action.equals("houseChance"))
{ {
houseCooldown -= amount; if(houseCooldown > 0)
} {
houseCooldown -= amount;
}else
{
return false;
}
}else if(action.equals("demonPortalChance"))
{
demonHouseCooldown += amount;
}
return true;
} }
public void initialize() public void initialize()
@ -158,10 +180,14 @@ public class TEDemonPortal extends TileEntity
this.houseCooldown = TEDemonPortal.buildingGridDelay; this.houseCooldown = TEDemonPortal.buildingGridDelay;
this.roadCooldown = TEDemonPortal.roadGridDelay; this.roadCooldown = TEDemonPortal.roadGridDelay;
this.demonHoardCooldown = TEDemonPortal.demonHoardDelay;
isInitialized = true; isInitialized = true;
} }
/**
* Randomly increase one of the cooldowns such that a road, house, or a demon portal tier is caused. Demons are also randomly spawned via this mechanic.
*/
@Override @Override
public void updateEntity() public void updateEntity()
{ {
@ -170,6 +196,9 @@ public class TEDemonPortal extends TileEntity
return; return;
} }
this.incrementPoints();
this.assignPoints();
System.out.println("Roads: " + roadCooldown + " Buildings: " + houseCooldown); System.out.println("Roads: " + roadCooldown + " Buildings: " + houseCooldown);
if(buildingStage >= 0 && buildingStage <=2) if(buildingStage >= 0 && buildingStage <=2)
@ -179,41 +208,37 @@ public class TEDemonPortal extends TileEntity
buildingStage++; buildingStage++;
return; return;
} }
// if (this.hasLocationChanged)
// {
// if (this.changePortalLocation())
// {
// if(printDebug)
// System.out.println("Changed portal location.");
// return;
// } else
// {
// if(printDebug)
// System.out.println("Going back to normal, have a nice day!");
// this.hasLocationChanged = false;
// }
// }
if (this.roadCooldown <= 0) if(this.roadCooldown <= 0)
{ {
int roadsMade = this.createRandomRoad(); int roadsMade = this.createRandomRoad();
if (roadsMade > 0) if (roadsMade > 0)
{ {
this.roadCooldown = TEDemonPortal.roadGridDelay * roadsMade; this.roadCooldown = TEDemonPortal.roadGridDelay * roadsMade;
this.totalPoints += this.roadCooldown; //this.demonHouseCooldown += this.roadCooldown;
} }
} else if (this.houseCooldown <= 0) }
if(this.houseCooldown <= 0)
{ {
int gridsUsed = this.createRandomBuilding(DemonBuilding.BUILDING_HOUSE, tier); int gridsUsed = this.createRandomBuilding(DemonBuilding.BUILDING_HOUSE, tier);
if (gridsUsed > 0) if (gridsUsed > 0)
{ {
this.houseCooldown = TEDemonPortal.buildingGridDelay * gridsUsed; this.houseCooldown = TEDemonPortal.buildingGridDelay * gridsUsed;
this.totalPoints += this.houseCooldown; //this.demonHouseCooldown += this.houseCooldown;
} }
} }
if(this.demonHoardCooldown <= 0)
{
int complexityCost = this.createRandomDemonHoard(tier);
if(complexityCost > 0)
{
this.demonHoardCooldown = TEDemonPortal.demonHoardDelay * complexityCost;
}
}
if (this.tier < this.tierCostList.length && this.totalPoints > this.tierCostList[this.tier]) if(this.tier < this.tierCostList.length && this.demonHouseCooldown > this.tierCostList[this.tier])
{ {
this.tier++; this.tier++;
@ -223,8 +248,25 @@ public class TEDemonPortal extends TileEntity
} }
} }
this.houseCooldown = Math.max(0, this.houseCooldown - 1); //Current dummy implementation of the increasing costs
this.roadCooldown = Math.max(0, this.roadCooldown - 1); // this.houseCooldown = Math.max(0, this.houseCooldown - 1); //Current dummy implementation of the increasing costs
// this.roadCooldown = Math.max(0, this.roadCooldown - 1);
}
public void assignPoints()
{
if((int)this.pointPool > 0)
{
if(this.decreaseRandomCooldown((int)this.pointPool))
{
this.pointPool -= (int)this.pointPool;
}
}
}
public void incrementPoints()
{
this.pointPool += 1f;
} }
@Override @Override
@ -237,6 +279,7 @@ public class TEDemonPortal extends TileEntity
this.posZRadius = par1NBTTagCompound.getInteger("posZRadius"); this.posZRadius = par1NBTTagCompound.getInteger("posZRadius");
this.houseCooldown = par1NBTTagCompound.getInteger("houseCooldown"); this.houseCooldown = par1NBTTagCompound.getInteger("houseCooldown");
this.roadCooldown = par1NBTTagCompound.getInteger("roadCooldown"); this.roadCooldown = par1NBTTagCompound.getInteger("roadCooldown");
this.demonHoardCooldown = par1NBTTagCompound.getInteger("demonHoardCooldown");
area = new GridSpace[negXRadius + posXRadius + 1][negZRadius + posZRadius + 1]; area = new GridSpace[negXRadius + posXRadius + 1][negZRadius + posZRadius + 1];
@ -258,11 +301,13 @@ public class TEDemonPortal extends TileEntity
this.isInitialized = par1NBTTagCompound.getBoolean("init"); this.isInitialized = par1NBTTagCompound.getBoolean("init");
this.tier = par1NBTTagCompound.getInteger("tier"); this.tier = par1NBTTagCompound.getInteger("tier");
this.totalPoints = par1NBTTagCompound.getInteger("totalPoints"); this.demonHouseCooldown = par1NBTTagCompound.getInteger("demonHouseCooldown");
this.nextDemonPortalName = par1NBTTagCompound.getString("nextDemonPortalName"); this.nextDemonPortalName = par1NBTTagCompound.getString("nextDemonPortalName");
this.buildingStage = par1NBTTagCompound.getInteger("buildingStage"); this.buildingStage = par1NBTTagCompound.getInteger("buildingStage");
this.nextDemonPortalDirection = ForgeDirection.getOrientation(par1NBTTagCompound.getInteger("nextDemonPortalDirection")); this.nextDemonPortalDirection = ForgeDirection.getOrientation(par1NBTTagCompound.getInteger("nextDemonPortalDirection"));
this.pointPool = par1NBTTagCompound.getFloat("pointPool");
} }
@Override @Override
@ -275,6 +320,7 @@ public class TEDemonPortal extends TileEntity
par1NBTTagCompound.setInteger("posZRadius", posZRadius); par1NBTTagCompound.setInteger("posZRadius", posZRadius);
par1NBTTagCompound.setInteger("houseCooldown", houseCooldown); par1NBTTagCompound.setInteger("houseCooldown", houseCooldown);
par1NBTTagCompound.setInteger("roadCooldown", roadCooldown); par1NBTTagCompound.setInteger("roadCooldown", roadCooldown);
par1NBTTagCompound.setInteger("demonHoardCooldown", demonHoardCooldown);
NBTTagList gridList = new NBTTagList(); NBTTagList gridList = new NBTTagList();
@ -303,14 +349,22 @@ public class TEDemonPortal extends TileEntity
par1NBTTagCompound.setBoolean("init", this.isInitialized); par1NBTTagCompound.setBoolean("init", this.isInitialized);
par1NBTTagCompound.setInteger("tier", this.tier); par1NBTTagCompound.setInteger("tier", this.tier);
par1NBTTagCompound.setInteger("totalPoints", this.totalPoints); par1NBTTagCompound.setInteger("demonHouseCooldown", this.demonHouseCooldown);
par1NBTTagCompound.setString("nextDemonPortalName", nextDemonPortalName); par1NBTTagCompound.setString("nextDemonPortalName", nextDemonPortalName);
par1NBTTagCompound.setInteger("buildingStage", buildingStage); par1NBTTagCompound.setInteger("buildingStage", buildingStage);
par1NBTTagCompound.setInteger("nextDemonPortalDirection", this.nextDemonPortalDirection.ordinal()); par1NBTTagCompound.setInteger("nextDemonPortalDirection", this.nextDemonPortalDirection.ordinal());
par1NBTTagCompound.setFloat("pointPool", pointPool);
} }
public int createRandomDemonHoard(int tier)
{
return 10;
}
public int createRandomRoad() //Return the number of road spaces public int createRandomRoad() //Return the number of road spaces
{ {
int next = rand.nextInt(4); int next = rand.nextInt(4);
@ -1062,159 +1116,87 @@ public class TEDemonPortal extends TileEntity
dir = ForgeDirection.NORTH; dir = ForgeDirection.NORTH;
} }
boolean newProtocol = true; Int3 space = this.findRoadSpaceFromDirection(dir, 1 * (rand.nextInt(negXRadius + negZRadius + posXRadius + posZRadius)) + 1);
if (newProtocol) int x = space.xCoord;
int z = space.zCoord;
int yLevel = space.yCoord;
if(printDebug)
System.out.println("Road space - x: " + x + " z: " + z);
GridSpaceHolder grid = this.createGSH();
if (!this.getGridSpace(x, z).isRoadSegment())
{ {
Int3 space = this.findRoadSpaceFromDirection(dir, 1 * (rand.nextInt(negXRadius + negZRadius + posXRadius + posZRadius)) + 1); return 0;
}
int x = space.xCoord; List<ForgeDirection> directions = new ArrayList();
int z = space.zCoord;
int yLevel = space.yCoord;
if(printDebug) for (int i = 2; i < 6; i++)
System.out.println("Road space - x: " + x + " z: " + z);
GridSpaceHolder grid = this.createGSH();
if (!this.getGridSpace(x, z).isRoadSegment())
{
return 0;
}
List<ForgeDirection> directions = new ArrayList();
for (int i = 2; i < 6; i++)
{
ForgeDirection testDir = ForgeDirection.getOrientation(i);
if (this.getGridSpace(x + testDir.offsetX, z + testDir.offsetZ).isEmpty())
{
directions.add(testDir);
}
}
if (directions.isEmpty())
{
return 0;
}
HashMap<ForgeDirection, List<DemonBuilding>> schemMap = new HashMap();
for (ForgeDirection nextDir : directions)
{
for (DemonBuilding build : TEDemonPortal.buildingList)
{
if (build.buildingTier != buildingTier || build.buildingType != DemonBuilding.BUILDING_HOUSE)
{
continue;
}
Int3 offsetSpace = build.getGridOffsetFromRoad(nextDir, yLevel);
int xOff = offsetSpace.xCoord;
int zOff = offsetSpace.zCoord;
if (build.isValid(grid, x + xOff, z + zOff, nextDir.getOpposite()))
{
if (schemMap.containsKey(nextDir))
{
schemMap.get(nextDir).add(build);
} else
{
schemMap.put(nextDir, new ArrayList());
schemMap.get(nextDir).add(build);
}
} else
{
System.out.println("This ISN'T valid!");
}
}
}
if (schemMap.keySet().isEmpty())
{
return 0;
}
ForgeDirection chosenDirection = (ForgeDirection) schemMap.keySet().toArray()[new Random().nextInt(schemMap.keySet().size())];
DemonBuilding build = schemMap.get(chosenDirection).get(new Random().nextInt(schemMap.get(chosenDirection).size()));
Int3 offsetSpace = build.getGridOffsetFromRoad(chosenDirection, yLevel);
int xOff = offsetSpace.xCoord;
int zOff = offsetSpace.zCoord;
build.destroyAllInField(worldObj, xCoord + (x + xOff) * 5, yLevel, zCoord + (z + zOff) * 5, chosenDirection.getOpposite());
build.buildAll(worldObj, xCoord + (x + xOff) * 5, yLevel, zCoord + (z + zOff) * 5, chosenDirection.getOpposite());
build.setAllGridSpaces(x + xOff, z + zOff, yLevel, chosenDirection.getOpposite(), GridSpace.HOUSE, grid);
this.loadGSH(grid);
return build.getNumberOfGridSpaces();
} else
{ {
Int3 space = findEmptySpaceNearRoad(dir, 3 * (rand.nextInt(negXRadius + negZRadius + posXRadius + posZRadius)) + 1, 2); ForgeDirection testDir = ForgeDirection.getOrientation(i);
if (this.getGridSpace(x + testDir.offsetX, z + testDir.offsetZ).isEmpty())
int x = space.xCoord;
int z = space.zCoord;
int yLevel = space.yCoord;
GridSpace newSpace = this.getGridSpace(x, z);
if (!newSpace.isEmpty())
{ {
return 0; directions.add(testDir);
} }
}
if (yLevel == -1) if (directions.isEmpty())
{ {
return 0; return 0;
} }
GridSpaceHolder grid = this.createGSH(); HashMap<ForgeDirection, List<DemonBuilding>> schemMap = new HashMap();
ForgeDirection chosenDirection = ForgeDirection.NORTH;
HashMap<ForgeDirection, List<DemonBuilding>> bigList = new HashMap();
for (ForgeDirection nextDir : directions)
{
for (DemonBuilding build : TEDemonPortal.buildingList) for (DemonBuilding build : TEDemonPortal.buildingList)
{ {
for (int i = 2; i < 6; i++) if (build.buildingTier != buildingTier || build.buildingType != DemonBuilding.BUILDING_HOUSE)
{ {
chosenDirection = ForgeDirection.getOrientation(i); continue;
System.out.println("" + chosenDirection.toString()); }
if (build.isValid(grid, x, z, chosenDirection)) Int3 offsetSpace = build.getGridOffsetFromRoad(nextDir, yLevel);
int xOff = offsetSpace.xCoord;
int zOff = offsetSpace.zCoord;
if (build.isValid(grid, x + xOff, z + zOff, nextDir.getOpposite()))
{
if (schemMap.containsKey(nextDir))
{ {
System.out.println("Valid!"); schemMap.get(nextDir).add(build);
if (bigList.containsKey(chosenDirection)) } else
{ {
bigList.get(chosenDirection).add(build); schemMap.put(nextDir, new ArrayList());
} else schemMap.get(nextDir).add(build);
{
bigList.put(chosenDirection, new ArrayList());
bigList.get(chosenDirection).add(build);
}
} }
} else
{
System.out.println("This ISN'T valid!");
} }
} }
chosenDirection = ForgeDirection.getOrientation(new Random().nextInt(4) + 2); //Change to favour a direction with a road nearby
List<DemonBuilding> buildingList = bigList.get(chosenDirection);
DemonBuilding build;
if (buildingList != null && buildingList.size() > 0)
{
build = buildingList.get(new Random().nextInt(buildingList.size()));
} else
{
return 0;
}
//TODO: Finish the selection algorythm
//TODO: Should favour those directions that have a road right next to them.
build.buildAll(worldObj, xCoord + x * 5, yLevel, zCoord + z * 5, chosenDirection);
build.setAllGridSpaces(x, z, yLevel, chosenDirection, GridSpace.HOUSE, grid);
this.loadGSH(grid);
return build.getNumberOfGridSpaces();
// System.out.println("X: " + x + " Z: " + z + " Direction: " + chosenDirection.toString());
} }
if (schemMap.keySet().isEmpty())
{
return 0;
}
ForgeDirection chosenDirection = (ForgeDirection) schemMap.keySet().toArray()[new Random().nextInt(schemMap.keySet().size())];
DemonBuilding build = schemMap.get(chosenDirection).get(new Random().nextInt(schemMap.get(chosenDirection).size()));
Int3 offsetSpace = build.getGridOffsetFromRoad(chosenDirection, yLevel);
int xOff = offsetSpace.xCoord;
int zOff = offsetSpace.zCoord;
build.destroyAllInField(worldObj, xCoord + (x + xOff) * 5, yLevel, zCoord + (z + zOff) * 5, chosenDirection.getOpposite());
build.buildAll(worldObj, xCoord + (x + xOff) * 5, yLevel, zCoord + (z + zOff) * 5, chosenDirection.getOpposite());
build.setAllGridSpaces(x + xOff, z + zOff, yLevel, chosenDirection.getOpposite(), GridSpace.HOUSE, grid);
this.loadGSH(grid);
return build.getNumberOfGridSpaces();
} }
public int findNearestRoadYLevel(int xCoord, int zCoord, int maxDistance) public int findNearestRoadYLevel(int xCoord, int zCoord, int maxDistance)
@ -1332,13 +1314,8 @@ public class TEDemonPortal extends TileEntity
} }
} }
public int getTotalPoints()
{
return this.totalPoints;
}
public void addToPoints(int addition) public void addToPoints(int addition)
{ {
this.totalPoints += addition; this.demonHouseCooldown += addition;
} }
} }

View file

@ -14,9 +14,9 @@ import net.minecraft.world.World;
public class EntityDemon extends EntityTameable implements IDemon public class EntityDemon extends EntityTameable implements IDemon
{ {
private boolean isAggro; private boolean isAggro;
private int demonID; private String demonID;
public EntityDemon(World par1World, int demonID) public EntityDemon(World par1World, String demonID)
{ {
super(par1World); super(par1World);
this.demonID = demonID; this.demonID = demonID;
@ -49,7 +49,9 @@ public class EntityDemon extends EntityTameable implements IDemon
protected void dropFewItems(boolean par1, int par2) protected void dropFewItems(boolean par1, int par2)
{ {
ItemStack drop = new ItemStack(ModItems.demonPlacer, 1, this.getDemonID()); ItemStack drop = new ItemStack(ModItems.demonPlacer);
DemonPlacer.setDemonString(drop, this.getDemonID());
if ((this.getOwner() instanceof EntityPlayer)) if ((this.getOwner() instanceof EntityPlayer))
{ {
@ -92,7 +94,7 @@ public class EntityDemon extends EntityTameable implements IDemon
} }
} }
public int getDemonID() public String getDemonID()
{ {
return this.demonID; return this.demonID;
} }

View file

@ -32,9 +32,9 @@ public class EntityElemental extends EntityDemon
private static float maxTamedHealth = 100.0F; private static float maxTamedHealth = 100.0F;
private static float maxUntamedHealth = 100.0F; private static float maxUntamedHealth = 100.0F;
public EntityElemental(World par1World, int demonID) public EntityElemental(World par1World, String entityAirElementalID)
{ {
super(par1World, demonID); super(par1World, entityAirElementalID);
this.setSize(0.5F, 1.0F); this.setSize(0.5F, 1.0F);
this.setAggro(false); this.setAggro(false);
this.setTamed(false); this.setTamed(false);

View file

@ -677,7 +677,7 @@ public class BoundArmour extends ItemArmor implements IAlchemyGoggles, ISpecialA
public int getItemEnchantability() public int getItemEnchantability()
{ {
return 0; return Integer.MIN_VALUE;
} }
public boolean getIsInvisible(ItemStack armourStack) public boolean getIsInvisible(ItemStack armourStack)

View file

@ -68,7 +68,8 @@ public class DemonPlacer extends Item
d0 = 0.5D; d0 = 0.5D;
} }
Entity entity = spawnCreature(par3World, par1ItemStack.getItemDamage(), (double) par4 + 0.5D, (double) par5 + d0, (double) par6 + 0.5D, par1ItemStack); String demonName = DemonPlacer.getDemonString(par1ItemStack);
Entity entity = spawnCreature(par3World, demonName, (double) par4 + 0.5D, (double) par5 + d0, (double) par6 + 0.5D, par1ItemStack);
if (entity != null) if (entity != null)
{ {
@ -122,7 +123,8 @@ public class DemonPlacer extends Item
if (par2World.getBlock(i, j, k).getMaterial() == Material.water) if (par2World.getBlock(i, j, k).getMaterial() == Material.water)
{ {
Entity entity = spawnCreature(par2World, par1ItemStack.getItemDamage(), (double) i, (double) j, (double) k, par1ItemStack); String demonName = DemonPlacer.getDemonString(par1ItemStack);
Entity entity = spawnCreature(par2World, demonName, (double) i, (double) j, (double) k, par1ItemStack);
if (entity != null) if (entity != null)
{ {
@ -148,7 +150,7 @@ public class DemonPlacer extends Item
* Spawns the creature specified by the egg's type in the location specified by the last three parameters. * Spawns the creature specified by the egg's type in the location specified by the last three parameters.
* Parameters: world, entityID, x, y, z. * Parameters: world, entityID, x, y, z.
*/ */
public static Entity spawnCreature(World par0World, int par1, double par2, double par4, double par6, ItemStack itemStack) public static Entity spawnCreature(World par0World, String par1, double par2, double par4, double par6, ItemStack itemStack)
{ {
Entity entity = null; Entity entity = null;
@ -198,6 +200,26 @@ public class DemonPlacer extends Item
return par1ItemStack.stackTagCompound.getString("ownerName"); return par1ItemStack.stackTagCompound.getString("ownerName");
} }
public static void setDemonString(ItemStack itemStack, String demonName)
{
if (itemStack.stackTagCompound == null)
{
itemStack.setTagCompound(new NBTTagCompound());
}
itemStack.stackTagCompound.setString("demonName", demonName);
}
public static String getDemonString(ItemStack itemStack)
{
if (itemStack.stackTagCompound == null)
{
itemStack.setTagCompound(new NBTTagCompound());
}
return itemStack.stackTagCompound.getString("demonName");
}
@Override @Override
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)

View file

@ -1,20 +1,21 @@
package WayofTime.alchemicalWizardry.common.rituals; package WayofTime.alchemicalWizardry.common.rituals;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.FoodStats;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone; import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone;
import WayofTime.alchemicalWizardry.api.rituals.RitualComponent; import WayofTime.alchemicalWizardry.api.rituals.RitualComponent;
import WayofTime.alchemicalWizardry.api.rituals.RitualEffect; import WayofTime.alchemicalWizardry.api.rituals.RitualEffect;
import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler; import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper; import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.FoodStats;
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.List;
public class RitualEffectFullStomach extends RitualEffect public class RitualEffectFullStomach extends RitualEffect
{ {
@ -86,7 +87,11 @@ public class RitualEffectFullStomach extends RitualEffect
if (saturatedHeal + satLevel <= 20) if (saturatedHeal + satLevel <= 20)
{ {
foodStats.setFoodSaturationLevel(saturatedHeal + satLevel); NBTTagCompound nbt = new NBTTagCompound();
foodStats.writeNBT(nbt);
nbt.setFloat("foodSaturationLevel", saturatedHeal + satLevel);
foodStats.readNBT(nbt);
inventory.decrStackSize(i, 1); inventory.decrStackSize(i, 1);
count++; count++;
break; break;

View file

@ -7,7 +7,7 @@ import net.minecraft.world.World;
public class SummoningFallenAngel extends SummoningHelper public class SummoningFallenAngel extends SummoningHelper
{ {
public SummoningFallenAngel(int id) public SummoningFallenAngel(String id)
{ {
super(id); super(id);
} }

View file

@ -10,79 +10,79 @@ import net.minecraft.world.World;
public class SummoningHelperAW extends SummoningHelper public class SummoningHelperAW extends SummoningHelper
{ {
public SummoningHelperAW(int id) public SummoningHelperAW(String id)
{ {
super(id); super(id);
} }
public EntityLivingBase getEntity(World worldObj) public EntityLivingBase getEntity(World worldObj)
{ {
if (this.id == AlchemicalWizardry.entityFallenAngelID) if (this.id.equals(AlchemicalWizardry.entityFallenAngelID))
{ {
return new EntityFallenAngel(worldObj); return new EntityFallenAngel(worldObj);
} }
if (this.id == AlchemicalWizardry.entityLowerGuardianID) if (this.id.equals(AlchemicalWizardry.entityLowerGuardianID))
{ {
return new EntityLowerGuardian(worldObj); return new EntityLowerGuardian(worldObj);
} }
if (this.id == AlchemicalWizardry.entityBileDemonID) if (this.id.equals(AlchemicalWizardry.entityBileDemonID))
{ {
return new EntityBileDemon(worldObj); return new EntityBileDemon(worldObj);
} }
if (this.id == AlchemicalWizardry.entityWingedFireDemonID) if (this.id.equals(AlchemicalWizardry.entityWingedFireDemonID))
{ {
return new EntityWingedFireDemon(worldObj); return new EntityWingedFireDemon(worldObj);
} }
if (this.id == AlchemicalWizardry.entitySmallEarthGolemID) if (this.id.equals(AlchemicalWizardry.entitySmallEarthGolemID))
{ {
return new EntitySmallEarthGolem(worldObj); return new EntitySmallEarthGolem(worldObj);
} }
if (this.id == AlchemicalWizardry.entityIceDemonID) if (this.id.equals(AlchemicalWizardry.entityIceDemonID))
{ {
return new EntityIceDemon(worldObj); return new EntityIceDemon(worldObj);
} }
if (this.id == AlchemicalWizardry.entityBoulderFistID) if (this.id.equals(AlchemicalWizardry.entityBoulderFistID))
{ {
return new EntityBoulderFist(worldObj); return new EntityBoulderFist(worldObj);
} }
if (this.id == AlchemicalWizardry.entityShadeID) if (this.id.equals(AlchemicalWizardry.entityShadeID))
{ {
return new EntityShade(worldObj); return new EntityShade(worldObj);
} }
if (this.id == AlchemicalWizardry.entityAirElementalID) if (this.id.equals(AlchemicalWizardry.entityAirElementalID))
{ {
return new EntityAirElemental(worldObj); return new EntityAirElemental(worldObj);
} }
if (this.id == AlchemicalWizardry.entityWaterElementalID) if (this.id.equals(AlchemicalWizardry.entityWaterElementalID))
{ {
return new EntityWaterElemental(worldObj); return new EntityWaterElemental(worldObj);
} }
if (this.id == AlchemicalWizardry.entityEarthElementalID) if (this.id.equals(AlchemicalWizardry.entityEarthElementalID))
{ {
return new EntityEarthElemental(worldObj); return new EntityEarthElemental(worldObj);
} }
if (this.id == AlchemicalWizardry.entityFireElementalID) if (this.id.equals(AlchemicalWizardry.entityFireElementalID))
{ {
return new EntityFireElemental(worldObj); return new EntityFireElemental(worldObj);
} }
if (this.id == AlchemicalWizardry.entityShadeElementalID) if (this.id.equals(AlchemicalWizardry.entityShadeElementalID))
{ {
return new EntityShadeElemental(worldObj); return new EntityShadeElemental(worldObj);
} }
if (this.id == AlchemicalWizardry.entityHolyElementalID) if (this.id.equals(AlchemicalWizardry.entityHolyElementalID))
{ {
return new EntityHolyElemental(worldObj); return new EntityHolyElemental(worldObj);
} }
@ -90,7 +90,7 @@ public class SummoningHelperAW extends SummoningHelper
return new EntityPig(worldObj); return new EntityPig(worldObj);
} }
public int getSummoningHelperID() public String getSummoningHelperID()
{ {
return id; return id;
} }

View file

@ -183,7 +183,7 @@ item.sanguineBoots.name=Sanguine Boots
item.itemAttunedCrystal.name=Alchemic Router item.itemAttunedCrystal.name=Alchemic Router
item.itemTankSegmenter.name=Alchemic Segmenter item.itemTankSegmenter.name=Alchemic Segmenter
item.destinationClearer.name=Alchemic Cleanser item.destinationClearer.name=Alchemic Cleanser
item.demonPlacer.name=Demon Crystal
#Creative Tab #Creative Tab
itemGroup.tabBloodMagic=Blood Magic itemGroup.tabBloodMagic=Blood Magic