1.12
WayofTime 2014-01-17 14:12:49 -05:00
commit 8601e9faff
498 changed files with 45817 additions and 0 deletions

22
.gitattributes vendored Normal file
View File

@ -0,0 +1,22 @@
# Auto detect text files and perform LF normalization
* text=auto
# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union
# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain

215
.gitignore vendored Normal file
View File

@ -0,0 +1,215 @@
#################
## Eclipse
#################
*.pydevproject
.project
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# PDT-specific
.buildpath
#################
## Visual Studio
#################
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.scc
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
*.ncrunch*
.*crunch*.local.xml
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.Publish.xml
*.pubxml
# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
#packages/
# Windows Azure Build Output
csx
*.build.csdef
# Windows Store app package directory
AppPackages/
# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
App_Data/*.mdf
App_Data/*.ldf
#############
## Windows detritus
#############
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Mac crap
.DS_Store
#############
## Python
#############
*.py[co]
# Packages
*.egg
*.egg-info
dist/
build/
eggs/
parts/
var/
sdist/
develop-eggs/
.installed.cfg
# Installer logs
pip-log.txt
# Unit test / coverage reports
.coverage
.tox
#Translations
*.mo
#Mr Developer
.mr.developer.cfg

View File

@ -0,0 +1,22 @@
package WayofTime.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.IconRegister;
public class TestingBlock extends Block
{
public TestingBlock(int id, Material material)
{
super(id, material);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
this.blockIcon = iconRegister.registerIcon("AlchemicalWizardry:Testing");
}
}

View File

@ -0,0 +1,121 @@
package WayofTime.alchemicalWizardry.client;
import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient;
import WayofTime.alchemicalWizardry.common.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.CommonProxy;
import WayofTime.alchemicalWizardry.common.EntityAirElemental;
import WayofTime.alchemicalWizardry.common.entity.mob.EntityBileDemon;
import WayofTime.alchemicalWizardry.common.entity.mob.EntityBoulderFist;
import WayofTime.alchemicalWizardry.common.entity.mob.EntityEarthElemental;
import WayofTime.alchemicalWizardry.common.entity.mob.EntityFallenAngel;
import WayofTime.alchemicalWizardry.common.entity.mob.EntityFireElemental;
import WayofTime.alchemicalWizardry.common.entity.mob.EntityHolyElemental;
import WayofTime.alchemicalWizardry.common.entity.mob.EntityIceDemon;
import WayofTime.alchemicalWizardry.common.entity.mob.EntityLowerGuardian;
import WayofTime.alchemicalWizardry.common.entity.mob.EntityShade;
import WayofTime.alchemicalWizardry.common.entity.mob.EntityShadeElemental;
import WayofTime.alchemicalWizardry.common.entity.mob.EntitySmallEarthGolem;
import WayofTime.alchemicalWizardry.common.entity.mob.EntityWaterElemental;
import WayofTime.alchemicalWizardry.common.entity.mob.EntityWingedFireDemon;
import WayofTime.alchemicalWizardry.common.entity.projectile.EnergyBlastProjectile;
import WayofTime.alchemicalWizardry.common.entity.projectile.EntityEnergyBazookaMainProjectile;
import WayofTime.alchemicalWizardry.common.entity.projectile.EntityMeteor;
import WayofTime.alchemicalWizardry.common.renderer.block.RenderConduit;
import WayofTime.alchemicalWizardry.common.renderer.block.RenderPedestal;
import WayofTime.alchemicalWizardry.common.renderer.block.RenderPlinth;
import WayofTime.alchemicalWizardry.common.renderer.block.RenderWritingTable;
import WayofTime.alchemicalWizardry.common.renderer.block.TEAltarRenderer;
import WayofTime.alchemicalWizardry.common.renderer.block.itemRender.TEAltarItemRenderer;
import WayofTime.alchemicalWizardry.common.renderer.mob.RenderBileDemon;
import WayofTime.alchemicalWizardry.common.renderer.mob.RenderBoulderFist;
import WayofTime.alchemicalWizardry.common.renderer.mob.RenderElemental;
import WayofTime.alchemicalWizardry.common.renderer.mob.RenderFallenAngel;
import WayofTime.alchemicalWizardry.common.renderer.mob.RenderIceDemon;
import WayofTime.alchemicalWizardry.common.renderer.mob.RenderLowerGuardian;
import WayofTime.alchemicalWizardry.common.renderer.mob.RenderShade;
import WayofTime.alchemicalWizardry.common.renderer.mob.RenderSmallEarthGolem;
import WayofTime.alchemicalWizardry.common.renderer.mob.RenderWingedFireDemon;
import WayofTime.alchemicalWizardry.common.renderer.model.ModelBileDemon;
import WayofTime.alchemicalWizardry.common.renderer.model.ModelBoulderFist;
import WayofTime.alchemicalWizardry.common.renderer.model.ModelElemental;
import WayofTime.alchemicalWizardry.common.renderer.model.ModelFallenAngel;
import WayofTime.alchemicalWizardry.common.renderer.model.ModelIceDemon;
import WayofTime.alchemicalWizardry.common.renderer.model.ModelLowerGuardian;
import WayofTime.alchemicalWizardry.common.renderer.model.ModelShade;
import WayofTime.alchemicalWizardry.common.renderer.model.ModelSmallEarthGolem;
import WayofTime.alchemicalWizardry.common.renderer.model.ModelWingedFireDemon;
import WayofTime.alchemicalWizardry.common.renderer.projectile.RenderEnergyBazookaMainProjectile;
import WayofTime.alchemicalWizardry.common.renderer.projectile.RenderEnergyBlastProjectile;
import WayofTime.alchemicalWizardry.common.renderer.projectile.RenderMeteor;
import WayofTime.alchemicalWizardry.common.tileEntity.TEAltar;
import WayofTime.alchemicalWizardry.common.tileEntity.TEConduit;
import WayofTime.alchemicalWizardry.common.tileEntity.TEPedestal;
import WayofTime.alchemicalWizardry.common.tileEntity.TEPlinth;
import WayofTime.alchemicalWizardry.common.tileEntity.TEWritingTable;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
public class ClientProxy extends CommonProxy
{
public static int renderPass;
public static int altarRenderType;
@Override
public void registerRenderers()
{
//altarRenderType = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerEntityRenderingHandler(EnergyBlastProjectile.class, new RenderEnergyBlastProjectile());
RenderingRegistry.registerEntityRenderingHandler(EntityEnergyBazookaMainProjectile.class, new RenderEnergyBazookaMainProjectile());
RenderingRegistry.registerEntityRenderingHandler(EntityMeteor.class, new RenderMeteor());
//EntityRegistry.registerGlobalEntityID(EntityFallenAngel.class, "AlchemicalWizardry.FallenAngel", EntityRegistry.findGlobalUniqueEntityId(),0x40FF00, 0x0B610B);
RenderingRegistry.registerEntityRenderingHandler(EntityFallenAngel.class, new RenderFallenAngel(new ModelFallenAngel(), 0.5F));
//EntityRegistry.registerGlobalEntityID(EntityLowerGuardian.class, "AlchemicalWizardry.LowerGuardian", EntityRegistry.findGlobalUniqueEntityId(),0x40FF00, 0x0B610B);
RenderingRegistry.registerEntityRenderingHandler(EntityLowerGuardian.class, new RenderLowerGuardian(new ModelLowerGuardian(), 0.5F));
//EntityRegistry.registerGlobalEntityID(EntityBileDemon.class, "AlchemicalWizardry.BileDemon", EntityRegistry.findGlobalUniqueEntityId(),0x40FF00, 0x0B610B);
RenderingRegistry.registerEntityRenderingHandler(EntityBileDemon.class, new RenderBileDemon(new ModelBileDemon(), 1.5F));
//EntityRegistry.registerGlobalEntityID(EntityWingedFireDemon.class, "AlchemicalWizardry.WingedFireDemon", EntityRegistry.findGlobalUniqueEntityId(),0x40FF00, 0x0B610B);
RenderingRegistry.registerEntityRenderingHandler(EntityWingedFireDemon.class, new RenderWingedFireDemon(new ModelWingedFireDemon(), 1.0F));
//EntityRegistry.registerGlobalEntityID(EntitySmallEarthGolem.class, "AlchemicalWizardry.SmallEarthGolem", EntityRegistry.findGlobalUniqueEntityId(),0x40FF00, 0x0B610B);
RenderingRegistry.registerEntityRenderingHandler(EntitySmallEarthGolem.class, new RenderSmallEarthGolem(new ModelSmallEarthGolem(), 0.5F));
//EntityRegistry.registerGlobalEntityID(EntityIceDemon.class, "AlchemicalWizardry.IceDemon", EntityRegistry.findGlobalUniqueEntityId(),0x40FF00, 0x0B610B);
RenderingRegistry.registerEntityRenderingHandler(EntityIceDemon.class, new RenderIceDemon(new ModelIceDemon(), 0.5F));
// EntityRegistry.registerGlobalEntityID(EntityBoulderFist.class, "AlchemicalWizardry.BoulderFist", EntityRegistry.findGlobalUniqueEntityId(),0x40FF00, 0x0B610B);
RenderingRegistry.registerEntityRenderingHandler(EntityBoulderFist.class, new RenderBoulderFist(new ModelBoulderFist(), 0.5F));
//EntityRegistry.registerGlobalEntityID(EntityShade.class, "AlchemicalWizardry.Shade", EntityRegistry.findGlobalUniqueEntityId(),0x40FF00, 0x0B610B);
RenderingRegistry.registerEntityRenderingHandler(EntityShade.class, new RenderShade(new ModelShade(), 0.5F));
//EntityRegistry.registerGlobalEntityID(EntityAirElemental.class, "AlchemicalWizardry.AirElemental", EntityRegistry.findGlobalUniqueEntityId(),0x40FF00, 0x0B610B);
RenderingRegistry.registerEntityRenderingHandler(EntityAirElemental.class, new RenderElemental(new ModelElemental(), 0.5F));
//EntityRegistry.registerGlobalEntityID(EntityWaterElemental.class, "AlchemicalWizardry.WaterElemental", EntityRegistry.findGlobalUniqueEntityId(),0x40FF00, 0x0B610B);
RenderingRegistry.registerEntityRenderingHandler(EntityWaterElemental.class, new RenderElemental(new ModelElemental(), 0.5F));
//EntityRegistry.registerGlobalEntityID(EntityEarthElemental.class, "AlchemicalWizardry.EarthElemental", EntityRegistry.findGlobalUniqueEntityId(),0x40FF00, 0x0B610B);
RenderingRegistry.registerEntityRenderingHandler(EntityEarthElemental.class, new RenderElemental(new ModelElemental(), 0.5F));
//EntityRegistry.registerGlobalEntityID(EntityFireElemental.class, "AlchemicalWizardry.FireElemental", EntityRegistry.findGlobalUniqueEntityId(),0x40FF00, 0x0B610B);
RenderingRegistry.registerEntityRenderingHandler(EntityFireElemental.class, new RenderElemental(new ModelElemental(), 0.5F));
//EntityRegistry.registerGlobalEntityID(EntityShadeElemental.class, "AlchemicalWizardry.ShadeElemental", EntityRegistry.findGlobalUniqueEntityId(),0x40FF00, 0x0B610B);
RenderingRegistry.registerEntityRenderingHandler(EntityShadeElemental.class, new RenderElemental(new ModelElemental(), 0.5F));
//EntityRegistry.registerGlobalEntityID(EntityHolyElemental.class, "AlchemicalWizardry.HolyElemental", EntityRegistry.findGlobalUniqueEntityId(),0x40FF00, 0x0B610B);
RenderingRegistry.registerEntityRenderingHandler(EntityHolyElemental.class, new RenderElemental(new ModelElemental(), 0.5F));
ClientRegistry.bindTileEntitySpecialRenderer(TEPedestal.class, new RenderPedestal());
ClientRegistry.bindTileEntitySpecialRenderer(TEPlinth.class, new RenderPlinth());
ClientRegistry.bindTileEntitySpecialRenderer(TEWritingTable.class, new RenderWritingTable());
ClientRegistry.bindTileEntitySpecialRenderer(TEConduit.class, new RenderConduit());
//RenderingRegistry.registerEntityRenderingHandler(FireProjectile.class, new RenderFireProjectile());
//RenderingRegistry.registerBlockHandler(new AltarRenderer());
}
@Override
public World getClientWorld()
{
return FMLClientHandler.instance().getClient().theWorld;
}
@Override
public void InitRendering()
{
ClientRegistry.bindTileEntitySpecialRenderer(TEAltar.class, new TEAltarRenderer());
MinecraftForgeClient.registerItemRenderer(AlchemicalWizardry.blockAltar.blockID, new TEAltarItemRenderer());
//MinecraftForgeClient.registerItemRenderer(AlchemicalWizardry.blockWritingTable.blockID, new TEWritingTableItemRenderer());
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,220 @@
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 WayofTime.alchemicalWizardry.common.entity.projectile.EnergyBlastProjectile;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IProjectile;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerCapabilities;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.living.LivingAttackEvent;
import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
import cpw.mods.fml.common.ObfuscationReflectionHelper;
import cpw.mods.fml.relauncher.ReflectionHelper;
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();
@ForgeSubscribe
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);
}
}
@ForgeSubscribe
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);
}
}
}
// @ForgeSubscribe
// public void onFOVUpdate(FOVUpdateEvent event)
// {
// event.setResult(Result.DEFAULT);
// }
@ForgeSubscribe
public void onEntityUpdate(LivingUpdateEvent event)
{
EntityLivingBase entityLiving = event.entityLiving;
if (entityLiving instanceof EntityPlayer && entityLiving.worldObj.isRemote)
{
EntityPlayer entityPlayer = (EntityPlayer)entityLiving;
boolean highStepListed = playersWith1Step.contains(entityPlayer.username);
boolean hasHighStep = entityPlayer.isPotionActive(AlchemicalWizardry.customPotionBoost);
if (hasHighStep && !highStepListed)
{
playersWith1Step.add(entityPlayer.username);
}
if (!hasHighStep && highStepListed)
{
playersWith1Step.remove(entityPlayer.username);
entityPlayer.stepHeight = 0.5F;
}
}
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())
{
double percentIncrease = (i + 1) * 0.03d;
if (event.entityLiving instanceof EntityPlayer)
{
EntityPlayer entityPlayer = (EntityPlayer)event.entityLiving;
entityPlayer.stepHeight = 1.0f;
if (!entityPlayer.worldObj.isRemote)
{
float speed = ((Float)ReflectionHelper.getPrivateValue(PlayerCapabilities.class, entityPlayer.capabilities, new String[] { "walkSpeed", "g", "field_75097_g" })).floatValue();
ObfuscationReflectionHelper.setPrivateValue(PlayerCapabilities.class, entityPlayer.capabilities, Float.valueOf(speed + (float)percentIncrease), new String[] { "walkSpeed", "g", "field_75097_g" }); //CAUTION
}
}
}
}
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 = i;
AxisAlignedBB axisalignedbb = AxisAlignedBB.getAABBPool().getAABB(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))
{
continue;
}
if (projectile instanceof EntityArrow)
{
if (((EntityArrow)projectile).shootingEntity == null)
{
}
else if (!(((EntityArrow)projectile).shootingEntity == null) && ((EntityArrow)projectile).shootingEntity.equals(entity))
{
break;
}
}
else if (projectile instanceof EnergyBlastProjectile)
{
if (!(((EnergyBlastProjectile)projectile).shootingEntity == null) && ((EnergyBlastProjectile)projectile).shootingEntity.equals(entity))
{
break;
}
}
double delX = projectile.posX - entity.posX;
double delY = projectile.posY - entity.posY;
double delZ = projectile.posZ - entity.posZ;
double curVel = Math.sqrt(delX * delX + delY * delY + delZ * delZ);
//NOTE: It appears that it constantly reverses the direction.
//Any way to do it only once? Or find the shooting entity?
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 = entityPlayer.username;
playerFlightBuff.put(ownerName, true);
entityPlayer.capabilities.allowFlying = true;
//entityPlayer.sendPlayerAbilities();
}
}
else
{
if (event.entityLiving instanceof EntityPlayer)
{
EntityPlayer entityPlayer = (EntityPlayer)event.entityLiving;
String ownerName = entityPlayer.username;
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();
}
}
}
}
}
}

View File

@ -0,0 +1,65 @@
package WayofTime.alchemicalWizardry.common;
import net.minecraft.entity.player.EntityPlayer;
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;
import WayofTime.alchemicalWizardry.common.items.LavaCrystal;
import cpw.mods.fml.common.IFuelHandler;
public class AlchemicalWizardryFuelHandler implements IFuelHandler
{
@Override
public int getBurnTime(ItemStack fuel)
{
ItemStack itemStack = fuel;
int var1 = fuel.itemID;
if (var1 == AlchemicalWizardry.lavaCrystal.itemID)
{
/*ItemStack newItem = new ItemStack(AlchemicalWizardry.lavaCrystal);
newItem.getItem().setDamage(newItem, 50);
fuel.getItem().setContainerItem(((LavaCrystal)newItem.getItem()).change());
*/
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 = MinecraftServer.getServer().getConfigurationManager().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,50 @@
package WayofTime.alchemicalWizardry.common;
import java.util.EnumSet;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerCapabilities;
import net.minecraft.item.ItemStack;
import net.minecraft.server.MinecraftServer;
import cpw.mods.fml.common.ITickHandler;
import cpw.mods.fml.common.ObfuscationReflectionHelper;
import cpw.mods.fml.common.TickType;
public class AlchemicalWizardryTickHandler implements ITickHandler
{
public void tickStart(EnumSet<TickType> type, Object... tickData)
{
}
public EnumSet<TickType> ticks()
{
return EnumSet.of(TickType.PLAYER);
}
public String getLabel()
{
return "BloodMagic";
}
public void tickEnd(EnumSet<TickType> type, Object... tickData)
{
String[] usernames = MinecraftServer.getServer().getAllUsernames();
if (usernames == null)
{
return;
}
for (String userName : usernames)
{
EntityPlayer entityPlayer = MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(userName);
if (entityPlayer != null)
{
ObfuscationReflectionHelper.setPrivateValue(PlayerCapabilities.class, entityPlayer.capabilities, Float.valueOf(0.1f), new String[] { "walkSpeed", "g", "field_75097_g" });
//entityPlayer.sendPlayerAbilities();
}
}
}
}

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,15 @@
package WayofTime.alchemicalWizardry.common;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public interface ArmourUpgrade
{
//Called when the armour ticks
public void onArmourUpdate(World world, EntityPlayer player, ItemStack thisItemStack);
public boolean isUpgrade();
public int getEnergyForTenSeconds();
}

View File

@ -0,0 +1,85 @@
package WayofTime.alchemicalWizardry.common;
import WayofTime.alchemicalWizardry.common.entity.projectile.EnergyBlastProjectile;
import WayofTime.alchemicalWizardry.common.entity.projectile.EntityBloodLightProjectile;
import WayofTime.alchemicalWizardry.common.entity.projectile.EntityEnergyBazookaMainProjectile;
import WayofTime.alchemicalWizardry.common.entity.projectile.EntityEnergyBazookaSecondaryProjectile;
import WayofTime.alchemicalWizardry.common.entity.projectile.EntityMeteor;
import WayofTime.alchemicalWizardry.common.entity.projectile.ExplosionProjectile;
import WayofTime.alchemicalWizardry.common.entity.projectile.FireProjectile;
import WayofTime.alchemicalWizardry.common.entity.projectile.HolyProjectile;
import WayofTime.alchemicalWizardry.common.entity.projectile.IceProjectile;
import WayofTime.alchemicalWizardry.common.entity.projectile.LightningBoltProjectile;
import WayofTime.alchemicalWizardry.common.entity.projectile.MudProjectile;
import WayofTime.alchemicalWizardry.common.entity.projectile.TeleportProjectile;
import WayofTime.alchemicalWizardry.common.entity.projectile.WaterProjectile;
import WayofTime.alchemicalWizardry.common.entity.projectile.WindGustProjectile;
import WayofTime.alchemicalWizardry.common.tileEntity.TEAltar;
import WayofTime.alchemicalWizardry.common.tileEntity.TEMasterStone;
import net.minecraft.world.World;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
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, 128, 3, true);
}
public void registerTickHandlers()
{
}
public void InitRendering()
{
// TODO Auto-generated method stub
}
}

View File

@ -0,0 +1,5 @@
package WayofTime.alchemicalWizardry.common;
public class EntityAIFly
{
}

View File

@ -0,0 +1,27 @@
package WayofTime.alchemicalWizardry.common;
import WayofTime.alchemicalWizardry.common.entity.mob.EntityDemon;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.passive.EntityTameable;
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,49 @@
package WayofTime.alchemicalWizardry.common;
import WayofTime.alchemicalWizardry.common.entity.mob.EntityElemental;
import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.common.network.Player;
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.EntityFlying;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.monster.EntityGhast;
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityLargeFireball;
import net.minecraft.entity.projectile.EntitySmallFireball;
import net.minecraft.item.Item;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.PotionEffect;
import net.minecraft.stats.AchievementList;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3;
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)
{
PacketDispatcher.sendPacketToPlayer(PacketHandler.getPlayerVelocitySettingPacket(target.motionX, target.motionY + 3, target.motionZ), (Player)target);
((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,5 @@
package WayofTime.alchemicalWizardry.common;
public class EnumToolMaterialBoundBlood
{
}

View File

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

View File

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

View File

@ -0,0 +1,7 @@
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,40 @@
package WayofTime.alchemicalWizardry.common;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.event.Event.Result;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.player.FillBucketEvent;
public class LifeBucketHandler
{
@ForgeSubscribe
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)
{
int blockID = world.getBlockId(pos.blockX, pos.blockY, pos.blockZ);
if ((blockID == AlchemicalWizardry.blockLifeEssence.blockID) && world.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ) == 0)
{
world.setBlock(pos.blockX, pos.blockY, pos.blockZ, 0);
return new ItemStack(AlchemicalWizardry.bucketLife);
}
else
{
return null;
}
}
}

View File

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

View File

@ -0,0 +1,25 @@
package WayofTime.alchemicalWizardry.common;
import net.minecraft.nbt.NBTTagCompound;
public class LifeEssenceNetwork extends net.minecraft.world.WorldSavedData
{
public int currentEssence;
public LifeEssenceNetwork(String par1Str)
{
super(par1Str);
currentEssence = 0;
}
@Override
public void readFromNBT(NBTTagCompound nbttagcompound)
{
currentEssence = nbttagcompound.getInteger("currentEssence");
}
@Override
public void writeToNBT(NBTTagCompound nbttagcompound)
{
nbttagcompound.setInteger("currentEssence", currentEssence);
}
}

View File

@ -0,0 +1,35 @@
package WayofTime.alchemicalWizardry.common;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.living.LivingDropsEvent;
public class ModLivingDropsEvent
{
public static double rand;
@ForgeSubscribe
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(AlchemicalWizardry.weakBloodShard.itemID, 1);
}
}
}
}
}
}

File diff suppressed because it is too large Load Diff

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,18 @@
package WayofTime.alchemicalWizardry.common;
import net.minecraft.potion.Potion;
public class PotionBoost extends Potion
{
protected PotionBoost(int par1, boolean par2, int par3)
{
super(par1, par2, par3);
}
@Override
public Potion setIconIndex(int par1, int par2)
{
super.setIconIndex(par1, par2);
return this;
}
}

View File

@ -0,0 +1,18 @@
package WayofTime.alchemicalWizardry.common;
import net.minecraft.potion.Potion;
public class PotionDrowning extends Potion
{
protected PotionDrowning(int par1, boolean par2, int par3)
{
super(par1, par2, par3);
}
@Override
public Potion setIconIndex(int par1, int par2)
{
super.setIconIndex(par1, par2);
return this;
}
}

View File

@ -0,0 +1,18 @@
package WayofTime.alchemicalWizardry.common;
import net.minecraft.potion.Potion;
public class PotionFlight extends Potion
{
protected PotionFlight(int par1, boolean par2, int par3)
{
super(par1, par2, par3);
}
@Override
public Potion setIconIndex(int par1, int par2)
{
super.setIconIndex(par1, par2);
return this;
}
}

View File

@ -0,0 +1,18 @@
package WayofTime.alchemicalWizardry.common;
import net.minecraft.potion.Potion;
public class PotionInhibit extends Potion
{
protected PotionInhibit(int par1, boolean par2, int par3)
{
super(par1, par2, par3);
}
@Override
public Potion setIconIndex(int par1, int par2)
{
super.setIconIndex(par1, par2);
return this;
}
}

View File

@ -0,0 +1,18 @@
package WayofTime.alchemicalWizardry.common;
import net.minecraft.potion.Potion;
public class PotionProjectileProtect extends Potion
{
protected PotionProjectileProtect(int par1, boolean par2, int par3)
{
super(par1, par2, par3);
}
@Override
public Potion setIconIndex(int par1, int par2)
{
super.setIconIndex(par1, par2);
return this;
}
}

View File

@ -0,0 +1,18 @@
package WayofTime.alchemicalWizardry.common;
import net.minecraft.potion.Potion;
public class PotionReciprocation extends Potion
{
protected PotionReciprocation(int par1, boolean par2, int par3)
{
super(par1, par2, par3);
}
@Override
public Potion setIconIndex(int par1, int par2)
{
super.setIconIndex(par1, par2);
return this;
}
}

View File

@ -0,0 +1,107 @@
package WayofTime.alchemicalWizardry.common.alchemy;
import java.util.ArrayList;
import WayofTime.alchemicalWizardry.common.AlchemicalWizardry;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
public class AlchemicalPotionCreationHandler
{
public static ArrayList<AlchemyPotionHandlerComponent> registeredPotionEffects = new ArrayList();
public static void initializePotions()
{
addPotion(new ItemStack(Item.ghastTear), Potion.regeneration.id, 450);
addPotion(new ItemStack(Item.goldenCarrot), Potion.nightVision.id, 2 * 60 * 20);
addPotion(new ItemStack(Item.magmaCream), Potion.fireResistance.id, 2 * 60 * 20);
addPotion(new ItemStack(Item.sugar), Potion.moveSpeed.id, 2 * 60 * 20);
addPotion(new ItemStack(Item.speckledMelon), Potion.heal.id, 2 * 60 * 20);
addPotion(new ItemStack(Item.spiderEye), Potion.poison.id, 450);
addPotion(new ItemStack(Item.fermentedSpiderEye), Potion.weakness.id, 450);
addPotion(new ItemStack(Item.blazePowder), Potion.damageBoost.id, 2 * 60 * 20);
addPotion(new ItemStack(AlchemicalWizardry.aether), Potion.jump.id, 2 * 60 * 20);
addPotion(new ItemStack(Item.clay), Potion.moveSlowdown.id, 450);
addPotion(new ItemStack(Item.redstone), Potion.digSpeed.id, 2 * 60 * 20);
addPotion(new ItemStack(Item.potion, 1, 0), AlchemicalWizardry.customPotionDrowning.id, 450);
//addPotion(new ItemStack(Item.goldenCarrot),Potion.nightVision.id,2*60*20);
addPotion(new ItemStack(Item.glassBottle), Potion.invisibility.id, 2 * 60 * 20);
addPotion(new ItemStack(Item.diamond), Potion.resistance.id, 2 * 60 * 20);
addPotion(new ItemStack(Item.poisonousPotato), Potion.field_76443_y.id, 2); //saturation
addPotion(new ItemStack(AlchemicalWizardry.demonBloodShard), Potion.field_76434_w.id, 4 * 60 * 20); //health boost
addPotion(new ItemStack(AlchemicalWizardry.weakBloodShard), Potion.field_76444_x.id, 4 * 60 * 20); //Absorption
addPotion(new ItemStack(AlchemicalWizardry.terrae), AlchemicalWizardry.customPotionBoost.id, 1 * 60 * 20);
addPotion(new ItemStack(Item.feather), AlchemicalWizardry.customPotionFlight.id, 1 * 60 * 20);
addPotion(new ItemStack(Item.arrow), AlchemicalWizardry.customPotionReciprocation.id, 1 * 60 * 20);
}
public static void addPotion(ItemStack itemStack, int potionID, int tickDuration)
{
registeredPotionEffects.add(new AlchemyPotionHandlerComponent(itemStack, potionID, tickDuration));
}
public static int getPotionIDForStack(ItemStack itemStack)
{
for (AlchemyPotionHandlerComponent aphc : registeredPotionEffects)
{
if (aphc.compareItemStack(itemStack))
{
return aphc.getPotionID();
}
}
return -1;
}
public static int getPotionTickDurationForStack(ItemStack itemStack)
{
{
for (AlchemyPotionHandlerComponent aphc : registeredPotionEffects)
{
if (aphc.compareItemStack(itemStack))
{
return aphc.getTickDuration();
}
}
return -1;
}
}
public static boolean containsRegisteredPotionIngredient(ItemStack[] stackList)
{
for (ItemStack is : stackList)
{
for (AlchemyPotionHandlerComponent aphc : registeredPotionEffects)
{
if (aphc.compareItemStack(is))
{
return true;
}
}
}
return false;
}
public static int getRegisteredPotionIngredientPosition(ItemStack[] stackList)
{
int i = 0;
for (ItemStack is : stackList)
{
for (AlchemyPotionHandlerComponent aphc : registeredPotionEffects)
{
if (aphc.compareItemStack(is))
{
return i;
}
}
i++;
}
return -1;
}
}

View File

@ -0,0 +1,53 @@
package WayofTime.alchemicalWizardry.common.alchemy;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
public class AlchemyPotionHandlerComponent
{
private ItemStack itemStack;
private int potionID;
private int tickDuration;
public AlchemyPotionHandlerComponent(ItemStack itemStack, int potionID, int tickDuration)
{
this.itemStack = itemStack;
this.potionID = potionID;
this.tickDuration = tickDuration;
}
public boolean compareItemStack(ItemStack comparedStack)
{
if (comparedStack != null && itemStack != null)
{
if (comparedStack.getItem() instanceof ItemBlock)
{
if (itemStack.getItem() instanceof ItemBlock)
{
return comparedStack.itemID == itemStack.itemID && comparedStack.getItemDamage() == itemStack.getItemDamage();
}
}
else if (!(itemStack.getItem() instanceof ItemBlock))
{
return comparedStack.itemID == itemStack.itemID && comparedStack.getItemDamage() == itemStack.getItemDamage();
}
}
return false;
}
public ItemStack getItemStack()
{
return itemStack;
}
public int getPotionID()
{
return this.potionID;
}
public int getTickDuration()
{
return this.tickDuration;
}
}

View File

@ -0,0 +1,76 @@
package WayofTime.alchemicalWizardry.common.alchemy;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
public class AlchemyPotionHelper
{
private int potionID;
private int tickDuration;
private int concentration;
private int durationFactor;
public AlchemyPotionHelper(int potionID, int tickDuration, int concentration, int durationFactor)
{
this.potionID = potionID;
this.tickDuration = tickDuration;
this.concentration = concentration;
this.durationFactor = durationFactor;
}
public void setConcentration(int concentration)
{
this.concentration = concentration;
}
public void setDurationFactor(int durationFactor)
{
this.durationFactor = durationFactor;
}
public int getPotionID()
{
return this.potionID;
}
public int getTickDuration()
{
return this.tickDuration;
}
public int getConcentration()
{
return this.concentration;
}
public int getdurationFactor()
{
return this.durationFactor;
}
public PotionEffect getPotionEffect()
{
if (potionID == Potion.heal.id || potionID == Potion.harm.id)
{
return(new PotionEffect(potionID, 1, concentration));
}
return(new PotionEffect(potionID, (int)(tickDuration * Math.pow(0.5f, concentration) * Math.pow(8.0f / 3.0f, durationFactor)), concentration));
}
public static AlchemyPotionHelper readEffectFromNBT(NBTTagCompound tagCompound)
{
return new AlchemyPotionHelper(tagCompound.getInteger("potionID"), tagCompound.getInteger("tickDuration"), tagCompound.getInteger("concentration"), tagCompound.getInteger("durationFactor"));
}
public static NBTTagCompound setEffectToNBT(AlchemyPotionHelper aph)
{
NBTTagCompound tagCompound = new NBTTagCompound();
tagCompound.setInteger("potionID", aph.getPotionID());
tagCompound.setInteger("tickDuration", aph.getTickDuration());
tagCompound.setInteger("concentration", aph.getConcentration());
tagCompound.setInteger("durationFactor", aph.getdurationFactor());
return tagCompound;
}
}

View File

@ -0,0 +1,179 @@
package WayofTime.alchemicalWizardry.common.alchemy;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
public class AlchemyRecipe
{
private ItemStack output;
private ItemStack[] recipe;
private int bloodOrbLevel;
private int amountNeeded;
public AlchemyRecipe(ItemStack output, int amountNeeded, ItemStack[] recipe, int bloodOrbLevel)
{
this.output = output;
this.recipe = recipe;
this.amountNeeded = amountNeeded;
this.bloodOrbLevel = bloodOrbLevel;
}
public boolean doesRecipeMatch(ItemStack[] items, int slottedBloodOrbLevel)
{
if (slottedBloodOrbLevel < bloodOrbLevel)
{
return false;
}
ItemStack[] recipe = new ItemStack[5];
if (items.length < 5)
{
return false;
}
if (this.recipe.length != 5)
{
ItemStack[] newRecipe = new ItemStack[5];
for (int i = 0; i < 5; i++)
{
if (i + 1 > this.recipe.length)
{
newRecipe[i] = null;
}
else
{
newRecipe[i] = this.recipe[i];
}
}
recipe = newRecipe;
}
else
{
recipe = this.recipe;
}
boolean[] checkList = new boolean[5];
for (int i = 0; i < 5; i++)
{
checkList[i] = false;
}
for (int i = 0; i < 5; i++)
{
ItemStack recipeItemStack = recipe[i];
if (recipeItemStack == null)
{
continue;
}
boolean test = false;
for (int j = 0; j < 5; j++)
{
if (checkList[j])
{
continue;
}
ItemStack checkedItemStack = items[j];
if (checkedItemStack == null)
{
continue;
}
boolean quickTest = false;
if (recipeItemStack.getItem() instanceof ItemBlock)
{
if (checkedItemStack.getItem() instanceof ItemBlock)
{
quickTest = true;
}
}
else if (!(checkedItemStack.getItem() instanceof ItemBlock))
{
quickTest = true;
}
if (!quickTest)
{
continue;
}
if ((checkedItemStack.getItemDamage() == recipeItemStack.getItemDamage() || OreDictionary.WILDCARD_VALUE == recipeItemStack.getItemDamage()) && checkedItemStack.itemID == recipeItemStack.itemID)
{
test = true;
checkList[j] = true;
break;
}
}
if (!test)
{
return false;
}
}
return true;
// if(slottedBloodOrbLevel<bloodOrbLevel)
// {
// return false;
// }
//
// if(items.length<5)
// {
// return false;
// }
//
// for(int i=0;i<5;i++)
// {
// ItemStack itemStackR = this.recipe[i];
// ItemStack itemStackC = items[i];
//
// if(itemStackR==null&&itemStackC==null)
// {
// continue;
// }
//
// if(itemStackR==null||itemStackC==null)
// {
// return false;
// }
//
// Item itemR = itemStackR.getItem();
// Item itemC = itemStackC.getItem();
//
// if(itemR.equals(itemC))
// {
// continue;
// }else
// {
// return false;
// }
// }
//
// return true;
}
public ItemStack getResult()
{
return output.copy();
}
public int getAmountNeeded()
{
return this.amountNeeded;
}
public ItemStack[] getRecipe()
{
return this.recipe;
}
}

View File

@ -0,0 +1,85 @@
package WayofTime.alchemicalWizardry.common.alchemy;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.item.ItemStack;
import WayofTime.alchemicalWizardry.common.items.EnergyBattery;
public class AlchemyRecipeRegistry
{
public static List<AlchemyRecipe> recipes = new ArrayList();
public static void registerRecipe(ItemStack output, int amountNeeded, ItemStack[] recipe, int bloodOrbLevel)
{
recipes.add(new AlchemyRecipe(output, amountNeeded, recipe, bloodOrbLevel));
}
public static ItemStack getResult(ItemStack[] recipe, ItemStack bloodOrb)
{
if (bloodOrb == null)
{
return null;
}
if (!(bloodOrb.getItem() instanceof EnergyBattery))
{
return null;
}
int bloodOrbLevel = ((EnergyBattery)bloodOrb.getItem()).getOrbLevel();
for (AlchemyRecipe ar : recipes)
{
if (ar.doesRecipeMatch(recipe, bloodOrbLevel))
{
return(ar.getResult());
}
}
return null;
}
public static int getAmountNeeded(ItemStack[] recipe, ItemStack bloodOrb)
{
if (bloodOrb == null)
{
return 0;
}
if (!(bloodOrb.getItem() instanceof EnergyBattery))
{
return 0;
}
int bloodOrbLevel = ((EnergyBattery)bloodOrb.getItem()).getOrbLevel();
for (AlchemyRecipe ar : recipes)
{
if (ar.doesRecipeMatch(recipe, bloodOrbLevel))
{
return(ar.getAmountNeeded());
}
}
return 0;
}
public static ItemStack[] getRecipeForItemStack(ItemStack itemStack)
{
for (AlchemyRecipe ar: recipes)
{
ItemStack result = ar.getResult();
if (result != null)
{
if (result.isItemEqual(itemStack))
{
return ar.getRecipe();
}
}
}
return null;
}
}

View File

@ -0,0 +1,333 @@
package WayofTime.alchemicalWizardry.common.block;
import java.util.ArrayList;
import java.util.List;
import WayofTime.alchemicalWizardry.common.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.ArmourComponent;
import WayofTime.alchemicalWizardry.common.ArmourUpgrade;
import WayofTime.alchemicalWizardry.common.items.BoundArmour;
import WayofTime.alchemicalWizardry.common.tileEntity.TEAltar;
import WayofTime.alchemicalWizardry.common.tileEntity.TESocket;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
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 cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
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(int par1)
{
super(par1, Material.iron);
setHardness(2.0F);
setResistance(5.0F);
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
setUnlocalizedName("armourForge");
// TODO Auto-generated constructor stub
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister 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(AlchemicalWizardry.boundPlate.itemID, 1, 0);
break;
case 1:
list = leggingsList;
armourPiece = new ItemStack(AlchemicalWizardry.boundLeggings.itemID, 1, 0);
break;
case 2:
list = helmetList;
armourPiece = new ItemStack(AlchemicalWizardry.boundHelmet.itemID, 1, 0);
break;
case 3:
list = bootsList;
armourPiece = new ItemStack(AlchemicalWizardry.boundBoots.itemID, 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.getBlockTileEntity(x + xOff, y, z - zOff);
break;
case 2:
tileEntity = world.getBlockTileEntity(x + zOff, y, z + xOff);
break;
case 3:
tileEntity = world.getBlockTileEntity(x - xOff, y, z + zOff);
break;
case 4:
tileEntity = world.getBlockTileEntity(x - zOff, y, z - xOff);
break;
case 5:
tileEntity = world.getBlockTileEntity(x + xOff, y + zOff, z);
break;
case 6:
tileEntity = world.getBlockTileEntity(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++)
{
PacketDispatcher.sendPacketToAllAround(xCoord, yCoord, zCoord, 20, world.provider.dimensionId, TEAltar.getParticlePacket(xCoord, yCoord, zCoord, (short)1));
}
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.getBlockTileEntity(x + xOff, y, z - zOff) instanceof TESocket))
{
return false;
}
break;
case 2:
if (!(world.getBlockTileEntity(x + zOff, y, z + xOff) instanceof TESocket))
{
return false;
}
break;
case 3:
if (!(world.getBlockTileEntity(x - xOff, y, z + zOff) instanceof TESocket))
{
return false;
}
break;
case 4:
if (!(world.getBlockTileEntity(x - zOff, y, z - xOff) instanceof TESocket))
{
return false;
}
break;
case 5:
if (!(world.getBlockTileEntity(x + xOff, y + zOff, z) instanceof TESocket))
{
return false;
}
break;
case 6:
if (!(world.getBlockTileEntity(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,277 @@
package WayofTime.alchemicalWizardry.common.block;
import java.util.Random;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
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.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.common.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.PacketHandler;
import WayofTime.alchemicalWizardry.common.items.EnergyBattery;
import WayofTime.alchemicalWizardry.common.items.sigil.SigilOfHolding;
import WayofTime.alchemicalWizardry.common.tileEntity.TEAltar;
import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockAltar extends BlockContainer
{
@SideOnly(Side.CLIENT)
private static Icon topIcon;
@SideOnly(Side.CLIENT)
private static Icon sideIcon1;
@SideOnly(Side.CLIENT)
private static Icon sideIcon2;
@SideOnly(Side.CLIENT)
private static Icon bottomIcon;
public BlockAltar(int id)
{
super(id, Material.rock);
setHardness(2.0F);
setResistance(5.0F);
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
setUnlocalizedName("blockAltar");
//func_111022_d("AlchemicalWizardry:blocks");
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister 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 Icon getIcon(int side, int meta)
{
switch (side)
{
case 0:
return bottomIcon;
case 1:
return topIcon;
//case 2: return sideIcon1;
//case 3: return sideIcon1;
//case 4: return sideIcon2;
//case 5: return sideIcon2;
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)
{
TEAltar tileEntity = (TEAltar)world.getBlockTileEntity(x, y, z);
// world.scheduleBlockUpdate(x, y, z, this.blockID, 0);
if (tileEntity == null || player.isSneaking())
{
return false;
}
ItemStack playerItem = player.getCurrentEquippedItem();
if (playerItem != null)
{
if (playerItem.getItem().itemID == AlchemicalWizardry.divinationSigil.itemID)
{
if (player.worldObj.isRemote)
{
PacketDispatcher.sendPacketToServer(PacketHandler.getAltarPacket(x, y, z));
}
return true;
}
else if (playerItem.getItem().itemID == AlchemicalWizardry.sigilOfHolding.itemID)
{
ItemStack item = ((SigilOfHolding)playerItem.getItem()).getCurrentItem(playerItem);
if (item != null && item.getItem().itemID == AlchemicalWizardry.divinationSigil.itemID)
{
if (player.worldObj.isRemote)
{
PacketDispatcher.sendPacketToServer(PacketHandler.getAltarPacket(x, y, z));
}
return true;
}
}
}
if (tileEntity.getStackInSlot(0) == null && playerItem != null)
{
ItemStack newItem = playerItem.copy();
newItem.stackSize = 1;
// if(newItem.getMaxDamage()==0)
// {
// newItem.setItemDamage(0);
// }
--playerItem.stackSize;
tileEntity.setInventorySlotContents(0, newItem);
tileEntity.startCycle();
}
else if (tileEntity.getStackInSlot(0) != null && playerItem == null)
{
/**stub method
* Add the item that is in the slot to the player's inventory, and
* then set the slot to null.
*/
player.inventory.addItemStackToInventory(tileEntity.getStackInSlot(0));
tileEntity.setInventorySlotContents(0, null);
tileEntity.setActive();
}
world.markBlockForUpdate(x, y, z);
//player.openGui(AlchemicalWizardry.instance, 0, world, x, y, z);
//PacketDispatcher.sendPacketToServer(tileEntity.getDescriptionPacket());
return true;
}
@Override
public void breakBlock(World world, int x, int y, int z, int 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.getBlockTileEntity(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.itemID, 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)
{
return new TEAltar();
}
@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.getBlockTileEntity(x, y, z);
if (!tileEntity.isActive())
{
return;
}
if (rand.nextInt(3) != 0)
{
return;
}
}
// @Override
// public int isProvidingStrongPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
// {
// return 1;
// }
@Override
public boolean canProvidePower()
{
return true;
}
@Override
public int isProvidingWeakPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
{
TileEntity tile = par1IBlockAccess.getBlockTileEntity(par2, par3, par4);
if (tile instanceof TEAltar)
{
// if(tile.worldObj.isRemote)
// {
// return 0;
// }
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;
}
}

View File

@ -0,0 +1,75 @@
package WayofTime.alchemicalWizardry.common.block;
import java.util.List;
import java.util.Random;
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.IconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockBloodLightSource extends Block
{
public BlockBloodLightSource(int par1)
{
super(par1, Material.cloth);
//setCreativeTab(AlchemicalWizardry.tabBloodMagic);
this.setUnlocalizedName("blockBloodLightSource");
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister 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);
//super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
}
public int quantityDropped(Random par1Random)
{
return 0;
}
}

View File

@ -0,0 +1,144 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.common.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.tileEntity.TEConduit;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockConduit extends BlockContainer
{
@SideOnly(Side.CLIENT)
private static Icon topIcon;
@SideOnly(Side.CLIENT)
private static Icon sideIcon1;
@SideOnly(Side.CLIENT)
private static Icon sideIcon2;
@SideOnly(Side.CLIENT)
private static Icon bottomIcon;
public BlockConduit(int id)
{
super(id, Material.rock);
setHardness(2.0F);
setResistance(5.0F);
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
setUnlocalizedName("blockConduit");
//func_111022_d("AlchemicalWizardry:blocks");
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister 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 Icon getIcon(int side, int meta)
{
switch (side)
{
case 0:
return bottomIcon;
case 1:
return topIcon;
//case 2: return sideIcon1;
//case 3: return sideIcon1;
//case 4: return sideIcon2;
//case 5: return sideIcon2;
default:
return sideIcon2;
}
}
@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;
}
ForgeDirection sideClicked = ForgeDirection.getOrientation(side);
TileEntity tile = world.getBlockTileEntity(x, y, z);
if (tile instanceof TEConduit)
{
//TODO NEEDS WORK
if (((TEConduit)tile).getInputDirection().equals(sideClicked))
{
((TEConduit)tile).setInputDirection(((TEConduit)tile).getOutputDirection());
((TEConduit)tile).setOutputDirection(sideClicked);
}
else if (((TEConduit)tile).getOutputDirection().equals(sideClicked))
{
((TEConduit)tile).setOutputDirection(((TEConduit)tile).getInputDirection());
((TEConduit)tile).setInputDirection(sideClicked);
}
else
{
if (!player.isSneaking())
{
((TEConduit)tile).setOutputDirection(sideClicked);
}
else
{
((TEConduit)tile).setOutputDirection(sideClicked.getOpposite());
}
}
}
world.markBlockForUpdate(x, y, z);
return true;
}
@Override
public void breakBlock(World world, int x, int y, int z, int par5, int par6)
{
//dropItems(world, x, y, z);
super.breakBlock(world, x, y, z, par5, par6);
}
@Override
public TileEntity createNewTileEntity(World world)
{
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,103 @@
package WayofTime.alchemicalWizardry.common.block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.BlockGrass;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
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.Icon;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.common.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;
public class BlockHomHeart extends BlockContainer
{
public Icon bottomIcon;
public Icon topIcon;
public Icon sideIcon;
public BlockHomHeart(int id)
{
super(id, Material.rock);
setHardness(2.0F);
setResistance(5.0F);
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
setUnlocalizedName("blockHomHeart");
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister 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 Icon getIcon(int side, int meta)
{
switch (side)
{
case 0:
return bottomIcon;
case 1:
return topIcon;
//case 2: return sideIcon1;
//case 3: return sideIcon1;
//case 4: return sideIcon2;
//case 5: return sideIcon2;
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.getBlockTileEntity(x, y, z);
if (tileEntity == null || player.isSneaking())
{
return false;
}
BlockGrass d;
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)
{
return new TEHomHeart();
}
}

View File

@ -0,0 +1,72 @@
package WayofTime.alchemicalWizardry.common.block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
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;
import WayofTime.alchemicalWizardry.common.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;
public class BlockMasterStone extends BlockContainer
{
public BlockMasterStone(int id)
{
super(id, Material.iron);
setHardness(2.0F);
setResistance(5.0F);
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
setUnlocalizedName("blockMasterStone");
// TODO Auto-generated constructor stub
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
this.blockIcon = iconRegister.registerIcon("AlchemicalWizardry:MasterStone");
}
@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.getBlockTileEntity(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));
world.markBlockForUpdate(x, y, z);
return true;
}
@Override
public TileEntity createNewTileEntity(World world)
{
return new TEMasterStone();
}
}

View File

@ -0,0 +1,193 @@
package WayofTime.alchemicalWizardry.common.block;
import java.util.Random;
import WayofTime.alchemicalWizardry.common.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.tileEntity.TEPedestal;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
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.Icon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockPedestal extends BlockContainer
{
@SideOnly(Side.CLIENT)
private static Icon topIcon;
@SideOnly(Side.CLIENT)
private static Icon sideIcon1;
@SideOnly(Side.CLIENT)
private static Icon sideIcon2;
@SideOnly(Side.CLIENT)
private static Icon bottomIcon;
public BlockPedestal(int id)
{
super(id, Material.rock);
setHardness(2.0F);
setResistance(5.0F);
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
setUnlocalizedName("bloodPedestal");
//func_111022_d("AlchemicalWizardry:blocks");
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister 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 Icon getIcon(int side, int meta)
{
switch (side)
{
case 0:
return bottomIcon;
case 1:
return topIcon;
//case 2: return sideIcon1;
//case 3: return sideIcon1;
//case 4: return sideIcon2;
//case 5: return sideIcon2;
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.getBlockTileEntity(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)
{
/**stub method
* Add the item that is in the slot to the player's inventory, and
* then set the slot to null.
*/
player.inventory.addItemStackToInventory(tileEntity.getStackInSlot(0));
tileEntity.setInventorySlotContents(0, null);
tileEntity.setActive();
}
world.markBlockForUpdate(x, y, z);
//player.openGui(AlchemicalWizardry.instance, 0, world, x, y, z);
//PacketDispatcher.sendPacketToServer(tileEntity.getDescriptionPacket());
return true;
}
@Override
public void breakBlock(World world, int x, int y, int z, int 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.getBlockTileEntity(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.itemID, 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)
{
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,193 @@
package WayofTime.alchemicalWizardry.common.block;
import java.util.Random;
import WayofTime.alchemicalWizardry.common.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.tileEntity.TEPlinth;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
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.Icon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockPlinth extends BlockContainer
{
@SideOnly(Side.CLIENT)
private static Icon topIcon;
@SideOnly(Side.CLIENT)
private static Icon sideIcon1;
@SideOnly(Side.CLIENT)
private static Icon sideIcon2;
@SideOnly(Side.CLIENT)
private static Icon bottomIcon;
public BlockPlinth(int id)
{
super(id, Material.rock);
setHardness(2.0F);
setResistance(5.0F);
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
setUnlocalizedName("bloodPlinth");
//func_111022_d("AlchemicalWizardry:blocks");
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister 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 Icon getIcon(int side, int meta)
{
switch (side)
{
case 0:
return bottomIcon;
case 1:
return topIcon;
//case 2: return sideIcon1;
//case 3: return sideIcon1;
//case 4: return sideIcon2;
//case 5: return sideIcon2;
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.getBlockTileEntity(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)
{
/**stub method
* Add the item that is in the slot to the player's inventory, and
* then set the slot to null.
*/
player.inventory.addItemStackToInventory(tileEntity.getStackInSlot(0));
tileEntity.setInventorySlotContents(0, null);
tileEntity.setActive();
}
world.markBlockForUpdate(x, y, z);
//player.openGui(AlchemicalWizardry.instance, 0, world, x, y, z);
//PacketDispatcher.sendPacketToServer(tileEntity.getDescriptionPacket());
return true;
}
@Override
public void breakBlock(World world, int x, int y, int z, int 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.getBlockTileEntity(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.itemID, 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)
{
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,162 @@
package WayofTime.alchemicalWizardry.common.block;
import java.util.Random;
import WayofTime.alchemicalWizardry.common.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.ArmourUpgrade;
import WayofTime.alchemicalWizardry.common.tileEntity.TESocket;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
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.Icon;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockSocket extends BlockContainer
{
@SideOnly(Side.CLIENT)
private static Icon topIcon;
@SideOnly(Side.CLIENT)
private static Icon sideIcon1;
@SideOnly(Side.CLIENT)
private static Icon sideIcon2;
@SideOnly(Side.CLIENT)
private static Icon bottomIcon;
public BlockSocket(int id)
{
super(id, Material.rock);
setHardness(2.0F);
setResistance(5.0F);
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
setUnlocalizedName("bloodSocket");
//func_111022_d("AlchemicalWizardry:blocks");
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister 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 Icon getIcon(int side, int meta)
{
switch (side)
{
case 0:
return bottomIcon;
case 1:
return topIcon;
//case 2: return sideIcon1;
//case 3: return sideIcon1;
//case 4: return sideIcon2;
//case 5: return sideIcon2;
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.getBlockTileEntity(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)
{
/**stub method
* Add the item that is in the slot to the player's inventory, and
* then set the slot to null.
*/
player.inventory.addItemStackToInventory(tileEntity.getStackInSlot(0));
tileEntity.setInventorySlotContents(0, null);
tileEntity.setActive();
}
world.markBlockForUpdate(x, y, z);
//player.openGui(AlchemicalWizardry.instance, 0, world, x, y, z);
//PacketDispatcher.sendPacketToServer(tileEntity.getDescriptionPacket());
return true;
}
@Override
public void breakBlock(World world, int x, int y, int z, int 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.getBlockTileEntity(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.itemID, 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)
{
return new TESocket();
}
}

View File

@ -0,0 +1,317 @@
package WayofTime.alchemicalWizardry.common.block;
import java.util.Random;
import WayofTime.alchemicalWizardry.common.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.items.TelepositionFocus;
import WayofTime.alchemicalWizardry.common.tileEntity.TETeleposer;
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.IconRegister;
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.Icon;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockTeleposer extends BlockContainer
{
@SideOnly(Side.CLIENT)
private static Icon topIcon;
@SideOnly(Side.CLIENT)
private static Icon sideIcon1;
@SideOnly(Side.CLIENT)
private static Icon sideIcon2;
@SideOnly(Side.CLIENT)
private static Icon bottomIcon;
public BlockTeleposer(int id)
{
super(id, Material.rock);
setHardness(2.0F);
setResistance(5.0F);
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
setUnlocalizedName("bloodTeleposer");
//func_111022_d("AlchemicalWizardry:blocks");
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister 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 Icon getIcon(int side, int meta)
{
switch (side)
{
case 0:
return bottomIcon;
case 1:
return topIcon;
//case 2: return sideIcon1;
//case 3: return sideIcon1;
//case 4: return sideIcon2;
//case 5: return sideIcon2;
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.getBlockTileEntity(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);
// this.swapBlocks(world, x, y+1, z, x, y+2, z);
//
// world.markBlockForUpdate(x, y, z);
//player.openGui(AlchemicalWizardry.instance, 0, world, x, y, z);
//PacketDispatcher.sendPacketToServer(tileEntity.getDescriptionPacket());
return true;
}
@Override
public void breakBlock(World world, int x, int y, int z, int 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.getBlockTileEntity(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.itemID, 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)
{
return new TETeleposer();
}
public static boolean swapBlocks(World worldI, World worldF, int xi, int yi, int zi, int xf, int yf, int zf)
{
//TODO Fix sapling duplication glitch
TileEntity tileEntityI = worldI.getBlockTileEntity(xi, yi, zi);
TileEntity tileEntityF = worldF.getBlockTileEntity(xf, yf, zf);
TileEntity tileI;
TileEntity tileF;
// ItemStack[] inv1 = new ItemStack[0];
// ItemStack[] inv2 = new ItemStack[0];
NBTTagCompound nbttag1 = new NBTTagCompound();
NBTTagCompound nbttag2 = new NBTTagCompound();
if (tileEntityI != null)
{
//NBTTagCompound nbttag1 = new NBTTagCompound();
// tileEntityI.xCoord=xf;
// tileEntityI.yCoord=yf;
// tileEntityI.zCoord=zf;
tileEntityI.writeToNBT(nbttag1);
//tileEntityI.readFromNBT(new NBTTagCompound());
}
// if(tileEntityI instanceof IInventory)
// {
// int size = ((IInventory)tileEntityI).getSizeInventory();
// inv1 = new ItemStack[size];
// for(int i=0; i<size; i++)
// {
// inv1[i] = ((IInventory)tileEntityI).getStackInSlot(i);
// ((IInventory)tileEntityI).setInventorySlotContents(i, null);
// }
// }
if (tileEntityF != null)
{
// tileEntityF.xCoord=xi;
// tileEntityF.yCoord=yi;
// tileEntityF.zCoord=zi;
tileEntityF.writeToNBT(nbttag2);
}
// if(tileEntityF instanceof IInventory)
// {
// int size = ((IInventory)tileEntityF).getSizeInventory();
// inv2 = new ItemStack[size];
// for(int i=0; i<size; i++)
// {
// inv2[i] = ((IInventory)tileEntityF).getStackInSlot(i);
// ((IInventory)tileEntityF).setInventorySlotContents(i, null);
// }
// }
int idI = worldI.getBlockId(xi, yi, zi);
int idF = worldF.getBlockId(xf, yf, zf);
// if(ThaumcraftApi.portableHoleBlackList.contains(idI)||ThaumcraftApi.portableHoleBlackList.contains(idF))
// {
// return false;
// }
if (idI == 0 && idF == 0)
{
return false;
}
//if(Block.blocksList[idI] instanceof IPlantable || Block.blocksList[idF] instanceof IPlantable||Block.blocksList[idI] instanceof BlockMobSpawner || Block.blocksList[idF] instanceof BlockMobSpawner)
if (Block.blocksList[idI] instanceof BlockMobSpawner || Block.blocksList[idF] 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 = Block.blocksList[idF];
if (finalBlock != null)
{
TileEntity tileToSet = finalBlock.createTileEntity(worldF, metaF);
// tileToSet.xCoord = xf;
// tileToSet.yCoord = yf;
// tileToSet.zCoord = zf;
worldF.setBlockTileEntity(xf, yf, zf, tileToSet);
}
Block initialBlock = Block.blocksList[idI];
if (initialBlock != null)
{
TileEntity tileToSet = initialBlock.createTileEntity(worldI, metaI);
// tileToSet.xCoord = xi;
// tileToSet.yCoord = yi;
// tileToSet.zCoord = zi;
worldI.setBlockTileEntity(xi, yi, zi, tileToSet);
}
//TILES CLEARED
// worldF.destroyBlock(xf, yf, zf, false);
// worldI.destroyBlock(xi, yi, zi, false);
// worldI.setBlockToAir(xi, yi, zi);
// worldF.setBlockToAir(xf, yf, zf);
worldF.setBlock(xf, yf, zf, idI, metaI, 3);
if (tileEntityI != null)
{
TileEntity newTileEntityI = TileEntity.createAndLoadEntity(nbttag1);
worldF.setBlockTileEntity(xf, yf, zf, newTileEntityI);
newTileEntityI.xCoord = xf;
newTileEntityI.yCoord = yf;
newTileEntityI.zCoord = zf;
}
worldI.setBlock(xi, yi, zi, idF, metaF, 3);
if (tileEntityF != null)
{
TileEntity newTileEntityF = TileEntity.createAndLoadEntity(nbttag2);
worldI.setBlockTileEntity(xi, yi, zi, newTileEntityF);
newTileEntityF.xCoord = xi;
newTileEntityF.yCoord = yi;
newTileEntityF.zCoord = zi;
}
// if(finalBlock!=null)
// finalBlock.onNeighborBlockChange(worldI, xi, yi, zi, AlchemicalWizardry.blockTeleposer.blockID);
// if(initialBlock!=null)
// initialBlock.onNeighborBlockChange(worldF, xf, yf, zf, AlchemicalWizardry.blockTeleposer.blockID);
// tileI = worldI.getBlockTileEntity(xi, yi, zi);
// tileF = worldF.getBlockTileEntity(xf, yf, zf);
// if(tileI!=null)
// {
// tileI.readFromNBT(nbttag2);
// }
//
// if(tileF!=null)
// {
// tileF.readFromNBT(nbttag1);
// }
// if(tileI instanceof IInventory && inv2.length>0)
// {
// for(int i=0;i<((IInventory)tileI).getSizeInventory();i++)
// {
// ((IInventory)tileI).setInventorySlotContents(i, inv2[i]);
// }
// }
//
// if(tileF instanceof IInventory && inv1.length>0)
// {
// for(int i=0;i<((IInventory)tileF).getSizeInventory();i++)
// {
// ((IInventory)tileF).setInventorySlotContents(i, inv1[i]);
// }
// }
// worldI.markBlockForUpdate(xi, yi, zi);
// worldF.markBlockForUpdate(xf, yf, zf);
return true;
}
}

View File

@ -0,0 +1,183 @@
package WayofTime.alchemicalWizardry.common.block;
import java.util.List;
import java.util.Random;
import WayofTime.alchemicalWizardry.common.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.tileEntity.TEWritingTable;
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.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
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.Icon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
public class BlockWritingTable extends BlockContainer
{
@SideOnly(Side.CLIENT)
private static Icon topIcon;
@SideOnly(Side.CLIENT)
private static Icon sideIcon1;
@SideOnly(Side.CLIENT)
private static Icon sideIcon2;
@SideOnly(Side.CLIENT)
private static Icon bottomIcon;
public BlockWritingTable(int id)
{
super(id, Material.wood);
setHardness(2.0F);
setResistance(5.0F);
setUnlocalizedName("blockWritingTable");
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister 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 Icon getIcon(int side, int meta)
{
switch (side)
{
case 0:
return bottomIcon;
case 1:
return topIcon;
//case 2: return sideIcon1;
//case 3: return sideIcon1;
//case 4: return sideIcon2;
//case 5: return sideIcon2;
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.getBlockTileEntity(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, int 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.getBlockTileEntity(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.itemID, 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)
{
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,109 @@
package WayofTime.alchemicalWizardry.common.block;
import java.util.List;
import WayofTime.alchemicalWizardry.common.AlchemicalWizardry;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BloodRune extends Block
{
//private Icon bloodRuneIcon;
private Icon altarCapacityRuneIcon;
private Icon dislocationRuneIcon;
private Icon orbCapacityRuneIcon;
public BloodRune(int id)
{
super(id, Material.iron);
setUnlocalizedName("bloodRune");
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
setHardness(2.0F);
setResistance(5.0F);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister 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");
}
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;
}
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(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
if (this.blockID == AlchemicalWizardry.bloodRune.blockID)
{
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
@SideOnly(Side.CLIENT)
public Icon getIcon(int side, int meta)
{
switch (meta)
{
case 0:
return blockIcon;
case 1:
return altarCapacityRuneIcon;
case 2:
return dislocationRuneIcon;
case 3:
return this.orbCapacityRuneIcon;
default:
return blockIcon;
}
}
@Override
public int damageDropped(int metadata)
{
return metadata;
}
}

View File

@ -0,0 +1,28 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.common.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.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
public class BloodStoneBrick extends Block
{
public BloodStoneBrick(int par1)
{
super(par1, Material.iron);
setHardness(2.0F);
setResistance(5.0F);
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
setUnlocalizedName("bloodStoneBrick");
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
this.blockIcon = iconRegister.registerIcon("AlchemicalWizardry:BloodStoneBrick");
}
}

View File

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

View File

@ -0,0 +1,35 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.common.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.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
public class EmptySocket extends Block
{
public EmptySocket(int par1)
{
super(par1, Material.iron);
setHardness(2.0F);
setResistance(5.0F);
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
setUnlocalizedName("emptySocket");
// TODO Auto-generated constructor stub
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
this.blockIcon = iconRegister.registerIcon("AlchemicalWizardry:EmptySocket");
}
}

View File

@ -0,0 +1,12 @@
package WayofTime.alchemicalWizardry.common.block;
import net.minecraftforge.common.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,150 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.common.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.PacketHandler;
import cpw.mods.fml.common.network.PacketDispatcher;
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.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class ImperfectRitualStone extends Block
{
public ImperfectRitualStone(int id)
{
super(id, Material.iron);
setHardness(2.0F);
setResistance(5.0F);
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
setUnlocalizedName("imperfectRitualStone");
// TODO Auto-generated constructor stub
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister 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)
{
//ItemStack ist = player.getItemInUse();
//if (!world.isRemote)
{
int blockID = world.getBlockId(x, y + 1, z);
if (blockID == Block.waterStill.blockID)
{
if (!player.capabilities.isCreativeMode && world.isRemote)
{
PacketDispatcher.sendPacketToServer(PacketHandler.getPacket(player.getEntityName(), -5000, 0));
}
if (!world.isRemote)
{
world.addWeatherEffect(new EntityLightningBolt(world, x, y + 2, z));
// if (!player.capabilities.isCreativeMode)
// {
// PacketDispatcher.sendPacketToServer(PacketHandler.getPacket(player.getEntityName(), -5000, 0));
// }
}
world.getWorldInfo().setRaining(true);
if (world.isRemote)
{
world.setRainStrength(1.0F);
}
world.thunderingStrength = 1.0F;
world.getWorldInfo().setThunderTime(0);
world.getWorldInfo().setThundering(true);
return true;
}
else if (blockID == Block.coalBlock.blockID)
{
if (!player.capabilities.isCreativeMode && world.isRemote)
{
PacketDispatcher.sendPacketToServer(PacketHandler.getPacket(player.getEntityName(), -5000, 0));
}
//EntityFallenAngel zomb = new EntityFallenAngel(world);
EntityZombie zomb = new EntityZombie(world);
zomb.setPosition(x + 0.5, y + 2, z + 0.5);
// zomb.setCurrentItemOrArmor(4, new ItemStack(Item.helmetIron.itemID,1,0));
// zomb.setCurrentItemOrArmor(3, new ItemStack(Item.plateIron.itemID,1,0));
// zomb.setCurrentItemOrArmor(2, new ItemStack(Item.legsIron.itemID,1,0));
// zomb.setCurrentItemOrArmor(1, new ItemStack(Item.bootsIron.itemID,1,0));
//zomb.setCurrentItemOrArmor(0, new ItemStack(AlchemicalWizardry.energySword.itemID,1,0));
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));
// if (!player.capabilities.isCreativeMode)
// {
// PacketDispatcher.sendPacketToServer(PacketHandler.getPacket(player.getEntityName(), -5000, 0));
// }
}
return true;
}
else if (blockID == Block.blockLapis.blockID)
{
if (!player.capabilities.isCreativeMode && world.isRemote)
{
PacketDispatcher.sendPacketToServer(PacketHandler.getPacket(player.getEntityName(), -5000, 0));
}
if (!world.isRemote)
{
world.addWeatherEffect(new EntityLightningBolt(world, x, y + 2, z));
world.setWorldTime((world.getWorldTime() / 24000) * 24000 + 13800);
// if (!player.capabilities.isCreativeMode)
// {
// PacketDispatcher.sendPacketToServer(PacketHandler.getPacket(player.getEntityName(), -5000, 0));
// }
}
}
else if (blockID == Block.bedrock.blockID)
{
if (!player.capabilities.isCreativeMode && world.isRemote)
{
PacketDispatcher.sendPacketToServer(PacketHandler.getPacket(player.getEntityName(), -5000, 0));
}
if (!world.isRemote)
{
world.addWeatherEffect(new EntityLightningBolt(world, x, y + 2, z));
//world.setWorldTime((world.getWorldTime()/24000)*24000+13800);
// if (!player.capabilities.isCreativeMode)
// {
// PacketDispatcher.sendPacketToServer(PacketHandler.getPacket(player.getEntityName(), -5000, 0));
// }
}
player.addPotionEffect(new PotionEffect(Potion.resistance.id, 60 * 20, 1));
}
}
return false;
}
}

View File

@ -0,0 +1,28 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.common.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.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
public class LargeBloodStoneBrick extends Block
{
public LargeBloodStoneBrick(int par1)
{
super(par1, Material.iron);
setHardness(2.0F);
setResistance(5.0F);
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
setUnlocalizedName("largeBloodStoneBrick");
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
this.blockIcon = iconRegister.registerIcon("AlchemicalWizardry:LargeBloodStoneBrick");
}
}

View File

@ -0,0 +1,58 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.common.AlchemicalWizardry;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fluids.BlockFluidClassic;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class LifeEssenceBlock extends BlockFluidClassic
{
public LifeEssenceBlock(int id)
{
super(id, AlchemicalWizardry.lifeEssenceFluid, Material.water);
AlchemicalWizardry.lifeEssenceFluid.setBlockID(id);
//setCreativeTab(AlchemicalWizardry.tabBloodMagic);
}
@Override
@SideOnly(Side.CLIENT)
public Icon getIcon(int side, int meta)
{
return this.blockIcon;
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
this.blockIcon = iconRegister.registerIcon("AlchemicalWizardry:lifeEssenceStill");
this.getFluid().setIcons(blockIcon);
}
@Override
public boolean canDisplace(IBlockAccess world, int x, int y, int z)
{
if (world.getBlockMaterial(x, y, z).isLiquid())
{
return false;
}
return super.canDisplace(world, x, y, z);
}
@Override
public boolean displaceIfPossible(World world, int x, int y, int z)
{
if (world.getBlockMaterial(x, y, z).isLiquid())
{
return false;
}
return super.displaceIfPossible(world, x, y, z);
}
}

View File

@ -0,0 +1,32 @@
package WayofTime.alchemicalWizardry.common.block;
import net.minecraft.block.BlockFlowing;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.util.Icon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class LifeEssenceFlowing extends BlockFlowing
{
protected LifeEssenceFlowing(int par1)
{
super(par1, Material.water);
this.blockHardness = 100.0F;
this.setLightOpacity(3);
//this.setLightValue(10);
setCreativeTab(CreativeTabs.tabMisc);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
this.theIcon = new Icon[]
{
iconRegister.registerIcon("AlchemicalWizardry:lifeEssenceStill"),
iconRegister.registerIcon("AlchemicalWizardry:lifeEssenceFlowing")
};
}
}

View File

@ -0,0 +1,33 @@
package WayofTime.alchemicalWizardry.common.block;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.BlockStationary;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.util.Icon;
public class LifeEssenceStill extends BlockStationary
{
protected LifeEssenceStill(int par1)
{
super(par1, Material.water);
this.blockHardness = 100.0F;
this.setLightOpacity(3);
//this.setLightValue(10);
this.disableStats();
//setCreativeTab(CreativeTabs.tabMisc);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
this.theIcon = new Icon[]
{
iconRegister.registerIcon("AlchemicalWizardry:lifeEssenceStill"),
iconRegister.registerIcon("AlchemicalWizardry:lifeEssenceFlowing")
};
}
}

View File

@ -0,0 +1,120 @@
package WayofTime.alchemicalWizardry.common.block;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.common.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.items.ScribeTool;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class RitualStone extends Block
{
@SideOnly(Side.CLIENT)
private static Icon blankIcon;
@SideOnly(Side.CLIENT)
private static Icon waterStoneIcon;
@SideOnly(Side.CLIENT)
private static Icon fireStoneIcon;
@SideOnly(Side.CLIENT)
private static Icon earthStoneIcon;
@SideOnly(Side.CLIENT)
private static Icon airStoneIcon;
@SideOnly(Side.CLIENT)
private static Icon duskStoneIcon;
public RitualStone(int par1)
{
super(par1, Material.iron);
setHardness(2.0F);
setResistance(5.0F);
setUnlocalizedName("ritualStone");
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister 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 Icon 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,32 @@
package WayofTime.alchemicalWizardry.common.block;
import WayofTime.alchemicalWizardry.common.AlchemicalWizardry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
public class RuneOfSacrifice extends BloodRune
{
public RuneOfSacrifice(int id)
{
super(id);
setUnlocalizedName("runeOfSacrifice");
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
setHardness(2.0F);
setResistance(5.0F);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
this.blockIcon = iconRegister.registerIcon("AlchemicalWizardry:RuneOfSacrifice");
}
@Override
public int getRuneEffect(int metaData)
{
return 3;
}
}

View File

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

View File

@ -0,0 +1,107 @@
package WayofTime.alchemicalWizardry.common.block;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLeaves;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class SpectralBlock extends Block
{
public SpectralBlock(int par1)
{
super(par1, Material.rock);
this.setUnlocalizedName("spectralBlock");
}
// @Override
// public int tickRate(World par1World)
// {
// return 10;
// }
/**
* Ticks the block if it's been scheduled
*/
@Override
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
//if(!par1World.isRemote)
par1World.setBlockToAir(par2, par3, par4);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
this.blockIcon = iconRegister.registerIcon("AlchemicalWizardry:SpectralBlock");
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public int quantityDropped(Random par1Random)
{
return 0;
}
@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)
{
//TEAltar tileEntity = (TEAltar)world.getBlockTileEntity(x, y, z);
if (player.isSneaking())
{
return false;
}
ItemStack playerItem = player.getCurrentEquippedItem();
if (playerItem != null)
{
if (playerItem.getItem() instanceof ItemBlock)
{
world.setBlock(x, y, z, playerItem.itemID, playerItem.getItemDamage(), 3);
if (!player.capabilities.isCreativeMode)
{
playerItem.stackSize--;
}
return true;
}
else
{
return false;
}
}
return true;
}
@Override
public void onBlockAdded(World par1World, int par2, int par3, int par4)
{
par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, 100);
}
}

View File

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

View File

@ -0,0 +1,58 @@
package WayofTime.alchemicalWizardry.common.bloodAltarUpgrade;
public class AltarComponent
{
private int x;
private int y;
private int z;
private int blockID;
private int metadata;
private boolean isBloodRune;
private boolean isUpgradeSlot;
public AltarComponent(int x, int y, int z, int blockID, int metadata, boolean isBloodRune, boolean isUpgradeSlot)
{
this.x = x;
this.y = y;
this.z = z;
this.blockID = blockID;
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 int getBlockID()
{
return blockID;
}
public int getMetadata()
{
return metadata;
}
public boolean isBloodRune()
{
return isBloodRune;
}
public boolean isUpgradeSlot()
{
return isUpgradeSlot;
}
}

View File

@ -0,0 +1,93 @@
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;
public AltarUpgradeComponent()
{
speedUpgrades = 0;
efficiencyUpgrades = 0;
sacrificeUpgrades = 0;
selfSacrificeUpgrades = 0;
displacementUpgrades = 0;
altarCapacitiveUpgrades = 0;
orbCapacitiveUpgrades = 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 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;
}
}

View File

@ -0,0 +1,298 @@
package WayofTime.alchemicalWizardry.common.bloodAltarUpgrade;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.common.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.block.BloodRune;
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 = Block.blocksList[world.getBlockId(x + ac.getX(), y + ac.getY(), z + ac.getZ())];
if (!(testBlock instanceof BloodRune))
{
return false;
}
}
else
{
int blockId = world.getBlockId(x + ac.getX(), y + ac.getY(), z + ac.getZ());
int metadata = world.getBlockMetadata(x + ac.getX(), y + ac.getY(), z + ac.getZ());
if (((ac.getBlockID() != blockId) || (ac.getMetadata() != metadata)) && !(ac.getBlockID() == Block.stoneBrick.blockID && !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 = Block.blocksList[world.getBlockId(x + ac.getX(), y + ac.getY(), z + ac.getZ())];
if (!(testBlock instanceof BloodRune))
{
return false;
}
}
else
{
int blockId = world.getBlockId(x + ac.getX(), y + ac.getY(), z + ac.getZ());
int metadata = world.getBlockMetadata(x + ac.getX(), y + ac.getY(), z + ac.getZ());
if (((ac.getBlockID() != blockId) || (ac.getMetadata() != metadata)) && !(ac.getBlockID() == Block.stoneBrick.blockID && !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 = Block.blocksList[world.getBlockId(x + ac.getX(), y + ac.getY(), z + ac.getZ())];
if (!(testBlock instanceof BloodRune))
{
return false;
}
}
else
{
int blockId = world.getBlockId(x + ac.getX(), y + ac.getY(), z + ac.getZ());
int metadata = world.getBlockMetadata(x + ac.getX(), y + ac.getY(), z + ac.getZ());
if (((ac.getBlockID() != blockId) || (ac.getMetadata() != metadata)) && !(ac.getBlockID() == Block.stoneBrick.blockID && !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 = Block.blocksList[world.getBlockId(x + ac.getX(), y + ac.getY(), z + ac.getZ())];
if (!(testBlock instanceof BloodRune))
{
return false;
}
}
else
{
int blockId = world.getBlockId(x + ac.getX(), y + ac.getY(), z + ac.getZ());
int metadata = world.getBlockMetadata(x + ac.getX(), y + ac.getY(), z + ac.getZ());
if (((ac.getBlockID() != blockId) || (ac.getMetadata() != metadata)) && !(ac.getBlockID() == Block.stoneBrick.blockID && !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 = Block.blocksList[world.getBlockId(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;
}
}
}
}
}
return upgrades;
}
public static void loadAltars()
{
secondTierAltar.add(new AltarComponent(-1, -1, -1, AlchemicalWizardry.bloodRuneBlockID, 0, true, false));
secondTierAltar.add(new AltarComponent(0, -1, -1, AlchemicalWizardry.bloodRuneBlockID, 0, true, true));
secondTierAltar.add(new AltarComponent(1, -1, -1, AlchemicalWizardry.bloodRuneBlockID, 0, true, false));
secondTierAltar.add(new AltarComponent(-1, -1, 0, AlchemicalWizardry.bloodRuneBlockID, 0, true, true));
secondTierAltar.add(new AltarComponent(1, -1, 0, AlchemicalWizardry.bloodRuneBlockID, 0, true, true));
secondTierAltar.add(new AltarComponent(-1, -1, 1, AlchemicalWizardry.bloodRuneBlockID, 0, true, false));
secondTierAltar.add(new AltarComponent(0, -1, 1, AlchemicalWizardry.bloodRuneBlockID, 0, true, true));
secondTierAltar.add(new AltarComponent(1, -1, 1, AlchemicalWizardry.bloodRuneBlockID, 0, true, false));
thirdTierAltar.add(new AltarComponent(-1, -1, -1, AlchemicalWizardry.bloodRuneBlockID, 0, true, true));
thirdTierAltar.add(new AltarComponent(0, -1, -1, AlchemicalWizardry.bloodRuneBlockID, 0, true, true));
thirdTierAltar.add(new AltarComponent(1, -1, -1, AlchemicalWizardry.bloodRuneBlockID, 0, true, true));
thirdTierAltar.add(new AltarComponent(-1, -1, 0, AlchemicalWizardry.bloodRuneBlockID, 0, true, true));
thirdTierAltar.add(new AltarComponent(1, -1, 0, AlchemicalWizardry.bloodRuneBlockID, 0, true, true));
thirdTierAltar.add(new AltarComponent(-1, -1, 1, AlchemicalWizardry.bloodRuneBlockID, 0, true, true));
thirdTierAltar.add(new AltarComponent(0, -1, 1, AlchemicalWizardry.bloodRuneBlockID, 0, true, true));
thirdTierAltar.add(new AltarComponent(1, -1, 1, AlchemicalWizardry.bloodRuneBlockID, 0, true, true));
thirdTierAltar.add(new AltarComponent(-3, -1, -3, Block.stoneBrick.blockID, 0, false, false));
thirdTierAltar.add(new AltarComponent(-3, 0, -3, Block.stoneBrick.blockID, 0, false, false));
thirdTierAltar.add(new AltarComponent(3, -1, -3, Block.stoneBrick.blockID, 0, false, false));
thirdTierAltar.add(new AltarComponent(3, 0, -3, Block.stoneBrick.blockID, 0, false, false));
thirdTierAltar.add(new AltarComponent(-3, -1, 3, Block.stoneBrick.blockID, 0, false, false));
thirdTierAltar.add(new AltarComponent(-3, 0, 3, Block.stoneBrick.blockID, 0, false, false));
thirdTierAltar.add(new AltarComponent(3, -1, 3, Block.stoneBrick.blockID, 0, false, false));
thirdTierAltar.add(new AltarComponent(3, 0, 3, Block.stoneBrick.blockID, 0, false, false));
thirdTierAltar.add(new AltarComponent(-3, 1, -3, Block.glowStone.blockID, 0, false, false));
thirdTierAltar.add(new AltarComponent(3, 1, -3, Block.glowStone.blockID, 0, false, false));
thirdTierAltar.add(new AltarComponent(-3, 1, 3, Block.glowStone.blockID, 0, false, false));
thirdTierAltar.add(new AltarComponent(3, 1, 3, Block.glowStone.blockID, 0, false, false));
for (int i = -2; i <= 2; i++)
{
thirdTierAltar.add(new AltarComponent(3, -2, i, AlchemicalWizardry.bloodRuneBlockID, 0, true, true));
thirdTierAltar.add(new AltarComponent(-3, -2, i, AlchemicalWizardry.bloodRuneBlockID, 0, true, true));
thirdTierAltar.add(new AltarComponent(i, -2, 3, AlchemicalWizardry.bloodRuneBlockID, 0, true, true));
thirdTierAltar.add(new AltarComponent(i, -2, -3, AlchemicalWizardry.bloodRuneBlockID, 0, true, true));
}
fourthTierAltar.addAll(thirdTierAltar);
for (int i = -3; i <= 3; i++)
{
fourthTierAltar.add(new AltarComponent(5, -3, i, AlchemicalWizardry.bloodRuneBlockID, 0, true, true));
fourthTierAltar.add(new AltarComponent(-5, -3, i, AlchemicalWizardry.bloodRuneBlockID, 0, true, true));
fourthTierAltar.add(new AltarComponent(i, -3, 5, AlchemicalWizardry.bloodRuneBlockID, 0, true, true));
fourthTierAltar.add(new AltarComponent(i, -3, -5, AlchemicalWizardry.bloodRuneBlockID, 0, true, true));
}
for (int i = -2; i <= 1; i++)
{
fourthTierAltar.add(new AltarComponent(5, i, 5, Block.stoneBrick.blockID, 0, false, false));
fourthTierAltar.add(new AltarComponent(5, i, -5, Block.stoneBrick.blockID, 0, false, false));
fourthTierAltar.add(new AltarComponent(-5, i, -5, Block.stoneBrick.blockID, 0, false, false));
fourthTierAltar.add(new AltarComponent(-5, i, 5, Block.stoneBrick.blockID, 0, false, false));
}
fourthTierAltar.add(new AltarComponent(5, 2, 5, AlchemicalWizardry.largeBloodStoneBrick.blockID, 0, false, false));
fourthTierAltar.add(new AltarComponent(5, 2, -5, AlchemicalWizardry.largeBloodStoneBrick.blockID, 0, false, false));
fourthTierAltar.add(new AltarComponent(-5, 2, -5, AlchemicalWizardry.largeBloodStoneBrick.blockID, 0, false, false));
fourthTierAltar.add(new AltarComponent(-5, 2, 5, AlchemicalWizardry.largeBloodStoneBrick.blockID, 0, false, false));
fifthTierAltar.addAll(fourthTierAltar);
fifthTierAltar.add(new AltarComponent(-8, -3, 8, Block.beacon.blockID, 0, false, false));
fifthTierAltar.add(new AltarComponent(-8, -3, -8, Block.beacon.blockID, 0, false, false));
fifthTierAltar.add(new AltarComponent(8, -3, 8, Block.beacon.blockID, 0, false, false));
fifthTierAltar.add(new AltarComponent(8, -3, 8, Block.beacon.blockID, 0, false, false));
for (int i = -6; i <= 6; i++)
{
fifthTierAltar.add(new AltarComponent(8, -4, i, AlchemicalWizardry.bloodRuneBlockID, 0, true, true));
fifthTierAltar.add(new AltarComponent(-8, -4, i, AlchemicalWizardry.bloodRuneBlockID, 0, true, true));
fifthTierAltar.add(new AltarComponent(i, -4, 8, AlchemicalWizardry.bloodRuneBlockID, 0, true, true));
fifthTierAltar.add(new AltarComponent(i, -4, -8, AlchemicalWizardry.bloodRuneBlockID, 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,501 @@
package WayofTime.alchemicalWizardry.common.entity.mob;
import WayofTime.alchemicalWizardry.common.AlchemicalWizardry;
import net.minecraft.block.BlockColored;
import net.minecraft.client.model.ModelIronGolem;
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.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.passive.EntityTameable;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.Item;
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(3, new EntityAILeapAtTarget(this, 0.4F));
this.tasks.addTask(2, new EntityAIAttackOnCollide(this, 1.0D, true));
this.tasks.addTask(3, this.aiSit);
this.tasks.addTask(5, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F));
//this.tasks.addTask(6, new EntityAIMate(this, 1.0D));
this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
//this.tasks.addTask(8, new EntityAIBeg(this, 8.0F));
this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
this.tasks.addTask(9, 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 EntityAITargetNonTamed(this, EntitySheep.class, 200, false));
this.setTamed(false);
attackTimer = 0;
//this.isImmuneToFire = true;
}
@Override
protected void applyEntityAttributes()
{
super.applyEntityAttributes();
//This line affects the speed of the monster
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setAttribute(0.20000001192092896D);
//My guess is that this will alter the max health
if (this.isTamed())
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(this.maxTamedHealth);
}
else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(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("CollarColor", (byte)this.getCollarColor());
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"));
if (par1NBTTagCompound.hasKey("CollarColor"))
{
this.setCollarColor(par1NBTTagCompound.getByte("CollarColor"));
}
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).setAttribute(this.maxTamedHealth);
}
else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(this.maxUntamedHealth);
}
}
/**
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
*/
public boolean interact(EntityPlayer par1EntityPlayer)
{
ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
if (this.isTamed())
{
if (itemstack != null)
{
if (Item.itemsList[itemstack.itemID] instanceof ItemFood)
{
ItemFood itemfood = (ItemFood)Item.itemsList[itemstack.itemID];
if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < this.maxTamedHealth)
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
this.heal((float)itemfood.getHealAmount());
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack)null);
}
return true;
}
}
}
if (par1EntityPlayer.getCommandSenderName().equalsIgnoreCase(this.getOwnerName()) && !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.itemID == AlchemicalWizardry.weakBloodOrb.itemID && !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.setOwner(par1EntityPlayer.getCommandSenderName());
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 EntityBileDemon)
{
EntityBileDemon entitywolf = (EntityBileDemon)par1EntityLivingBase;
if (entitywolf.isTamed() && entitywolf.func_130012_q() == 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,555 @@
package WayofTime.alchemicalWizardry.common.entity.mob;
import java.util.Calendar;
import java.util.UUID;
import WayofTime.alchemicalWizardry.common.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.EntityAITargetAggro;
import WayofTime.alchemicalWizardry.common.entity.projectile.HolyProjectile;
import cpw.mods.fml.common.network.Player;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockColored;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.EntityLivingData;
import net.minecraft.entity.EntityOwnable;
import net.minecraft.entity.EnumCreatureAttribute;
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.EntityAIBeg;
import net.minecraft.entity.ai.EntityAIBreakDoor;
import net.minecraft.entity.ai.EntityAIFleeSun;
import net.minecraft.entity.ai.EntityAIFollowOwner;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAILeapAtTarget;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAIMate;
import net.minecraft.entity.ai.EntityAIMoveThroughVillage;
import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAIOwnerHurtByTarget;
import net.minecraft.entity.ai.EntityAIOwnerHurtTarget;
import net.minecraft.entity.ai.EntityAIPanic;
import net.minecraft.entity.ai.EntityAIRestrictSun;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAITargetNonTamed;
import net.minecraft.entity.ai.EntityAITempt;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.ai.attributes.Attribute;
import net.minecraft.entity.ai.attributes.AttributeInstance;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.ai.attributes.RangedAttribute;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityGhast;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.entity.passive.EntityTameable;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.Item;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.pathfinding.PathEntity;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.stats.AchievementList;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.WorldProviderHell;
public class EntityBoulderFist extends EntityDemon
{
//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 = 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 EntityAIMate(this, 1.0D));
this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
//this.tasks.addTask(8, new EntityAIBeg(this, 8.0F));
this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
this.tasks.addTask(9, 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.targetTasks.addTask(4, new EntityAITargetNonTamed(this, EntitySheep.class, 200, 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).setAttribute(0.30000001192092896D);
//My guess is that this will alter the max health
if (this.isTamed())
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(this.maxTamedHealth);
}
else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(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("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"));
if (par1NBTTagCompound.hasKey("CollarColor"))
{
this.setCollarColor(par1NBTTagCompound.getByte("CollarColor"));
}
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).setAttribute(this.maxTamedHealth);
}
else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(this.maxUntamedHealth);
}
}
/**
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
*/
public boolean interact(EntityPlayer par1EntityPlayer)
{
ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
if (this.isTamed())
{
if (itemstack != null)
{
if (Item.itemsList[itemstack.itemID] instanceof ItemFood)
{
ItemFood itemfood = (ItemFood)Item.itemsList[itemstack.itemID];
if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < this.maxTamedHealth)
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
this.heal((float)itemfood.getHealAmount());
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack)null);
}
return true;
}
}
}
if (par1EntityPlayer.getCommandSenderName().equalsIgnoreCase(this.getOwnerName()) && !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.itemID == AlchemicalWizardry.weakBloodOrb.itemID && !this.isAngry() && !this.isAggro())
{
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.setOwner(par1EntityPlayer.getCommandSenderName());
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 EntityBoulderFist)
{
EntityBoulderFist entitywolf = (EntityBoulderFist)par1EntityLivingBase;
if (entitywolf.isTamed() && entitywolf.func_130012_q() == 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,95 @@
package WayofTime.alchemicalWizardry.common.entity.mob;
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.ChatMessageComponent;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.common.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.IDemon;
import WayofTime.alchemicalWizardry.common.items.DemonPlacer;
public class EntityDemon extends EntityTameable implements IDemon
{
private boolean isAggro;
private int demonID;
public EntityDemon(World par1World, int 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(AlchemicalWizardry.demonPlacer, 1, this.getDemonID());
DemonPlacer.setOwnerName(drop, this.getOwnerName());
if (this.hasCustomNameTag())
{
drop.setItemName(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)
{
ChatMessageComponent chatmessagecomponent = new ChatMessageComponent();
if (isSitting)
{
chatmessagecomponent.addText("I will stay here for now, Master.");
}
else
{
chatmessagecomponent.addText("I shall follow and protect you!");
}
owner.sendChatToPlayer(chatmessagecomponent);
}
}
public int getDemonID()
{
return this.demonID;
}
}

View File

@ -0,0 +1,28 @@
package WayofTime.alchemicalWizardry.common.entity.mob;
import WayofTime.alchemicalWizardry.common.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,771 @@
package WayofTime.alchemicalWizardry.common.entity.mob;
import java.util.List;
import WayofTime.alchemicalWizardry.common.AlchemicalWizardry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockColored;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
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.item.EntityItem;
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.entity.projectile.EntityLargeFireball;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.pathfinding.PathEntity;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
public class EntityElemental extends EntityDemon
{
//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 = 100.0F;
public EntityElemental(World par1World, int demonID)
{
super(par1World, demonID);
this.setSize(0.5F, 1.0F);
this.setAggro(false);
//this.targetTasks.addTask(4, new EntityAITargetNonTamed(this, EntitySheep.class, 200, false));
this.setTamed(false);
if (par1World != null && !par1World.isRemote)
{
this.setCombatTask();
}
//this.isImmuneToFire = true;
}
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. */
//private int explosionStrength = 1;
//
// private int heightOffsetUpdateTime;
// private float heightOffset = 0.5F;
// private int field_70846_g;
protected void dropFewItems(boolean par1, int par2)
{
if (worldObj.rand.nextFloat() < (1 - Math.pow(0.6f, par2 + 1)))
{
this.entityDropItem(new ItemStack(AlchemicalWizardry.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;
int i = this.worldObj.getBlockId(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.boundingBox.minY) - 1, MathHelper.floor_double(this.posZ));
if (i > 0)
{
f2 = Block.blocksList[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;
int j = this.worldObj.getBlockId(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.boundingBox.minY) - 1, MathHelper.floor_double(this.posZ));
if (j > 0)
{
f2 = Block.blocksList[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.worldObj.isRemote && this.worldObj.difficultySetting == 0)
// {
// this.setDead();
// }
//this.despawnEntity();
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)
{
// if (this.attackCounter == 10)
// {
// this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1007, (int)this.posX, (int)this.posY, (int)this.posZ, 0);
// }
++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);
par1NBTTagCompound.setBoolean("Angry", this.isAngry());
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"));
if (par1NBTTagCompound.hasKey("CollarColor"))
{
this.setCollarColor(par1NBTTagCompound.getByte("CollarColor"));
}
this.setCombatTask();
}
@Override
protected void applyEntityAttributes()
{
super.applyEntityAttributes();
//This line affects the speed of the monster
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setAttribute(0.30000001192092896D);
//My guess is that this will alter the max health
if (this.isTamed())
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(this.maxTamedHealth);
}
else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(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 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(20, new Byte((byte)BlockColored.getBlockFromDye(1)));
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).setAttribute(this.maxTamedHealth);
}
else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(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;
//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;
}
@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.func_130012_q() == par2EntityLivingBase)
{
return false;
}
}
return par1EntityLivingBase instanceof EntityPlayer && par2EntityLivingBase instanceof EntityPlayer && !((EntityPlayer)par2EntityLivingBase).canAttackPlayer((EntityPlayer)par1EntityLivingBase) ? false : !(par1EntityLivingBase instanceof EntityHorse) || !((EntityHorse)par1EntityLivingBase).isTame();
//return par1EntityLivingBase instanceof EntityPlayer && par2EntityLivingBase instanceof EntityPlayer && !((EntityPlayer)par2EntityLivingBase).func_96122_a((EntityPlayer)par1EntityLivingBase) ? false : !(par1EntityLivingBase instanceof EntityHorse) || !((EntityHorse)par1EntityLivingBase).func_110248_bS();
}
else
{
return false;
}
}
public EntityAgeable createChild(EntityAgeable par1EntityAgeable)
{
return this.spawnBabyAnimal(par1EntityAgeable);
}
/**
* 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);
}
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() //TODO
{
return 10;
}
}

View File

@ -0,0 +1,555 @@
package WayofTime.alchemicalWizardry.common.entity.mob;
import java.util.Calendar;
import java.util.UUID;
import WayofTime.alchemicalWizardry.common.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.EntityAITargetAggro;
import WayofTime.alchemicalWizardry.common.entity.projectile.HolyProjectile;
import cpw.mods.fml.common.network.Player;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockColored;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.EntityLivingData;
import net.minecraft.entity.EntityOwnable;
import net.minecraft.entity.EnumCreatureAttribute;
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.EntityAIBeg;
import net.minecraft.entity.ai.EntityAIBreakDoor;
import net.minecraft.entity.ai.EntityAIFleeSun;
import net.minecraft.entity.ai.EntityAIFollowOwner;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAILeapAtTarget;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAIMate;
import net.minecraft.entity.ai.EntityAIMoveThroughVillage;
import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAIOwnerHurtByTarget;
import net.minecraft.entity.ai.EntityAIOwnerHurtTarget;
import net.minecraft.entity.ai.EntityAIPanic;
import net.minecraft.entity.ai.EntityAIRestrictSun;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAITargetNonTamed;
import net.minecraft.entity.ai.EntityAITempt;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.ai.attributes.Attribute;
import net.minecraft.entity.ai.attributes.AttributeInstance;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.ai.attributes.RangedAttribute;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityGhast;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.entity.passive.EntityTameable;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.Item;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.pathfinding.PathEntity;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.stats.AchievementList;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.WorldProviderHell;
public class EntityFallenAngel extends EntityDemon implements IRangedAttackMob, Player
{
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 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 EntityAIMate(this, 1.0D));
this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
//this.tasks.addTask(8, new EntityAIBeg(this, 8.0F));
this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
this.tasks.addTask(9, 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.targetTasks.addTask(4, new EntityAITargetNonTamed(this, EntitySheep.class, 200, 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).setAttribute(0.30000001192092896D);
//My guess is that this will alter the max health
if (this.isTamed())
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(this.maxTamedHealth);
}
else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(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("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"));
if (par1NBTTagCompound.hasKey("CollarColor"))
{
this.setCollarColor(par1NBTTagCompound.getByte("CollarColor"));
}
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).setAttribute(this.maxTamedHealth);
}
else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(this.maxUntamedHealth);
}
}
/**
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
*/
public boolean interact(EntityPlayer par1EntityPlayer)
{
ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
if (this.isTamed())
{
if (itemstack != null)
{
if (Item.itemsList[itemstack.itemID] instanceof ItemFood)
{
ItemFood itemfood = (ItemFood)Item.itemsList[itemstack.itemID];
if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < this.maxTamedHealth)
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
this.heal((float)itemfood.getHealAmount());
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack)null);
}
return true;
}
}
}
if (par1EntityPlayer.getCommandSenderName().equalsIgnoreCase(this.getOwnerName()) && !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.itemID == AlchemicalWizardry.weakBloodOrb.itemID && !this.isAngry() && !this.isAggro())
{
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.setOwner(par1EntityPlayer.getCommandSenderName());
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.func_130012_q() == 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,29 @@
package WayofTime.alchemicalWizardry.common.entity.mob;
import WayofTime.alchemicalWizardry.common.AlchemicalWizardry;
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;
import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.common.network.Player;
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,31 @@
package WayofTime.alchemicalWizardry.common.entity.mob;
import WayofTime.alchemicalWizardry.common.AlchemicalWizardry;
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.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.common.network.Player;
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,534 @@
package WayofTime.alchemicalWizardry.common.entity.mob;
import WayofTime.alchemicalWizardry.common.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.EntityAITargetAggro;
import WayofTime.alchemicalWizardry.common.entity.projectile.IceProjectile;
import net.minecraft.block.Block;
import net.minecraft.block.BlockColored;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityAgeable;
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.passive.EntityWolf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.Item;
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 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.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 EntityAIMate(this, 1.0D));
this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
//this.tasks.addTask(8, new EntityAIBeg(this, 8.0F));
this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
this.tasks.addTask(9, 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.targetTasks.addTask(4, new EntityAITargetNonTamed(this, EntitySheep.class, 200, 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).setAttribute(0.40000001192092896D);
//My guess is that this will alter the max health
if (this.isTamed())
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(this.maxTamedHealth);
}
else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(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("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"));
if (par1NBTTagCompound.hasKey("CollarColor"))
{
this.setCollarColor(par1NBTTagCompound.getByte("CollarColor"));
}
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;
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)
{
int blockID = worldObj.getBlockId((int)posX + i, (int)posY + j, (int)posZ + k);
if (blockID == Block.waterStill.blockID || blockID == Block.waterMoving.blockID)
{
worldObj.setBlock((int)posX + i, (int)posY + j, (int)posZ + k, Block.ice.blockID);
}
}
}
}
}
}
/**
* 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).setAttribute(this.maxTamedHealth);
}
else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(this.maxUntamedHealth);
}
}
/**
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
*/
public boolean interact(EntityPlayer par1EntityPlayer)
{
ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
if (this.isTamed())
{
if (itemstack != null)
{
if (Item.itemsList[itemstack.itemID] instanceof ItemFood)
{
ItemFood itemfood = (ItemFood)Item.itemsList[itemstack.itemID];
if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < this.maxTamedHealth)
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
this.heal((float)itemfood.getHealAmount());
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack)null);
}
return true;
}
}
}
if (par1EntityPlayer.getCommandSenderName().equalsIgnoreCase(this.getOwnerName()) && !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.itemID == AlchemicalWizardry.weakBloodOrb.itemID && !this.isAngry() && !this.isAggro())
{
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.setOwner(par1EntityPlayer.getCommandSenderName());
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 EntityIceDemon)
{
EntityIceDemon entitywolf = (EntityIceDemon)par1EntityLivingBase;
if (entitywolf.isTamed() && entitywolf.func_130012_q() == 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,512 @@
package WayofTime.alchemicalWizardry.common.entity.mob;
import WayofTime.alchemicalWizardry.common.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.EntityAITargetAggro;
import net.minecraft.block.BlockColored;
import net.minecraft.client.model.ModelIronGolem;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityAgeable;
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.EntityAITargetNonTamed;
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.passive.EntitySheep;
import net.minecraft.entity.passive.EntityTameable;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.Item;
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;
import cpw.mods.fml.common.network.Player;
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(3, new EntityAILeapAtTarget(this, 0.4F));
this.tasks.addTask(2, new EntityAIAttackOnCollide(this, 1.0D, true));
this.tasks.addTask(3, this.aiSit);
this.tasks.addTask(5, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F));
//this.tasks.addTask(6, new EntityAIMate(this, 1.0D));
this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
//this.tasks.addTask(8, new EntityAIBeg(this, 8.0F));
this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
this.tasks.addTask(9, 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;
//isAggro = false;
//this.isImmuneToFire = true;
}
@Override
protected void applyEntityAttributes()
{
super.applyEntityAttributes();
//This line affects the speed of the monster
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setAttribute(0.30000001192092896D);
//My guess is that this will alter the max health
if (this.isTamed())
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(this.maxTamedHealth);
}
else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(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("CollarColor", (byte)this.getCollarColor());
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"));
if (par1NBTTagCompound.hasKey("CollarColor"))
{
this.setCollarColor(par1NBTTagCompound.getByte("CollarColor"));
}
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).setAttribute(this.maxTamedHealth);
}
else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(this.maxUntamedHealth);
}
}
/**
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
*/
public boolean interact(EntityPlayer par1EntityPlayer)
{
ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
if (this.isTamed())
{
if (itemstack != null)
{
if (Item.itemsList[itemstack.itemID] instanceof ItemFood)
{
ItemFood itemfood = (ItemFood)Item.itemsList[itemstack.itemID];
if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectInt(18) < this.maxTamedHealth)
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
this.heal((float)itemfood.getHealAmount());
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack)null);
}
return true;
}
}
}
if (par1EntityPlayer.getCommandSenderName().equalsIgnoreCase(this.getOwnerName()) && !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.itemID == AlchemicalWizardry.weakBloodOrb.itemID && !this.isAngry() && !this.isAggro())
{
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.setOwner(par1EntityPlayer.getCommandSenderName());
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 EntityLowerGuardian)
{
EntityLowerGuardian entitywolf = (EntityLowerGuardian)par1EntityLivingBase;
if (entitywolf.isTamed() && entitywolf.func_130012_q() == 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,513 @@
package WayofTime.alchemicalWizardry.common.entity.mob;
import WayofTime.alchemicalWizardry.common.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.EntityAITargetAggro;
import WayofTime.alchemicalWizardry.common.entity.projectile.HolyProjectile;
import net.minecraft.block.BlockColored;
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.EntityAIAttackOnCollide;
import net.minecraft.entity.ai.EntityAIFollowOwner;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAILeapAtTarget;
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.passive.EntityWolf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.Item;
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 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 = 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 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 EntityAIMate(this, 1.0D));
this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
//this.tasks.addTask(8, new EntityAIBeg(this, 8.0F));
this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
this.tasks.addTask(9, 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.targetTasks.addTask(4, new EntityAITargetNonTamed(this, EntitySheep.class, 200, 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).setAttribute(0.30000001192092896D);
//My guess is that this will alter the max health
if (this.isTamed())
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(this.maxTamedHealth);
}
else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(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("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"));
if (par1NBTTagCompound.hasKey("CollarColor"))
{
this.setCollarColor(par1NBTTagCompound.getByte("CollarColor"));
}
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).setAttribute(this.maxTamedHealth);
}
else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(this.maxUntamedHealth);
}
}
/**
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
*/
public boolean interact(EntityPlayer par1EntityPlayer)
{
ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
if (this.isTamed())
{
if (itemstack != null)
{
if (Item.itemsList[itemstack.itemID] instanceof ItemFood)
{
ItemFood itemfood = (ItemFood)Item.itemsList[itemstack.itemID];
if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < this.maxTamedHealth)
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
this.heal((float)itemfood.getHealAmount());
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack)null);
}
return true;
}
}
}
if (par1EntityPlayer.getCommandSenderName().equalsIgnoreCase(this.getOwnerName()) && !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.itemID == AlchemicalWizardry.weakBloodOrb.itemID && !this.isAngry() && !this.isAggro())
{
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.setOwner(par1EntityPlayer.getCommandSenderName());
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 EntityBoulderFist)
{
EntityBoulderFist entitywolf = (EntityBoulderFist)par1EntityLivingBase;
if (entitywolf.isTamed() && entitywolf.func_130012_q() == 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.common.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,515 @@
package WayofTime.alchemicalWizardry.common.entity.mob;
import WayofTime.alchemicalWizardry.common.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.EntityAITargetAggro;
import WayofTime.alchemicalWizardry.common.entity.projectile.MudProjectile;
import net.minecraft.block.BlockColored;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityAgeable;
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.passive.EntityTameable;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.Item;
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;
import cpw.mods.fml.common.network.Player;
public class EntitySmallEarthGolem extends EntityDemon implements IRangedAttackMob, Player
{
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 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 EntityAIMate(this, 1.0D));
this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
//this.tasks.addTask(8, new EntityAIBeg(this, 8.0F));
this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
this.tasks.addTask(9, 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.targetTasks.addTask(4, new EntityAITargetNonTamed(this, EntitySheep.class, 200, 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).setAttribute(0.40000001192092896D);
//My guess is that this will alter the max health
if (this.isTamed())
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(this.maxTamedHealth);
}
else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(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("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"));
if (par1NBTTagCompound.hasKey("CollarColor"))
{
this.setCollarColor(par1NBTTagCompound.getByte("CollarColor"));
}
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).setAttribute(this.maxTamedHealth);
}
else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(this.maxUntamedHealth);
}
}
/**
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
*/
public boolean interact(EntityPlayer par1EntityPlayer)
{
ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
if (this.isTamed())
{
if (itemstack != null)
{
if (Item.itemsList[itemstack.itemID] instanceof ItemFood)
{
ItemFood itemfood = (ItemFood)Item.itemsList[itemstack.itemID];
if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < this.maxTamedHealth)
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
this.heal((float)itemfood.getHealAmount());
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack)null);
}
return true;
}
}
}
if (par1EntityPlayer.getCommandSenderName().equalsIgnoreCase(this.getOwnerName()) && !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.itemID == AlchemicalWizardry.weakBloodOrb.itemID && !this.isAngry() && !this.isAggro())
{
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.setOwner(par1EntityPlayer.getCommandSenderName());
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 EntitySmallEarthGolem)
{
EntitySmallEarthGolem entitywolf = (EntitySmallEarthGolem)par1EntityLivingBase;
if (entitywolf.isTamed() && entitywolf.func_130012_q() == 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.common.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,516 @@
package WayofTime.alchemicalWizardry.common.entity.mob;
import WayofTime.alchemicalWizardry.common.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.EntityAITargetAggro;
import WayofTime.alchemicalWizardry.common.entity.projectile.FireProjectile;
import net.minecraft.block.BlockColored;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityAgeable;
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.EntityBlaze;
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.EntityTameable;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.Item;
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;
import cpw.mods.fml.common.network.Player;
public class EntityWingedFireDemon extends EntityDemon implements IRangedAttackMob, Player
{
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 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 EntityAIMate(this, 1.0D));
this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
//this.tasks.addTask(8, new EntityAIBeg(this, 8.0F));
this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
this.tasks.addTask(9, 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.targetTasks.addTask(4, new EntityAITargetNonTamed(this, EntitySheep.class, 200, 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).setAttribute(0.30000001192092896D);
//My guess is that this will alter the max health
if (this.isTamed())
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(this.maxTamedHealth);
}
else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(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("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"));
if (par1NBTTagCompound.hasKey("CollarColor"))
{
this.setCollarColor(par1NBTTagCompound.getByte("CollarColor"));
}
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).setAttribute(this.maxTamedHealth);
}
else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(this.maxUntamedHealth);
}
}
/**
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
*/
public boolean interact(EntityPlayer par1EntityPlayer)
{
ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
if (this.isTamed())
{
if (itemstack != null)
{
if (Item.itemsList[itemstack.itemID] instanceof ItemFood)
{
ItemFood itemfood = (ItemFood)Item.itemsList[itemstack.itemID];
if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < this.maxTamedHealth)
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
this.heal((float)itemfood.getHealAmount());
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack)null);
}
return true;
}
}
}
if (par1EntityPlayer.getCommandSenderName().equalsIgnoreCase(this.getOwnerName()) && !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.itemID == AlchemicalWizardry.weakBloodOrb.itemID && !this.isAngry() && !this.isAggro())
{
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.setOwner(par1EntityPlayer.getCommandSenderName());
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 EntityWingedFireDemon)
{
EntityWingedFireDemon entitywolf = (EntityWingedFireDemon)par1EntityLivingBase;
if (entitywolf.isTamed() && entitywolf.func_130012_q() == 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,513 @@
package WayofTime.alchemicalWizardry.common.entity.projectile;
import java.util.Iterator;
import java.util.List;
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.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumMovingObjectType;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.common.network.Player;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
//Shamelessly ripped off from x3n0ph0b3
public class EnergyBlastProjectile extends Entity implements IProjectile
{
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);
}
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;
}
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);
}
int var16 = worldObj.getBlockId(xTile, yTile, zTile);
if (var16 > 0)
{
Block.blocksList[var16].setBlockBoundsBasedOnState(worldObj, xTile, yTile, zTile);
AxisAlignedBB var2 = Block.blocksList[var16].getCollisionBoundingBoxFromPool(worldObj, xTile, yTile, zTile);
if (var2 != null && var2.isVecInside(worldObj.getWorldVec3Pool().getVecFromPool(posX, posY, posZ)))
{
inGround = true;
}
}
if (inGround)
{
int var18 = worldObj.getBlockId(xTile, yTile, zTile);
int var19 = worldObj.getBlockMetadata(xTile, yTile, zTile);
if (var18 == inTile && var19 == inData)
{
// this.groundImpact();
// this.setDead();
}
}
else
{
++ticksInAir;
if (ticksInAir > 1 && ticksInAir < 3)
{
//worldObj.spawnParticle("flame", posX + smallGauss(0.1D), posY + smallGauss(0.1D), posZ + smallGauss(0.1D), 0D, 0D, 0D);
for (int particles = 0; particles < 3; particles++)
{
this.doFiringParticles();
}
}
Vec3 var17 = worldObj.getWorldVec3Pool().getVecFromPool(posX, posY, posZ);
Vec3 var3 = worldObj.getWorldVec3Pool().getVecFromPool(posX + motionX, posY + motionY, posZ + motionZ);
MovingObjectPosition var4 = worldObj.rayTraceBlocks_do_do(var17, var3, false, true);
var17 = worldObj.getWorldVec3Pool().getVecFromPool(posX, posY, posZ);
var3 = worldObj.getWorldVec3Pool().getVecFromPool(posX + motionX, posY + motionY, posZ + motionZ);
if (var4 != null)
{
var3 = worldObj.getWorldVec3Pool().getVecFromPool(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);
this.doBlockCollisions();
}
}
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 == EnumMovingObjectType.ENTITY && mop.entityHit != null)
{
if (mop.entityHit == shootingEntity)
{
return;
}
this.onImpact(mop.entityHit);
}
else if (mop.typeOfHit == EnumMovingObjectType.TILE)
{
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
{
//doDamage(8 + d6(), mop);
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;
}
}

View File

@ -0,0 +1,141 @@
package WayofTime.alchemicalWizardry.common.entity.projectile;
import WayofTime.alchemicalWizardry.common.AlchemicalWizardry;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.potion.Potion;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumMovingObjectType;
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 == EnumMovingObjectType.ENTITY && mop.entityHit != null)
{
if (mop.entityHit == shootingEntity)
{
return;
}
this.onImpact(mop.entityHit);
}
else if (mop.typeOfHit == EnumMovingObjectType.TILE)
{
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, AlchemicalWizardry.blockBloodLight.blockID);
}
if (sideHit == 1 && this.worldObj.isAirBlock(blockX, blockY + 1, blockZ))
{
this.worldObj.setBlock(blockX, blockY + 1, blockZ, AlchemicalWizardry.blockBloodLight.blockID);
}
if (sideHit == 2 && this.worldObj.isAirBlock(blockX, blockY, blockZ - 1))
{
this.worldObj.setBlock(blockX, blockY, blockZ - 1 , AlchemicalWizardry.blockBloodLight.blockID);
}
if (sideHit == 3 && this.worldObj.isAirBlock(blockX, blockY, blockZ + 1))
{
this.worldObj.setBlock(blockX, blockY, blockZ + 1 , AlchemicalWizardry.blockBloodLight.blockID);
}
if (sideHit == 4 && this.worldObj.isAirBlock(blockX - 1, blockY, blockZ))
{
this.worldObj.setBlock(blockX - 1, blockY, blockZ, AlchemicalWizardry.blockBloodLight.blockID);
}
if (sideHit == 5 && this.worldObj.isAirBlock(blockX + 1, blockY, blockZ))
{
this.worldObj.setBlock(blockX + 1, blockY, blockZ, AlchemicalWizardry.blockBloodLight.blockID);
}
//worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float)(0.1), true);
}
this.setDead();
}
@Override
public void onImpact(Entity mop)
{
if (mop == shootingEntity && ticksInAir > 3)
{
shootingEntity.attackEntityFrom(DamageSource.causeMobDamage(shootingEntity), 1);
this.setDead();
}
else
{
//doDamage(8 + d6(), mop);
if (mop instanceof EntityLivingBase)
{
//((EntityLivingBase)mop).addPotionEffect(new PotionEffect(Potion.weakness.id, 60,2));
((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;
}
}
//worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float)(0.1), true);
}
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();
}
}

View File

@ -0,0 +1,108 @@
package WayofTime.alchemicalWizardry.common.entity.projectile;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumMovingObjectType;
import net.minecraft.util.MathHelper;
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 == EnumMovingObjectType.ENTITY && mop.entityHit != null)
{
if (mop.entityHit == shootingEntity)
{
return;
}
this.onImpact(mop.entityHit);
}
else if (mop.typeOfHit == EnumMovingObjectType.TILE)
{
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
{
//doDamage(8 + d6(), mop);
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,514 @@
package WayofTime.alchemicalWizardry.common.entity.projectile;
import java.util.Iterator;
import java.util.List;
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.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumMovingObjectType;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
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()
{
if (ticksInAir > 600)
{
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);
}
int var16 = worldObj.getBlockId(xTile, yTile, zTile);
if (var16 > 0)
{
Block.blocksList[var16].setBlockBoundsBasedOnState(worldObj, xTile, yTile, zTile);
AxisAlignedBB var2 = Block.blocksList[var16].getCollisionBoundingBoxFromPool(worldObj, xTile, yTile, zTile);
if (var2 != null && var2.isVecInside(worldObj.getWorldVec3Pool().getVecFromPool(posX, posY, posZ)))
{
inGround = true;
}
}
if (inGround)
{
int var18 = worldObj.getBlockId(xTile, yTile, zTile);
int var19 = worldObj.getBlockMetadata(xTile, yTile, zTile);
if (var18 == inTile && var19 == inData)
{
// this.groundImpact();
// this.setDead();
}
}
else
{
++ticksInAir;
if (ticksInAir > 1 && ticksInAir < 3)
{
worldObj.spawnParticle("flame", posX + smallGauss(0.1D), posY + smallGauss(0.1D), posZ + smallGauss(0.1D), 0D, 0D, 0D);
for (int particles = 0; particles < 3; particles++)
{
this.doFiringParticles();
}
}
Vec3 var17 = worldObj.getWorldVec3Pool().getVecFromPool(posX, posY, posZ);
Vec3 var3 = worldObj.getWorldVec3Pool().getVecFromPool(posX + motionX, posY + motionY, posZ + motionZ);
MovingObjectPosition var4 = worldObj.rayTraceBlocks_do_do(var17, var3, false, true);
var17 = worldObj.getWorldVec3Pool().getVecFromPool(posX, posY, posZ);
var3 = worldObj.getWorldVec3Pool().getVecFromPool(posX + motionX, posY + motionY, posZ + motionZ);
if (var4 != null)
{
var3 = worldObj.getWorldVec3Pool().getVecFromPool(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);
motionY -= 0.1f; //TODO
this.doBlockCollisions();
}
}
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 == EnumMovingObjectType.ENTITY && mop.entityHit != null)
{
if (mop.entityHit == shootingEntity)
{
return;
}
this.onImpact(mop.entityHit);
}
else if (mop.typeOfHit == EnumMovingObjectType.TILE)
{
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,73 @@
package WayofTime.alchemicalWizardry.common.entity.projectile;
import WayofTime.alchemicalWizardry.common.summoning.meteor.MeteorRegistry;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumMovingObjectType;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
public class EntityMeteor extends EnergyBlastProjectile
{
private int meteorID;
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 DamageSource getDamageSource()
{
return DamageSource.fallingBlock;
}
@Override
public void onImpact(MovingObjectPosition mop)
{
if (worldObj.isRemote)
{
return;
}
if (mop.typeOfHit == EnumMovingObjectType.ENTITY && mop.entityHit != null)
{
this.onImpact(mop.entityHit);
}
else if (mop.typeOfHit == EnumMovingObjectType.TILE)
{
MeteorRegistry.createMeteorImpact(worldObj, mop.blockX, mop.blockY, mop.blockZ, this.meteorID);
}
this.setDead();
}
@Override
public void onImpact(Entity mop)
{
if (mop == shootingEntity && ticksInAir > 3)
{
shootingEntity.attackEntityFrom(DamageSource.causeMobDamage(shootingEntity), 1);
this.setDead();
}
else
{
MeteorRegistry.createMeteorImpact(worldObj, (int)this.posX, (int)this.posY, (int)this.posZ, meteorID);
}
this.setDead();
}
}

View File

@ -0,0 +1,141 @@
package WayofTime.alchemicalWizardry.common.entity.projectile;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
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.DamageSource;
import net.minecraft.util.EnumMovingObjectType;
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 == EnumMovingObjectType.ENTITY && mop.entityHit != null)
{
if (mop.entityHit == shootingEntity)
{
return;
}
worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float)(2), causesEnvDamage);
//this.onImpact(mop.entityHit);
}
else if (mop.typeOfHit == EnumMovingObjectType.TILE)
{
// 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,Block.fire.blockID);
// }
// }
// }
// }
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
{
//doDamage(8 + d6(), mop);
if (mop instanceof EntityLivingBase)
{
//((EntityLivingBase)mop).addPotionEffect(new PotionEffect(Potion.weakness.id, 60,2));
//((EntityLivingBase)mop).setFire(50);
//((EntityLivingBase)mop).setRevengeTarget(shootingEntity);
if (((EntityLivingBase)mop).isImmuneToFire())
{
doDamage((int)(projectileDamage), mop);
}
else
{
doDamage(projectileDamage, mop);
}
}
//worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float)(0.1), true);
}
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()
{
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,121 @@
package WayofTime.alchemicalWizardry.common.entity.projectile;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumMovingObjectType;
import net.minecraft.util.MathHelper;
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 == EnumMovingObjectType.ENTITY && mop.entityHit != null)
{
if (mop.entityHit == shootingEntity)
{
return;
}
this.onImpact(mop.entityHit);
}
else if (mop.typeOfHit == EnumMovingObjectType.TILE)
{
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, Block.fire.blockID);
}
}
}
}
//worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float)(0.1), true);
}
this.setDead();
}
@Override
public void onImpact(Entity mop)
{
if (mop == shootingEntity && ticksInAir > 3)
{
shootingEntity.attackEntityFrom(DamageSource.causeMobDamage(shootingEntity), 1);
this.setDead();
}
else
{
//doDamage(8 + d6(), mop);
if (mop instanceof EntityLivingBase)
{
//((EntityLivingBase)mop).addPotionEffect(new PotionEffect(Potion.weakness.id, 60,2));
((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;
}
}
//worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float)(0.1), true);
}
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();
}
}

View File

@ -0,0 +1,122 @@
package WayofTime.alchemicalWizardry.common.entity.projectile;
import WayofTime.alchemicalWizardry.common.PacketHandler;
import cpw.mods.fml.common.network.PacketDispatcher;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumMovingObjectType;
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 == EnumMovingObjectType.ENTITY && mop.entityHit != null)
{
if (mop.entityHit == shootingEntity)
{
return;
}
this.onImpact(mop.entityHit);
}
else if (mop.typeOfHit == EnumMovingObjectType.TILE)
{
// 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,Block.fire.blockID);
// }
// }
// }
// }
}
this.setDead();
}
@Override
public void onImpact(Entity mop)
{
if (mop == shootingEntity && ticksInAir > 3)
{
shootingEntity.attackEntityFrom(DamageSource.causeMobDamage(shootingEntity), 1);
this.setDead();
}
else
{
//doDamage(8 + d6(), mop);
if (mop instanceof EntityLivingBase)
{
//((EntityLivingBase)mop).addPotionEffect(new PotionEffect(Potion.weakness.id, 60,2));
//((EntityLivingBase)mop).setFire(50);
//((EntityLivingBase)mop).setRevengeTarget(shootingEntity);
if (((EntityLivingBase)mop).isEntityUndead())
{
doDamage((int)(projectileDamage * 2), mop);
}
else
{
doDamage(projectileDamage, mop);
}
}
//worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float)(0.1), true);
}
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()
{
PacketDispatcher.sendPacketToAllAround(posX, posY, posZ, 30, worldObj.provider.dimensionId, PacketHandler.getCustomParticlePacket("mobSpellAmbient", posX + smallGauss(0.1D), posY + smallGauss(0.1D), posZ + smallGauss(0.1D), 0.5D, 0.5D, 0.5D));
PacketDispatcher.sendPacketToAllAround(posX, posY, posZ, 30, worldObj.provider.dimensionId, PacketHandler.getCustomParticlePacket("mobSpell", posX, posY, posZ, 1.0F, 1.0F, 1.0F));
}
}

View File

@ -0,0 +1,128 @@
package WayofTime.alchemicalWizardry.common.entity.projectile;
import WayofTime.alchemicalWizardry.common.PacketHandler;
import WayofTime.alchemicalWizardry.common.entity.mob.EntityIceDemon;
import cpw.mods.fml.common.network.PacketDispatcher;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumMovingObjectType;
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 == EnumMovingObjectType.ENTITY && mop.entityHit != null)
{
if (mop.entityHit == shootingEntity)
{
return;
}
this.onImpact(mop.entityHit);
}
else if (mop.typeOfHit == EnumMovingObjectType.TILE)
{
// 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,Block.fire.blockID);
// }
// }
// }
// }
//worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float)(0.1), true);
}
this.setDead();
}
@Override
public void onImpact(Entity mop)
{
if (mop == shootingEntity && ticksInAir > 3)
{
shootingEntity.attackEntityFrom(DamageSource.causeMobDamage(shootingEntity), 1);
this.setDead();
}
else
{
//doDamage(8 + d6(), mop);
if (mop instanceof EntityLivingBase)
{
//((EntityLivingBase)mop).addPotionEffect(new PotionEffect(Potion.weakness.id, 60,2));
//((EntityLivingBase)mop).setFire(50);
//((EntityLivingBase)mop).setRevengeTarget(shootingEntity);
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));
}
}
//worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float)(0.1), true);
}
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()
{
PacketDispatcher.sendPacketToAllAround(posX, posY, posZ, 30, worldObj.provider.dimensionId, PacketHandler.getCustomParticlePacket("mobSpellAmbient", posX + smallGauss(0.1D), posY + smallGauss(0.1D), posZ + smallGauss(0.1D), 0.5D, 0.5D, 0.5D));
PacketDispatcher.sendPacketToAllAround(posX, posY, posZ, 30, worldObj.provider.dimensionId, PacketHandler.getCustomParticlePacket("explode", posX, posY, posZ, gaussian(motionX), gaussian(motionY), gaussian(motionZ)));
}
}

View File

@ -0,0 +1,133 @@
package WayofTime.alchemicalWizardry.common.entity.projectile;
import WayofTime.alchemicalWizardry.common.PacketHandler;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumMovingObjectType;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import cpw.mods.fml.common.network.PacketDispatcher;
public class LightningBoltProjectile extends EnergyBlastProjectile
{
private boolean causeLightning;
public LightningBoltProjectile(World par1World)
{
super(par1World);
}
public LightningBoltProjectile(World par1World, double par2, double par4, double par6)
{
super(par1World, par2, par4, par6);
}
public LightningBoltProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage, boolean flag)
{
super(par1World, par2EntityPlayer, damage);
causeLightning = flag;
}
public LightningBoltProjectile(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);
causeLightning = flag;
}
@Override
public DamageSource getDamageSource()
{
return DamageSource.causeMobDamage(shootingEntity);
}
@Override
public void onImpact(MovingObjectPosition mop)
{
if (mop.typeOfHit == EnumMovingObjectType.ENTITY && mop.entityHit != null)
{
if (mop.entityHit == shootingEntity)
{
return;
}
this.onImpact(mop.entityHit);
}
else if (mop.typeOfHit == EnumMovingObjectType.TILE)
{
if (causeLightning)
{
this.worldObj.addWeatherEffect(new EntityLightningBolt(this.worldObj, this.posX, this.posY, this.posZ));
}
}
this.setDead();
}
@Override
public void onImpact(Entity mop)
{
if (mop == shootingEntity && ticksInAir > 3)
{
//shootingEntity.attackEntityFrom(DamageSource.causePlayerDamage(shootingEntity), 1);
this.setDead();
}
else
{
//doDamage(8 + d6(), mop);
if (mop instanceof EntityLivingBase)
{
//((EntityLivingBase)mop).addPotionEffect(new PotionEffect(Potion.weakness.id, 60,2));
//((EntityLivingBase)mop).setFire(50);
//((EntityLivingBase)mop).setRevengeTarget(shootingEntity);
// if(((EntityLivingBase)mop).isEntityUndead())
// {
// doDamage((int)(projectileDamage*2),mop);
// }else
// {
// doDamage(projectileDamage, mop);
// }
if (causeLightning)
{
this.worldObj.addWeatherEffect(new EntityLightningBolt(this.worldObj, ((EntityLivingBase)mop).posX, ((EntityLivingBase)mop).posY, ((EntityLivingBase)mop).posZ));
}
else
{
doDamage(projectileDamage, mop);
}
//((EntityLivingBase)mop).setVelocity(this.motionX*2, ((EntityLivingBase)mop).motionY+1.5, this.motionZ*2);
}
//worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float)(0.1), true);
}
spawnHitParticles("magicCrit", 8);
this.setDead();
}
@Override
public void doFiringParticles()
{
PacketDispatcher.sendPacketToAllAround(posX, posY, posZ, 30, worldObj.provider.dimensionId, PacketHandler.getCustomParticlePacket("mobSpellAmbient", posX + smallGauss(0.1D), posY + smallGauss(0.1D), posZ + smallGauss(0.1D), 0.5D, 0.5D, 0.5D));
PacketDispatcher.sendPacketToAllAround(posX, posY, posZ, 30, worldObj.provider.dimensionId, PacketHandler.getCustomParticlePacket("mobSpell", posX, posY, posZ, 1.0F, 1.0F, 1.0F));
}
@Override
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
par1NBTTagCompound.setBoolean("causeLightning", causeLightning);
}
@Override
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
causeLightning = par1NBTTagCompound.getBoolean("causeLightning");
}
}

View File

@ -0,0 +1,136 @@
package WayofTime.alchemicalWizardry.common.entity.projectile;
import WayofTime.alchemicalWizardry.common.PacketHandler;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
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.DamageSource;
import net.minecraft.util.EnumMovingObjectType;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import cpw.mods.fml.common.network.PacketDispatcher;
public class MudProjectile extends EnergyBlastProjectile
{
private boolean doesBlindness; //True for when it applies blindness, false for slowness
public MudProjectile(World par1World)
{
super(par1World);
}
public MudProjectile(World par1World, double par2, double par4, double par6)
{
super(par1World, par2, par4, par6);
}
public MudProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage, boolean flag)
{
super(par1World, par2EntityPlayer, damage);
doesBlindness = flag;
}
public MudProjectile(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);
doesBlindness = flag;
}
public MudProjectile(World par1World, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase, float par4, float par5, int damage, int maxTicksInAir, boolean flag)
{
super(par1World, par2EntityLivingBase, par3EntityLivingBase, par4, par5, damage, maxTicksInAir);
doesBlindness = flag;
}
@Override
public DamageSource getDamageSource()
{
return DamageSource.causeMobDamage(shootingEntity);
}
@Override
public void onImpact(MovingObjectPosition mop)
{
if (mop.typeOfHit == EnumMovingObjectType.ENTITY && mop.entityHit != null)
{
if (mop.entityHit == shootingEntity)
{
return;
}
this.onImpact(mop.entityHit);
}
else if (mop.typeOfHit == EnumMovingObjectType.TILE)
{
}
this.setDead();
}
@Override
public void onImpact(Entity mop)
{
if (mop == shootingEntity && ticksInAir > 3)
{
//shootingEntity.attackEntityFrom(DamageSource.causePlayerDamage(shootingEntity), 1);
this.setDead();
}
else
{
//doDamage(8 + d6(), mop);
if (mop instanceof EntityLivingBase)
{
//((EntityLivingBase)mop).addPotionEffect(new PotionEffect(Potion.weakness.id, 60,2));
//((EntityLivingBase)mop).setFire(50);
//((EntityLivingBase)mop).setRevengeTarget(shootingEntity);
// if(((EntityLivingBase)mop).isEntityUndead())
// {
// doDamage((int)(projectileDamage*2),mop);
// }else
// {
// doDamage(projectileDamage, mop);
// }
if (doesBlindness)
{
((EntityLivingBase)mop).addPotionEffect(new PotionEffect(Potion.blindness.id, 100, 0));
}
else
{
((EntityLivingBase)mop).addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 100, 2));
}
doDamage(projectileDamage, mop);
//((EntityLivingBase)mop).setVelocity(this.motionX*2, ((EntityLivingBase)mop).motionY+1.5, this.motionZ*2);
}
//worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float)(0.1), true);
}
spawnHitParticles("magicCrit", 8);
this.setDead();
}
@Override
public void doFiringParticles()
{
PacketDispatcher.sendPacketToAllAround(posX, posY, posZ, 30, worldObj.provider.dimensionId, PacketHandler.getCustomParticlePacket("mobSpellAmbient", posX + smallGauss(0.1D), posY + smallGauss(0.1D), posZ + smallGauss(0.1D), 0.5D, 0.5D, 0.5D));
PacketDispatcher.sendPacketToAllAround(posX, posY, posZ, 30, worldObj.provider.dimensionId, PacketHandler.getCustomParticlePacket("mobSpell", posX, posY, posZ, 0.5F, 0.297F, 0.0664F));
}
@Override
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
par1NBTTagCompound.setBoolean("doesBlindness", doesBlindness);
}
@Override
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
doesBlindness = par1NBTTagCompound.getBoolean("doesBlindness");
}
}

View File

@ -0,0 +1,212 @@
package WayofTime.alchemicalWizardry.common.entity.projectile;
import WayofTime.alchemicalWizardry.common.PacketHandler;
import WayofTime.alchemicalWizardry.common.spell.simple.SpellTeleport;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumMovingObjectType;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.EnderTeleportEvent;
import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.common.network.Player;
public class TeleportProjectile extends EnergyBlastProjectile
{
private boolean isEntityTeleport; //True if the entity firing teleports on hit
public TeleportProjectile(World par1World)
{
super(par1World);
this.motionX *= 3;
this.motionY *= 3;
this.motionZ *= 3;
}
public TeleportProjectile(World par1World, double par2, double par4, double par6)
{
super(par1World, par2, par4, par6);
this.motionX *= 3;
this.motionY *= 3;
this.motionZ *= 3;
}
public TeleportProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage, boolean flag)
{
super(par1World, par2EntityPlayer, damage);
isEntityTeleport = flag;
this.motionX *= 3;
this.motionY *= 3;
this.motionZ *= 3;
}
public TeleportProjectile(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);
isEntityTeleport = flag;
this.motionX *= 3;
this.motionY *= 3;
this.motionZ *= 3;
}
@Override
public DamageSource getDamageSource()
{
return DamageSource.causeMobDamage(shootingEntity);
}
@Override
public void onImpact(MovingObjectPosition mop)
{
if (mop.typeOfHit == EnumMovingObjectType.ENTITY && mop.entityHit != null)
{
if (mop.entityHit == shootingEntity)
{
return;
}
this.onImpact(mop.entityHit);
}
else if (mop.typeOfHit == EnumMovingObjectType.TILE)
{
if (isEntityTeleport)
{
if (shootingEntity != null && shootingEntity instanceof EntityPlayerMP)
{
EntityPlayerMP entityplayermp = (EntityPlayerMP)shootingEntity;
if (!entityplayermp.playerNetServerHandler.connectionClosed && entityplayermp.worldObj == this.worldObj)
{
EnderTeleportEvent event = new EnderTeleportEvent(entityplayermp, this.posX, this.posY, this.posZ, 5.0F);
if (!MinecraftForge.EVENT_BUS.post(event))
{
if (shootingEntity.isRiding())
{
shootingEntity.mountEntity((Entity)null);
}
shootingEntity.setPositionAndUpdate(event.targetX, event.targetY, event.targetZ);
// this.getThrower().fallDistance = 0.0F;
// this.getThrower().attackEntityFrom(DamageSource.fall, event.attackDamage);
}
}
}
}
}
this.setDead();
}
@Override
public void onImpact(Entity mop)
{
if (mop == shootingEntity && ticksInAir > 3)
{
//shootingEntity.attackEntityFrom(DamageSource.causePlayerDamage(shootingEntity), 1);
this.setDead();
}
else
{
//doDamage(8 + d6(), mop);
if (mop instanceof EntityLivingBase)
{
//((EntityLivingBase)mop).addPotionEffect(new PotionEffect(Potion.weakness.id, 60,2));
//((EntityLivingBase)mop).setFire(50);
//((EntityLivingBase)mop).setRevengeTarget(shootingEntity);
// if(((EntityLivingBase)mop).isEntityUndead())
// {
// doDamage((int)(projectileDamage*2),mop);
// }else
// {
// doDamage(projectileDamage, mop);
// }
if (isEntityTeleport)
{
if (shootingEntity != null && shootingEntity instanceof EntityPlayerMP)
{
EntityPlayerMP entityplayermp = (EntityPlayerMP)shootingEntity;
if (!entityplayermp.playerNetServerHandler.connectionClosed && entityplayermp.worldObj == this.worldObj)
{
EnderTeleportEvent event = new EnderTeleportEvent(entityplayermp, this.posX, this.posY, this.posZ, 5.0F);
if (!MinecraftForge.EVENT_BUS.post(event))
{
if (shootingEntity.isRiding())
{
shootingEntity.mountEntity((Entity)null);
}
shootingEntity.setPositionAndUpdate(event.targetX, event.targetY, event.targetZ);
// this.getThrower().fallDistance = 0.0F;
// this.getThrower().attackEntityFrom(DamageSource.fall, event.attackDamage);
}
}
}
}
else
{
// int x = (int)this.posX + mop.worldObj.rand.nextInt(100) - mop.worldObj.rand.nextInt(100);
// int y = (int)this.posY + mop.worldObj.rand.nextInt(10) - mop.worldObj.rand.nextInt(10);
// int z = (int)this.posZ + mop.worldObj.rand.nextInt(100) - mop.worldObj.rand.nextInt(100);
//
// boolean bool = false;
// int i = 0;
//
// while(!bool&&i<100)
// {
// if(worldObj.isAirBlock(x, y, z)||worldObj.isAirBlock(x, y+1, z))
// {
// ((EntityLivingBase) mop).setPositionAndUpdate(x, y, z);
// bool=true;
// }else
// {
// x = (int)this.posX + mop.worldObj.rand.nextInt(100) - mop.worldObj.rand.nextInt(100);
// y = (int)this.posY + mop.worldObj.rand.nextInt(10) - mop.worldObj.rand.nextInt(10);
// z = (int)this.posZ + mop.worldObj.rand.nextInt(100) - mop.worldObj.rand.nextInt(100);
// i++;
// }
// }
SpellTeleport.teleportRandomly((EntityLivingBase)mop, 64);
}
//doDamage(projectileDamage, mop);
//((EntityLivingBase)mop).setVelocity(this.motionX*2, ((EntityLivingBase)mop).motionY+1.5, this.motionZ*2);
}
//worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float)(0.1), true);
}
spawnHitParticles("magicCrit", 8);
this.setDead();
}
@Override
public void doFiringParticles()
{
PacketDispatcher.sendPacketToAllAround(posX, posY, posZ, 30, worldObj.provider.dimensionId, PacketHandler.getCustomParticlePacket("mobSpellAmbient", posX + smallGauss(0.1D), posY + smallGauss(0.1D), posZ + smallGauss(0.1D), 0.5D, 0.5D, 0.5D));
PacketDispatcher.sendPacketToAllAround(posX, posY, posZ, 30, worldObj.provider.dimensionId, PacketHandler.getCustomParticlePacket("portal", posX, posY, posZ, -motionX, -motionY, -motionZ));
}
@Override
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
par1NBTTagCompound.setBoolean("isEntityTeleport", isEntityTeleport);
}
@Override
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
isEntityTeleport = par1NBTTagCompound.getBoolean("isEntityTeleport");
}
}

View File

@ -0,0 +1,113 @@
package WayofTime.alchemicalWizardry.common.entity.projectile;
import WayofTime.alchemicalWizardry.common.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.PacketHandler;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumMovingObjectType;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import cpw.mods.fml.common.network.PacketDispatcher;
public class WaterProjectile extends EnergyBlastProjectile
{
public WaterProjectile(World par1World)
{
super(par1World);
}
public WaterProjectile(World par1World, double par2, double par4, double par6)
{
super(par1World, par2, par4, par6);
}
public WaterProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage)
{
super(par1World, par2EntityPlayer, damage);
}
public WaterProjectile(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);
}
@Override
public DamageSource getDamageSource()
{
return DamageSource.causeMobDamage(shootingEntity);
}
@Override
public void onImpact(MovingObjectPosition mop)
{
if (mop.typeOfHit == EnumMovingObjectType.ENTITY && mop.entityHit != null)
{
if (mop.entityHit == shootingEntity)
{
return;
}
this.onImpact(mop.entityHit);
}
else if (mop.typeOfHit == EnumMovingObjectType.TILE)
{
}
this.setDead();
}
@Override
public void onImpact(Entity mop)
{
if (mop == shootingEntity && ticksInAir > 3)
{
//shootingEntity.attackEntityFrom(DamageSource.causePlayerDamage(shootingEntity), 1);
this.setDead();
}
else
{
//doDamage(8 + d6(), mop);
if (mop instanceof EntityLivingBase)
{
//((EntityLivingBase)mop).addPotionEffect(new PotionEffect(Potion.weakness.id, 60,2));
//((EntityLivingBase)mop).setFire(50);
//((EntityLivingBase)mop).setRevengeTarget(shootingEntity);
// if(((EntityLivingBase)mop).isEntityUndead())
// {
// doDamage((int)(projectileDamage*2),mop);
// }else
// {
// doDamage(projectileDamage, mop);
// }
if (((EntityLivingBase)mop).isImmuneToFire())
{
doDamage(projectileDamage * 2, mop);
((EntityLivingBase)mop).addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionDrowning.id, 80, 1));
}
else
{
doDamage(projectileDamage, mop);
((EntityLivingBase)mop).addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionDrowning.id, 80, 0));
}
//((EntityLivingBase)mop).setVelocity(this.motionX*2, ((EntityLivingBase)mop).motionY+1.5, this.motionZ*2);
}
//worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float)(0.1), true);
}
spawnHitParticles("magicCrit", 8);
this.setDead();
}
@Override
public void doFiringParticles()
{
PacketDispatcher.sendPacketToAllAround(posX, posY, posZ, 30, worldObj.provider.dimensionId, PacketHandler.getCustomParticlePacket("mobSpellAmbient", posX + smallGauss(0.1D), posY + smallGauss(0.1D), posZ + smallGauss(0.1D), 0.5D, 0.5D, 0.5D));
PacketDispatcher.sendPacketToAllAround(posX, posY, posZ, 30, worldObj.provider.dimensionId, PacketHandler.getCustomParticlePacket("mobSpell", posX, posY, posZ, 0.0F, 0.410F, 1.0F));
}
}

View File

@ -0,0 +1,115 @@
package WayofTime.alchemicalWizardry.common.entity.projectile;
import WayofTime.alchemicalWizardry.common.PacketHandler;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumMovingObjectType;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import cpw.mods.fml.common.network.PacketDispatcher;
public class WindGustProjectile extends EnergyBlastProjectile
{
public WindGustProjectile(World par1World)
{
super(par1World);
}
public WindGustProjectile(World par1World, double par2, double par4, double par6)
{
super(par1World, par2, par4, par6);
}
public WindGustProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage)
{
super(par1World, par2EntityPlayer, damage);
}
public WindGustProjectile(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);
}
@Override
public DamageSource getDamageSource()
{
return DamageSource.causeMobDamage(shootingEntity);
}
@Override
public void onImpact(MovingObjectPosition mop)
{
if (mop.typeOfHit == EnumMovingObjectType.ENTITY && mop.entityHit != null)
{
if (mop.entityHit == shootingEntity)
{
return;
}
this.onImpact(mop.entityHit);
}
else if (mop.typeOfHit == EnumMovingObjectType.TILE)
{
// 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,Block.fire.blockID);
// }
// }
// }
// }
}
this.setDead();
}
@Override
public void onImpact(Entity mop)
{
if (mop == shootingEntity && ticksInAir > 3)
{
//shootingEntity.attackEntityFrom(DamageSource.causePlayerDamage(shootingEntity), 1);
this.setDead();
}
else
{
//doDamage(8 + d6(), mop);
if (mop instanceof EntityLivingBase)
{
//((EntityLivingBase)mop).addPotionEffect(new PotionEffect(Potion.weakness.id, 60,2));
//((EntityLivingBase)mop).setFire(50);
//((EntityLivingBase)mop).setRevengeTarget(shootingEntity);
// if(((EntityLivingBase)mop).isEntityUndead())
// {
// doDamage((int)(projectileDamage*2),mop);
// }else
// {
// doDamage(projectileDamage, mop);
// }
((EntityLivingBase)mop).motionX = this.motionX * 2;
((EntityLivingBase)mop).motionY = 1.5;
((EntityLivingBase)mop).motionZ = this.motionZ * 2;
//((EntityLivingBase)mop).setVelocity(this.motionX*2, ((EntityLivingBase)mop).motionY+1.5, this.motionZ*2);
}
//worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float)(0.1), true);
}
spawnHitParticles("magicCrit", 8);
this.setDead();
}
@Override
public void doFiringParticles()
{
PacketDispatcher.sendPacketToAllAround(posX, posY, posZ, 30, worldObj.provider.dimensionId, PacketHandler.getCustomParticlePacket("mobSpellAmbient", posX + smallGauss(0.1D), posY + smallGauss(0.1D), posZ + smallGauss(0.1D), 0.5D, 0.5D, 0.5D));
PacketDispatcher.sendPacketToAllAround(posX, posY, posZ, 30, worldObj.provider.dimensionId, PacketHandler.getCustomParticlePacket("mobSpell", posX, posY, posZ, 1.0F, 1.0F, 1.0F));
}
}

View File

@ -0,0 +1,46 @@
package WayofTime.alchemicalWizardry.common.items;
import java.util.List;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import WayofTime.alchemicalWizardry.common.AlchemicalWizardry;
public class AWBaseItems extends Item
{
public AWBaseItems(int id)
{
super(id);
setMaxStackSize(64);
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
}
public void registerIcons(IconRegister iconRegister)
{
if (this.itemID == AlchemicalWizardry.blankSlate.itemID)
{
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:BlankSlate");
}
else if (this.itemID == AlchemicalWizardry.reinforcedSlate.itemID)
{
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:ReinforcedSlate");
}
else if (this.itemID == AlchemicalWizardry.imbuedSlate.itemID)
{
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:InfusedSlate");
}
else if (this.itemID == AlchemicalWizardry.demonicSlate.itemID)
{
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:DemonSlate");
}
}
@Override
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
par3List.add("Infused stone inside of");
par3List.add("a blood altar");
}
}

View File

@ -0,0 +1,133 @@
package WayofTime.alchemicalWizardry.common.items;
import java.util.List;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.Icon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import org.lwjgl.input.Keyboard;
import WayofTime.alchemicalWizardry.common.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.alchemy.AlchemyRecipeRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ActivationCrystal extends EnergyItems
{
private static final String[] ACTIVATION_CRYSTAL_NAMES = new String[] { "Weak", "Awakened"};
@SideOnly(Side.CLIENT)
private Icon[] icons;
public ActivationCrystal(int id)
{
super(id);
this.maxStackSize = 1;
setEnergyUsed(100);
this.setCreativeTab(AlchemicalWizardry.tabBloodMagic);
this.hasSubtypes = true;
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
icons = new Icon[ACTIVATION_CRYSTAL_NAMES.length];
for (int i = 0; i < ACTIVATION_CRYSTAL_NAMES.length; ++i)
{
icons[i] = iconRegister.registerIcon("AlchemicalWizardry:" + "activationCrystal" + ACTIVATION_CRYSTAL_NAMES[i]);
}
}
@Override
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
switch (par1ItemStack.getItemDamage())
{
case 0:
{
par3List.add("Activates low-level rituals");
break;
}
case 1:
{
par3List.add("Activates more powerful rituals");
if (Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))
{
ItemStack[] recipe = AlchemyRecipeRegistry.getRecipeForItemStack(par1ItemStack);
if (recipe != null)
{
par3List.add(EnumChatFormatting.BLUE + "Recipe:");
for (ItemStack item: recipe)
{
if (item != null)
{
par3List.add("" + item.getDisplayName());
}
}
}
}
else
{
par3List.add("-Press " + EnumChatFormatting.BLUE + "shift" + EnumChatFormatting.GRAY + " for Recipe-");
}
break;
}
}
if (!(par1ItemStack.stackTagCompound == null))
{
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
}
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
return par1ItemStack;
}
public int getCrystalLevel(ItemStack itemStack)
{
return itemStack.getItemDamage() + 1;
}
@Override
public String getUnlocalizedName(ItemStack itemStack)
{
//This is what will do all the localisation things on the alchemy components so you dont have to set it :D
int meta = MathHelper.clamp_int(itemStack.getItemDamage(), 0, ACTIVATION_CRYSTAL_NAMES.length - 1);
return ("" + "item.activationCrystal" + ACTIVATION_CRYSTAL_NAMES[meta]);
}
@Override
@SideOnly(Side.CLIENT)
public Icon getIconFromDamage(int meta)
{
int j = MathHelper.clamp_int(meta, 0, ACTIVATION_CRYSTAL_NAMES.length - 1);
return icons[j];
}
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(int id, CreativeTabs creativeTab, List list)
{
for (int meta = 0; meta < ACTIVATION_CRYSTAL_NAMES.length; ++meta)
{
list.add(new ItemStack(id, 1, meta));
}
}
}

View File

@ -0,0 +1,24 @@
package WayofTime.alchemicalWizardry.common.items;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.item.Item;
import WayofTime.alchemicalWizardry.common.AlchemicalWizardry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class AirInk extends Item
{
public AirInk(int id)
{
super(id);
this.maxStackSize = 1;
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:ElementalInkWater");
}
}

View File

@ -0,0 +1,20 @@
package WayofTime.alchemicalWizardry.common.items;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IconRegister;
public class AirScribeTool extends ScribeTool
{
public AirScribeTool(int id)
{
super(id, 4);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:AirScribeTool");
}
}

View File

@ -0,0 +1,21 @@
package WayofTime.alchemicalWizardry.common.items;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IconRegister;
public class ApprenticeBloodOrb extends EnergyBattery
{
public ApprenticeBloodOrb(int id, int damage)
{
super(id, damage);
orbLevel = 2;
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:ApprenticeBloodOrb");
}
}

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