Testing the creation of hell

This commit is contained in:
WayofTime 2014-10-31 17:35:30 -04:00
parent 796e75b1f9
commit a2b006105e
2587 changed files with 0 additions and 129617 deletions

View file

@ -0,0 +1,498 @@
package WayofTime.alchemicalWizardry.common;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IProjectile;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerCapabilities;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.Vec3;
import net.minecraftforge.event.AnvilUpdateEvent;
import net.minecraftforge.event.entity.living.EnderTeleportEvent;
import net.minecraftforge.event.entity.living.LivingAttackEvent;
import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
import net.minecraftforge.event.entity.living.LivingSpawnEvent.CheckSpawn;
import vazkii.botania.api.internal.IManaBurst;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
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.tileEntity.TEMasterStone;
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.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerRespawnEvent;
import cpw.mods.fml.common.registry.GameRegistry;
public class AlchemicalWizardryEventHooks
{
public static Map<String, Boolean> playerFlightBuff = new HashMap();
public static Map<String, Boolean> playerBoostStepHeight = new HashMap();
public static List<String> playersWith1Step = new ArrayList();
public static Map<Integer, List<CoordAndRange>> respawnMap = 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
public void onPlayerDamageEvent(LivingAttackEvent event)
{
if (event.source.isProjectile())
{
if (event.entityLiving.isPotionActive(AlchemicalWizardry.customPotionProjProt) && event.isCancelable())
{
event.setCanceled(true);
}
}
}
@SubscribeEvent
public void onLivingSpawnEvent(CheckSpawn event)
{
if (!(event.entityLiving instanceof EntityMob))
{
return;
}
String respawnRitual = "AW028SpawnWard";
Integer dimension = new Integer(event.world.provider.dimensionId);
if (respawnMap.containsKey(dimension))
{
List<CoordAndRange> list = respawnMap.get(dimension);
if (list != null)
{
for (CoordAndRange coords : list)
{
TileEntity tile = event.world.getTileEntity(coords.xCoord, coords.yCoord, coords.zCoord);
if (tile instanceof TEMasterStone && ((TEMasterStone) tile).isRunning && ((TEMasterStone) tile).getCurrentRitual().equals(respawnRitual))
{
if (event.x > coords.xCoord - coords.horizRadius && event.x < coords.xCoord + coords.horizRadius && event.z > coords.zCoord - coords.horizRadius && event.z < coords.zCoord + coords.horizRadius && event.y > coords.yCoord - coords.vertRadius && event.y < coords.yCoord + coords.vertRadius)
{
switch (event.getResult())
{
case ALLOW:
event.setResult(Result.DEFAULT);
break;
case DEFAULT:
event.setResult(Result.DENY);
break;
case DENY:
break;
default:
break;
}
break;
}
} else
{
list.remove(coords);
}
}
}
}
if (event.entityLiving instanceof EntityCreeper)
{
GameRegistry d;
return;
}
String forceSpawnRitual = "AW029VeilOfEvil";
if (forceSpawnMap.containsKey(dimension))
{
List<CoordAndRange> list = forceSpawnMap.get(dimension);
if (list != null)
{
for (CoordAndRange coords : list)
{
TileEntity tile = event.world.getTileEntity(coords.xCoord, coords.yCoord, coords.zCoord);
if (tile instanceof TEMasterStone && ((TEMasterStone) tile).isRunning && ((TEMasterStone) tile).getCurrentRitual().equals(forceSpawnRitual))
{
if (event.x > coords.xCoord - coords.horizRadius && event.x < coords.xCoord + coords.horizRadius && event.z > coords.zCoord - coords.horizRadius && event.z < coords.zCoord + coords.horizRadius && event.y > coords.yCoord - coords.vertRadius && event.y < coords.yCoord + coords.vertRadius)
{
switch (event.getResult())
{
case ALLOW:
break;
case DEFAULT:
event.setResult(Result.ALLOW);
break;
case DENY:
event.setResult(Result.DEFAULT);
break;
default:
break;
}
break;
}
} else
{
list.remove(coords);
}
}
}
}
}
@SubscribeEvent
public void onPlayerRespawnEvent(PlayerRespawnEvent event)
{
if (AlchemicalWizardry.respawnWithDebuff)
{
event.player.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionSoulFray.id, 20 * 60 * 5, 0));
}
}
@SubscribeEvent
public void onLivingJumpEvent(LivingJumpEvent event)
{
if (event.entityLiving.isPotionActive(AlchemicalWizardry.customPotionBoost))
{
int i = event.entityLiving.getActivePotionEffect(AlchemicalWizardry.customPotionBoost).getAmplifier();
event.entityLiving.motionY += (0.1f) * (2 + i);
}
if (event.entityLiving.isPotionActive(AlchemicalWizardry.customPotionHeavyHeart))
{
event.entityLiving.motionY = 0;
}
}
@SubscribeEvent
public void onEndermanTeleportEvent(EnderTeleportEvent event)
{
if (event.entityLiving.isPotionActive(AlchemicalWizardry.customPotionPlanarBinding) && event.isCancelable())
{
event.setCanceled(true);
}
}
@SubscribeEvent
public void onEntityDamaged(LivingAttackEvent event)
{
EntityLivingBase entityAttacked = event.entityLiving;
if (entityAttacked.isPotionActive(AlchemicalWizardry.customPotionReciprocation))
{
Entity entityAttacking = event.source.getSourceOfDamage();
if (entityAttacking != null && entityAttacking instanceof EntityLivingBase)
{
int i = event.entityLiving.getActivePotionEffect(AlchemicalWizardry.customPotionReciprocation).getAmplifier();
float damageRecieve = event.ammount / 2 * (i + 1);
((EntityLivingBase) entityAttacking).attackEntityFrom(DamageSource.generic, damageRecieve);
}
}
if (entityAttacked.isPotionActive(AlchemicalWizardry.customPotionFlameCloak))
{
int i = event.entityLiving.getActivePotionEffect(AlchemicalWizardry.customPotionFlameCloak).getAmplifier();
Entity entityAttacking = event.source.getSourceOfDamage();
if (entityAttacking != null && entityAttacking instanceof EntityLivingBase && !entityAttacking.isImmuneToFire() && !((EntityLivingBase) entityAttacking).isPotionActive(Potion.fireResistance))
{
entityAttacking.attackEntityFrom(DamageSource.inFire, 2 * i + 2);
entityAttacking.setFire(3);
}
}
}
// @ForgeSubscribe
// public void onFOVUpdate(FOVUpdateEvent event)
// {
// event.setResult(Result.DEFAULT);
// }
// @SubscribeEvent
// public void onPlayerTickEnd(PlayerTickEvent event)
// {
// if(event.type.equals(Type.PLAYER) && event.phase.equals(TickEvent.Phase.END))
// {
// ObfuscationReflectionHelper.setPrivateValue(PlayerCapabilities.class, event.player.capabilities, Float.valueOf(0.1f), new String[]{"walkSpeed", "g", "field_75097_g"});
// }
// }
@SubscribeEvent
public void onEntityUpdate(LivingUpdateEvent event)
{
EntityLivingBase entityLiving = event.entityLiving;
double x = entityLiving.posX;
double y = entityLiving.posY;
double z = entityLiving.posZ;
Vec3 blockVector = SpellHelper.getEntityBlockVector(entityLiving);
int xPos = (int) (blockVector.xCoord);
int yPos = (int) (blockVector.yCoord);
int zPos = (int) (blockVector.zCoord);
if (entityLiving instanceof EntityPlayer)
{
ObfuscationReflectionHelper.setPrivateValue(PlayerCapabilities.class, ((EntityPlayer) event.entityLiving).capabilities, Float.valueOf(0.1f), new String[]{"walkSpeed", "g", "field_75097_g"});
}
if (entityLiving instanceof EntityPlayer && entityLiving.worldObj.isRemote)
{
EntityPlayer entityPlayer = (EntityPlayer) entityLiving;
boolean highStepListed = playersWith1Step.contains(entityPlayer.getDisplayName());
boolean hasHighStep = entityPlayer.isPotionActive(AlchemicalWizardry.customPotionBoost);
if (hasHighStep && !highStepListed)
{
playersWith1Step.add(SpellHelper.getUsername(entityPlayer));
}
if (!hasHighStep && highStepListed)
{
playersWith1Step.remove(SpellHelper.getUsername(entityPlayer));
entityPlayer.stepHeight = 0.5F;
}
}
if (event.entityLiving.isPotionActive(AlchemicalWizardry.customPotionFeatherFall))
{
event.entityLiving.fallDistance = 0;
}
if (event.entityLiving.isPotionActive(AlchemicalWizardry.customPotionDrowning))
{
int i = event.entityLiving.getActivePotionEffect(AlchemicalWizardry.customPotionDrowning).getAmplifier();
if (event.entityLiving.worldObj.getWorldTime() % ((int) (20 / (i + 1))) == 0)
{
event.entityLiving.attackEntityFrom(DamageSource.drown, 2);
event.entityLiving.hurtResistantTime = Math.min(event.entityLiving.hurtResistantTime, 20 / (i + 1));
}
}
if (event.entityLiving.isPotionActive(AlchemicalWizardry.customPotionBoost))
{
int i = event.entityLiving.getActivePotionEffect(AlchemicalWizardry.customPotionBoost).getAmplifier();
EntityLivingBase entity = event.entityLiving;
//if(!entity.isSneaking())
{
float percentIncrease = (i + 1) * 0.05f;
if (event.entityLiving instanceof EntityPlayer)
{
EntityPlayer entityPlayer = (EntityPlayer) event.entityLiving;
entityPlayer.stepHeight = 1.0f;
if ((entityPlayer.onGround || entityPlayer.capabilities.isFlying) && entityPlayer.moveForward > 0F)
entityPlayer.moveFlying(0F, 1F, entityPlayer.capabilities.isFlying ? (percentIncrease / 2.0f) : percentIncrease);
}
}
}
if (event.entityLiving.isPotionActive(AlchemicalWizardry.customPotionProjProt))
{
int i = event.entityLiving.getActivePotionEffect(AlchemicalWizardry.customPotionProjProt).getAmplifier();
EntityLivingBase entity = event.entityLiving;
int posX = (int) Math.round(entity.posX - 0.5f);
int posY = (int) Math.round(entity.posY);
int posZ = (int) Math.round(entity.posZ - 0.5f);
int d0 = (int) ((i + 1) * 2.5);
AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox(posX - 0.5, posY - 0.5, posZ - 0.5, posX + 0.5, posY + 0.5, posZ + 0.5).expand(d0, d0, d0);
List list = event.entityLiving.worldObj.getEntitiesWithinAABB(Entity.class, axisalignedbb);
Iterator iterator = list.iterator();
EntityLivingBase livingEntity;
while (iterator.hasNext())
{
Entity projectile = (Entity) iterator.next();
if (projectile == null)
{
continue;
}
if (!(projectile instanceof IProjectile) || (AlchemicalWizardry.isBotaniaLoaded && isManaBurst(projectile)))
{
continue;
}
Entity throwingEntity = null;
if (projectile instanceof EntityArrow)
{
throwingEntity = ((EntityArrow) projectile).shootingEntity;
} else if (projectile instanceof EnergyBlastProjectile)
{
throwingEntity = ((EnergyBlastProjectile) projectile).shootingEntity;
} else if (projectile instanceof EntityThrowable)
{
throwingEntity = ((EntityThrowable) projectile).getThrower();
}
if (throwingEntity != null && throwingEntity.equals(entity))
{
continue;
}
double delX = projectile.posX - entity.posX;
double delY = projectile.posY - entity.posY;
double delZ = projectile.posZ - entity.posZ;
if (throwingEntity != null)
{
delX = -projectile.posX + throwingEntity.posX;
delY = -projectile.posY + (throwingEntity.posY + throwingEntity.getEyeHeight());
delZ = -projectile.posZ + throwingEntity.posZ;
}
double curVel = Math.sqrt(delX * delX + delY * delY + delZ * delZ);
delX /= curVel;
delY /= curVel;
delZ /= curVel;
double newVel = Math.sqrt(projectile.motionX * projectile.motionX + projectile.motionY * projectile.motionY + projectile.motionZ * projectile.motionZ);
projectile.motionX = newVel * delX;
projectile.motionY = newVel * delY;
projectile.motionZ = newVel * delZ;
//TODO make this not affect player's projectiles
}
}
if (event.entityLiving.isPotionActive(AlchemicalWizardry.customPotionFlight))
{
if (event.entityLiving instanceof EntityPlayer)
{
EntityPlayer entityPlayer = (EntityPlayer) event.entityLiving;
String ownerName = SpellHelper.getUsername(entityPlayer);
playerFlightBuff.put(ownerName, true);
entityPlayer.capabilities.allowFlying = true;
}
} else
{
if (event.entityLiving instanceof EntityPlayer)
{
EntityPlayer entityPlayer = (EntityPlayer) event.entityLiving;
String ownerName = SpellHelper.getUsername(entityPlayer);
if (!playerFlightBuff.containsKey(ownerName))
{
playerFlightBuff.put(ownerName, false);
}
if (playerFlightBuff.get(ownerName))
{
playerFlightBuff.put(ownerName, false);
if (!entityPlayer.capabilities.isCreativeMode)
{
entityPlayer.capabilities.allowFlying = false;
entityPlayer.capabilities.isFlying = false;
entityPlayer.sendPlayerAbilities();
}
}
}
}
if (entityLiving.isPotionActive(AlchemicalWizardry.customPotionFlameCloak))
{
entityLiving.worldObj.spawnParticle("flame", x + SpellHelper.gaussian(1), y - 1.3 + SpellHelper.gaussian(0.3), z + SpellHelper.gaussian(1), 0, 0.06d, 0);
int i = event.entityLiving.getActivePotionEffect(AlchemicalWizardry.customPotionFlameCloak).getAmplifier();
double range = i * 0.5;
List<Entity> entities = SpellHelper.getEntitiesInRange(entityLiving.worldObj, x, y, z, range, range);
if (entities != null)
{
for (Entity entity : entities)
{
if (!entity.equals(entityLiving) && !entity.isImmuneToFire() && !(entity instanceof EntityLivingBase && ((EntityLivingBase) entity).isPotionActive(Potion.fireResistance)))
{
entity.setFire(3);
}
}
}
}
if (entityLiving.isPotionActive(AlchemicalWizardry.customPotionIceCloak))
{
if (entityLiving.worldObj.getWorldTime() % 2 == 0)
entityLiving.worldObj.spawnParticle("reddust", x + SpellHelper.gaussian(1), y - 1.3 + SpellHelper.gaussian(0.3), z + SpellHelper.gaussian(1), 0x74, 0xbb, 0xfb);
int r = event.entityLiving.getActivePotionEffect(AlchemicalWizardry.customPotionIceCloak).getAmplifier();
int horizRange = r + 1;
int vertRange = 1;
if (!entityLiving.worldObj.isRemote)
{
for (int i = -horizRange; i <= horizRange; i++)
{
for (int k = -horizRange; k <= horizRange; k++)
{
for (int j = -vertRange - 1; j <= vertRange - 1; j++)
{
SpellHelper.freezeWaterBlock(entityLiving.worldObj, xPos + i, yPos + j, zPos + k);
}
}
}
}
}
if (entityLiving.isPotionActive(AlchemicalWizardry.customPotionHeavyHeart))
{
entityLiving.worldObj.spawnParticle("flame", x + SpellHelper.gaussian(1), y - 1.3 + SpellHelper.gaussian(0.3), z + SpellHelper.gaussian(1), 0, 0.06d, 0);
int i = event.entityLiving.getActivePotionEffect(AlchemicalWizardry.customPotionHeavyHeart).getAmplifier();
double decrease = 0.025 * (i + 1);
if (entityLiving.motionY > -0.9)
{
entityLiving.motionY -= decrease;
}
}
if (entityLiving.isPotionActive(AlchemicalWizardry.customPotionFireFuse))
{
entityLiving.worldObj.spawnParticle("flame", x + SpellHelper.gaussian(1), y - 1.3 + SpellHelper.gaussian(0.3), z + SpellHelper.gaussian(1), 0, 0.06d, 0);
int r = event.entityLiving.getActivePotionEffect(AlchemicalWizardry.customPotionFireFuse).getAmplifier();
int radius = r + 1;
if (entityLiving.getActivePotionEffect(AlchemicalWizardry.customPotionFireFuse).getDuration() <= 2)
{
entityLiving.worldObj.createExplosion(null, x, y, z, radius, false);
}
}
}
@Optional.Method(modid = "Botania")
private boolean isManaBurst(Entity projectile)
{
return projectile instanceof IManaBurst;
}
}

View file

@ -0,0 +1,68 @@
package WayofTime.alchemicalWizardry.common;
import WayofTime.alchemicalWizardry.ModItems;
import WayofTime.alchemicalWizardry.common.items.LavaCrystal;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import cpw.mods.fml.common.IFuelHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.server.MinecraftServer;
public class AlchemicalWizardryFuelHandler implements IFuelHandler
{
@Override
public int getBurnTime(ItemStack fuel)
{
ItemStack itemStack = fuel;
if (itemStack == null)
{
return 0;
}
Item fuelItem = itemStack.getItem();
if (fuelItem.equals(ModItems.lavaCrystal))
{
LavaCrystal item = (LavaCrystal) fuel.getItem();
if (item.hasEnoughEssence(fuel))
{
return 200;
} else
{
NBTTagCompound tag = itemStack.stackTagCompound;
if (tag == null)
{
return 0;
}
if (MinecraftServer.getServer() == null)
{
return 0;
}
if (MinecraftServer.getServer().getConfigurationManager() == null)
{
return 0;
}
EntityPlayer owner = SpellHelper.getPlayerForUsername(tag.getString("ownerName"));
if (owner == null)
{
return 0;
}
owner.addPotionEffect(new PotionEffect(Potion.confusion.id, 80));
return 0;
}
}
return 0;
}
}

View file

@ -0,0 +1,23 @@
package WayofTime.alchemicalWizardry.common;
public class ArmourComponent
{
private int xOff;
private int zOff;
public ArmourComponent(int xOff, int zOff)
{
this.xOff = xOff;
this.zOff = zOff;
}
public int getXOff()
{
return xOff;
}
public int getZOff()
{
return zOff;
}
}

View file

@ -0,0 +1,79 @@
package WayofTime.alchemicalWizardry.common;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.entity.projectile.*;
import WayofTime.alchemicalWizardry.common.spell.complex.EntitySpellProjectile;
import WayofTime.alchemicalWizardry.common.tileEntity.TEAltar;
import WayofTime.alchemicalWizardry.common.tileEntity.TEMasterStone;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.world.World;
public class CommonProxy
{
public static String ITEMS_PNG = "/WayofTime/alchemicalWizardry/items.png";
public static String BLOCK_PNG = "/WayofTime/alchemicalWizardry/block.png";
// Client stuff
public void registerRenderers()
{
// Nothing here as the server doesn't render graphics!
}
public void registerEntities()
{
}
public World getClientWorld()
{
return null;
}
public void registerActions()
{
}
public void registerEvents()
{
}
public void registerSoundHandler()
{
// Nothing here as this is a server side proxy
}
public void registerTileEntities()
{
GameRegistry.registerTileEntity(TEAltar.class, "containerAltar");
GameRegistry.registerTileEntity(TEMasterStone.class, "containerMasterStone");
}
public void registerEntityTrackers()
{
EntityRegistry.registerModEntity(EnergyBlastProjectile.class, "energyBlastProjectile", 0, AlchemicalWizardry.instance, 128, 5, true);
EntityRegistry.registerModEntity(FireProjectile.class, "fireProjectile", 1, AlchemicalWizardry.instance, 128, 5, true);
EntityRegistry.registerModEntity(IceProjectile.class, "iceProjectile", 2, AlchemicalWizardry.instance, 128, 5, true);
EntityRegistry.registerModEntity(ExplosionProjectile.class, "explosionProjectile", 3, AlchemicalWizardry.instance, 128, 5, true);
EntityRegistry.registerModEntity(HolyProjectile.class, "holyProjectile", 4, AlchemicalWizardry.instance, 128, 5, true);
EntityRegistry.registerModEntity(WindGustProjectile.class, "windGustProjectile", 5, AlchemicalWizardry.instance, 128, 5, true);
EntityRegistry.registerModEntity(LightningBoltProjectile.class, "lightningBoltProjectile", 6, AlchemicalWizardry.instance, 128, 5, true);
EntityRegistry.registerModEntity(WaterProjectile.class, "waterProjectile", 7, AlchemicalWizardry.instance, 128, 5, true);
EntityRegistry.registerModEntity(MudProjectile.class, "mudProjectile", 8, AlchemicalWizardry.instance, 128, 5, true);
EntityRegistry.registerModEntity(TeleportProjectile.class, "teleportProjectile", 9, AlchemicalWizardry.instance, 128, 5, true);
EntityRegistry.registerModEntity(EntityEnergyBazookaMainProjectile.class, "energyBazookaMain", 10, AlchemicalWizardry.instance, 128, 3, true);
EntityRegistry.registerModEntity(EntityEnergyBazookaSecondaryProjectile.class, "energyBazookaSecondary", 11, AlchemicalWizardry.instance, 128, 3, true);
EntityRegistry.registerModEntity(EntityBloodLightProjectile.class, "bloodLightProjectile", 12, AlchemicalWizardry.instance, 128, 3, true);
EntityRegistry.registerModEntity(EntityMeteor.class, "meteor", 13, AlchemicalWizardry.instance, 120, 3, true);
EntityRegistry.registerModEntity(EntitySpellProjectile.class, "spellProjectile", 14, AlchemicalWizardry.instance, 128, 3, true);
EntityRegistry.registerModEntity(EntityParticleBeam.class, "particleBeam", 15, AlchemicalWizardry.instance, 120, 3, true);
}
public void registerTickHandlers()
{
}
public void InitRendering()
{
// TODO Auto-generated method stub
}
}

View file

@ -0,0 +1,25 @@
package WayofTime.alchemicalWizardry.common;
public class CoordAndRange
{
public int xCoord;
public int yCoord;
public int zCoord;
public int horizRadius;
public int vertRadius;
public CoordAndRange(int x, int y, int z, int horiz, int vert)
{
this.xCoord = x;
this.yCoord = y;
this.zCoord = z;
this.horizRadius = horiz;
this.vertRadius = vert;
}
@Override
public boolean equals(Object o)
{
return o instanceof CoordAndRange ? ((CoordAndRange) o).xCoord == this.xCoord && ((CoordAndRange) o).yCoord == this.yCoord && ((CoordAndRange) o).zCoord == this.zCoord && ((CoordAndRange) o).horizRadius == this.horizRadius && ((CoordAndRange) o).vertRadius == this.vertRadius : false;
}
}

View file

@ -0,0 +1,24 @@
package WayofTime.alchemicalWizardry.common;
import WayofTime.alchemicalWizardry.common.entity.mob.EntityDemon;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
public class EntityAITargetAggro extends EntityAINearestAttackableTarget
{
private EntityDemon theCreature;
public EntityAITargetAggro(EntityDemon par1EntityDemon, Class par2Class, int par3, boolean par4)
{
super(par1EntityDemon, par2Class, par3, par4);
this.theCreature = par1EntityDemon;
}
/**
* Returns whether the EntityAIBase should begin execution.
*/
@Override
public boolean shouldExecute()
{
return theCreature.isAggro() && super.shouldExecute();
}
}

View file

@ -0,0 +1,32 @@
package WayofTime.alchemicalWizardry.common;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.entity.mob.EntityElemental;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
public class EntityAirElemental extends EntityElemental implements IMob
{
public EntityAirElemental(World world)
{
super(world, AlchemicalWizardry.entityAirElementalID);
}
public void inflictEffectOnEntity(Entity target)
{
if (target instanceof EntityPlayer)
{
SpellHelper.setPlayerSpeedFromServer((EntityPlayer) target, target.motionX, target.motionY + 3, target.motionZ);
((EntityLivingBase) target).addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionInhibit.id, 150, 0));
} else if (target instanceof EntityLivingBase)
{
((EntityLivingBase) target).motionY += 3.0D;
((EntityLivingBase) target).addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionInhibit.id, 150, 0));
}
}
}

View file

@ -0,0 +1,6 @@
package WayofTime.alchemicalWizardry.common;
public interface IBindingAgent
{
public abstract float getSuccessRateForPotionNumber(int potionEffects);
}

View file

@ -0,0 +1,8 @@
package WayofTime.alchemicalWizardry.common;
public interface ICatalyst
{
public abstract int getCatalystLevel();
public abstract boolean isConcentration();
}

View file

@ -0,0 +1,10 @@
package WayofTime.alchemicalWizardry.common;
public interface IDemon
{
public abstract void setSummonedConditions();
public boolean isAggro();
public void setAggro(boolean aggro);
}

View file

@ -0,0 +1,6 @@
package WayofTime.alchemicalWizardry.common;
public interface IFillingAgent
{
public abstract int getFilledAmountForPotionNumber(int potionEffects);
}

View file

@ -0,0 +1,38 @@
package WayofTime.alchemicalWizardry.common;
import net.minecraft.nbt.NBTTagCompound;
public class Int3
{
public int xCoord;
public int yCoord;
public int zCoord;
public Int3(int xCoord, int yCoord, int zCoord)
{
this.xCoord = xCoord;
this.yCoord = yCoord;
this.zCoord = zCoord;
}
public static Int3 readFromNBT(NBTTagCompound tag)
{
return new Int3(tag.getInteger("xCoord"), tag.getInteger("yCoord"), tag.getInteger("zCoord"));
}
public NBTTagCompound writeToNBT(NBTTagCompound tag)
{
tag.setInteger("xCoord", xCoord);
tag.setInteger("yCoord", yCoord);
tag.setInteger("zCoord", zCoord);
return tag;
}
@Override
public boolean equals(Object o)
{
return o instanceof Int3 ? ((Int3) o).xCoord == this.xCoord && ((Int3) o).yCoord == this.yCoord && ((Int3) o).zCoord == this.zCoord : false;
}
}

View file

@ -0,0 +1,42 @@
package WayofTime.alchemicalWizardry.common;
import WayofTime.alchemicalWizardry.ModBlocks;
import WayofTime.alchemicalWizardry.ModItems;
import cpw.mods.fml.common.eventhandler.Event.Result;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.player.FillBucketEvent;
public class LifeBucketHandler
{
@SubscribeEvent
public void onBucketFill(FillBucketEvent event)
{
ItemStack result = fillCustomBucket(event.world, event.target);
if (result == null)
{
return;
}
event.result = result;
event.setResult(Result.ALLOW);
}
public ItemStack fillCustomBucket(World world, MovingObjectPosition pos)
{
Block block = world.getBlock(pos.blockX, pos.blockY, pos.blockZ);
if (block != null && (block.equals(ModBlocks.blockLifeEssence)) && world.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ) == 0)
{
world.setBlockToAir(pos.blockX, pos.blockY, pos.blockZ);
return new ItemStack(ModItems.bucketLife);
} else
{
return null;
}
}
}

View file

@ -0,0 +1,25 @@
package WayofTime.alchemicalWizardry.common;
import net.minecraftforge.fluids.Fluid;
public class LifeEssence extends Fluid
{
public LifeEssence(String fluidName)
{
super(fluidName);
this.setDensity(2000);
this.setViscosity(2000);
}
@Override
public int getColor()
{
return 0xEEEEEE;
}
@Override
public String getLocalizedName()
{
return "Life Essence";
}
}

View file

@ -0,0 +1,36 @@
package WayofTime.alchemicalWizardry.common;
import WayofTime.alchemicalWizardry.ModItems;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraftforge.event.entity.living.LivingDropsEvent;
public class ModLivingDropsEvent
{
public static double rand;
@SubscribeEvent
public void onEntityDrop(LivingDropsEvent event)
{
if (event.source.getDamageType().equals("player"))
{
rand = Math.random();
if (!(event.entityLiving instanceof EntityAnimal))
{
PotionEffect effect = event.entityLiving.getActivePotionEffect(Potion.weakness);
if (effect != null)
{
if (effect.getAmplifier() >= 2)
if (rand < 0.50d)
{
event.entityLiving.dropItem(ModItems.weakBloodShard, 1);
}
}
}
}
}
}

View file

@ -0,0 +1,954 @@
package WayofTime.alchemicalWizardry.common;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.api.ColourAndCoords;
import WayofTime.alchemicalWizardry.common.tileEntity.*;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.network.FMLEmbeddedChannel;
import cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec;
import cpw.mods.fml.common.network.FMLOutboundHandler;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.Packet;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.EnumMap;
import java.util.LinkedList;
import java.util.List;
/**
* Handles the packet wrangling for IronChest
*
* @author cpw
*/
public enum NewPacketHandler
{
INSTANCE;
/**
* Our channel "pair" from {@link NetworkRegistry}
*/
private EnumMap<Side, FMLEmbeddedChannel> channels;
/**
* Make our packet handler, and add an {@link IronChestCodec} always
*/
private NewPacketHandler()
{
// request a channel pair for IronChest from the network registry
// Add the IronChestCodec as a member of both channel pipelines
this.channels = NetworkRegistry.INSTANCE.newChannel("BloodMagic", new TEAltarCodec());
if (FMLCommonHandler.instance().getSide() == Side.CLIENT)
{
addClientHandler();
}
}
@SideOnly(Side.CLIENT)
private void addClientHandler()
{
FMLEmbeddedChannel clientChannel = this.channels.get(Side.CLIENT);
String tileAltarCodec = clientChannel.findChannelHandlerNameForType(TEAltarCodec.class);
clientChannel.pipeline().addAfter(tileAltarCodec, "TEAltarHandler", new TEAltarMessageHandler());
clientChannel.pipeline().addAfter(tileAltarCodec, "TEOrientableHandler", new TEOrientableMessageHandler());
clientChannel.pipeline().addAfter(tileAltarCodec, "TEPedestalHandler", new TEPedestalMessageHandler());
clientChannel.pipeline().addAfter(tileAltarCodec, "TEPlinthHandler", new TEPlinthMessageHandler());
clientChannel.pipeline().addAfter(tileAltarCodec, "TESocketHandler", new TESocketMessageHandler());
clientChannel.pipeline().addAfter(tileAltarCodec, "TETeleposerHandler", new TETeleposerMessageHandler());
clientChannel.pipeline().addAfter(tileAltarCodec, "TEWritingTableHandler", new TEWritingTableMessageHandler());
clientChannel.pipeline().addAfter(tileAltarCodec, "ParticleHandler", new ParticleMessageHandler());
clientChannel.pipeline().addAfter(tileAltarCodec, "VelocityHandler", new VelocityMessageHandler());
clientChannel.pipeline().addAfter(tileAltarCodec, "TEMasterStoneHandler", new TEMasterStoneMessageHandler());
clientChannel.pipeline().addAfter(tileAltarCodec, "TEReagentConduitHandler", new TEReagentConduitMessageHandler());
}
/**
* This class simply handles the {@link IronChestMessage} when it's received
* at the client side It can contain client only code, because it's only run
* on the client.
*
* @author cpw
*/
private static class TEAltarMessageHandler extends SimpleChannelInboundHandler<TEAltarMessage>
{
@Override
protected void channelRead0(ChannelHandlerContext ctx, TEAltarMessage msg) throws Exception
{
World world = AlchemicalWizardry.proxy.getClientWorld();
TileEntity te = world.getTileEntity(msg.x, msg.y, msg.z);
if (te instanceof TEAltar)
{
TEAltar altar = (TEAltar) te;
altar.handlePacketData(msg.items, msg.fluids, msg.capacity);
}
}
}
private static class TEOrientableMessageHandler extends SimpleChannelInboundHandler<TEOrientableMessage>
{
@Override
protected void channelRead0(ChannelHandlerContext ctx, TEOrientableMessage msg) throws Exception
{
World world = AlchemicalWizardry.proxy.getClientWorld();
TileEntity te = world.getTileEntity(msg.x, msg.y, msg.z);
if (te instanceof TEOrientable)
{
TEOrientable tile = (TEOrientable) te;
((TEOrientable) te).setInputDirection(ForgeDirection.getOrientation(msg.input));
((TEOrientable) te).setOutputDirection(ForgeDirection.getOrientation(msg.output));
}
}
}
private static class TEPedestalMessageHandler extends SimpleChannelInboundHandler<TEPedestalMessage>
{
@Override
protected void channelRead0(ChannelHandlerContext ctx, TEPedestalMessage msg) throws Exception
{
World world = AlchemicalWizardry.proxy.getClientWorld();
TileEntity te = world.getTileEntity(msg.x, msg.y, msg.z);
if (te instanceof TEPedestal)
{
TEPedestal pedestal = (TEPedestal) te;
pedestal.handlePacketData(msg.items);
}
}
}
private static class TEPlinthMessageHandler extends SimpleChannelInboundHandler<TEPlinthMessage>
{
@Override
protected void channelRead0(ChannelHandlerContext ctx, TEPlinthMessage msg) throws Exception
{
World world = AlchemicalWizardry.proxy.getClientWorld();
TileEntity te = world.getTileEntity(msg.x, msg.y, msg.z);
if (te instanceof TEPlinth)
{
TEPlinth Plinth = (TEPlinth) te;
Plinth.handlePacketData(msg.items);
}
}
}
private static class TESocketMessageHandler extends SimpleChannelInboundHandler<TESocketMessage>
{
@Override
protected void channelRead0(ChannelHandlerContext ctx, TESocketMessage msg) throws Exception
{
World world = AlchemicalWizardry.proxy.getClientWorld();
TileEntity te = world.getTileEntity(msg.x, msg.y, msg.z);
if (te instanceof TESocket)
{
TESocket Socket = (TESocket) te;
Socket.handlePacketData(msg.items);
}
}
}
private static class TETeleposerMessageHandler extends SimpleChannelInboundHandler<TETeleposerMessage>
{
@Override
protected void channelRead0(ChannelHandlerContext ctx, TETeleposerMessage msg) throws Exception
{
World world = AlchemicalWizardry.proxy.getClientWorld();
TileEntity te = world.getTileEntity(msg.x, msg.y, msg.z);
if (te instanceof TETeleposer)
{
TETeleposer Teleposer = (TETeleposer) te;
Teleposer.handlePacketData(msg.items);
}
}
}
private static class TEWritingTableMessageHandler extends SimpleChannelInboundHandler<TEWritingTableMessage>
{
@Override
protected void channelRead0(ChannelHandlerContext ctx, TEWritingTableMessage msg) throws Exception
{
World world = AlchemicalWizardry.proxy.getClientWorld();
TileEntity te = world.getTileEntity(msg.x, msg.y, msg.z);
if (te instanceof TEWritingTable)
{
TEWritingTable WritingTable = (TEWritingTable) te;
WritingTable.handlePacketData(msg.items);
}
}
}
private static class ParticleMessageHandler extends SimpleChannelInboundHandler<ParticleMessage>
{
@Override
protected void channelRead0(ChannelHandlerContext ctx, ParticleMessage msg) throws Exception
{
World world = AlchemicalWizardry.proxy.getClientWorld();
world.spawnParticle(msg.particle, msg.xCoord, msg.yCoord, msg.zCoord, msg.xVel, msg.yVel, msg.zVel);
}
}
private static class VelocityMessageHandler extends SimpleChannelInboundHandler<VelocityMessage>
{
@Override
protected void channelRead0(ChannelHandlerContext ctx, VelocityMessage msg) throws Exception
{
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
if (player != null)
{
player.motionX = msg.xVel;
player.motionY = msg.yVel;
player.motionZ = msg.zVel;
}
}
}
private static class TEMasterStoneMessageHandler extends SimpleChannelInboundHandler<TEMasterStoneMessage>
{
@Override
protected void channelRead0(ChannelHandlerContext ctx, TEMasterStoneMessage msg) throws Exception
{
World world = AlchemicalWizardry.proxy.getClientWorld();
TileEntity te = world.getTileEntity(msg.x, msg.y, msg.z);
if (te instanceof TEMasterStone)
{
TEMasterStone masterStone = (TEMasterStone) te;
masterStone.setCurrentRitual(msg.ritual);
masterStone.isRunning = msg.isRunning;
}
}
}
private static class TEReagentConduitMessageHandler extends SimpleChannelInboundHandler<TEReagentConduitMessage>
{
@Override
protected void channelRead0(ChannelHandlerContext ctx, TEReagentConduitMessage msg) throws Exception
{
World world = AlchemicalWizardry.proxy.getClientWorld();
TileEntity te = world.getTileEntity(msg.x, msg.y, msg.z);
if (te instanceof TEReagentConduit)
{
TEReagentConduit reagentConduit = (TEReagentConduit) te;
reagentConduit.destinationList = msg.destinationList;
}
}
}
public static class BMMessage
{
int index;
}
public static class TEAltarMessage extends BMMessage
{
int x;
int y;
int z;
int[] items;
int[] fluids;
int capacity;
}
public static class TEOrientableMessage extends BMMessage
{
int x;
int y;
int z;
int input;
int output;
}
public static class TEPedestalMessage extends BMMessage
{
int x;
int y;
int z;
int[] items;
}
public static class TEPlinthMessage extends BMMessage
{
int x;
int y;
int z;
int[] items;
}
public static class TESocketMessage extends BMMessage
{
int x;
int y;
int z;
int[] items;
}
public static class TETeleposerMessage extends BMMessage
{
int x;
int y;
int z;
int[] items;
}
public static class TEWritingTableMessage extends BMMessage
{
int x;
int y;
int z;
int[] items;
}
public static class ParticleMessage extends BMMessage
{
String particle;
double xCoord;
double yCoord;
double zCoord;
double xVel;
double yVel;
double zVel;
}
public static class VelocityMessage extends BMMessage
{
double xVel;
double yVel;
double zVel;
}
public static class TEMasterStoneMessage extends BMMessage
{
int x;
int y;
int z;
String ritual;
boolean isRunning;
}
public static class TEReagentConduitMessage extends BMMessage
{
int x;
int y;
int z;
List<ColourAndCoords> destinationList;
}
private class TEAltarCodec extends FMLIndexedMessageToMessageCodec<BMMessage>
{
public TEAltarCodec()
{
addDiscriminator(0, TEAltarMessage.class);
addDiscriminator(1, TEOrientableMessage.class);
addDiscriminator(2, TEPedestalMessage.class);
addDiscriminator(3, TEPlinthMessage.class);
addDiscriminator(4, TESocketMessage.class);
addDiscriminator(5, TETeleposerMessage.class);
addDiscriminator(6, TEWritingTableMessage.class);
addDiscriminator(7, ParticleMessage.class);
addDiscriminator(8, VelocityMessage.class);
addDiscriminator(9, TEMasterStoneMessage.class);
addDiscriminator(10, TEReagentConduitMessage.class);
}
@Override
public void encodeInto(ChannelHandlerContext ctx, BMMessage msg, ByteBuf target) throws Exception
{
target.writeInt(msg.index);
switch (msg.index)
{
case 0:
target.writeInt(((TEAltarMessage) msg).x);
target.writeInt(((TEAltarMessage) msg).y);
target.writeInt(((TEAltarMessage) msg).z);
target.writeBoolean(((TEAltarMessage) msg).items != null);
if (((TEAltarMessage) msg).items != null)
{
int[] items = ((TEAltarMessage) msg).items;
for (int j = 0; j < items.length; j++)
{
int i = items[j];
target.writeInt(i);
}
}
target.writeBoolean(((TEAltarMessage) msg).fluids != null);
if (((TEAltarMessage) msg).fluids != null)
{
int[] fluids = ((TEAltarMessage) msg).fluids;
for (int j = 0; j < fluids.length; j++)
{
int i = fluids[j];
target.writeInt(i);
}
}
target.writeInt(((TEAltarMessage) msg).capacity);
break;
case 1:
target.writeInt(((TEOrientableMessage) msg).x);
target.writeInt(((TEOrientableMessage) msg).y);
target.writeInt(((TEOrientableMessage) msg).z);
target.writeInt(((TEOrientableMessage) msg).input);
target.writeInt(((TEOrientableMessage) msg).output);
break;
case 2:
target.writeInt(((TEPedestalMessage) msg).x);
target.writeInt(((TEPedestalMessage) msg).y);
target.writeInt(((TEPedestalMessage) msg).z);
target.writeBoolean(((TEPedestalMessage) msg).items != null);
if (((TEPedestalMessage) msg).items != null)
{
int[] items = ((TEPedestalMessage) msg).items;
for (int j = 0; j < items.length; j++)
{
int i = items[j];
target.writeInt(i);
}
}
break;
case 3:
target.writeInt(((TEPlinthMessage) msg).x);
target.writeInt(((TEPlinthMessage) msg).y);
target.writeInt(((TEPlinthMessage) msg).z);
target.writeBoolean(((TEPlinthMessage) msg).items != null);
if (((TEPlinthMessage) msg).items != null)
{
int[] items = ((TEPlinthMessage) msg).items;
for (int j = 0; j < items.length; j++)
{
int i = items[j];
target.writeInt(i);
}
}
break;
case 4:
target.writeInt(((TESocketMessage) msg).x);
target.writeInt(((TESocketMessage) msg).y);
target.writeInt(((TESocketMessage) msg).z);
target.writeBoolean(((TESocketMessage) msg).items != null);
if (((TESocketMessage) msg).items != null)
{
int[] items = ((TESocketMessage) msg).items;
for (int j = 0; j < items.length; j++)
{
int i = items[j];
target.writeInt(i);
}
}
break;
case 5:
target.writeInt(((TETeleposerMessage) msg).x);
target.writeInt(((TETeleposerMessage) msg).y);
target.writeInt(((TETeleposerMessage) msg).z);
target.writeBoolean(((TETeleposerMessage) msg).items != null);
if (((TETeleposerMessage) msg).items != null)
{
int[] items = ((TETeleposerMessage) msg).items;
for (int j = 0; j < items.length; j++)
{
int i = items[j];
target.writeInt(i);
}
}
break;
case 6:
target.writeInt(((TEWritingTableMessage) msg).x);
target.writeInt(((TEWritingTableMessage) msg).y);
target.writeInt(((TEWritingTableMessage) msg).z);
target.writeBoolean(((TEWritingTableMessage) msg).items != null);
if (((TEWritingTableMessage) msg).items != null)
{
int[] items = ((TEWritingTableMessage) msg).items;
for (int j = 0; j < items.length; j++)
{
int i = items[j];
target.writeInt(i);
}
}
break;
case 7:
String str = ((ParticleMessage) msg).particle;
target.writeInt(str.length());
for (int i = 0; i < str.length(); i++)
{
target.writeChar(str.charAt(i));
}
target.writeDouble(((ParticleMessage) msg).xCoord);
target.writeDouble(((ParticleMessage) msg).yCoord);
target.writeDouble(((ParticleMessage) msg).zCoord);
target.writeDouble(((ParticleMessage) msg).xVel);
target.writeDouble(((ParticleMessage) msg).yVel);
target.writeDouble(((ParticleMessage) msg).zVel);
break;
case 8:
target.writeDouble(((VelocityMessage) msg).xVel);
target.writeDouble(((VelocityMessage) msg).yVel);
target.writeDouble(((VelocityMessage) msg).zVel);
break;
case 9:
target.writeInt(((TEMasterStoneMessage) msg).x);
target.writeInt(((TEMasterStoneMessage) msg).y);
target.writeInt(((TEMasterStoneMessage) msg).z);
String ritual = ((TEMasterStoneMessage) msg).ritual;
target.writeInt(ritual.length());
for (int i = 0; i < ritual.length(); i++)
{
target.writeChar(ritual.charAt(i));
}
target.writeBoolean(((TEMasterStoneMessage) msg).isRunning);
break;
case 10:
target.writeInt(((TEReagentConduitMessage) msg).x);
target.writeInt(((TEReagentConduitMessage) msg).y);
target.writeInt(((TEReagentConduitMessage) msg).z);
List<ColourAndCoords> list = ((TEReagentConduitMessage) msg).destinationList;
target.writeInt(list.size());
for (ColourAndCoords colourSet : list)
{
target.writeInt(colourSet.colourRed);
target.writeInt(colourSet.colourGreen);
target.writeInt(colourSet.colourBlue);
target.writeInt(colourSet.colourIntensity);
target.writeInt(colourSet.xCoord);
target.writeInt(colourSet.yCoord);
target.writeInt(colourSet.zCoord);
}
break;
}
}
@Override
public void decodeInto(ChannelHandlerContext ctx, ByteBuf dat, BMMessage msg)
{
int index = dat.readInt();
switch (index)
{
case 0:
((TEAltarMessage) msg).x = dat.readInt();
((TEAltarMessage) msg).y = dat.readInt();
((TEAltarMessage) msg).z = dat.readInt();
boolean hasStacks = dat.readBoolean();
((TEAltarMessage) msg).items = new int[TEAltar.sizeInv * 3];
if (hasStacks)
{
((TEAltarMessage) msg).items = new int[TEAltar.sizeInv * 3];
for (int i = 0; i < ((TEAltarMessage) msg).items.length; i++)
{
((TEAltarMessage) msg).items[i] = dat.readInt();
}
}
boolean hasFluids = dat.readBoolean();
((TEAltarMessage) msg).fluids = new int[6];
if (hasFluids)
for (int i = 0; i < ((TEAltarMessage) msg).fluids.length; i++)
{
((TEAltarMessage) msg).fluids[i] = dat.readInt();
}
((TEAltarMessage) msg).capacity = dat.readInt();
break;
case 1:
((TEOrientableMessage) msg).x = dat.readInt();
((TEOrientableMessage) msg).y = dat.readInt();
((TEOrientableMessage) msg).z = dat.readInt();
((TEOrientableMessage) msg).input = dat.readInt();
((TEOrientableMessage) msg).output = dat.readInt();
break;
case 2:
((TEPedestalMessage) msg).x = dat.readInt();
((TEPedestalMessage) msg).y = dat.readInt();
((TEPedestalMessage) msg).z = dat.readInt();
boolean hasStacks1 = dat.readBoolean();
((TEPedestalMessage) msg).items = new int[TEPedestal.sizeInv * 3];
if (hasStacks1)
{
((TEPedestalMessage) msg).items = new int[TEPedestal.sizeInv * 3];
for (int i = 0; i < ((TEPedestalMessage) msg).items.length; i++)
{
((TEPedestalMessage) msg).items[i] = dat.readInt();
}
}
break;
case 3:
((TEPlinthMessage) msg).x = dat.readInt();
((TEPlinthMessage) msg).y = dat.readInt();
((TEPlinthMessage) msg).z = dat.readInt();
boolean hasStacks2 = dat.readBoolean();
((TEPlinthMessage) msg).items = new int[TEPlinth.sizeInv * 3];
if (hasStacks2)
{
((TEPlinthMessage) msg).items = new int[TEPlinth.sizeInv * 3];
for (int i = 0; i < ((TEPlinthMessage) msg).items.length; i++)
{
((TEPlinthMessage) msg).items[i] = dat.readInt();
}
}
break;
case 4:
((TESocketMessage) msg).x = dat.readInt();
((TESocketMessage) msg).y = dat.readInt();
((TESocketMessage) msg).z = dat.readInt();
boolean hasStacks3 = dat.readBoolean();
((TESocketMessage) msg).items = new int[TESocket.sizeInv * 3];
if (hasStacks3)
{
((TESocketMessage) msg).items = new int[TESocket.sizeInv * 3];
for (int i = 0; i < ((TESocketMessage) msg).items.length; i++)
{
((TESocketMessage) msg).items[i] = dat.readInt();
}
}
break;
case 5:
((TETeleposerMessage) msg).x = dat.readInt();
((TETeleposerMessage) msg).y = dat.readInt();
((TETeleposerMessage) msg).z = dat.readInt();
boolean hasStacks4 = dat.readBoolean();
((TETeleposerMessage) msg).items = new int[TETeleposer.sizeInv * 3];
if (hasStacks4)
{
((TETeleposerMessage) msg).items = new int[TETeleposer.sizeInv * 3];
for (int i = 0; i < ((TETeleposerMessage) msg).items.length; i++)
{
((TETeleposerMessage) msg).items[i] = dat.readInt();
}
}
break;
case 6:
((TEWritingTableMessage) msg).x = dat.readInt();
((TEWritingTableMessage) msg).y = dat.readInt();
((TEWritingTableMessage) msg).z = dat.readInt();
boolean hasStacks5 = dat.readBoolean();
((TEWritingTableMessage) msg).items = new int[TEWritingTable.sizeInv * 3];
if (hasStacks5)
{
((TEWritingTableMessage) msg).items = new int[TEWritingTable.sizeInv * 3];
for (int i = 0; i < ((TEWritingTableMessage) msg).items.length; i++)
{
((TEWritingTableMessage) msg).items[i] = dat.readInt();
}
}
break;
case 7:
int size = dat.readInt();
String str = "";
for (int i = 0; i < size; i++)
{
str = str + dat.readChar();
}
((ParticleMessage) msg).particle = str;
((ParticleMessage) msg).xCoord = dat.readDouble();
((ParticleMessage) msg).yCoord = dat.readDouble();
((ParticleMessage) msg).zCoord = dat.readDouble();
((ParticleMessage) msg).xVel = dat.readDouble();
((ParticleMessage) msg).yVel = dat.readDouble();
((ParticleMessage) msg).zVel = dat.readDouble();
break;
case 8:
((VelocityMessage) msg).xVel = dat.readDouble();
((VelocityMessage) msg).yVel = dat.readDouble();
((VelocityMessage) msg).zVel = dat.readDouble();
break;
case 9:
((TEMasterStoneMessage) msg).x = dat.readInt();
((TEMasterStoneMessage) msg).y = dat.readInt();
((TEMasterStoneMessage) msg).z = dat.readInt();
int ritualStrSize = dat.readInt();
String ritual = "";
for (int i = 0; i < ritualStrSize; i++)
{
ritual = ritual + dat.readChar();
}
((TEMasterStoneMessage) msg).ritual = ritual;
((TEMasterStoneMessage) msg).isRunning = dat.readBoolean();
break;
case 10:
((TEReagentConduitMessage) msg).x = dat.readInt();
((TEReagentConduitMessage) msg).y = dat.readInt();
((TEReagentConduitMessage) msg).z = dat.readInt();
int listSize = dat.readInt();
List<ColourAndCoords> list = new LinkedList();
for (int i = 0; i < listSize; i++)
{
list.add(new ColourAndCoords(dat.readInt(), dat.readInt(), dat.readInt(), dat.readInt(), dat.readInt(), dat.readInt(), dat.readInt()));
}
((TEReagentConduitMessage) msg).destinationList = list;
break;
}
}
}
//Packets to be obtained
public static Packet getPacket(TEAltar tileAltar)
{
TEAltarMessage msg = new TEAltarMessage();
msg.index = 0;
msg.x = tileAltar.xCoord;
msg.y = tileAltar.yCoord;
msg.z = tileAltar.zCoord;
msg.items = tileAltar.buildIntDataList();
msg.fluids = tileAltar.buildFluidList();
msg.capacity = tileAltar.getCapacity();
return INSTANCE.channels.get(Side.SERVER).generatePacketFrom(msg);
}
public static Packet getPacket(TEOrientable tileOrientable)
{
TEOrientableMessage msg = new TEOrientableMessage();
msg.index = 1;
msg.x = tileOrientable.xCoord;
msg.y = tileOrientable.yCoord;
msg.z = tileOrientable.zCoord;
msg.input = tileOrientable.getIntForForgeDirection(tileOrientable.getInputDirection());
msg.output = tileOrientable.getIntForForgeDirection(tileOrientable.getOutputDirection());
return INSTANCE.channels.get(Side.SERVER).generatePacketFrom(msg);
}
public static Packet getPacket(TEPedestal tilePedestal)
{
TEPedestalMessage msg = new TEPedestalMessage();
msg.index = 2;
msg.x = tilePedestal.xCoord;
msg.y = tilePedestal.yCoord;
msg.z = tilePedestal.zCoord;
msg.items = tilePedestal.buildIntDataList();
return INSTANCE.channels.get(Side.SERVER).generatePacketFrom(msg);
}
public static Packet getPacket(TEPlinth tilePlinth)
{
TEPlinthMessage msg = new TEPlinthMessage();
msg.index = 3;
msg.x = tilePlinth.xCoord;
msg.y = tilePlinth.yCoord;
msg.z = tilePlinth.zCoord;
msg.items = tilePlinth.buildIntDataList();
return INSTANCE.channels.get(Side.SERVER).generatePacketFrom(msg);
}
public static Packet getPacket(TESocket tileSocket)
{
TESocketMessage msg = new TESocketMessage();
msg.index = 4;
msg.x = tileSocket.xCoord;
msg.y = tileSocket.yCoord;
msg.z = tileSocket.zCoord;
msg.items = tileSocket.buildIntDataList();
return INSTANCE.channels.get(Side.SERVER).generatePacketFrom(msg);
}
public static Packet getPacket(TETeleposer tileTeleposer)
{
TETeleposerMessage msg = new TETeleposerMessage();
msg.index = 5;
msg.x = tileTeleposer.xCoord;
msg.y = tileTeleposer.yCoord;
msg.z = tileTeleposer.zCoord;
msg.items = tileTeleposer.buildIntDataList();
return INSTANCE.channels.get(Side.SERVER).generatePacketFrom(msg);
}
public static Packet getPacket(TEWritingTable tileWritingTable)
{
TEWritingTableMessage msg = new TEWritingTableMessage();
msg.index = 6;
msg.x = tileWritingTable.xCoord;
msg.y = tileWritingTable.yCoord;
msg.z = tileWritingTable.zCoord;
msg.items = tileWritingTable.buildIntDataList();
return INSTANCE.channels.get(Side.SERVER).generatePacketFrom(msg);
}
public static Packet getParticlePacket(String str, double xCoord, double yCoord, double zCoord, double xVel, double yVel, double zVel)
{
ParticleMessage msg = new ParticleMessage();
msg.index = 7;
msg.particle = str;
msg.xCoord = xCoord;
msg.yCoord = yCoord;
msg.zCoord = zCoord;
msg.xVel = xVel;
msg.yVel = yVel;
msg.zVel = zVel;
return INSTANCE.channels.get(Side.SERVER).generatePacketFrom(msg);
}
public static Packet getVelSettingPacket(double xVel, double yVel, double zVel)
{
VelocityMessage msg = new VelocityMessage();
msg.index = 8;
msg.xVel = xVel;
msg.yVel = yVel;
msg.zVel = zVel;
return INSTANCE.channels.get(Side.SERVER).generatePacketFrom(msg);
}
public static Packet getPacket(TEMasterStone tile)
{
TEMasterStoneMessage msg = new TEMasterStoneMessage();
msg.index = 9;
msg.x = tile.xCoord;
msg.y = tile.yCoord;
msg.z = tile.zCoord;
msg.ritual = tile.getCurrentRitual();
msg.isRunning = tile.isRunning;
return INSTANCE.channels.get(Side.SERVER).generatePacketFrom(msg);
}
public static Packet getPacket(TEReagentConduit tile)
{
TEReagentConduitMessage msg = new TEReagentConduitMessage();
msg.index = 10;
msg.x = tile.xCoord;
msg.y = tile.yCoord;
msg.z = tile.zCoord;
msg.destinationList = tile.destinationList;
return INSTANCE.channels.get(Side.SERVER).generatePacketFrom(msg);
}
public void sendTo(Packet message, EntityPlayerMP player)
{
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER);
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(player);
this.channels.get(Side.SERVER).writeAndFlush(message);
}
public void sendToAll(Packet message)
{
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALL);
this.channels.get(Side.SERVER).writeAndFlush(message);
}
public void sendToAllAround(Packet message, NetworkRegistry.TargetPoint point)
{
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALLAROUNDPOINT);
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(point);
this.channels.get(Side.SERVER).writeAndFlush(message);
}
}

View file

@ -0,0 +1,37 @@
package WayofTime.alchemicalWizardry.common;
public class PlinthComponent
{
public int xOffset;
public int yOffset;
public int zOffset;
public int ring;
public PlinthComponent(int xOffset, int yOffset, int zOffset, int ring)
{
this.xOffset = xOffset;
this.yOffset = yOffset;
this.zOffset = zOffset;
this.ring = ring;
}
public int getXOffset()
{
return xOffset;
}
public int getYOffset()
{
return yOffset;
}
public int getZOffset()
{
return zOffset;
}
public int getRing()
{
return ring;
}
}

View file

@ -0,0 +1,27 @@
package WayofTime.alchemicalWizardry.common.alchemy;
import net.minecraft.potion.Potion;
public class CombinedPotionComponent
{
public Potion result;
public Potion pot1;
public Potion pot2;
public CombinedPotionComponent(Potion result, Potion pot1, Potion pot2)
{
this.result = result;
this.pot1 = pot1;
this.pot2 = pot2;
}
public boolean isRecipeValid(Potion test1, Potion test2)
{
return (test1 == pot1 && test2 == pot2) || (test1 == pot2 && test2 == pot1);
}
public boolean isRecipeValid(int test1, int test2)
{
return (test1 == pot1.id && test2 == pot2.id) || (test1 == pot2.id && test2 == pot1.id);
}
}

View file

@ -0,0 +1,182 @@
package WayofTime.alchemicalWizardry.common.alchemy;
import WayofTime.alchemicalWizardry.api.alchemy.AlchemyPotionHelper;
import WayofTime.alchemicalWizardry.common.items.potion.AlchemyFlask;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import java.util.ArrayList;
import java.util.List;
public class CombinedPotionRegistry
{
public static List<CombinedPotionComponent> potionList = new ArrayList();
public static void registerCombinedPotionRecipe(Potion result, Potion pot1, Potion pot2)
{
potionList.add(new CombinedPotionComponent(result, pot1, pot2));
}
public static boolean isRecipeValid(Potion pot1, Potion pot2)
{
for (CombinedPotionComponent recipe : potionList)
{
if (recipe.isRecipeValid(pot1, pot2))
{
return true;
}
}
return false;
}
public static boolean isRecipeValid(int pot1, int pot2)
{
for (CombinedPotionComponent recipe : potionList)
{
if (recipe.isRecipeValid(pot1, pot2))
{
return true;
}
}
return false;
}
public static Potion getPotion(Potion pot1, Potion pot2)
{
for (CombinedPotionComponent recipe : potionList)
{
if (recipe.isRecipeValid(pot1, pot2))
{
return recipe.result;
}
}
return null;
}
public static Potion getPotion(int pot1, int pot2)
{
for (CombinedPotionComponent recipe : potionList)
{
if (recipe.isRecipeValid(pot1, pot2))
{
return recipe.result;
}
}
return null;
}
public static ItemStack applyPotionEffect(ItemStack stack)
{
if (stack == null || !(stack.getItem() instanceof AlchemyFlask))
{
return null;
}
List<AlchemyPotionHelper> list = AlchemyFlask.getEffects(stack);
if (list == null)
{
return stack;
}
boolean isDone = false;
for (AlchemyPotionHelper helper1 : list)
{
if (isDone)
{
continue;
}
for (int i = 0; i < list.size(); i++)
{
if (isDone)
{
continue;
}
AlchemyPotionHelper helper2 = list.get(i);
PotionEffect potEffect = getResultantPotion(helper1, helper2);
if (potEffect != null)
{
AlchemyPotionHelper potHelper = new AlchemyPotionHelper(potEffect.getPotionID(), potEffect.getDuration(), 0, potEffect.getAmplifier());
list.remove(helper1);
list.remove(helper2);
list.add(potHelper);
isDone = true;
}
}
}
if (isDone)
{
AlchemyFlask.setEffects(stack, list);
return stack;
}
return null;
}
public static boolean hasCombinablePotionEffect(ItemStack stack)
{
if (stack == null || !(stack.getItem() instanceof AlchemyFlask))
{
return false;
}
List<AlchemyPotionHelper> list = AlchemyFlask.getEffects(stack);
if (list == null)
{
return false;
}
for (AlchemyPotionHelper helper1 : list)
{
for (AlchemyPotionHelper helper2 : list)
{
int pot1 = helper1.getPotionID();
int pot2 = helper2.getPotionID();
if (isRecipeValid(pot1, pot2))
{
return true;
}
}
}
return false;
}
public static PotionEffect getResultantPotion(AlchemyPotionHelper potE1, AlchemyPotionHelper potE2)
{
if (potE1 == null || potE2 == null)
{
return null;
}
int pot1 = potE1.getPotionID();
int pot2 = potE2.getPotionID();
if (isRecipeValid(pot1, pot2))
{
int duration = (int) ((potE1.getTickDuration() * Math.pow(8.0f / 3.0f, potE1.getdurationFactor()) + potE2.getdurationFactor() * Math.pow(8.0f / 3.0f, potE2.getdurationFactor())) / 2.0);
int amplifier = (potE1.getConcentration() + potE2.getConcentration()) / 2;
Potion pot = getPotion(pot1, pot2);
return new PotionEffect(pot.id, duration, amplifier);
}
return null;
}
}

View file

@ -0,0 +1,5 @@
package WayofTime.alchemicalWizardry.common.alchemy;
public interface ICombinationalCatalyst
{
}

View file

@ -0,0 +1,332 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.ModItems;
import WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade;
import WayofTime.alchemicalWizardry.common.ArmourComponent;
import WayofTime.alchemicalWizardry.common.items.BoundArmour;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import WayofTime.alchemicalWizardry.common.tileEntity.TESocket;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.List;
public class ArmourForge extends Block
{
public static List<ArmourComponent> helmetList = new ArrayList();
public static List<ArmourComponent> plateList = new ArrayList();
public static List<ArmourComponent> leggingsList = new ArrayList();
public static List<ArmourComponent> bootsList = new ArrayList();
public ArmourForge()
{
super(Material.iron);
setHardness(2.0F);
setResistance(5.0F);
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
this.setBlockName("armourForge");
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister)
{
this.blockIcon = iconRegister.registerIcon("AlchemicalWizardry:SoulForge");
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int idk, float what, float these, float are)
{
if (world.isRemote)
{
return false;
}
int armourType = getArmourType(world, x, y, z);
if (armourType == -1)
{
return false;
}
int direction = getDirectionForArmourType(world, x, y, z, armourType);
if (!isParadigmValid(armourType, direction, world, x, y, z))
{
return false;
}
List<ArmourComponent> list = null;
ItemStack armourPiece = null;
switch (armourType)
{
case 0:
list = plateList;
armourPiece = new ItemStack(ModItems.boundPlate, 1, 0);
break;
case 1:
list = leggingsList;
armourPiece = new ItemStack(ModItems.boundLeggings, 1, 0);
break;
case 2:
list = helmetList;
armourPiece = new ItemStack(ModItems.boundHelmet, 1, 0);
break;
case 3:
list = bootsList;
armourPiece = new ItemStack(ModItems.boundBoots, 1, 0);
break;
}
if (list == null)
{
return false;
}
if (armourPiece == null)
{
return false;
}
if (armourPiece.stackTagCompound == null)
{
armourPiece.setTagCompound(new NBTTagCompound());
}
for (ArmourComponent ac : list)
{
int xOff = ac.getXOff();
int zOff = ac.getZOff();
TileEntity tileEntity;
switch (direction)
{
case 1:
tileEntity = world.getTileEntity(x + xOff, y, z - zOff);
break;
case 2:
tileEntity = world.getTileEntity(x + zOff, y, z + xOff);
break;
case 3:
tileEntity = world.getTileEntity(x - xOff, y, z + zOff);
break;
case 4:
tileEntity = world.getTileEntity(x - zOff, y, z - xOff);
break;
case 5:
tileEntity = world.getTileEntity(x + xOff, y + zOff, z);
break;
case 6:
tileEntity = world.getTileEntity(x, y + zOff, z + xOff);
break;
default:
tileEntity = null;
}
if (tileEntity instanceof TESocket)
{
ItemStack itemStack = ((TESocket) tileEntity).getStackInSlot(0);
int xCoord = tileEntity.xCoord;
int yCoord = tileEntity.yCoord;
int zCoord = tileEntity.zCoord;
((TESocket) tileEntity).setInventorySlotContents(0, null);
world.setBlockToAir(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
for (int i = 0; i < 8; i++)
{
SpellHelper.sendIndexedParticleToAllAround(world, xCoord, yCoord, zCoord, 20, world.provider.dimensionId, 1, xCoord, yCoord, zCoord);
}
if (itemStack != null)
{
Item item = itemStack.getItem();
if (item instanceof ArmourUpgrade)
{
((BoundArmour) armourPiece.getItem()).hasAddedToInventory(armourPiece, itemStack.copy());
((TESocket) tileEntity).setInventorySlotContents(0, null);
}
}
}
}
if (armourPiece != null)
{
int xOff = (world.rand.nextInt(11) - 5);
int zOff = (int) (Math.sqrt(25 - xOff * xOff) * (world.rand.nextInt(2) - 0.5) * 2);
world.addWeatherEffect(new EntityLightningBolt(world, x + xOff, y + 5, z + zOff));
world.spawnEntityInWorld(new EntityItem(world, x, y + 1, z, armourPiece));
}
return true;
}
//0 for plate, 1 for leggings, 2 for helmet, 3 for boots
public int getArmourType(World world, int x, int y, int z)
{
for (int i = 0; i <= 3; i++)
{
if (getDirectionForArmourType(world, x, y, z, i) != -1)
{
return i;
}
}
return -1;
}
public int getDirectionForArmourType(World world, int x, int y, int z, int armourType)
{
for (int i = 1; i <= 6; i++)
{
if (isParadigmValid(armourType, i, world, x, y, z))
{
return i;
}
}
return -1;
}
public boolean isParadigmValid(int armourType, int direction, World world, int x, int y, int z)
{
List<ArmourComponent> list = null;
switch (armourType)
{
case 0:
list = plateList;
break;
case 1:
list = leggingsList;
break;
case 2:
list = helmetList;
break;
case 3:
list = bootsList;
break;
}
if (list == null)
{
return false;
}
for (ArmourComponent ac : list)
{
int xOff = ac.getXOff();
int zOff = ac.getZOff();
switch (direction)
{
case 1:
if (!(world.getTileEntity(x + xOff, y, z - zOff) instanceof TESocket))
{
return false;
}
break;
case 2:
if (!(world.getTileEntity(x + zOff, y, z + xOff) instanceof TESocket))
{
return false;
}
break;
case 3:
if (!(world.getTileEntity(x - xOff, y, z + zOff) instanceof TESocket))
{
return false;
}
break;
case 4:
if (!(world.getTileEntity(x - zOff, y, z - xOff) instanceof TESocket))
{
return false;
}
break;
case 5:
if (!(world.getTileEntity(x + xOff, y + zOff, z) instanceof TESocket))
{
return false;
}
break;
case 6:
if (!(world.getTileEntity(x, y + zOff, z + xOff) instanceof TESocket))
{
return false;
}
break;
default:
return false;
}
}
return true;
}
public static void initializeRecipes()
{
helmetList.add(new ArmourComponent(-1, 1));
helmetList.add(new ArmourComponent(0, 1));
helmetList.add(new ArmourComponent(1, 1));
helmetList.add(new ArmourComponent(-1, 0));
helmetList.add(new ArmourComponent(1, 0));
bootsList.add(new ArmourComponent(-1, 1));
bootsList.add(new ArmourComponent(1, 1));
bootsList.add(new ArmourComponent(-1, 0));
bootsList.add(new ArmourComponent(1, 0));
plateList.add(new ArmourComponent(-1, 0));
plateList.add(new ArmourComponent(1, 0));
plateList.add(new ArmourComponent(-1, -1));
plateList.add(new ArmourComponent(0, -1));
plateList.add(new ArmourComponent(1, -1));
plateList.add(new ArmourComponent(-1, -2));
plateList.add(new ArmourComponent(0, -2));
plateList.add(new ArmourComponent(1, -2));
leggingsList.add(new ArmourComponent(-1, 1));
leggingsList.add(new ArmourComponent(0, 1));
leggingsList.add(new ArmourComponent(1, 1));
leggingsList.add(new ArmourComponent(-1, 0));
leggingsList.add(new ArmourComponent(1, 0));
leggingsList.add(new ArmourComponent(-1, -1));
leggingsList.add(new ArmourComponent(1, -1));
}
}

View file

@ -0,0 +1,167 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.api.items.interfaces.IBloodOrb;
import WayofTime.alchemicalWizardry.api.items.interfaces.IReagentManipulator;
import WayofTime.alchemicalWizardry.common.tileEntity.TEAlchemicCalcinator;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import java.util.Random;
public class BlockAlchemicCalcinator extends BlockContainer
{
public BlockAlchemicCalcinator()
{
super(Material.rock);
setHardness(2.0F);
setResistance(5.0F);
this.setCreativeTab(AlchemicalWizardry.tabBloodMagic);
this.setBlockName("alchemicCalcinator");
}
@Override
public TileEntity createNewTileEntity(World world, int meta)
{
return new TEAlchemicCalcinator();
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public int getRenderType()
{
return -1;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean hasTileEntity()
{
return true;
}
@Override
public boolean canProvidePower()
{
return true;
}
@Override
public void breakBlock(World world, int x, int y, int z, Block par5, int par6)
{
dropItems(world, x, y, z);
super.breakBlock(world, x, y, z, par5, par6);
}
private void dropItems(World world, int x, int y, int z)
{
Random rand = new Random();
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (!(tileEntity instanceof IInventory))
{
return;
}
IInventory inventory = (IInventory) tileEntity;
for (int i = 0; i < inventory.getSizeInventory(); i++)
{
ItemStack item = inventory.getStackInSlot(i);
if (item != null && item.stackSize > 0)
{
float rx = rand.nextFloat() * 0.8F + 0.1F;
float ry = rand.nextFloat() * 0.8F + 0.1F;
float rz = rand.nextFloat() * 0.8F + 0.1F;
EntityItem entityItem = new EntityItem(world,
x + rx, y + ry, z + rz,
new ItemStack(item.getItem(), item.stackSize, item.getItemDamage()));
if (item.hasTagCompound())
{
entityItem.getEntityItem().setTagCompound((NBTTagCompound) item.getTagCompound().copy());
}
float factor = 0.05F;
entityItem.motionX = rand.nextGaussian() * factor;
entityItem.motionY = rand.nextGaussian() * factor + 0.2F;
entityItem.motionZ = rand.nextGaussian() * factor;
world.spawnEntityInWorld(entityItem);
item.stackSize = 0;
}
}
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int idk, float what, float these, float are)
{
TEAlchemicCalcinator tileEntity = (TEAlchemicCalcinator) world.getTileEntity(x, y, z);
if (tileEntity == null || player.isSneaking())
{
return false;
}
ItemStack playerItem = player.getCurrentEquippedItem();
if (playerItem != null)
{
if (playerItem.getItem() instanceof IReagentManipulator)
{
return false;
}
if (playerItem.getItem() instanceof IBloodOrb)
{
if (tileEntity.getStackInSlot(0) == null)
{
ItemStack newItem = playerItem.copy();
newItem.stackSize = 1;
--playerItem.stackSize;
tileEntity.setInventorySlotContents(0, newItem);
}
} else if (tileEntity.getStackInSlot(1) == null)
{
ItemStack newItem = playerItem.copy();
newItem.stackSize = 1;
--playerItem.stackSize;
tileEntity.setInventorySlotContents(1, newItem);
}
} else if (playerItem == null)
{
if (tileEntity.getStackInSlot(1) != null)
{
player.inventory.addItemStackToInventory(tileEntity.getStackInSlot(1));
tileEntity.setInventorySlotContents(1, null);
} else if (tileEntity.getStackInSlot(0) != null)
{
player.inventory.addItemStackToInventory(tileEntity.getStackInSlot(0));
tileEntity.setInventorySlotContents(0, null);
}
}
tileEntity.getWorldObj().markBlockForUpdate(x, y, z);
return true;
}
}

View file

@ -0,0 +1,273 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.ModItems;
import WayofTime.alchemicalWizardry.common.items.EnergyBattery;
import WayofTime.alchemicalWizardry.common.items.sigil.SigilOfHolding;
import WayofTime.alchemicalWizardry.common.tileEntity.TEAltar;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
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.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import java.util.Random;
public class BlockAltar extends BlockContainer
{
@SideOnly(Side.CLIENT)
private static IIcon topIcon;
@SideOnly(Side.CLIENT)
private static IIcon sideIcon1;
@SideOnly(Side.CLIENT)
private static IIcon sideIcon2;
@SideOnly(Side.CLIENT)
private static IIcon bottomIcon;
public BlockAltar()
{
super(Material.rock);
setHardness(2.0F);
setResistance(5.0F);
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
this.setBlockName("bloodAltar");
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister)
{
this.topIcon = iconRegister.registerIcon("AlchemicalWizardry:BloodAltar_Top");
this.sideIcon1 = iconRegister.registerIcon("AlchemicalWizardry:BloodAltar_SideType1");
this.sideIcon2 = iconRegister.registerIcon("AlchemicalWizardry:BloodAltar_SideType2");
this.bottomIcon = iconRegister.registerIcon("AlchemicalWizardry:BloodAltar_Bottom");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta)
{
switch (side)
{
case 0:
return bottomIcon;
case 1:
return topIcon;
default:
return sideIcon2;
}
}
@Override
public boolean hasComparatorInputOverride()
{
return true;
}
@Override
public int getComparatorInputOverride(World world, int x, int y, int z, int meta)
{
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TEAltar)
{
ItemStack stack = ((TEAltar) tile).getStackInSlot(0);
if (stack != null && stack.getItem() instanceof EnergyBattery)
{
EnergyBattery bloodOrb = (EnergyBattery) stack.getItem();
int maxEssence = bloodOrb.getMaxEssence();
int currentEssence = bloodOrb.getCurrentEssence(stack);
int level = currentEssence * 15 / maxEssence;
return ((int) (Math.min(15, level))) % 16;
}
}
return 0;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int idk, float what, float these, float are)
{
TEAltar tileEntity = (TEAltar) world.getTileEntity(x, y, z);
if (tileEntity == null || player.isSneaking())
{
return false;
}
ItemStack playerItem = player.getCurrentEquippedItem();
if (playerItem != null)
{
if (playerItem.getItem().equals(ModItems.divinationSigil))
{
if (player.worldObj.isRemote)
{
world.markBlockForUpdate(x, y, z);
} else
{
tileEntity.sendChatInfoToPlayer(player);
}
return true;
} else if (playerItem.getItem().equals(ModItems.itemSeerSigil))
{
if (player.worldObj.isRemote)
{
world.markBlockForUpdate(x, y, z);
} else
{
tileEntity.sendMoreChatInfoToPlayer(player);
}
return true;
} else if (playerItem.getItem().equals(ModItems.sigilOfHolding))
{
ItemStack item = ((SigilOfHolding) playerItem.getItem()).getCurrentItem(playerItem);
if (item != null && item.getItem().equals(ModItems.divinationSigil))
{
if (player.worldObj.isRemote)
{
world.markBlockForUpdate(x, y, z);
} else
{
tileEntity.sendChatInfoToPlayer(player);
}
return true;
} else if (item != null && item.getItem().equals(ModItems.itemSeerSigil))
{
if (player.worldObj.isRemote)
{
world.markBlockForUpdate(x, y, z);
} else
{
tileEntity.sendMoreChatInfoToPlayer(player);
}
return true;
}
}
}
if (tileEntity.getStackInSlot(0) == null && playerItem != null)
{
ItemStack newItem = playerItem.copy();
newItem.stackSize = 1;
--playerItem.stackSize;
tileEntity.setInventorySlotContents(0, newItem);
tileEntity.startCycle();
} else if (tileEntity.getStackInSlot(0) != null && playerItem == null)
{
player.inventory.addItemStackToInventory(tileEntity.getStackInSlot(0));
tileEntity.setInventorySlotContents(0, null);
tileEntity.setActive();
}
world.markBlockForUpdate(x, y, z);
return true;
}
@Override
public void breakBlock(World world, int x, int y, int z, Block par5, int par6)
{
dropItems(world, x, y, z);
super.breakBlock(world, x, y, z, par5, par6);
}
private void dropItems(World world, int x, int y, int z)
{
Random rand = new Random();
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (!(tileEntity instanceof IInventory))
{
return;
}
IInventory inventory = (IInventory) tileEntity;
for (int i = 0; i < inventory.getSizeInventory(); i++)
{
ItemStack item = inventory.getStackInSlot(i);
if (item != null && item.stackSize > 0)
{
float rx = rand.nextFloat() * 0.8F + 0.1F;
float ry = rand.nextFloat() * 0.8F + 0.1F;
float rz = rand.nextFloat() * 0.8F + 0.1F;
EntityItem entityItem = new EntityItem(world,
x + rx, y + ry, z + rz,
new ItemStack(item.getItem(), item.stackSize, item.getItemDamage()));
if (item.hasTagCompound())
{
entityItem.getEntityItem().setTagCompound((NBTTagCompound) item.getTagCompound().copy());
}
float factor = 0.05F;
entityItem.motionX = rand.nextGaussian() * factor;
entityItem.motionY = rand.nextGaussian() * factor + 0.2F;
entityItem.motionZ = rand.nextGaussian() * factor;
world.spawnEntityInWorld(entityItem);
item.stackSize = 0;
}
}
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public int getRenderType()
{
return -1;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean hasTileEntity()
{
return true;
}
@Override
public void randomDisplayTick(World world, int x, int y, int z, Random rand)
{
TEAltar tileEntity = (TEAltar) world.getTileEntity(x, y, z);
if (!tileEntity.isActive())
{
return;
}
if (rand.nextInt(3) != 0)
{
return;
}
}
@Override
public TileEntity createNewTileEntity(World var1, int var2)
{
return new TEAltar();
}
}

View file

@ -0,0 +1,115 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.tileEntity.TEBellJar;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import java.util.ArrayList;
public class BlockBelljar extends BlockContainer
{
public BlockBelljar()
{
super(Material.glass);
setHardness(2.0F);
setResistance(5.0F);
this.setCreativeTab(AlchemicalWizardry.tabBloodMagic);
this.setBlockName("crystalBelljar");
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack stack)
{
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TEBellJar)
{
NBTTagCompound tag = stack.getTagCompound();
if (tag != null)
{
((TEBellJar) tile).readTankNBTOnPlace(tag);
}
}
}
@Override
public TileEntity createNewTileEntity(World world, int meta)
{
return new TEBellJar();
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public int getRenderType()
{
return -1;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean hasTileEntity()
{
return true;
}
@Override
public boolean hasComparatorInputOverride()
{
return true;
}
@Override
public int getComparatorInputOverride(World world, int x, int y, int z, int meta)
{
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TEBellJar)
{
return ((TEBellJar) tile).getRSPowerOutput();
}
return 15;
}
@Override
public void onBlockHarvested(World world, int x, int y, int z, int meta, EntityPlayer player)
{
this.dropBlockAsItem(world, x, y, z, meta, 0);
super.onBlockHarvested(world, x, y, z, meta, player);
}
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune)
{
ArrayList<ItemStack> list = new ArrayList();
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TEBellJar)
{
ItemStack drop = new ItemStack(this);
NBTTagCompound tag = new NBTTagCompound();
((TEBellJar) tile).writeTankNBT(tag);
drop.stackTagCompound = tag;
list.add(drop);
}
return list;
}
}

View file

@ -0,0 +1,73 @@
package WayofTime.alchemicalWizardry.common.block;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import java.util.List;
import java.util.Random;
public class BlockBloodLightSource extends Block
{
public BlockBloodLightSource()
{
super(Material.cloth);
this.setBlockName("blockBloodLightSource");
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister)
{
this.blockIcon = iconRegister.registerIcon("AlchemicalWizardry:BlockBloodLight");
}
@Override
public int getLightValue(IBlockAccess world, int x, int y, int z)
{
return 15;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public void randomDisplayTick(World world, int x, int y, int z, Random rand)
{
if (rand.nextInt(3) != 0)
{
float f = (float) 1.0F;
float f1 = f * 0.6F + 0.4F;
float f2 = f * f * 0.7F - 0.5F;
float f3 = f * f * 0.6F - 0.7F;
world.spawnParticle("reddust", x + 0.5D + rand.nextGaussian() / 8, y + 0.5D, z + 0.5D + rand.nextGaussian() / 8, f1, f2, f3);
}
}
@Override
public void addCollisionBoxesToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity)
{
this.setBlockBounds(0.40F, 0.40F, 0.40F, 0.60F, 0.60F, 0.60F);
}
public int quantityDropped(Random par1Random)
{
return 0;
}
}

View file

@ -0,0 +1,93 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.tileEntity.TEConduit;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
public class BlockConduit extends BlockOrientable
{
@SideOnly(Side.CLIENT)
private static IIcon topIcon;
@SideOnly(Side.CLIENT)
private static IIcon sideIcon1;
@SideOnly(Side.CLIENT)
private static IIcon sideIcon2;
@SideOnly(Side.CLIENT)
private static IIcon bottomIcon;
public BlockConduit()
{
super();
setHardness(2.0F);
setResistance(5.0F);
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
this.setBlockName("blockConduit");
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister)
{
this.topIcon = iconRegister.registerIcon("AlchemicalWizardry:BloodAltar_Top");
this.sideIcon1 = iconRegister.registerIcon("AlchemicalWizardry:BloodAltar_SideType1");
this.sideIcon2 = iconRegister.registerIcon("AlchemicalWizardry:BloodAltar_SideType2");
this.bottomIcon = iconRegister.registerIcon("AlchemicalWizardry:BloodAltar_Bottom");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta)
{
switch (side)
{
case 0:
return bottomIcon;
case 1:
return topIcon;
default:
return sideIcon2;
}
}
@Override
public void breakBlock(World world, int x, int y, int z, Block par5, int par6)
{
super.breakBlock(world, x, y, z, par5, par6);
}
@Override
public TileEntity createNewTileEntity(World world, int noClue)
{
return new TEConduit();
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public int getRenderType()
{
return -1;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean hasTileEntity()
{
return true;
}
}

View file

@ -0,0 +1,42 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.TEDemonPortal;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class BlockDemonPortal extends BlockContainer
{
public BlockDemonPortal()
{
super(Material.rock);
setHardness(2.0F);
setResistance(5.0F);
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
this.setBlockName("demonPortal");
}
@Override
public TileEntity createNewTileEntity(World var1, int var2)
{
return new TEDemonPortal();
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float what, float these, float are)
{
if (world.isRemote)
{
return false;
}
TEDemonPortal tileEntity = (TEDemonPortal) world.getTileEntity(x, y, z);
tileEntity.rightClickBlock(player, side);
return false;
}
}

View file

@ -0,0 +1,95 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.items.BlankSpell;
import WayofTime.alchemicalWizardry.common.tileEntity.TEHomHeart;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
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.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
public class BlockHomHeart extends BlockContainer
{
public IIcon bottomIcon;
public IIcon topIcon;
public IIcon sideIcon;
public BlockHomHeart()
{
super(Material.rock);
setHardness(2.0F);
setResistance(5.0F);
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
this.setBlockName("blockHomHeart");
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister)
{
this.topIcon = iconRegister.registerIcon("AlchemicalWizardry:HomHeart_top");
this.bottomIcon = iconRegister.registerIcon("AlchemicalWizardry:HomHeart_bottom");
this.sideIcon = iconRegister.registerIcon("AlchemicalWizardry:HomHeart_side");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta)
{
switch (side)
{
case 0:
return bottomIcon;
case 1:
return topIcon;
default:
return sideIcon;
}
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int idk, float what, float these, float are)
{
TEHomHeart tileEntity = (TEHomHeart) world.getTileEntity(x, y, z);
if (tileEntity == null || player.isSneaking())
{
return false;
}
ItemStack playerItem = player.getCurrentEquippedItem();
if (playerItem != null)
{
if (playerItem.getItem() instanceof BlankSpell)
{
if (playerItem.stackTagCompound == null)
{
playerItem.setTagCompound(new NBTTagCompound());
}
NBTTagCompound itemTag = playerItem.stackTagCompound;
itemTag.setInteger("xCoord", x);
itemTag.setInteger("yCoord", y);
itemTag.setInteger("zCoord", z);
itemTag.setInteger("dimensionId", world.provider.dimensionId);
return true;
}
}
return false;
}
@Override
public TileEntity createNewTileEntity(World world, int metaMaybe)
{
return new TEHomHeart();
}
}

View file

@ -0,0 +1,83 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.items.ActivationCrystal;
import WayofTime.alchemicalWizardry.common.tileEntity.TEMasterStone;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
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.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class BlockMasterStone extends BlockContainer
{
public BlockMasterStone()
{
super(Material.iron);
setHardness(2.0F);
setResistance(5.0F);
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
this.setBlockName("blockMasterStone");
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister)
{
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)
{
TEMasterStone tileEntity = (TEMasterStone) world.getTileEntity(x, y, z);
if (tileEntity == null || player.isSneaking())
{
return false;
}
ItemStack playerItem = player.getCurrentEquippedItem();
if (playerItem == null)
{
return false;
}
Item item = playerItem.getItem();
if (!(item instanceof ActivationCrystal))
{
return false;
}
ActivationCrystal acItem = (ActivationCrystal) item;
tileEntity.setOwner(acItem.getOwnerName(playerItem));
tileEntity.activateRitual(world, acItem.getCrystalLevel(playerItem), player);
world.markBlockForUpdate(x, y, z);
return true;
}
@Override
public TileEntity createNewTileEntity(World world, int meta)
{
return new TEMasterStone();
}
}

View file

@ -0,0 +1,205 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.tileEntity.TEOrientable;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class BlockOrientable extends BlockContainer
{
public BlockOrientable()
{
super(Material.rock);
setHardness(2.0F);
setResistance(5.0F);
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
}
@Override
public TileEntity createNewTileEntity(World world, int dunno)
{
return new TEOrientable();
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float what, float these, float are)
{
//Right-click orients the output face. Shift-right-click orients the input face.
if (world.isRemote)
{
return false;
}
ForgeDirection sideClicked = ForgeDirection.getOrientation(side);
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TEOrientable)
{
TEOrientable newTile = (TEOrientable) tile;
if (player.isSneaking())
{
int nextSide = TEOrientable.getIntForForgeDirection(newTile.getInputDirection()) + 1;
if (nextSide > 5)
{
nextSide = 0;
}
if (ForgeDirection.getOrientation(nextSide) == newTile.getOutputDirection())
{
nextSide++;
if (nextSide > 5)
{
nextSide = 0;
}
}
newTile.setInputDirection(ForgeDirection.getOrientation(nextSide));
} else
{
int nextSide = TEOrientable.getIntForForgeDirection(newTile.getOutputDirection()) + 1;
if (nextSide > 5)
{
nextSide = 0;
}
if (ForgeDirection.getOrientation(nextSide) == newTile.getInputDirection())
{
nextSide++;
if (nextSide > 5)
{
nextSide = 0;
}
}
newTile.setOutputDirection(ForgeDirection.getOrientation(nextSide));
}
}
world.markBlockForUpdate(x, y, z);
return true;
}
public int getTextureIndexForSideAndOrientation(int side, ForgeDirection input, ForgeDirection output)
{
if (ForgeDirection.getOrientation(side) == input)
{
return 0;
}
if (ForgeDirection.getOrientation(side) == output)
{
return 1;
}
if (ForgeDirection.getOrientation(side) == output.getOpposite())
{
return 6;
}
switch (side)
{
case 0: //BOTTOM
switch (output)
{
case NORTH:
return 2; //UP
case SOUTH:
return 3; //DOWN
case EAST:
return 4; //LEFT
case WEST:
return 5; //RIGHT
default:
break;
}
break;
case 1: //TOP
switch (output)
{
case NORTH:
return 2; //UP
case SOUTH:
return 3; //DOWN
case EAST:
return 5;
case WEST:
return 4;
default:
break;
}
break;
case 2: //NORTH
switch (output)
{
case DOWN:
return 3;
case UP:
return 2;
case EAST:
return 4;
case WEST:
return 5;
default:
break;
}
break;
case 3: //SOUTH
switch (output)
{
case DOWN:
return 3;
case UP:
return 2;
case EAST:
return 5;
case WEST:
return 4;
default:
break;
}
break;
case 4: //WEST
switch (output)
{
case DOWN:
return 3;
case UP:
return 2;
case NORTH:
return 5;
case SOUTH:
return 4;
default:
break;
}
break;
case 5: //EAST
switch (output)
{
case DOWN:
return 3;
case UP:
return 2;
case NORTH:
return 4;
case SOUTH:
return 5;
default:
break;
}
break;
}
return 0;
}
@Override
public int damageDropped(int metadata)
{
return metadata;
}
}

View file

@ -0,0 +1,179 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.tileEntity.TEPedestal;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
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.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import java.util.Random;
public class BlockPedestal extends BlockContainer
{
@SideOnly(Side.CLIENT)
private static IIcon topIcon;
@SideOnly(Side.CLIENT)
private static IIcon sideIcon1;
@SideOnly(Side.CLIENT)
private static IIcon sideIcon2;
@SideOnly(Side.CLIENT)
private static IIcon bottomIcon;
public BlockPedestal()
{
super(Material.rock);
setHardness(2.0F);
setResistance(5.0F);
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
this.setBlockName("bloodPedestal");
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister)
{
this.topIcon = iconRegister.registerIcon("AlchemicalWizardry:ArcanePedestal");
this.sideIcon1 = iconRegister.registerIcon("AlchemicalWizardry:BloodSocket");
this.sideIcon2 = iconRegister.registerIcon("AlchemicalWizardry:BloodSocket");
this.bottomIcon = iconRegister.registerIcon("AlchemicalWizardry:BloodSocket");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta)
{
switch (side)
{
case 0:
return bottomIcon;
case 1:
return topIcon;
default:
return sideIcon2;
}
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int idk, float what, float these, float are)
{
TEPedestal tileEntity = (TEPedestal) world.getTileEntity(x, y, z);
if (tileEntity == null || player.isSneaking())
{
return false;
}
ItemStack playerItem = player.getCurrentEquippedItem();
if (tileEntity.getStackInSlot(0) == null && playerItem != null)
{
ItemStack newItem = playerItem.copy();
newItem.stackSize = 1;
--playerItem.stackSize;
tileEntity.setInventorySlotContents(0, newItem);
} else if (tileEntity.getStackInSlot(0) != null && playerItem == null)
{
player.inventory.addItemStackToInventory(tileEntity.getStackInSlot(0));
tileEntity.setInventorySlotContents(0, null);
tileEntity.setActive();
}
world.markBlockForUpdate(x, y, z);
return true;
}
@Override
public void breakBlock(World world, int x, int y, int z, Block par5, int par6)
{
dropItems(world, x, y, z);
super.breakBlock(world, x, y, z, par5, par6);
}
private void dropItems(World world, int x, int y, int z)
{
Random rand = new Random();
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (!(tileEntity instanceof IInventory))
{
return;
}
IInventory inventory = (IInventory) tileEntity;
for (int i = 0; i < inventory.getSizeInventory(); i++)
{
ItemStack item = inventory.getStackInSlot(i);
if (item != null && item.stackSize > 0)
{
float rx = rand.nextFloat() * 0.8F + 0.1F;
float ry = rand.nextFloat() * 0.8F + 0.1F;
float rz = rand.nextFloat() * 0.8F + 0.1F;
EntityItem entityItem = new EntityItem(world, x + rx, y + ry, z + rz, new ItemStack(item.getItem(), item.stackSize, item.getItemDamage()));
if (item.hasTagCompound())
{
entityItem.getEntityItem().setTagCompound((NBTTagCompound) item.getTagCompound().copy());
}
float factor = 0.05F;
entityItem.motionX = rand.nextGaussian() * factor;
entityItem.motionY = rand.nextGaussian() * factor + 0.2F;
entityItem.motionZ = rand.nextGaussian() * factor;
world.spawnEntityInWorld(entityItem);
item.stackSize = 0;
}
}
}
@Override
public TileEntity createNewTileEntity(World world, int meta)
{
return new TEPedestal();
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public int getRenderType()
{
return -1;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean hasTileEntity()
{
return true;
}
@Override
public MovingObjectPosition collisionRayTrace(World par1World, int par2, int par3, int par4, Vec3 par5Vec3, Vec3 par6Vec3)
{
float f = 0.3125F;
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.6F, 0.5F + f);
return super.collisionRayTrace(par1World, par2, par3, par4, par5Vec3, par6Vec3);
}
}

View file

@ -0,0 +1,179 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.tileEntity.TEPlinth;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
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.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import java.util.Random;
public class BlockPlinth extends BlockContainer
{
@SideOnly(Side.CLIENT)
private static IIcon topIcon;
@SideOnly(Side.CLIENT)
private static IIcon sideIcon1;
@SideOnly(Side.CLIENT)
private static IIcon sideIcon2;
@SideOnly(Side.CLIENT)
private static IIcon bottomIcon;
public BlockPlinth()
{
super(Material.rock);
setHardness(2.0F);
setResistance(5.0F);
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
this.setBlockName("bloodPlinth");
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister)
{
this.topIcon = iconRegister.registerIcon("AlchemicalWizardry:ArcanePlinth");
this.sideIcon1 = iconRegister.registerIcon("AlchemicalWizardry:BloodSocket");
this.sideIcon2 = iconRegister.registerIcon("AlchemicalWizardry:BloodSocket");
this.bottomIcon = iconRegister.registerIcon("AlchemicalWizardry:BloodSocket");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta)
{
switch (side)
{
case 0:
return bottomIcon;
case 1:
return topIcon;
default:
return sideIcon2;
}
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int idk, float what, float these, float are)
{
TEPlinth tileEntity = (TEPlinth) world.getTileEntity(x, y, z);
if (tileEntity == null || player.isSneaking())
{
return false;
}
ItemStack playerItem = player.getCurrentEquippedItem();
if (tileEntity.getStackInSlot(0) == null && playerItem != null)
{
ItemStack newItem = playerItem.copy();
newItem.stackSize = 1;
--playerItem.stackSize;
tileEntity.setInventorySlotContents(0, newItem);
} else if (tileEntity.getStackInSlot(0) != null && playerItem == null)
{
player.inventory.addItemStackToInventory(tileEntity.getStackInSlot(0));
tileEntity.setInventorySlotContents(0, null);
tileEntity.setActive();
}
world.markBlockForUpdate(x, y, z);
return true;
}
@Override
public void breakBlock(World world, int x, int y, int z, Block par5, int par6)
{
dropItems(world, x, y, z);
super.breakBlock(world, x, y, z, par5, par6);
}
private void dropItems(World world, int x, int y, int z)
{
Random rand = new Random();
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (!(tileEntity instanceof IInventory))
{
return;
}
IInventory inventory = (IInventory) tileEntity;
for (int i = 0; i < inventory.getSizeInventory(); i++)
{
ItemStack item = inventory.getStackInSlot(i);
if (item != null && item.stackSize > 0)
{
float rx = rand.nextFloat() * 0.8F + 0.1F;
float ry = rand.nextFloat() * 0.8F + 0.1F;
float rz = rand.nextFloat() * 0.8F + 0.1F;
EntityItem entityItem = new EntityItem(world, x + rx, y + ry, z + rz, new ItemStack(item.getItem(), item.stackSize, item.getItemDamage()));
if (item.hasTagCompound())
{
entityItem.getEntityItem().setTagCompound((NBTTagCompound) item.getTagCompound().copy());
}
float factor = 0.05F;
entityItem.motionX = rand.nextGaussian() * factor;
entityItem.motionY = rand.nextGaussian() * factor + 0.2F;
entityItem.motionZ = rand.nextGaussian() * factor;
world.spawnEntityInWorld(entityItem);
item.stackSize = 0;
}
}
}
@Override
public TileEntity createNewTileEntity(World world, int meta)
{
return new TEPlinth();
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public int getRenderType()
{
return -1;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean hasTileEntity()
{
return true;
}
@Override
public MovingObjectPosition collisionRayTrace(World par1World, int par2, int par3, int par4, Vec3 par5Vec3, Vec3 par6Vec3)
{
float f = 0.0625F;
this.setBlockBounds(f, 0.0F, f, 1.0f - f, 0.875f, 1.0f - f);
return super.collisionRayTrace(par1World, par2, par3, par4, par5Vec3, par6Vec3);
}
}

View file

@ -0,0 +1,67 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.tileEntity.TEReagentConduit;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
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.tileentity.TileEntity;
import net.minecraft.world.World;
public class BlockReagentConduit extends BlockContainer
{
public BlockReagentConduit()
{
super(Material.cloth);
setHardness(2.0F);
setResistance(5.0F);
this.setBlockName("blockReagentConduit");
this.setCreativeTab(AlchemicalWizardry.tabBloodMagic);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister)
{
this.blockIcon = iconRegister.registerIcon("AlchemicalWizardry:SimpleTransCircle");
}
@Override
public TileEntity createNewTileEntity(World world, int meta)
{
return new TEReagentConduit();
}
@Override
public boolean canProvidePower()
{
return true;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float what, float these, float are)
{
return super.onBlockActivated(world, x, y, z, player, side, what, these, are);
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public int getRenderType()
{
return -1;
}
}

View file

@ -0,0 +1,42 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.tileEntity.TESchematicSaver;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class BlockSchematicSaver extends BlockContainer
{
public BlockSchematicSaver()
{
super(Material.rock);
setHardness(2.0F);
setResistance(5.0F);
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
this.setBlockName("schematicSaver");
}
@Override
public TileEntity createNewTileEntity(World var1, int var2)
{
return new TESchematicSaver();
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float what, float these, float are)
{
if (world.isRemote)
{
return false;
}
TESchematicSaver tileEntity = (TESchematicSaver) world.getTileEntity(x, y, z);
tileEntity.rightClickBlock(player, side);
return false;
}
}

View file

@ -0,0 +1,149 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade;
import WayofTime.alchemicalWizardry.common.tileEntity.TESocket;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
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.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import java.util.Random;
public class BlockSocket extends BlockContainer
{
@SideOnly(Side.CLIENT)
private static IIcon topIcon;
@SideOnly(Side.CLIENT)
private static IIcon sideIcon1;
@SideOnly(Side.CLIENT)
private static IIcon sideIcon2;
@SideOnly(Side.CLIENT)
private static IIcon bottomIcon;
public BlockSocket()
{
super(Material.rock);
setHardness(2.0F);
setResistance(5.0F);
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
this.setBlockName("bloodSocket");
//func_111022_d("AlchemicalWizardry:blocks");
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister)
{
this.topIcon = iconRegister.registerIcon("AlchemicalWizardry:BloodSocket");
this.sideIcon1 = iconRegister.registerIcon("AlchemicalWizardry:BloodSocket");
this.sideIcon2 = iconRegister.registerIcon("AlchemicalWizardry:BloodSocket");
this.bottomIcon = iconRegister.registerIcon("AlchemicalWizardry:BloodSocket");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta)
{
switch (side)
{
case 0:
return bottomIcon;
case 1:
return topIcon;
default:
return sideIcon2;
}
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int idk, float what, float these, float are)
{
TESocket tileEntity = (TESocket) world.getTileEntity(x, y, z);
if (tileEntity == null || player.isSneaking())
{
return false;
}
ItemStack playerItem = player.getCurrentEquippedItem();
if (tileEntity.getStackInSlot(0) == null && playerItem != null)
{
if (playerItem.getItem() instanceof ArmourUpgrade)
{
ItemStack newItem = playerItem.copy();
newItem.stackSize = 1;
--playerItem.stackSize;
tileEntity.setInventorySlotContents(0, newItem);
}
} else if (tileEntity.getStackInSlot(0) != null && playerItem == null)
{
player.inventory.addItemStackToInventory(tileEntity.getStackInSlot(0));
tileEntity.setInventorySlotContents(0, null);
tileEntity.setActive();
}
world.markBlockForUpdate(x, y, z);
return true;
}
@Override
public void breakBlock(World world, int x, int y, int z, Block par5, int par6)
{
dropItems(world, x, y, z);
super.breakBlock(world, x, y, z, par5, par6);
}
private void dropItems(World world, int x, int y, int z)
{
Random rand = new Random();
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (!(tileEntity instanceof IInventory))
{
return;
}
IInventory inventory = (IInventory) tileEntity;
for (int i = 0; i < inventory.getSizeInventory(); i++)
{
ItemStack item = inventory.getStackInSlot(i);
if (item != null && item.stackSize > 0)
{
float rx = rand.nextFloat() * 0.8F + 0.1F;
float ry = rand.nextFloat() * 0.8F + 0.1F;
float rz = rand.nextFloat() * 0.8F + 0.1F;
EntityItem entityItem = new EntityItem(world, x + rx, y + ry, z + rz, new ItemStack(item.getItem(), item.stackSize, item.getItemDamage()));
if (item.hasTagCompound())
{
entityItem.getEntityItem().setTagCompound((NBTTagCompound) item.getTagCompound().copy());
}
float factor = 0.05F;
entityItem.motionX = rand.nextGaussian() * factor;
entityItem.motionY = rand.nextGaussian() * factor + 0.2F;
entityItem.motionZ = rand.nextGaussian() * factor;
world.spawnEntityInWorld(entityItem);
item.stackSize = 0;
}
}
}
@Override
public TileEntity createNewTileEntity(World world, int meta)
{
return new TESocket();
}
}

View file

@ -0,0 +1,74 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.common.tileEntity.TESpectralContainer;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import java.util.List;
import java.util.Random;
public class BlockSpectralContainer extends BlockContainer
{
public BlockSpectralContainer()
{
super(Material.cloth);
this.setBlockName("blockSpectralContainer");
this.setBlockBounds(0, 0, 0, 0, 0, 0);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister)
{
this.blockIcon = iconRegister.registerIcon("AlchemicalWizardry:BlockBloodLight");
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public void addCollisionBoxesToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity)
{
}
public int quantityDropped(Random par1Random)
{
return 0;
}
@Override
public boolean isReplaceable(IBlockAccess world, int x, int y, int z)
{
return true;
}
@Override
public boolean isAir(IBlockAccess world, int x, int y, int z)
{
return true;
}
@Override
public TileEntity createNewTileEntity(World var1, int var2)
{
return new TESpectralContainer();
}
}

View file

@ -0,0 +1,62 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.ModBlocks;
import WayofTime.alchemicalWizardry.common.tileEntity.TESpellEffectBlock;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import java.util.List;
public class BlockSpellEffect extends BlockOrientable
{
public BlockSpellEffect()
{
super();
this.setBlockName("blockSpellEffect");
}
@Override
public TileEntity createNewTileEntity(World world, int meta)
{
return new TESpellEffectBlock();
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public int getRenderType()
{
return -1;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List)
{
if (this.equals(ModBlocks.blockSpellEffect))
{
for (int i = 0; i < 4; i++)
{
par3List.add(new ItemStack(par1, 1, i));
}
} else
{
super.getSubBlocks(par1, par2CreativeTabs, par3List);
}
}
}

View file

@ -0,0 +1,62 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.ModBlocks;
import WayofTime.alchemicalWizardry.common.tileEntity.TESpellEnhancementBlock;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import java.util.List;
public class BlockSpellEnhancement extends BlockOrientable
{
public BlockSpellEnhancement()
{
super();
this.setBlockName("blockSpellEnhancement");
}
@Override
public TileEntity createNewTileEntity(World world, int meta)
{
return new TESpellEnhancementBlock();
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public int getRenderType()
{
return -1;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List)
{
if (this.equals(ModBlocks.blockSpellEnhancement))
{
for (int i = 0; i < 15; i++)
{
par3List.add(new ItemStack(par1, 1, i));
}
} else
{
super.getSubBlocks(par1, par2CreativeTabs, par3List);
}
}
}

View file

@ -0,0 +1,62 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.ModBlocks;
import WayofTime.alchemicalWizardry.common.tileEntity.TESpellModifierBlock;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import java.util.List;
public class BlockSpellModifier extends BlockOrientable
{
public BlockSpellModifier()
{
super();
this.setBlockName("blockSpellModifier");
}
@Override
public TileEntity createNewTileEntity(World world, int meta)
{
return new TESpellModifierBlock();
}
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List)
{
if (this.equals(ModBlocks.blockSpellModifier))
{
for (int i = 0; i < 4; i++)
{
par3List.add(new ItemStack(par1, 1, i));
}
} else
{
super.getSubBlocks(par1, par2CreativeTabs, par3List);
}
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public int getRenderType()
{
return -1;
}
}

View file

@ -0,0 +1,94 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.ModBlocks;
import WayofTime.alchemicalWizardry.common.items.ItemComplexSpellCrystal;
import WayofTime.alchemicalWizardry.common.tileEntity.TESpellParadigmBlock;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import java.util.List;
public class BlockSpellParadigm extends BlockOrientable
{
public static final float minPos = (3f / 16f);
public static final float maxPos = (13f / 16f);
public BlockSpellParadigm()
{
super();
this.setBlockName("blockSpellParadigm");
}
@Override
public TileEntity createNewTileEntity(World world, int meta)
{
return new TESpellParadigmBlock();
}
@SideOnly(Side.CLIENT)
/**
* returns a list of items with the same ID, but different meta (eg: dye returns 16 items)
*/
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List)
{
if (this.equals(ModBlocks.blockSpellParadigm))
{
par3List.add(new ItemStack(par1, 1, 0));
par3List.add(new ItemStack(par1, 1, 1));
par3List.add(new ItemStack(par1, 1, 2));
par3List.add(new ItemStack(par1, 1, 3));
} else
{
super.getSubBlocks(par1, par2CreativeTabs, par3List);
}
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float what, float these, float are)
{
ItemStack stack = player.getCurrentEquippedItem();
if (stack != null && stack.getItem() instanceof ItemComplexSpellCrystal)
{
if (stack.stackTagCompound == null)
{
stack.setTagCompound(new NBTTagCompound());
}
NBTTagCompound itemTag = stack.stackTagCompound;
itemTag.setInteger("xCoord", x);
itemTag.setInteger("yCoord", y);
itemTag.setInteger("zCoord", z);
itemTag.setInteger("dimensionId", world.provider.dimensionId);
return true;
}
return super.onBlockActivated(world, x, y, z, player, side, what, these, are);
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public int getRenderType()
{
return -1;
}
}

View file

@ -0,0 +1,230 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.items.TelepositionFocus;
import WayofTime.alchemicalWizardry.common.tileEntity.TETeleposer;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.BlockMobSpawner;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import java.util.Random;
public class BlockTeleposer extends BlockContainer
{
@SideOnly(Side.CLIENT)
private static IIcon topIcon;
@SideOnly(Side.CLIENT)
private static IIcon sideIcon1;
@SideOnly(Side.CLIENT)
private static IIcon sideIcon2;
@SideOnly(Side.CLIENT)
private static IIcon bottomIcon;
public BlockTeleposer()
{
super(Material.rock);
setHardness(2.0F);
setResistance(5.0F);
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
this.setBlockName("bloodTeleposer");
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister)
{
this.topIcon = iconRegister.registerIcon("AlchemicalWizardry:Teleposer_Top");
this.sideIcon1 = iconRegister.registerIcon("AlchemicalWizardry:Teleposer_Side");
this.sideIcon2 = iconRegister.registerIcon("AlchemicalWizardry:Teleposer_Side");
this.bottomIcon = iconRegister.registerIcon("AlchemicalWizardry:Teleposer_Side");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta)
{
switch (side)
{
case 0:
return bottomIcon;
case 1:
return topIcon;
default:
return sideIcon2;
}
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int idk, float what, float these, float are)
{
TETeleposer tileEntity = (TETeleposer) world.getTileEntity(x, y, z);
ItemStack playerItem = player.getCurrentEquippedItem();
if (playerItem != null)
{
if (playerItem.getItem() instanceof TelepositionFocus)
{
if (playerItem.stackTagCompound == null)
{
playerItem.setTagCompound(new NBTTagCompound());
}
NBTTagCompound itemTag = playerItem.stackTagCompound;
itemTag.setInteger("xCoord", x);
itemTag.setInteger("yCoord", y);
itemTag.setInteger("zCoord", z);
itemTag.setInteger("dimensionId", world.provider.dimensionId);
return true;
}
}
player.openGui(AlchemicalWizardry.instance, 1, world, x, y, z);
return true;
}
@Override
public void breakBlock(World world, int x, int y, int z, Block par5, int par6)
{
dropItems(world, x, y, z);
super.breakBlock(world, x, y, z, par5, par6);
}
private void dropItems(World world, int x, int y, int z)
{
Random rand = new Random();
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (!(tileEntity instanceof IInventory))
{
return;
}
IInventory inventory = (IInventory) tileEntity;
for (int i = 0; i < inventory.getSizeInventory(); i++)
{
ItemStack item = inventory.getStackInSlot(i);
if (item != null && item.stackSize > 0)
{
float rx = rand.nextFloat() * 0.8F + 0.1F;
float ry = rand.nextFloat() * 0.8F + 0.1F;
float rz = rand.nextFloat() * 0.8F + 0.1F;
EntityItem entityItem = new EntityItem(world, x + rx, y + ry, z + rz, new ItemStack(item.getItem(), item.stackSize, item.getItemDamage()));
if (item.hasTagCompound())
{
entityItem.getEntityItem().setTagCompound((NBTTagCompound) item.getTagCompound().copy());
}
float factor = 0.05F;
entityItem.motionX = rand.nextGaussian() * factor;
entityItem.motionY = rand.nextGaussian() * factor + 0.2F;
entityItem.motionZ = rand.nextGaussian() * factor;
world.spawnEntityInWorld(entityItem);
item.stackSize = 0;
}
}
}
@Override
public TileEntity createNewTileEntity(World world, int meta)
{
return new TETeleposer();
}
public static boolean swapBlocks(World worldI, World worldF, int xi, int yi, int zi, int xf, int yf, int zf)
{
TileEntity tileEntityI = worldI.getTileEntity(xi, yi, zi);
TileEntity tileEntityF = worldF.getTileEntity(xf, yf, zf);
TileEntity tileI;
TileEntity tileF;
NBTTagCompound nbttag1 = new NBTTagCompound();
NBTTagCompound nbttag2 = new NBTTagCompound();
if (tileEntityI != null)
{
tileEntityI.writeToNBT(nbttag1);
}
if (tileEntityF != null)
{
tileEntityF.writeToNBT(nbttag2);
}
Block blockI = worldI.getBlock(xi, yi, zi);
Block blockF = worldF.getBlock(xf, yf, zf);
if (blockI.equals(Blocks.air) && blockF.equals(Blocks.air))
{
return false;
}
if (blockI instanceof BlockMobSpawner || blockF instanceof BlockMobSpawner)
{
return false;
}
int metaI = worldI.getBlockMetadata(xi, yi, zi);
int metaF = worldF.getBlockMetadata(xf, yf, zf);
worldI.playSoundEffect(xi, yi, zi, "mob.endermen.portal", 1.0F, 1.0F);
worldF.playSoundEffect(xf, yf, zf, "mob.endermen.portal", 1.0F, 1.0F);
//CLEAR TILES
Block finalBlock = blockF;
if (finalBlock != null)
{
TileEntity tileToSet = finalBlock.createTileEntity(worldF, metaF);
worldF.setTileEntity(xf, yf, zf, tileToSet);
}
Block initialBlock = blockI;
if (initialBlock != null)
{
TileEntity tileToSet = initialBlock.createTileEntity(worldI, metaI);
worldI.setTileEntity(xi, yi, zi, tileToSet);
}
//TILES CLEARED
worldF.setBlock(xf, yf, zf, initialBlock, metaI, 3);
if (tileEntityI != null)
{
TileEntity newTileEntityI = TileEntity.createAndLoadEntity(nbttag1);
worldF.setTileEntity(xf, yf, zf, newTileEntityI);
newTileEntityI.xCoord = xf;
newTileEntityI.yCoord = yf;
newTileEntityI.zCoord = zf;
}
worldI.setBlock(xi, yi, zi, finalBlock, metaF, 3);
if (tileEntityF != null)
{
TileEntity newTileEntityF = TileEntity.createAndLoadEntity(nbttag2);
worldI.setTileEntity(xi, yi, zi, newTileEntityF);
newTileEntityF.xCoord = xi;
newTileEntityF.yCoord = yi;
newTileEntityF.zCoord = zi;
}
return true;
}
}

View file

@ -0,0 +1,175 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.tileEntity.TEWritingTable;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
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.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import java.util.List;
import java.util.Random;
public class BlockWritingTable extends BlockContainer
{
@SideOnly(Side.CLIENT)
private static IIcon topIcon;
@SideOnly(Side.CLIENT)
private static IIcon sideIcon1;
@SideOnly(Side.CLIENT)
private static IIcon sideIcon2;
@SideOnly(Side.CLIENT)
private static IIcon bottomIcon;
public BlockWritingTable()
{
super(Material.wood);
setHardness(2.0F);
setResistance(5.0F);
this.setBlockName("blockWritingTable");
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister)
{
this.topIcon = iconRegister.registerIcon("AlchemicalWizardry:AlchemicChemistrySet");
this.sideIcon1 = iconRegister.registerIcon("AlchemicalWizardry:BloodAltar_SideType1");
this.sideIcon2 = iconRegister.registerIcon("AlchemicalWizardry:BloodAltar_SideType2");
this.bottomIcon = iconRegister.registerIcon("AlchemicalWizardry:BloodAltar_Bottom");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta)
{
switch (side)
{
case 0:
return bottomIcon;
case 1:
return topIcon;
default:
return sideIcon2;
}
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int metadata, float what, float these, float are)
{
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity == null || player.isSneaking())
{
return false;
}
//code to open gui explained later
player.openGui(AlchemicalWizardry.instance, 0, world, x, y, z);
return true;
}
@Override
public void breakBlock(World world, int x, int y, int z, Block par5, int par6)
{
dropItems(world, x, y, z);
super.breakBlock(world, x, y, z, par5, par6);
}
private void dropItems(World world, int x, int y, int z)
{
Random rand = new Random();
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (!(tileEntity instanceof IInventory))
{
return;
}
IInventory inventory = (IInventory) tileEntity;
for (int i = 0; i < inventory.getSizeInventory(); i++)
{
ItemStack item = inventory.getStackInSlot(i);
if (item != null && item.stackSize > 0)
{
float rx = rand.nextFloat() * 0.8F + 0.1F;
float ry = rand.nextFloat() * 0.8F + 0.1F;
float rz = rand.nextFloat() * 0.8F + 0.1F;
EntityItem entityItem = new EntityItem(world,
x + rx, y + ry, z + rz,
new ItemStack(item.getItem(), item.stackSize, item.getItemDamage()));
if (item.hasTagCompound())
{
entityItem.getEntityItem().setTagCompound((NBTTagCompound) item.getTagCompound().copy());
}
float factor = 0.05F;
entityItem.motionX = rand.nextGaussian() * factor;
entityItem.motionY = rand.nextGaussian() * factor + 0.2F;
entityItem.motionZ = rand.nextGaussian() * factor;
world.spawnEntityInWorld(entityItem);
item.stackSize = 0;
}
}
}
@Override
public TileEntity createNewTileEntity(World world, int meta)
{
return new TEWritingTable();
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public int getRenderType()
{
return -1;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean hasTileEntity()
{
return true;
}
@Override
public void addCollisionBoxesToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity)
{
this.setBlockBounds(0.4375F, 0.0F, 0.4375F, 0.5625F, 0.9375F, 0.5625F);
super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
this.setBlockBoundsForItemRender();
super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
}
public void setBlockBoundsForItemRender()
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);
}
}

View file

@ -0,0 +1,119 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.ModBlocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import java.util.List;
public class BloodRune extends Block
{
//private Icon bloodRuneIcon;
private IIcon altarCapacityRuneIcon;
private IIcon dislocationRuneIcon;
private IIcon orbCapacityRuneIcon;
private IIcon betterCapacityRuneIcon;
public BloodRune()
{
super(Material.iron);
this.setBlockName("bloodRune");
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
setHardness(2.0F);
setResistance(5.0F);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister)
{
this.blockIcon = iconRegister.registerIcon("AlchemicalWizardry:BlankRune");
this.altarCapacityRuneIcon = iconRegister.registerIcon("AlchemicalWizardry:AltarCapacityRune");
this.dislocationRuneIcon = iconRegister.registerIcon("AlchemicalWizardry:DislocationRune");
this.orbCapacityRuneIcon = iconRegister.registerIcon("AlchemicalWizardry:OrbCapacityRune");
this.betterCapacityRuneIcon = iconRegister.registerIcon("AlchemicalWizardry:BetterCapacityRune");
}
public int getRuneEffect(int metaData)
{
switch (metaData)
{
case 0:
return 0;
case 1: //Altar Capacity rune
return 5;
case 2: //Filling/emptying rune
return 6;
case 3: //Orb Capacity rune
return 7;
case 4: //Better Capacity rune
return 8;
}
return 0;
}
@SideOnly(Side.CLIENT)
/**
* returns a list of items with the same ID, but different meta (eg: dye returns 16 items)
*/
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List)
{
if (this.equals(ModBlocks.bloodRune))
{
par3List.add(new ItemStack(par1, 1, 0));
par3List.add(new ItemStack(par1, 1, 1));
par3List.add(new ItemStack(par1, 1, 2));
par3List.add(new ItemStack(par1, 1, 3));
par3List.add(new ItemStack(par1, 1, 4));
} else
{
super.getSubBlocks(par1, par2CreativeTabs, par3List);
}
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta)
{
switch (meta)
{
case 0:
return blockIcon;
case 1:
return altarCapacityRuneIcon;
case 2:
return dislocationRuneIcon;
case 3:
return this.orbCapacityRuneIcon;
case 4:
return this.betterCapacityRuneIcon;
default:
return blockIcon;
}
}
@Override
public int damageDropped(int metadata)
{
return metadata;
}
}

View file

@ -0,0 +1,27 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
public class BloodStoneBrick extends Block
{
public BloodStoneBrick()
{
super(Material.iron);
setHardness(2.0F);
setResistance(5.0F);
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
this.setBlockName("bloodStoneBrick");
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister)
{
this.blockIcon = iconRegister.registerIcon("AlchemicalWizardry:BloodStoneBrick");
}
}

View file

@ -0,0 +1,31 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
public class EfficiencyRune extends BloodRune
{
public EfficiencyRune()
{
super();
this.setBlockName("efficiencyRune");
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
setHardness(2.0F);
setResistance(5.0F);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister)
{
this.blockIcon = iconRegister.registerIcon("AlchemicalWizardry:EfficiencyRune");
}
@Override
public int getRuneEffect(int metaData)
{
return 2;
}
}

View file

@ -0,0 +1,33 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
public class EmptySocket extends Block
{
public EmptySocket()
{
super(Material.iron);
setHardness(2.0F);
setResistance(5.0F);
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
this.setBlockName("emptySocket");
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister)
{
this.blockIcon = iconRegister.registerIcon("AlchemicalWizardry:EmptySocket");
}
}

View file

@ -0,0 +1,14 @@
package WayofTime.alchemicalWizardry.common.block;
import net.minecraftforge.common.util.ForgeDirection;
public interface IOrientable
{
public ForgeDirection getInputDirection();
public ForgeDirection getOutputDirection();
public void setInputDirection(ForgeDirection direction);
public void setOutputDirection(ForgeDirection direction);
}

View file

@ -0,0 +1,114 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
public class ImperfectRitualStone extends Block
{
public ImperfectRitualStone()
{
super(Material.iron);
setHardness(2.0F);
setResistance(5.0F);
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
this.setBlockName("imperfectRitualStone");
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister)
{
this.blockIcon = iconRegister.registerIcon("AlchemicalWizardry:ImperfectRitualStone");
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float xOff, float yOff, float zOff)
{
{
Block block = world.getBlock(x, y + 1, z);
if (block == Blocks.water)
{
if (!player.capabilities.isCreativeMode && !world.isRemote)
{
EnergyItems.drainPlayerNetwork(player, 5000);
}
if (!world.isRemote)
{
world.addWeatherEffect(new EntityLightningBolt(world, x, y + 2, z));
}
world.getWorldInfo().setRaining(true);
if (world.isRemote)
{
world.setRainStrength(1.0F);
world.setThunderStrength(1.0f);
}
world.getWorldInfo().setThunderTime(0);
world.getWorldInfo().setThundering(true);
return true;
} else if (block == Blocks.coal_block)
{
if (!player.capabilities.isCreativeMode && !world.isRemote)
{
EnergyItems.drainPlayerNetwork(player, 5000);
}
EntityZombie zomb = new EntityZombie(world);
zomb.setPosition(x + 0.5, y + 2, z + 0.5);
zomb.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 2000));
zomb.addPotionEffect(new PotionEffect(Potion.damageBoost.id, 20000, 7));
zomb.addPotionEffect(new PotionEffect(Potion.resistance.id, 20000, 3));
if (!world.isRemote)
{
world.spawnEntityInWorld(zomb);
world.addWeatherEffect(new EntityLightningBolt(world, x, y + 2, z));
}
return true;
} else if (block == Blocks.lapis_block)
{
if (!player.capabilities.isCreativeMode && !world.isRemote)
{
EnergyItems.drainPlayerNetwork(player, 5000);
}
if (!world.isRemote)
{
world.addWeatherEffect(new EntityLightningBolt(world, x, y + 2, z));
world.setWorldTime((world.getWorldTime() / 24000) * 24000 + 13800);
}
} else if (block == Blocks.bedrock)
{
if (!player.capabilities.isCreativeMode && !world.isRemote)
{
EnergyItems.drainPlayerNetwork(player, 5000);
}
if (!world.isRemote)
{
world.addWeatherEffect(new EntityLightningBolt(world, x, y + 2, z));
}
player.addPotionEffect(new PotionEffect(Potion.resistance.id, 60 * 20, 1));
}
}
return false;
}
}

View file

@ -0,0 +1,27 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
public class LargeBloodStoneBrick extends Block
{
public LargeBloodStoneBrick()
{
super(Material.iron);
setHardness(2.0F);
setResistance(5.0F);
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
this.setBlockName("largeBloodStoneBrick");
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister)
{
this.blockIcon = iconRegister.registerIcon("AlchemicalWizardry:LargeBloodStoneBrick");
}
}

View file

@ -0,0 +1,59 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fluids.BlockFluidClassic;
public class LifeEssenceBlock extends BlockFluidClassic
{
public LifeEssenceBlock()
{
super(AlchemicalWizardry.lifeEssenceFluid, Material.water);
AlchemicalWizardry.lifeEssenceFluid.setBlock(this);
this.setBlockName("lifeEssenceFluidBlock");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta)
{
return this.blockIcon;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister)
{
this.blockIcon = iconRegister.registerIcon("AlchemicalWizardry:lifeEssenceStill");
AlchemicalWizardry.lifeEssenceFluid.setFlowingIcon(blockIcon);
AlchemicalWizardry.lifeEssenceFluid.setStillIcon(blockIcon);
}
@Override
public boolean canDisplace(IBlockAccess world, int x, int y, int z)
{
if (world.getBlock(x, y, z).getMaterial().isLiquid())
{
return false;
}
return super.canDisplace(world, x, y, z);
}
@Override
public boolean displaceIfPossible(World world, int x, int y, int z)
{
if (world.getBlock(x, y, z).getMaterial().isLiquid())
{
return false;
}
return super.displaceIfPossible(world, x, y, z);
}
}

View file

@ -0,0 +1,121 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.api.rituals.IRitualStone;
import WayofTime.alchemicalWizardry.common.items.ScribeTool;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
public class RitualStone extends Block implements IRitualStone
{
@SideOnly(Side.CLIENT)
private static IIcon blankIcon;
@SideOnly(Side.CLIENT)
private static IIcon waterStoneIcon;
@SideOnly(Side.CLIENT)
private static IIcon fireStoneIcon;
@SideOnly(Side.CLIENT)
private static IIcon earthStoneIcon;
@SideOnly(Side.CLIENT)
private static IIcon airStoneIcon;
@SideOnly(Side.CLIENT)
private static IIcon duskStoneIcon;
public RitualStone()
{
super(Material.iron);
setHardness(2.0F);
setResistance(5.0F);
this.setBlockName("ritualStone");
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister)
{
this.blankIcon = iconRegister.registerIcon("AlchemicalWizardry:RitualStone");
this.waterStoneIcon = iconRegister.registerIcon("AlchemicalWizardry:WaterRitualStone");
this.fireStoneIcon = iconRegister.registerIcon("AlchemicalWizardry:FireRitualStone");
this.earthStoneIcon = iconRegister.registerIcon("AlchemicalWizardry:EarthRitualStone");
this.airStoneIcon = iconRegister.registerIcon("AlchemicalWizardry:AirRitualStone");
this.duskStoneIcon = iconRegister.registerIcon("AlchemicalWizardry:DuskRitualStone");
}
@Override
public int damageDropped(int metadata)
{
return 0;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int idk, float what, float these, float are)
{
ItemStack playerItem = player.getCurrentEquippedItem();
if (playerItem == null)
{
return false;
}
Item item = playerItem.getItem();
if (!(item instanceof ScribeTool))
{
return false;
}
if (playerItem.getMaxDamage() <= playerItem.getItemDamage() && !(playerItem.getMaxDamage() == 0))
{
return false;
}
ScribeTool scribeTool = (ScribeTool) item;
if (!player.capabilities.isCreativeMode)
{
playerItem.setItemDamage(playerItem.getItemDamage() + 1);
}
world.setBlockMetadataWithNotify(x, y, z, scribeTool.getType(), 3);
world.markBlockForUpdate(x, y, z);
return true;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata)
{
switch (metadata)
{
case 0:
return blankIcon;
case 1:
return waterStoneIcon;
case 2:
return fireStoneIcon;
case 3:
return earthStoneIcon;
case 4:
return airStoneIcon;
case 5:
return duskStoneIcon;
default:
return blankIcon;
}
}
}

View file

@ -0,0 +1,31 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
public class RuneOfSacrifice extends BloodRune
{
public RuneOfSacrifice()
{
super();
this.setBlockName("runeOfSacrifice");
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
setHardness(2.0F);
setResistance(5.0F);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister)
{
this.blockIcon = iconRegister.registerIcon("AlchemicalWizardry:RuneOfSacrifice");
}
@Override
public int getRuneEffect(int metaData)
{
return 3;
}
}

View file

@ -0,0 +1,31 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
public class RuneOfSelfSacrifice extends BloodRune
{
public RuneOfSelfSacrifice()
{
super();
this.setBlockName("runeOfSelfSacrifice");
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
setHardness(2.0F);
setResistance(5.0F);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister)
{
this.blockIcon = iconRegister.registerIcon("AlchemicalWizardry:RuneOfSelfSacrifice");
}
@Override
public int getRuneEffect(int metaData)
{
return 4;
}
}

View file

@ -0,0 +1,111 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.common.tileEntity.TESpectralBlock;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
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;
import net.minecraft.world.World;
import java.util.Random;
public class SpectralBlock extends BlockContainer
{
public SpectralBlock()
{
super(Material.rock);
this.setBlockName("spectralBlock");
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister)
{
this.blockIcon = iconRegister.registerIcon("AlchemicalWizardry:SpectralBlock");
}
@Override
public boolean isOpaqueCube()
{
Block d;
return false;
}
@Override
public int quantityDropped(Random par1Random)
{
return 0;
}
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_)
{
Block block = p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_);
if (p_149646_1_.getBlockMetadata(p_149646_2_, p_149646_3_, p_149646_4_) != p_149646_1_.getBlockMetadata(p_149646_2_ - Facing.offsetsXForSide[p_149646_5_], p_149646_3_ - Facing.offsetsYForSide[p_149646_5_], p_149646_4_ - Facing.offsetsZForSide[p_149646_5_]))
{
return true;
}
if (block == this)
{
return false;
}
return block == this ? false : super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_);
}
@SideOnly(Side.CLIENT)
/**
* Returns which pass should this block be rendered on. 0 for solids and 1 for alpha
*/
public int getRenderBlockPass()
{
return 1;
}
@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;
}
}
return true;
}
@Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_)
{
return new TESpectralBlock();
}
}

View file

@ -0,0 +1,31 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
public class SpeedRune extends BloodRune
{
public SpeedRune()
{
super();
this.setBlockName("speedRune");
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
setHardness(2.0F);
setResistance(5.0F);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister)
{
this.blockIcon = iconRegister.registerIcon("AlchemicalWizardry:SpeedRune");
}
@Override
public int getRuneEffect(int metaData)
{
return 1;
}
}

View file

@ -0,0 +1,60 @@
package WayofTime.alchemicalWizardry.common.bloodAltarUpgrade;
import net.minecraft.block.Block;
public class AltarComponent
{
private int x;
private int y;
private int z;
private Block block;
private int metadata;
private boolean isBloodRune;
private boolean isUpgradeSlot;
public AltarComponent(int x, int y, int z, Block block, int metadata, boolean isBloodRune, boolean isUpgradeSlot)
{
this.x = x;
this.y = y;
this.z = z;
this.block = block;
this.metadata = metadata;
this.isBloodRune = isBloodRune;
this.isUpgradeSlot = isUpgradeSlot;
}
public int getX()
{
return x;
}
public int getY()
{
return y;
}
public int getZ()
{
return z;
}
public Block getBlock()
{
return block;
}
public int getMetadata()
{
return metadata;
}
public boolean isBloodRune()
{
return isBloodRune;
}
public boolean isUpgradeSlot()
{
return isUpgradeSlot;
}
}

View file

@ -0,0 +1,105 @@
package WayofTime.alchemicalWizardry.common.bloodAltarUpgrade;
public class AltarUpgradeComponent
{
private int speedUpgrades;
private int efficiencyUpgrades;
private int sacrificeUpgrades;
private int selfSacrificeUpgrades;
private int displacementUpgrades;
private int altarCapacitiveUpgrades;
private int orbCapacitiveUpgrades;
private int betterCapacitiveUpgrades;
public AltarUpgradeComponent()
{
speedUpgrades = 0;
efficiencyUpgrades = 0;
sacrificeUpgrades = 0;
selfSacrificeUpgrades = 0;
displacementUpgrades = 0;
altarCapacitiveUpgrades = 0;
orbCapacitiveUpgrades = 0;
betterCapacitiveUpgrades = 0;
}
public void addSpeedUpgrade()
{
speedUpgrades++;
}
public void addEfficiencyUpgrade()
{
efficiencyUpgrades++;
}
public void addSacrificeUpgrade()
{
sacrificeUpgrades++;
}
public void addSelfSacrificeUpgrade()
{
selfSacrificeUpgrades++;
}
public void addDisplacementUpgrade()
{
displacementUpgrades++;
}
public void addaltarCapacitiveUpgrade()
{
altarCapacitiveUpgrades++;
}
public void addorbCapacitiveUpgrade()
{
orbCapacitiveUpgrades++;
}
public void addBetterCapacitiveUpgrade()
{
betterCapacitiveUpgrades++;
}
public int getSpeedUpgrades()
{
return speedUpgrades;
}
public int getEfficiencyUpgrades()
{
return efficiencyUpgrades;
}
public int getSacrificeUpgrades()
{
return sacrificeUpgrades;
}
public int getSelfSacrificeUpgrades()
{
return selfSacrificeUpgrades;
}
public int getDisplacementUpgrades()
{
return displacementUpgrades;
}
public int getAltarCapacitiveUpgrades()
{
return this.altarCapacitiveUpgrades;
}
public int getOrbCapacitiveUpgrades()
{
return this.orbCapacitiveUpgrades;
}
public int getBetterCapacitiveUpgrades()
{
return this.betterCapacitiveUpgrades;
}
}

View file

@ -0,0 +1,299 @@
package WayofTime.alchemicalWizardry.common.bloodAltarUpgrade;
import WayofTime.alchemicalWizardry.ModBlocks;
import WayofTime.alchemicalWizardry.common.block.BloodRune;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.List;
public class UpgradedAltars
{
public static List<AltarComponent> secondTierAltar = new ArrayList();
public static List<AltarComponent> thirdTierAltar = new ArrayList();
public static List<AltarComponent> fourthTierAltar = new ArrayList();
public static List<AltarComponent> fifthTierAltar = new ArrayList();
public static int highestAltar = 5;
public static int isAltarValid(World world, int x, int y, int z)
{
for (int i = highestAltar; i >= 2; i--)
{
if (checkAltarIsValid(world, x, y, z, i))
{
return i;
}
}
return 1;
}
public static boolean checkAltarIsValid(World world, int x, int y, int z, int altarTier)
{
switch (altarTier)
{
case 1:
return true;
case 2:
for (AltarComponent ac : secondTierAltar)
{
if (ac.isBloodRune())
{
Block testBlock = world.getBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ());
if (!(testBlock instanceof BloodRune))
{
return false;
}
} else
{
Block block = world.getBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ());
int metadata = world.getBlockMetadata(x + ac.getX(), y + ac.getY(), z + ac.getZ());
if (((ac.getBlock() != block) || (ac.getMetadata() != metadata)) && !(ac.getBlock() == Blocks.stonebrick && !world.isAirBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ())))
{
return false;
}
}
}
return true;
case 3:
for (AltarComponent ac : thirdTierAltar)
{
if (ac.isBloodRune())
{
Block testBlock = world.getBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ());
if (!(testBlock instanceof BloodRune))
{
return false;
}
} else
{
Block block = world.getBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ());
int metadata = world.getBlockMetadata(x + ac.getX(), y + ac.getY(), z + ac.getZ());
if (((ac.getBlock() != block) || (ac.getMetadata() != metadata)) && !(ac.getBlock() == Blocks.stonebrick && !world.isAirBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ())))
{
return false;
}
}
}
return true;
case 4:
for (AltarComponent ac : fourthTierAltar)
{
if (ac.isBloodRune())
{
Block testBlock = world.getBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ());
if (!(testBlock instanceof BloodRune))
{
return false;
}
} else
{
Block block = world.getBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ());
int metadata = world.getBlockMetadata(x + ac.getX(), y + ac.getY(), z + ac.getZ());
if (((ac.getBlock() != block) || (ac.getMetadata() != metadata)) && !(ac.getBlock() == Blocks.stonebrick && !world.isAirBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ())))
{
return false;
}
}
}
return true;
case 5:
for (AltarComponent ac : fifthTierAltar)
{
if (ac.isBloodRune())
{
Block testBlock = world.getBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ());
if (!(testBlock instanceof BloodRune))
{
return false;
}
} else
{
Block block = world.getBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ());
int metadata = world.getBlockMetadata(x + ac.getX(), y + ac.getY(), z + ac.getZ());
if (((ac.getBlock() != block) || (ac.getMetadata() != metadata)) && !(ac.getBlock() == Blocks.stonebrick && !world.isAirBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ())))
{
return false;
}
}
}
return true;
default:
return false;
}
}
public static AltarUpgradeComponent getUpgrades(World world, int x, int y, int z, int altarTier)
{
AltarUpgradeComponent upgrades = new AltarUpgradeComponent();
List<AltarComponent> list = UpgradedAltars.getAltarUpgradeListForTier(altarTier);
for (AltarComponent ac : list)
{
if (ac.isUpgradeSlot())
{
//Currently checks the getRuneEffect.
//TODO Change so that it uses the metadata instead, with the BlockID.
Block testBlock = world.getBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ());
if (testBlock instanceof BloodRune)
{
if (!world.isRemote)
{
switch (((BloodRune) testBlock).getRuneEffect(world.getBlockMetadata(x + ac.getX(), y + ac.getY(), z + ac.getZ())))
{
case 1:
upgrades.addSpeedUpgrade();
break;
case 2:
upgrades.addEfficiencyUpgrade();
break;
case 3:
upgrades.addSacrificeUpgrade();
break;
case 4:
upgrades.addSelfSacrificeUpgrade();
break;
case 5:
upgrades.addaltarCapacitiveUpgrade();
break;
case 6:
upgrades.addDisplacementUpgrade();
break;
case 7:
upgrades.addorbCapacitiveUpgrade();
break;
case 8:
upgrades.addBetterCapacitiveUpgrade();
break;
}
}
}
}
}
return upgrades;
}
public static void loadAltars()
{
secondTierAltar.add(new AltarComponent(-1, -1, -1, ModBlocks.bloodRune, 0, true, false));
secondTierAltar.add(new AltarComponent(0, -1, -1, ModBlocks.bloodRune, 0, true, true));
secondTierAltar.add(new AltarComponent(1, -1, -1, ModBlocks.bloodRune, 0, true, false));
secondTierAltar.add(new AltarComponent(-1, -1, 0, ModBlocks.bloodRune, 0, true, true));
secondTierAltar.add(new AltarComponent(1, -1, 0, ModBlocks.bloodRune, 0, true, true));
secondTierAltar.add(new AltarComponent(-1, -1, 1, ModBlocks.bloodRune, 0, true, false));
secondTierAltar.add(new AltarComponent(0, -1, 1, ModBlocks.bloodRune, 0, true, true));
secondTierAltar.add(new AltarComponent(1, -1, 1, ModBlocks.bloodRune, 0, true, false));
thirdTierAltar.add(new AltarComponent(-1, -1, -1, ModBlocks.bloodRune, 0, true, true));
thirdTierAltar.add(new AltarComponent(0, -1, -1, ModBlocks.bloodRune, 0, true, true));
thirdTierAltar.add(new AltarComponent(1, -1, -1, ModBlocks.bloodRune, 0, true, true));
thirdTierAltar.add(new AltarComponent(-1, -1, 0, ModBlocks.bloodRune, 0, true, true));
thirdTierAltar.add(new AltarComponent(1, -1, 0, ModBlocks.bloodRune, 0, true, true));
thirdTierAltar.add(new AltarComponent(-1, -1, 1, ModBlocks.bloodRune, 0, true, true));
thirdTierAltar.add(new AltarComponent(0, -1, 1, ModBlocks.bloodRune, 0, true, true));
thirdTierAltar.add(new AltarComponent(1, -1, 1, ModBlocks.bloodRune, 0, true, true));
thirdTierAltar.add(new AltarComponent(-3, -1, -3, Blocks.stonebrick, 0, false, false));
thirdTierAltar.add(new AltarComponent(-3, 0, -3, Blocks.stonebrick, 0, false, false));
thirdTierAltar.add(new AltarComponent(3, -1, -3, Blocks.stonebrick, 0, false, false));
thirdTierAltar.add(new AltarComponent(3, 0, -3, Blocks.stonebrick, 0, false, false));
thirdTierAltar.add(new AltarComponent(-3, -1, 3, Blocks.stonebrick, 0, false, false));
thirdTierAltar.add(new AltarComponent(-3, 0, 3, Blocks.stonebrick, 0, false, false));
thirdTierAltar.add(new AltarComponent(3, -1, 3, Blocks.stonebrick, 0, false, false));
thirdTierAltar.add(new AltarComponent(3, 0, 3, Blocks.stonebrick, 0, false, false));
thirdTierAltar.add(new AltarComponent(-3, 1, -3, Blocks.glowstone, 0, false, false));
thirdTierAltar.add(new AltarComponent(3, 1, -3, Blocks.glowstone, 0, false, false));
thirdTierAltar.add(new AltarComponent(-3, 1, 3, Blocks.glowstone, 0, false, false));
thirdTierAltar.add(new AltarComponent(3, 1, 3, Blocks.glowstone, 0, false, false));
for (int i = -2; i <= 2; i++)
{
thirdTierAltar.add(new AltarComponent(3, -2, i, ModBlocks.bloodRune, 0, true, true));
thirdTierAltar.add(new AltarComponent(-3, -2, i, ModBlocks.bloodRune, 0, true, true));
thirdTierAltar.add(new AltarComponent(i, -2, 3, ModBlocks.bloodRune, 0, true, true));
thirdTierAltar.add(new AltarComponent(i, -2, -3, ModBlocks.bloodRune, 0, true, true));
}
fourthTierAltar.addAll(thirdTierAltar);
for (int i = -3; i <= 3; i++)
{
fourthTierAltar.add(new AltarComponent(5, -3, i, ModBlocks.bloodRune, 0, true, true));
fourthTierAltar.add(new AltarComponent(-5, -3, i, ModBlocks.bloodRune, 0, true, true));
fourthTierAltar.add(new AltarComponent(i, -3, 5, ModBlocks.bloodRune, 0, true, true));
fourthTierAltar.add(new AltarComponent(i, -3, -5, ModBlocks.bloodRune, 0, true, true));
}
for (int i = -2; i <= 1; i++)
{
fourthTierAltar.add(new AltarComponent(5, i, 5, Blocks.stonebrick, 0, false, false));
fourthTierAltar.add(new AltarComponent(5, i, -5, Blocks.stonebrick, 0, false, false));
fourthTierAltar.add(new AltarComponent(-5, i, -5, Blocks.stonebrick, 0, false, false));
fourthTierAltar.add(new AltarComponent(-5, i, 5, Blocks.stonebrick, 0, false, false));
}
fourthTierAltar.add(new AltarComponent(5, 2, 5, ModBlocks.largeBloodStoneBrick, 0, false, false));
fourthTierAltar.add(new AltarComponent(5, 2, -5, ModBlocks.largeBloodStoneBrick, 0, false, false));
fourthTierAltar.add(new AltarComponent(-5, 2, -5, ModBlocks.largeBloodStoneBrick, 0, false, false));
fourthTierAltar.add(new AltarComponent(-5, 2, 5, ModBlocks.largeBloodStoneBrick, 0, false, false));
fifthTierAltar.addAll(fourthTierAltar);
fifthTierAltar.add(new AltarComponent(-8, -3, 8, Blocks.beacon, 0, false, false));
fifthTierAltar.add(new AltarComponent(-8, -3, -8, Blocks.beacon, 0, false, false));
fifthTierAltar.add(new AltarComponent(8, -3, 8, Blocks.beacon, 0, false, false));
fifthTierAltar.add(new AltarComponent(8, -3, 8, Blocks.beacon, 0, false, false));
for (int i = -6; i <= 6; i++)
{
fifthTierAltar.add(new AltarComponent(8, -4, i, ModBlocks.bloodRune, 0, true, true));
fifthTierAltar.add(new AltarComponent(-8, -4, i, ModBlocks.bloodRune, 0, true, true));
fifthTierAltar.add(new AltarComponent(i, -4, 8, ModBlocks.bloodRune, 0, true, true));
fifthTierAltar.add(new AltarComponent(i, -4, -8, ModBlocks.bloodRune, 0, true, true));
}
}
public static List<AltarComponent> getAltarUpgradeListForTier(int tier)
{
switch (tier)
{
case 2:
return secondTierAltar;
case 3:
return thirdTierAltar;
case 4:
return fourthTierAltar;
case 5:
return fifthTierAltar;
}
return null;
}
}

View file

@ -0,0 +1,195 @@
package WayofTime.alchemicalWizardry.common.demonVillage;
import WayofTime.alchemicalWizardry.common.Int3;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier;
import net.minecraft.block.Block;
import net.minecraft.block.BlockStairs;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.ArrayList;
import java.util.List;
public class BlockSet
{
protected String blockid;
protected int[] metadata;
protected List<Int3> positions;
public BlockSet()
{
this(Blocks.stone);
}
public BlockSet(String blockid)
{
this.blockid = blockid;
this.metadata = new int[4];
positions = new ArrayList();
}
public BlockSet(Block block)
{
this(BlockSet.getPairedIdForBlock(block));
}
public BlockSet(Block block, int meta)
{
this(block);
for (int i = 0; i < metadata.length; i++)
{
metadata[i] = meta;
}
if (block instanceof BlockStairs)
{
int[] northSet = new int[]{2, 3, 0, 1};
int[] eastSet = new int[]{1, 0, 2, 3};
int[] southSet = new int[]{3, 2, 1, 0};
int[] westSet = new int[]{0, 1, 3, 2};
int[] northUpSet = new int[]{6, 7, 4, 5};
int[] eastUpSet = new int[]{5, 4, 6, 7};
int[] southUpSet = new int[]{7, 6, 5, 4};
int[] westUpSet = new int[]{4, 5, 7, 6};
switch (meta)
{
case 0:
metadata = westSet;
break;
case 1:
metadata = eastSet;
break;
case 2:
metadata = northSet;
break;
case 3:
metadata = southSet;
break;
case 4:
metadata = westUpSet;
break;
case 5:
metadata = eastUpSet;
break;
case 6:
metadata = northUpSet;
break;
case 7:
metadata = southUpSet;
break;
}
}
}
public List<Int3> getPositions()
{
return positions;
}
public void addPositionToBlock(int xOffset, int yOffset, int zOffset)
{
positions.add(new Int3(xOffset, yOffset, zOffset));
}
public Block getBlock()
{
return this.getBlockForString(blockid);
}
public static String getPairedIdForBlock(Block block)
{
UniqueIdentifier un = GameRegistry.findUniqueIdentifierFor(block);
String name = "";
if (un != null)
{
name = un.modId + ":" + un.name;
}
return name;
}
public static Block getBlockForString(String str)
{
String[] parts = str.split(":");
String modId = parts[0];
String name = parts[1];
return GameRegistry.findBlock(modId, name);
}
public int getMetaForDirection(ForgeDirection dir)
{
if (metadata.length < 4)
{
return 0;
}
switch (dir)
{
case NORTH:
return metadata[0];
case SOUTH:
return metadata[1];
case WEST:
return metadata[2];
case EAST:
return metadata[3];
default:
return 0;
}
}
public void buildAtIndex(World world, int xCoord, int yCoord, int zCoord, ForgeDirection dir, int index)
{
Block block = this.getBlock();
if (index >= positions.size() || block == null)
{
return;
}
Int3 position = positions.get(index);
int xOff = position.xCoord;
int yOff = position.yCoord;
int zOff = position.zCoord;
int meta = this.getMetaForDirection(dir);
switch (dir)
{
case NORTH:
break;
case SOUTH:
xOff *= -1;
zOff *= -1;
break;
case WEST:
int temp = zOff;
zOff = xOff * -1;
xOff = temp;
break;
case EAST:
int temp2 = zOff * -1;
zOff = xOff;
xOff = temp2;
break;
default:
}
world.setBlock(xCoord + xOff, yCoord + yOff, zCoord + zOff, block, meta, 3);
}
public void buildAll(World world, int xCoord, int yCoord, int zCoord, ForgeDirection dir)
{
for (int i = 0; i < positions.size(); i++)
{
this.buildAtIndex(world, xCoord, yCoord, zCoord, dir, i);
}
}
public boolean isContained(Block block, int defaultMeta)
{
Block thisBlock = this.getBlock();
return thisBlock == null ? false : thisBlock.equals(block) && this.metadata[0] == defaultMeta;
}
}

View file

@ -0,0 +1,185 @@
package WayofTime.alchemicalWizardry.common.demonVillage;
import WayofTime.alchemicalWizardry.ModBlocks;
import WayofTime.alchemicalWizardry.common.Int3;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.ArrayList;
import java.util.List;
public class BuildingSchematic
{
public String name;
public int doorX;
public int doorZ;
public int doorY;
public int buildingTier;
public int buildingType;
public List<BlockSet> blockList;
public BuildingSchematic()
{
this("");
}
public BuildingSchematic(String name)
{
this.name = name;
blockList = new ArrayList();
this.doorX = 0;
this.doorZ = 0;
this.doorY = 0;
this.buildingTier = 0;
this.buildingType = DemonBuilding.BUILDING_HOUSE;
}
public void addBlockWithMeta(Block block, int meta, int xOffset, int yOffset, int zOffset)
{
for (BlockSet set : blockList)
{
if (set.isContained(block, meta))
{
set.addPositionToBlock(xOffset, yOffset, zOffset);
return;
}
}
BlockSet set = new BlockSet(block, meta);
set.addPositionToBlock(xOffset, yOffset, zOffset);
blockList.add(set);
}
public void buildAll(World world, int xCoord, int yCoord, int zCoord, ForgeDirection dir)
{
for (BlockSet set : blockList)
{
set.buildAll(world, xCoord, yCoord, zCoord, dir);
}
}
public GridSpaceHolder createGSH()
{
GridSpaceHolder holder = new GridSpaceHolder();
for (BlockSet set : blockList)
{
for (Int3 coords : set.getPositions())
{
int gridX = (int) ((coords.xCoord + 2 * Math.signum(coords.xCoord)) / 5);
int gridZ = (int) ((coords.zCoord + 2 * Math.signum(coords.zCoord)) / 5);
holder.setGridSpace(gridX, gridZ, new GridSpace(GridSpace.HOUSE, 0));
}
}
return holder;
}
public Int3 getGridSpotOfDoor()
{
int gridX = (int) ((doorX + 2 * Math.signum(doorX)) / 5);
int gridZ = (int) ((doorZ + 2 * Math.signum(doorZ)) / 5);
return new Int3(gridX, doorY, gridZ);
}
public List<Int3> getGriddedPositions(ForgeDirection dir)
{
List<Int3> positionList = new ArrayList();
for (BlockSet blockSet : blockList)
{
for (Int3 pos : blockSet.getPositions())
{
int xOff = pos.xCoord;
int zOff = pos.zCoord;
switch (dir)
{
case SOUTH:
xOff *= -1;
zOff *= -1;
break;
case WEST:
int temp = zOff;
zOff = xOff * -1;
xOff = temp;
break;
case EAST:
int temp2 = zOff * -1;
zOff = xOff;
xOff = temp2;
break;
default:
}
Int3 nextPos = new Int3(xOff, 0, zOff);
if (!positionList.contains(nextPos))
{
positionList.add(nextPos);
}
}
}
return positionList;
}
public void destroyAllInField(World world, int xCoord, int yCoord, int zCoord, ForgeDirection dir)
{
GridSpaceHolder grid = this.createGSH(); //GridSpaceHolder is not aware of the buildings - need to use the schematic
List<Int3> positionList = getGriddedPositions(dir);
for (int i = this.getMinY(); i <= this.getMaxY(); i++)
{
for (Int3 pos : positionList)
{
Block block = world.getBlock(xCoord + pos.xCoord, yCoord + i, zCoord + pos.zCoord);
if (block != ModBlocks.blockDemonPortal)
{
world.setBlockToAir(xCoord + pos.xCoord, yCoord + i, zCoord + pos.zCoord);
}
}
}
}
public int getMinY()
{
int min = 0;
for (BlockSet set : blockList)
{
for (Int3 pos : set.getPositions())
{
if (pos.yCoord < min)
{
min = pos.yCoord;
}
}
}
return min;
}
public int getMaxY()
{
int max = 0;
for (BlockSet set : blockList)
{
for (Int3 pos : set.getPositions())
{
if (pos.yCoord > max)
{
max = pos.yCoord;
}
}
}
return max;
}
public String getName()
{
return this.name;
}
}

View file

@ -0,0 +1,120 @@
package WayofTime.alchemicalWizardry.common.demonVillage;
import WayofTime.alchemicalWizardry.common.Int3;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class DemonBuilding
{
public static final int BUILDING_HOUSE = 0;
public static final int BUILDING_PORTAL = 1;
public BuildingSchematic schematic;
public GridSpaceHolder area;
public int buildingTier;
public int buildingType;
public Int3 doorGridSpace;
public DemonBuilding(BuildingSchematic schematic)
{
this.schematic = schematic;
this.buildingType = schematic.buildingType;
this.buildingTier = schematic.buildingTier;
this.area = this.createGSHForSchematic(schematic);
this.doorGridSpace = schematic.getGridSpotOfDoor();
}
public String getName()
{
return schematic.getName();
}
public boolean isValid(GridSpaceHolder master, int gridX, int gridZ, ForgeDirection dir)
{
return area.doesContainAll(master, gridX, gridZ, dir);
}
public void buildAll(World world, int xCoord, int yCoord, int zCoord, ForgeDirection dir)
{
schematic.buildAll(world, xCoord, yCoord, zCoord, dir);
}
public void setAllGridSpaces(int xInit, int zInit, int yLevel, ForgeDirection dir, int type, GridSpaceHolder master)
{
area.setAllGridSpaces(xInit, zInit, yLevel, dir, type, master);
}
public GridSpaceHolder createGSHForSchematic(BuildingSchematic scheme)
{
switch (this.buildingType)
{
case DemonBuilding.BUILDING_HOUSE:
return scheme.createGSH();
case DemonBuilding.BUILDING_PORTAL:
}
return scheme.createGSH();
}
public Int3 getDoorSpace(ForgeDirection dir)
{
int x = 0;
int z = 0;
switch (dir)
{
case SOUTH:
x = -doorGridSpace.xCoord;
z = -doorGridSpace.zCoord;
break;
case WEST:
x = doorGridSpace.zCoord;
z = -doorGridSpace.xCoord;
break;
case EAST:
x = -doorGridSpace.zCoord;
z = doorGridSpace.xCoord;
break;
default:
x = doorGridSpace.xCoord;
z = doorGridSpace.zCoord;
break;
}
return new Int3(x, doorGridSpace.yCoord, z);
}
public Int3 getGridOffsetFromRoad(ForgeDirection sideOfRoad, int yLevel)
{
Int3 doorSpace = this.getDoorSpace(sideOfRoad);
int x = doorSpace.xCoord;
int z = doorSpace.zCoord;
switch (sideOfRoad)
{
case SOUTH:
z++;
break;
case EAST:
x++;
break;
case WEST:
x--;
break;
default:
z--;
break;
}
return new Int3(x, yLevel, z);
}
public void destroyAllInField(World world, int xCoord, int yCoord, int zCoord, ForgeDirection dir)
{
schematic.destroyAllInField(world, xCoord, yCoord, zCoord, dir);
}
public int getNumberOfGridSpaces()
{
return area.getNumberOfGridSpaces();
}
}

View file

@ -0,0 +1,22 @@
package WayofTime.alchemicalWizardry.common.demonVillage;
import net.minecraft.world.World;
public class DemonCrosspath
{
private int xCoord;
private int yLevel;
private int zCoord;
public DemonCrosspath(int xCoord, int yLevel, int zCoord)
{
this.xCoord = xCoord;
this.yLevel = yLevel;
this.zCoord = zCoord;
}
public void createCrosspath(World world)
{
}
}

View file

@ -0,0 +1,135 @@
package WayofTime.alchemicalWizardry.common.demonVillage;
import WayofTime.alchemicalWizardry.ModBlocks;
import WayofTime.alchemicalWizardry.common.Int3;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class DemonVillagePath
{
public int xi;
public int yi;
public int zi;
public ForgeDirection dir;
public int length;
public DemonVillagePath(int xi, int yi, int zi, ForgeDirection dir, int length)
{
this.xi = xi;
this.yi = yi;
this.zi = zi;
this.dir = dir;
this.length = length;
}
public Int3 constructFullPath(World world, int clearance, Block block, int meta)
{
int xPos = this.xi;
int yPos = this.yi;
int zPos = this.zi;
int rad = this.getRoadRadius();
for (int i = -rad; i <= rad; i++)
{
this.constructPartialPath(world, clearance, block, meta, xPos - rad * dir.offsetX + i * dir.offsetZ, yPos, zPos - rad * dir.offsetZ + i * dir.offsetX, dir, length + 2 * rad);
}
return this.getFinalLocation(world, clearance);
}
public void constructPartialPath(World world, int clearance, Block roadBlock, int meta, int xi, int yi, int zi, ForgeDirection dir, int length)
{
int xPos = xi;
int yPos = yi;
int zPos = zi;
for (int i = 0; i < length; i++)
{
int xOffset = i * dir.offsetX;
int zOffset = i * dir.offsetZ;
for (int yOffset = 0; yOffset <= clearance; yOffset++)
{
int sign = 1;
Block block1 = world.getBlock(xPos + xOffset, yPos + sign * yOffset, zPos + zOffset);
Block highBlock1 = world.getBlock(xPos + xOffset, yPos + sign * yOffset + 1, zPos + zOffset);
if (!block1.isReplaceable(world, xPos + xOffset, yPos + sign * yOffset, zPos + zOffset) && this.isBlockReplaceable(block1) && highBlock1.isReplaceable(world, xPos + xOffset, yPos + sign * yOffset + 1, zPos + zOffset))
{
world.setBlock(xPos + xOffset, yPos + sign * yOffset, zPos + zOffset, roadBlock, meta, 3);
yPos += sign * yOffset;
break;
} else
{
sign = -1;
Block block2 = world.getBlock(xPos + xOffset, yPos + sign * yOffset, zPos + zOffset);
Block highBlock2 = world.getBlock(xPos + xOffset, yPos + sign * yOffset + 1, zPos + zOffset);
if (!block2.isReplaceable(world, xPos + xOffset, yPos + sign * yOffset, zPos + zOffset) && this.isBlockReplaceable(block1) && highBlock2.isReplaceable(world, xPos + xOffset, yPos + sign * yOffset + 1, zPos + zOffset))
{
world.setBlock(xPos + xOffset, yPos + sign * yOffset, zPos + zOffset, roadBlock, meta, 3);
yPos += sign * yOffset;
break;
}
}
}
}
}
public Int3 getFinalLocation(World world, int clearance)
{
int xPos = xi;
int yPos = yi;
int zPos = zi;
for (int i = 0; i < length; i++)
{
int xOffset = i * dir.offsetX;
int zOffset = i * dir.offsetZ;
for (int yOffset = 0; yOffset <= clearance; yOffset++)
{
int sign = 1;
Block block1 = world.getBlock(xPos + xOffset, yPos + sign * yOffset, zPos + zOffset);
Block highBlock1 = world.getBlock(xPos + xOffset, yPos + sign * yOffset + 1, zPos + zOffset);
if (!block1.isReplaceable(world, xPos + xOffset, yPos + sign * yOffset, zPos + zOffset) && this.isBlockReplaceable(block1) && highBlock1.isReplaceable(world, xPos + xOffset, yPos + sign * yOffset + 1, zPos + zOffset))
{
yPos += sign * yOffset;
break;
} else
{
sign = -1;
Block block2 = world.getBlock(xPos + xOffset, yPos + sign * yOffset, zPos + zOffset);
Block highBlock2 = world.getBlock(xPos + xOffset, yPos + sign * yOffset + 1, zPos + zOffset);
if (!block2.isReplaceable(world, xPos + xOffset, yPos + sign * yOffset, zPos + zOffset) && this.isBlockReplaceable(block1) && highBlock2.isReplaceable(world, xPos + xOffset, yPos + sign * yOffset + 1, zPos + zOffset))
{
yPos += sign * yOffset;
break;
}
}
}
}
return new Int3(xPos, yPos, zPos);
}
public int getRoadRadius()
{
return 1;
}
public boolean isBlockReplaceable(Block block)
{
if (block.getMaterial() == Material.leaves || block.getMaterial() == Material.vine)
{
return false;
}
return !block.equals(ModBlocks.blockDemonPortal);
}
}

View file

@ -0,0 +1,77 @@
package WayofTime.alchemicalWizardry.common.demonVillage;
import net.minecraft.nbt.NBTTagCompound;
public class GridSpace
{
public static final int EMPTY = 0;
public static final int MAIN_PORTAL = 1;
public static final int MINI_PORTAL = 2;
public static final int ROAD = 3;
public static final int CROSSROAD = 4;
public static final int HOUSE = 5;
private int yLevel;
private int type;
public GridSpace()
{
this(EMPTY, -1);
}
public GridSpace(int type, int yLevel)
{
this.type = type;
this.yLevel = yLevel;
}
public int getGridType()
{
return this.type;
}
public void setGridType(int type)
{
this.type = type;
}
public int getYLevel()
{
return this.yLevel;
}
public void setYLevel(int yLevel)
{
this.yLevel = yLevel;
}
public boolean isEmpty()
{
return type == this.EMPTY;
}
public static GridSpace getGridFromTag(NBTTagCompound tag)
{
return new GridSpace(tag.getInteger("type"), tag.getInteger("yLevel"));
}
public NBTTagCompound getTag()
{
NBTTagCompound tag = new NBTTagCompound();
tag.setInteger("type", type);
tag.setInteger("yLevel", yLevel);
return tag;
}
public boolean isRoadSegment()
{
return type == this.ROAD || type == this.CROSSROAD;
}
public boolean isBuilding()
{
return type == this.HOUSE;
}
}

View file

@ -0,0 +1,309 @@
package WayofTime.alchemicalWizardry.common.demonVillage;
import WayofTime.alchemicalWizardry.ModBlocks;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class GridSpaceHolder
{
public GridSpace[][] area;
public int negXRadius; //These variables indicate how much the grid has expanded from the 1x1
public int posXRadius; //matrix in each direction
public int negZRadius;
public int posZRadius;
public GridSpaceHolder()
{
area = new GridSpace[1][1];
area[0][0] = new GridSpace();
}
public void expandAreaInNegX()
{
GridSpace[][] newGrid = new GridSpace[negXRadius + posXRadius + 2][negZRadius + posZRadius + 1];
for (int i = 0; i <= negZRadius + posZRadius; i++)
{
newGrid[0][i] = new GridSpace();
}
for (int i = 0; i <= negXRadius + posXRadius; i++)
{
for (int j = 0; j <= negZRadius + posZRadius; j++)
{
newGrid[i + 1][j] = area[i][j];
}
}
area = newGrid;
negXRadius += 1;
}
public void expandAreaInPosX()
{
GridSpace[][] newGrid = new GridSpace[negXRadius + posXRadius + 2][negZRadius + posZRadius + 1];
for (int i = 0; i <= negZRadius + posZRadius; i++)
{
newGrid[negXRadius + posXRadius + 1][i] = new GridSpace();
}
for (int i = 0; i <= negXRadius + posXRadius; i++)
{
for (int j = 0; j <= negZRadius + posZRadius; j++)
{
newGrid[i][j] = area[i][j];
}
}
area = newGrid;
posXRadius += 1;
}
public void expandAreaInNegZ()
{
GridSpace[][] newGrid = new GridSpace[negXRadius + posXRadius + 1][negZRadius + posZRadius + 2];
System.out.println("x " + newGrid.length + "z " + newGrid[0].length);
for (int i = 0; i <= negXRadius + posXRadius; i++)
{
newGrid[i][0] = new GridSpace();
}
for (int i = 0; i <= negXRadius + posXRadius; i++)
{
for (int j = 0; j <= negZRadius + posZRadius; j++)
{
newGrid[i][j + 1] = area[i][j];
}
}
area = newGrid;
negZRadius += 1;
}
public void expandAreaInPosZ()
{
GridSpace[][] newGrid = new GridSpace[negXRadius + posXRadius + 1][negZRadius + posZRadius + 2];
for (int i = 0; i <= negXRadius + posXRadius; i++)
{
newGrid[i][negZRadius + posZRadius + 1] = new GridSpace();
}
for (int i = 0; i <= negXRadius + posXRadius; i++)
{
for (int j = 0; j <= negZRadius + posZRadius; j++)
{
newGrid[i][j] = area[i][j];
}
}
area = newGrid;
posZRadius += 1;
}
public GridSpace getGridSpace(int x, int z)
{
if (x > posXRadius || x < -negXRadius || z > posZRadius || z < -negZRadius)
{
return new GridSpace();
} else
{
return (area[x + negXRadius][z + negZRadius]);
}
}
public void setGridSpace(int x, int z, GridSpace space)
{
if (x > posXRadius)
{
this.expandAreaInPosX();
this.setGridSpace(x, z, space);
return;
} else if (x < -negXRadius)
{
this.expandAreaInNegX();
this.setGridSpace(x, z, space);
return;
} else if (z > posZRadius)
{
this.expandAreaInPosZ();
this.setGridSpace(x, z, space);
return;
} else if (z < -negZRadius)
{
this.expandAreaInNegZ();
this.setGridSpace(x, z, space);
return;
} else
{
area[x + negXRadius][z + negZRadius] = space;
}
}
public boolean doesContainAll(GridSpaceHolder master, int xInit, int zInit, ForgeDirection dir)
{
if (master != null)
{
System.out.println("negXRadius: " + negXRadius + " posXRadius: " + posXRadius + " negZRadius: " + negZRadius + " posZRadius: " + posZRadius);
for (int i = -negXRadius; i <= posXRadius; i++)
{
for (int j = -negZRadius; j <= posZRadius; j++)
{
GridSpace thisSpace = this.getGridSpace(i, j);
if (thisSpace.isEmpty())
{
continue;
}
System.out.println("x: " + i + " z: " + j);
int xOff = 0;
int zOff = 0;
switch (dir)
{
case SOUTH:
xOff = -i;
zOff = -j;
break;
case WEST:
xOff = j;
zOff = -i;
break;
case EAST:
xOff = -j;
zOff = i;
break;
default:
xOff = i;
zOff = j;
break;
}
if (!master.getGridSpace(xInit + xOff, zInit + zOff).isEmpty())
{
return false;
}
}
}
return true;
}
return false;
}
public void setAllGridSpaces(int xInit, int zInit, int yLevel, ForgeDirection dir, int type, GridSpaceHolder master)
{
System.out.println("Grid space selected: (" + xInit + "," + zInit + ")");
if (master != null)
{
for (int i = -negXRadius; i <= posXRadius; i++)
{
for (int j = -negZRadius; j <= posZRadius; j++)
{
GridSpace thisSpace = this.getGridSpace(i, j);
if (thisSpace.isEmpty())
{
continue;
}
int xOff = 0;
int zOff = 0;
switch (dir)
{
case SOUTH:
xOff = -i;
zOff = -j;
break;
case WEST:
xOff = j;
zOff = -i;
break;
case EAST:
xOff = -j;
zOff = i;
break;
default:
xOff = i;
zOff = j;
break;
}
System.out.println("Grid space (" + (xInit + xOff) + "," + (zInit + zOff) + ")");
master.setGridSpace(xInit + xOff, zInit + zOff, new GridSpace(type, yLevel));
}
}
}
}
public void destroyAllInGridSpaces(World world, int xCoord, int yCoord, int zCoord, ForgeDirection dir)
{
for (int i = -negXRadius; i <= posXRadius; i++)
{
for (int j = -negZRadius; j <= posZRadius; j++)
{
GridSpace thisSpace = this.getGridSpace(i, j);
if (thisSpace.isEmpty())
{
continue;
}
int xOff = 0;
int zOff = 0;
switch (dir)
{
case SOUTH:
xOff = -i;
zOff = -j;
break;
case WEST:
xOff = j;
zOff = -i;
break;
case EAST:
xOff = -j;
zOff = i;
break;
default:
xOff = i;
zOff = j;
break;
}
for (int l = -2; l <= 2; l++)
{
for (int m = -2; m <= 2; m++)
{
Block block = world.getBlock(xCoord + xOff * 5 + l, yCoord, zCoord + zOff * 5 + m);
if (block == ModBlocks.blockDemonPortal)
{
continue;
}
world.setBlockToAir(xCoord + xOff * 5 + l, yCoord, zCoord + zOff * 5 + m);
}
}
}
}
}
public int getNumberOfGridSpaces()
{
int num = 0;
for (int i = -this.negXRadius; i <= this.posXRadius; i++)
{
for (int j = -this.negZRadius; j <= this.posZRadius; j++)
{
if (!this.getGridSpace(i, j).isEmpty())
{
num++;
}
}
}
return num;
}
}

View file

@ -0,0 +1,8 @@
package WayofTime.alchemicalWizardry.common.demonVillage;
import net.minecraft.nbt.NBTTagCompound;
public class TileBlockSet extends BlockSet
{
public NBTTagCompound tag;
}

View file

@ -0,0 +1,63 @@
package WayofTime.alchemicalWizardry.common.demonVillage.ai;
import java.util.Iterator;
import java.util.List;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import WayofTime.alchemicalWizardry.common.Int3;
import WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon.IHoardDemon;
import WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.TEDemonPortal;
public class EntityDemonAIHurtByTarget extends EntityAIHurtByTarget
{
boolean entityCallsForHelp;
private int revengeTimer;
public EntityDemonAIHurtByTarget(EntityCreature demon, boolean callsForHelp)
{
super(demon, callsForHelp);
this.entityCallsForHelp = callsForHelp;
}
@Override
public void startExecuting()
{
this.taskOwner.setAttackTarget(this.taskOwner.getAITarget());
this.revengeTimer = this.taskOwner.func_142015_aE();
if (this.entityCallsForHelp && this.taskOwner instanceof IHoardDemon)
{
Int3 portalPosition = ((IHoardDemon)this.taskOwner).getPortalLocation();
if(portalPosition == null)
{
super.startExecuting();
return;
}
TileEntity portal = this.taskOwner.worldObj.getTileEntity(portalPosition.xCoord, portalPosition.yCoord, portalPosition.zCoord);
if(portal instanceof TEDemonPortal)
{
((TEDemonPortal) portal).notifyDemons(taskOwner, this.taskOwner.getAITarget());
}
// double d0 = this.getTargetDistance();
// List list = this.taskOwner.worldObj.getEntitiesWithinAABB(this.taskOwner.getClass(), AxisAlignedBB.getBoundingBox(this.taskOwner.posX, this.taskOwner.posY, this.taskOwner.posZ, this.taskOwner.posX + 1.0D, this.taskOwner.posY + 1.0D, this.taskOwner.posZ + 1.0D).expand(d0, 10.0D, d0));
// Iterator iterator = list.iterator();
//
// while (iterator.hasNext())
// {
// EntityCreature entitycreature = (EntityCreature)iterator.next();
//
// if (this.taskOwner != entitycreature && entitycreature.getAttackTarget() == null && !entitycreature.isOnSameTeam(this.taskOwner.getAITarget()))
// {
// entitycreature.setAttackTarget(this.taskOwner.getAITarget());
// }
// }
}
super.startExecuting();
}
}

View file

@ -0,0 +1,17 @@
package WayofTime.alchemicalWizardry.common.demonVillage.demonHoard;
import net.minecraft.world.World;
public abstract class DemonHoardPacket
{
public DemonHoardPacket()
{
}
public abstract int summonDemons(World world, int x, int y, int z, DemonType type, int tier);
public abstract boolean canFitType(DemonType type);
public abstract float getRelativeChance(DemonType type, int tier);
}

View file

@ -0,0 +1,30 @@
package WayofTime.alchemicalWizardry.common.demonVillage.demonHoard;
import net.minecraft.entity.Entity;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.common.entity.mob.EntityFallenAngel;
public class DemonPacketAngel extends DemonHoardPacket
{
@Override
public boolean canFitType(DemonType type)
{
return true;
}
@Override
public float getRelativeChance(DemonType type, int tier)
{
return 1.0f;
}
@Override
public int summonDemons(World world, int x, int y, int z, DemonType type, int tier)
{
Entity entity = new EntityFallenAngel(world);
entity.setPosition(x, y, z);
world.spawnEntityInWorld(entity);
return 1;
}
}

View file

@ -0,0 +1,80 @@
package WayofTime.alchemicalWizardry.common.demonVillage.demonHoard;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import net.minecraft.world.World;
public class DemonPacketRegistry
{
public static Map<String, DemonHoardPacket> packetMap = new HashMap();
public static boolean registerDemonPacket(String string, DemonHoardPacket packet)
{
if(!packetMap.containsValue(string) && packet != null)
{
packetMap.put(string, packet);
return true;
}
return false;
}
public static String getDemonPacketName(DemonType type, int tier)
{
float totalChance = 0;
for(Entry<String, DemonHoardPacket> entry : packetMap.entrySet())
{
DemonHoardPacket packet = entry.getValue();
if(packet == null)
{
continue;
}
totalChance += packet.getRelativeChance(type, tier);
}
for(Entry<String, DemonHoardPacket> entry : packetMap.entrySet())
{
DemonHoardPacket packet = entry.getValue();
if(packet == null)
{
continue;
}
float relativeChance = packet.getRelativeChance(type, tier);
if(relativeChance >= totalChance)
{
return entry.getKey();
}else
{
totalChance -= relativeChance;
}
}
return "";
}
public static int spawnDemons(World world, int x, int y, int z, DemonType type, int tier)
{
return spawnDemons(world, x, y, z, getDemonPacketName(type, tier), type, tier);
}
public static int spawnDemons(World world, int x, int y, int z, String name, DemonType type, int tier)
{
DemonHoardPacket packet = packetMap.get(name);
if(packet != null)
{
return packet.summonDemons(world, x, y, z, type, tier);
}
return 0;
}
}

View file

@ -0,0 +1,9 @@
package WayofTime.alchemicalWizardry.common.demonVillage.demonHoard;
public enum DemonType
{
FIRE,
WATER,
ICE,
WIND
}

View file

@ -0,0 +1,416 @@
package WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IRangedAttackMob;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIArrowAttack;
import net.minecraft.entity.ai.EntityAIAttackOnCollide;
import net.minecraft.entity.ai.EntityAIFollowOwner;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAIOwnerHurtByTarget;
import net.minecraft.entity.ai.EntityAIOwnerHurtTarget;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityGhast;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.pathfinding.PathEntity;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.ModItems;
import WayofTime.alchemicalWizardry.common.EntityAITargetAggro;
import WayofTime.alchemicalWizardry.common.Int3;
import WayofTime.alchemicalWizardry.common.entity.mob.EntityDemon;
import WayofTime.alchemicalWizardry.common.entity.projectile.HolyProjectile;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
public class EntityMinorDemonGrunt extends EntityDemon implements IRangedAttackMob, IHoardDemon
{
private EntityAIArrowAttack aiArrowAttack = new EntityAIArrowAttack(this, 1.0D, 40, 40, 15.0F);
private EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.2D, false);
private boolean isAngry = false;
private Int3 demonPortal;
private static float maxTamedHealth = 50.0F;
private static float maxUntamedHealth = 50.0F;
public EntityMinorDemonGrunt(World par1World)
{
super(par1World, "GruntString");
this.setSize(0.7F, 1.8F);
this.getNavigator().setAvoidsWater(true);
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(2, this.aiSit);
this.tasks.addTask(3, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F));
this.tasks.addTask(4, new EntityAIWander(this, 1.0D));
this.tasks.addTask(5, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
this.tasks.addTask(6, new EntityAILookIdle(this));
this.targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this));
this.targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this));
this.targetTasks.addTask(3, new EntityAIHurtByTarget(this, true));
this.targetTasks.addTask(4, new EntityAITargetAggro(this, EntityPlayer.class, 0, false));
this.setAggro(false);
this.setTamed(false);
demonPortal = new Int3(0,0,0);
if (par1World != null && !par1World.isRemote)
{
this.setCombatTask();
}
//this.isImmuneToFire = true;
}
@Override
protected void applyEntityAttributes()
{
super.applyEntityAttributes();
//This line affects the speed of the monster
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.30000001192092896D);
//My guess is that this will alter the max health
if (this.isTamed())
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxTamedHealth);
} else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxUntamedHealth);
}
}
@Override
public void setPortalLocation(Int3 position)
{
this.demonPortal = position;
}
@Override
public Int3 getPortalLocation()
{
return this.demonPortal;
}
/**
* Returns true if the newer Entity AI code should be run
*/
public boolean isAIEnabled()
{
return true;
}
/**
* Sets the active target the Task system uses for tracking
*/
public void setAttackTarget(EntityLivingBase par1EntityLivingBase)
{
super.setAttackTarget(par1EntityLivingBase);
if (par1EntityLivingBase == null)
{
this.setAngry(false);
} else if (!this.isTamed())
{
this.setAngry(true);
}
}
/**
* main AI tick function, replaces updateEntityActionState
*/
protected void updateAITick()
{
this.dataWatcher.updateObject(18, Float.valueOf(this.getHealth()));
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
par1NBTTagCompound.setBoolean("Angry", this.isAngry());
this.demonPortal.writeToNBT(par1NBTTagCompound);
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
this.setAngry(par1NBTTagCompound.getBoolean("Angry"));
this.demonPortal = Int3.readFromNBT(par1NBTTagCompound);
this.setCombatTask();
}
/**
* Returns the sound this mob makes while it's alive.
*/
@Override
protected String getLivingSound()
{
//TODO change sounds
return "none";
}
/**
* Returns the sound this mob makes when it is hurt.
*/
@Override
protected String getHurtSound()
{
return "none";
}
/**
* Returns the sound this mob makes on death.
*/
@Override
protected String getDeathSound()
{
return "mob.wolf.death";
}
/**
* Returns the volume for the sounds this mob makes.
*/
@Override
protected float getSoundVolume()
{
return 0.4F;
}
/**
* Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
* use this to react to sunlight and start to burn.
*/
@Override
public void onLivingUpdate()
{
super.onLivingUpdate();
}
/**
* Called to update the entity's position/logic.
*/
@Override
public void onUpdate()
{
super.onUpdate();
}
@Override
public float getEyeHeight()
{
return this.height * 0.8F;
}
/**
* The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently
* use in wolves.
*/
public int getVerticalFaceSpeed()
{
return this.isSitting() ? 20 : super.getVerticalFaceSpeed();
}
public void setTamed(boolean par1)
{
super.setTamed(par1);
if (par1)
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxTamedHealth);
} else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxUntamedHealth);
}
}
/**
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
*/
@Override
public boolean interact(EntityPlayer par1EntityPlayer)
{
ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
if (this.isTamed())
{
if (itemstack != null)
{
if (itemstack.getItem() instanceof ItemFood)
{
ItemFood itemfood = (ItemFood) itemstack.getItem();
if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < this.maxTamedHealth)
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
this.heal((float) itemfood.func_150905_g(itemstack));
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack) null);
}
return true;
}
}
}
if (this.getOwner() instanceof EntityPlayer && SpellHelper.getUsername(par1EntityPlayer).equalsIgnoreCase(SpellHelper.getUsername((EntityPlayer) this.getOwner())) && !this.isBreedingItem(itemstack))
{
if (!this.worldObj.isRemote)
{
this.aiSit.setSitting(!this.isSitting());
this.isJumping = false;
this.setPathToEntity((PathEntity) null);
this.setTarget((Entity) null);
this.setAttackTarget((EntityLivingBase) null);
}
this.sendSittingMessageToPlayer(par1EntityPlayer, !this.isSitting());
}
} else if (itemstack != null && itemstack.getItem().equals(ModItems.weakBloodOrb) && !this.isAngry())
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null);
}
if (!this.worldObj.isRemote)
{
if (this.rand.nextInt(1) == 0)
{
this.setTamed(true);
this.setPathToEntity((PathEntity) null);
this.setAttackTarget((EntityLivingBase) null);
this.aiSit.setSitting(true);
this.setHealth(this.maxTamedHealth);
this.func_152115_b(par1EntityPlayer.getUniqueID().toString());
this.playTameEffect(true);
this.worldObj.setEntityState(this, (byte) 7);
} else
{
this.playTameEffect(false);
this.worldObj.setEntityState(this, (byte) 6);
}
}
return true;
}
return super.interact(par1EntityPlayer);
}
public boolean isBreedingItem(ItemStack par1ItemStack)
{
return false;
}
/**
* Determines whether this wolf is angry or not.
*/
public boolean isAngry()
{
return this.isAngry;
}
/**
* Sets whether this wolf is angry or not.
*/
public void setAngry(boolean angry)
{
this.isAngry = angry;
}
/**
* Returns true if the mob is currently able to mate with the specified mob.
*/
@Override
public boolean canMateWith(EntityAnimal par1EntityAnimal)
{
return false;
}
/**
* Determines if an entity can be despawned, used on idle far away entities
*/
@Override
protected boolean canDespawn()
{
//return !this.isTamed() && this.ticksExisted > 2400;
return false;
}
/**
* A call to determine if this entity should attack the other entity
*/
@Override
public boolean func_142018_a(EntityLivingBase par1EntityLivingBase, EntityLivingBase par2EntityLivingBase)
{
if (!(par1EntityLivingBase instanceof EntityCreeper) && !(par1EntityLivingBase instanceof EntityGhast))
{
if (par1EntityLivingBase instanceof EntityDemon)
{
EntityDemon entitywolf = (EntityDemon) par1EntityLivingBase;
if (entitywolf.isTamed() && entitywolf.getOwner() == par2EntityLivingBase)
{
return false;
}
}
return par1EntityLivingBase instanceof EntityPlayer && par2EntityLivingBase instanceof EntityPlayer && !((EntityPlayer) par2EntityLivingBase).canAttackPlayer((EntityPlayer) par1EntityLivingBase) ? false : !(par1EntityLivingBase instanceof EntityHorse) || !((EntityHorse) par1EntityLivingBase).isTame();
} else
{
return false;
}
}
/**
* Attack the specified entity using a ranged attack.
*/
@Override
public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2)
{
double xCoord;
double yCoord;
double zCoord;
HolyProjectile hol = new HolyProjectile(worldObj, this, par1EntityLivingBase, 1.8f, 0f, 5, 600);
this.worldObj.spawnEntityInWorld(hol);
}
/**
* sets this entity's combat AI.
*/
public void setCombatTask()
{
this.tasks.removeTask(this.aiAttackOnCollide);
this.tasks.removeTask(this.aiArrowAttack);
this.tasks.addTask(4, this.aiArrowAttack);
}
}

View file

@ -0,0 +1,9 @@
package WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon;
import WayofTime.alchemicalWizardry.common.Int3;
public interface IHoardDemon
{
public void setPortalLocation(Int3 position);
public Int3 getPortalLocation();
}

View file

@ -0,0 +1,471 @@
package WayofTime.alchemicalWizardry.common.entity.mob;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.ModItems;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.*;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityGhast;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.pathfinding.PathEntity;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
public class EntityBileDemon extends EntityDemon
{
private EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.2D, false);
private static float maxTamedHealth = 100.0F;
private static float maxUntamedHealth = 200.0F;
private int attackTimer;
public EntityBileDemon(World par1World)
{
super(par1World, AlchemicalWizardry.entityBileDemonID);
this.setSize(1.3F, 2.0F);
this.getNavigator().setAvoidsWater(true);
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(2, new EntityAIAttackOnCollide(this, 1.0D, true));
this.tasks.addTask(3, this.aiSit);
this.tasks.addTask(4, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F));
this.tasks.addTask(5, new EntityAIWander(this, 1.0D));
this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
this.tasks.addTask(7, new EntityAILookIdle(this));
this.targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this));
this.targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this));
this.targetTasks.addTask(3, new EntityAIHurtByTarget(this, true));
this.setTamed(false);
attackTimer = 0;
}
@Override
protected void applyEntityAttributes()
{
super.applyEntityAttributes();
//This line affects the speed of the monster
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.20000001192092896D);
//My guess is that this will alter the max health
if (this.isTamed())
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxTamedHealth);
} else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxUntamedHealth);
}
//this.func_110148_a(SharedMonsterAttributes.field_111267_a).func_111128_a(10.0D);
}
/**
* Returns true if the newer Entity AI code should be run
*/
public boolean isAIEnabled()
{
return true;
}
/**
* Sets the active target the Task system uses for tracking
*/
public void setAttackTarget(EntityLivingBase par1EntityLivingBase)
{
super.setAttackTarget(par1EntityLivingBase);
if (par1EntityLivingBase == null)
{
this.setAngry(false);
} else if (!this.isTamed())
{
this.setAngry(true);
}
}
/**
* main AI tick function, replaces updateEntityActionState
*/
protected void updateAITick()
{
this.dataWatcher.updateObject(18, Float.valueOf(this.getHealth()));
}
protected void entityInit()
{
super.entityInit();
this.dataWatcher.addObject(18, new Float(this.getHealth()));
this.dataWatcher.addObject(19, new Byte((byte) 0));
//this.dataWatcher.addObject(20, new Byte((byte) BlockColored.getBlockFromDye(1)));
}
/**
* Plays step sound at given x, y, z for the entity
*/
protected void playStepSound(int par1, int par2, int par3, int par4)
{
this.playSound("mob.zombie.step", 0.15F, 1.0F);
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
par1NBTTagCompound.setBoolean("Angry", this.isAngry());
par1NBTTagCompound.setByte("attackTimer", (byte) attackTimer);
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
this.setAngry(par1NBTTagCompound.getBoolean("Angry"));
attackTimer = par1NBTTagCompound.getByte("attackTimer");
}
/**
* Returns the sound this mob makes while it's alive.
*/
protected String getLivingSound()
{
return "none";
}
/**
* Returns the sound this mob makes when it is hurt.
*/
protected String getHurtSound()
{
return "mob.irongolem.hit";
}
/**
* Returns the sound this mob makes on death.
*/
protected String getDeathSound()
{
return "mob.irongolem.death";
}
/**
* Returns the volume for the sounds this mob makes.
*/
protected float getSoundVolume()
{
return 1.0F;
}
/**
* Returns the item ID for the item the mob drops on death.
*/
protected int getDropItemId()
{
return -1;
}
/**
* Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
* use this to react to sunlight and start to burn.
*/
public void onLivingUpdate()
{
super.onLivingUpdate();
if (attackTimer > 0)
{
attackTimer--;
}
}
public int getAttackTimer()
{
return attackTimer;
}
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
super.onUpdate();
}
public float getEyeHeight()
{
return this.height * 0.8F;
}
/**
* The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently
* use in wolves.
*/
public int getVerticalFaceSpeed()
{
return this.isSitting() ? 20 : super.getVerticalFaceSpeed();
}
/**
* Called when the entity is attacked.
*/
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
{
if (this.isEntityInvulnerable())
{
return false;
} else
{
Entity entity = par1DamageSource.getEntity();
this.aiSit.setSitting(false);
if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow))
{
par2 = (par2 + 1.0F) / 2.0F;
}
return super.attackEntityFrom(par1DamageSource, par2);
}
}
public boolean attackEntityAsMob(Entity par1Entity)
{
this.attackTimer = 10;
this.worldObj.setEntityState(this, (byte) 4);
boolean flag = par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) (7 + this.rand.nextInt(15)));
if (flag)
{
par1Entity.motionY += 0.4000000059604645D;
}
this.playSound("mob.irongolem.throw", 1.0F, 1.0F);
return flag;
}
public void setTamed(boolean par1)
{
super.setTamed(par1);
if (par1)
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxTamedHealth);
} else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxUntamedHealth);
}
}
/**
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
*/
@Override
public boolean interact(EntityPlayer par1EntityPlayer)
{
ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
if (this.isTamed())
{
if (itemstack != null)
{
if (itemstack.getItem() instanceof ItemFood)
{
ItemFood itemfood = (ItemFood) itemstack.getItem();
if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < this.maxTamedHealth)
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
this.heal((float) itemfood.func_150905_g(itemstack));
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack) null);
}
return true;
}
}
}
if (this.getOwner() instanceof EntityPlayer && SpellHelper.getUsername(par1EntityPlayer).equalsIgnoreCase(SpellHelper.getUsername((EntityPlayer) this.getOwner())) && !this.isBreedingItem(itemstack))
{
if (!this.worldObj.isRemote)
{
this.aiSit.setSitting(!this.isSitting());
this.isJumping = false;
this.setPathToEntity((PathEntity) null);
this.setTarget((Entity) null);
this.setAttackTarget((EntityLivingBase) null);
}
this.sendSittingMessageToPlayer(par1EntityPlayer, !this.isSitting());
}
} else if (itemstack != null && itemstack.getItem().equals(ModItems.weakBloodOrb) && !this.isAngry())
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack) null);
}
if (!this.worldObj.isRemote)
{
if (this.rand.nextInt(1) == 0)
{
this.setTamed(true);
this.setPathToEntity((PathEntity) null);
this.setAttackTarget((EntityLivingBase) null);
this.aiSit.setSitting(true);
this.setHealth(this.maxTamedHealth);
this.func_152115_b(par1EntityPlayer.getUniqueID().toString());
this.playTameEffect(true);
this.worldObj.setEntityState(this, (byte) 7);
} else
{
this.playTameEffect(false);
this.worldObj.setEntityState(this, (byte) 6);
}
}
return true;
}
return super.interact(par1EntityPlayer);
}
/**
* Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on
* the animal type)
*/
public boolean isBreedingItem(ItemStack par1ItemStack)
{
return false;
}
/**
* Determines whether this wolf is angry or not.
*/
public boolean isAngry()
{
return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0;
}
/**
* Sets whether this wolf is angry or not.
*/
public void setAngry(boolean par1)
{
byte b0 = this.dataWatcher.getWatchableObjectByte(16);
if (par1)
{
this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 | 2)));
} else
{
this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 & -3)));
}
}
/**
* Return this wolf's collar color.
*/
public int getCollarColor()
{
return this.dataWatcher.getWatchableObjectByte(20) & 15;
}
/**
* Set this wolf's collar color.
*/
public void setCollarColor(int par1)
{
this.dataWatcher.updateObject(20, Byte.valueOf((byte) (par1 & 15)));
}
/**
* This function is used when two same-species animals in 'love mode' breed to generate the new baby animal.
*/
public EntityWolf spawnBabyAnimal(EntityAgeable par1EntityAgeable)
{
return null;
}
public void func_70918_i(boolean par1)
{
if (par1)
{
this.dataWatcher.updateObject(19, Byte.valueOf((byte) 1));
} else
{
this.dataWatcher.updateObject(19, Byte.valueOf((byte) 0));
}
}
/**
* Returns true if the mob is currently able to mate with the specified mob.
*/
public boolean canMateWith(EntityAnimal par1EntityAnimal)
{
return false;
}
public boolean func_70922_bv()
{
return this.dataWatcher.getWatchableObjectByte(19) == 1;
}
/**
* Determines if an entity can be despawned, used on idle far away entities
*/
protected boolean canDespawn()
{
return false;
}
@Override
public boolean func_142018_a(EntityLivingBase par1EntityLivingBase, EntityLivingBase par2EntityLivingBase)
{
if (!(par1EntityLivingBase instanceof EntityCreeper) && !(par1EntityLivingBase instanceof EntityGhast))
{
if (par1EntityLivingBase instanceof EntityBileDemon)
{
EntityBileDemon entitywolf = (EntityBileDemon) par1EntityLivingBase;
if (entitywolf.isTamed() && entitywolf.getOwner() == par2EntityLivingBase)
{
return false;
}
}
return par1EntityLivingBase instanceof EntityPlayer && par2EntityLivingBase instanceof EntityPlayer && !((EntityPlayer) par2EntityLivingBase).canAttackPlayer((EntityPlayer) par1EntityLivingBase) ? false : !(par1EntityLivingBase instanceof EntityHorse) || !((EntityHorse) par1EntityLivingBase).isTame();
} else
{
return false;
}
}
public EntityAgeable createChild(EntityAgeable par1EntityAgeable)
{
return this.spawnBabyAnimal(par1EntityAgeable);
}
}

View file

@ -0,0 +1,481 @@
package WayofTime.alchemicalWizardry.common.entity.mob;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.ModItems;
import WayofTime.alchemicalWizardry.common.EntityAITargetAggro;
import WayofTime.alchemicalWizardry.common.entity.projectile.HolyProjectile;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.*;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityGhast;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.pathfinding.PathEntity;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
public class EntityBoulderFist extends EntityDemon
{
private EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.2D, false);
private static float maxTamedHealth = 60.0F;
private static float maxUntamedHealth = 50.0F;
public EntityBoulderFist(World par1World)
{
super(par1World, AlchemicalWizardry.entityBoulderFistID);
this.setSize(0.8F, 1.2F);
this.getNavigator().setAvoidsWater(true);
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(2, this.aiSit);
this.tasks.addTask(3, new EntityAILeapAtTarget(this, 0.4F));
this.tasks.addTask(4, new EntityAIAttackOnCollide(this, 1.0D, true));
this.tasks.addTask(5, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F));
this.tasks.addTask(6, new EntityAIWander(this, 1.0D));
this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
this.tasks.addTask(8, new EntityAILookIdle(this));
this.targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this));
this.targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this));
this.targetTasks.addTask(3, new EntityAIHurtByTarget(this, true));
this.targetTasks.addTask(4, new EntityAITargetAggro(this, EntityPlayer.class, 0, false));
this.setAggro(false);
this.setTamed(false);
if (par1World != null && !par1World.isRemote)
{
this.setCombatTask();
}
}
@Override
protected void applyEntityAttributes()
{
super.applyEntityAttributes();
//This line affects the speed of the monster
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.30000001192092896D);
//My guess is that this will alter the max health
if (this.isTamed())
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxTamedHealth);
} else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxUntamedHealth);
}
}
/**
* Returns true if the newer Entity AI code should be run
*/
public boolean isAIEnabled()
{
return true;
}
/**
* Sets the active target the Task system uses for tracking
*/
public void setAttackTarget(EntityLivingBase par1EntityLivingBase)
{
super.setAttackTarget(par1EntityLivingBase);
if (par1EntityLivingBase == null)
{
this.setAngry(false);
} else if (!this.isTamed())
{
this.setAngry(true);
}
}
/**
* main AI tick function, replaces updateEntityActionState
*/
protected void updateAITick()
{
this.dataWatcher.updateObject(18, Float.valueOf(this.getHealth()));
}
protected void entityInit()
{
super.entityInit();
this.dataWatcher.addObject(18, new Float(this.getHealth()));
this.dataWatcher.addObject(19, new Byte((byte) 0));
}
/**
* Plays step sound at given x, y, z for the entity
*/
protected void playStepSound(int par1, int par2, int par3, int par4)
{
this.playSound("mob.zombie.step", 0.15F, 1.0F);
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
par1NBTTagCompound.setByte("CollarColor", (byte) this.getCollarColor());
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
this.setAngry(par1NBTTagCompound.getBoolean("Angry"));
this.setCombatTask();
}
/**
* Returns the sound this mob makes while it's alive.
*/
protected String getLivingSound()
{
//TODO change sounds
return this.isAngry() ? "mob.wolf.growl" : (this.rand.nextInt(3) == 0 ? (this.isTamed() && this.dataWatcher.getWatchableObjectFloat(18) < 10.0F ? "mob.wolf.whine" : "mob.wolf.panting") : "mob.wolf.bark");
}
/**
* Returns the sound this mob makes when it is hurt.
*/
protected String getHurtSound()
{
return "mob.wolf.hurt";
}
/**
* Returns the sound this mob makes on death.
*/
protected String getDeathSound()
{
return "mob.wolf.death";
}
/**
* Returns the volume for the sounds this mob makes.
*/
protected float getSoundVolume()
{
return 0.4F;
}
/**
* Returns the item ID for the item the mob drops on death.
*/
protected int getDropItemId()
{
return -1;
}
/**
* Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
* use this to react to sunlight and start to burn.
*/
public void onLivingUpdate()
{
super.onLivingUpdate();
}
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
super.onUpdate();
}
public float getEyeHeight()
{
return this.height * 0.8F;
}
/**
* The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently
* use in wolves.
*/
public int getVerticalFaceSpeed()
{
return this.isSitting() ? 20 : super.getVerticalFaceSpeed();
}
/**
* Called when the entity is attacked.
*/
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
{
if (this.isEntityInvulnerable())
{
return false;
} else
{
Entity entity = par1DamageSource.getEntity();
this.aiSit.setSitting(false);
if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow))
{
par2 = (par2 + 1.0F) / 2.0F;
}
return super.attackEntityFrom(par1DamageSource, par2);
}
}
public boolean attackEntityAsMob(Entity par1Entity)
{
int i = this.isTamed() ? 6 : 7;
return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i);
}
public void setTamed(boolean par1)
{
super.setTamed(par1);
if (par1)
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxTamedHealth);
} else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxUntamedHealth);
}
}
/**
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
*/
@Override
public boolean interact(EntityPlayer par1EntityPlayer)
{
ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
if (this.isTamed())
{
if (itemstack != null)
{
if (itemstack.getItem() instanceof ItemFood)
{
ItemFood itemfood = (ItemFood) itemstack.getItem();
if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < this.maxTamedHealth)
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
this.heal((float) itemfood.func_150905_g(itemstack));
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack) null);
}
return true;
}
}
}
if (this.getOwner() instanceof EntityPlayer && SpellHelper.getUsername(par1EntityPlayer).equalsIgnoreCase(SpellHelper.getUsername((EntityPlayer) this.getOwner())) && !this.isBreedingItem(itemstack))
{
if (!this.worldObj.isRemote)
{
this.aiSit.setSitting(!this.isSitting());
this.isJumping = false;
this.setPathToEntity((PathEntity) null);
this.setTarget((Entity) null);
this.setAttackTarget((EntityLivingBase) null);
}
this.sendSittingMessageToPlayer(par1EntityPlayer, !this.isSitting());
}
} else if (itemstack != null && itemstack.getItem().equals(ModItems.weakBloodOrb) && !this.isAngry())
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack) null);
}
if (!this.worldObj.isRemote)
{
if (this.rand.nextInt(1) == 0)
{
this.setTamed(true);
this.setPathToEntity((PathEntity) null);
this.setAttackTarget((EntityLivingBase) null);
this.aiSit.setSitting(true);
this.setHealth(this.maxTamedHealth);
this.func_152115_b(par1EntityPlayer.getUniqueID().toString());
this.playTameEffect(true);
this.worldObj.setEntityState(this, (byte) 7);
} else
{
this.playTameEffect(false);
this.worldObj.setEntityState(this, (byte) 6);
}
}
return true;
}
return super.interact(par1EntityPlayer);
}
/**
* Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on
* the animal type)
*/
public boolean isBreedingItem(ItemStack par1ItemStack)
{
return false;
}
/**
* Determines whether this wolf is angry or not.
*/
public boolean isAngry()
{
return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0;
}
/**
* Sets whether this wolf is angry or not.
*/
public void setAngry(boolean par1)
{
byte b0 = this.dataWatcher.getWatchableObjectByte(16);
if (par1)
{
this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 | 2)));
} else
{
this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 & -3)));
}
}
/**
* Return this wolf's collar color.
*/
public int getCollarColor()
{
return this.dataWatcher.getWatchableObjectByte(20) & 15;
}
/**
* Set this wolf's collar color.
*/
public void setCollarColor(int par1)
{
this.dataWatcher.updateObject(20, Byte.valueOf((byte) (par1 & 15)));
}
/**
* This function is used when two same-species animals in 'love mode' breed to generate the new baby animal.
*/
public EntityWolf spawnBabyAnimal(EntityAgeable par1EntityAgeable)
{
return null;
}
public void func_70918_i(boolean par1)
{
if (par1)
{
this.dataWatcher.updateObject(19, Byte.valueOf((byte) 1));
} else
{
this.dataWatcher.updateObject(19, Byte.valueOf((byte) 0));
}
}
/**
* Returns true if the mob is currently able to mate with the specified mob.
*/
public boolean canMateWith(EntityAnimal par1EntityAnimal)
{
return false;
}
public boolean func_70922_bv()
{
return this.dataWatcher.getWatchableObjectByte(19) == 1;
}
/**
* Determines if an entity can be despawned, used on idle far away entities
*/
protected boolean canDespawn()
{
return false;
}
@Override
public boolean func_142018_a(EntityLivingBase par1EntityLivingBase, EntityLivingBase par2EntityLivingBase)
{
if (!(par1EntityLivingBase instanceof EntityCreeper) && !(par1EntityLivingBase instanceof EntityGhast))
{
if (par1EntityLivingBase instanceof EntityBoulderFist)
{
EntityBoulderFist entitywolf = (EntityBoulderFist) par1EntityLivingBase;
if (entitywolf.isTamed() && entitywolf.getOwner() == par2EntityLivingBase)
{
return false;
}
}
return par1EntityLivingBase instanceof EntityPlayer && par2EntityLivingBase instanceof EntityPlayer && !((EntityPlayer) par2EntityLivingBase).canAttackPlayer((EntityPlayer) par1EntityLivingBase) ? false : !(par1EntityLivingBase instanceof EntityHorse) || !((EntityHorse) par1EntityLivingBase).isTame();
} else
{
return false;
}
}
public EntityAgeable createChild(EntityAgeable par1EntityAgeable)
{
return this.spawnBabyAnimal(par1EntityAgeable);
}
/**
* Attack the specified entity using a ranged attack.
*/
public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2)
{
double xCoord;
double yCoord;
double zCoord;
HolyProjectile hol = new HolyProjectile(worldObj, this, par1EntityLivingBase, 1.8f, 0f, 5, 600);
this.worldObj.spawnEntityInWorld(hol);
}
/**
* sets this entity's combat AI.
*/
public void setCombatTask()
{
this.tasks.removeTask(this.aiAttackOnCollide);
//this.tasks.removeTask(this.aiArrowAttack);
ItemStack itemstack = this.getHeldItem();
this.tasks.addTask(4, this.aiAttackOnCollide);
}
}

View file

@ -0,0 +1,101 @@
package WayofTime.alchemicalWizardry.common.entity.mob;
import WayofTime.alchemicalWizardry.ModItems;
import WayofTime.alchemicalWizardry.common.IDemon;
import WayofTime.alchemicalWizardry.common.items.DemonPlacer;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.passive.EntityTameable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentText;
import net.minecraft.world.World;
public class EntityDemon extends EntityTameable implements IDemon
{
private boolean isAggro;
private String demonID;
public EntityDemon(World par1World, String demonID)
{
super(par1World);
this.demonID = demonID;
}
@Override
public void setSummonedConditions()
{
this.setAggro(true);
}
@Override
public boolean isAggro()
{
return this.isAggro;
}
@Override
public void setAggro(boolean aggro)
{
this.isAggro = aggro;
}
@Override
public EntityAgeable createChild(EntityAgeable entityageable)
{
// TODO Auto-generated method stub
return null;
}
protected void dropFewItems(boolean par1, int par2)
{
ItemStack drop = new ItemStack(ModItems.demonPlacer);
DemonPlacer.setDemonString(drop, this.getDemonID());
if ((this.getOwner() instanceof EntityPlayer))
{
DemonPlacer.setOwnerName(drop, SpellHelper.getUsername((EntityPlayer) this.getOwner()));
}
if (this.hasCustomNameTag())
{
drop.setStackDisplayName(this.getCustomNameTag());
}
this.entityDropItem(drop, 0.0f);
}
public void onLivingUpdate()
{
super.onLivingUpdate();
if (!this.isAggro() && worldObj.getWorldTime() % 100 == 0)
{
this.heal(1);
}
}
public void sendSittingMessageToPlayer(EntityPlayer owner, boolean isSitting)
{
if (owner != null && owner.worldObj.isRemote)
{
ChatComponentText chatmessagecomponent;
if (isSitting)
{
chatmessagecomponent = new ChatComponentText("I will stay here for now, Master.");
} else
{
chatmessagecomponent = new ChatComponentText("I shall follow and protect you!");
}
owner.addChatComponentMessage(chatmessagecomponent);
}
}
public String getDemonID()
{
return this.demonID;
}
}

View file

@ -0,0 +1,28 @@
package WayofTime.alchemicalWizardry.common.entity.mob;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.IMob;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
public class EntityEarthElemental extends EntityElemental implements IMob
{
public EntityEarthElemental(World world)
{
super(world, AlchemicalWizardry.entityEarthElementalID);
}
public void inflictEffectOnEntity(Entity target)
{
if (target instanceof EntityLivingBase)
{
((EntityLivingBase) target).attackEntityFrom(DamageSource.causeMobDamage(this), 10);
((EntityLivingBase) target).addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 100, 4));
((EntityLivingBase) target).addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionInhibit.id, 150, 0));
}
}
}

View file

@ -0,0 +1,686 @@
package WayofTime.alchemicalWizardry.common.entity.mob;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.ModItems;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIAttackOnCollide;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityGhast;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import java.util.List;
public class EntityElemental extends EntityDemon
{
private EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.2D, false);
private static float maxTamedHealth = 100.0F;
private static float maxUntamedHealth = 100.0F;
public EntityElemental(World par1World, String entityAirElementalID)
{
super(par1World, entityAirElementalID);
this.setSize(0.5F, 1.0F);
this.setAggro(false);
this.setTamed(false);
if (par1World != null && !par1World.isRemote)
{
this.setCombatTask();
}
}
public int courseChangeCooldown;
public double waypointX;
public double waypointY;
public double waypointZ;
private Entity targetedEntity;
/**
* Cooldown time between target loss and new target aquirement.
*/
private int aggroCooldown;
public int prevAttackCounter;
public int attackCounter;
/**
* The explosion radius of spawned fireballs.
*/
protected void dropFewItems(boolean par1, int par2)
{
if (worldObj.rand.nextFloat() < (1 - Math.pow(0.6f, par2 + 1)))
{
this.entityDropItem(new ItemStack(ModItems.demonBloodShard, 1, 0), 0.0f);
}
}
protected void fall(float par1)
{
}
/**
* Takes in the distance the entity has fallen this tick and whether its on the ground to update the fall distance
* and deal fall damage if landing on the ground. Args: distanceFallenThisTick, onGround
*/
protected void updateFallState(double par1, boolean par3)
{
}
/**
* Moves the entity based on the specified heading. Args: strafe, forward
*/
public void moveEntityWithHeading(float par1, float par2)
{
if (this.isInWater())
{
this.moveFlying(par1, par2, 0.02F);
this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.motionX *= 0.800000011920929D;
this.motionY *= 0.800000011920929D;
this.motionZ *= 0.800000011920929D;
} else if (this.handleLavaMovement())
{
this.moveFlying(par1, par2, 0.02F);
this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.motionX *= 0.5D;
this.motionY *= 0.5D;
this.motionZ *= 0.5D;
} else
{
float f2 = 0.91F;
if (this.onGround)
{
f2 = 0.54600006F;
Block i = this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.boundingBox.minY) - 1, MathHelper.floor_double(this.posZ));
if (i != null)
{
f2 = i.slipperiness * 0.91F;
}
}
float f3 = 0.16277136F / (f2 * f2 * f2);
this.moveFlying(par1, par2, this.onGround ? 0.1F * f3 : 0.02F);
f2 = 0.91F;
if (this.onGround)
{
f2 = 0.54600006F;
Block j = this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.boundingBox.minY) - 1, MathHelper.floor_double(this.posZ));
if (j != null)
{
f2 = j.slipperiness * 0.91F;
}
}
this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.motionX *= (double) f2;
this.motionY *= (double) f2;
this.motionZ *= (double) f2;
}
double d0 = this.posX - this.prevPosX;
double d1 = this.posZ - this.prevPosZ;
float f4 = MathHelper.sqrt_double(d0 * d0 + d1 * d1) * 4.0F;
if (f4 > 1.0F)
{
f4 = 1.0F;
}
}
/**
* returns true if this entity is by a ladder, false otherwise
*/
public boolean isOnLadder()
{
return false;
}
@SideOnly(Side.CLIENT)
public boolean func_110182_bF()
{
return this.dataWatcher.getWatchableObjectByte(25) != 0;
}
protected void updateEntityActionState()
{
if (this.getHealth() <= this.getMaxHealth() / 2.0f && worldObj.rand.nextInt(200) == 0)
{
this.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionReciprocation.id, 100, 1));
}
this.prevAttackCounter = this.attackCounter;
double d0 = this.waypointX - this.posX;
double d1 = this.waypointY - this.posY;
double d2 = this.waypointZ - this.posZ;
double d3 = d0 * d0 + d1 * d1 + d2 * d2;
if (d3 < 1.0D || d3 > 3600.0D)
{
this.waypointX = this.posX + (double) ((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F);
this.waypointY = this.posY + (double) ((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F);
this.waypointZ = this.posZ + (double) ((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F);
}
if (this.courseChangeCooldown-- <= 0)
{
this.courseChangeCooldown += this.rand.nextInt(5) + 2;
d3 = (double) MathHelper.sqrt_double(d3);
if (this.isCourseTraversable(this.waypointX, this.waypointY, this.waypointZ, d3))
{
this.motionX += d0 / d3 * 0.1D;
this.motionY += d1 / d3 * 0.1D;
this.motionZ += d2 / d3 * 0.1D;
} else
{
this.waypointX = this.posX + (double) ((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F);
this.waypointY = this.posY + (double) ((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F);
this.waypointZ = this.posZ + (double) ((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F);
}
}
if (this.targetedEntity != null && this.targetedEntity.isDead)
{
this.targetedEntity = null;
}
if (this.targetedEntity == null || this.aggroCooldown-- <= 0)
{
this.targetedEntity = getClosestVulnerableMonsterToEntity(this, 100.0D);
if (this.targetedEntity != null)
{
this.aggroCooldown = 20;
}
}
double d4 = 64.0D;
if (this.targetedEntity != null && this.targetedEntity.getDistanceSqToEntity(this) < d4 * d4)
{
double d5 = this.targetedEntity.posX - this.posX;
double d6 = this.targetedEntity.boundingBox.minY + (double) (this.targetedEntity.height / 2.0F) - (this.posY + (double) (this.height / 2.0F));
double d7 = this.targetedEntity.posZ - this.posZ;
this.renderYawOffset = this.rotationYaw = -((float) Math.atan2(d5, d7)) * 180.0F / (float) Math.PI;
if (this.courseChangeCooldown <= 0)
{
if (isCourseTraversable(this.targetedEntity.posX, this.targetedEntity.posY, this.targetedEntity.posZ, Math.sqrt(d5 * d5 + d6 * d6 + d7 * d7)))
{
this.waypointX = this.targetedEntity.posX;
this.waypointY = this.targetedEntity.posY;
this.waypointZ = this.targetedEntity.posZ;
this.motionX += d5 / d3 * 0.1D;
this.motionY += d6 / d3 * 0.1D;
this.motionZ += d7 / d3 * 0.1D;
} else
{
this.waypointX = this.posX + (double) ((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F);
this.waypointY = this.posY + (double) ((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F);
this.waypointZ = this.posZ + (double) ((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F);
this.motionX += d5 / d3 * 0.1D;
this.motionY += d6 / d3 * 0.1D;
this.motionZ += d7 / d3 * 0.1D;
}
}
if (this.canEntityBeSeen(this.targetedEntity))
{
if (Math.sqrt(d5 * d5 + d6 * d6 + d7 * d7) < 4)
{
++this.attackCounter;
if (this.attackCounter >= 10)
{
this.worldObj.playAuxSFXAtEntity((EntityPlayer) null, 1008, (int) this.posX, (int) this.posY, (int) this.posZ, 0);
this.inflictEffectOnEntity(this.targetedEntity);
this.attackCounter = -40;
}
}
} else if (this.attackCounter > 0)
{
--this.attackCounter;
}
} else
{
this.renderYawOffset = this.rotationYaw = -((float) Math.atan2(this.motionX, this.motionZ)) * 180.0F / (float) Math.PI;
if (this.attackCounter > 0)
{
--this.attackCounter;
}
}
if (!this.worldObj.isRemote)
{
byte b0 = this.dataWatcher.getWatchableObjectByte(25);
byte b1 = (byte) (this.attackCounter > 10 ? 1 : 0);
if (b0 != b1)
{
this.dataWatcher.updateObject(25, Byte.valueOf(b1));
}
}
}
/**
* True if the ghast has an unobstructed line of travel to the waypoint.
*/
private boolean isCourseTraversable(double par1, double par3, double par5, double par7)
{
double d4 = (this.waypointX - this.posX) / par7;
double d5 = (this.waypointY - this.posY) / par7;
double d6 = (this.waypointZ - this.posZ) / par7;
AxisAlignedBB axisalignedbb = this.boundingBox.copy();
for (int i = 1; (double) i < par7; ++i)
{
axisalignedbb.offset(d4, d5, d6);
if (!this.worldObj.getCollidingBoundingBoxes(this, axisalignedbb).isEmpty())
{
return false;
}
}
return true;
}
/**
* Will return how many at most can spawn in a chunk at once.
*/
public int getMaxSpawnedInChunk()
{
return 1;
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
this.setAngry(par1NBTTagCompound.getBoolean("Angry"));
this.setCombatTask();
}
@Override
protected void applyEntityAttributes()
{
super.applyEntityAttributes();
//This line affects the speed of the monster
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.30000001192092896D);
//My guess is that this will alter the max health
if (this.isTamed())
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxTamedHealth);
} else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxUntamedHealth);
}
}
/**
* Returns true if the newer Entity AI code should be run
*/
public boolean isAIEnabled()
{
return false;
}
/**
* Sets the active target the Task system uses for tracking
*/
public void setAttackTarget(EntityLivingBase par1EntityLivingBase)
{
super.setAttackTarget(par1EntityLivingBase);
if (par1EntityLivingBase == null)
{
this.setAngry(false);
} else if (!this.isTamed())
{
this.setAngry(true);
}
}
/**
* main AI tick function, replaces updateEntityActionState
*/
protected void updateAITick()
{
this.dataWatcher.updateObject(18, Float.valueOf(this.getHealth()));
}
protected void entityInit()
{
super.entityInit();
this.dataWatcher.addObject(18, new Float(this.getHealth()));
this.dataWatcher.addObject(19, new Byte((byte) 0));
this.dataWatcher.addObject(25, Byte.valueOf((byte) 0));
}
/**
* Plays step sound at given x, y, z for the entity
*/
protected void playStepSound(int par1, int par2, int par3, int par4)
{
this.playSound("mob.zombie.step", 0.15F, 1.0F);
}
/**
* Returns the sound this mob makes while it's alive.
*/
protected String getLivingSound()
{
//TODO change sounds
return "none";
}
/**
* Returns the sound this mob makes when it is hurt.
*/
protected String getHurtSound()
{
return "none";
}
/**
* Returns the sound this mob makes on death.
*/
protected String getDeathSound()
{
return "none";
}
/**
* Returns the volume for the sounds this mob makes.
*/
protected float getSoundVolume()
{
return 0.4F;
}
/**
* Returns the item ID for the item the mob drops on death.
*/
protected int getDropItemId()
{
return -1;
}
/**
* Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
* use this to react to sunlight and start to burn.
*/
public void onLivingUpdate()
{
super.onLivingUpdate();
}
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
super.onUpdate();
}
public float getEyeHeight()
{
return this.height * 0.8F;
}
/**
* The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently
* use in wolves.
*/
public int getVerticalFaceSpeed()
{
return this.isSitting() ? 20 : super.getVerticalFaceSpeed();
}
/**
* Called when the entity is attacked.
*/
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
{
if (this.isEntityInvulnerable())
{
return false;
} else
{
Entity entity = par1DamageSource.getEntity();
this.aiSit.setSitting(false);
if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow))
{
par2 = (par2 + 1.0F) / 2.0F;
}
return super.attackEntityFrom(par1DamageSource, par2);
}
}
public boolean attackEntityAsMob(Entity par1Entity)
{
int i = this.isTamed() ? 6 : 7;
return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i);
}
public void setTamed(boolean par1)
{
super.setTamed(par1);
if (par1)
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxTamedHealth);
} else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxUntamedHealth);
}
}
/**
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
*/
/**
* Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on
* the animal type)
*/
public boolean isBreedingItem(ItemStack par1ItemStack)
{
return false;
}
/**
* Determines whether this wolf is angry or not.
*/
public boolean isAngry()
{
return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0;
}
/**
* Sets whether this wolf is angry or not.
*/
public void setAngry(boolean par1)
{
byte b0 = this.dataWatcher.getWatchableObjectByte(16);
if (par1)
{
this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 | 2)));
} else
{
this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 & -3)));
}
}
public void func_70918_i(boolean par1)
{
if (par1)
{
this.dataWatcher.updateObject(19, Byte.valueOf((byte) 1));
} else
{
this.dataWatcher.updateObject(19, Byte.valueOf((byte) 0));
}
}
/**
* Returns true if the mob is currently able to mate with the specified mob.
*/
public boolean canMateWith(EntityAnimal par1EntityAnimal)
{
return false;
}
public boolean func_70922_bv()
{
return this.dataWatcher.getWatchableObjectByte(19) == 1;
}
/**
* Determines if an entity can be despawned, used on idle far away entities
*/
protected boolean canDespawn()
{
return false;
}
@Override
public boolean func_142018_a(EntityLivingBase par1EntityLivingBase, EntityLivingBase par2EntityLivingBase)
{
if (!(par1EntityLivingBase instanceof EntityCreeper) && !(par1EntityLivingBase instanceof EntityGhast))
{
if (par1EntityLivingBase instanceof EntityBoulderFist)
{
EntityBoulderFist entitywolf = (EntityBoulderFist) par1EntityLivingBase;
if (entitywolf.isTamed() && entitywolf.getOwner() == par2EntityLivingBase)
{
return false;
}
}
return par1EntityLivingBase instanceof EntityPlayer && par2EntityLivingBase instanceof EntityPlayer && !((EntityPlayer) par2EntityLivingBase).canAttackPlayer((EntityPlayer) par1EntityLivingBase) ? false : !(par1EntityLivingBase instanceof EntityHorse) || !((EntityHorse) par1EntityLivingBase).isTame();
} else
{
return false;
}
}
/**
* sets this entity's combat AI.
*/
public void setCombatTask()
{
this.tasks.removeTask(this.aiAttackOnCollide);
ItemStack itemstack = this.getHeldItem();
this.tasks.addTask(4, this.aiAttackOnCollide);
}
public void inflictEffectOnEntity(Entity target)
{
if (target instanceof EntityLivingBase)
{
((EntityLivingBase) target).addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionDrowning.id, 100, 0));
}
}
public static Entity getClosestVulnerableMonsterToEntity(Entity par1Entity, double par2)
{
double d4 = -1.0D;
double par1 = par1Entity.posX;
double par3 = par1Entity.posY;
double par5 = par1Entity.posZ;
EntityLivingBase entityLiving = null;
World world = par1Entity.worldObj;
double range = Math.sqrt(par2);
double verticalRange = Math.sqrt(par2);
List<EntityLivingBase> entities = world.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(par1 - 0.5f, par3 - 0.5f, par5 - 0.5f, par1 + 0.5f, par3 + 0.5f, par5 + 0.5f).expand(range, verticalRange, range));
if (entities == null)
{
return null;
}
for (int i = 0; i < entities.size(); ++i)
{
EntityLivingBase entityLiving1 = entities.get(i);
if (!(entityLiving1 instanceof EntityPlayer && ((EntityPlayer) entityLiving1).capabilities.disableDamage) && entityLiving1.isEntityAlive())
{
double d5 = entityLiving1.getDistanceSq(par1, par3, par5);
double d6 = par2;
if (entityLiving1.isSneaking())
{
d6 = par2 * 0.800000011920929D;
}
if (entityLiving1.isInvisible())
{
float f = entityLiving1 instanceof EntityPlayer ? ((EntityPlayer) entityLiving1).getArmorVisibility() : 1.0f;
if (f < 0.1F)
{
f = 0.1F;
}
d6 *= (double) (0.7F * f);
}
if ((par2 < 0.0D || d5 < d6 * d6) && (d4 == -1.0D || d5 < d4))
{
if (par1Entity != entityLiving1)
{
d4 = d5;
entityLiving = entityLiving1;
}
}
}
}
return entityLiving;
}
@Override
public int getTotalArmorValue()
{
return 10;
}
}

View file

@ -0,0 +1,480 @@
package WayofTime.alchemicalWizardry.common.entity.mob;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.ModItems;
import WayofTime.alchemicalWizardry.common.EntityAITargetAggro;
import WayofTime.alchemicalWizardry.common.entity.projectile.HolyProjectile;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import net.minecraft.entity.*;
import net.minecraft.entity.ai.*;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityGhast;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.pathfinding.PathEntity;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
public class EntityFallenAngel extends EntityDemon implements IRangedAttackMob
{
private EntityAIArrowAttack aiArrowAttack = new EntityAIArrowAttack(this, 1.0D, 40, 40, 15.0F);
private EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.2D, false);
private static float maxTamedHealth = 50.0F;
private static float maxUntamedHealth = 50.0F;
public EntityFallenAngel(World par1World)
{
super(par1World, AlchemicalWizardry.entityFallenAngelID);
this.setSize(0.7F, 1.8F);
this.getNavigator().setAvoidsWater(true);
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(2, this.aiSit);
this.tasks.addTask(3, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F));
this.tasks.addTask(4, new EntityAIWander(this, 1.0D));
this.tasks.addTask(5, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
this.tasks.addTask(6, new EntityAILookIdle(this));
this.targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this));
this.targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this));
this.targetTasks.addTask(3, new EntityAIHurtByTarget(this, true));
this.targetTasks.addTask(4, new EntityAITargetAggro(this, EntityPlayer.class, 0, false));
this.setAggro(false);
this.setTamed(false);
if (par1World != null && !par1World.isRemote)
{
this.setCombatTask();
}
//this.isImmuneToFire = true;
}
@Override
protected void applyEntityAttributes()
{
super.applyEntityAttributes();
//This line affects the speed of the monster
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.30000001192092896D);
//My guess is that this will alter the max health
if (this.isTamed())
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxTamedHealth);
} else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxUntamedHealth);
}
}
/**
* Returns true if the newer Entity AI code should be run
*/
public boolean isAIEnabled()
{
return true;
}
/**
* Sets the active target the Task system uses for tracking
*/
public void setAttackTarget(EntityLivingBase par1EntityLivingBase)
{
super.setAttackTarget(par1EntityLivingBase);
if (par1EntityLivingBase == null)
{
this.setAngry(false);
} else if (!this.isTamed())
{
this.setAngry(true);
}
}
/**
* main AI tick function, replaces updateEntityActionState
*/
protected void updateAITick()
{
this.dataWatcher.updateObject(18, Float.valueOf(this.getHealth()));
}
protected void entityInit()
{
super.entityInit();
this.dataWatcher.addObject(18, new Float(this.getHealth()));
this.dataWatcher.addObject(19, new Byte((byte) 0));
}
/**
* Plays step sound at given x, y, z for the entity
*/
protected void playStepSound(int par1, int par2, int par3, int par4)
{
this.playSound("mob.zombie.step", 0.15F, 1.0F);
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
par1NBTTagCompound.setBoolean("Angry", this.isAngry());
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
this.setAngry(par1NBTTagCompound.getBoolean("Angry"));
this.setCombatTask();
}
/**
* Returns the sound this mob makes while it's alive.
*/
protected String getLivingSound()
{
//TODO change sounds
return "none";
}
/**
* Returns the sound this mob makes when it is hurt.
*/
protected String getHurtSound()
{
return "none";
}
/**
* Returns the sound this mob makes on death.
*/
protected String getDeathSound()
{
return "mob.wolf.death";
}
/**
* Returns the volume for the sounds this mob makes.
*/
protected float getSoundVolume()
{
return 0.4F;
}
/**
* Returns the item ID for the item the mob drops on death.
*/
protected int getDropItemId()
{
return -1;
}
/**
* Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
* use this to react to sunlight and start to burn.
*/
public void onLivingUpdate()
{
super.onLivingUpdate();
}
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
super.onUpdate();
}
public float getEyeHeight()
{
return this.height * 0.8F;
}
/**
* The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently
* use in wolves.
*/
public int getVerticalFaceSpeed()
{
return this.isSitting() ? 20 : super.getVerticalFaceSpeed();
}
/**
* Called when the entity is attacked.
*/
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
{
if (this.isEntityInvulnerable())
{
return false;
} else
{
Entity entity = par1DamageSource.getEntity();
this.aiSit.setSitting(false);
if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow))
{
par2 = (par2 + 1.0F) / 2.0F;
}
return super.attackEntityFrom(par1DamageSource, par2);
}
}
public boolean attackEntityAsMob(Entity par1Entity)
{
int i = this.isTamed() ? 4 : 2;
return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i);
}
public void setTamed(boolean par1)
{
super.setTamed(par1);
if (par1)
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxTamedHealth);
} else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxUntamedHealth);
}
}
/**
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
*/
@Override
public boolean interact(EntityPlayer par1EntityPlayer)
{
ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
if (this.isTamed())
{
if (itemstack != null)
{
if (itemstack.getItem() instanceof ItemFood)
{
ItemFood itemfood = (ItemFood) itemstack.getItem();
if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < this.maxTamedHealth)
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
this.heal((float) itemfood.func_150905_g(itemstack));
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack) null);
}
return true;
}
}
}
if (this.getOwner() instanceof EntityPlayer && SpellHelper.getUsername(par1EntityPlayer).equalsIgnoreCase(SpellHelper.getUsername((EntityPlayer) this.getOwner())) && !this.isBreedingItem(itemstack))
{
if (!this.worldObj.isRemote)
{
this.aiSit.setSitting(!this.isSitting());
this.isJumping = false;
this.setPathToEntity((PathEntity) null);
this.setTarget((Entity) null);
this.setAttackTarget((EntityLivingBase) null);
}
this.sendSittingMessageToPlayer(par1EntityPlayer, !this.isSitting());
}
} else if (itemstack != null && itemstack.getItem().equals(ModItems.weakBloodOrb) && !this.isAngry())
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack) null);
}
if (!this.worldObj.isRemote)
{
if (this.rand.nextInt(1) == 0)
{
this.setTamed(true);
this.setPathToEntity((PathEntity) null);
this.setAttackTarget((EntityLivingBase) null);
this.aiSit.setSitting(true);
this.setHealth(this.maxTamedHealth);
this.func_152115_b(par1EntityPlayer.getUniqueID().toString());
this.playTameEffect(true);
this.worldObj.setEntityState(this, (byte) 7);
} else
{
this.playTameEffect(false);
this.worldObj.setEntityState(this, (byte) 6);
}
}
return true;
}
return super.interact(par1EntityPlayer);
}
/**
* Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on
* the animal type)
*/
public boolean isBreedingItem(ItemStack par1ItemStack)
{
return false;
//return par1ItemStack == null ? false : (!(Item.itemsList[par1ItemStack.itemID] instanceof ItemFood) ? false : ((ItemFood)Item.itemsList[par1ItemStack.itemID]).isWolfsFavoriteMeat());
}
/**
* Determines whether this wolf is angry or not.
*/
public boolean isAngry()
{
return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0;
}
/**
* Sets whether this wolf is angry or not.
*/
public void setAngry(boolean par1)
{
byte b0 = this.dataWatcher.getWatchableObjectByte(16);
if (par1)
{
this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 | 2)));
} else
{
this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 & -3)));
}
}
/**
* Return this wolf's collar color.
*/
public int getCollarColor()
{
return this.dataWatcher.getWatchableObjectByte(20) & 15;
}
/**
* Set this wolf's collar color.
*/
public void setCollarColor(int par1)
{
this.dataWatcher.updateObject(20, Byte.valueOf((byte) (par1 & 15)));
}
/**
* This function is used when two same-species animals in 'love mode' breed to generate the new baby animal.
*/
public EntityWolf spawnBabyAnimal(EntityAgeable par1EntityAgeable)
{
return null;
}
public void func_70918_i(boolean par1)
{
if (par1)
{
this.dataWatcher.updateObject(19, Byte.valueOf((byte) 1));
} else
{
this.dataWatcher.updateObject(19, Byte.valueOf((byte) 0));
}
}
/**
* Returns true if the mob is currently able to mate with the specified mob.
*/
public boolean canMateWith(EntityAnimal par1EntityAnimal)
{
return false;
}
public boolean func_70922_bv()
{
return this.dataWatcher.getWatchableObjectByte(19) == 1;
}
/**
* Determines if an entity can be despawned, used on idle far away entities
*/
protected boolean canDespawn()
{
//return !this.isTamed() && this.ticksExisted > 2400;
return false;
}
public boolean func_142018_a(EntityLivingBase par1EntityLivingBase, EntityLivingBase par2EntityLivingBase)
{
if (!(par1EntityLivingBase instanceof EntityCreeper) && !(par1EntityLivingBase instanceof EntityGhast))
{
if (par1EntityLivingBase instanceof EntityFallenAngel)
{
EntityFallenAngel entitywolf = (EntityFallenAngel) par1EntityLivingBase;
if (entitywolf.isTamed() && entitywolf.getOwner() == par2EntityLivingBase)
{
return false;
}
}
return par1EntityLivingBase instanceof EntityPlayer && par2EntityLivingBase instanceof EntityPlayer && !((EntityPlayer) par2EntityLivingBase).canAttackPlayer((EntityPlayer) par1EntityLivingBase) ? false : !(par1EntityLivingBase instanceof EntityHorse) || !((EntityHorse) par1EntityLivingBase).isTame();
} else
{
return false;
}
}
public EntityAgeable createChild(EntityAgeable par1EntityAgeable)
{
return this.spawnBabyAnimal(par1EntityAgeable);
}
/**
* Attack the specified entity using a ranged attack.
*/
public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2)
{
double xCoord;
double yCoord;
double zCoord;
HolyProjectile hol = new HolyProjectile(worldObj, this, par1EntityLivingBase, 1.8f, 0f, 5, 600);
this.worldObj.spawnEntityInWorld(hol);
}
/**
* sets this entity's combat AI.
*/
public void setCombatTask()
{
this.tasks.removeTask(this.aiAttackOnCollide);
this.tasks.removeTask(this.aiArrowAttack);
ItemStack itemstack = this.getHeldItem();
this.tasks.addTask(4, this.aiArrowAttack);
}
}

View file

@ -0,0 +1,26 @@
package WayofTime.alchemicalWizardry.common.entity.mob;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.IMob;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
public class EntityFireElemental extends EntityElemental implements IMob
{
public EntityFireElemental(World world)
{
super(world, AlchemicalWizardry.entityFireElementalID);
this.isImmuneToFire = true;
}
public void inflictEffectOnEntity(Entity target)
{
if (target instanceof EntityLivingBase)
{
((EntityLivingBase) target).setFire(10);
((EntityLivingBase) target).addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionInhibit.id, 150, 0));
}
}
}

View file

@ -0,0 +1,28 @@
package WayofTime.alchemicalWizardry.common.entity.mob;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.IMob;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
public class EntityHolyElemental extends EntityElemental implements IMob
{
public EntityHolyElemental(World world)
{
super(world, AlchemicalWizardry.entityHolyElementalID);
}
public void inflictEffectOnEntity(Entity target)
{
if (target instanceof EntityLivingBase)
{
((EntityLivingBase) target).attackEntityFrom(DamageSource.causeMobDamage(this), 15);
((EntityLivingBase) target).addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionInhibit.id, 150, 0));
((EntityLivingBase) target).addPotionEffect(new PotionEffect(Potion.poison.id, 100, 1));
}
}
}

View file

@ -0,0 +1,496 @@
package WayofTime.alchemicalWizardry.common.entity.mob;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.ModItems;
import WayofTime.alchemicalWizardry.common.EntityAITargetAggro;
import WayofTime.alchemicalWizardry.common.entity.projectile.IceProjectile;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import net.minecraft.entity.*;
import net.minecraft.entity.ai.*;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityGhast;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.pathfinding.PathEntity;
import net.minecraft.util.DamageSource;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
public class EntityIceDemon extends EntityDemon implements IRangedAttackMob
{
private EntityAIArrowAttack aiArrowAttack = new EntityAIArrowAttack(this, 1.0D, 30, 50, 15.0F);
private EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.2D, false);
private static float maxTamedHealth = 50.0F;
private static float maxUntamedHealth = 30.0F;
public EntityIceDemon(World par1World)
{
super(par1World, AlchemicalWizardry.entityIceDemonID);
this.setSize(0.5F, 2.0F);
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(2, this.aiSit);
this.tasks.addTask(3, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F));
this.tasks.addTask(4, new EntityAIWander(this, 1.0D));
this.tasks.addTask(5, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
this.tasks.addTask(6, new EntityAILookIdle(this));
this.targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this));
this.targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this));
this.targetTasks.addTask(3, new EntityAIHurtByTarget(this, true));
this.targetTasks.addTask(4, new EntityAITargetAggro(this, EntityPlayer.class, 0, false));
this.setAggro(false);
this.setTamed(false);
if (par1World != null && !par1World.isRemote)
{
this.setCombatTask();
}
}
@Override
protected void applyEntityAttributes()
{
super.applyEntityAttributes();
//This line affects the speed of the monster
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.40000001192092896D);
//My guess is that this will alter the max health
if (this.isTamed())
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxTamedHealth);
} else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxUntamedHealth);
}
}
/**
* Returns true if the newer Entity AI code should be run
*/
public boolean isAIEnabled()
{
return true;
}
/**
* Sets the active target the Task system uses for tracking
*/
public void setAttackTarget(EntityLivingBase par1EntityLivingBase)
{
super.setAttackTarget(par1EntityLivingBase);
if (par1EntityLivingBase == null)
{
this.setAngry(false);
} else if (!this.isTamed())
{
this.setAngry(true);
}
}
/**
* main AI tick function, replaces updateEntityActionState
*/
protected void updateAITick()
{
this.dataWatcher.updateObject(18, Float.valueOf(this.getHealth()));
}
protected void entityInit()
{
super.entityInit();
this.dataWatcher.addObject(18, new Float(this.getHealth()));
this.dataWatcher.addObject(19, new Byte((byte) 0));
}
/**
* Plays step sound at given x, y, z for the entity
*/
protected void playStepSound(int par1, int par2, int par3, int par4)
{
this.playSound("mob.zombie.step", 0.15F, 1.0F);
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
par1NBTTagCompound.setBoolean("Angry", this.isAngry());
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
this.setAngry(par1NBTTagCompound.getBoolean("Angry"));
this.setCombatTask();
}
/**
* Returns the sound this mob makes while it's alive.
*/
protected String getLivingSound()
{
return "none";
}
/**
* Returns the sound this mob makes when it is hurt.
*/
protected String getHurtSound()
{
return "mob.irongolem.hit";
}
/**
* Returns the sound this mob makes on death.
*/
protected String getDeathSound()
{
return "mob.irongolem.death";
}
/**
* Returns the volume for the sounds this mob makes.
*/
protected float getSoundVolume()
{
return 0.4F;
}
/**
* Returns the item ID for the item the mob drops on death.
*/
protected int getDropItemId()
{
return -1;
}
/**
* Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
* use this to react to sunlight and start to burn.
*/
public void onLivingUpdate()
{
super.onLivingUpdate();
int range = 2;
Vec3 blockVector = SpellHelper.getEntityBlockVector(this);
int xCoord = (int) (blockVector.xCoord);
int yCoord = (int) (blockVector.yCoord);
int zCoord = (int) (blockVector.zCoord);
for (int i = -range; i <= range; i++)
{
for (int j = -range; j <= range; j++)
{
for (int k = -range; k <= range; k++)
{
if (worldObj.rand.nextFloat() < 0.25f)
{
SpellHelper.freezeWaterBlock(worldObj, xCoord + i, yCoord + j, zCoord + k);
}
}
}
}
}
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
super.onUpdate();
}
public float getEyeHeight()
{
return this.height * 0.8F;
}
/**
* The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently
* use in wolves.
*/
public int getVerticalFaceSpeed()
{
return this.isSitting() ? 20 : super.getVerticalFaceSpeed();
}
/**
* Called when the entity is attacked.
*/
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
{
if (this.isEntityInvulnerable())
{
return false;
} else
{
Entity entity = par1DamageSource.getEntity();
this.aiSit.setSitting(false);
if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow))
{
par2 = (par2 + 1.0F) / 2.0F;
}
return super.attackEntityFrom(par1DamageSource, par2);
}
}
public boolean attackEntityAsMob(Entity par1Entity)
{
int i = this.isTamed() ? 4 : 2;
return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i);
}
public void setTamed(boolean par1)
{
super.setTamed(par1);
if (par1)
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxTamedHealth);
} else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxUntamedHealth);
}
}
/**
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
*/
@Override
public boolean interact(EntityPlayer par1EntityPlayer)
{
ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
if (this.isTamed())
{
if (itemstack != null)
{
if (itemstack.getItem() instanceof ItemFood)
{
ItemFood itemfood = (ItemFood) itemstack.getItem();
if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < this.maxTamedHealth)
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
this.heal((float) itemfood.func_150905_g(itemstack));
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack) null);
}
return true;
}
}
}
if (this.getOwner() instanceof EntityPlayer && SpellHelper.getUsername(par1EntityPlayer).equalsIgnoreCase(SpellHelper.getUsername((EntityPlayer) this.getOwner())) && !this.isBreedingItem(itemstack))
{
if (!this.worldObj.isRemote)
{
this.aiSit.setSitting(!this.isSitting());
this.isJumping = false;
this.setPathToEntity((PathEntity) null);
this.setTarget((Entity) null);
this.setAttackTarget((EntityLivingBase) null);
}
this.sendSittingMessageToPlayer(par1EntityPlayer, !this.isSitting());
}
} else if (itemstack != null && itemstack.getItem().equals(ModItems.weakBloodOrb) && !this.isAngry())
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack) null);
}
if (!this.worldObj.isRemote)
{
if (this.rand.nextInt(1) == 0)
{
this.setTamed(true);
this.setPathToEntity((PathEntity) null);
this.setAttackTarget((EntityLivingBase) null);
this.aiSit.setSitting(true);
this.setHealth(this.maxTamedHealth);
this.func_152115_b(par1EntityPlayer.getUniqueID().toString());
this.playTameEffect(true);
this.worldObj.setEntityState(this, (byte) 7);
} else
{
this.playTameEffect(false);
this.worldObj.setEntityState(this, (byte) 6);
}
}
return true;
}
return super.interact(par1EntityPlayer);
}
/**
* Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on
* the animal type)
*/
public boolean isBreedingItem(ItemStack par1ItemStack)
{
return false;
}
/**
* Determines whether this wolf is angry or not.
*/
public boolean isAngry()
{
return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0;
}
/**
* Sets whether this wolf is angry or not.
*/
public void setAngry(boolean par1)
{
byte b0 = this.dataWatcher.getWatchableObjectByte(16);
if (par1)
{
this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 | 2)));
} else
{
this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 & -3)));
}
}
/**
* Return this wolf's collar color.
*/
public int getCollarColor()
{
return this.dataWatcher.getWatchableObjectByte(20) & 15;
}
/**
* Set this wolf's collar color.
*/
public void setCollarColor(int par1)
{
this.dataWatcher.updateObject(20, Byte.valueOf((byte) (par1 & 15)));
}
/**
* This function is used when two same-species animals in 'love mode' breed to generate the new baby animal.
*/
public EntityWolf spawnBabyAnimal(EntityAgeable par1EntityAgeable)
{
return null;
}
public void func_70918_i(boolean par1)
{
if (par1)
{
this.dataWatcher.updateObject(19, Byte.valueOf((byte) 1));
} else
{
this.dataWatcher.updateObject(19, Byte.valueOf((byte) 0));
}
}
/**
* Returns true if the mob is currently able to mate with the specified mob.
*/
public boolean canMateWith(EntityAnimal par1EntityAnimal)
{
return false;
}
public boolean func_70922_bv()
{
return this.dataWatcher.getWatchableObjectByte(19) == 1;
}
/**
* Determines if an entity can be despawned, used on idle far away entities
*/
protected boolean canDespawn()
{
return false;
}
public boolean func_142018_a(EntityLivingBase par1EntityLivingBase, EntityLivingBase par2EntityLivingBase)
{
if (!(par1EntityLivingBase instanceof EntityCreeper) && !(par1EntityLivingBase instanceof EntityGhast))
{
if (par1EntityLivingBase instanceof EntityIceDemon)
{
EntityIceDemon entitywolf = (EntityIceDemon) par1EntityLivingBase;
if (entitywolf.isTamed() && entitywolf.getOwner() == par2EntityLivingBase)
{
return false;
}
}
return par1EntityLivingBase instanceof EntityPlayer && par2EntityLivingBase instanceof EntityPlayer && !((EntityPlayer) par2EntityLivingBase).canAttackPlayer((EntityPlayer) par1EntityLivingBase) ? false : !(par1EntityLivingBase instanceof EntityHorse) || !((EntityHorse) par1EntityLivingBase).isTame();
} else
{
return false;
}
}
public EntityAgeable createChild(EntityAgeable par1EntityAgeable)
{
return this.spawnBabyAnimal(par1EntityAgeable);
}
/**
* Attack the specified entity using a ranged attack.
*/
public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2)
{
double xCoord;
double yCoord;
double zCoord;
IceProjectile hol = new IceProjectile(worldObj, this, par1EntityLivingBase, 1.8f, 0f, 3, 600);
this.worldObj.spawnEntityInWorld(hol);
}
/**
* sets this entity's combat AI.
*/
public void setCombatTask()
{
this.tasks.removeTask(this.aiAttackOnCollide);
this.tasks.removeTask(this.aiArrowAttack);
ItemStack itemstack = this.getHeldItem();
this.tasks.addTask(4, this.aiArrowAttack);
}
}

View file

@ -0,0 +1,474 @@
package WayofTime.alchemicalWizardry.common.entity.mob;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.ModItems;
import WayofTime.alchemicalWizardry.common.EntityAITargetAggro;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.*;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityGhast;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.pathfinding.PathEntity;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
public class EntityLowerGuardian extends EntityDemon
{
private EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.2D, false);
private static float maxTamedHealth = 50.0F;
private static float maxUntamedHealth = 30.0F;
private int attackTimer;
private boolean isAggro;
public EntityLowerGuardian(World par1World)
{
super(par1World, AlchemicalWizardry.entityLowerGuardianID);
this.setSize(0.7F, 1.8F);
this.getNavigator().setAvoidsWater(true);
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(2, new EntityAIAttackOnCollide(this, 1.0D, true));
this.tasks.addTask(3, this.aiSit);
this.tasks.addTask(4, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F));
this.tasks.addTask(5, new EntityAIWander(this, 1.0D));
this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
this.tasks.addTask(7, new EntityAILookIdle(this));
this.targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this));
this.targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this));
this.targetTasks.addTask(3, new EntityAIHurtByTarget(this, true));
this.targetTasks.addTask(4, new EntityAITargetAggro(this, EntityPlayer.class, 0, false));
this.setAggro(false);
this.setTamed(false);
attackTimer = 0;
}
@Override
protected void applyEntityAttributes()
{
super.applyEntityAttributes();
//This line affects the speed of the monster
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.30000001192092896D);
//My guess is that this will alter the max health
if (this.isTamed())
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxTamedHealth);
} else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxUntamedHealth);
}
}
/**
* Returns true if the newer Entity AI code should be run
*/
public boolean isAIEnabled()
{
return true;
}
/**
* Sets the active target the Task system uses for tracking
*/
public void setAttackTarget(EntityLivingBase par1EntityLivingBase)
{
super.setAttackTarget(par1EntityLivingBase);
if (par1EntityLivingBase == null)
{
this.setAngry(false);
} else if (!this.isTamed())
{
this.setAngry(true);
}
}
/**
* main AI tick function, replaces updateEntityActionState
*/
protected void updateAITick()
{
this.dataWatcher.updateObject(18, Float.valueOf(this.getHealth()));
}
protected void entityInit()
{
super.entityInit();
this.dataWatcher.addObject(18, new Float(this.getHealth()));
this.dataWatcher.addObject(19, new Byte((byte) 0));
}
/**
* Plays step sound at given x, y, z for the entity
*/
protected void playStepSound(int par1, int par2, int par3, int par4)
{
this.playSound("mob.zombie.step", 0.15F, 1.0F);
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
par1NBTTagCompound.setBoolean("Angry", this.isAngry());
par1NBTTagCompound.setByte("attackTimer", (byte) attackTimer);
par1NBTTagCompound.setBoolean("isAggro", this.isAggro());
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
this.setAngry(par1NBTTagCompound.getBoolean("Angry"));
attackTimer = par1NBTTagCompound.getByte("attackTimer");
isAggro = par1NBTTagCompound.getBoolean("isAggro");
}
/**
* Returns the sound this mob makes while it's alive.
*/
protected String getLivingSound()
{
return "none";
}
/**
* Returns the sound this mob makes when it is hurt.
*/
protected String getHurtSound()
{
return "mob.irongolem.hit";
}
/**
* Returns the sound this mob makes on death.
*/
protected String getDeathSound()
{
return "mob.irongolem.death";
}
/**
* Returns the volume for the sounds this mob makes.
*/
protected float getSoundVolume()
{
return 1.0F;
}
/**
* Returns the item ID for the item the mob drops on death.
*/
protected int getDropItemId()
{
return -1;
}
/**
* Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
* use this to react to sunlight and start to burn.
*/
public void onLivingUpdate()
{
super.onLivingUpdate();
if (attackTimer > 0)
{
attackTimer--;
}
}
public int getAttackTimer()
{
return attackTimer;
}
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
super.onUpdate();
}
public float getEyeHeight()
{
return this.height * 0.8F;
}
/**
* The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently
* use in wolves.
*/
public int getVerticalFaceSpeed()
{
return this.isSitting() ? 20 : super.getVerticalFaceSpeed();
}
/**
* Called when the entity is attacked.
*/
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
{
if (this.isEntityInvulnerable())
{
return false;
} else
{
Entity entity = par1DamageSource.getEntity();
this.aiSit.setSitting(false);
if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow))
{
par2 = (par2 + 1.0F) / 2.0F;
}
return super.attackEntityFrom(par1DamageSource, par2);
}
}
public boolean attackEntityAsMob(Entity par1Entity)
{
this.attackTimer = 10;
this.worldObj.setEntityState(this, (byte) 4);
boolean flag = par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) (7 + this.rand.nextInt(15)));
if (flag)
{
par1Entity.motionY += 0.4000000059604645D;
}
this.playSound("mob.irongolem.throw", 1.0F, 1.0F);
return flag;
}
public void setTamed(boolean par1)
{
super.setTamed(par1);
if (par1)
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxTamedHealth);
} else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxUntamedHealth);
}
}
/**
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
*/
@Override
public boolean interact(EntityPlayer par1EntityPlayer)
{
ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
if (this.isTamed())
{
if (itemstack != null)
{
if (itemstack.getItem() instanceof ItemFood)
{
ItemFood itemfood = (ItemFood) itemstack.getItem();
if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < this.maxTamedHealth)
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
this.heal((float) itemfood.func_150905_g(itemstack));
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack) null);
}
return true;
}
}
}
if (this.getOwner() instanceof EntityPlayer && SpellHelper.getUsername(par1EntityPlayer).equalsIgnoreCase(SpellHelper.getUsername((EntityPlayer) this.getOwner())) && !this.isBreedingItem(itemstack))
{
if (!this.worldObj.isRemote)
{
this.aiSit.setSitting(!this.isSitting());
this.isJumping = false;
this.setPathToEntity((PathEntity) null);
this.setTarget((Entity) null);
this.setAttackTarget((EntityLivingBase) null);
}
this.sendSittingMessageToPlayer(par1EntityPlayer, !this.isSitting());
}
} else if (itemstack != null && itemstack.getItem().equals(ModItems.weakBloodOrb) && !this.isAngry())
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack) null);
}
if (!this.worldObj.isRemote)
{
if (this.rand.nextInt(1) == 0)
{
this.setTamed(true);
this.setPathToEntity((PathEntity) null);
this.setAttackTarget((EntityLivingBase) null);
this.aiSit.setSitting(true);
this.setHealth(this.maxTamedHealth);
this.func_152115_b(par1EntityPlayer.getUniqueID().toString());
this.playTameEffect(true);
this.worldObj.setEntityState(this, (byte) 7);
} else
{
this.playTameEffect(false);
this.worldObj.setEntityState(this, (byte) 6);
}
}
return true;
}
return super.interact(par1EntityPlayer);
}
/**
* Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on
* the animal type)
*/
public boolean isBreedingItem(ItemStack par1ItemStack)
{
return false;
}
/**
* Determines whether this wolf is angry or not.
*/
public boolean isAngry()
{
return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0;
}
/**
* Sets whether this wolf is angry or not.
*/
public void setAngry(boolean par1)
{
byte b0 = this.dataWatcher.getWatchableObjectByte(16);
if (par1)
{
this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 | 2)));
} else
{
this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 & -3)));
}
}
/**
* Return this wolf's collar color.
*/
public int getCollarColor()
{
return this.dataWatcher.getWatchableObjectByte(20) & 15;
}
/**
* Set this wolf's collar color.
*/
public void setCollarColor(int par1)
{
this.dataWatcher.updateObject(20, Byte.valueOf((byte) (par1 & 15)));
}
/**
* This function is used when two same-species animals in 'love mode' breed to generate the new baby animal.
*/
public EntityWolf spawnBabyAnimal(EntityAgeable par1EntityAgeable)
{
return null;
}
public void func_70918_i(boolean par1)
{
if (par1)
{
this.dataWatcher.updateObject(19, Byte.valueOf((byte) 1));
} else
{
this.dataWatcher.updateObject(19, Byte.valueOf((byte) 0));
}
}
/**
* Returns true if the mob is currently able to mate with the specified mob.
*/
public boolean canMateWith(EntityAnimal par1EntityAnimal)
{
return false;
}
public boolean func_70922_bv()
{
return this.dataWatcher.getWatchableObjectByte(19) == 1;
}
/**
* Determines if an entity can be despawned, used on idle far away entities
*/
protected boolean canDespawn()
{
return false;
}
public boolean func_142018_a(EntityLivingBase par1EntityLivingBase, EntityLivingBase par2EntityLivingBase)
{
if (!(par1EntityLivingBase instanceof EntityCreeper) && !(par1EntityLivingBase instanceof EntityGhast))
{
if (par1EntityLivingBase instanceof EntityLowerGuardian)
{
EntityLowerGuardian entitywolf = (EntityLowerGuardian) par1EntityLivingBase;
if (entitywolf.isTamed() && entitywolf.getOwner() == par2EntityLivingBase)
{
return false;
}
}
return par1EntityLivingBase instanceof EntityPlayer && par2EntityLivingBase instanceof EntityPlayer && !((EntityPlayer) par2EntityLivingBase).canAttackPlayer((EntityPlayer) par1EntityLivingBase) ? false : !(par1EntityLivingBase instanceof EntityHorse) || !((EntityHorse) par1EntityLivingBase).isTame();
} else
{
return false;
}
}
public EntityAgeable createChild(EntityAgeable par1EntityAgeable)
{
return this.spawnBabyAnimal(par1EntityAgeable);
}
}

View file

@ -0,0 +1,479 @@
package WayofTime.alchemicalWizardry.common.entity.mob;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.ModItems;
import WayofTime.alchemicalWizardry.common.EntityAITargetAggro;
import WayofTime.alchemicalWizardry.common.entity.projectile.HolyProjectile;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.*;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityGhast;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.pathfinding.PathEntity;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
public class EntityShade extends EntityDemon
{
private EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.2D, false);
private static float maxTamedHealth = 50.0F;
private static float maxUntamedHealth = 100.0F;
public EntityShade(World par1World)
{
super(par1World, AlchemicalWizardry.entityShadeID);
this.setSize(0.8F, 2.0F);
this.getNavigator().setAvoidsWater(true);
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(2, this.aiSit);
this.tasks.addTask(3, new EntityAIAttackOnCollide(this, 1.0D, true));
this.tasks.addTask(4, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F));
this.tasks.addTask(5, new EntityAIWander(this, 1.0D));
this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
this.tasks.addTask(7, new EntityAILookIdle(this));
this.targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this));
this.targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this));
this.targetTasks.addTask(3, new EntityAIHurtByTarget(this, true));
this.targetTasks.addTask(4, new EntityAITargetAggro(this, EntityPlayer.class, 0, false));
this.setAggro(false);
this.setTamed(false);
if (par1World != null && !par1World.isRemote)
{
this.setCombatTask();
}
}
@Override
protected void applyEntityAttributes()
{
super.applyEntityAttributes();
//This line affects the speed of the monster
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.30000001192092896D);
//My guess is that this will alter the max health
if (this.isTamed())
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxTamedHealth);
} else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxUntamedHealth);
}
}
/**
* Returns true if the newer Entity AI code should be run
*/
public boolean isAIEnabled()
{
return true;
}
/**
* Sets the active target the Task system uses for tracking
*/
public void setAttackTarget(EntityLivingBase par1EntityLivingBase)
{
super.setAttackTarget(par1EntityLivingBase);
if (par1EntityLivingBase == null)
{
this.setAngry(false);
} else if (!this.isTamed())
{
this.setAngry(true);
}
}
/**
* main AI tick function, replaces updateEntityActionState
*/
protected void updateAITick()
{
this.dataWatcher.updateObject(18, Float.valueOf(this.getHealth()));
}
protected void entityInit()
{
super.entityInit();
this.dataWatcher.addObject(18, new Float(this.getHealth()));
this.dataWatcher.addObject(19, new Byte((byte) 0));
}
/**
* Plays step sound at given x, y, z for the entity
*/
protected void playStepSound(int par1, int par2, int par3, int par4)
{
this.playSound("mob.zombie.step", 0.15F, 1.0F);
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
par1NBTTagCompound.setBoolean("Angry", this.isAngry());
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
this.setAngry(par1NBTTagCompound.getBoolean("Angry"));
this.setCombatTask();
}
/**
* Returns the sound this mob makes while it's alive.
*/
protected String getLivingSound()
{
//TODO change sounds
return "none";
}
/**
* Returns the sound this mob makes when it is hurt.
*/
protected String getHurtSound()
{
return "none";
}
/**
* Returns the sound this mob makes on death.
*/
protected String getDeathSound()
{
return "none";
}
/**
* Returns the volume for the sounds this mob makes.
*/
protected float getSoundVolume()
{
return 0.4F;
}
/**
* Returns the item ID for the item the mob drops on death.
*/
protected int getDropItemId()
{
return -1;
}
/**
* Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
* use this to react to sunlight and start to burn.
*/
public void onLivingUpdate()
{
super.onLivingUpdate();
}
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
super.onUpdate();
}
public float getEyeHeight()
{
return this.height * 0.8F;
}
/**
* The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently
* use in wolves.
*/
public int getVerticalFaceSpeed()
{
return this.isSitting() ? 20 : super.getVerticalFaceSpeed();
}
/**
* Called when the entity is attacked.
*/
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
{
if (this.isEntityInvulnerable())
{
return false;
} else
{
Entity entity = par1DamageSource.getEntity();
this.aiSit.setSitting(false);
if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow))
{
par2 = (par2 + 1.0F) / 2.0F;
}
return super.attackEntityFrom(par1DamageSource, par2);
}
}
public boolean attackEntityAsMob(Entity par1Entity)
{
int i = this.isTamed() ? 6 : 7;
return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i);
}
public void setTamed(boolean par1)
{
super.setTamed(par1);
if (par1)
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxTamedHealth);
} else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxUntamedHealth);
}
}
/**
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
*/
@Override
public boolean interact(EntityPlayer par1EntityPlayer)
{
ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
if (this.isTamed())
{
if (itemstack != null)
{
if (itemstack.getItem() instanceof ItemFood)
{
ItemFood itemfood = (ItemFood) itemstack.getItem();
if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < this.maxTamedHealth)
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
this.heal((float) itemfood.func_150905_g(itemstack));
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack) null);
}
return true;
}
}
}
if (this.getOwner() instanceof EntityPlayer && SpellHelper.getUsername(par1EntityPlayer).equalsIgnoreCase(SpellHelper.getUsername((EntityPlayer) this.getOwner())) && !this.isBreedingItem(itemstack))
{
if (!this.worldObj.isRemote)
{
this.aiSit.setSitting(!this.isSitting());
this.isJumping = false;
this.setPathToEntity((PathEntity) null);
this.setTarget((Entity) null);
this.setAttackTarget((EntityLivingBase) null);
}
this.sendSittingMessageToPlayer(par1EntityPlayer, !this.isSitting());
}
} else if (itemstack != null && itemstack.getItem().equals(ModItems.weakBloodOrb) && !this.isAngry())
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack) null);
}
if (!this.worldObj.isRemote)
{
if (this.rand.nextInt(1) == 0)
{
this.setTamed(true);
this.setPathToEntity((PathEntity) null);
this.setAttackTarget((EntityLivingBase) null);
this.aiSit.setSitting(true);
this.setHealth(this.maxTamedHealth);
this.func_152115_b(par1EntityPlayer.getUniqueID().toString());
this.playTameEffect(true);
this.worldObj.setEntityState(this, (byte) 7);
} else
{
this.playTameEffect(false);
this.worldObj.setEntityState(this, (byte) 6);
}
}
return true;
}
return super.interact(par1EntityPlayer);
}
/**
* Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on
* the animal type)
*/
public boolean isBreedingItem(ItemStack par1ItemStack)
{
return false;
}
/**
* Determines whether this wolf is angry or not.
*/
public boolean isAngry()
{
return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0;
}
/**
* Sets whether this wolf is angry or not.
*/
public void setAngry(boolean par1)
{
byte b0 = this.dataWatcher.getWatchableObjectByte(16);
if (par1)
{
this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 | 2)));
} else
{
this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 & -3)));
}
}
/**
* Return this wolf's collar color.
*/
public int getCollarColor()
{
return this.dataWatcher.getWatchableObjectByte(20) & 15;
}
/**
* Set this wolf's collar color.
*/
public void setCollarColor(int par1)
{
this.dataWatcher.updateObject(20, Byte.valueOf((byte) (par1 & 15)));
}
/**
* This function is used when two same-species animals in 'love mode' breed to generate the new baby animal.
*/
public EntityWolf spawnBabyAnimal(EntityAgeable par1EntityAgeable)
{
return null;
}
public void func_70918_i(boolean par1)
{
if (par1)
{
this.dataWatcher.updateObject(19, Byte.valueOf((byte) 1));
} else
{
this.dataWatcher.updateObject(19, Byte.valueOf((byte) 0));
}
}
/**
* Returns true if the mob is currently able to mate with the specified mob.
*/
public boolean canMateWith(EntityAnimal par1EntityAnimal)
{
return false;
}
public boolean func_70922_bv()
{
return this.dataWatcher.getWatchableObjectByte(19) == 1;
}
/**
* Determines if an entity can be despawned, used on idle far away entities
*/
protected boolean canDespawn()
{
return false;
}
public boolean func_142018_a(EntityLivingBase par1EntityLivingBase, EntityLivingBase par2EntityLivingBase)
{
if (!(par1EntityLivingBase instanceof EntityCreeper) && !(par1EntityLivingBase instanceof EntityGhast))
{
if (par1EntityLivingBase instanceof EntityBoulderFist)
{
EntityBoulderFist entitywolf = (EntityBoulderFist) par1EntityLivingBase;
if (entitywolf.isTamed() && entitywolf.getOwner() == par2EntityLivingBase)
{
return false;
}
}
return par1EntityLivingBase instanceof EntityPlayer && par2EntityLivingBase instanceof EntityPlayer && !((EntityPlayer) par2EntityLivingBase).canAttackPlayer((EntityPlayer) par1EntityLivingBase) ? false : !(par1EntityLivingBase instanceof EntityHorse) || !((EntityHorse) par1EntityLivingBase).isTame();
} else
{
return false;
}
}
public EntityAgeable createChild(EntityAgeable par1EntityAgeable)
{
return this.spawnBabyAnimal(par1EntityAgeable);
}
/**
* Attack the specified entity using a ranged attack.
*/
public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2)
{
double xCoord;
double yCoord;
double zCoord;
HolyProjectile hol = new HolyProjectile(worldObj, this, par1EntityLivingBase, 1.8f, 0f, 5, 600);
this.worldObj.spawnEntityInWorld(hol);
}
/**
* sets this entity's combat AI.
*/
public void setCombatTask()
{
this.tasks.removeTask(this.aiAttackOnCollide);
//this.tasks.removeTask(this.aiArrowAttack);
ItemStack itemstack = this.getHeldItem();
this.tasks.addTask(4, this.aiAttackOnCollide);
}
}

View file

@ -0,0 +1,27 @@
package WayofTime.alchemicalWizardry.common.entity.mob;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.IMob;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
public class EntityShadeElemental extends EntityElemental implements IMob
{
public EntityShadeElemental(World world)
{
super(world, AlchemicalWizardry.entityShadeElementalID);
}
public void inflictEffectOnEntity(Entity target)
{
if (target instanceof EntityLivingBase)
{
((EntityLivingBase) target).addPotionEffect(new PotionEffect(Potion.blindness.id, 100, 1));
((EntityLivingBase) target).addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionInhibit.id, 150, 0));
((EntityLivingBase) target).addPotionEffect(new PotionEffect(Potion.nightVision.id, 100, 0));
}
}
}

View file

@ -0,0 +1,475 @@
package WayofTime.alchemicalWizardry.common.entity.mob;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.ModItems;
import WayofTime.alchemicalWizardry.common.EntityAITargetAggro;
import WayofTime.alchemicalWizardry.common.entity.projectile.MudProjectile;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import net.minecraft.entity.*;
import net.minecraft.entity.ai.*;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityGhast;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.pathfinding.PathEntity;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
public class EntitySmallEarthGolem extends EntityDemon implements IRangedAttackMob
{
private EntityAIArrowAttack aiArrowAttack = new EntityAIArrowAttack(this, 1.0D, 25, 25, 15.0F);
private EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.2D, false);
private static float maxTamedHealth = 20.0F;
private static float maxUntamedHealth = 10.0F;
public EntitySmallEarthGolem(World par1World)
{
super(par1World, AlchemicalWizardry.entitySmallEarthGolemID);
this.setSize(0.2F, 1.0F);
this.getNavigator().setAvoidsWater(true);
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(2, this.aiSit);
this.tasks.addTask(3, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F));
this.tasks.addTask(4, new EntityAIWander(this, 1.0D));
this.tasks.addTask(5, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
this.tasks.addTask(5, new EntityAILookIdle(this));
this.targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this));
this.targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this));
this.targetTasks.addTask(3, new EntityAIHurtByTarget(this, true));
this.targetTasks.addTask(4, new EntityAITargetAggro(this, EntityPlayer.class, 0, false));
this.setAggro(false);
this.setTamed(false);
if (par1World != null && !par1World.isRemote)
{
this.setCombatTask();
}
}
@Override
protected void applyEntityAttributes()
{
super.applyEntityAttributes();
//This line affects the speed of the monster
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.40000001192092896D);
//My guess is that this will alter the max health
if (this.isTamed())
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxTamedHealth);
} else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxUntamedHealth);
}
}
/**
* Returns true if the newer Entity AI code should be run
*/
public boolean isAIEnabled()
{
return true;
}
/**
* Sets the active target the Task system uses for tracking
*/
public void setAttackTarget(EntityLivingBase par1EntityLivingBase)
{
super.setAttackTarget(par1EntityLivingBase);
if (par1EntityLivingBase == null)
{
this.setAngry(false);
} else if (!this.isTamed())
{
this.setAngry(true);
}
}
/**
* main AI tick function, replaces updateEntityActionState
*/
protected void updateAITick()
{
this.dataWatcher.updateObject(18, Float.valueOf(this.getHealth()));
}
protected void entityInit()
{
super.entityInit();
this.dataWatcher.addObject(18, new Float(this.getHealth()));
this.dataWatcher.addObject(19, new Byte((byte) 0));
}
/**
* Plays step sound at given x, y, z for the entity
*/
protected void playStepSound(int par1, int par2, int par3, int par4)
{
this.playSound("mob.zombie.step", 0.15F, 1.0F);
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
par1NBTTagCompound.setBoolean("Angry", this.isAngry());
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
this.setAngry(par1NBTTagCompound.getBoolean("Angry"));
this.setCombatTask();
}
/**
* Returns the sound this mob makes while it's alive.
*/
protected String getLivingSound()
{
return "none";
}
/**
* Returns the sound this mob makes when it is hurt.
*/
protected String getHurtSound()
{
return "mob.irongolem.hit";
}
/**
* Returns the sound this mob makes on death.
*/
protected String getDeathSound()
{
return "mob.irongolem.death";
}
/**
* Returns the volume for the sounds this mob makes.
*/
protected float getSoundVolume()
{
return 0.4F;
}
/**
* Returns the item ID for the item the mob drops on death.
*/
protected int getDropItemId()
{
return -1;
}
/**
* Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
* use this to react to sunlight and start to burn.
*/
public void onLivingUpdate()
{
super.onLivingUpdate();
}
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
super.onUpdate();
}
public float getEyeHeight()
{
return this.height * 0.8F;
}
/**
* The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently
* use in wolves.
*/
public int getVerticalFaceSpeed()
{
return this.isSitting() ? 20 : super.getVerticalFaceSpeed();
}
/**
* Called when the entity is attacked.
*/
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
{
if (this.isEntityInvulnerable())
{
return false;
} else
{
Entity entity = par1DamageSource.getEntity();
this.aiSit.setSitting(false);
if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow))
{
par2 = (par2 + 1.0F) / 2.0F;
}
return super.attackEntityFrom(par1DamageSource, par2);
}
}
public boolean attackEntityAsMob(Entity par1Entity)
{
int i = this.isTamed() ? 4 : 2;
return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i);
}
public void setTamed(boolean par1)
{
super.setTamed(par1);
if (par1)
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxTamedHealth);
} else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxUntamedHealth);
}
}
/**
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
*/
@Override
public boolean interact(EntityPlayer par1EntityPlayer)
{
ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
if (this.isTamed())
{
if (itemstack != null)
{
if (itemstack.getItem() instanceof ItemFood)
{
ItemFood itemfood = (ItemFood) itemstack.getItem();
if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < this.maxTamedHealth)
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
this.heal((float) itemfood.func_150905_g(itemstack));
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack) null);
}
return true;
}
}
}
if (this.getOwner() instanceof EntityPlayer && SpellHelper.getUsername(par1EntityPlayer).equalsIgnoreCase(SpellHelper.getUsername((EntityPlayer) this.getOwner())) && !this.isBreedingItem(itemstack))
{
if (!this.worldObj.isRemote)
{
this.aiSit.setSitting(!this.isSitting());
this.isJumping = false;
this.setPathToEntity((PathEntity) null);
this.setTarget((Entity) null);
this.setAttackTarget((EntityLivingBase) null);
}
this.sendSittingMessageToPlayer(par1EntityPlayer, !this.isSitting());
}
} else if (itemstack != null && itemstack.getItem().equals(ModItems.weakBloodOrb) && !this.isAngry())
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack) null);
}
if (!this.worldObj.isRemote)
{
if (this.rand.nextInt(1) == 0)
{
this.setTamed(true);
this.setPathToEntity((PathEntity) null);
this.setAttackTarget((EntityLivingBase) null);
this.aiSit.setSitting(true);
this.setHealth(this.maxTamedHealth);
this.func_152115_b(par1EntityPlayer.getUniqueID().toString());
this.playTameEffect(true);
this.worldObj.setEntityState(this, (byte) 7);
} else
{
this.playTameEffect(false);
this.worldObj.setEntityState(this, (byte) 6);
}
}
return true;
}
return super.interact(par1EntityPlayer);
}
/**
* Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on
* the animal type)
*/
public boolean isBreedingItem(ItemStack par1ItemStack)
{
return false;
}
/**
* Determines whether this wolf is angry or not.
*/
public boolean isAngry()
{
return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0;
}
/**
* Sets whether this wolf is angry or not.
*/
public void setAngry(boolean par1)
{
byte b0 = this.dataWatcher.getWatchableObjectByte(16);
if (par1)
{
this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 | 2)));
} else
{
this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 & -3)));
}
}
/**
* Return this wolf's collar color.
*/
public int getCollarColor()
{
return this.dataWatcher.getWatchableObjectByte(20) & 15;
}
/**
* Set this wolf's collar color.
*/
public void setCollarColor(int par1)
{
this.dataWatcher.updateObject(20, Byte.valueOf((byte) (par1 & 15)));
}
/**
* This function is used when two same-species animals in 'love mode' breed to generate the new baby animal.
*/
public EntityWolf spawnBabyAnimal(EntityAgeable par1EntityAgeable)
{
return null;
}
public void func_70918_i(boolean par1)
{
if (par1)
{
this.dataWatcher.updateObject(19, Byte.valueOf((byte) 1));
} else
{
this.dataWatcher.updateObject(19, Byte.valueOf((byte) 0));
}
}
/**
* Returns true if the mob is currently able to mate with the specified mob.
*/
public boolean canMateWith(EntityAnimal par1EntityAnimal)
{
return false;
}
public boolean func_70922_bv()
{
return this.dataWatcher.getWatchableObjectByte(19) == 1;
}
/**
* Determines if an entity can be despawned, used on idle far away entities
*/
protected boolean canDespawn()
{
return false;
}
public boolean func_142018_a(EntityLivingBase par1EntityLivingBase, EntityLivingBase par2EntityLivingBase)
{
if (!(par1EntityLivingBase instanceof EntityCreeper) && !(par1EntityLivingBase instanceof EntityGhast))
{
if (par1EntityLivingBase instanceof EntitySmallEarthGolem)
{
EntitySmallEarthGolem entitywolf = (EntitySmallEarthGolem) par1EntityLivingBase;
if (entitywolf.isTamed() && entitywolf.getOwner() == par2EntityLivingBase)
{
return false;
}
}
return par1EntityLivingBase instanceof EntityPlayer && par2EntityLivingBase instanceof EntityPlayer && !((EntityPlayer) par2EntityLivingBase).canAttackPlayer((EntityPlayer) par1EntityLivingBase) ? false : !(par1EntityLivingBase instanceof EntityHorse) || !((EntityHorse) par1EntityLivingBase).isTame();
} else
{
return false;
}
}
public EntityAgeable createChild(EntityAgeable par1EntityAgeable)
{
return this.spawnBabyAnimal(par1EntityAgeable);
}
/**
* Attack the specified entity using a ranged attack.
*/
public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2)
{
double xCoord;
double yCoord;
double zCoord;
MudProjectile hol = new MudProjectile(worldObj, this, par1EntityLivingBase, 1.8f, 0f, 3, 600, false);
this.worldObj.spawnEntityInWorld(hol);
}
/**
* sets this entity's combat AI.
*/
public void setCombatTask()
{
this.tasks.removeTask(this.aiAttackOnCollide);
this.tasks.removeTask(this.aiArrowAttack);
ItemStack itemstack = this.getHeldItem();
this.tasks.addTask(4, this.aiArrowAttack);
}
}

View file

@ -0,0 +1,25 @@
package WayofTime.alchemicalWizardry.common.entity.mob;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.IMob;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
public class EntityWaterElemental extends EntityElemental implements IMob
{
public EntityWaterElemental(World world)
{
super(world, AlchemicalWizardry.entityWaterElementalID);
}
public void inflictEffectOnEntity(Entity target)
{
if (target instanceof EntityLivingBase)
{
((EntityLivingBase) target).addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionDrowning.id, 100, 2));
((EntityLivingBase) target).addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionInhibit.id, 150, 0));
}
}
}

View file

@ -0,0 +1,480 @@
package WayofTime.alchemicalWizardry.common.entity.mob;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.ModItems;
import WayofTime.alchemicalWizardry.common.EntityAITargetAggro;
import WayofTime.alchemicalWizardry.common.entity.projectile.FireProjectile;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import net.minecraft.entity.*;
import net.minecraft.entity.ai.*;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityGhast;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.pathfinding.PathEntity;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
public class EntityWingedFireDemon extends EntityDemon implements IRangedAttackMob
{
private EntityAIArrowAttack aiArrowAttack = new EntityAIArrowAttack(this, 1.0D, 40, 40, 15.0F);
private EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.2D, false);
private static float maxTamedHealth = 100.0F;
private static float maxUntamedHealth = 200.0F;
public EntityWingedFireDemon(World par1World)
{
super(par1World, AlchemicalWizardry.entityWingedFireDemonID);
this.setSize(0.7F, 1.8F);
this.getNavigator().setAvoidsWater(true);
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(2, this.aiSit);
this.tasks.addTask(3, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F));
this.tasks.addTask(4, new EntityAIWander(this, 1.0D));
this.tasks.addTask(5, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
this.tasks.addTask(6, new EntityAILookIdle(this));
this.targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this));
this.targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this));
this.targetTasks.addTask(3, new EntityAIHurtByTarget(this, true));
this.targetTasks.addTask(4, new EntityAITargetAggro(this, EntityPlayer.class, 0, false));
this.setAggro(false);
this.setTamed(false);
if (par1World != null && !par1World.isRemote)
{
this.setCombatTask();
}
this.isImmuneToFire = true;
}
@Override
protected void applyEntityAttributes()
{
super.applyEntityAttributes();
//This line affects the speed of the monster
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.30000001192092896D);
//My guess is that this will alter the max health
if (this.isTamed())
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxTamedHealth);
} else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxUntamedHealth);
}
//this.func_110148_a(SharedMonsterAttributes.field_111267_a).func_111128_a(10.0D);
}
/**
* Returns true if the newer Entity AI code should be run
*/
public boolean isAIEnabled()
{
return true;
}
/**
* Sets the active target the Task system uses for tracking
*/
public void setAttackTarget(EntityLivingBase par1EntityLivingBase)
{
super.setAttackTarget(par1EntityLivingBase);
if (par1EntityLivingBase == null)
{
this.setAngry(false);
} else if (!this.isTamed())
{
this.setAngry(true);
}
}
/**
* main AI tick function, replaces updateEntityActionState
*/
protected void updateAITick()
{
this.dataWatcher.updateObject(18, Float.valueOf(this.getHealth()));
}
protected void entityInit()
{
super.entityInit();
this.dataWatcher.addObject(18, new Float(this.getHealth()));
this.dataWatcher.addObject(19, new Byte((byte) 0));
}
/**
* Plays step sound at given x, y, z for the entity
*/
protected void playStepSound(int par1, int par2, int par3, int par4)
{
this.playSound("mob.zombie.step", 0.15F, 1.0F);
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
par1NBTTagCompound.setBoolean("Angry", this.isAngry());
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
this.setAngry(par1NBTTagCompound.getBoolean("Angry"));
this.setCombatTask();
}
/**
* Returns the sound this mob makes while it's alive.
*/
protected String getLivingSound()
{
return "mob.blaze.breathe";
}
/**
* Returns the sound this mob makes when it is hurt.
*/
protected String getHurtSound()
{
return "mob.blaze.hit";
}
/**
* Returns the sound this mob makes on death.
*/
protected String getDeathSound()
{
return "mob.blaze.death";
}
/**
* Returns the volume for the sounds this mob makes.
*/
protected float getSoundVolume()
{
return 0.4F;
}
/**
* Returns the item ID for the item the mob drops on death.
*/
protected int getDropItemId()
{
return -1;
}
/**
* Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
* use this to react to sunlight and start to burn.
*/
public void onLivingUpdate()
{
super.onLivingUpdate();
}
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
super.onUpdate();
}
public float getEyeHeight()
{
return this.height * 0.8F;
}
/**
* The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently
* use in wolves.
*/
public int getVerticalFaceSpeed()
{
return this.isSitting() ? 20 : super.getVerticalFaceSpeed();
}
/**
* Called when the entity is attacked.
*/
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
{
if (this.isEntityInvulnerable())
{
return false;
} else
{
Entity entity = par1DamageSource.getEntity();
this.aiSit.setSitting(false);
if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow))
{
par2 = (par2 + 1.0F) / 2.0F;
}
return super.attackEntityFrom(par1DamageSource, par2);
}
}
public boolean attackEntityAsMob(Entity par1Entity)
{
int i = this.isTamed() ? 4 : 2;
return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i);
}
public void setTamed(boolean par1)
{
super.setTamed(par1);
if (par1)
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxTamedHealth);
} else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.maxUntamedHealth);
}
}
/**
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
*/
@Override
public boolean interact(EntityPlayer par1EntityPlayer)
{
ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
if (this.isTamed())
{
if (itemstack != null)
{
if (itemstack.getItem() instanceof ItemFood)
{
ItemFood itemfood = (ItemFood) itemstack.getItem();
if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < this.maxTamedHealth)
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
this.heal((float) itemfood.func_150905_g(itemstack));
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack) null);
}
return true;
}
}
}
if (this.getOwner() instanceof EntityPlayer && SpellHelper.getUsername(par1EntityPlayer).equalsIgnoreCase(SpellHelper.getUsername((EntityPlayer) this.getOwner())) && !this.isBreedingItem(itemstack))
{
if (!this.worldObj.isRemote)
{
this.aiSit.setSitting(!this.isSitting());
this.isJumping = false;
this.setPathToEntity((PathEntity) null);
this.setTarget((Entity) null);
this.setAttackTarget((EntityLivingBase) null);
}
this.sendSittingMessageToPlayer(par1EntityPlayer, !this.isSitting());
}
} else if (itemstack != null && itemstack.getItem().equals(ModItems.weakBloodOrb) && !this.isAngry())
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack) null);
}
if (!this.worldObj.isRemote)
{
if (this.rand.nextInt(1) == 0)
{
this.setTamed(true);
this.setPathToEntity((PathEntity) null);
this.setAttackTarget((EntityLivingBase) null);
this.aiSit.setSitting(true);
this.setHealth(this.maxTamedHealth);
this.func_152115_b(par1EntityPlayer.getUniqueID().toString());
this.playTameEffect(true);
this.worldObj.setEntityState(this, (byte) 7);
} else
{
this.playTameEffect(false);
this.worldObj.setEntityState(this, (byte) 6);
}
}
return true;
}
return super.interact(par1EntityPlayer);
}
/**
* Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on
* the animal type)
*/
public boolean isBreedingItem(ItemStack par1ItemStack)
{
return false;
}
/**
* Determines whether this wolf is angry or not.
*/
public boolean isAngry()
{
return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0;
}
/**
* Sets whether this wolf is angry or not.
*/
public void setAngry(boolean par1)
{
byte b0 = this.dataWatcher.getWatchableObjectByte(16);
if (par1)
{
this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 | 2)));
} else
{
this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 & -3)));
}
}
/**
* Return this wolf's collar color.
*/
public int getCollarColor()
{
return this.dataWatcher.getWatchableObjectByte(20) & 15;
}
/**
* Set this wolf's collar color.
*/
public void setCollarColor(int par1)
{
this.dataWatcher.updateObject(20, Byte.valueOf((byte) (par1 & 15)));
}
/**
* This function is used when two same-species animals in 'love mode' breed to generate the new baby animal.
*/
public EntityWolf spawnBabyAnimal(EntityAgeable par1EntityAgeable)
{
return null;
}
public void func_70918_i(boolean par1)
{
if (par1)
{
this.dataWatcher.updateObject(19, Byte.valueOf((byte) 1));
} else
{
this.dataWatcher.updateObject(19, Byte.valueOf((byte) 0));
}
}
/**
* Returns true if the mob is currently able to mate with the specified mob.
*/
public boolean canMateWith(EntityAnimal par1EntityAnimal)
{
return false;
}
public boolean func_70922_bv()
{
return this.dataWatcher.getWatchableObjectByte(19) == 1;
}
/**
* Determines if an entity can be despawned, used on idle far away entities
*/
protected boolean canDespawn()
{
return false;
}
public boolean func_142018_a(EntityLivingBase par1EntityLivingBase, EntityLivingBase par2EntityLivingBase)
{
if (!(par1EntityLivingBase instanceof EntityCreeper) && !(par1EntityLivingBase instanceof EntityGhast))
{
if (par1EntityLivingBase instanceof EntityWingedFireDemon)
{
EntityWingedFireDemon entitywolf = (EntityWingedFireDemon) par1EntityLivingBase;
if (entitywolf.isTamed() && entitywolf.getOwner() == par2EntityLivingBase)
{
return false;
}
}
return par1EntityLivingBase instanceof EntityPlayer && par2EntityLivingBase instanceof EntityPlayer && !((EntityPlayer) par2EntityLivingBase).canAttackPlayer((EntityPlayer) par1EntityLivingBase) ? false : !(par1EntityLivingBase instanceof EntityHorse) || !((EntityHorse) par1EntityLivingBase).isTame();
} else
{
return false;
}
}
public EntityAgeable createChild(EntityAgeable par1EntityAgeable)
{
return this.spawnBabyAnimal(par1EntityAgeable);
}
/**
* Attack the specified entity using a ranged attack.
*/
public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2)
{
double xCoord;
double yCoord;
double zCoord;
this.worldObj.playAuxSFXAtEntity((EntityPlayer) null, 1009, (int) this.posX, (int) this.posY, (int) this.posZ, 0);
FireProjectile hol = new FireProjectile(worldObj, this, par1EntityLivingBase, 1.8f, 0f, 20, 600);
this.worldObj.spawnEntityInWorld(hol);
}
/**
* sets this entity's combat AI.
*/
public void setCombatTask()
{
this.tasks.removeTask(this.aiAttackOnCollide);
this.tasks.removeTask(this.aiArrowAttack);
ItemStack itemstack = this.getHeldItem();
this.tasks.addTask(4, this.aiArrowAttack);
}
}

View file

@ -0,0 +1,516 @@
package WayofTime.alchemicalWizardry.common.entity.projectile;
import cpw.mods.fml.common.registry.IThrowableEntity;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IProjectile;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.*;
import net.minecraft.world.World;
import java.util.Iterator;
import java.util.List;
//Shamelessly ripped off from x3n0ph0b3
public class EnergyBlastProjectile extends Entity implements IProjectile, IThrowableEntity
{
protected int xTile = -1;
protected int yTile = -1;
protected int zTile = -1;
protected int inTile = 0;
protected int inData = 0;
protected boolean inGround = false;
/**
* The owner of this arrow.
*/
public EntityLivingBase shootingEntity;
protected int ticksInAir = 0;
protected int maxTicksInAir = 600;
private int ricochetCounter = 0;
private boolean scheduledForDeath = false;
protected int projectileDamage;
public EnergyBlastProjectile(World par1World)
{
super(par1World);
this.setSize(0.5F, 0.5F);
this.maxTicksInAir = 600;
}
public EnergyBlastProjectile(World par1World, double par2, double par4, double par6)
{
super(par1World);
this.setSize(0.5F, 0.5F);
this.setPosition(par2, par4, par6);
yOffset = 0.0F;
this.maxTicksInAir = 600;
}
public EnergyBlastProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage)
{
super(par1World);
shootingEntity = par2EntityPlayer;
float par3 = 0.8F;
this.setSize(0.5F, 0.5F);
this.setLocationAndAngles(par2EntityPlayer.posX, par2EntityPlayer.posY + par2EntityPlayer.getEyeHeight(), par2EntityPlayer.posZ, par2EntityPlayer.rotationYaw, par2EntityPlayer.rotationPitch);
posX -= MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * 0.16F;
posY -= 0.2D;
posZ -= MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) * 0.16F;
this.setPosition(posX, posY, posZ);
yOffset = 0.0F;
motionX = -MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI);
motionZ = MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI);
motionY = -MathHelper.sin(rotationPitch / 180.0F * (float) Math.PI);
this.setThrowableHeading(motionX, motionY, motionZ, par3 * 1.5F, 1.0F);
this.projectileDamage = damage;
this.maxTicksInAir = 600;
}
public EnergyBlastProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage, int maxTicksInAir, double posX, double posY, double posZ, float rotationYaw, float rotationPitch)
{
super(par1World);
shootingEntity = par2EntityPlayer;
float par3 = 0.8F;
this.setSize(0.5F, 0.5F);
this.setLocationAndAngles(posX, posY, posZ, rotationYaw, rotationPitch);
posX -= MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * 0.16F;
posY -= 0.2D;
posZ -= MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) * 0.16F;
this.setPosition(posX, posY, posZ);
yOffset = 0.0F;
motionX = -MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI);
motionZ = MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI);
motionY = -MathHelper.sin(rotationPitch / 180.0F * (float) Math.PI);
this.setThrowableHeading(motionX, motionY, motionZ, par3 * 1.5F, 1.0F);
this.projectileDamage = damage;
this.maxTicksInAir = maxTicksInAir;
}
public EnergyBlastProjectile(World par1World, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase, float par4, float par5, int damage, int maxTicksInAir)
{
super(par1World);
this.renderDistanceWeight = 10.0D;
this.shootingEntity = par2EntityLivingBase;
this.posY = par2EntityLivingBase.posY + (double) par2EntityLivingBase.getEyeHeight() - 0.10000000149011612D;
double d0 = par3EntityLivingBase.posX - par2EntityLivingBase.posX;
double d1 = par3EntityLivingBase.boundingBox.minY + (double) (par3EntityLivingBase.height / 1.5F) - this.posY;
double d2 = par3EntityLivingBase.posZ - par2EntityLivingBase.posZ;
double d3 = (double) MathHelper.sqrt_double(d0 * d0 + d2 * d2);
if (d3 >= 1.0E-7D)
{
float f2 = (float) (Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F;
float f3 = (float) (-(Math.atan2(d1, d3) * 180.0D / Math.PI));
double d4 = d0 / d3;
double d5 = d2 / d3;
this.setLocationAndAngles(par2EntityLivingBase.posX + d4, this.posY, par2EntityLivingBase.posZ + d5, f2, f3);
this.yOffset = 0.0F;
float f4 = (float) d3 * 0.2F;
this.setThrowableHeading(d0, d1, d2, par4, par5);
}
this.projectileDamage = damage;
this.maxTicksInAir = maxTicksInAir;
}
@Override
protected void entityInit()
{
dataWatcher.addObject(16, Byte.valueOf((byte) 0));
}
/**
* Similar to setArrowHeading, it's point the throwable entity to a x, y, z
* direction.
*/
@Override
public void setThrowableHeading(double var1, double var3, double var5, float var7, float var8)
{
float var9 = MathHelper.sqrt_double(var1 * var1 + var3 * var3 + var5 * var5);
var1 /= var9;
var3 /= var9;
var5 /= var9;
var1 += rand.nextGaussian() * 0.007499999832361937D * var8;
var3 += rand.nextGaussian() * 0.007499999832361937D * var8;
var5 += rand.nextGaussian() * 0.007499999832361937D * var8;
var1 *= var7;
var3 *= var7;
var5 *= var7;
motionX = var1;
motionY = var3;
motionZ = var5;
float var10 = MathHelper.sqrt_double(var1 * var1 + var5 * var5);
prevRotationYaw = rotationYaw = (float) (Math.atan2(var1, var5) * 180.0D / Math.PI);
prevRotationPitch = rotationPitch = (float) (Math.atan2(var3, var10) * 180.0D / Math.PI);
}
@Override
@SideOnly(Side.CLIENT)
/**
* Sets the position and rotation. Only difference from the other one is no bounding on the rotation. Args: posX,
* posY, posZ, yaw, pitch
*/
public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9)
{
this.setPosition(par1, par3, par5);
this.setRotation(par7, par8);
}
@Override
@SideOnly(Side.CLIENT)
/**
* Sets the velocity to the args. Args: x, y, z
*/
public void setVelocity(double par1, double par3, double par5)
{
motionX = par1;
motionY = par3;
motionZ = par5;
if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F)
{
float var7 = MathHelper.sqrt_double(par1 * par1 + par5 * par5);
prevRotationYaw = rotationYaw = (float) (Math.atan2(par1, par5) * 180.0D / Math.PI);
prevRotationPitch = rotationPitch = (float) (Math.atan2(par3, var7) * 180.0D / Math.PI);
prevRotationPitch = rotationPitch;
prevRotationYaw = rotationYaw;
this.setLocationAndAngles(posX, posY, posZ, rotationYaw, rotationPitch);
}
}
/**
* Called to update the entity's position/logic.
*/
@Override
public void onUpdate()
{
super.onUpdate();
if (ticksInAir > maxTicksInAir)
{
this.setDead();
}
if (shootingEntity == null)
{
List players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(posX - 1, posY - 1, posZ - 1, posX + 1, posY + 1, posZ + 1));
Iterator i = players.iterator();
double closestDistance = Double.MAX_VALUE;
EntityPlayer closestPlayer = null;
while (i.hasNext())
{
EntityPlayer e = (EntityPlayer) i.next();
double distance = e.getDistanceToEntity(this);
if (distance < closestDistance)
{
closestPlayer = e;
}
}
if (closestPlayer != null)
{
shootingEntity = closestPlayer;
}
}
if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F)
{
float var1 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
prevRotationYaw = rotationYaw = (float) (Math.atan2(motionX, motionZ) * 180.0D / Math.PI);
prevRotationPitch = rotationPitch = (float) (Math.atan2(motionY, var1) * 180.0D / Math.PI);
}
Block var16 = worldObj.getBlock(xTile, yTile, zTile);
if (var16 != null)
{
var16.setBlockBoundsBasedOnState(worldObj, xTile, yTile, zTile);
AxisAlignedBB var2 = var16.getCollisionBoundingBoxFromPool(worldObj, xTile, yTile, zTile);
if (var2 != null && var2.isVecInside(Vec3.createVectorHelper(posX, posY, posZ)))
{
inGround = true;
}
}
if (inGround)
{
Block var18 = worldObj.getBlock(xTile, yTile, zTile);
int var19 = worldObj.getBlockMetadata(xTile, yTile, zTile);
if (var18.equals(Block.getBlockById(inTile)) && var19 == inData)
{
}
} else
{
++ticksInAir;
if (ticksInAir > 1 && ticksInAir < 3)
{
for (int particles = 0; particles < 3; particles++)
{
this.doFiringParticles();
}
}
Vec3 var17 = Vec3.createVectorHelper(posX, posY, posZ);
Vec3 var3 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
MovingObjectPosition var4 = worldObj.func_147447_a(var17, var3, true, false, false);
var17 = Vec3.createVectorHelper(posX, posY, posZ);
var3 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
if (var4 != null)
{
var3 = Vec3.createVectorHelper(var4.hitVec.xCoord, var4.hitVec.yCoord, var4.hitVec.zCoord);
}
Entity var5 = null;
List var6 = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D));
double var7 = 0.0D;
Iterator var9 = var6.iterator();
float var11;
while (var9.hasNext())
{
Entity var10 = (Entity) var9.next();
if (var10.canBeCollidedWith() && (var10 != shootingEntity || ticksInAir >= 5))
{
var11 = 0.3F;
AxisAlignedBB var12 = var10.boundingBox.expand(var11, var11, var11);
MovingObjectPosition var13 = var12.calculateIntercept(var17, var3);
if (var13 != null)
{
double var14 = var17.distanceTo(var13.hitVec);
if (var14 < var7 || var7 == 0.0D)
{
var5 = var10;
var7 = var14;
}
}
}
}
if (var5 != null)
{
var4 = new MovingObjectPosition(var5);
}
if (var4 != null)
{
this.onImpact(var4);
if (scheduledForDeath)
{
this.setDead();
}
}
posX += motionX;
posY += motionY;
posZ += motionZ;
MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
this.setPosition(posX, posY, posZ);
}
}
public void doFiringParticles()
{
worldObj.spawnParticle("mobSpellAmbient", posX + smallGauss(0.1D), posY + smallGauss(0.1D), posZ + smallGauss(0.1D), 0.5D, 0.5D, 0.5D);
worldObj.spawnParticle("flame", posX, posY, posZ, gaussian(motionX), gaussian(motionY), gaussian(motionZ));
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
@Override
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
par1NBTTagCompound.setShort("xTile", (short) xTile);
par1NBTTagCompound.setShort("yTile", (short) yTile);
par1NBTTagCompound.setShort("zTile", (short) zTile);
par1NBTTagCompound.setByte("inTile", (byte) inTile);
par1NBTTagCompound.setByte("inData", (byte) inData);
par1NBTTagCompound.setByte("inGround", (byte) (inGround ? 1 : 0));
par1NBTTagCompound.setInteger("ticksInAir", ticksInAir);
par1NBTTagCompound.setInteger("maxTicksInAir", maxTicksInAir);
par1NBTTagCompound.setInteger("projectileDamage", this.projectileDamage);
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
@Override
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
xTile = par1NBTTagCompound.getShort("xTile");
yTile = par1NBTTagCompound.getShort("yTile");
zTile = par1NBTTagCompound.getShort("zTile");
inTile = par1NBTTagCompound.getByte("inTile") & 255;
inData = par1NBTTagCompound.getByte("inData") & 255;
inGround = par1NBTTagCompound.getByte("inGround") == 1;
ticksInAir = par1NBTTagCompound.getInteger("ticksInAir");
maxTicksInAir = par1NBTTagCompound.getInteger("maxTicksInAir");
projectileDamage = par1NBTTagCompound.getInteger("projectileDamage");
}
/**
* returns if this entity triggers Block.onEntityWalking on the blocks they
* walk on. used for spiders and wolves to prevent them from trampling crops
*/
@Override
protected boolean canTriggerWalking()
{
return false;
}
@Override
@SideOnly(Side.CLIENT)
public float getShadowSize()
{
return 0.0F;
}
/**
* Sets the amount of knockback the arrow applies when it hits a mob.
*/
public void setKnockbackStrength(int par1)
{
}
/**
* If returns false, the item will not inflict any damage against entities.
*/
@Override
public boolean canAttackWithItem()
{
return false;
}
/**
* Whether the arrow has a stream of critical hit particles flying behind
* it.
*/
public void setIsCritical(boolean par1)
{
byte var2 = dataWatcher.getWatchableObjectByte(16);
if (par1)
{
dataWatcher.updateObject(16, Byte.valueOf((byte) (var2 | 1)));
} else
{
dataWatcher.updateObject(16, Byte.valueOf((byte) (var2 & -2)));
}
}
/**
* Whether the arrow has a stream of critical hit particles flying behind
* it.
*/
public boolean getIsCritical()
{
byte var1 = dataWatcher.getWatchableObjectByte(16);
return (var1 & 1) != 0;
}
public void onImpact(MovingObjectPosition mop)
{
if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY && mop.entityHit != null)
{
if (mop.entityHit == shootingEntity)
{
return;
}
this.onImpact(mop.entityHit);
} else if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
{
worldObj.createExplosion(shootingEntity, this.posX, this.posY, this.posZ, (float) (0.1), true);
this.setDead();
}
}
public void onImpact(Entity mop)
{
if (mop == shootingEntity && ticksInAir > 3)
{
shootingEntity.attackEntityFrom(DamageSource.causeMobDamage(shootingEntity), 1);
this.setDead();
} else
{
if (mop instanceof EntityLivingBase)
{
((EntityLivingBase) mop).addPotionEffect(new PotionEffect(Potion.weakness.id, 60, 2));
}
doDamage(projectileDamage, mop);
worldObj.createExplosion(shootingEntity, this.posX, this.posY, this.posZ, (float) (0.1), true);
}
spawnHitParticles("magicCrit", 8);
this.setDead();
}
private int d6()
{
return rand.nextInt(6) + 1;
}
protected void spawnHitParticles(String string, int i)
{
for (int particles = 0; particles < i; particles++)
{
worldObj.spawnParticle(string, posX, posY - (string == "portal" ? 1 : 0), posZ, gaussian(motionX), gaussian(motionY), gaussian(motionZ));
}
}
protected void doDamage(int i, Entity mop)
{
mop.attackEntityFrom(this.getDamageSource(), i);
}
public DamageSource getDamageSource()
{
return DamageSource.causeMobDamage(shootingEntity);
}
public double smallGauss(double d)
{
return (worldObj.rand.nextFloat() - 0.5D) * d;
}
public double gaussian(double d)
{
return d + d * ((rand.nextFloat() - 0.5D) / 4);
}
private int getRicochetMax()
{
return 0;
}
@Override
public Entity getThrower()
{
// TODO Auto-generated method stub
return this.shootingEntity;
}
@Override
public void setThrower(Entity entity)
{
if (entity instanceof EntityLivingBase)
this.shootingEntity = (EntityLivingBase) entity;
}
}

View file

@ -0,0 +1,16 @@
package WayofTime.alchemicalWizardry.common.entity.projectile;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.world.World;
public class EntityBeamParticle extends EntityFX
{
protected EntityBeamParticle(World p_i1218_1_, double p_i1218_2_,
double p_i1218_4_, double p_i1218_6_)
{
super(p_i1218_1_, p_i1218_2_, p_i1218_4_, p_i1218_6_);
// TODO Auto-generated constructor stub
}
}

View file

@ -0,0 +1,121 @@
package WayofTime.alchemicalWizardry.common.entity.projectile;
import WayofTime.alchemicalWizardry.ModBlocks;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Blocks;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
public class EntityBloodLightProjectile extends EnergyBlastProjectile
{
public EntityBloodLightProjectile(World par1World)
{
super(par1World);
}
public EntityBloodLightProjectile(World par1World, double par2, double par4, double par6)
{
super(par1World, par2, par4, par6);
}
public EntityBloodLightProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage)
{
super(par1World, par2EntityPlayer, damage);
}
public EntityBloodLightProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage, int maxTicksInAir, double posX, double posY, double posZ, float rotationYaw, float rotationPitch)
{
super(par1World, par2EntityPlayer, damage, maxTicksInAir, posX, posY, posZ, rotationYaw, rotationPitch);
}
public EntityBloodLightProjectile(World par1World, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase, float par4, float par5, int damage, int maxTicksInAir)
{
super(par1World, par2EntityLivingBase, par3EntityLivingBase, par4, par5, damage, maxTicksInAir);
}
@Override
public DamageSource getDamageSource()
{
return DamageSource.causeMobDamage(shootingEntity);
}
@Override
public void onImpact(MovingObjectPosition mop)
{
if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY && mop.entityHit != null)
{
if (mop.entityHit == shootingEntity)
{
return;
}
this.onImpact(mop.entityHit);
} else if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
{
int sideHit = mop.sideHit;
int blockX = mop.blockX;
int blockY = mop.blockY;
int blockZ = mop.blockZ;
if (sideHit == 0 && this.worldObj.isAirBlock(blockX, blockY - 1, blockZ))
{
this.worldObj.setBlock(blockX, blockY - 1, blockZ, ModBlocks.blockBloodLight);
}
if (sideHit == 1 && this.worldObj.isAirBlock(blockX, blockY + 1, blockZ))
{
this.worldObj.setBlock(blockX, blockY + 1, blockZ, ModBlocks.blockBloodLight);
}
if (sideHit == 2 && this.worldObj.isAirBlock(blockX, blockY, blockZ - 1))
{
this.worldObj.setBlock(blockX, blockY, blockZ - 1, ModBlocks.blockBloodLight);
}
if (sideHit == 3 && this.worldObj.isAirBlock(blockX, blockY, blockZ + 1))
{
this.worldObj.setBlock(blockX, blockY, blockZ + 1, ModBlocks.blockBloodLight);
}
if (sideHit == 4 && this.worldObj.isAirBlock(blockX - 1, blockY, blockZ))
{
this.worldObj.setBlock(blockX - 1, blockY, blockZ, ModBlocks.blockBloodLight);
}
if (sideHit == 5 && this.worldObj.isAirBlock(blockX + 1, blockY, blockZ))
{
this.worldObj.setBlock(blockX + 1, blockY, blockZ, ModBlocks.blockBloodLight);
}
}
this.setDead();
}
@Override
public void onImpact(Entity mop)
{
if (mop == shootingEntity && ticksInAir > 3)
{
shootingEntity.attackEntityFrom(DamageSource.causeMobDamage(shootingEntity), 1);
this.setDead();
} else
{
if (mop instanceof EntityLivingBase)
{
((EntityLivingBase) mop).setRevengeTarget(shootingEntity);
doDamage(1, mop);
}
}
if (worldObj.isAirBlock((int) this.posX, (int) this.posY, (int) this.posZ))
{
worldObj.setBlock((int) this.posX, (int) this.posY, (int) this.posZ, Blocks.fire);
}
spawnHitParticles("magicCrit", 8);
this.setDead();
}
}

View file

@ -0,0 +1,99 @@
package WayofTime.alchemicalWizardry.common.entity.projectile;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
public class EntityEnergyBazookaMainProjectile extends EnergyBlastProjectile
{
public EntityEnergyBazookaMainProjectile(World par1World)
{
super(par1World);
}
public EntityEnergyBazookaMainProjectile(World par1World, double par2, double par4, double par6)
{
super(par1World, par2, par4, par6);
}
public EntityEnergyBazookaMainProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage)
{
super(par1World, par2EntityPlayer, damage);
}
public EntityEnergyBazookaMainProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage, int maxTicksInAir, double posX, double posY, double posZ, float rotationYaw, float rotationPitch)
{
super(par1World, par2EntityPlayer, damage, maxTicksInAir, posX, posY, posZ, rotationYaw, rotationPitch);
}
public EntityEnergyBazookaMainProjectile(World par1World, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase, float par4, float par5, int damage, int maxTicksInAir)
{
super(par1World, par2EntityLivingBase, par3EntityLivingBase, par4, par5, damage, maxTicksInAir);
}
@Override
public DamageSource getDamageSource()
{
return DamageSource.causeMobDamage(shootingEntity);
}
@Override
public void onImpact(MovingObjectPosition mop)
{
if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY && mop.entityHit != null)
{
if (mop.entityHit == shootingEntity)
{
return;
}
this.onImpact(mop.entityHit);
} else if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
{
worldObj.createExplosion(this.shootingEntity, this.posX, this.posY, this.posZ, (float) (5.0f), false);
this.spawnSecondaryProjectiles();
}
this.setDead();
}
@Override
public void onImpact(Entity mop)
{
if (mop == shootingEntity && ticksInAir > 3)
{
shootingEntity.attackEntityFrom(DamageSource.causeMobDamage(shootingEntity), 1);
this.setDead();
} else
{
if (mop instanceof EntityLivingBase)
{
spawnSecondaryProjectiles();
}
worldObj.createExplosion(this.shootingEntity, this.posX, this.posY, this.posZ, (float) (5.0f), false);
}
spawnHitParticles("magicCrit", 8);
this.setDead();
}
public void spawnSecondaryProjectiles()
{
for (int i = 0; i < 20; i++)
{
EntityEnergyBazookaSecondaryProjectile secProj = new EntityEnergyBazookaSecondaryProjectile(worldObj, this.posX, this.posY, this.posZ, 15);
secProj.shootingEntity = this.shootingEntity;
float xVel = rand.nextFloat() - rand.nextFloat();
float yVel = rand.nextFloat() - rand.nextFloat();
float zVel = rand.nextFloat() - rand.nextFloat();
float wantedVel = 0.5f;
secProj.motionX = xVel * wantedVel;
secProj.motionY = yVel * wantedVel;
secProj.motionZ = zVel * wantedVel;
worldObj.spawnEntityInWorld(secProj);
}
}
}

View file

@ -0,0 +1,504 @@
package WayofTime.alchemicalWizardry.common.entity.projectile;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IProjectile;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.*;
import net.minecraft.world.World;
import java.util.Iterator;
import java.util.List;
public class EntityEnergyBazookaSecondaryProjectile extends EnergyBlastProjectile implements IProjectile
{
private int xTile = -1;
private int yTile = -1;
private int zTile = -1;
private int inTile = 0;
private int inData = 0;
private boolean inGround = false;
/**
* The owner of this arrow.
*/
public EntityLivingBase shootingEntity;
private int ticksInAir = 0;
private int ricochetCounter = 0;
private boolean scheduledForDeath = false;
public int damage;
public EntityEnergyBazookaSecondaryProjectile(World par1World)
{
super(par1World);
this.setSize(0.5F, 0.5F);
damage = 5;
}
public EntityEnergyBazookaSecondaryProjectile(World par1World, double par2, double par4, double par6, int damage)
{
super(par1World);
this.setSize(0.5F, 0.5F);
this.setPosition(par2, par4, par6);
yOffset = 0.0F;
this.damage = damage;
}
public EntityEnergyBazookaSecondaryProjectile(World par1World, EntityPlayer par2EntityPlayer, int damage)
{
super(par1World);
shootingEntity = par2EntityPlayer;
float par3 = 0.8F;
this.setSize(0.1F, 0.1F);
this.setLocationAndAngles(par2EntityPlayer.posX, par2EntityPlayer.posY + par2EntityPlayer.getEyeHeight(), par2EntityPlayer.posZ, par2EntityPlayer.rotationYaw, par2EntityPlayer.rotationPitch);
posX -= MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * 0.16F;
posY -= 0.2D;
posZ -= MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) * 0.16F;
this.setPosition(posX, posY, posZ);
yOffset = 0.0F;
motionX = -MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI);
motionZ = MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI);
motionY = -MathHelper.sin(rotationPitch / 180.0F * (float) Math.PI);
this.setThrowableHeading(motionX, motionY, motionZ, par3 * 1.5F, 1.0F);
this.damage = damage;
}
@Override
protected void entityInit()
{
dataWatcher.addObject(16, Byte.valueOf((byte) 0));
}
/**
* Similar to setArrowHeading, it's point the throwable entity to a x, y, z
* direction.
*/
@Override
public void setThrowableHeading(double var1, double var3, double var5, float var7, float var8)
{
float var9 = MathHelper.sqrt_double(var1 * var1 + var3 * var3 + var5 * var5);
var1 /= var9;
var3 /= var9;
var5 /= var9;
var1 += rand.nextGaussian() * 0.007499999832361937D * var8;
var3 += rand.nextGaussian() * 0.007499999832361937D * var8;
var5 += rand.nextGaussian() * 0.007499999832361937D * var8;
var1 *= var7;
var3 *= var7;
var5 *= var7;
motionX = var1;
motionY = var3;
motionZ = var5;
float var10 = MathHelper.sqrt_double(var1 * var1 + var5 * var5);
prevRotationYaw = rotationYaw = (float) (Math.atan2(var1, var5) * 180.0D / Math.PI);
prevRotationPitch = rotationPitch = (float) (Math.atan2(var3, var10) * 180.0D / Math.PI);
}
@Override
@SideOnly(Side.CLIENT)
/**
* Sets the position and rotation. Only difference from the other one is no bounding on the rotation. Args: posX,
* posY, posZ, yaw, pitch
*/
public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9)
{
this.setPosition(par1, par3, par5);
this.setRotation(par7, par8);
}
@Override
@SideOnly(Side.CLIENT)
/**
* Sets the velocity to the args. Args: x, y, z
*/
public void setVelocity(double par1, double par3, double par5)
{
motionX = par1;
motionY = par3;
motionZ = par5;
if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F)
{
float var7 = MathHelper.sqrt_double(par1 * par1 + par5 * par5);
prevRotationYaw = rotationYaw = (float) (Math.atan2(par1, par5) * 180.0D / Math.PI);
prevRotationPitch = rotationPitch = (float) (Math.atan2(par3, var7) * 180.0D / Math.PI);
prevRotationPitch = rotationPitch;
prevRotationYaw = rotationYaw;
this.setLocationAndAngles(posX, posY, posZ, rotationYaw, rotationPitch);
}
}
/**
* Called to update the entity's position/logic.
*/
@Override
public void onUpdate()
{
super.onUpdate();
if (ticksInAir > maxTicksInAir)
{
this.setDead();
}
if (shootingEntity == null)
{
List players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(posX - 1, posY - 1, posZ - 1, posX + 1, posY + 1, posZ + 1));
Iterator i = players.iterator();
double closestDistance = Double.MAX_VALUE;
EntityPlayer closestPlayer = null;
while (i.hasNext())
{
EntityPlayer e = (EntityPlayer) i.next();
double distance = e.getDistanceToEntity(this);
if (distance < closestDistance)
{
closestPlayer = e;
}
}
if (closestPlayer != null)
{
shootingEntity = closestPlayer;
}
}
if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F)
{
float var1 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
prevRotationYaw = rotationYaw = (float) (Math.atan2(motionX, motionZ) * 180.0D / Math.PI);
prevRotationPitch = rotationPitch = (float) (Math.atan2(motionY, var1) * 180.0D / Math.PI);
}
Block var16 = worldObj.getBlock(xTile, yTile, zTile);
if (var16 != null)
{
var16.setBlockBoundsBasedOnState(worldObj, xTile, yTile, zTile);
AxisAlignedBB var2 = var16.getCollisionBoundingBoxFromPool(worldObj, xTile, yTile, zTile);
if (var2 != null && var2.isVecInside(Vec3.createVectorHelper(posX, posY, posZ)))
{
inGround = true;
}
}
if (inGround)
{
Block var18 = worldObj.getBlock(xTile, yTile, zTile);
int var19 = worldObj.getBlockMetadata(xTile, yTile, zTile);
if (var18.equals(Block.getBlockById(inTile)) && var19 == inData)
{
}
} else
{
++ticksInAir;
if (ticksInAir > 1 && ticksInAir < 3)
{
for (int particles = 0; particles < 3; particles++)
{
this.doFiringParticles();
}
}
Vec3 var17 = Vec3.createVectorHelper(posX, posY, posZ);
Vec3 var3 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
MovingObjectPosition var4 = worldObj.func_147447_a(var17, var3, true, false, false);
var17 = Vec3.createVectorHelper(posX, posY, posZ);
var3 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
if (var4 != null)
{
var3 = Vec3.createVectorHelper(var4.hitVec.xCoord, var4.hitVec.yCoord, var4.hitVec.zCoord);
}
Entity var5 = null;
List var6 = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D));
double var7 = 0.0D;
Iterator var9 = var6.iterator();
float var11;
while (var9.hasNext())
{
Entity var10 = (Entity) var9.next();
if (var10.canBeCollidedWith() && (var10 != shootingEntity || ticksInAir >= 5))
{
var11 = 0.3F;
AxisAlignedBB var12 = var10.boundingBox.expand(var11, var11, var11);
MovingObjectPosition var13 = var12.calculateIntercept(var17, var3);
if (var13 != null)
{
double var14 = var17.distanceTo(var13.hitVec);
if (var14 < var7 || var7 == 0.0D)
{
var5 = var10;
var7 = var14;
}
}
}
}
if (var5 != null)
{
var4 = new MovingObjectPosition(var5);
}
if (var4 != null)
{
this.onImpact(var4);
if (scheduledForDeath)
{
this.setDead();
}
}
posX += motionX;
posY += motionY;
posZ += motionZ;
MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
this.setPosition(posX, posY, posZ);
}
}
public void doFiringParticles()
{
worldObj.spawnParticle("mobSpellAmbient", posX + smallGauss(0.1D), posY + smallGauss(0.1D), posZ + smallGauss(0.1D), 0.5D, 0.5D, 0.5D);
worldObj.spawnParticle("flame", posX, posY, posZ, gaussian(motionX), gaussian(motionY), gaussian(motionZ));
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
@Override
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
par1NBTTagCompound.setShort("xTile", (short) xTile);
par1NBTTagCompound.setShort("yTile", (short) yTile);
par1NBTTagCompound.setShort("zTile", (short) zTile);
par1NBTTagCompound.setByte("inTile", (byte) inTile);
par1NBTTagCompound.setByte("inData", (byte) inData);
par1NBTTagCompound.setByte("inGround", (byte) (inGround ? 1 : 0));
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
@Override
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
xTile = par1NBTTagCompound.getShort("xTile");
yTile = par1NBTTagCompound.getShort("yTile");
zTile = par1NBTTagCompound.getShort("zTile");
inTile = par1NBTTagCompound.getByte("inTile") & 255;
inData = par1NBTTagCompound.getByte("inData") & 255;
inGround = par1NBTTagCompound.getByte("inGround") == 1;
}
/**
* returns if this entity triggers Block.onEntityWalking on the blocks they
* walk on. used for spiders and wolves to prevent them from trampling crops
*/
@Override
protected boolean canTriggerWalking()
{
return false;
}
@Override
@SideOnly(Side.CLIENT)
public float getShadowSize()
{
return 0.0F;
}
/**
* Sets the amount of knockback the arrow applies when it hits a mob.
*/
public void setKnockbackStrength(int par1)
{
}
/**
* If returns false, the item will not inflict any damage against entities.
*/
@Override
public boolean canAttackWithItem()
{
return false;
}
/**
* Whether the arrow has a stream of critical hit particles flying behind
* it.
*/
public void setIsCritical(boolean par1)
{
byte var2 = dataWatcher.getWatchableObjectByte(16);
if (par1)
{
dataWatcher.updateObject(16, Byte.valueOf((byte) (var2 | 1)));
} else
{
dataWatcher.updateObject(16, Byte.valueOf((byte) (var2 & -2)));
}
}
/**
* Whether the arrow has a stream of critical hit particles flying behind
* it.
*/
public boolean getIsCritical()
{
byte var1 = dataWatcher.getWatchableObjectByte(16);
return (var1 & 1) != 0;
}
public void onImpact(MovingObjectPosition mop)
{
if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY && mop.entityHit != null)
{
if (mop.entityHit == shootingEntity)
{
return;
}
this.onImpact(mop.entityHit);
} else if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
{
this.groundImpact(mop.sideHit);
worldObj.createExplosion(shootingEntity, posX, posY, posZ, 2, false);
}
}
public void onImpact(Entity mop)
{
if (mop == shootingEntity && ticksInAir > 3)
{
shootingEntity.attackEntityFrom(DamageSource.causeMobDamage(shootingEntity), 1);
this.setDead();
} else
{
doDamage(this.damage + d6(), mop);
worldObj.createExplosion(shootingEntity, posX, posY, posZ, 2, false);
}
spawnHitParticles("magicCrit", 8);
this.setDead();
}
private int d6()
{
return rand.nextInt(6) + 1;
}
public void spawnHitParticles(String string, int i)
{
for (int particles = 0; particles < i; particles++)
{
worldObj.spawnParticle(string, posX, posY - (string == "portal" ? 1 : 0), posZ, gaussian(motionX), gaussian(motionY), gaussian(motionZ));
}
}
public void doDamage(int i, Entity mop)
{
mop.attackEntityFrom(this.getDamageSource(), i);
}
public DamageSource getDamageSource()
{
return DamageSource.causeMobDamage(shootingEntity);
}
public void groundImpact(int sideHit)
{
this.ricochet(sideHit);
}
public double smallGauss(double d)
{
return (worldObj.rand.nextFloat() - 0.5D) * d;
}
public double gaussian(double d)
{
return d + d * ((rand.nextFloat() - 0.5D) / 4);
}
private void ricochet(int sideHit)
{
switch (sideHit)
{
case 0:
case 1:
// topHit, bottomHit, reflect Y
motionY = motionY * -1;
break;
case 2:
case 3:
// westHit, eastHit, reflect Z
motionZ = motionZ * -1;
break;
case 4:
case 5:
// southHit, northHit, reflect X
motionX = motionX * -1;
break;
}
ricochetCounter++;
if (ricochetCounter > this.getRicochetMax())
{
scheduledForDeath = true;
for (int particles = 0; particles < 4; particles++)
{
switch (sideHit)
{
case 0:
worldObj.spawnParticle("smoke", posX, posY, posZ, gaussian(0.1D), -gaussian(0.1D), gaussian(0.1D));
break;
case 1:
worldObj.spawnParticle("smoke", posX, posY, posZ, gaussian(0.1D), gaussian(0.1D), gaussian(0.1D));
break;
case 2:
worldObj.spawnParticle("smoke", posX, posY, posZ, gaussian(0.1D), gaussian(0.1D), -gaussian(0.1D));
break;
case 3:
worldObj.spawnParticle("smoke", posX, posY, posZ, gaussian(0.1D), gaussian(0.1D), gaussian(0.1D));
break;
case 4:
worldObj.spawnParticle("smoke", posX, posY, posZ, -gaussian(0.1D), gaussian(0.1D), gaussian(0.1D));
break;
case 5:
worldObj.spawnParticle("smoke", posX, posY, posZ, gaussian(0.1D), gaussian(0.1D), gaussian(0.1D));
break;
}
}
}
}
private int getRicochetMax()
{
return 3;
}
}

View file

@ -0,0 +1,90 @@
package WayofTime.alchemicalWizardry.common.entity.projectile;
import WayofTime.alchemicalWizardry.common.summoning.meteor.MeteorRegistry;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
public class EntityMeteor extends EnergyBlastProjectile
{
private int meteorID;
public boolean hasTerrae;
public boolean hasOrbisTerrae;
public boolean hasCrystallos;
public boolean hasIncendium;
public boolean hasTennebrae;
public EntityMeteor(World par1World)
{
super(par1World);
this.meteorID = 0;
}
public EntityMeteor(World par1World, double par2, double par4, double par6, int meteorID)
{
super(par1World, par2, par4, par6);
this.meteorID = meteorID;
}
@Override
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
par1NBTTagCompound.setInteger("meteorID", meteorID);
par1NBTTagCompound.setBoolean("hasTerrae", hasTerrae);
par1NBTTagCompound.setBoolean("hasOrbisTerrae", hasOrbisTerrae);
par1NBTTagCompound.setBoolean("hasCrystallos", hasCrystallos);
par1NBTTagCompound.setBoolean("hasIncendium", hasIncendium);
par1NBTTagCompound.setBoolean("hasTennebrae", hasTennebrae);
}
@Override
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
meteorID = par1NBTTagCompound.getInteger("meteorID");
hasTerrae = par1NBTTagCompound.getBoolean("hasTerrae");
hasOrbisTerrae = par1NBTTagCompound.getBoolean("hasOrbisTerrae");
hasIncendium = par1NBTTagCompound.getBoolean("hasIncendium");
hasCrystallos = par1NBTTagCompound.getBoolean("hasCrystallos");
hasTennebrae = par1NBTTagCompound.getBoolean("hasTennebrae");
}
@Override
public DamageSource getDamageSource()
{
return DamageSource.fallingBlock;
}
@Override
public void onImpact(MovingObjectPosition mop)
{
if (worldObj.isRemote)
{
return;
}
if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY && mop.entityHit != null)
{
this.onImpact(mop.entityHit);
} else if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
{
MeteorRegistry.createMeteorImpact(worldObj, mop.blockX, mop.blockY, mop.blockZ, this.meteorID, new boolean[]{hasTerrae, hasOrbisTerrae, hasCrystallos, hasIncendium, hasTennebrae});
}
this.setDead();
}
@Override
public void onImpact(Entity mop)
{
MeteorRegistry.createMeteorImpact(worldObj, (int) this.posX, (int) this.posY, (int) this.posZ, meteorID, new boolean[]{hasTerrae, hasOrbisTerrae, hasCrystallos, hasIncendium, hasTennebrae});
this.setDead();
}
}

View file

@ -0,0 +1,348 @@
package WayofTime.alchemicalWizardry.common.entity.projectile;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.registry.IThrowableEntity;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.particle.EntityCloudFX;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IProjectile;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
//Shamelessly ripped off from x3n0ph0b3
public class EntityParticleBeam extends Entity implements IProjectile, IThrowableEntity
{
protected int xTile = -1;
protected int yTile = -1;
protected int zTile = -1;
protected int inTile = 0;
protected int inData = 0;
protected float colourRed = 0f;
protected float colourGreen = 0f;
protected float colourBlue = 0f;
protected int xDest = 0;
protected int yDest = 0;
protected int zDest = 0;
protected boolean inGround = false;
/**
* The owner of this arrow.
*/
public EntityLivingBase shootingEntity;
protected int ticksInAir = 0;
protected int maxTicksInAir = 600;
private int ricochetCounter = 0;
private boolean scheduledForDeath = false;
protected int projectileDamage;
public EntityParticleBeam(World par1World)
{
super(par1World);
this.setSize(0.5F, 0.5F);
this.maxTicksInAir = 600;
}
public EntityParticleBeam(World par1World, double par2, double par4, double par6)
{
super(par1World);
this.setSize(0.5F, 0.5F);
this.setPosition(par2, par4, par6);
yOffset = 0.0F;
this.maxTicksInAir = 600;
}
public EntityParticleBeam(World par1World, EntityLivingBase par2EntityPlayer, int damage)
{
super(par1World);
shootingEntity = par2EntityPlayer;
float par3 = 0.8F;
this.setSize(0.5F, 0.5F);
this.setLocationAndAngles(par2EntityPlayer.posX, par2EntityPlayer.posY + par2EntityPlayer.getEyeHeight(), par2EntityPlayer.posZ, par2EntityPlayer.rotationYaw, par2EntityPlayer.rotationPitch);
posX -= MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * 0.16F;
posY -= 0.2D;
posZ -= MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) * 0.16F;
this.setPosition(posX, posY, posZ);
yOffset = 0.0F;
motionX = -MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI);
motionZ = MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI);
motionY = -MathHelper.sin(rotationPitch / 180.0F * (float) Math.PI);
this.setThrowableHeading(motionX, motionY, motionZ, par3 * 1.5F, 1.0F);
this.projectileDamage = damage;
this.maxTicksInAir = 600;
}
public EntityParticleBeam(World par1World, EntityLivingBase par2EntityPlayer, int damage, int maxTicksInAir, double posX, double posY, double posZ, float rotationYaw, float rotationPitch)
{
super(par1World);
shootingEntity = par2EntityPlayer;
float par3 = 0.8F;
this.setSize(0.5F, 0.5F);
this.setLocationAndAngles(posX, posY, posZ, rotationYaw, rotationPitch);
posX -= MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * 0.16F;
posY -= 0.2D;
posZ -= MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) * 0.16F;
this.setPosition(posX, posY, posZ);
yOffset = 0.0F;
motionX = -MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI);
motionZ = MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI);
motionY = -MathHelper.sin(rotationPitch / 180.0F * (float) Math.PI);
this.setThrowableHeading(motionX, motionY, motionZ, par3 * 1.5F, 1.0F);
this.projectileDamage = damage;
this.maxTicksInAir = maxTicksInAir;
}
public EntityParticleBeam(World par1World, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase, float par4, float par5, int damage, int maxTicksInAir)
{
super(par1World);
this.renderDistanceWeight = 10.0D;
this.shootingEntity = par2EntityLivingBase;
this.posY = par2EntityLivingBase.posY + (double) par2EntityLivingBase.getEyeHeight() - 0.10000000149011612D;
double d0 = par3EntityLivingBase.posX - par2EntityLivingBase.posX;
double d1 = par3EntityLivingBase.boundingBox.minY + (double) (par3EntityLivingBase.height / 1.5F) - this.posY;
double d2 = par3EntityLivingBase.posZ - par2EntityLivingBase.posZ;
double d3 = (double) MathHelper.sqrt_double(d0 * d0 + d2 * d2);
if (d3 >= 1.0E-7D)
{
float f2 = (float) (Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F;
float f3 = (float) (-(Math.atan2(d1, d3) * 180.0D / Math.PI));
double d4 = d0 / d3;
double d5 = d2 / d3;
this.setLocationAndAngles(par2EntityLivingBase.posX + d4, this.posY, par2EntityLivingBase.posZ + d5, f2, f3);
this.yOffset = 0.0F;
float f4 = (float) d3 * 0.2F;
this.setThrowableHeading(d0, d1, d2, par4, par5);
}
this.projectileDamage = damage;
this.maxTicksInAir = maxTicksInAir;
}
@Override
protected void entityInit()
{
dataWatcher.addObject(16, Byte.valueOf((byte) 0));
}
/**
* Similar to setArrowHeading, it's point the throwable entity to a x, y, z
* direction.
*/
@Override
public void setThrowableHeading(double var1, double var3, double var5, float var7, float var8)
{
float var9 = MathHelper.sqrt_double(var1 * var1 + var3 * var3 + var5 * var5);
var1 /= var9;
var3 /= var9;
var5 /= var9;
var1 += rand.nextGaussian() * 0.007499999832361937D * var8;
var3 += rand.nextGaussian() * 0.007499999832361937D * var8;
var5 += rand.nextGaussian() * 0.007499999832361937D * var8;
var1 *= var7;
var3 *= var7;
var5 *= var7;
motionX = var1;
motionY = var3;
motionZ = var5;
float var10 = MathHelper.sqrt_double(var1 * var1 + var5 * var5);
prevRotationYaw = rotationYaw = (float) (Math.atan2(var1, var5) * 180.0D / Math.PI);
prevRotationPitch = rotationPitch = (float) (Math.atan2(var3, var10) * 180.0D / Math.PI);
}
@Override
@SideOnly(Side.CLIENT)
/**
* Sets the position and rotation. Only difference from the other one is no bounding on the rotation. Args: posX,
* posY, posZ, yaw, pitch
*/
public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9)
{
this.setPosition(par1, par3, par5);
this.setRotation(par7, par8);
}
@Override
@SideOnly(Side.CLIENT)
/**
* Sets the velocity to the args. Args: x, y, z
*/
public void setVelocity(double par1, double par3, double par5)
{
motionX = par1;
motionY = par3;
motionZ = par5;
if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F)
{
float var7 = MathHelper.sqrt_double(par1 * par1 + par5 * par5);
prevRotationYaw = rotationYaw = (float) (Math.atan2(par1, par5) * 180.0D / Math.PI);
prevRotationPitch = rotationPitch = (float) (Math.atan2(par3, var7) * 180.0D / Math.PI);
prevRotationPitch = rotationPitch;
prevRotationYaw = rotationYaw;
this.setLocationAndAngles(posX, posY, posZ, rotationYaw, rotationPitch);
}
}
/**
* Called to update the entity's position/logic.
*/
@Override
public void onUpdate()
{
super.onUpdate();
if (ticksInAir > maxTicksInAir)
{
this.setDead();
}
posX += motionX;
posY += motionY;
posZ += motionZ;
MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
this.setPosition(posX, posY, posZ);
this.doFiringParticles();
if (Math.pow(posX - xDest, 2) + Math.pow(posY - yDest, 2) + Math.pow(posZ - zDest, 2) <= 1)
{
this.scheduledForDeath = true;
}
if (this.scheduledForDeath)
{
this.setDead();
}
}
public void doFiringParticles()
{
if (!worldObj.isRemote)
{
return;
}
EntityFX particle = new EntityCloudFX(worldObj, posX, posY, posZ, 0, 0, 0);
particle.setRBGColorF(colourRed + 0.15f * (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()), colourGreen + 0.15f * (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()), colourBlue + 0.15f * (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()));
FMLClientHandler.instance().getClient().effectRenderer.addEffect(particle);
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
@Override
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
par1NBTTagCompound.setShort("xTile", (short) xTile);
par1NBTTagCompound.setShort("yTile", (short) yTile);
par1NBTTagCompound.setShort("zTile", (short) zTile);
par1NBTTagCompound.setByte("inTile", (byte) inTile);
par1NBTTagCompound.setByte("inData", (byte) inData);
par1NBTTagCompound.setByte("inGround", (byte) (inGround ? 1 : 0));
par1NBTTagCompound.setInteger("ticksInAir", ticksInAir);
par1NBTTagCompound.setInteger("maxTicksInAir", maxTicksInAir);
par1NBTTagCompound.setInteger("projectileDamage", this.projectileDamage);
par1NBTTagCompound.setFloat("colourRed", colourRed);
par1NBTTagCompound.setFloat("colourGreen", colourGreen);
par1NBTTagCompound.setFloat("colourBlue", colourBlue);
par1NBTTagCompound.setInteger("xDest", xDest);
par1NBTTagCompound.setInteger("yDest", yDest);
par1NBTTagCompound.setInteger("zDest", zDest);
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
@Override
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
xTile = par1NBTTagCompound.getShort("xTile");
yTile = par1NBTTagCompound.getShort("yTile");
zTile = par1NBTTagCompound.getShort("zTile");
inTile = par1NBTTagCompound.getByte("inTile") & 255;
inData = par1NBTTagCompound.getByte("inData") & 255;
inGround = par1NBTTagCompound.getByte("inGround") == 1;
ticksInAir = par1NBTTagCompound.getInteger("ticksInAir");
maxTicksInAir = par1NBTTagCompound.getInteger("maxTicksInAir");
projectileDamage = par1NBTTagCompound.getInteger("projectileDamage");
colourRed = par1NBTTagCompound.getFloat("colourRed");
colourGreen = par1NBTTagCompound.getFloat("colourGreen");
colourBlue = par1NBTTagCompound.getFloat("colourBlue");
xDest = par1NBTTagCompound.getInteger("xDest");
yDest = par1NBTTagCompound.getInteger("yDest");
zDest = par1NBTTagCompound.getInteger("zDest");
}
@Override
protected boolean canTriggerWalking()
{
return false;
}
@Override
@SideOnly(Side.CLIENT)
public float getShadowSize()
{
return 0.0F;
}
protected void spawnHitParticles(String string, int i)
{
for (int particles = 0; particles < i; particles++)
{
worldObj.spawnParticle(string, posX, posY - (string == "portal" ? 1 : 0), posZ, gaussian(motionX), gaussian(motionY), gaussian(motionZ));
}
}
public DamageSource getDamageSource()
{
return DamageSource.causeMobDamage(shootingEntity);
}
public double smallGauss(double d)
{
return (worldObj.rand.nextFloat() - 0.5D) * d;
}
public double gaussian(double d)
{
return d + d * ((rand.nextFloat() - 0.5D) / 4);
}
private int getRicochetMax()
{
return 0;
}
@Override
public Entity getThrower()
{
// TODO Auto-generated method stub
return this.shootingEntity;
}
@Override
public void setThrower(Entity entity)
{
if (entity instanceof EntityLivingBase)
this.shootingEntity = (EntityLivingBase) entity;
}
public void setColour(float red, float green, float blue)
{
this.colourRed = red;
this.colourGreen = green;
this.colourBlue = blue;
}
public void setDestination(int xDest, int yDest, int zDest)
{
this.xDest = xDest;
this.yDest = yDest;
this.zDest = zDest;
}
}

View file

@ -0,0 +1,113 @@
package WayofTime.alchemicalWizardry.common.entity.projectile;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
public class ExplosionProjectile extends EnergyBlastProjectile
{
protected boolean causesEnvDamage;
public ExplosionProjectile(World par1World)
{
super(par1World);
}
public ExplosionProjectile(World par1World, double par2, double par4, double par6)
{
super(par1World, par2, par4, par6);
}
public ExplosionProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage, boolean flag)
{
super(par1World, par2EntityPlayer, damage);
causesEnvDamage = flag;
}
public ExplosionProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage, int maxTicksInAir, double posX, double posY, double posZ, float rotationYaw, float rotationPitch, boolean flag)
{
super(par1World, par2EntityPlayer, damage, maxTicksInAir, posX, posY, posZ, rotationYaw, rotationPitch);
causesEnvDamage = flag;
}
@Override
public DamageSource getDamageSource()
{
return DamageSource.causeMobDamage(shootingEntity);
}
@Override
public void onImpact(MovingObjectPosition mop)
{
if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY && mop.entityHit != null)
{
if (mop.entityHit == shootingEntity)
{
return;
}
worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float) (2), causesEnvDamage);
} else if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
{
worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float) (2), causesEnvDamage);
}
this.setDead();
}
@Override
public void onImpact(Entity mop)
{
if (mop == shootingEntity && ticksInAir > 3)
{
shootingEntity.attackEntityFrom(DamageSource.causeMobDamage(shootingEntity), 1);
this.setDead();
} else
{
if (mop instanceof EntityLivingBase)
{
if (((EntityLivingBase) mop).isImmuneToFire())
{
doDamage((int) (projectileDamage), mop);
} else
{
doDamage(projectileDamage, mop);
}
}
}
if (worldObj.isAirBlock((int) this.posX, (int) this.posY, (int) this.posZ))
{
}
spawnHitParticles("magicCrit", 8);
this.setDead();
}
@Override
public void doFiringParticles()
{
worldObj.spawnParticle("mobSpellAmbient", posX + smallGauss(0.1D), posY + smallGauss(0.1D), posZ + smallGauss(0.1D), 0.5D, 0.5D, 0.5D);
worldObj.spawnParticle("explode", posX, posY, posZ, gaussian(motionX), gaussian(motionY), gaussian(motionZ));
}
@Override
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
par1NBTTagCompound.setBoolean("causesEnvDamage", causesEnvDamage);
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
@Override
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
causesEnvDamage = par1NBTTagCompound.getBoolean("causesEnvDamage");
}
}

View file

@ -0,0 +1,108 @@
package WayofTime.alchemicalWizardry.common.entity.projectile;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Blocks;
import net.minecraft.potion.Potion;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
public class FireProjectile extends EnergyBlastProjectile
{
public FireProjectile(World par1World)
{
super(par1World);
}
public FireProjectile(World par1World, double par2, double par4, double par6)
{
super(par1World, par2, par4, par6);
}
public FireProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage)
{
super(par1World, par2EntityPlayer, damage);
}
public FireProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage, int maxTicksInAir, double posX, double posY, double posZ, float rotationYaw, float rotationPitch)
{
super(par1World, par2EntityPlayer, damage, maxTicksInAir, posX, posY, posZ, rotationYaw, rotationPitch);
}
public FireProjectile(World par1World, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase, float par4, float par5, int damage, int maxTicksInAir)
{
super(par1World, par2EntityLivingBase, par3EntityLivingBase, par4, par5, damage, maxTicksInAir);
}
@Override
public DamageSource getDamageSource()
{
return DamageSource.causeMobDamage(shootingEntity);
}
@Override
public void onImpact(MovingObjectPosition mop)
{
if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY && mop.entityHit != null)
{
if (mop.entityHit == shootingEntity)
{
return;
}
this.onImpact(mop.entityHit);
} else if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
{
for (int i = -1; i <= 1; i++)
{
for (int j = -1; j <= 1; j++)
{
for (int k = -1; k <= 1; k++)
{
if (worldObj.isAirBlock((int) this.posX + i, (int) this.posY + j, (int) this.posZ + k))
{
worldObj.setBlock((int) this.posX + i, (int) this.posY + j, (int) this.posZ + k, Blocks.fire);
}
}
}
}
}
this.setDead();
}
@Override
public void onImpact(Entity mop)
{
if (mop == shootingEntity && ticksInAir > 3)
{
shootingEntity.attackEntityFrom(DamageSource.causeMobDamage(shootingEntity), 1);
this.setDead();
} else
{
if (mop instanceof EntityLivingBase)
{
((EntityLivingBase) mop).setFire(50);
((EntityLivingBase) mop).setRevengeTarget(shootingEntity);
if (((EntityLivingBase) mop).isPotionActive(Potion.fireResistance) || ((EntityLivingBase) mop).isImmuneToFire())
{
((EntityLivingBase) mop).attackEntityFrom(DamageSource.causeMobDamage(shootingEntity), 1);
} else
{
doDamage(projectileDamage, mop);
((EntityLivingBase) mop).hurtResistantTime = 0;
}
}
}
if (worldObj.isAirBlock((int) this.posX, (int) this.posY, (int) this.posZ))
{
worldObj.setBlock((int) this.posX, (int) this.posY, (int) this.posZ, Blocks.fire);
}
spawnHitParticles("magicCrit", 8);
this.setDead();
}
}

View file

@ -0,0 +1,96 @@
package WayofTime.alchemicalWizardry.common.entity.projectile;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
public class HolyProjectile extends EnergyBlastProjectile
{
public HolyProjectile(World par1World)
{
super(par1World);
}
public HolyProjectile(World par1World, double par2, double par4, double par6)
{
super(par1World, par2, par4, par6);
}
public HolyProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage)
{
super(par1World, par2EntityPlayer, damage);
}
public HolyProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage, int maxTicksInAir, double posX, double posY, double posZ, float rotationYaw, float rotationPitch)
{
super(par1World, par2EntityPlayer, damage, maxTicksInAir, posX, posY, posZ, rotationYaw, rotationPitch);
}
public HolyProjectile(World par1World, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase, float par4, float par5, int damage, int maxTicksInAir)
{
super(par1World, par2EntityLivingBase, par3EntityLivingBase, par4, par5, damage, maxTicksInAir);
}
@Override
public DamageSource getDamageSource()
{
return DamageSource.causeMobDamage(shootingEntity);
}
@Override
public void onImpact(MovingObjectPosition mop)
{
if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY && mop.entityHit != null)
{
if (mop.entityHit == shootingEntity)
{
return;
}
this.onImpact(mop.entityHit);
} else if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
{
}
this.setDead();
}
@Override
public void onImpact(Entity mop)
{
if (mop == shootingEntity && ticksInAir > 3)
{
shootingEntity.attackEntityFrom(DamageSource.causeMobDamage(shootingEntity), 1);
this.setDead();
} else
{
if (mop instanceof EntityLivingBase)
{
if (((EntityLivingBase) mop).isEntityUndead())
{
doDamage((int) (projectileDamage * 2), mop);
} else
{
doDamage(projectileDamage, mop);
}
}
}
if (worldObj.isAirBlock((int) this.posX, (int) this.posY, (int) this.posZ))
{
}
spawnHitParticles("magicCrit", 8);
this.setDead();
}
@Override
public void doFiringParticles()
{
SpellHelper.sendParticleToAllAround(worldObj, posX, posY, posZ, 30, worldObj.provider.dimensionId, "mobSpellAmbient", posX + smallGauss(0.1D), posY + smallGauss(0.1D), posZ + smallGauss(0.1D), 0.5D, 0.5D, 0.5D);
SpellHelper.sendParticleToAllAround(worldObj, posX, posY, posZ, 30, worldObj.provider.dimensionId, "mobSpell", posX, posY, posZ, 1.0F, 1.0F, 1.0F);
}
}

View file

@ -0,0 +1,101 @@
package WayofTime.alchemicalWizardry.common.entity.projectile;
import WayofTime.alchemicalWizardry.common.entity.mob.EntityIceDemon;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
public class IceProjectile extends EnergyBlastProjectile
{
public IceProjectile(World par1World)
{
super(par1World);
}
public IceProjectile(World par1World, double par2, double par4, double par6)
{
super(par1World, par2, par4, par6);
}
public IceProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage)
{
super(par1World, par2EntityPlayer, damage);
}
public IceProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage, int maxTicksInAir, double posX, double posY, double posZ, float rotationYaw, float rotationPitch)
{
super(par1World, par2EntityPlayer, damage, maxTicksInAir, posX, posY, posZ, rotationYaw, rotationPitch);
}
public IceProjectile(World worldObj, EntityIceDemon entityIceDemon, EntityLivingBase par1EntityLivingBase, float f, float g, int i, int j)
{
super(worldObj, entityIceDemon, par1EntityLivingBase, f, g, i, j);
}
@Override
public DamageSource getDamageSource()
{
return DamageSource.causeMobDamage(shootingEntity);
}
@Override
public void onImpact(MovingObjectPosition mop)
{
if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY && mop.entityHit != null)
{
if (mop.entityHit == shootingEntity)
{
return;
}
this.onImpact(mop.entityHit);
} else if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
{
}
this.setDead();
}
@Override
public void onImpact(Entity mop)
{
if (mop == shootingEntity && ticksInAir > 3)
{
shootingEntity.attackEntityFrom(DamageSource.causeMobDamage(shootingEntity), 1);
this.setDead();
} else
{
if (mop instanceof EntityLivingBase)
{
if (((EntityLivingBase) mop).isImmuneToFire())
{
doDamage((int) (projectileDamage * 2), mop);
((EntityLivingBase) mop).addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 200, 2));
} else
{
doDamage(projectileDamage, mop);
((EntityLivingBase) mop).addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 100, 1));
}
}
}
if (worldObj.isAirBlock((int) this.posX, (int) this.posY, (int) this.posZ))
{
//worldObj.setBlock((int)this.posX, (int)this.posY, (int)this.posZ,Block.fire.blockID);
}
spawnHitParticles("magicCrit", 8);
this.setDead();
}
@Override
public void doFiringParticles()
{
SpellHelper.sendParticleToAllAround(worldObj, posX, posY, posZ, 30, worldObj.provider.dimensionId, "mobSpellAmbient", posX + smallGauss(0.1D), posY + smallGauss(0.1D), posZ + smallGauss(0.1D), 0.5D, 0.5D, 0.5D);
SpellHelper.sendParticleToAllAround(worldObj, posX, posY, posZ, 30, worldObj.provider.dimensionId, "explode", posX, posY, posZ, gaussian(motionX), gaussian(motionY), gaussian(motionZ));
}
}

Some files were not shown because too many files have changed in this diff Show more