Initial commit of BM 1.8

This commit is contained in:
WayofTime 2015-07-29 08:23:01 -04:00
parent d99eadbea7
commit c5681dc831
713 changed files with 6502 additions and 27334 deletions

View file

@ -7,8 +7,6 @@ import java.util.List;
import java.util.Map;
import java.util.Random;
import WayofTime.alchemicalWizardry.common.achievements.ModAchievements;
import WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon.IHoardDemon;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
@ -24,18 +22,25 @@ import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.DamageSource;
import net.minecraft.util.Vec3;
import net.minecraft.util.EnumParticleTypes;
import net.minecraftforge.common.ISpecialArmor.ArmorProperties;
import net.minecraftforge.event.AnvilUpdateEvent;
import net.minecraftforge.event.entity.living.EnderTeleportEvent;
import net.minecraftforge.event.entity.living.LivingAttackEvent;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.event.entity.living.LivingSpawnEvent.CheckSpawn;
import net.minecraftforge.event.entity.player.EntityInteractEvent;
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
import net.minecraftforge.fml.common.Optional;
import net.minecraftforge.fml.common.eventhandler.Event.Result;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerRespawnEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.oredict.OreDictionary;
import vazkii.botania.api.internal.IManaBurst;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
@ -53,13 +58,7 @@ import WayofTime.alchemicalWizardry.common.omega.OmegaRegistry;
import WayofTime.alchemicalWizardry.common.omega.ReagentRegenConfiguration;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import WayofTime.alchemicalWizardry.common.tileEntity.TEMasterStone;
import cpw.mods.fml.client.event.ConfigChangedEvent;
import cpw.mods.fml.common.Optional;
import cpw.mods.fml.common.eventhandler.Event.Result;
import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerRespawnEvent;
import cpw.mods.fml.common.registry.GameRegistry;
public class AlchemicalWizardryEventHooks
{
@ -117,7 +116,7 @@ public class AlchemicalWizardryEventHooks
float prevHp = APISpellHelper.getCurrentAdditionalHP((EntityPlayer)event.entityLiving);
if(prevHp > 0)
{
float recalculatedAmount = ArmorProperties.ApplyArmor(player, player.inventory.armorInventory, event.source, event.ammount);
float recalculatedAmount = ArmorProperties.applyArmor(player, player.inventory.armorInventory, event.source, event.ammount);
if (recalculatedAmount <= 0) return;
recalculatedAmount = SpellHelper.applyPotionDamageCalculations(player, event.source, recalculatedAmount); //Recalculated damage
@ -335,7 +334,7 @@ public class AlchemicalWizardryEventHooks
String respawnRitual = "AW028SpawnWard";
int dimension = event.world.provider.dimensionId;
int dimension = event.world.provider.getDimensionId();
if (respawnMap.containsKey(dimension))
{
List<CoordAndRange> list = respawnMap.get(dimension);
@ -344,7 +343,7 @@ public class AlchemicalWizardryEventHooks
{
for (CoordAndRange coords : list)
{
TileEntity tile = event.world.getTileEntity(coords.xCoord, coords.yCoord, coords.zCoord);
TileEntity tile = event.world.getTileEntity(coords.getPos());
if (tile instanceof TEMasterStone && ((TEMasterStone) tile).isRunning && ((TEMasterStone) tile).getCurrentRitual().equals(respawnRitual))
{
@ -388,7 +387,7 @@ public class AlchemicalWizardryEventHooks
{
for (CoordAndRange coords : list)
{
TileEntity tile = event.world.getTileEntity(coords.xCoord, coords.yCoord, coords.zCoord);
TileEntity tile = event.world.getTileEntity(coords.getPos());
if (tile instanceof TEMasterStone && ((TEMasterStone) tile).isRunning && ((TEMasterStone) tile).getCurrentRitual().equals(forceSpawnRitual))
{
@ -508,10 +507,10 @@ public class AlchemicalWizardryEventHooks
double y = entityLiving.posY;
double z = entityLiving.posZ;
Vec3 blockVector = SpellHelper.getEntityBlockVector(entityLiving);
int xPos = (int) (blockVector.xCoord);
int yPos = (int) (blockVector.yCoord);
int zPos = (int) (blockVector.zCoord);
BlockPos blockVector = entityLiving.getPosition();
int xPos = blockVector.getX();
int yPos = blockVector.getY();
int zPos = blockVector.getZ();
if (entityLiving instanceof EntityPlayer)
{
@ -592,7 +591,7 @@ public class AlchemicalWizardryEventHooks
int posY = (int) Math.round(entity.posY);
int posZ = (int) Math.round(entity.posZ - 0.5f);
int d0 = (int) ((i + 1) * 2.5);
AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox(posX - 0.5, posY - 0.5, posZ - 0.5, posX + 0.5, posY + 0.5, posZ + 0.5).expand(d0, d0, d0);
AxisAlignedBB axisalignedbb = new AxisAlignedBB(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();
@ -697,7 +696,7 @@ public class AlchemicalWizardryEventHooks
if (entityLiving.isPotionActive(AlchemicalWizardry.customPotionFlameCloak))
{
entityLiving.worldObj.spawnParticle("flame", x + SpellHelper.gaussian(1), y - 1.3 + SpellHelper.gaussian(0.3), z + SpellHelper.gaussian(1), 0, 0.06d, 0);
entityLiving.worldObj.spawnParticle(EnumParticleTypes.FLAME, x + SpellHelper.gaussian(1), y - 1.3 + SpellHelper.gaussian(0.3), z + SpellHelper.gaussian(1), 0, 0.06d, 0);
int i = event.entityLiving.getActivePotionEffect(AlchemicalWizardry.customPotionFlameCloak).getAmplifier();
double range = i * 0.5;
@ -718,7 +717,7 @@ public class AlchemicalWizardryEventHooks
if (entityLiving.isPotionActive(AlchemicalWizardry.customPotionIceCloak))
{
if (entityLiving.worldObj.getWorldTime() % 2 == 0)
entityLiving.worldObj.spawnParticle("reddust", x + SpellHelper.gaussian(1), y - 1.3 + SpellHelper.gaussian(0.3), z + SpellHelper.gaussian(1), 0x74, 0xbb, 0xfb);
entityLiving.worldObj.spawnParticle(EnumParticleTypes.REDSTONE, x + SpellHelper.gaussian(1), y - 1.3 + SpellHelper.gaussian(0.3), z + SpellHelper.gaussian(1), 0x74, 0xbb, 0xfb);
int r = event.entityLiving.getActivePotionEffect(AlchemicalWizardry.customPotionIceCloak).getAmplifier();
int horizRange = r + 1;
@ -732,7 +731,7 @@ public class AlchemicalWizardryEventHooks
{
for (int j = -vertRange - 1; j <= vertRange - 1; j++)
{
SpellHelper.freezeWaterBlock(entityLiving.worldObj, xPos + i, yPos + j, zPos + k);
SpellHelper.freezeWaterBlock(entityLiving.worldObj, new BlockPos(xPos + i, yPos + j, zPos + k));
}
}
}
@ -741,7 +740,7 @@ public class AlchemicalWizardryEventHooks
if (entityLiving.isPotionActive(AlchemicalWizardry.customPotionHeavyHeart))
{
entityLiving.worldObj.spawnParticle("flame", x + SpellHelper.gaussian(1), y - 1.3 + SpellHelper.gaussian(0.3), z + SpellHelper.gaussian(1), 0, 0.06d, 0);
entityLiving.worldObj.spawnParticle(EnumParticleTypes.FLAME, x + SpellHelper.gaussian(1), y - 1.3 + SpellHelper.gaussian(0.3), z + SpellHelper.gaussian(1), 0, 0.06d, 0);
int i = event.entityLiving.getActivePotionEffect(AlchemicalWizardry.customPotionHeavyHeart).getAmplifier();
double decrease = 0.025 * (i + 1);
@ -759,7 +758,7 @@ public class AlchemicalWizardryEventHooks
if (entityLiving.isPotionActive(AlchemicalWizardry.customPotionFireFuse))
{
entityLiving.worldObj.spawnParticle("flame", x + SpellHelper.gaussian(1), y - 1.3 + SpellHelper.gaussian(0.3), z + SpellHelper.gaussian(1), 0, 0.06d, 0);
entityLiving.worldObj.spawnParticle(EnumParticleTypes.FLAME, x + SpellHelper.gaussian(1), y - 1.3 + SpellHelper.gaussian(0.3), z + SpellHelper.gaussian(1), 0, 0.06d, 0);
int r = event.entityLiving.getActivePotionEffect(AlchemicalWizardry.customPotionFireFuse).getAmplifier();
int radius = r + 1;
@ -791,7 +790,7 @@ public class AlchemicalWizardryEventHooks
meta = 0;
if (block != null)
if (( block == event.initialBlock || block == event.finalBlock) && (meta == event.initialMetadata || meta == event.finalMetadata || meta == OreDictionary.WILDCARD_VALUE))
if ((block == event.initialBlock || block == event.finalBlock) && (meta == event.initialBlock.getMetaFromState(event.initialState) || meta == event.finalBlock.getMetaFromState(event.finalState) || meta == OreDictionary.WILDCARD_VALUE))
event.setCanceled(true);
// If the block uses shorthand syntax: modid:blockname
@ -801,31 +800,12 @@ public class AlchemicalWizardryEventHooks
int meta = 0;
if (block != null)
if (( block == event.initialBlock || block == event.finalBlock) && (meta == event.initialMetadata || meta == event.finalMetadata || meta == OreDictionary.WILDCARD_VALUE))
if (( block == event.initialBlock || block == event.finalBlock) && (meta == event.initialBlock.getMetaFromState(event.initialState) || meta == event.finalBlock.getMetaFromState(event.finalState) || meta == OreDictionary.WILDCARD_VALUE))
event.setCanceled(true);
}
}
}
@SubscribeEvent
public void onEntityDeath(LivingDeathEvent event)
{
EntityLivingBase entityLiving = event.entityLiving;
if (entityLiving instanceof IDemon && event.source.getEntity() instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer) event.source.getEntity();
player.addStat(ModAchievements.demonSpawn, 1);
}
if (entityLiving instanceof IHoardDemon && event.source.getEntity() instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer) event.source.getEntity();
player.addStat(ModAchievements.demons, 1);
}
}
@SubscribeEvent
public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) {
if (event.modID.equals("AWWayofTime")) {

View file

@ -1,9 +1,5 @@
package WayofTime.alchemicalWizardry.common;
import WayofTime.alchemicalWizardry.ModItems;
import WayofTime.alchemicalWizardry.common.items.LavaCrystal;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import cpw.mods.fml.common.IFuelHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@ -11,6 +7,10 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.fml.common.IFuelHandler;
import WayofTime.alchemicalWizardry.ModItems;
import WayofTime.alchemicalWizardry.common.items.LavaCrystal;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
public class AlchemicalWizardryFuelHandler implements IFuelHandler
{

View file

@ -1,5 +1,7 @@
package WayofTime.alchemicalWizardry.common;
import net.minecraft.util.BlockPos;
public class CoordAndRange
{
public int xCoord;
@ -8,6 +10,11 @@ public class CoordAndRange
public int horizRadius;
public int vertRadius;
public CoordAndRange(BlockPos pos, int horiz, int vert)
{
this(pos.getX(), pos.getY(), pos.getZ(), horiz, vert);
}
public CoordAndRange(int x, int y, int z, int horiz, int vert)
{
this.xCoord = x;
@ -16,6 +23,11 @@ public class CoordAndRange
this.horizRadius = horiz;
this.vertRadius = vert;
}
public BlockPos getPos()
{
return new BlockPos(xCoord, yCoord, zCoord);
}
@Override
public boolean equals(Object o)

View file

@ -9,7 +9,7 @@ public class EntityAITargetAggro extends EntityAINearestAttackableTarget
public EntityAITargetAggro(EntityDemon par1EntityDemon, Class par2Class, int par3, boolean par4)
{
super(par1EntityDemon, par2Class, par3, par4);
super(par1EntityDemon, par2Class, par4);
this.theCreature = par1EntityDemon;
}

View file

@ -53,7 +53,7 @@ public class ItemType
public ItemStack createStack(int count)
{
ItemStack result = new ItemStack(item, count, meta);
result.stackTagCompound = nbtTag;
result.setTagCompound(nbtTag);
return result;
}
@ -87,7 +87,7 @@ public class ItemType
public static ItemType fromStack(ItemStack stack)
{
return new ItemType(stack.getItem(), stack.getItemDamage(), stack.stackTagCompound);
return new ItemType(stack.getItem(), stack.getItemDamage(), stack.getTagCompound());
}
}

View file

@ -1,14 +1,15 @@
package WayofTime.alchemicalWizardry.common;
import WayofTime.alchemicalWizardry.ModBlocks;
import WayofTime.alchemicalWizardry.ModItems;
import cpw.mods.fml.common.eventhandler.Event.Result;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.player.FillBucketEvent;
import net.minecraftforge.fml.common.eventhandler.Event.Result;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import WayofTime.alchemicalWizardry.ModBlocks;
import WayofTime.alchemicalWizardry.ModItems;
public class LifeBucketHandler
{
@ -28,11 +29,12 @@ public class LifeBucketHandler
public ItemStack fillCustomBucket(World world, MovingObjectPosition pos)
{
Block block = world.getBlock(pos.blockX, pos.blockY, pos.blockZ);
IBlockState state = world.getBlockState(pos.func_178782_a());
Block block = state.getBlock();
if (block != null && (block.equals(ModBlocks.blockLifeEssence)) && world.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ) == 0)
if (block != null && (block.equals(ModBlocks.blockLifeEssence)) && block.getMetaFromState(state) == 0)
{
world.setBlockToAir(pos.blockX, pos.blockY, pos.blockZ);
world.setBlockToAir(pos.func_178782_a());
return new ItemStack(ModItems.bucketLife);
} else
{

View file

@ -1,7 +1,6 @@
package WayofTime.alchemicalWizardry.common;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
public class LifeEssence extends Fluid
{
@ -19,7 +18,7 @@ public class LifeEssence extends Fluid
}
@Override
public String getLocalizedName(FluidStack fluidStack)
public String getLocalizedName()
{
return "Life Essence";
}

View file

@ -13,9 +13,12 @@ import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.Packet;
import net.minecraft.network.PacketBuffer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.api.ColourAndCoords;
import WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent;
@ -95,7 +98,7 @@ public enum NewPacketHandler
protected void channelRead0(ChannelHandlerContext ctx, TEAltarMessage msg) throws Exception
{
World world = AlchemicalWizardry.proxy.getClientWorld();
TileEntity te = world.getTileEntity(msg.x, msg.y, msg.z);
TileEntity te = world.getTileEntity(msg.pos);
if (te instanceof TEAltar)
{
TEAltar altar = (TEAltar) te;
@ -111,11 +114,11 @@ public enum NewPacketHandler
protected void channelRead0(ChannelHandlerContext ctx, TEOrientableMessage msg) throws Exception
{
World world = AlchemicalWizardry.proxy.getClientWorld();
TileEntity te = world.getTileEntity(msg.x, msg.y, msg.z);
TileEntity te = world.getTileEntity(msg.pos);
if (te instanceof TEOrientable)
{
((TEOrientable) te).setInputDirection(ForgeDirection.getOrientation(msg.input));
((TEOrientable) te).setOutputDirection(ForgeDirection.getOrientation(msg.output));
((TEOrientable) te).setInputDirection(EnumFacing.getFront(msg.input));
((TEOrientable) te).setOutputDirection(EnumFacing.getFront(msg.output));
}
}
}
@ -126,7 +129,7 @@ public enum NewPacketHandler
protected void channelRead0(ChannelHandlerContext ctx, TEPedestalMessage msg) throws Exception
{
World world = AlchemicalWizardry.proxy.getClientWorld();
TileEntity te = world.getTileEntity(msg.x, msg.y, msg.z);
TileEntity te = world.getTileEntity(msg.pos);
if (te instanceof TEPedestal)
{
TEPedestal pedestal = (TEPedestal) te;
@ -142,7 +145,7 @@ public enum NewPacketHandler
protected void channelRead0(ChannelHandlerContext ctx, TEPlinthMessage msg) throws Exception
{
World world = AlchemicalWizardry.proxy.getClientWorld();
TileEntity te = world.getTileEntity(msg.x, msg.y, msg.z);
TileEntity te = world.getTileEntity(msg.pos);
if (te instanceof TEPlinth)
{
TEPlinth Plinth = (TEPlinth) te;
@ -158,7 +161,7 @@ public enum NewPacketHandler
protected void channelRead0(ChannelHandlerContext ctx, TESocketMessage msg) throws Exception
{
World world = AlchemicalWizardry.proxy.getClientWorld();
TileEntity te = world.getTileEntity(msg.x, msg.y, msg.z);
TileEntity te = world.getTileEntity(msg.pos);
if (te instanceof TESocket)
{
TESocket Socket = (TESocket) te;
@ -174,7 +177,7 @@ public enum NewPacketHandler
protected void channelRead0(ChannelHandlerContext ctx, TETeleposerMessage msg) throws Exception
{
World world = AlchemicalWizardry.proxy.getClientWorld();
TileEntity te = world.getTileEntity(msg.x, msg.y, msg.z);
TileEntity te = world.getTileEntity(msg.pos);
if (te instanceof TETeleposer)
{
TETeleposer Teleposer = (TETeleposer) te;
@ -190,7 +193,7 @@ public enum NewPacketHandler
protected void channelRead0(ChannelHandlerContext ctx, TEWritingTableMessage msg) throws Exception
{
World world = AlchemicalWizardry.proxy.getClientWorld();
TileEntity te = world.getTileEntity(msg.x, msg.y, msg.z);
TileEntity te = world.getTileEntity(msg.pos);
if (te instanceof TEWritingTable)
{
TEWritingTable WritingTable = (TEWritingTable) te;
@ -207,7 +210,7 @@ public enum NewPacketHandler
{
World world = AlchemicalWizardry.proxy.getClientWorld();
world.spawnParticle(msg.particle, msg.xCoord, msg.yCoord, msg.zCoord, msg.xVel, msg.yVel, msg.zVel);
world.spawnParticle(EnumParticleTypes.func_179342_a(msg.particle), msg.xCoord, msg.yCoord, msg.zCoord, msg.xVel, msg.yVel, msg.zVel);
}
}
@ -233,7 +236,7 @@ public enum NewPacketHandler
protected void channelRead0(ChannelHandlerContext ctx, TEMasterStoneMessage msg) throws Exception
{
World world = AlchemicalWizardry.proxy.getClientWorld();
TileEntity te = world.getTileEntity(msg.x, msg.y, msg.z);
TileEntity te = world.getTileEntity(msg.pos);
if (te instanceof TEMasterStone)
{
TEMasterStone masterStone = (TEMasterStone) te;
@ -250,7 +253,7 @@ public enum NewPacketHandler
protected void channelRead0(ChannelHandlerContext ctx, TEReagentConduitMessage msg) throws Exception
{
World world = AlchemicalWizardry.proxy.getClientWorld();
TileEntity te = world.getTileEntity(msg.x, msg.y, msg.z);
TileEntity te = world.getTileEntity(msg.pos);
if (te instanceof TEReagentConduit)
{
TEReagentConduit reagentConduit = (TEReagentConduit) te;
@ -318,9 +321,7 @@ public enum NewPacketHandler
public static class TEAltarMessage extends BMMessage
{
int x;
int y;
int z;
BlockPos pos;
int[] items;
int[] fluids;
@ -329,9 +330,7 @@ public enum NewPacketHandler
public static class TEOrientableMessage extends BMMessage
{
int x;
int y;
int z;
BlockPos pos;
int input;
int output;
@ -339,52 +338,42 @@ public enum NewPacketHandler
public static class TEPedestalMessage extends BMMessage
{
int x;
int y;
int z;
BlockPos pos;
int[] items;
}
public static class TEPlinthMessage extends BMMessage
{
int x;
int y;
int z;
BlockPos pos;
int[] items;
}
public static class TESocketMessage extends BMMessage
{
int x;
int y;
int z;
BlockPos pos;
int[] items;
}
public static class TETeleposerMessage extends BMMessage
{
int x;
int y;
int z;
BlockPos pos;
int[] items;
}
public static class TEWritingTableMessage extends BMMessage
{
int x;
int y;
int z;
BlockPos pos;
int[] items;
}
public static class ParticleMessage extends BMMessage
{
String particle;
int particle;
double xCoord;
double yCoord;
@ -404,9 +393,7 @@ public enum NewPacketHandler
public static class TEMasterStoneMessage extends BMMessage
{
int x;
int y;
int z;
BlockPos pos;
String ritual;
boolean isRunning;
@ -414,9 +401,7 @@ public enum NewPacketHandler
public static class TEReagentConduitMessage extends BMMessage
{
int x;
int y;
int z;
BlockPos pos;
List<ColourAndCoords> destinationList;
}
@ -501,231 +486,209 @@ public enum NewPacketHandler
@Override
public void encodeInto(ChannelHandlerContext ctx, BMMessage msg, ByteBuf target) throws Exception
{
target.writeInt(msg.index);
PacketBuffer newBuffer = new PacketBuffer(target);
newBuffer.writeInt(msg.index);
switch (msg.index)
{
case 0:
target.writeInt(((TEAltarMessage) msg).x);
target.writeInt(((TEAltarMessage) msg).y);
target.writeInt(((TEAltarMessage) msg).z);
newBuffer.writeBlockPos(((TEAltarMessage) msg).pos);
target.writeBoolean(((TEAltarMessage) msg).items != null);
newBuffer.writeBoolean(((TEAltarMessage) msg).items != null);
if (((TEAltarMessage) msg).items != null)
{
int[] items = ((TEAltarMessage) msg).items;
for (int j = 0; j < items.length; j++)
{
int i = items[j];
target.writeInt(i);
newBuffer.writeInt(i);
}
}
target.writeBoolean(((TEAltarMessage) msg).fluids != null);
newBuffer.writeBoolean(((TEAltarMessage) msg).fluids != null);
if (((TEAltarMessage) msg).fluids != null)
{
int[] fluids = ((TEAltarMessage) msg).fluids;
for (int j = 0; j < fluids.length; j++)
{
int i = fluids[j];
target.writeInt(i);
newBuffer.writeInt(i);
}
}
target.writeInt(((TEAltarMessage) msg).capacity);
newBuffer.writeInt(((TEAltarMessage) msg).capacity);
break;
case 1:
target.writeInt(((TEOrientableMessage) msg).x);
target.writeInt(((TEOrientableMessage) msg).y);
target.writeInt(((TEOrientableMessage) msg).z);
newBuffer.writeBlockPos(((TEOrientableMessage) msg).pos);
target.writeInt(((TEOrientableMessage) msg).input);
target.writeInt(((TEOrientableMessage) msg).output);
newBuffer.writeInt(((TEOrientableMessage) msg).input);
newBuffer.writeInt(((TEOrientableMessage) msg).output);
break;
case 2:
target.writeInt(((TEPedestalMessage) msg).x);
target.writeInt(((TEPedestalMessage) msg).y);
target.writeInt(((TEPedestalMessage) msg).z);
newBuffer.writeBlockPos(((TEPedestalMessage) msg).pos);
target.writeBoolean(((TEPedestalMessage) msg).items != null);
newBuffer.writeBoolean(((TEPedestalMessage) msg).items != null);
if (((TEPedestalMessage) msg).items != null)
{
int[] items = ((TEPedestalMessage) msg).items;
for (int j = 0; j < items.length; j++)
{
int i = items[j];
target.writeInt(i);
newBuffer.writeInt(i);
}
}
break;
case 3:
target.writeInt(((TEPlinthMessage) msg).x);
target.writeInt(((TEPlinthMessage) msg).y);
target.writeInt(((TEPlinthMessage) msg).z);
newBuffer.writeBlockPos(((TEPlinthMessage) msg).pos);
target.writeBoolean(((TEPlinthMessage) msg).items != null);
newBuffer.writeBoolean(((TEPlinthMessage) msg).items != null);
if (((TEPlinthMessage) msg).items != null)
{
int[] items = ((TEPlinthMessage) msg).items;
for (int j = 0; j < items.length; j++)
{
int i = items[j];
target.writeInt(i);
newBuffer.writeInt(i);
}
}
break;
case 4:
target.writeInt(((TESocketMessage) msg).x);
target.writeInt(((TESocketMessage) msg).y);
target.writeInt(((TESocketMessage) msg).z);
newBuffer.writeBlockPos(((TESocketMessage) msg).pos);
target.writeBoolean(((TESocketMessage) msg).items != null);
newBuffer.writeBoolean(((TESocketMessage) msg).items != null);
if (((TESocketMessage) msg).items != null)
{
int[] items = ((TESocketMessage) msg).items;
for (int j = 0; j < items.length; j++)
{
int i = items[j];
target.writeInt(i);
newBuffer.writeInt(i);
}
}
break;
case 5:
target.writeInt(((TETeleposerMessage) msg).x);
target.writeInt(((TETeleposerMessage) msg).y);
target.writeInt(((TETeleposerMessage) msg).z);
newBuffer.writeBlockPos(((TETeleposerMessage) msg).pos);
target.writeBoolean(((TETeleposerMessage) msg).items != null);
newBuffer.writeBoolean(((TETeleposerMessage) msg).items != null);
if (((TETeleposerMessage) msg).items != null)
{
int[] items = ((TETeleposerMessage) msg).items;
for (int j = 0; j < items.length; j++)
{
int i = items[j];
target.writeInt(i);
newBuffer.writeInt(i);
}
}
break;
case 6:
target.writeInt(((TEWritingTableMessage) msg).x);
target.writeInt(((TEWritingTableMessage) msg).y);
target.writeInt(((TEWritingTableMessage) msg).z);
newBuffer.writeBlockPos(((TEWritingTableMessage) msg).pos);
target.writeBoolean(((TEWritingTableMessage) msg).items != null);
newBuffer.writeBoolean(((TEWritingTableMessage) msg).items != null);
if (((TEWritingTableMessage) msg).items != null)
{
int[] items = ((TEWritingTableMessage) msg).items;
for (int j = 0; j < items.length; j++)
{
int i = items[j];
target.writeInt(i);
newBuffer.writeInt(i);
}
}
break;
case 7:
String str = ((ParticleMessage) msg).particle;
target.writeInt(str.length());
for (int i = 0; i < str.length(); i++)
{
target.writeChar(str.charAt(i));
}
newBuffer.writeInt(((ParticleMessage) msg).particle);
target.writeDouble(((ParticleMessage) msg).xCoord);
target.writeDouble(((ParticleMessage) msg).yCoord);
target.writeDouble(((ParticleMessage) msg).zCoord);
newBuffer.writeDouble(((ParticleMessage) msg).xCoord);
newBuffer.writeDouble(((ParticleMessage) msg).yCoord);
newBuffer.writeDouble(((ParticleMessage) msg).zCoord);
target.writeDouble(((ParticleMessage) msg).xVel);
target.writeDouble(((ParticleMessage) msg).yVel);
target.writeDouble(((ParticleMessage) msg).zVel);
newBuffer.writeDouble(((ParticleMessage) msg).xVel);
newBuffer.writeDouble(((ParticleMessage) msg).yVel);
newBuffer.writeDouble(((ParticleMessage) msg).zVel);
break;
case 8:
target.writeDouble(((VelocityMessage) msg).xVel);
target.writeDouble(((VelocityMessage) msg).yVel);
target.writeDouble(((VelocityMessage) msg).zVel);
newBuffer.writeDouble(((VelocityMessage) msg).xVel);
newBuffer.writeDouble(((VelocityMessage) msg).yVel);
newBuffer.writeDouble(((VelocityMessage) msg).zVel);
break;
case 9:
target.writeInt(((TEMasterStoneMessage) msg).x);
target.writeInt(((TEMasterStoneMessage) msg).y);
target.writeInt(((TEMasterStoneMessage) msg).z);
newBuffer.writeBlockPos(((TEMasterStoneMessage) msg).pos);
String ritual = ((TEMasterStoneMessage) msg).ritual;
target.writeInt(ritual.length());
newBuffer.writeInt(ritual.length());
for (int i = 0; i < ritual.length(); i++)
{
target.writeChar(ritual.charAt(i));
newBuffer.writeChar(ritual.charAt(i));
}
target.writeBoolean(((TEMasterStoneMessage) msg).isRunning);
newBuffer.writeBoolean(((TEMasterStoneMessage) msg).isRunning);
break;
case 10:
target.writeInt(((TEReagentConduitMessage) msg).x);
target.writeInt(((TEReagentConduitMessage) msg).y);
target.writeInt(((TEReagentConduitMessage) msg).z);
newBuffer.writeBlockPos(((TEReagentConduitMessage) msg).pos);
List<ColourAndCoords> list = ((TEReagentConduitMessage) msg).destinationList;
target.writeInt(list.size());
newBuffer.writeInt(list.size());
for (ColourAndCoords colourSet : list)
{
target.writeInt(colourSet.colourRed);
target.writeInt(colourSet.colourGreen);
target.writeInt(colourSet.colourBlue);
target.writeInt(colourSet.colourIntensity);
target.writeInt(colourSet.xCoord);
target.writeInt(colourSet.yCoord);
target.writeInt(colourSet.zCoord);
newBuffer.writeInt(colourSet.colourRed);
newBuffer.writeInt(colourSet.colourGreen);
newBuffer.writeInt(colourSet.colourBlue);
newBuffer.writeInt(colourSet.colourIntensity);
newBuffer.writeInt(colourSet.xCoord);
newBuffer.writeInt(colourSet.yCoord);
newBuffer.writeInt(colourSet.zCoord);
}
break;
case 11:
target.writeInt(((CurrentLPMessage) msg).currentLP);
target.writeInt(((CurrentLPMessage) msg).maxLP);
newBuffer.writeInt(((CurrentLPMessage) msg).currentLP);
newBuffer.writeInt(((CurrentLPMessage) msg).maxLP);
break;
case 12:
char[] charSet = ((CurrentReagentBarMessage)msg).reagent.toCharArray();
target.writeInt(charSet.length);
newBuffer.writeInt(charSet.length);
for(char cha : charSet)
{
target.writeChar(cha);
newBuffer.writeChar(cha);
}
target.writeFloat(((CurrentReagentBarMessage)msg).currentAR);
target.writeFloat(((CurrentReagentBarMessage)msg).maxAR);
newBuffer.writeFloat(((CurrentReagentBarMessage)msg).currentAR);
newBuffer.writeFloat(((CurrentReagentBarMessage)msg).maxAR);
break;
case 13:
target.writeFloat(((CurrentAddedHPMessage) msg).currentHP);
target.writeFloat(((CurrentAddedHPMessage) msg).maxHP);
newBuffer.writeFloat(((CurrentAddedHPMessage) msg).currentHP);
newBuffer.writeFloat(((CurrentAddedHPMessage) msg).maxHP);
break;
case 14:
System.out.println("Packet is being encoded");
target.writeByte(((KeyboardMessage)msg).keyPressed);
newBuffer.writeByte(((KeyboardMessage)msg).keyPressed);
break;
}
}
@ -734,15 +697,14 @@ public enum NewPacketHandler
@Override
public void decodeInto(ChannelHandlerContext ctx, ByteBuf dat, BMMessage msg)
{
int index = dat.readInt();
PacketBuffer newBuffer = new PacketBuffer(dat);
int index = newBuffer.readInt();
switch (index)
{
case 0:
((TEAltarMessage) msg).x = dat.readInt();
((TEAltarMessage) msg).y = dat.readInt();
((TEAltarMessage) msg).z = dat.readInt();
boolean hasStacks = dat.readBoolean();
((TEAltarMessage) msg).pos = newBuffer.readBlockPos();
boolean hasStacks = newBuffer.readBoolean();
((TEAltarMessage) msg).items = new int[TEAltar.sizeInv * 3];
if (hasStacks)
@ -750,38 +712,34 @@ public enum NewPacketHandler
((TEAltarMessage) msg).items = new int[TEAltar.sizeInv * 3];
for (int i = 0; i < ((TEAltarMessage) msg).items.length; i++)
{
((TEAltarMessage) msg).items[i] = dat.readInt();
((TEAltarMessage) msg).items[i] = newBuffer.readInt();
}
}
boolean hasFluids = dat.readBoolean();
boolean hasFluids = newBuffer.readBoolean();
((TEAltarMessage) msg).fluids = new int[6];
if (hasFluids)
for (int i = 0; i < ((TEAltarMessage) msg).fluids.length; i++)
{
((TEAltarMessage) msg).fluids[i] = dat.readInt();
((TEAltarMessage) msg).fluids[i] = newBuffer.readInt();
}
((TEAltarMessage) msg).capacity = dat.readInt();
((TEAltarMessage) msg).capacity = newBuffer.readInt();
break;
case 1:
((TEOrientableMessage) msg).x = dat.readInt();
((TEOrientableMessage) msg).y = dat.readInt();
((TEOrientableMessage) msg).z = dat.readInt();
((TEOrientableMessage) msg).pos = newBuffer.readBlockPos();
((TEOrientableMessage) msg).input = dat.readInt();
((TEOrientableMessage) msg).output = dat.readInt();
((TEOrientableMessage) msg).input = newBuffer.readInt();
((TEOrientableMessage) msg).output = newBuffer.readInt();
break;
case 2:
((TEPedestalMessage) msg).x = dat.readInt();
((TEPedestalMessage) msg).y = dat.readInt();
((TEPedestalMessage) msg).z = dat.readInt();
((TEPedestalMessage) msg).pos = newBuffer.readBlockPos();
boolean hasStacks1 = dat.readBoolean();
boolean hasStacks1 = newBuffer.readBoolean();
((TEPedestalMessage) msg).items = new int[TEPedestal.sizeInv * 3];
if (hasStacks1)
@ -789,18 +747,16 @@ public enum NewPacketHandler
((TEPedestalMessage) msg).items = new int[TEPedestal.sizeInv * 3];
for (int i = 0; i < ((TEPedestalMessage) msg).items.length; i++)
{
((TEPedestalMessage) msg).items[i] = dat.readInt();
((TEPedestalMessage) msg).items[i] = newBuffer.readInt();
}
}
break;
case 3:
((TEPlinthMessage) msg).x = dat.readInt();
((TEPlinthMessage) msg).y = dat.readInt();
((TEPlinthMessage) msg).z = dat.readInt();
((TEPlinthMessage) msg).pos = newBuffer.readBlockPos();
boolean hasStacks2 = dat.readBoolean();
boolean hasStacks2 = newBuffer.readBoolean();
((TEPlinthMessage) msg).items = new int[TEPlinth.sizeInv * 3];
if (hasStacks2)
@ -808,18 +764,16 @@ public enum NewPacketHandler
((TEPlinthMessage) msg).items = new int[TEPlinth.sizeInv * 3];
for (int i = 0; i < ((TEPlinthMessage) msg).items.length; i++)
{
((TEPlinthMessage) msg).items[i] = dat.readInt();
((TEPlinthMessage) msg).items[i] = newBuffer.readInt();
}
}
break;
case 4:
((TESocketMessage) msg).x = dat.readInt();
((TESocketMessage) msg).y = dat.readInt();
((TESocketMessage) msg).z = dat.readInt();
((TESocketMessage) msg).pos = newBuffer.readBlockPos();
boolean hasStacks3 = dat.readBoolean();
boolean hasStacks3 = newBuffer.readBoolean();
((TESocketMessage) msg).items = new int[TESocket.sizeInv * 3];
if (hasStacks3)
@ -827,18 +781,16 @@ public enum NewPacketHandler
((TESocketMessage) msg).items = new int[TESocket.sizeInv * 3];
for (int i = 0; i < ((TESocketMessage) msg).items.length; i++)
{
((TESocketMessage) msg).items[i] = dat.readInt();
((TESocketMessage) msg).items[i] = newBuffer.readInt();
}
}
break;
case 5:
((TETeleposerMessage) msg).x = dat.readInt();
((TETeleposerMessage) msg).y = dat.readInt();
((TETeleposerMessage) msg).z = dat.readInt();
((TETeleposerMessage) msg).pos = newBuffer.readBlockPos();
boolean hasStacks4 = dat.readBoolean();
boolean hasStacks4 = newBuffer.readBoolean();
((TETeleposerMessage) msg).items = new int[TETeleposer.sizeInv * 3];
if (hasStacks4)
@ -846,18 +798,16 @@ public enum NewPacketHandler
((TETeleposerMessage) msg).items = new int[TETeleposer.sizeInv * 3];
for (int i = 0; i < ((TETeleposerMessage) msg).items.length; i++)
{
((TETeleposerMessage) msg).items[i] = dat.readInt();
((TETeleposerMessage) msg).items[i] = newBuffer.readInt();
}
}
break;
case 6:
((TEWritingTableMessage) msg).x = dat.readInt();
((TEWritingTableMessage) msg).y = dat.readInt();
((TEWritingTableMessage) msg).z = dat.readInt();
((TEWritingTableMessage) msg).pos = newBuffer.readBlockPos();
boolean hasStacks5 = dat.readBoolean();
boolean hasStacks5 = newBuffer.readBoolean();
((TEWritingTableMessage) msg).items = new int[TEWritingTable.sizeInv * 3];
if (hasStacks5)
@ -865,70 +815,58 @@ public enum NewPacketHandler
((TEWritingTableMessage) msg).items = new int[TEWritingTable.sizeInv * 3];
for (int i = 0; i < ((TEWritingTableMessage) msg).items.length; i++)
{
((TEWritingTableMessage) msg).items[i] = dat.readInt();
((TEWritingTableMessage) msg).items[i] = newBuffer.readInt();
}
}
break;
case 7:
int size = dat.readInt();
String str = "";
((ParticleMessage) msg).particle = newBuffer.readInt();
for (int i = 0; i < size; i++)
{
str = str + dat.readChar();
}
((ParticleMessage) msg).xCoord = newBuffer.readDouble();
((ParticleMessage) msg).yCoord = newBuffer.readDouble();
((ParticleMessage) msg).zCoord = newBuffer.readDouble();
((ParticleMessage) msg).particle = str;
((ParticleMessage) msg).xCoord = dat.readDouble();
((ParticleMessage) msg).yCoord = dat.readDouble();
((ParticleMessage) msg).zCoord = dat.readDouble();
((ParticleMessage) msg).xVel = dat.readDouble();
((ParticleMessage) msg).yVel = dat.readDouble();
((ParticleMessage) msg).zVel = dat.readDouble();
((ParticleMessage) msg).xVel = newBuffer.readDouble();
((ParticleMessage) msg).yVel = newBuffer.readDouble();
((ParticleMessage) msg).zVel = newBuffer.readDouble();
break;
case 8:
((VelocityMessage) msg).xVel = dat.readDouble();
((VelocityMessage) msg).yVel = dat.readDouble();
((VelocityMessage) msg).zVel = dat.readDouble();
((VelocityMessage) msg).xVel = newBuffer.readDouble();
((VelocityMessage) msg).yVel = newBuffer.readDouble();
((VelocityMessage) msg).zVel = newBuffer.readDouble();
break;
case 9:
((TEMasterStoneMessage) msg).x = dat.readInt();
((TEMasterStoneMessage) msg).y = dat.readInt();
((TEMasterStoneMessage) msg).z = dat.readInt();
((TEMasterStoneMessage) msg).pos = newBuffer.readBlockPos();
int ritualStrSize = dat.readInt();
int ritualStrSize = newBuffer.readInt();
String ritual = "";
for (int i = 0; i < ritualStrSize; i++)
{
ritual = ritual + dat.readChar();
ritual = ritual + newBuffer.readChar();
}
((TEMasterStoneMessage) msg).ritual = ritual;
((TEMasterStoneMessage) msg).isRunning = dat.readBoolean();
((TEMasterStoneMessage) msg).isRunning = newBuffer.readBoolean();
break;
case 10:
((TEReagentConduitMessage) msg).x = dat.readInt();
((TEReagentConduitMessage) msg).y = dat.readInt();
((TEReagentConduitMessage) msg).z = dat.readInt();
int listSize = dat.readInt();
((TEReagentConduitMessage) msg).pos = newBuffer.readBlockPos();
int listSize = newBuffer.readInt();
List<ColourAndCoords> list = new LinkedList();
for (int i = 0; i < listSize; i++)
{
list.add(new ColourAndCoords(dat.readInt(), dat.readInt(), dat.readInt(), dat.readInt(), dat.readInt(), dat.readInt(), dat.readInt()));
list.add(new ColourAndCoords(newBuffer.readInt(), newBuffer.readInt(), newBuffer.readInt(), newBuffer.readInt(), newBuffer.readInt(), newBuffer.readInt(), newBuffer.readInt()));
}
((TEReagentConduitMessage) msg).destinationList = list;
@ -936,34 +874,34 @@ public enum NewPacketHandler
break;
case 11:
((CurrentLPMessage) msg).currentLP = dat.readInt();
((CurrentLPMessage) msg).maxLP = dat.readInt();
((CurrentLPMessage) msg).currentLP = newBuffer.readInt();
((CurrentLPMessage) msg).maxLP = newBuffer.readInt();
break;
case 12:
int size1 = dat.readInt();
int size1 = newBuffer.readInt();
String str1 = "";
for(int i=0; i<size1; i++)
{
str1 = str1 + dat.readChar();
str1 = str1 + newBuffer.readChar();
}
((CurrentReagentBarMessage) msg).reagent = str1;
((CurrentReagentBarMessage) msg).currentAR = dat.readFloat();
((CurrentReagentBarMessage) msg).maxAR = dat.readFloat();
((CurrentReagentBarMessage) msg).currentAR = newBuffer.readFloat();
((CurrentReagentBarMessage) msg).maxAR = newBuffer.readFloat();
break;
case 13:
((CurrentAddedHPMessage) msg).currentHP = dat.readFloat();
((CurrentAddedHPMessage) msg).maxHP = dat.readFloat();
((CurrentAddedHPMessage) msg).currentHP = newBuffer.readFloat();
((CurrentAddedHPMessage) msg).maxHP = newBuffer.readFloat();
break;
case 14:
System.out.println("Packet recieved: being decoded");
((KeyboardMessage)msg).keyPressed = dat.readByte();
((KeyboardMessage)msg).keyPressed = newBuffer.readByte();
break;
}
}
@ -974,9 +912,7 @@ public enum NewPacketHandler
{
TEAltarMessage msg = new TEAltarMessage();
msg.index = 0;
msg.x = tileAltar.xCoord;
msg.y = tileAltar.yCoord;
msg.z = tileAltar.zCoord;
msg.pos = tileAltar.getPos();
msg.items = tileAltar.buildIntDataList();
msg.fluids = tileAltar.buildFluidList();
msg.capacity = tileAltar.getCapacity();
@ -988,11 +924,9 @@ public enum NewPacketHandler
{
TEOrientableMessage msg = new TEOrientableMessage();
msg.index = 1;
msg.x = tileOrientable.xCoord;
msg.y = tileOrientable.yCoord;
msg.z = tileOrientable.zCoord;
msg.input = tileOrientable.getIntForForgeDirection(tileOrientable.getInputDirection());
msg.output = tileOrientable.getIntForForgeDirection(tileOrientable.getOutputDirection());
msg.pos = tileOrientable.getPos();
msg.input = tileOrientable.getIntForEnumFacing(tileOrientable.getInputDirection());
msg.output = tileOrientable.getIntForEnumFacing(tileOrientable.getOutputDirection());
return INSTANCE.channels.get(Side.SERVER).generatePacketFrom(msg);
}
@ -1001,9 +935,7 @@ public enum NewPacketHandler
{
TEPedestalMessage msg = new TEPedestalMessage();
msg.index = 2;
msg.x = tilePedestal.xCoord;
msg.y = tilePedestal.yCoord;
msg.z = tilePedestal.zCoord;
msg.pos = tilePedestal.getPos();
msg.items = tilePedestal.buildIntDataList();
return INSTANCE.channels.get(Side.SERVER).generatePacketFrom(msg);
@ -1013,9 +945,7 @@ public enum NewPacketHandler
{
TEPlinthMessage msg = new TEPlinthMessage();
msg.index = 3;
msg.x = tilePlinth.xCoord;
msg.y = tilePlinth.yCoord;
msg.z = tilePlinth.zCoord;
msg.pos = tilePlinth.getPos();
msg.items = tilePlinth.buildIntDataList();
return INSTANCE.channels.get(Side.SERVER).generatePacketFrom(msg);
@ -1025,9 +955,7 @@ public enum NewPacketHandler
{
TESocketMessage msg = new TESocketMessage();
msg.index = 4;
msg.x = tileSocket.xCoord;
msg.y = tileSocket.yCoord;
msg.z = tileSocket.zCoord;
msg.pos = tileSocket.getPos();
msg.items = tileSocket.buildIntDataList();
return INSTANCE.channels.get(Side.SERVER).generatePacketFrom(msg);
@ -1037,9 +965,7 @@ public enum NewPacketHandler
{
TETeleposerMessage msg = new TETeleposerMessage();
msg.index = 5;
msg.x = tileTeleposer.xCoord;
msg.y = tileTeleposer.yCoord;
msg.z = tileTeleposer.zCoord;
msg.pos = tileTeleposer.getPos();
msg.items = tileTeleposer.buildIntDataList();
return INSTANCE.channels.get(Side.SERVER).generatePacketFrom(msg);
@ -1049,19 +975,17 @@ public enum NewPacketHandler
{
TEWritingTableMessage msg = new TEWritingTableMessage();
msg.index = 6;
msg.x = tileWritingTable.xCoord;
msg.y = tileWritingTable.yCoord;
msg.z = tileWritingTable.zCoord;
msg.pos = tileWritingTable.getPos();
msg.items = tileWritingTable.buildIntDataList();
return INSTANCE.channels.get(Side.SERVER).generatePacketFrom(msg);
}
public static Packet getParticlePacket(String str, double xCoord, double yCoord, double zCoord, double xVel, double yVel, double zVel)
public static Packet getParticlePacket(EnumParticleTypes type, double xCoord, double yCoord, double zCoord, double xVel, double yVel, double zVel)
{
ParticleMessage msg = new ParticleMessage();
msg.index = 7;
msg.particle = str;
msg.particle = type.ordinal();
msg.xCoord = xCoord;
msg.yCoord = yCoord;
msg.zCoord = zCoord;
@ -1087,9 +1011,7 @@ public enum NewPacketHandler
{
TEMasterStoneMessage msg = new TEMasterStoneMessage();
msg.index = 9;
msg.x = tile.xCoord;
msg.y = tile.yCoord;
msg.z = tile.zCoord;
msg.pos = tile.getPos();
msg.ritual = tile.getCurrentRitual();
msg.isRunning = tile.isRunning;
@ -1101,9 +1023,7 @@ public enum NewPacketHandler
{
TEReagentConduitMessage msg = new TEReagentConduitMessage();
msg.index = 10;
msg.x = tile.xCoord;
msg.y = tile.yCoord;
msg.z = tile.zCoord;
msg.pos = tile.getPos();
msg.destinationList = tile.destinationList;

View file

@ -3,7 +3,6 @@ package WayofTime.alchemicalWizardry.common.achievements;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement;
@ -33,25 +32,13 @@ public class AchievementTrigger
{
for (Item item : AchievementsRegistry.craftinglist)
{
if (event.crafting != null)
if (event.crafting != null && event.crafting.getItem() == item)
{
if (event.crafting.getItem() == item)
{
Achievement achievement = AchievementsRegistry.getAchievementForItem(event.crafting.getItem());
Achievement achievement = AchievementsRegistry.getAchievementForItem(event.crafting.getItem());
if (achievement != null)
{
event.player.addStat(achievement, 1);
}
}
if (event.crafting.getItem() instanceof ItemBlock)
if (achievement != null)
{
Achievement achievement = AchievementsRegistry.getAchievementForBlock(((ItemBlock) event.crafting.getItem()).field_150939_a);
if (achievement != null)
{
event.player.addStat(achievement, 1);
}
event.player.addStat(achievement, 1);
}
}
}

View file

@ -1,9 +1,6 @@
package WayofTime.alchemicalWizardry.common.achievements;
import WayofTime.alchemicalWizardry.ModBlocks;
import WayofTime.alchemicalWizardry.ModItems;
import WayofTime.alchemicalWizardry.common.items.ItemRitualDiviner;
import WayofTime.alchemicalWizardry.common.items.armour.BoundArmour;
import net.minecraft.item.Item;
import net.minecraft.block.Block;
import net.minecraft.stats.Achievement;
@ -13,92 +10,40 @@ import java.util.List;
public class AchievementsRegistry
{
public final static List<Item> craftinglist = new ArrayList<Item>();
public final static List<Item> pickupList = new ArrayList<Item>();
public final static List<Block> blockCraftingList = new ArrayList<Block>();
// public final static List<Block> blockPickupList = new ArrayList<Block>();
public final static List<Item> craftinglist = new ArrayList();
public final static List<Item> pickupList = new ArrayList();
public static void init()
{
addItemsToCraftingList();
addBlocksToCraftingList();
addItemsToPickupList();
// addBlocksToPickupList();
}
public static void addItemsToCraftingList()
{
craftinglist.add(ModItems.sacrificialDagger);
craftinglist.add(ModItems.itemBloodPack);
craftinglist.add(ModItems.waterSigil);
craftinglist.add(ModItems.airSigil);
craftinglist.add(ModItems.sigilOfHolding);
craftinglist.add(ModItems.itemRitualDiviner);
craftinglist.add(ModItems.sigilOfTheBridge);
craftinglist.add(ModItems.itemSigilOfSupression);
craftinglist.add(ModItems.energyBazooka);
}
public static void addBlocksToCraftingList()
{
blockCraftingList.add(ModBlocks.bloodRune);
blockCraftingList.add(ModBlocks.blockWritingTable);
blockCraftingList.add(ModBlocks.blockTeleposer);
}
public static void addItemsToPickupList()
{
pickupList.add(ModItems.weakBloodOrb);
pickupList.add(ModItems.apprenticeBloodOrb);
pickupList.add(ModItems.daggerOfSacrifice);
pickupList.add(ModItems.magicianBloodOrb);
pickupList.add(ModItems.energySword);
pickupList.add(ModItems.boundHelmet);
pickupList.add(ModItems.boundPlate);
pickupList.add(ModItems.boundLeggings);
pickupList.add(ModItems.boundBoots);
pickupList.add(ModItems.itemComplexSpellCrystal);
pickupList.add(ModItems.masterBloodOrb);
pickupList.add(ModItems.archmageBloodOrb);
pickupList.add(ModItems.transcendentBloodOrb);
}
public static void addBlocksToPickupList()
{
}
public static Achievement getAchievementForItem(Item item)
{
if (item == ModItems.sacrificialDagger) return ModAchievements.firstPrick;
if (item == ModItems.weakBloodOrb) return ModAchievements.weakOrb;
if (item == ModItems.itemBloodPack) return ModAchievements.bloodLettersPack;
if (item == ModItems.waterSigil) return ModAchievements.waterSigil;
if (item == ModItems.apprenticeBloodOrb) return ModAchievements.apprenticeOrb;
if (item == ModItems.airSigil) return ModAchievements.airSigil;
if (item == ModItems.daggerOfSacrifice) return ModAchievements.daggerOfSacrifice;
if (item == ModItems.magicianBloodOrb) return ModAchievements.magicianOrb;
if (item == ModItems.sigilOfHolding) return ModAchievements.sigilHolding;
if (item == ModItems.energySword) return ModAchievements.boundBlade;
if (item instanceof BoundArmour) return ModAchievements.boundArmor;
if (item == ModItems.itemComplexSpellCrystal) return ModAchievements.complexSpells;
if (item instanceof ItemRitualDiviner) return ModAchievements.ritualDiviner;
if (item == ModItems.masterBloodOrb) return ModAchievements.masterOrb;
if (item == ModItems.sigilOfTheBridge) return ModAchievements.phantomBridgeSigil;
if (item == ModItems.itemSigilOfSupression) return ModAchievements.suppressionSigil;
if (item == ModItems.archmageBloodOrb) return ModAchievements.archmageOrb;
if (item == ModItems.energyBazooka) return ModAchievements.energyBazooka;
if (item == ModItems.transcendentBloodOrb) return ModAchievements.transcendentOrb;
if (item == ModItems.sacrificialDagger)
{
return ModAchievements.firstPrick;
}
if (item == ModItems.weakBloodOrb)
{
return ModAchievements.weakOrb;
}
return null;
}
public static Achievement getAchievementForBlock(Block block)
{
if (block == ModBlocks.bloodRune) return ModAchievements.blankRunes;
if (block == ModBlocks.blockWritingTable) return ModAchievements.brewingPotions;
if (block == ModBlocks.blockTeleposer) return ModAchievements.teleposer;
return null;
}
}

View file

@ -0,0 +1,11 @@
package WayofTime.alchemicalWizardry.common.achievements;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement;
public interface ICraftAchievement
{
Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix);
}

View file

@ -0,0 +1,11 @@
package WayofTime.alchemicalWizardry.common.achievements;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement;
public interface IPickupAchievement
{
Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item);
}

View file

@ -1,8 +1,7 @@
package WayofTime.alchemicalWizardry.common.achievements;
import WayofTime.alchemicalWizardry.ModBlocks;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.AchievementPage;
import WayofTime.alchemicalWizardry.ModItems;
import cpw.mods.fml.common.FMLCommonHandler;
@ -13,57 +12,13 @@ public class ModAchievements
public static Achievement firstPrick;
public static Achievement weakOrb;
public static Achievement bloodLettersPack;
public static Achievement waterSigil;
public static Achievement blankRunes;
public static Achievement apprenticeOrb;
public static Achievement airSigil;
public static Achievement daggerOfSacrifice;
public static Achievement brewingPotions;
public static Achievement magicianOrb;
public static Achievement sigilHolding;
public static Achievement boundBlade;
public static Achievement boundArmor;
public static Achievement complexSpells;
public static Achievement ritualDiviner;
public static Achievement masterOrb;
public static Achievement demonSpawn;
public static Achievement phantomBridgeSigil;
public static Achievement teleposer;
public static Achievement suppressionSigil;
public static Achievement archmageOrb;
public static Achievement energyBazooka;
public static Achievement demons;
public static Achievement transcendentOrb;
public static void init()
{
firstPrick = new AchievementsMod("firstPrick", 0, 0, ModItems.sacrificialDagger, null).setSpecial();
weakOrb = new AchievementsMod("weakOrb", 3, 0, ModItems.weakBloodOrb, firstPrick);
bloodLettersPack = new AchievementsMod("bloodLettersPack", 3, 2, ModItems.itemBloodPack, weakOrb);
waterSigil = new AchievementsMod("waterSigil", 6, 2, ModItems.waterSigil, weakOrb);
blankRunes = new AchievementsMod("blankRunes", 4, -2, ModBlocks.bloodRune, weakOrb);
apprenticeOrb = new AchievementsMod("apprenticeOrb", 4, -4, ModItems.apprenticeBloodOrb, blankRunes);
airSigil = new AchievementsMod("airSigil", 6, 1, ModItems.airSigil, apprenticeOrb);
daggerOfSacrifice = new AchievementsMod("daggerSacrifice", 4, -5, ModItems.daggerOfSacrifice, apprenticeOrb);
brewingPotions = new AchievementsMod("brewingPotions", 6, -3, ModBlocks.blockWritingTable, apprenticeOrb);
magicianOrb = new AchievementsMod("magicianOrb", 2, -2, ModItems.magicianBloodOrb, apprenticeOrb);
sigilHolding = new AchievementsMod("sigilHolding", 6, 0, ModItems.sigilOfHolding, magicianOrb);
boundBlade = new AchievementsMod("boundBlade", 0, -2, ModItems.energySword, magicianOrb);
boundArmor = new AchievementsMod("boundArmor", 1, -1, ModItems.boundPlate, magicianOrb);
complexSpells = new AchievementsMod("complexSpells", 1, -4, ModItems.itemComplexSpellCrystal, magicianOrb);
ritualDiviner = new AchievementsMod("ritualDiviner", 1, -3, ModItems.itemRitualDiviner, magicianOrb);
masterOrb = new AchievementsMod("masterOrb", -2, -1, ModItems.masterBloodOrb, boundBlade);
demonSpawn = new AchievementsMod("demonSpawn", -3, -2, ModItems.demonPlacer, masterOrb);
phantomBridgeSigil = new AchievementsMod("phantomBridgeSigil", 6, -1, ModItems.sigilOfTheBridge, masterOrb);
teleposer = new AchievementsMod("teleposer", -4, -1, ModBlocks.blockTeleposer, masterOrb);
suppressionSigil = new AchievementsMod("suppressionSigil", 6, -2, ModItems.itemSigilOfSupression, masterOrb);
archmageOrb = new AchievementsMod("archmageOrb", -1, 2, ModItems.archmageBloodOrb, masterOrb);
energyBazooka = new AchievementsMod("energyBazooka", -3, 2, ModItems.energyBazooka, archmageOrb);
demons = new AchievementsMod("demons", 0, 3, new ItemStack(ModItems.baseItems, 1, 29), archmageOrb).setSpecial();
transcendentOrb = new AchievementsMod("trancsendentOrb", 0, 5, ModItems.transcendentBloodOrb, demons);
firstPrick = new AchievementsMod(StatCollector.translateToLocal("firstPrick"), 0, 0, ModItems.sacrificialDagger, null);
weakOrb = new AchievementsMod(StatCollector.translateToLocal("weakOrb"), 3, 0, ModItems.weakBloodOrb, firstPrick);
alchemicalWizardryPage = new AchievementPage("Blood Magic", AchievementsMod.achievements.toArray(new Achievement[AchievementsMod.achievements.size()]));
alchemicalWizardryPage = new AchievementPage("AlchemicalWizardry", AchievementsMod.achievements.toArray(new Achievement[AchievementsMod.achievements.size()]));
AchievementPage.registerAchievementPage(alchemicalWizardryPage);
AchievementsRegistry.init();
FMLCommonHandler.instance().bus().register(new AchievementTrigger());

View file

@ -157,7 +157,7 @@ public class ArmourForge extends Block
for (int i = 0; i < 8; i++)
{
SpellHelper.sendIndexedParticleToAllAround(world, xCoord, yCoord, zCoord, 20, world.provider.dimensionId, 1, xCoord, yCoord, zCoord);
SpellHelper.sendIndexedParticleToAllAround(world, xCoord, yCoord, zCoord, 20, world.provider.getDimensionId(), 1, xCoord, yCoord, zCoord);
}
if (itemStack != null)

View file

@ -82,7 +82,7 @@ public class BlockHomHeart extends BlockContainer
itemTag.setInteger("xCoord", x);
itemTag.setInteger("yCoord", y);
itemTag.setInteger("zCoord", z);
itemTag.setInteger("dimensionId", world.provider.dimensionId);
itemTag.setInteger("dimensionId", world.provider.getDimensionId());
return true;
}
}

View file

@ -64,7 +64,7 @@ public class BlockSpellParadigm extends BlockOrientable
itemTag.setInteger("xCoord", x);
itemTag.setInteger("yCoord", y);
itemTag.setInteger("zCoord", z);
itemTag.setInteger("dimensionId", world.provider.dimensionId);
itemTag.setInteger("dimensionId", world.provider.getDimensionId());
return true;
}

View file

@ -7,7 +7,7 @@ import net.minecraft.block.BlockContainer;
import net.minecraft.block.BlockMobSpawner;
import net.minecraft.block.BlockPortal;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
@ -15,9 +15,14 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Optional;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.api.event.TeleposeEvent;
import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
@ -26,9 +31,7 @@ import WayofTime.alchemicalWizardry.common.items.TelepositionFocus;
import WayofTime.alchemicalWizardry.common.tileEntity.TETeleposer;
import codechicken.multipart.MultipartHelper;
import codechicken.multipart.TileMultipart;
import cpw.mods.fml.common.Optional;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockTeleposer extends BlockContainer
{
@ -45,35 +48,35 @@ public class BlockTeleposer extends BlockContainer
setHardness(2.0F);
setResistance(5.0F);
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
this.setBlockName("bloodTeleposer");
this.setUnlocalizedName("bloodTeleposer");
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister)
{
this.topIcon = iconRegister.registerIcon("AlchemicalWizardry:Teleposer_Top");
this.sideIcon2 = iconRegister.registerIcon("AlchemicalWizardry:Teleposer_Side");
this.bottomIcon = iconRegister.registerIcon("AlchemicalWizardry:Teleposer_Side");
}
// @Override
// @SideOnly(Side.CLIENT)
// public void registerBlockIcons(IIconRegister iconRegister)
// {
// this.topIcon = iconRegister.registerIcon("AlchemicalWizardry:Teleposer_Top");
// this.sideIcon2 = iconRegister.registerIcon("AlchemicalWizardry:Teleposer_Side");
// this.bottomIcon = iconRegister.registerIcon("AlchemicalWizardry:Teleposer_Side");
// }
//
// @Override
// @SideOnly(Side.CLIENT)
// public IIcon getIcon(int side, int meta)
// {
// switch (side)
// {
// case 0:
// return bottomIcon;
// case 1:
// return topIcon;
// default:
// return sideIcon2;
// }
// }
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta)
{
switch (side)
{
case 0:
return bottomIcon;
case 1:
return topIcon;
default:
return sideIcon2;
}
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int idk, float what, float these, float are)
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ)
{
ItemStack playerItem = player.getCurrentEquippedItem();
@ -89,28 +92,28 @@ public class BlockTeleposer extends BlockContainer
}
NBTTagCompound itemTag = playerItem.getTagCompound();
itemTag.setInteger("xCoord", x);
itemTag.setInteger("yCoord", y);
itemTag.setInteger("zCoord", z);
itemTag.setInteger("dimensionId", world.provider.dimensionId);
itemTag.setInteger("xCoord", pos.getX());
itemTag.setInteger("yCoord", pos.getY());
itemTag.setInteger("zCoord", pos.getZ());
itemTag.setInteger("dimensionId", world.provider.getDimensionId());
return true;
}
}
player.openGui(AlchemicalWizardry.instance, 1, world, x, y, z);
player.openGui(AlchemicalWizardry.instance, 1, world, pos.getX(), pos.getY(), pos.getZ());
return true;
}
@Override
public void breakBlock(World world, int x, int y, int z, Block par5, int par6)
public void breakBlock(World world, BlockPos pos, IBlockState state)
{
dropItems(world, x, y, z);
super.breakBlock(world, x, y, z, par5, par6);
dropItems(world, pos);
super.breakBlock(world, pos, state);
}
private void dropItems(World world, int x, int y, int z)
private void dropItems(World world, BlockPos pos)
{
Random rand = new Random();
TileEntity tileEntity = world.getTileEntity(x, y, z);
TileEntity tileEntity = world.getTileEntity(pos);
if (!(tileEntity instanceof IInventory))
{
@ -128,7 +131,7 @@ public class BlockTeleposer extends BlockContainer
float rx = rand.nextFloat() * 0.8F + 0.1F;
float ry = rand.nextFloat() * 0.8F + 0.1F;
float rz = rand.nextFloat() * 0.8F + 0.1F;
EntityItem entityItem = new EntityItem(world, x + rx, y + ry, z + rz, new ItemStack(item.getItem(), item.stackSize, item.getItemDamage()));
EntityItem entityItem = new EntityItem(world, pos.getX() + rx, pos.getY() + ry, pos.getZ() + rz, new ItemStack(item.getItem(), item.stackSize, item.getItemDamage()));
if (item.hasTagCompound())
{
@ -151,20 +154,20 @@ public class BlockTeleposer extends BlockContainer
return new TETeleposer();
}
public static boolean swapBlocks(Object caller, World worldI, World worldF, int xi, int yi, int zi, int xf, int yf, int zf)
public static boolean swapBlocks(Object caller, World worldI, World worldF, BlockPos posi, BlockPos posf)
{
return swapBlocks(caller, worldI, worldF, xi, yi, zi, xf, yf, zf, true, 3);
return swapBlocks(caller, worldI, worldF, posi, posf, true, 3);
}
public static boolean swapBlocksWithoutSound(Object caller, World worldI, World worldF, int xi, int yi, int zi, int xf, int yf, int zf)
public static boolean swapBlocksWithoutSound(Object caller, World worldI, World worldF, BlockPos posi, BlockPos posf)
{
return swapBlocks(caller, worldI, worldF, xi, yi, zi, xf, yf, zf, false, 3);
return swapBlocks(caller, worldI, worldF, posi, posf, false, 3);
}
public static boolean swapBlocks(Object caller, World worldI, World worldF, int xi, int yi, int zi, int xf, int yf, int zf, boolean doSound, int flag)
public static boolean swapBlocks(Object caller, World worldI, World worldF, BlockPos posi, BlockPos posf, boolean doSound, int flag)
{
TileEntity tileEntityI = worldI.getTileEntity(xi, yi, zi);
TileEntity tileEntityF = worldF.getTileEntity(xf, yf, zf);
TileEntity tileEntityI = worldI.getTileEntity(posi);
TileEntity tileEntityF = worldF.getTileEntity(posf);
NBTTagCompound nbttag1 = new NBTTagCompound();
NBTTagCompound nbttag2 = new NBTTagCompound();
@ -179,8 +182,10 @@ public class BlockTeleposer extends BlockContainer
tileEntityF.writeToNBT(nbttag2);
}
Block blockI = worldI.getBlock(xi, yi, zi);
Block blockF = worldF.getBlock(xf, yf, zf);
IBlockState stateI = worldI.getBlockState(posi);
Block blockI = stateI.getBlock();
IBlockState stateF = worldF.getBlockState(posf);
Block blockF = stateF.getBlock();
if (blockI.equals(Blocks.air) && blockF.equals(Blocks.air))
@ -192,18 +197,15 @@ public class BlockTeleposer extends BlockContainer
{
return false;
}
int metaI = worldI.getBlockMetadata(xi, yi, zi);
int metaF = worldF.getBlockMetadata(xf, yf, zf);
TeleposeEvent evt = new TeleposeEvent(worldI, xi, yi, zi, blockI, metaI, worldF, xf, yf, zf, blockF, metaF);
TeleposeEvent evt = new TeleposeEvent(worldI, posi, stateI, worldF, posf, stateF);
if (MinecraftForge.EVENT_BUS.post(evt))
return false;
if(doSound)
{
worldI.playSoundEffect(xi, yi, zi, "mob.endermen.portal", 1.0F, 1.0F);
worldF.playSoundEffect(xf, yf, zf, "mob.endermen.portal", 1.0F, 1.0F);
worldI.playSoundEffect(posi.getX(), posi.getY(), posi.getZ(), "mob.endermen.portal", 1.0F, 1.0F);
worldF.playSoundEffect(posf.getX(), posf.getY(), posf.getZ(), "mob.endermen.portal", 1.0F, 1.0F);
}
//CLEAR TILES
@ -211,20 +213,20 @@ public class BlockTeleposer extends BlockContainer
if (finalBlock != null)
{
TileEntity tileToSet = finalBlock.createTileEntity(worldF, metaF);
TileEntity tileToSet = finalBlock.createTileEntity(worldF, stateF);
worldF.setTileEntity(xf, yf, zf, tileToSet);
worldF.setTileEntity(posf, tileToSet);
}
if (blockI != null)
{
TileEntity tileToSet = blockI.createTileEntity(worldI, metaI);
TileEntity tileToSet = blockI.createTileEntity(worldI, stateI);
worldI.setTileEntity(xi, yi, zi, tileToSet);
worldI.setTileEntity(posi, tileToSet);
}
//TILES CLEARED
worldF.setBlock(xf, yf, zf, blockI, metaI, flag);
worldF.setBlockState(posf, stateI, flag);
if (tileEntityI != null)
{
@ -235,19 +237,16 @@ public class BlockTeleposer extends BlockContainer
newTileEntityI = createMultipartFromNBT(worldF, nbttag1);
}
worldF.setTileEntity(xf, yf, zf, newTileEntityI);
newTileEntityI.xCoord = xf;
newTileEntityI.yCoord = yf;
newTileEntityI.zCoord = zf;
worldF.setTileEntity(posf, newTileEntityI);
newTileEntityI.setPos(posf);
if(AlchemicalWizardry.isFMPLoaded && isMultipart(tileEntityI))
{
sendDescriptorOfTile(worldF, newTileEntityI);
}
}
worldI.setBlock(xi, yi, zi, finalBlock, metaF, flag);
worldI.setBlockState(posi, stateF, flag);
if (tileEntityF != null)
{
@ -257,11 +256,9 @@ public class BlockTeleposer extends BlockContainer
newTileEntityF = createMultipartFromNBT(worldI, nbttag2);
}
worldI.setTileEntity(xi, yi, zi, newTileEntityF);
worldI.setTileEntity(posi, newTileEntityF);
newTileEntityF.xCoord = xi;
newTileEntityF.yCoord = yi;
newTileEntityF.zCoord = zi;
newTileEntityF.setPos(posi);
if(AlchemicalWizardry.isFMPLoaded && isMultipart(tileEntityF))
{

View file

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

View file

@ -1,6 +1,7 @@
package WayofTime.alchemicalWizardry.common.bloodAltarUpgrade;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
public class AltarComponent
{
@ -47,6 +48,11 @@ public class AltarComponent
{
return metadata;
}
public IBlockState getBlockState()
{
return block.getStateFromMeta(getMetadata());
}
public boolean isBloodRune()
{

View file

@ -4,7 +4,9 @@ import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.ModBlocks;
import WayofTime.alchemicalWizardry.api.altarRecipeRegistry.IFadedRune;
@ -19,11 +21,11 @@ public class UpgradedAltars
public static List<AltarComponent> sixthTierAltar = new ArrayList();
public static int highestAltar = 6;
public static int isAltarValid(World world, int x, int y, int z)
public static int isAltarValid(World world, BlockPos pos)
{
for (int i = highestAltar; i >= 2; i--)
{
if (checkAltarIsValid(world, x, y, z, i))
if (checkAltarIsValid(world, pos, i))
{
return i;
}
@ -32,144 +34,37 @@ public class UpgradedAltars
return 1;
}
public static boolean checkAltarIsValid(World world, int x, int y, int z, int altarTier)
public static boolean checkAltarIsValid(World world, BlockPos pos, int altarTier)
{
switch (altarTier)
List<AltarComponent> list = UpgradedAltars.getAltarUpgradeListForTier(altarTier);
for (AltarComponent ac : list)
{
case 1:
return true;
case 2:
for (AltarComponent ac : secondTierAltar)
BlockPos newPos = pos.add(ac.getX(), ac.getY(), ac.getZ());
IBlockState state = world.getBlockState(newPos);
Block block = state.getBlock();
if (ac.isBloodRune())
{
if (!(block instanceof BloodRune))
{
if (ac.isBloodRune())
{
Block testBlock = world.getBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ());
if (!(testBlock instanceof BloodRune))
{
return false;
}
} else
{
Block block = world.getBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ());
int metadata = world.getBlockMetadata(x + ac.getX(), y + ac.getY(), z + ac.getZ());
if (((ac.getBlock() != block) || (ac.getMetadata() != metadata)) && !(ac.getBlock() == Blocks.stonebrick && !world.isAirBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ())))
{
return false;
}
}
return false;
}
} else
{
int metadata = block.getMetaFromState(state);
return true;
case 3:
for (AltarComponent ac : thirdTierAltar)
if (((ac.getBlock() != block) || (ac.getMetadata() != metadata)) && !(ac.getBlock() == Blocks.stonebrick && !world.isAirBlock(newPos)))
{
if (ac.isBloodRune())
{
Block testBlock = world.getBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ());
if (!(testBlock instanceof BloodRune))
{
return false;
}
} else
{
Block block = world.getBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ());
int metadata = world.getBlockMetadata(x + ac.getX(), y + ac.getY(), z + ac.getZ());
if (((ac.getBlock() != block) || (ac.getMetadata() != metadata)) && !(ac.getBlock() == Blocks.stonebrick && !world.isAirBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ())))
{
return false;
}
}
return false;
}
return true;
case 4:
for (AltarComponent ac : fourthTierAltar)
{
if (ac.isBloodRune())
{
Block testBlock = world.getBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ());
if (!(testBlock instanceof BloodRune))
{
return false;
}
} else
{
Block block = world.getBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ());
int metadata = world.getBlockMetadata(x + ac.getX(), y + ac.getY(), z + ac.getZ());
if (((ac.getBlock() != block) || (ac.getMetadata() != metadata)) && !(ac.getBlock() == Blocks.stonebrick && !world.isAirBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ())))
{
return false;
}
}
}
return true;
case 5:
for (AltarComponent ac : fifthTierAltar)
{
if (ac.isBloodRune())
{
Block testBlock = world.getBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ());
if (!(testBlock instanceof BloodRune))
{
return false;
}
} else
{
Block block = world.getBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ());
int metadata = world.getBlockMetadata(x + ac.getX(), y + ac.getY(), z + ac.getZ());
if (((ac.getBlock() != block) || (ac.getMetadata() != metadata)) && !(ac.getBlock() == Blocks.stonebrick && !world.isAirBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ())))
{
return false;
}
}
}
return true;
case 6:
for (AltarComponent ac : sixthTierAltar)
{
if (ac.isBloodRune())
{
Block testBlock = world.getBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ());
if (!(testBlock instanceof BloodRune))
{
return false;
}
} else
{
Block block = world.getBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ());
int metadata = world.getBlockMetadata(x + ac.getX(), y + ac.getY(), z + ac.getZ());
if (((ac.getBlock() != block) || (ac.getMetadata() != metadata)) && !(ac.getBlock() == Blocks.stonebrick && !world.isAirBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ())))
{
return false;
}
}
}
return true;
default:
return false;
}
}
return true;
}
public static AltarUpgradeComponent getUpgrades(World world, int x, int y, int z, int altarTier)
public static AltarUpgradeComponent getUpgrades(World world, BlockPos pos, int altarTier)
{
if(world.isRemote)
{
@ -180,18 +75,21 @@ public class UpgradedAltars
for (AltarComponent ac : list)
{
BlockPos newPos = pos.add(ac.getX(), ac.getY(), ac.getZ());
if (ac.isUpgradeSlot())
{
//Currently checks the getRuneEffect.
//TODO Change so that it uses the metadata instead, with the BlockID.
Block testBlock = world.getBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ());
int meta = world.getBlockMetadata(x + ac.getX(), y + ac.getY(), z + ac.getZ());
IBlockState state = world.getBlockState(newPos);
Block testBlock = state.getBlock();
int meta = testBlock.getMetaFromState(state);
if (testBlock instanceof BloodRune)
{
if (testBlock instanceof IFadedRune && altarTier > ((IFadedRune)testBlock).getAltarTierLimit(meta))
{
return UpgradedAltars.getUpgrades(world, x, y, z, ((IFadedRune)testBlock).getAltarTierLimit(meta));
return UpgradedAltars.getUpgrades(world, pos, ((IFadedRune)testBlock).getAltarTierLimit(meta));
}
switch (((BloodRune) testBlock).getRuneEffect(meta))

View file

@ -1,76 +0,0 @@
package WayofTime.alchemicalWizardry.common.commands;
import java.util.List;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.server.MinecraftServer;
import WayofTime.alchemicalWizardry.api.items.interfaces.IBindable;
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
public class CommandBind extends CommandBase
{
public CommandBind() {}
public String getCommandName()
{
return "bind";
}
public int getRequiredPermissionLevel()
{
return 2;
}
public String getCommandUsage(ICommandSender icommandsender)
{
return "commands.bind.usage";
}
public void processCommand(ICommandSender iCommandSender, String[] astring)
{
EntityPlayerMP entityplayermp = getCommandSenderAsPlayer(iCommandSender);
ItemStack item = entityplayermp.getCurrentEquippedItem();
EntityPlayerMP targetPlayer = getPlayer(iCommandSender, astring[0]);
if (targetPlayer == null)
{
throw new CommandException("commands.bind.failed.noPlayer");
}
if (item != null && item.getItem() instanceof IBindable)
{
if (EnergyItems.getOwnerName(item).isEmpty())
{
EnergyItems.checkAndSetItemOwner(item, targetPlayer);
func_152373_a(iCommandSender, this, "commands.bind.success");
}
else
{
throw new CommandException("commands.bind.failed.alreadyBound");
}
}
else if (!(item.getItem() instanceof IBindable))
{
throw new CommandException("commands.bind.failed.notBindable");
}
}
public List addTabCompletionOptions(ICommandSender iCommandSender, String[] astring)
{
return getListOfStringsMatchingLastWord(astring, this.getPlayer());
}
protected String[] getPlayer()
{
return MinecraftServer.getServer().getAllUsernames();
}
public boolean isUsernameIndex(String[] astring, int par2)
{
return par2 == 0;
}
}

View file

@ -1,137 +0,0 @@
package WayofTime.alchemicalWizardry.common.commands;
import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;
import java.util.List;
public class CommandSN extends CommandBase
{
public CommandSN() {}
@Override
public String getCommandName()
{
return "soulnetwork";
}
@Override
public int getRequiredPermissionLevel()
{
return 2;
}
@Override
public String getCommandUsage(ICommandSender icommandsender)
{
return "commands.soulnetwork.usage";
}
@Override
public void processCommand(ICommandSender icommandsender, String[] astring)
{
EntityPlayerMP targetPlayer = getPlayer(icommandsender, astring[0]);
String owner = targetPlayer.getDisplayName();
EntityPlayerMP proxyPlayerName = getPlayer(icommandsender, astring[0]);
if (astring.length >= 2 && astring.length <= 3)
{
if ("add".equalsIgnoreCase(astring[1]))
{
int amount = parseIntBounded(icommandsender, astring[2], Integer.MIN_VALUE, Integer.MAX_VALUE);
SoulNetworkHandler.addCurrentEssenceToMaximum(owner, amount, Integer.MAX_VALUE);
func_152373_a(icommandsender, this, "commands.soulnetwork.add.success", amount, owner);
}
else if ("subtract".equalsIgnoreCase(astring[1]))
{
int amount = parseIntBounded(icommandsender, astring[2], Integer.MIN_VALUE, Integer.MAX_VALUE);
if (amount > SoulNetworkHandler.getCurrentEssence(owner))
{
int lp = SoulNetworkHandler.getCurrentEssence(owner);
SoulNetworkHandler.syphonFromNetwork(owner, lp);
func_152373_a(icommandsender, this, "commands.soulnetwork.subtract.success", SoulNetworkHandler.getCurrentEssence(owner), owner);
}
else
{
SoulNetworkHandler.syphonFromNetwork(owner, amount);
func_152373_a(icommandsender, this, "commands.soulnetwork.subtract.success", amount, owner);
}
}
else if ("fill".equalsIgnoreCase(astring[1]))
{
int amount = Integer.MAX_VALUE - SoulNetworkHandler.getCurrentEssence(owner);
SoulNetworkHandler.addCurrentEssenceToMaximum(owner, amount, Integer.MAX_VALUE);
func_152373_a(icommandsender, this, "commands.soulnetwork.fill.success", owner);
}
else if ("empty".equalsIgnoreCase(astring[1]))
{
SoulNetworkHandler.syphonFromNetwork(owner, SoulNetworkHandler.getCurrentEssence(owner));
func_152373_a(icommandsender, this, "commands.soulnetwork.empty.success", owner);
}
else if ("get".equalsIgnoreCase(astring[1]))
{
int currentEssence = SoulNetworkHandler.getCurrentEssence(owner);
func_152373_a(icommandsender, this, "commands.soulnetwork.get.success", currentEssence, owner);
}
else if ("fillMax".equalsIgnoreCase(astring[1]))
{
int currentEssence = SoulNetworkHandler.getCurrentEssence(owner);
int orbTier = SoulNetworkHandler.getCurrentMaxOrb(owner);
int maxForOrb = SoulNetworkHandler.getMaximumForOrbTier(orbTier);
int fillAmount = maxForOrb - currentEssence;
SoulNetworkHandler.addCurrentEssenceToMaximum(owner, fillAmount, fillAmount);
func_152373_a(icommandsender, this, "commands.soulnetwork.fillMax.success", owner);
}
else if ("create".equalsIgnoreCase(astring[1]))
{
int orbTier = parseIntBounded(icommandsender, astring[2], 1, 6);
SoulNetworkHandler.setMaxOrbToMax(proxyPlayerName.getDisplayName(), orbTier);
func_152373_a(icommandsender, this, "commands.soulnetwork.create.success", owner, orbTier);
}
else
{
throw new CommandException("commands.soulnetwork.notACommand");
}
}
else if (astring.length == 0)
{
throw new CommandException("commands.soulnetwork.noPlayer");
}
else if (astring.length == 1)
{
throw new CommandException("commands.soulnetwork.noCommand");
}
}
@Override
public List addTabCompletionOptions(ICommandSender iCommandSender, String[] astring)
{
if (astring.length == 1)
{
return getListOfStringsMatchingLastWord(astring, this.getPlayer());
}
else if (astring.length == 2)
{
return getListOfStringsMatchingLastWord(astring, "add", "subtract", "fill", "empty", "get", "fillMax", "create");
}
return null;
}
protected String[] getPlayer()
{
return MinecraftServer.getServer().getAllUsernames();
}
@Override
public boolean isUsernameIndex(String[] astring, int par2)
{
return par2 == 0;
}
}

View file

@ -1,52 +0,0 @@
package WayofTime.alchemicalWizardry.common.commands;
import WayofTime.alchemicalWizardry.api.items.interfaces.IBindable;
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
public class CommandUnbind extends CommandBase
{
public CommandUnbind() {}
public String getCommandName()
{
return "unbind";
}
public int getRequiredPermissionLevel()
{
return 2;
}
public String getCommandUsage(ICommandSender icommandsender)
{
return "commands.unbind.usage";
}
public void processCommand(ICommandSender iCommandSender, String[] astring)
{
EntityPlayerMP entityplayermp = getCommandSenderAsPlayer(iCommandSender);
ItemStack item = entityplayermp.getCurrentEquippedItem();
if (item != null && item.getItem() instanceof IBindable)
{
if (!EnergyItems.getOwnerName(item).isEmpty())
{
item.getTagCompound().removeTag("ownerName");
func_152373_a(iCommandSender, this, "commands.unbind.success");
}
else
{
throw new CommandException("commands.unbind.failed.notBindable");
}
}
else if (!(item.getItem() instanceof IBindable))
{
throw new CommandException("commands.unbind.failed.notBindable");
}
}
}

View file

@ -231,8 +231,8 @@ public class StorageBlockCraftingManager
if (i == 2 && itemstack.getItem() == itemstack1.getItem() && itemstack.stackSize == 1 && itemstack1.stackSize == 1 && itemstack.getItem().isRepairable())
{
Item item = itemstack.getItem();
int j1 = item.getMaxDamage() - itemstack.getItemDamageForDisplay();
int k = item.getMaxDamage() - itemstack1.getItemDamageForDisplay();
int j1 = item.getMaxDamage() - itemstack.getItemDamage();
int k = item.getMaxDamage() - itemstack1.getItemDamage();
int l = j1 + k + item.getMaxDamage() * 5 / 100;
int i1 = item.getMaxDamage() - l;

View file

@ -14,8 +14,9 @@ import net.minecraft.block.BlockTrapDoor;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.IInventory;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import WayofTime.alchemicalWizardry.api.Int3;
import WayofTime.alchemicalWizardry.common.demonVillage.loot.DemonVillageLootRegistry;
import WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.IBlockPortalNode;
@ -276,7 +277,7 @@ public class BlockSet
return GameRegistry.findBlock(modId, name);
}
public int getMetaForDirection(ForgeDirection dir)
public int getMetaForDirection(EnumFacing dir)
{
if (metadata.length < 4)
{
@ -298,7 +299,7 @@ public class BlockSet
}
}
public void buildAtIndex(TEDemonPortal teDemonPortal, World world, int xCoord, int yCoord, int zCoord, ForgeDirection dir, int index, boolean populateInventories, int tier)
public void buildAtIndex(TEDemonPortal teDemonPortal, World world, int xCoord, int yCoord, int zCoord, EnumFacing dir, int index, boolean populateInventories, int tier)
{
Block block = this.getBlock();
if (index >= positions.size() || block == null)
@ -333,14 +334,15 @@ public class BlockSet
default:
}
world.setBlock(xCoord + xOff, yCoord + yOff, zCoord + zOff, block, meta, 3);
BlockPos newPos = new BlockPos(xCoord + xOff, yCoord + yOff, zCoord + zOff);
world.setBlockState(newPos, block.getStateFromMeta(meta), 3);
if(populateInventories)
{
this.populateIfIInventory(world, xCoord + xOff, yCoord + yOff, zCoord + zOff, tier);
this.populateIfIInventory(world, newPos, tier);
}
if(block instanceof IBlockPortalNode)
{
TileEntity tile = world.getTileEntity(xCoord + xOff, yCoord + yOff, zCoord + zOff);
TileEntity tile = world.getTileEntity(newPos);
if(tile instanceof ITilePortalNode)
{
((ITilePortalNode) tile).setPortalLocation(teDemonPortal);
@ -348,16 +350,16 @@ public class BlockSet
}
}
public void populateIfIInventory(World world, int x, int y, int z, int tier)
public void populateIfIInventory(World world, BlockPos pos, int tier)
{
TileEntity tile = world.getTileEntity(x, y, z);
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof IInventory)
{
DemonVillageLootRegistry.populateChest((IInventory)tile, tier);
}
}
public void buildAll(TEDemonPortal teDemonPortal, World world, int xCoord, int yCoord, int zCoord, ForgeDirection dir, boolean populateInventories, int tier)
public void buildAll(TEDemonPortal teDemonPortal, World world, int xCoord, int yCoord, int zCoord, EnumFacing dir, boolean populateInventories, int tier)
{
for (int i = 0; i < positions.size(); i++)
{

View file

@ -4,8 +4,10 @@ import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import WayofTime.alchemicalWizardry.ModBlocks;
import WayofTime.alchemicalWizardry.api.Int3;
import WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.TEDemonPortal;
@ -52,7 +54,7 @@ public class BuildingSchematic
blockList.add(set);
}
public void buildAll(TEDemonPortal teDemonPortal, World world, int xCoord, int yCoord, int zCoord, ForgeDirection dir, boolean populateInventories)
public void buildAll(TEDemonPortal teDemonPortal, World world, int xCoord, int yCoord, int zCoord, EnumFacing dir, boolean populateInventories)
{
for (BlockSet set : blockList)
{
@ -86,7 +88,7 @@ public class BuildingSchematic
return new Int3(gridX, doorY, gridZ);
}
public List<Int3> getGriddedPositions(ForgeDirection dir)
public List<Int3> getGriddedPositions(EnumFacing dir)
{
List<Int3> positionList = new ArrayList();
@ -127,7 +129,7 @@ public class BuildingSchematic
return positionList;
}
public void destroyAllInField(World world, int xCoord, int yCoord, int zCoord, ForgeDirection dir)
public void destroyAllInField(World world, int xCoord, int yCoord, int zCoord, EnumFacing dir)
{
// GridSpaceHolder grid = this.createGSH(); //GridSpaceHolder is not aware of the buildings - need to use the schematic
@ -137,10 +139,12 @@ public class BuildingSchematic
{
for (Int3 pos : positionList)
{
Block block = world.getBlock(xCoord + pos.xCoord, yCoord + i, zCoord + pos.zCoord);
BlockPos newPos = new BlockPos(xCoord + pos.xCoord, yCoord + i, zCoord + pos.zCoord);
IBlockState state = world.getBlockState(newPos);
Block block = state.getBlock();
if (block != ModBlocks.blockDemonPortal)
{
world.setBlockToAir(xCoord + pos.xCoord, yCoord + i, zCoord + pos.zCoord);
world.setBlockToAir(newPos);
}
}
}

View file

@ -1,7 +1,7 @@
package WayofTime.alchemicalWizardry.common.demonVillage;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import WayofTime.alchemicalWizardry.api.Int3;
import WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.TEDemonPortal;
@ -30,17 +30,17 @@ public class DemonBuilding
return schematic.getName();
}
public boolean isValid(GridSpaceHolder master, int gridX, int gridZ, ForgeDirection dir)
public boolean isValid(GridSpaceHolder master, int gridX, int gridZ, EnumFacing dir)
{
return area.doesContainAll(master, gridX, gridZ, dir);
}
public void buildAll(TEDemonPortal teDemonPortal, World world, int xCoord, int yCoord, int zCoord, ForgeDirection dir, boolean populateInventories)
public void buildAll(TEDemonPortal teDemonPortal, World world, int xCoord, int yCoord, int zCoord, EnumFacing dir, boolean populateInventories)
{
schematic.buildAll(teDemonPortal, world, xCoord, yCoord, zCoord, dir, populateInventories);
}
public void setAllGridSpaces(int xInit, int zInit, int yLevel, ForgeDirection dir, int type, GridSpaceHolder master)
public void setAllGridSpaces(int xInit, int zInit, int yLevel, EnumFacing dir, int type, GridSpaceHolder master)
{
area.setAllGridSpaces(xInit, zInit, yLevel, dir, type, master);
}
@ -57,7 +57,7 @@ public class DemonBuilding
return scheme.createGSH();
}
public Int3 getDoorSpace(ForgeDirection dir)
public Int3 getDoorSpace(EnumFacing dir)
{
int x;
int z;
@ -84,7 +84,7 @@ public class DemonBuilding
return new Int3(x, doorGridSpace.yCoord, z);
}
public Int3 getGridOffsetFromRoad(ForgeDirection sideOfRoad, int yLevel)
public Int3 getGridOffsetFromRoad(EnumFacing sideOfRoad, int yLevel)
{
Int3 doorSpace = this.getDoorSpace(sideOfRoad);
int x = doorSpace.xCoord;
@ -109,7 +109,7 @@ public class DemonBuilding
return new Int3(x, yLevel, z);
}
public void destroyAllInField(World world, int xCoord, int yCoord, int zCoord, ForgeDirection dir)
public void destroyAllInField(World world, int xCoord, int yCoord, int zCoord, EnumFacing dir)
{
schematic.destroyAllInField(world, xCoord, yCoord, zCoord, dir);
}

View file

@ -3,9 +3,11 @@ package WayofTime.alchemicalWizardry.common.demonVillage;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFlower;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import WayofTime.alchemicalWizardry.ModBlocks;
import WayofTime.alchemicalWizardry.api.Int3;
import WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.IRoadWard;
@ -16,19 +18,19 @@ public class DemonVillagePath
public int xPos;
public int yPos;
public int zPos;
public ForgeDirection dir;
public EnumFacing dir;
public int length;
public static boolean canGoDown = true;
public static boolean tunnelIfObstructed = false;
public static boolean createBridgeInAirIfObstructed = false;
public DemonVillagePath(int xi, int yi, int zi, ForgeDirection dir, int length)
public DemonVillagePath(int xi, int yi, int zi, EnumFacing dir2, int length)
{
this.xPos = xi;
this.yPos = yi;
this.zPos = zi;
this.dir = dir;
this.dir = dir2;
this.length = length;
}
@ -40,11 +42,11 @@ public class DemonVillagePath
int rad = this.getRoadRadius();
int value = 0;
int finalYPos = this.constructPartialPath(portal, world, clearance, xi - rad * dir.offsetX, yi, zi - rad * dir.offsetZ, dir, length + rad, false);
int finalYPos = this.constructPartialPath(portal, world, clearance, xi - rad * dir.getFrontOffsetX(), yi, zi - rad * dir.getFrontOffsetZ(), dir, length + rad, false);
for (int i = -rad; i <= rad; i++)
{
value = Math.max(this.constructPartialPath(portal, world, clearance, xi - rad * dir.offsetX + i * dir.offsetZ, yi, zi - rad * dir.offsetZ + i * dir.offsetX, dir, length + 2 * rad, true), value);
value = Math.max(this.constructPartialPath(portal, world, clearance, xi - rad * dir.getFrontOffsetX() + i * dir.getFrontOffsetZ(), yi, zi - rad * dir.getFrontOffsetZ() + i * dir.getFrontOffsetX(), dir, length + 2 * rad, true), value);
if(TEDemonPortal.printDebug)
System.out.println("" + (length + 2 * rad) + ", " + value + "");
}
@ -80,12 +82,12 @@ public class DemonVillagePath
* @param doConstruct
* @return length if doConstruct, yi if !doConstruct
*/
public int constructPartialPath(TEDemonPortal portal, World world, int clearance, int xi, int yi, int zi, ForgeDirection dir, int length, boolean doConstruct)
public int constructPartialPath(TEDemonPortal portal, World world, int clearance, int xi, int yi, int zi, EnumFacing dir, int length, boolean doConstruct)
{
for (int i = 0; i < length; i++)
{
int xOffset = i * dir.offsetX;
int zOffset = i * dir.offsetZ;
int xOffset = i * dir.getFrontOffsetX();
int zOffset = i * dir.getFrontOffsetZ();
boolean completed = false;
@ -93,14 +95,19 @@ public class DemonVillagePath
{
int sign = 1;
Block block1 = world.getBlock(xi + xOffset, yi + sign * yOffset, zi + zOffset);
Block highBlock1 = world.getBlock(xi + xOffset, yi + sign * yOffset + 1, zi + zOffset);
BlockPos pos1 = new BlockPos(xi + xOffset, yi + sign * yOffset, zi + zOffset);
BlockPos highPos1 = pos1.offsetUp();
IBlockState state1 = world.getBlockState(pos1);
IBlockState highState1 = world.getBlockState(highPos1);
Block block1 = state1.getBlock();
Block highBlock1 = highState1.getBlock();
if ((this.forceReplaceBlock(block1))||(!block1.isReplaceable(world, xi + xOffset, yi + sign * yOffset, zi + zOffset) && this.isBlockReplaceable(block1) ) && (this.forceCanTunnelUnder(highBlock1) || highBlock1.isReplaceable(world, xi + xOffset, yi + sign * yOffset + 1, zi + zOffset)))
if ((this.forceReplaceBlock(block1))||(!block1.isReplaceable(world, pos1) && this.isBlockReplaceable(block1) ) && (this.forceCanTunnelUnder(highBlock1) || highBlock1.isReplaceable(world, highPos1)))
{
if(doConstruct)
{
world.setBlock(xi + xOffset, yi + sign * yOffset, zi + zOffset, portal.getRoadBlock(), portal.getRoadMeta(), 3);
world.setBlockState(pos1, portal.getRoadState(), 3);
}
yi += sign * yOffset;
completed = true;
@ -108,14 +115,19 @@ public class DemonVillagePath
} else if(canGoDown)
{
sign = -1;
Block block2 = world.getBlock(xi + xOffset, yi + sign * yOffset, zi + zOffset);
Block highBlock2 = world.getBlock(xi + xOffset, yi + sign * yOffset + 1, zi + zOffset);
pos1 = new BlockPos(xi + xOffset, yi + sign * yOffset, zi + zOffset);
highPos1 = pos1.offsetUp();
state1 = world.getBlockState(pos1);
highState1 = world.getBlockState(highPos1);
block1 = state1.getBlock();
highBlock1 = highState1.getBlock();
if ((this.forceReplaceBlock(block2))||(!block2.isReplaceable(world, xi + xOffset, yi + sign * yOffset, zi + zOffset) && this.isBlockReplaceable(block2)) && (this.forceCanTunnelUnder(highBlock2) || highBlock2.isReplaceable(world, xi + xOffset, yi + sign * yOffset + 1, zi + zOffset)))
if ((this.forceReplaceBlock(block1))||(!block1.isReplaceable(world, pos1) && this.isBlockReplaceable(block1) ) && (this.forceCanTunnelUnder(highBlock1) || highBlock1.isReplaceable(world, highPos1)))
{
if(doConstruct)
if(doConstruct)
{
world.setBlock(xi + xOffset, yi + sign * yOffset, zi + zOffset, portal.getRoadBlock(), portal.getRoadMeta(), 3);
world.setBlockState(pos1, portal.getRoadState(), 3);
}
yi += sign * yOffset;
completed = true;
@ -129,15 +141,17 @@ public class DemonVillagePath
boolean returnAmount = true;
if(createBridgeInAirIfObstructed)
{
Block block1 = world.getBlock(xi + xOffset, yi, zi + zOffset);
BlockPos pos1 = new BlockPos(xi + xOffset, yi, zi + zOffset);
IBlockState state1 = world.getBlockState(pos1);
Block block1 = state1.getBlock();
if (block1.isReplaceable(world, xi + xOffset, yi, zi + zOffset) || !this.isBlockReplaceable(block1) || !this.forceReplaceBlock(block1))
if (block1.isReplaceable(world, pos1) || !this.isBlockReplaceable(block1) || !this.forceReplaceBlock(block1))
{
returnAmount = false;
if(doConstruct)
{
world.setBlock(xi + xOffset, yi, zi + zOffset, portal.getRoadBlock(), portal.getRoadMeta(), 3);
world.setBlockState(pos1, portal.getRoadState(), 3);
}
}else
{
@ -146,18 +160,20 @@ public class DemonVillagePath
}else if(tunnelIfObstructed)
{
Block block1 = world.getBlock(xi + xOffset, yi, zi + zOffset);
BlockPos pos1 = new BlockPos(xi + xOffset, yi, zi + zOffset);
IBlockState state1 = world.getBlockState(pos1);
Block block1 = state1.getBlock();
if (!block1.isReplaceable(world, xi + xOffset, yi, zi + zOffset) || this.isBlockReplaceable(block1) || !this.forceReplaceBlock(block1))
if (!block1.isReplaceable(world, pos1) || this.isBlockReplaceable(block1) || !this.forceReplaceBlock(block1))
{
returnAmount = false;
if(doConstruct)
{
world.setBlock(xi + xOffset, yi, zi + zOffset, portal.getRoadBlock(), portal.getRoadMeta(), 3);
world.setBlockToAir(xi + xOffset, yi + 1, zi + zOffset);
world.setBlockToAir(xi + xOffset, yi + 2, zi + zOffset);
world.setBlockToAir(xi + xOffset, yi + 3, zi + zOffset);
world.setBlockState(pos1, portal.getRoadState(), 3);
world.setBlockToAir(pos1.offsetUp(1));
world.setBlockToAir(pos1.offsetUp(2));
world.setBlockToAir(pos1.offsetUp(3));
}
}else
{
@ -183,27 +199,37 @@ public class DemonVillagePath
for (int i = 0; i < length; i++)
{
int xOffset = i * dir.offsetX;
int zOffset = i * dir.offsetZ;
int xOffset = i * dir.getFrontOffsetX();
int zOffset = i * dir.getFrontOffsetZ();
for (int yOffset = 0; yOffset <= clearance; yOffset++)
{
int sign = 1;
Block block1 = world.getBlock(xi + xOffset, yi + sign * yOffset, zi + zOffset);
Block highBlock1 = world.getBlock(xi + xOffset, yi + sign * yOffset + 1, zi + zOffset);
BlockPos pos1 = new BlockPos(xi + xOffset, yi + sign * yOffset, zi + zOffset);
BlockPos highPos1 = pos1.offsetUp();
IBlockState state1 = world.getBlockState(pos1);
IBlockState highState1 = world.getBlockState(highPos1);
Block block1 = state1.getBlock();
Block highBlock1 = highState1.getBlock();
if ((this.forceReplaceBlock(block1))||(!block1.isReplaceable(world, xi + xOffset, yi + sign * yOffset, zi + zOffset) && this.isBlockReplaceable(block1) ) && (this.forceCanTunnelUnder(highBlock1) || highBlock1.isReplaceable(world, xi + xOffset, yi + sign * yOffset + 1, zi + zOffset)))
if ((this.forceReplaceBlock(block1))||(!block1.isReplaceable(world, pos1) && this.isBlockReplaceable(block1) ) && (this.forceCanTunnelUnder(highBlock1) || highBlock1.isReplaceable(world, highPos1)))
{
yi += sign * yOffset;
break;
} else
{
sign = -1;
Block block2 = world.getBlock(xi + xOffset, yi + sign * yOffset, zi + zOffset);
Block highBlock2 = world.getBlock(xi + xOffset, yi + sign * yOffset + 1, zi + zOffset);
BlockPos pos2 = new BlockPos(xi + xOffset, yi + sign * yOffset, zi + zOffset);
BlockPos highPos2 = pos2.offsetUp();
IBlockState state2 = world.getBlockState(pos2);
IBlockState highState2 = world.getBlockState(highPos2);
Block block2 = state2.getBlock();
Block highBlock2 = highState2.getBlock();
if ((this.forceReplaceBlock(block2))||(!block2.isReplaceable(world, xi + xOffset, yi + sign * yOffset, zi + zOffset) && this.isBlockReplaceable(block2) ) && (this.forceCanTunnelUnder(highBlock2) || highBlock2.isReplaceable(world, xi + xOffset, yi + sign * yOffset + 1, zi + zOffset)))
if ((this.forceReplaceBlock(block2))||(!block2.isReplaceable(world, pos2) && this.isBlockReplaceable(block2) ) && (this.forceCanTunnelUnder(highBlock2) || highBlock2.isReplaceable(world, highPos2)))
{
yi += sign * yOffset;
break;

View file

@ -1,11 +1,13 @@
package WayofTime.alchemicalWizardry.common.demonVillage;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.ModBlocks;
import WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.TEDemonPortal;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class GridSpaceHolder
{
@ -139,7 +141,7 @@ public class GridSpaceHolder
}
}
public boolean doesContainAll(GridSpaceHolder master, int xInit, int zInit, ForgeDirection dir)
public boolean doesContainAll(GridSpaceHolder master, int xInit, int zInit, EnumFacing dir)
{
if (master != null)
{
@ -191,7 +193,7 @@ public class GridSpaceHolder
return false;
}
public void setAllGridSpaces(int xInit, int zInit, int yLevel, ForgeDirection dir, int type, GridSpaceHolder master)
public void setAllGridSpaces(int xInit, int zInit, int yLevel, EnumFacing dir, int type, GridSpaceHolder master)
{
if(TEDemonPortal.printDebug)
AlchemicalWizardry.logger.info("Grid space selected: (" + xInit + "," + zInit + ")");
@ -239,7 +241,7 @@ public class GridSpaceHolder
}
}
public void destroyAllInGridSpaces(World world, int xCoord, int yCoord, int zCoord, ForgeDirection dir)
public void destroyAllInGridSpaces(World world, int xCoord, int yCoord, int zCoord, EnumFacing dir)
{
for (int i = -negXRadius; i <= posXRadius; i++)
{
@ -278,12 +280,14 @@ public class GridSpaceHolder
{
for (int m = -2; m <= 2; m++)
{
Block block = world.getBlock(xCoord + xOff * 5 + l, yCoord, zCoord + zOff * 5 + m);
BlockPos newPos = new BlockPos(xCoord + xOff * 5 + l, yCoord, zCoord + zOff * 5 + m);
IBlockState state = world.getBlockState(newPos);
Block block = state.getBlock();
if (block == ModBlocks.blockDemonPortal)
{
continue;
}
world.setBlockToAir(xCoord + xOff * 5 + l, yCoord, zCoord + zOff * 5 + m);
world.setBlockToAir(newPos);
}
}
}

View file

@ -24,7 +24,6 @@ public class EntityAIOccasionalRangedAttack extends EntityAIBase
private int maxRangedAttackTime;
private float field_96562_i;
private float field_82642_h;
private static final String __OBFID = "CL_00001609";
private double range;
public EntityAIOccasionalRangedAttack(IOccasionalRangedAttackMob p_i1649_1_, double p_i1649_2_, int p_i1649_4_, float p_i1649_5_, double range)
@ -110,7 +109,7 @@ public class EntityAIOccasionalRangedAttack extends EntityAIBase
*/
public void updateTask()
{
double d0 = this.entityHost.getDistanceSq(this.attackTarget.posX, this.attackTarget.boundingBox.minY, this.attackTarget.posZ);
double d0 = this.entityHost.getDistanceSq(this.attackTarget.posX, this.attackTarget.getBoundingBox().minY, this.attackTarget.posZ);
boolean flag = this.entityHost.getEntitySenses().canSee(this.attackTarget);
if (flag)

View file

@ -3,7 +3,7 @@ package WayofTime.alchemicalWizardry.common.demonVillage.ai;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.tileentity.TileEntity;
import WayofTime.alchemicalWizardry.api.Int3;
import net.minecraft.util.BlockPos;
import WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon.IHoardDemon;
import WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.TEDemonPortal;
@ -20,14 +20,14 @@ public class EntityDemonAIHurtByTarget extends EntityAIHurtByTarget
@Override
public void startExecuting()
{
Int3 portalPosition = ((IHoardDemon)this.taskOwner).getPortalLocation();
BlockPos portalPosition = ((IHoardDemon)this.taskOwner).getPortalLocation();
if(portalPosition == null)
{
super.startExecuting();
return;
}
TileEntity portal = this.taskOwner.worldObj.getTileEntity(portalPosition.xCoord, portalPosition.yCoord, portalPosition.zCoord);
TileEntity portal = this.taskOwner.worldObj.getTileEntity(portalPosition);
if((this.taskOwner.getAITarget() instanceof IHoardDemon && portalPosition.equals(((IHoardDemon)this.taskOwner.getAITarget()).getPortalLocation())))
{
@ -45,7 +45,7 @@ public class EntityDemonAIHurtByTarget extends EntityAIHurtByTarget
}
// double d0 = this.getTargetDistance();
// List list = this.taskOwner.worldObj.getEntitiesWithinAABB(this.taskOwner.getClass(), AxisAlignedBB.getBoundingBox(this.taskOwner.posX, this.taskOwner.posY, this.taskOwner.posZ, this.taskOwner.posX + 1.0D, this.taskOwner.posY + 1.0D, this.taskOwner.posZ + 1.0D).expand(d0, 10.0D, d0));
// List list = this.taskOwner.worldObj.getEntitiesWithinAABB(this.taskOwner.getClass(), new AxisAlignedBB(this.taskOwner.posX, this.taskOwner.posY, this.taskOwner.posZ, this.taskOwner.posX + 1.0D, this.taskOwner.posY + 1.0D, this.taskOwner.posZ + 1.0D).expand(d0, 10.0D, d0));
// Iterator iterator = list.iterator();
//
// while (iterator.hasNext())

View file

@ -20,11 +20,11 @@ import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.ModItems;
import WayofTime.alchemicalWizardry.api.Int3;
import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone;
import WayofTime.alchemicalWizardry.api.rituals.LocalRitualStorage;
import WayofTime.alchemicalWizardry.common.EntityAITargetAggroCloaking;
@ -34,7 +34,6 @@ import WayofTime.alchemicalWizardry.common.demonVillage.ai.IOccasionalRangedAtta
import WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.TEDemonPortal;
import WayofTime.alchemicalWizardry.common.entity.mob.EntityDemon;
import WayofTime.alchemicalWizardry.common.entity.projectile.HolyProjectile;
import WayofTime.alchemicalWizardry.common.rituals.LocalStorageAlphaPact;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
public class EntityMinorDemonGrunt extends EntityDemon implements IOccasionalRangedAttackMob, IHoardDemon
@ -43,7 +42,7 @@ public class EntityMinorDemonGrunt extends EntityDemon implements IOccasionalRan
private EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.2D, false);
private boolean isAngry = true;
private Int3 demonPortal;
private BlockPos demonPortal;
private static float maxTamedHealth = 200.0F;
private static float maxUntamedHealth = 200.0F;
@ -54,7 +53,7 @@ public class EntityMinorDemonGrunt extends EntityDemon implements IOccasionalRan
{
super(par1World, AlchemicalWizardry.entityMinorDemonGruntID);
this.setSize(0.7F, 1.8F);
this.getNavigator().setAvoidsWater(true);
// this.getNavigator().setAvoidsWater(true);
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(2, this.aiSit);
this.tasks.addTask(3, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F));
@ -68,7 +67,7 @@ public class EntityMinorDemonGrunt extends EntityDemon implements IOccasionalRan
this.setAggro(false);
this.setTamed(false);
demonPortal = new Int3(0,0,0);
demonPortal = new BlockPos(0,0,0);
if (par1World != null && !par1World.isRemote)
{
@ -128,13 +127,13 @@ public class EntityMinorDemonGrunt extends EntityDemon implements IOccasionalRan
}
@Override
public void setPortalLocation(Int3 position)
public void setPortalLocation(BlockPos position)
{
this.demonPortal = position;
}
@Override
public Int3 getPortalLocation()
public BlockPos getPortalLocation()
{
return this.demonPortal;
}
@ -176,23 +175,25 @@ public class EntityMinorDemonGrunt extends EntityDemon implements IOccasionalRan
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
@Override
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
public void writeEntityToNBT(NBTTagCompound tag)
{
super.writeEntityToNBT(par1NBTTagCompound);
par1NBTTagCompound.setBoolean("Angry", this.isAngry());
super.writeEntityToNBT(tag);
tag.setBoolean("Angry", this.isAngry());
this.demonPortal.writeToNBT(par1NBTTagCompound);
tag.setInteger("xCoord", this.demonPortal.getX());
tag.setInteger("yCoord", this.demonPortal.getY());
tag.setInteger("zCoord", this.demonPortal.getZ());
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
@Override
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
public void readEntityFromNBT(NBTTagCompound tag)
{
super.readEntityFromNBT(par1NBTTagCompound);
this.setAngry(par1NBTTagCompound.getBoolean("Angry"));
this.demonPortal = Int3.readFromNBT(par1NBTTagCompound);
super.readEntityFromNBT(tag);
this.setAngry(tag.getBoolean("Angry"));
this.demonPortal = new BlockPos(tag.getInteger("xCoord"), tag.getInteger("yCoord"), tag.getInteger("zCoord"));
this.setCombatTask();
}
@ -252,7 +253,7 @@ public class EntityMinorDemonGrunt extends EntityDemon implements IOccasionalRan
{
if(!this.enthralled)
{
TileEntity tile = this.worldObj.getTileEntity(this.demonPortal.xCoord, this.demonPortal.yCoord, this.demonPortal.zCoord);
TileEntity tile = this.worldObj.getTileEntity(this.demonPortal);
if(tile instanceof TEDemonPortal)
{
((TEDemonPortal) tile).enthrallDemon(this);
@ -261,12 +262,12 @@ public class EntityMinorDemonGrunt extends EntityDemon implements IOccasionalRan
{
IMasterRitualStone stone = (IMasterRitualStone)tile;
LocalRitualStorage stor = stone.getLocalStorage();
if(stor instanceof LocalStorageAlphaPact)
{
LocalStorageAlphaPact storage = (LocalStorageAlphaPact)stor;
storage.thrallDemon(this);
}
// if(stor instanceof LocalStorageAlphaPact)
// {
// LocalStorageAlphaPact storage = (LocalStorageAlphaPact)stor;
//
// storage.thrallDemon(this);
// }
}
}
super.onUpdate();
@ -325,7 +326,7 @@ public class EntityMinorDemonGrunt extends EntityDemon implements IOccasionalRan
--itemstack.stackSize;
}
this.heal((float) itemfood.func_150905_g(itemstack));
this.heal((float) itemfood.getHealAmount(itemstack));
if (itemstack.stackSize <= 0)
{
@ -343,8 +344,8 @@ public class EntityMinorDemonGrunt extends EntityDemon implements IOccasionalRan
{
this.aiSit.setSitting(!this.isSitting());
this.isJumping = false;
this.setPathToEntity(null);
this.setTarget(null);
// this.setPathToEntity(null);
// this.setTarget(null);
this.setAttackTarget(null);
}
@ -367,7 +368,7 @@ public class EntityMinorDemonGrunt extends EntityDemon implements IOccasionalRan
if (this.rand.nextInt(1) == 0)
{
this.setTamed(true);
this.setPathToEntity(null);
// this.setPathToEntity(null);
this.setAttackTarget(null);
this.aiSit.setSitting(true);
this.setHealth(maxTamedHealth);
@ -500,7 +501,7 @@ public class EntityMinorDemonGrunt extends EntityDemon implements IOccasionalRan
}
@Override
public boolean thrallDemon(Int3 location)
public boolean thrallDemon(BlockPos location)
{
this.setPortalLocation(location);
return true;
@ -509,9 +510,9 @@ public class EntityMinorDemonGrunt extends EntityDemon implements IOccasionalRan
@Override
public boolean isSamePortal(IHoardDemon demon)
{
Int3 position = demon.getPortalLocation();
TileEntity portal = worldObj.getTileEntity(this.demonPortal.xCoord, this.demonPortal.yCoord, this.demonPortal.zCoord);
BlockPos position = demon.getPortalLocation();
TileEntity portal = worldObj.getTileEntity(this.demonPortal);
return portal instanceof TEDemonPortal ? portal == worldObj.getTileEntity(position.xCoord, position.yCoord, position.zCoord) : false;
return portal instanceof TEDemonPortal ? portal == worldObj.getTileEntity(position) : false;
}
}

View file

@ -1,11 +1,11 @@
package WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon;
import WayofTime.alchemicalWizardry.api.Int3;
import net.minecraft.util.BlockPos;
public interface IHoardDemon
{
void setPortalLocation(Int3 position);
Int3 getPortalLocation();
boolean thrallDemon(Int3 location);
void setPortalLocation(BlockPos position);
BlockPos getPortalLocation();
boolean thrallDemon(BlockPos location);
boolean isSamePortal(IHoardDemon demon);
}

View file

@ -18,7 +18,7 @@ public class DemonVillageLootRegistry
String[] tier1Strings = new String[]{ChestGenHooks.DUNGEON_CHEST, ChestGenHooks.PYRAMID_DESERT_CHEST};
for(String str : tier1Strings)
{
WeightedRandomChestContent[] contents = ChestGenHooks.getItems(str, new Random());
List<WeightedRandomChestContent> contents = ChestGenHooks.getItems(str, new Random());
if(contents != null)
{
for(WeightedRandomChestContent content : contents)
@ -34,16 +34,6 @@ public class DemonVillageLootRegistry
public static void populateChest(IInventory tile, int tier)
{
WeightedRandomChestContent.generateChestContents(new Random(), toArray(list1), tile, tile.getSizeInventory() / 3);
}
public static WeightedRandomChestContent[] toArray(List<WeightedRandomChestContent> aList)
{
int size = aList.size();
WeightedRandomChestContent[] contents = new WeightedRandomChestContent[size];
contents = aList.toArray(contents);
return contents;
WeightedRandomChestContent.generateChestContents(new Random(), list1, tile, tile.getSizeInventory() / 3);
}
}

View file

@ -1,9 +1,9 @@
package WayofTime.alchemicalWizardry.common.demonVillage.tileEntity;
import net.minecraft.block.Block;
import net.minecraft.block.BlockChest;
import net.minecraft.inventory.IInventory;
import net.minecraft.block.state.IBlockState;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
@ -12,15 +12,10 @@ public class BlockDemonChest extends BlockChest implements IBlockPortalNode
public BlockDemonChest()
{
super(0);
this.setHardness(2.5F).setStepSound(soundTypeWood).setBlockName("demonChest");
this.setHardness(2.5F).setStepSound(soundTypeWood).setUnlocalizedName("demonChest");
this.setCreativeTab(AlchemicalWizardry.tabBloodMagic);
}
public IInventory func_149951_m(World world, int x, int y, int z)
{
return (IInventory)world.getTileEntity(x, y, z);
}
@Override
public TileEntity createNewTileEntity(World var1, int var2)
{
@ -28,18 +23,18 @@ public class BlockDemonChest extends BlockChest implements IBlockPortalNode
}
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int meta)
public void breakBlock(World world, BlockPos pos, IBlockState state)
{
TileEntity tile = world.getTileEntity(x, y, z);
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TEDemonChest)
{
((TEDemonChest) tile).notifyPortalOfInteraction();
}
super.breakBlock(world, x, y, z, block, meta);
super.breakBlock(world, pos, state);
}
@Override
public boolean canPlaceBlockAt(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_)
public boolean canPlaceBlockAt(World world, BlockPos pos)
{
return true;
}

View file

@ -1,16 +1,17 @@
package WayofTime.alchemicalWizardry.common.demonVillage.tileEntity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
import WayofTime.alchemicalWizardry.api.Int3;
import net.minecraft.util.BlockPos;
public class TEDemonChest extends TileEntityChest implements ITilePortalNode
{
public Int3 portalLocation = new Int3(0,0,0);
public BlockPos portalLocation = BlockPos.ORIGIN;
@Override
public String getInventoryName()
public String getName()
{
return "Demon's Chest";
}
@ -20,21 +21,24 @@ public class TEDemonChest extends TileEntityChest implements ITilePortalNode
{
super.readFromNBT(tag);
NBTTagCompound portalTag = tag.getCompoundTag("portalLocation");
portalLocation = Int3.readFromNBT(portalTag);
portalLocation = new BlockPos(portalTag.getInteger("xCoord"), portalTag.getInteger("yCoord"), portalTag.getInteger("zCoord"));
}
@Override
public void writeToNBT(NBTTagCompound tag)
{
super.writeToNBT(tag);
NBTTagCompound portalTag = portalLocation.writeToNBT(new NBTTagCompound());
NBTTagCompound portalTag = new NBTTagCompound();
portalTag.setInteger("xCoord", portalLocation.getX());
portalTag.setInteger("yCoord", portalLocation.getY());
portalTag.setInteger("zCoord", portalLocation.getZ());
tag.setTag("portalLocation", portalTag);
}
@Override
public void openInventory()
public void openInventory(EntityPlayer player)
{
super.openInventory();
super.openInventory(player);
this.notifyPortalOfInteraction();
}
@ -49,13 +53,13 @@ public class TEDemonChest extends TileEntityChest implements ITilePortalNode
{
if(teDemonPortal != null)
{
portalLocation = new Int3(teDemonPortal.xCoord, teDemonPortal.yCoord, teDemonPortal.zCoord);
portalLocation = teDemonPortal.getPos();
}
}
public TEDemonPortal getDemonPortal()
{
TileEntity tile = worldObj.getTileEntity(portalLocation.xCoord, portalLocation.yCoord, portalLocation.zCoord);
TileEntity tile = worldObj.getTileEntity(portalLocation);
if(tile instanceof TEDemonPortal)
{
return (TEDemonPortal)tile;
@ -71,6 +75,6 @@ public class TEDemonChest extends TileEntityChest implements ITilePortalNode
return;
}
portal.notifyDemons(xCoord, yCoord, zCoord, 50);
portal.notifyDemons(pos.getX(), pos.getY(), pos.getZ(), 50);
}
}

View file

@ -15,6 +15,7 @@ import java.util.Random;
import java.util.Set;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLivingBase;
@ -22,9 +23,11 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.server.gui.IUpdatePlayerListBox;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.common.util.ForgeDirection;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.api.Int3;
import WayofTime.alchemicalWizardry.common.block.BlockTeleposer;
@ -42,7 +45,7 @@ import WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon.IHoardD
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
public class TEDemonPortal extends TileEntity
public class TEDemonPortal extends TileEntity implements IUpdatePlayerListBox
{
public DemonType type = DemonType.FIRE;
@ -85,7 +88,7 @@ public class TEDemonPortal extends TileEntity
public float pointPool;
public String nextDemonPortalName = "";
public ForgeDirection nextDemonPortalDirection = ForgeDirection.DOWN;
public EnumFacing nextDemonPortalDirection = EnumFacing.DOWN;
public int buildingStage = -1;
@ -116,7 +119,7 @@ public class TEDemonPortal extends TileEntity
isInitialized = false;
this.setGridSpace(0, 0, new GridSpace(GridSpace.MAIN_PORTAL, yCoord));
this.setGridSpace(0, 0, new GridSpace(GridSpace.MAIN_PORTAL, pos.getY()));
this.houseCooldown = 0;
this.roadCooldown = 0;
@ -282,7 +285,7 @@ public class TEDemonPortal extends TileEntity
{
if(demon instanceof IHoardDemon)
{
boolean enthrall = ((IHoardDemon) demon).thrallDemon(new Int3(this.xCoord, this.yCoord, this.zCoord));
boolean enthrall = ((IHoardDemon) demon).thrallDemon(pos);
if(enthrall)
{
this.hoardList.add((IHoardDemon)demon);
@ -306,10 +309,10 @@ public class TEDemonPortal extends TileEntity
{
if (Math.abs(xIndex) == 1 || Math.abs(zIndex) == 1)
{
this.setGridSpace(xIndex, zIndex, new GridSpace(GridSpace.ROAD, yCoord));
this.setGridSpace(xIndex, zIndex, new GridSpace(GridSpace.ROAD, pos.getY()));
} else if (xIndex == 0 && zIndex == 0)
{
this.setGridSpace(0, 0, new GridSpace(GridSpace.MAIN_PORTAL, yCoord));
this.setGridSpace(0, 0, new GridSpace(GridSpace.MAIN_PORTAL, pos.getY()));
} else
{
this.setGridSpace(xIndex, zIndex, new GridSpace());
@ -334,7 +337,7 @@ public class TEDemonPortal extends TileEntity
public void createParty()
{
worldObj.createExplosion(null, xCoord + rand.nextInt(10) - rand.nextInt(10), yCoord, zCoord + rand.nextInt(10) - rand.nextInt(10), 5*rand.nextFloat(), false);
worldObj.createExplosion(null, pos.getX() + rand.nextInt(10) - rand.nextInt(10), pos.getY(), pos.getZ() + rand.nextInt(10) - rand.nextInt(10), 5*rand.nextFloat(), false);
}
public void start()
@ -346,7 +349,7 @@ public class TEDemonPortal extends TileEntity
* Randomly increase one of the cooldowns such that a road, house, or a demon portal tier is caused. Demons are also randomly spawned via this mechanic.
*/
@Override
public void updateEntity()
public void update()
{
if(worldObj.isRemote)
{
@ -364,7 +367,7 @@ public class TEDemonPortal extends TileEntity
if(delayBeforeParty <= 0)
{
worldObj.createExplosion(null, xCoord, yCoord, zCoord, 15, false);
worldObj.createExplosion(null, pos.getX(), pos.getY(), pos.getZ(), 15, false);
this.initialize();
}
@ -493,7 +496,7 @@ public class TEDemonPortal extends TileEntity
this.nextDemonPortalName = par1NBTTagCompound.getString("nextDemonPortalName");
this.buildingStage = par1NBTTagCompound.getInteger("buildingStage");
this.nextDemonPortalDirection = ForgeDirection.getOrientation(par1NBTTagCompound.getInteger("nextDemonPortalDirection"));
this.nextDemonPortalDirection = EnumFacing.getFront(par1NBTTagCompound.getInteger("nextDemonPortalDirection"));
this.pointPool = par1NBTTagCompound.getFloat("pointPool");
this.lockdownTimer = par1NBTTagCompound.getInteger("lockdownTimer");
@ -553,24 +556,24 @@ public class TEDemonPortal extends TileEntity
public int createRandomDemonHoard(TEDemonPortal teDemonPortal, int tier, DemonType type, boolean spawnGuardian)
{
int next = rand.nextInt(4);
ForgeDirection dir;
EnumFacing dir;
switch (next)
{
case 0:
dir = ForgeDirection.NORTH;
dir = EnumFacing.NORTH;
break;
case 1:
dir = ForgeDirection.SOUTH;
dir = EnumFacing.SOUTH;
break;
case 2:
dir = ForgeDirection.EAST;
dir = EnumFacing.EAST;
break;
case 3:
dir = ForgeDirection.WEST;
dir = EnumFacing.WEST;
break;
default:
dir = ForgeDirection.NORTH;
dir = EnumFacing.NORTH;
}
Int3 road = findRoadSpaceFromDirection(dir, (rand.nextInt(negXRadius + negZRadius + posXRadius + posZRadius)) + 1);
@ -582,30 +585,30 @@ public class TEDemonPortal extends TileEntity
if(TEDemonPortal.printDebug)
System.out.println("Spawning Demons");
return DemonPacketRegistry.spawnDemons(teDemonPortal, worldObj, xCoord + road.xCoord * 5, road.yCoord + 1, zCoord + road.zCoord * 5, type, tier, spawnGuardian);
return DemonPacketRegistry.spawnDemons(teDemonPortal, worldObj, pos.getX() + road.xCoord * 5, road.yCoord + 1, pos.getZ() + road.zCoord * 5, type, tier, spawnGuardian);
}
public int createRandomRoad() //Return the number of road spaces
{
int next = rand.nextInt(4);
ForgeDirection dir;
EnumFacing dir;
switch (next)
{
case 0:
dir = ForgeDirection.NORTH;
dir = EnumFacing.NORTH;
break;
case 1:
dir = ForgeDirection.SOUTH;
dir = EnumFacing.SOUTH;
break;
case 2:
dir = ForgeDirection.EAST;
dir = EnumFacing.EAST;
break;
case 3:
dir = ForgeDirection.WEST;
dir = EnumFacing.WEST;
break;
default:
dir = ForgeDirection.NORTH;
dir = EnumFacing.NORTH;
}
Int3 road = findRoadSpaceFromDirection(dir, (rand.nextInt(negXRadius + negZRadius + posXRadius + posZRadius)) + 1);
@ -617,7 +620,7 @@ public class TEDemonPortal extends TileEntity
if(printDebug)
AlchemicalWizardry.logger.info("X: " + x + " Z: " + z + " Direction: " + dir.toString());
List<ForgeDirection> directions = this.findValidExtentionDirection(x, z);
List<EnumFacing> directions = this.findValidExtentionDirection(x, z);
if (directions.size() <= 0)
{
@ -627,9 +630,9 @@ public class TEDemonPortal extends TileEntity
int maxDistance = 5;
int distance = 0;
ForgeDirection dominantDirection = null;
EnumFacing dominantDirection = null;
for (ForgeDirection direction : directions)
for (EnumFacing direction : directions)
{
int amt = this.getLength(direction, maxDistance, x, z);
if (amt > distance)
@ -656,9 +659,9 @@ public class TEDemonPortal extends TileEntity
return distance;
}
public List<ForgeDirection> findValidExtentionDirection(int x, int z)
public List<EnumFacing> findValidExtentionDirection(int x, int z)
{
List<ForgeDirection> directions = new LinkedList();
List<EnumFacing> directions = new LinkedList();
if (this.getGridSpace(x, z) == null || !this.getGridSpace(x, z).isRoadSegment())
{
@ -668,41 +671,41 @@ public class TEDemonPortal extends TileEntity
GridSpace nextGrid = this.getGridSpace(x + 1, z);
if (nextGrid.isEmpty())
{
directions.add(ForgeDirection.EAST);
directions.add(EnumFacing.EAST);
}
nextGrid = this.getGridSpace(x - 1, z);
if (nextGrid.isEmpty())
{
directions.add(ForgeDirection.WEST);
directions.add(EnumFacing.WEST);
}
nextGrid = this.getGridSpace(x, z + 1);
if (nextGrid.isEmpty())
{
directions.add(ForgeDirection.SOUTH);
directions.add(EnumFacing.SOUTH);
}
nextGrid = this.getGridSpace(x, z - 1);
if (nextGrid.isEmpty())
{
directions.add(ForgeDirection.NORTH);
directions.add(EnumFacing.NORTH);
}
return directions;
}
public int getLength(ForgeDirection dir, int maxLength, int x, int z) //Number of spaces forward
public int getLength(EnumFacing dir, int maxLength, int x, int z) //Number of spaces forward
{
for (int i = 1; i <= maxLength; i++)
{
GridSpace space = this.getGridSpace(x + i * dir.offsetX, z + i * dir.offsetZ);
GridSpace space = this.getGridSpace(x + i * dir.getFrontOffsetX(), z + i * dir.getFrontOffsetZ());
if (space.isEmpty())
{
for (int k = 1; k <= this.getRoadSpacer(); k++)
{
GridSpace space1 = this.getGridSpace(x + i * dir.offsetX + dir.offsetZ * k, z + i * dir.offsetZ + dir.offsetX * k);
GridSpace space2 = this.getGridSpace(x + i * dir.offsetX - dir.offsetZ * k, z + i * dir.offsetZ - dir.offsetX * k);
GridSpace space1 = this.getGridSpace(x + i * dir.getFrontOffsetX() + dir.getFrontOffsetZ() * k, z + i * dir.getFrontOffsetZ() + dir.getFrontOffsetX() * k);
GridSpace space2 = this.getGridSpace(x + i * dir.getFrontOffsetX() - dir.getFrontOffsetZ() * k, z + i * dir.getFrontOffsetZ() - dir.getFrontOffsetX() * k);
if (space1.isRoadSegment() || space2.isRoadSegment())
{
@ -723,10 +726,10 @@ public class TEDemonPortal extends TileEntity
return maxLength;
}
public Int3 findRoadSpaceFromDirection(ForgeDirection dir, int amount) //TODO
public Int3 findRoadSpaceFromDirection(EnumFacing dir, int amount) //TODO
{
int index = 0;
if (dir == ForgeDirection.NORTH)
if (dir == EnumFacing.NORTH)
{
if(printDebug)
System.out.print("NORTH!");
@ -745,7 +748,7 @@ public class TEDemonPortal extends TileEntity
}
}
}
} else if (dir == ForgeDirection.SOUTH)
} else if (dir == EnumFacing.SOUTH)
{
for (int i = negZRadius + Math.min(posZRadius, limit); i >= Math.max(0, -limit + negZRadius); i--)
{
@ -762,7 +765,7 @@ public class TEDemonPortal extends TileEntity
}
}
}
} else if (dir == ForgeDirection.EAST)
} else if (dir == EnumFacing.EAST)
{
for (int i = negXRadius + Math.min(posXRadius, limit); i >= Math.max(0, -limit + negXRadius); i--)
{
@ -779,7 +782,7 @@ public class TEDemonPortal extends TileEntity
}
}
}
} else if (dir == ForgeDirection.WEST)
} else if (dir == EnumFacing.WEST)
{
for (int i = Math.max(0, -limit + negXRadius); i <= negXRadius + Math.min(posXRadius, limit); i++)
{
@ -801,10 +804,10 @@ public class TEDemonPortal extends TileEntity
return new Int3(0, 0, 0);
}
public Int3 findEmptySpaceNearRoad(ForgeDirection dir, int amount, int closeness)
public Int3 findEmptySpaceNearRoad(EnumFacing dir, int amount, int closeness)
{
int index = 0;
if (dir == ForgeDirection.NORTH)
if (dir == EnumFacing.NORTH)
{
if(printDebug)
System.out.print("NORTH!");
@ -828,7 +831,7 @@ public class TEDemonPortal extends TileEntity
}
}
}
} else if (dir == ForgeDirection.SOUTH)
} else if (dir == EnumFacing.SOUTH)
{
for (int i = negZRadius + posZRadius; i >= 0; i--)
{
@ -850,7 +853,7 @@ public class TEDemonPortal extends TileEntity
}
}
}
} else if (dir == ForgeDirection.EAST)
} else if (dir == EnumFacing.EAST)
{
for (int i = negXRadius + posXRadius; i >= 0; i--)
{
@ -872,7 +875,7 @@ public class TEDemonPortal extends TileEntity
}
}
}
} else if (dir == ForgeDirection.WEST)
} else if (dir == EnumFacing.WEST)
{
for (int i = 0; i <= negXRadius + posXRadius; i++)
{
@ -899,10 +902,10 @@ public class TEDemonPortal extends TileEntity
return new Int3(0, 0, 0);
}
public Int3 findEmptySpaceFromDirection(ForgeDirection dir, int amount)
public Int3 findEmptySpaceFromDirection(EnumFacing dir, int amount)
{
int index = 0;
if (dir == ForgeDirection.NORTH)
if (dir == EnumFacing.NORTH)
{
if(printDebug)
System.out.print("NORTH!");
@ -921,7 +924,7 @@ public class TEDemonPortal extends TileEntity
}
}
}
} else if (dir == ForgeDirection.SOUTH)
} else if (dir == EnumFacing.SOUTH)
{
for (int i = negZRadius + posZRadius; i >= 0; i--)
{
@ -938,7 +941,7 @@ public class TEDemonPortal extends TileEntity
}
}
}
} else if (dir == ForgeDirection.EAST)
} else if (dir == EnumFacing.EAST)
{
for (int i = negXRadius + posXRadius; i >= 0; i--)
{
@ -955,7 +958,7 @@ public class TEDemonPortal extends TileEntity
}
}
}
} else if (dir == ForgeDirection.WEST)
} else if (dir == EnumFacing.WEST)
{
for (int i = 0; i <= negXRadius + posXRadius; i++)
{
@ -977,7 +980,7 @@ public class TEDemonPortal extends TileEntity
return new Int3(0, 0, 0);
}
public int createGriddedRoad(int gridXi, int yi, int gridZi, ForgeDirection dir, int gridLength, boolean convertStarter) //Total grid length
public int createGriddedRoad(int gridXi, int yi, int gridZi, EnumFacing dir, int gridLength, boolean convertStarter) //Total grid length
{
if (gridLength == 0 || gridLength == 1)
{
@ -992,13 +995,13 @@ public class TEDemonPortal extends TileEntity
{
this.setGridSpace(initGridX, initGridZ, new GridSpace(GridSpace.CROSSROAD, initY));
DemonCrosspath crosspath = new DemonCrosspath(xCoord + initGridX * 5, initY, zCoord + initGridZ * 5);
DemonCrosspath crosspath = new DemonCrosspath(pos.getX() + initGridX * 5, initY, pos.getZ() + initGridZ * 5);
crosspath.createCrosspath(worldObj);
}
for (int index = 0; index < gridLength - 1; index++)
{
DemonVillagePath path = new DemonVillagePath(xCoord + initGridX * 5, initY, zCoord + initGridZ * 5, dir, 6);
DemonVillagePath path = new DemonVillagePath(pos.getX() + initGridX * 5, initY, pos.getZ() + initGridZ * 5, dir, 6);
Int3AndBool temp = path.constructFullPath(this, worldObj, this.getRoadStepClearance());
Int3 next = temp.coords;
@ -1015,8 +1018,8 @@ public class TEDemonPortal extends TileEntity
return index;
}
initGridX += dir.offsetX;
initGridZ += dir.offsetZ;
initGridX += dir.getFrontOffsetX();
initGridZ += dir.getFrontOffsetZ();
if (!this.getGridSpace(initGridX, initGridZ).isRoadSegment())
{
@ -1157,10 +1160,10 @@ public class TEDemonPortal extends TileEntity
//
// this.initialize();
//
// if (ForgeDirection.getOrientation(side) == ForgeDirection.UP)
// if (EnumFacing.getOrientation(side) == EnumFacing.UP)
// {
// this.createRandomBuilding(DemonBuilding.BUILDING_HOUSE, 0);
// } else if (ForgeDirection.getOrientation(side) == ForgeDirection.DOWN)
// } else if (EnumFacing.getOrientation(side) == EnumFacing.DOWN)
// {
// this.createRandomBuilding(DemonBuilding.BUILDING_PORTAL, 0);
// } else
@ -1194,11 +1197,11 @@ public class TEDemonPortal extends TileEntity
// GridSpaceHolder grid = this.createGSH();
List<ForgeDirection> directions = new ArrayList();
List<EnumFacing> directions = new ArrayList();
for (int i = 2; i < 6; i++)
{
ForgeDirection testDir = ForgeDirection.getOrientation(i);
EnumFacing testDir = EnumFacing.getFront(i);
directions.add(testDir);
}
@ -1207,9 +1210,9 @@ public class TEDemonPortal extends TileEntity
return 0;
}
HashMap<ForgeDirection, List<DemonBuilding>> schemMap = new HashMap();
HashMap<EnumFacing, List<DemonBuilding>> schemMap = new HashMap();
for (ForgeDirection nextDir : directions)
for (EnumFacing nextDir : directions)
{
for (DemonBuilding build : TEDemonPortal.buildingList)
{
@ -1234,7 +1237,7 @@ public class TEDemonPortal extends TileEntity
return 0;
}
ForgeDirection chosenDirection = (ForgeDirection) schemMap.keySet().toArray()[new Random().nextInt(schemMap.keySet().size())];
EnumFacing chosenDirection = (EnumFacing) schemMap.keySet().toArray()[new Random().nextInt(schemMap.keySet().size())];
DemonBuilding build = schemMap.get(chosenDirection).get(new Random().nextInt(schemMap.get(chosenDirection).size()));
// Int3 portalSpace = build.getDoorSpace(chosenDirection);
@ -1276,7 +1279,7 @@ public class TEDemonPortal extends TileEntity
GridSpaceHolder grid = this.createGSH();
ForgeDirection chosenDirection = this.nextDemonPortalDirection;
EnumFacing chosenDirection = this.nextDemonPortalDirection;
Int3 portalSpace = build.getDoorSpace(chosenDirection);
int yOffset = portalSpace.yCoord;
@ -1288,9 +1291,9 @@ public class TEDemonPortal extends TileEntity
case 1:
int yDestination = yLevel + yOffset;
if(yCoord != yDestination)
if(pos.getY() != yDestination)
{
BlockTeleposer.swapBlocks(this, worldObj, worldObj, xCoord, yCoord, zCoord, xCoord, yDestination, zCoord);
BlockTeleposer.swapBlocks(this, worldObj, worldObj, pos, new BlockPos(pos.getX(), yDestination, pos.getZ()));
}else
{
//Nuthin - just as a reminder that we can now increment properly
@ -1298,9 +1301,9 @@ public class TEDemonPortal extends TileEntity
break;
case 2:
build.destroyAllInField(worldObj, xCoord + (x) * 5, yLevel, zCoord + (z) * 5, chosenDirection.getOpposite());
build.destroyAllInField(worldObj, pos.getX() + (x) * 5, yLevel, pos.getZ() + (z) * 5, chosenDirection.getOpposite());
build.buildAll(this, worldObj, xCoord + (x) * 5, yLevel, zCoord + (z) * 5, chosenDirection.getOpposite(), true);
build.buildAll(this, worldObj, pos.getX() + (x) * 5, yLevel, pos.getZ() + (z) * 5, chosenDirection.getOpposite(), true);
build.setAllGridSpaces(x, z, yLevel, chosenDirection.getOpposite(), GridSpace.MAIN_PORTAL, grid);
this.loadGSH(grid);
break;
@ -1314,24 +1317,24 @@ public class TEDemonPortal extends TileEntity
public int createRandomHouse(int buildingTier)
{
int next = rand.nextInt(4);
ForgeDirection dir;
EnumFacing dir;
switch (next)
{
case 0:
dir = ForgeDirection.NORTH;
dir = EnumFacing.NORTH;
break;
case 1:
dir = ForgeDirection.SOUTH;
dir = EnumFacing.SOUTH;
break;
case 2:
dir = ForgeDirection.EAST;
dir = EnumFacing.EAST;
break;
case 3:
dir = ForgeDirection.WEST;
dir = EnumFacing.WEST;
break;
default:
dir = ForgeDirection.NORTH;
dir = EnumFacing.NORTH;
}
Int3 space = this.findRoadSpaceFromDirection(dir, (rand.nextInt(negXRadius + negZRadius + posXRadius + posZRadius)) + 1); // Second: 1 *
@ -1350,12 +1353,12 @@ public class TEDemonPortal extends TileEntity
return 0;
}
List<ForgeDirection> directions = new ArrayList();
List<EnumFacing> directions = new ArrayList();
for (int i = 2; i < 6; i++)
{
ForgeDirection testDir = ForgeDirection.getOrientation(i);
if (this.getGridSpace(x + testDir.offsetX, z + testDir.offsetZ).isEmpty())
EnumFacing testDir = EnumFacing.getFront(i);
if (this.getGridSpace(x + testDir.getFrontOffsetX(), z + testDir.getFrontOffsetZ()).isEmpty())
{
directions.add(testDir);
}
@ -1366,9 +1369,9 @@ public class TEDemonPortal extends TileEntity
return 0;
}
HashMap<ForgeDirection, List<DemonBuilding>> schemMap = new HashMap();
HashMap<EnumFacing, List<DemonBuilding>> schemMap = new HashMap();
for (ForgeDirection nextDir : directions)
for (EnumFacing nextDir : directions)
{
for (DemonBuilding build : TEDemonPortal.buildingList)
{
@ -1403,19 +1406,19 @@ public class TEDemonPortal extends TileEntity
return 0;
}
ForgeDirection chosenDirection = (ForgeDirection) schemMap.keySet().toArray()[new Random().nextInt(schemMap.keySet().size())];
EnumFacing chosenDirection = (EnumFacing) schemMap.keySet().toArray()[new Random().nextInt(schemMap.keySet().size())];
DemonBuilding build = schemMap.get(chosenDirection).get(new Random().nextInt(schemMap.get(chosenDirection).size()));
Int3 offsetSpace = build.getGridOffsetFromRoad(chosenDirection, yLevel);
int xOff = offsetSpace.xCoord;
int zOff = offsetSpace.zCoord;
build.destroyAllInField(worldObj, xCoord + (x + xOff) * 5, yLevel, zCoord + (z + zOff) * 5, chosenDirection.getOpposite());
build.buildAll(this, worldObj, xCoord + (x + xOff) * 5, yLevel, zCoord + (z + zOff) * 5, chosenDirection.getOpposite(), true);
build.destroyAllInField(worldObj, pos.getX() + (x + xOff) * 5, yLevel, pos.getZ() + (z + zOff) * 5, chosenDirection.getOpposite());
build.buildAll(this, worldObj, pos.getX() + (x + xOff) * 5, yLevel, pos.getZ() + (z + zOff) * 5, chosenDirection.getOpposite(), true);
build.setAllGridSpaces(x + xOff, z + zOff, yLevel, chosenDirection.getOpposite(), GridSpace.HOUSE, grid);
this.loadGSH(grid);
DemonVillagePath path = new DemonVillagePath(xCoord + (x) * 5, yLevel, zCoord + (z) * 5, chosenDirection, 2);
DemonVillagePath path = new DemonVillagePath(pos.getX() + (x) * 5, yLevel, pos.getZ() + (z) * 5, chosenDirection, 2);
Int3AndBool temp = path.constructFullPath(this, worldObj, this.getRoadStepClearance());
@ -1446,14 +1449,14 @@ public class TEDemonPortal extends TileEntity
return -1;
}
public void createRoad(int xi, int yi, int zi, ForgeDirection dir, int length, boolean doesNotDrop)
public void createRoad(int xi, int yi, int zi, EnumFacing dir, int length, boolean doesNotDrop)
{
int curX = xi;
int curY = yi;
int curZ = zi;
int roadRadius = this.getRoadRadius();
if (dir.offsetY != 0)
if (dir.getFrontOffsetY() != 0)
{
return;
}
@ -1495,6 +1498,11 @@ public class TEDemonPortal extends TileEntity
}
return 0;
}
public IBlockState getRoadState()
{
return getRoadBlock().getStateFromMeta(getRoadMeta());
}
public int getRoadStepClearance()
{

View file

@ -26,7 +26,7 @@ public class BookEntityItem extends EntityItem
public BookEntityItem(World world, Entity original, ItemStack stack)
{
this(world, original.posX, original.posY, original.posZ);
this.delayBeforeCanPickup = 20;
this.setDefaultPickupDelay();
this.motionX = original.motionX;
this.motionY = original.motionY;
this.motionZ = original.motionZ;

View file

@ -1,34 +1,31 @@
package WayofTime.alchemicalWizardry.common.entity.mob;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.ModItems;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.*;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityGhast;
import net.minecraft.entity.passive.EntityHorse;
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.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
import net.minecraft.pathfinding.PathNavigateGround;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
public class EntityBileDemon extends EntityDemon
{
private static float maxTamedHealth = 100.0F;
private static float maxUntamedHealth = 200.0F;
private int attackTimer;
public EntityBileDemon(World par1World)
{
super(par1World, AlchemicalWizardry.entityBileDemonID);
maxTamedHealth = 100.0F;
maxUntamedHealth = 200.0F;
this.setSize(1.3F, 2.0F);
this.getNavigator().setAvoidsWater(true);
((PathNavigateGround)this.getNavigator()).func_179690_a(true);
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(2, new EntityAIAttackOnCollide(this, 1.0D, true));
this.tasks.addTask(3, this.aiSit);
@ -41,6 +38,7 @@ public class EntityBileDemon extends EntityDemon
this.targetTasks.addTask(3, new EntityAIHurtByTarget(this, true));
this.setTamed(false);
attackTimer = 0;
this.applyEntityAttributes();
}
@Override
@ -61,338 +59,4 @@ public class EntityBileDemon extends EntityDemon
//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, this.getHealth());
}
protected void entityInit()
{
super.entityInit();
this.dataWatcher.addObject(18, this.getHealth());
//this.dataWatcher.addObject(20, new Byte((byte) BlockColored.getBlockFromDye(1)));
}
/**
* Plays step sound at given x, y, z for the entity
*/
protected void playStepSound(int par1, int par2, int par3, int par4)
{
this.playSound("mob.zombie.step", 0.15F, 1.0F);
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
par1NBTTagCompound.setBoolean("Angry", this.isAngry());
par1NBTTagCompound.setByte("attackTimer", (byte) attackTimer);
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
this.setAngry(par1NBTTagCompound.getBoolean("Angry"));
attackTimer = par1NBTTagCompound.getByte("attackTimer");
}
/**
* Returns the sound this mob makes while it's alive.
*/
protected String getLivingSound()
{
return "none";
}
/**
* Returns the sound this mob makes when it is hurt.
*/
protected String getHurtSound()
{
return "mob.irongolem.hit";
}
/**
* Returns the sound this mob makes on death.
*/
protected String getDeathSound()
{
return "mob.irongolem.death";
}
/**
* Returns the volume for the sounds this mob makes.
*/
protected float getSoundVolume()
{
return 1.0F;
}
/**
* 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--;
}
}
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
super.onUpdate();
}
public float getEyeHeight()
{
return this.height * 0.8F;
}
/**
* The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently
* use in wolves.
*/
public int getVerticalFaceSpeed()
{
return this.isSitting() ? 20 : super.getVerticalFaceSpeed();
}
/**
* Called when the entity is attacked.
*/
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
{
if (this.isEntityInvulnerable())
{
return false;
} else
{
Entity entity = par1DamageSource.getEntity();
this.aiSit.setSitting(false);
if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow))
{
par2 = (par2 + 1.0F) / 2.0F;
}
return super.attackEntityFrom(par1DamageSource, par2);
}
}
public boolean attackEntityAsMob(Entity par1Entity)
{
this.attackTimer = 10;
this.worldObj.setEntityState(this, (byte) 4);
boolean flag = par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) (7 + this.rand.nextInt(15)));
if (flag)
{
par1Entity.motionY += 0.4000000059604645D;
}
this.playSound("mob.irongolem.throw", 1.0F, 1.0F);
return flag;
}
public void setTamed(boolean par1)
{
super.setTamed(par1);
if (par1)
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxTamedHealth);
} else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxUntamedHealth);
}
}
/**
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
*/
@Override
public boolean interact(EntityPlayer par1EntityPlayer)
{
ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
if (this.isTamed())
{
if (itemstack != null)
{
if (itemstack.getItem() instanceof ItemFood)
{
ItemFood itemfood = (ItemFood) itemstack.getItem();
if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < maxTamedHealth)
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
this.heal((float) itemfood.func_150905_g(itemstack));
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null);
}
return true;
}
}
}
if (this.getOwner() instanceof EntityPlayer && SpellHelper.getUsername(par1EntityPlayer).equalsIgnoreCase(SpellHelper.getUsername((EntityPlayer) this.getOwner())) && !this.isBreedingItem(itemstack))
{
if (!this.worldObj.isRemote)
{
this.aiSit.setSitting(!this.isSitting());
this.isJumping = false;
this.setPathToEntity(null);
this.setTarget(null);
this.setAttackTarget(null);
}
this.sendSittingMessageToPlayer(par1EntityPlayer, !this.isSitting());
}
} else if (itemstack != null && itemstack.getItem().equals(ModItems.weakBloodOrb) && !this.isAngry())
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null);
}
if (!this.worldObj.isRemote)
{
if (this.rand.nextInt(1) == 0)
{
this.setTamed(true);
this.setPathToEntity(null);
this.setAttackTarget(null);
this.aiSit.setSitting(true);
this.setHealth(maxTamedHealth);
this.func_152115_b(par1EntityPlayer.getUniqueID().toString());
this.playTameEffect(true);
this.worldObj.setEntityState(this, (byte) 7);
} else
{
this.playTameEffect(false);
this.worldObj.setEntityState(this, (byte) 6);
}
}
return true;
}
return super.interact(par1EntityPlayer);
}
/**
* Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on
* the animal type)
*/
public boolean isBreedingItem(ItemStack par1ItemStack)
{
return false;
}
/**
* Determines whether this wolf is angry or not.
*/
public boolean isAngry()
{
return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0;
}
/**
* Sets whether this wolf is angry or not.
*/
public void setAngry(boolean par1)
{
byte b0 = this.dataWatcher.getWatchableObjectByte(16);
if (par1)
{
this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 2)));
} else
{
this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & -3)));
}
}
/**
* Determines if an entity can be despawned, used on idle far away entities
*/
protected boolean canDespawn()
{
return false;
}
@Override
public boolean func_142018_a(EntityLivingBase par1EntityLivingBase, EntityLivingBase par2EntityLivingBase)
{
if (!(par1EntityLivingBase instanceof EntityCreeper) && !(par1EntityLivingBase instanceof EntityGhast))
{
if (par1EntityLivingBase instanceof EntityBileDemon)
{
EntityBileDemon entitywolf = (EntityBileDemon) par1EntityLivingBase;
if (entitywolf.isTamed() && entitywolf.getOwner() == par2EntityLivingBase)
{
return false;
}
}
return par1EntityLivingBase instanceof EntityPlayer && par2EntityLivingBase instanceof EntityPlayer && !((EntityPlayer) par2EntityLivingBase).canAttackPlayer((EntityPlayer) par1EntityLivingBase) ? false : !(par1EntityLivingBase instanceof EntityHorse) || !((EntityHorse) par1EntityLivingBase).isTame();
} else
{
return false;
}
}
}

View file

@ -1,24 +1,21 @@
package WayofTime.alchemicalWizardry.common.entity.mob;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.ModItems;
import WayofTime.alchemicalWizardry.common.EntityAITargetAggro;
import WayofTime.alchemicalWizardry.common.entity.projectile.HolyProjectile;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.*;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityGhast;
import net.minecraft.entity.passive.EntityHorse;
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.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
import net.minecraft.pathfinding.PathNavigateGround;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.EntityAITargetAggro;
public class EntityBoulderFist extends EntityDemon
{
@ -31,7 +28,7 @@ public class EntityBoulderFist extends EntityDemon
{
super(par1World, AlchemicalWizardry.entityBoulderFistID);
this.setSize(0.8F, 1.2F);
this.getNavigator().setAvoidsWater(true);
((PathNavigateGround)this.getNavigator()).func_179690_a(true);
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(2, this.aiSit);
this.tasks.addTask(3, new EntityAILeapAtTarget(this, 0.4F));
@ -70,334 +67,6 @@ public class EntityBoulderFist extends EntityDemon
}
}
/**
* 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, this.getHealth());
}
protected void entityInit()
{
super.entityInit();
this.dataWatcher.addObject(18, this.getHealth());
}
/**
* 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);
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
this.setAngry(par1NBTTagCompound.getBoolean("Angry"));
this.setCombatTask();
}
/**
* Returns the sound this mob makes while it's alive.
*/
protected String getLivingSound()
{
//TODO change sounds
return this.isAngry() ? "mob.wolf.growl" : (this.rand.nextInt(3) == 0 ? (this.isTamed() && this.dataWatcher.getWatchableObjectFloat(18) < 10.0F ? "mob.wolf.whine" : "mob.wolf.panting") : "mob.wolf.bark");
}
/**
* Returns the sound this mob makes when it is hurt.
*/
protected String getHurtSound()
{
return "mob.wolf.hurt";
}
/**
* Returns the sound this mob makes on death.
*/
protected String getDeathSound()
{
return "mob.wolf.death";
}
/**
* Returns the volume for the sounds this mob makes.
*/
protected float getSoundVolume()
{
return 0.4F;
}
/**
* Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
* use this to react to sunlight and start to burn.
*/
public void onLivingUpdate()
{
super.onLivingUpdate();
}
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
super.onUpdate();
}
public float getEyeHeight()
{
return this.height * 0.8F;
}
/**
* The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently
* use in wolves.
*/
public int getVerticalFaceSpeed()
{
return this.isSitting() ? 20 : super.getVerticalFaceSpeed();
}
/**
* Called when the entity is attacked.
*/
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
{
if (this.isEntityInvulnerable())
{
return false;
} else
{
Entity entity = par1DamageSource.getEntity();
this.aiSit.setSitting(false);
if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow))
{
par2 = (par2 + 1.0F) / 2.0F;
}
return super.attackEntityFrom(par1DamageSource, par2);
}
}
public boolean attackEntityAsMob(Entity par1Entity)
{
int i = this.isTamed() ? 6 : 7;
return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i);
}
public void setTamed(boolean par1)
{
super.setTamed(par1);
if (par1)
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxTamedHealth);
} else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxUntamedHealth);
}
}
/**
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
*/
@Override
public boolean interact(EntityPlayer par1EntityPlayer)
{
ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
if (this.isTamed())
{
if (itemstack != null)
{
if (itemstack.getItem() instanceof ItemFood)
{
ItemFood itemfood = (ItemFood) itemstack.getItem();
if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < maxTamedHealth)
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
this.heal((float) itemfood.func_150905_g(itemstack));
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null);
}
return true;
}
}
}
if (this.getOwner() instanceof EntityPlayer && SpellHelper.getUsername(par1EntityPlayer).equalsIgnoreCase(SpellHelper.getUsername((EntityPlayer) this.getOwner())) && !this.isBreedingItem(itemstack))
{
if (!this.worldObj.isRemote)
{
this.aiSit.setSitting(!this.isSitting());
this.isJumping = false;
this.setPathToEntity(null);
this.setTarget(null);
this.setAttackTarget(null);
}
this.sendSittingMessageToPlayer(par1EntityPlayer, !this.isSitting());
}
} else if (itemstack != null && itemstack.getItem().equals(ModItems.weakBloodOrb) && !this.isAngry())
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null);
}
if (!this.worldObj.isRemote)
{
if (this.rand.nextInt(1) == 0)
{
this.setTamed(true);
this.setPathToEntity(null);
this.setAttackTarget(null);
this.aiSit.setSitting(true);
this.setHealth(maxTamedHealth);
this.func_152115_b(par1EntityPlayer.getUniqueID().toString());
this.playTameEffect(true);
this.worldObj.setEntityState(this, (byte) 7);
} else
{
this.playTameEffect(false);
this.worldObj.setEntityState(this, (byte) 6);
}
}
return true;
}
return super.interact(par1EntityPlayer);
}
/**
* Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on
* the animal type)
*/
public boolean isBreedingItem(ItemStack par1ItemStack)
{
return false;
}
/**
* Determines whether this wolf is angry or not.
*/
public boolean isAngry()
{
return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0;
}
/**
* Sets whether this wolf is angry or not.
*/
public void setAngry(boolean par1)
{
byte b0 = this.dataWatcher.getWatchableObjectByte(16);
if (par1)
{
this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 2)));
} else
{
this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & -3)));
}
}
/**
* Determines if an entity can be despawned, used on idle far away entities
*/
protected boolean canDespawn()
{
return false;
}
@Override
public boolean func_142018_a(EntityLivingBase par1EntityLivingBase, EntityLivingBase par2EntityLivingBase)
{
if (!(par1EntityLivingBase instanceof EntityCreeper) && !(par1EntityLivingBase instanceof EntityGhast))
{
if (par1EntityLivingBase instanceof EntityBoulderFist)
{
EntityBoulderFist entitywolf = (EntityBoulderFist) par1EntityLivingBase;
if (entitywolf.isTamed() && entitywolf.getOwner() == par2EntityLivingBase)
{
return false;
}
}
return par1EntityLivingBase instanceof EntityPlayer && par2EntityLivingBase instanceof EntityPlayer && !((EntityPlayer) par2EntityLivingBase).canAttackPlayer((EntityPlayer) par1EntityLivingBase) ? false : !(par1EntityLivingBase instanceof EntityHorse) || !((EntityHorse) par1EntityLivingBase).isTame();
} else
{
return false;
}
}
/**
* Attack the specified entity using a ranged attack.
*/
public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2)
{
HolyProjectile hol = new HolyProjectile(worldObj, this, par1EntityLivingBase, 1.8f, 0f, 5, 600);
this.worldObj.spawnEntityInWorld(hol);
}
/**
* sets this entity's combat AI.
*/

View file

@ -1,11 +1,22 @@
package WayofTime.alchemicalWizardry.common.entity.mob;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
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.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.ModItems;
import WayofTime.alchemicalWizardry.common.IDemon;
@ -14,8 +25,12 @@ import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
public class EntityDemon extends EntityTameable implements IDemon
{
private boolean isAggro;
private String demonID;
protected boolean isAggro;
protected String demonID;
protected float maxTamedHealth = 100.0F;
protected float maxUntamedHealth = 200.0F;
protected int attackTimer;
protected boolean dropCrystal = true;
@ -61,13 +76,15 @@ public class EntityDemon extends EntityTameable implements IDemon
// TODO Auto-generated method stub
return null;
}
@Override
public void writeToNBT(NBTTagCompound tag)
{
super.writeToNBT(tag);
tag.setBoolean("dropCrystal", this.getDoesDropCrystal());
tag.setBoolean("isAggro", isAggro);
tag.setString("demonID", demonID);
}
@Override
@ -76,6 +93,8 @@ public class EntityDemon extends EntityTameable implements IDemon
super.readFromNBT(tag);
this.setDropCrystal(tag.getBoolean("dropCrystal"));
isAggro = tag.getBoolean("isAggro");
demonID = tag.getString("demonID");
}
@Override
@ -92,7 +111,7 @@ public class EntityDemon extends EntityTameable implements IDemon
DemonPlacer.setOwnerName(drop, SpellHelper.getUsername((EntityPlayer) this.getOwner()));
}
if (this.hasCustomNameTag())
if (this.hasCustomName())
{
drop.setStackDisplayName(this.getCustomNameTag());
}
@ -138,4 +157,387 @@ public class EntityDemon extends EntityTameable implements IDemon
{
this.demonID = id;
}
/**
* 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, this.getHealth());
}
protected void entityInit()
{
super.entityInit();
this.dataWatcher.addObject(18, this.getHealth());
this.dataWatcher.addObject(19, 0);
//this.dataWatcher.addObject(20, new Byte((byte) BlockColored.getBlockFromDye(1)));
}
/**
* Plays step sound at given x, y, z for the entity
*/
protected void playStepSound(int par1, int par2, int par3, int par4)
{
this.playSound("mob.zombie.step", 0.15F, 1.0F);
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
par1NBTTagCompound.setBoolean("Angry", this.isAngry());
par1NBTTagCompound.setByte("attackTimer", (byte) attackTimer);
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
this.setAngry(par1NBTTagCompound.getBoolean("Angry"));
attackTimer = par1NBTTagCompound.getByte("attackTimer");
}
/**
* Returns the sound this mob makes while it's alive.
*/
protected String getLivingSound()
{
return "none";
}
/**
* Returns the sound this mob makes when it is hurt.
*/
protected String getHurtSound()
{
return "mob.irongolem.hit";
}
/**
* Returns the sound this mob makes on death.
*/
protected String getDeathSound()
{
return "mob.irongolem.death";
}
/**
* Returns the volume for the sounds this mob makes.
*/
protected float getSoundVolume()
{
return 1.0F;
}
/**
* Returns the item ID for the item the mob drops on death.
*/
protected int getDropItemId()
{
return -1;
}
public int getAttackTimer()
{
return attackTimer;
}
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
super.onUpdate();
}
public float getEyeHeight()
{
return this.height * 0.8F;
}
/**
* The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently
* use in wolves.
*/
public int getVerticalFaceSpeed()
{
return this.isSitting() ? 20 : super.getVerticalFaceSpeed();
}
/**
* Called when the entity is attacked.
*/
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
{
// if (this.isEntityInvulnerable())
// {
// return false;
// } else
{
Entity entity = par1DamageSource.getEntity();
this.aiSit.setSitting(false);
if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow))
{
par2 = (par2 + 1.0F) / 2.0F;
}
return super.attackEntityFrom(par1DamageSource, par2);
}
}
public boolean attackEntityAsMob(Entity par1Entity)
{
this.attackTimer = 10;
this.worldObj.setEntityState(this, (byte) 4);
boolean flag = par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) (7 + this.rand.nextInt(15)));
if (flag)
{
par1Entity.motionY += 0.4000000059604645D;
}
this.playSound("mob.irongolem.throw", 1.0F, 1.0F);
return flag;
}
public void setTamed(boolean par1)
{
super.setTamed(par1);
if (par1)
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxTamedHealth);
} else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxUntamedHealth);
}
}
/**
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
*/
@Override
public boolean interact(EntityPlayer par1EntityPlayer)
{
ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
if (this.isTamed())
{
if (itemstack != null)
{
if (itemstack.getItem() instanceof ItemFood)
{
ItemFood itemfood = (ItemFood) itemstack.getItem();
if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < maxTamedHealth)
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
this.heal((float) itemfood.getHealAmount(itemstack));
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null);
}
return true;
}
}
}
if (this.getOwner() instanceof EntityPlayer && SpellHelper.getUsername(par1EntityPlayer).equalsIgnoreCase(SpellHelper.getUsername((EntityPlayer) this.getOwner())) && !this.isBreedingItem(itemstack))
{
if (!this.worldObj.isRemote)
{
this.aiSit.setSitting(!this.isSitting());
this.isJumping = false;
// this.setPathToEntity(null);
// this.setTarget(null);
this.setAttackTarget(null);
}
this.sendSittingMessageToPlayer(par1EntityPlayer, !this.isSitting());
}
} else if (itemstack != null && itemstack.getItem().equals(ModItems.weakBloodOrb) && !this.isAngry())
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack) null);
}
if (!this.worldObj.isRemote)
{
if (this.rand.nextInt(1) == 0)
{
this.setTamed(true);
// this.setPathToEntity(null);
this.setAttackTarget(null);
this.aiSit.setSitting(true);
this.setHealth(maxTamedHealth);
this.func_152115_b(par1EntityPlayer.getUniqueID().toString());
this.playTameEffect(true);
this.worldObj.setEntityState(this, (byte) 7);
} else
{
this.playTameEffect(false);
this.worldObj.setEntityState(this, (byte) 6);
}
}
return true;
}
return super.interact(par1EntityPlayer);
}
/**
* Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on
* the animal type)
*/
public boolean isBreedingItem(ItemStack par1ItemStack)
{
return false;
}
/**
* Determines whether this wolf is angry or not.
*/
public boolean isAngry()
{
return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0;
}
/**
* Sets whether this wolf is angry or not.
*/
public void setAngry(boolean par1)
{
byte b0 = this.dataWatcher.getWatchableObjectByte(16);
if (par1)
{
this.dataWatcher.updateObject(16, b0 | 2);
} else
{
this.dataWatcher.updateObject(16, 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, 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, 1);
} else
{
this.dataWatcher.updateObject(19, 0);
}
}
/**
* Returns true if the mob is currently able to mate with the specified mob.
*/
public boolean canMateWith(EntityAnimal par1EntityAnimal)
{
return false;
}
public boolean func_70922_bv()
{
return this.dataWatcher.getWatchableObjectByte(19) == 1;
}
/**
* Determines if an entity can be despawned, used on idle far away entities
*/
protected boolean canDespawn()
{
return false;
}
@Override
public boolean func_142018_a(EntityLivingBase par1EntityLivingBase, EntityLivingBase par2EntityLivingBase)
{
if (!(par1EntityLivingBase instanceof EntityCreeper) && !(par1EntityLivingBase instanceof EntityGhast))
{
if (par1EntityLivingBase instanceof EntityBileDemon)
{
EntityBileDemon entitywolf = (EntityBileDemon) par1EntityLivingBase;
if (entitywolf.isTamed() && entitywolf.getOwner() == par2EntityLivingBase)
{
return false;
}
}
return par1EntityLivingBase instanceof EntityPlayer && par2EntityLivingBase instanceof EntityPlayer && !((EntityPlayer) par2EntityLivingBase).canAttackPlayer((EntityPlayer) par1EntityLivingBase) ? false : !(par1EntityLivingBase instanceof EntityHorse) || !((EntityHorse) par1EntityLivingBase).isTame();
} else
{
return false;
}
}
}

View file

@ -2,13 +2,13 @@ package WayofTime.alchemicalWizardry.common.entity.mob;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIAttackOnCollide;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityGhast;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
@ -16,11 +16,14 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.ModItems;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class EntityElemental extends EntityDemon
{
@ -81,57 +84,60 @@ public class EntityElemental extends EntityDemon
/**
* Moves the entity based on the specified heading. Args: strafe, forward
*/
public void moveEntityWithHeading(float par1, float par2)
public void moveEntityWithHeading(float p_70612_1_, float p_70612_2_)
{
if (this.isInWater())
{
this.moveFlying(par1, par2, 0.02F);
this.moveFlying(p_70612_1_, p_70612_2_, 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())
}
else if (this.isInLava())
{
this.moveFlying(par1, par2, 0.02F);
this.moveFlying(p_70612_1_, p_70612_2_, 0.02F);
this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.motionX *= 0.5D;
this.motionY *= 0.5D;
this.motionZ *= 0.5D;
} else
}
else
{
float f2 = 0.91F;
if (this.onGround)
{
f2 = 0.54600006F;
Block i = this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.boundingBox.minY) - 1, MathHelper.floor_double(this.posZ));
if (i != null)
{
f2 = i.slipperiness * 0.91F;
}
f2 = this.worldObj.getBlockState(new BlockPos(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.getEntityBoundingBox().minY) - 1, MathHelper.floor_double(this.posZ))).getBlock().slipperiness * 0.91F;
}
float f3 = 0.16277136F / (f2 * f2 * f2);
this.moveFlying(par1, par2, this.onGround ? 0.1F * f3 : 0.02F);
this.moveFlying(p_70612_1_, p_70612_2_, this.onGround ? 0.1F * f3 : 0.02F);
f2 = 0.91F;
if (this.onGround)
{
f2 = 0.54600006F;
Block j = this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.boundingBox.minY) - 1, MathHelper.floor_double(this.posZ));
if (j != null)
{
f2 = j.slipperiness * 0.91F;
}
f2 = this.worldObj.getBlockState(new BlockPos(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.getEntityBoundingBox().minY) - 1, MathHelper.floor_double(this.posZ))).getBlock().slipperiness * 0.91F;
}
this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.motionX *= (double) f2;
this.motionY *= (double) f2;
this.motionZ *= (double) f2;
this.motionX *= (double)f2;
this.motionY *= (double)f2;
this.motionZ *= (double)f2;
}
this.prevLimbSwingAmount = this.limbSwingAmount;
double d1 = this.posX - this.prevPosX;
double d0 = this.posZ - this.prevPosZ;
float f4 = MathHelper.sqrt_double(d1 * d1 + d0 * d0) * 4.0F;
if (f4 > 1.0F)
{
f4 = 1.0F;
}
this.limbSwingAmount += (f4 - this.limbSwingAmount) * 0.4F;
this.limbSwing += this.limbSwingAmount;
}
/**
@ -142,115 +148,10 @@ public class EntityElemental extends EntityDemon
return false;
}
protected void updateEntityActionState()
@SideOnly(Side.CLIENT)
public boolean func_110182_bF()
{
if (this.getHealth() <= this.getMaxHealth() / 2.0f && worldObj.rand.nextInt(200) == 0)
{
this.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionReciprocation.id, 100, 1));
}
this.prevAttackCounter = this.attackCounter;
double d0 = this.waypointX - this.posX;
double d1 = this.waypointY - this.posY;
double d2 = this.waypointZ - this.posZ;
double d3 = d0 * d0 + d1 * d1 + d2 * d2;
if (d3 < 1.0D || d3 > 3600.0D)
{
this.waypointX = this.posX + (double) ((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F);
this.waypointY = this.posY + (double) ((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F);
this.waypointZ = this.posZ + (double) ((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F);
}
if (this.courseChangeCooldown-- <= 0)
{
this.courseChangeCooldown += this.rand.nextInt(5) + 2;
d3 = (double) MathHelper.sqrt_double(d3);
if (this.isCourseTraversable(this.waypointX, this.waypointY, this.waypointZ, d3))
{
this.motionX += d0 / d3 * 0.1D;
this.motionY += d1 / d3 * 0.1D;
this.motionZ += d2 / d3 * 0.1D;
} else
{
this.waypointX = this.posX + (double) ((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F);
this.waypointY = this.posY + (double) ((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F);
this.waypointZ = this.posZ + (double) ((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F);
}
}
if (this.targetedEntity != null && this.targetedEntity.isDead)
{
this.targetedEntity = null;
}
if (this.targetedEntity == null || this.aggroCooldown-- <= 0)
{
this.targetedEntity = getClosestVulnerableMonsterToEntity(this, 100.0D);
if (this.targetedEntity != null)
{
this.aggroCooldown = 20;
}
}
double d4 = 64.0D;
if (this.targetedEntity != null && this.targetedEntity.getDistanceSqToEntity(this) < d4 * d4)
{
double d5 = this.targetedEntity.posX - this.posX;
double d6 = this.targetedEntity.boundingBox.minY + (double) (this.targetedEntity.height / 2.0F) - (this.posY + (double) (this.height / 2.0F));
double d7 = this.targetedEntity.posZ - this.posZ;
this.renderYawOffset = this.rotationYaw = -((float) Math.atan2(d5, d7)) * 180.0F / (float) Math.PI;
if (this.courseChangeCooldown <= 0)
{
if (isCourseTraversable(this.targetedEntity.posX, this.targetedEntity.posY, this.targetedEntity.posZ, Math.sqrt(d5 * d5 + d6 * d6 + d7 * d7)))
{
this.waypointX = this.targetedEntity.posX;
this.waypointY = this.targetedEntity.posY;
this.waypointZ = this.targetedEntity.posZ;
this.motionX += d5 / d3 * 0.1D;
this.motionY += d6 / d3 * 0.1D;
this.motionZ += d7 / d3 * 0.1D;
} else
{
this.waypointX = this.posX + (double) ((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F);
this.waypointY = this.posY + (double) ((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F);
this.waypointZ = this.posZ + (double) ((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F);
this.motionX += d5 / d3 * 0.1D;
this.motionY += d6 / d3 * 0.1D;
this.motionZ += d7 / d3 * 0.1D;
}
}
if (this.canEntityBeSeen(this.targetedEntity))
{
if (Math.sqrt(d5 * d5 + d6 * d6 + d7 * d7) < 4)
{
++this.attackCounter;
if (this.attackCounter >= 10)
{
this.worldObj.playAuxSFXAtEntity(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(motionX, this.motionZ)) * 180.0F / (float) Math.PI;
if (this.attackCounter > 0)
{
--this.attackCounter;
}
}
return this.dataWatcher.getWatchableObjectByte(25) != 0;
}
/**
@ -261,7 +162,7 @@ public class EntityElemental extends EntityDemon
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();
AxisAlignedBB axisalignedbb = this.getBoundingBox();
for (int i = 1; (double) i < par7; ++i)
{
@ -298,6 +199,7 @@ public class EntityElemental extends EntityDemon
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
this.setAngry(par1NBTTagCompound.getBoolean("Angry"));
this.setCombatTask();
}
@ -333,6 +235,14 @@ public class EntityElemental extends EntityDemon
public void setAttackTarget(EntityLivingBase par1EntityLivingBase)
{
super.setAttackTarget(par1EntityLivingBase);
if (par1EntityLivingBase == null)
{
this.setAngry(false);
} else if (!this.isTamed())
{
this.setAngry(true);
}
}
/**
@ -348,6 +258,7 @@ public class EntityElemental extends EntityDemon
super.entityInit();
this.dataWatcher.addObject(18, this.getHealth());
this.dataWatcher.addObject(19, 0);
this.dataWatcher.addObject(25, 0);
}
/**
@ -392,12 +303,11 @@ public class EntityElemental extends EntityDemon
}
/**
* 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.
* Returns the item ID for the item the mob drops on death.
*/
public void onLivingUpdate()
protected int getDropItemId()
{
super.onLivingUpdate();
return -1;
}
/**
@ -406,6 +316,11 @@ public class EntityElemental extends EntityDemon
public void onUpdate()
{
super.onUpdate();
if (this.getHealth() <= this.getMaxHealth() / 2.0f && worldObj.rand.nextInt(200) == 0)
{
this.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionReciprocation.id, 100, 1));
}
}
public float getEyeHeight()
@ -425,14 +340,14 @@ public class EntityElemental extends EntityDemon
/**
* Called when the entity is attacked.
*/
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
public boolean attackEntityFrom(DamageSource source, float par2)
{
if (this.isEntityInvulnerable())
if (this.func_180431_b(source))
{
return false;
} else
{
Entity entity = par1DamageSource.getEntity();
Entity entity = source.getEntity();
this.aiSit.setSitting(false);
if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow))
@ -440,7 +355,7 @@ public class EntityElemental extends EntityDemon
par2 = (par2 + 1.0F) / 2.0F;
}
return super.attackEntityFrom(par1DamageSource, par2);
return super.attackEntityFrom(source, par2);
}
}
@ -476,6 +391,54 @@ public class EntityElemental extends EntityDemon
return false;
}
/**
* Determines whether this wolf is angry or not.
*/
public boolean isAngry()
{
return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0;
}
/**
* Sets whether this wolf is angry or not.
*/
public void setAngry(boolean par1)
{
byte b0 = this.dataWatcher.getWatchableObjectByte(16);
if (par1)
{
this.dataWatcher.updateObject(16, b0 | 2);
} else
{
this.dataWatcher.updateObject(16, b0 & -3);
}
}
public void func_70918_i(boolean par1)
{
if (par1)
{
this.dataWatcher.updateObject(19, 1);
} else
{
this.dataWatcher.updateObject(19, 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
*/
@ -536,7 +499,7 @@ public class EntityElemental extends EntityDemon
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));
List<EntityLivingBase> entities = world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(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;

View file

@ -1,22 +1,24 @@
package WayofTime.alchemicalWizardry.common.entity.mob;
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.player.EntityPlayer;
import net.minecraft.pathfinding.PathNavigateGround;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.ModItems;
import WayofTime.alchemicalWizardry.common.EntityAITargetAggro;
import WayofTime.alchemicalWizardry.common.entity.projectile.HolyProjectile;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import net.minecraft.entity.*;
import net.minecraft.entity.ai.*;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityGhast;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
public class EntityFallenAngel extends EntityDemon implements IRangedAttackMob
{
@ -30,7 +32,7 @@ public class EntityFallenAngel extends EntityDemon implements IRangedAttackMob
{
super(par1World, AlchemicalWizardry.entityFallenAngelID);
this.setSize(0.7F, 1.8F);
this.getNavigator().setAvoidsWater(true);
((PathNavigateGround)this.getNavigator()).func_179690_a(true);
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(2, this.aiSit);
this.tasks.addTask(3, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F));
@ -69,327 +71,6 @@ public class EntityFallenAngel extends EntityDemon implements IRangedAttackMob
}
}
/**
* 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, this.getHealth());
}
protected void entityInit()
{
super.entityInit();
this.dataWatcher.addObject(18, this.getHealth());
}
/**
* Plays step sound at given x, y, z for the entity
*/
protected void playStepSound(int par1, int par2, int par3, int par4)
{
this.playSound("mob.zombie.step", 0.15F, 1.0F);
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
par1NBTTagCompound.setBoolean("Angry", this.isAngry());
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
this.setAngry(par1NBTTagCompound.getBoolean("Angry"));
this.setCombatTask();
}
/**
* Returns the sound this mob makes while it's alive.
*/
protected String getLivingSound()
{
//TODO change sounds
return "none";
}
/**
* Returns the sound this mob makes when it is hurt.
*/
protected String getHurtSound()
{
return "none";
}
/**
* Returns the sound this mob makes on death.
*/
protected String getDeathSound()
{
return "mob.wolf.death";
}
/**
* Returns the volume for the sounds this mob makes.
*/
protected float getSoundVolume()
{
return 0.4F;
}
/**
* Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
* use this to react to sunlight and start to burn.
*/
public void onLivingUpdate()
{
super.onLivingUpdate();
}
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
super.onUpdate();
}
public float getEyeHeight()
{
return this.height * 0.8F;
}
/**
* The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently
* use in wolves.
*/
public int getVerticalFaceSpeed()
{
return this.isSitting() ? 20 : super.getVerticalFaceSpeed();
}
/**
* Called when the entity is attacked.
*/
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
{
if (this.isEntityInvulnerable())
{
return false;
} else
{
Entity entity = par1DamageSource.getEntity();
this.aiSit.setSitting(false);
if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow))
{
par2 = (par2 + 1.0F) / 2.0F;
}
return super.attackEntityFrom(par1DamageSource, par2);
}
}
public boolean attackEntityAsMob(Entity par1Entity)
{
int i = this.isTamed() ? 4 : 2;
return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i);
}
public void setTamed(boolean par1)
{
super.setTamed(par1);
if (par1)
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxTamedHealth);
} else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxUntamedHealth);
}
}
/**
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
*/
@Override
public boolean interact(EntityPlayer par1EntityPlayer)
{
ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
if (this.isTamed())
{
if (itemstack != null)
{
if (itemstack.getItem() instanceof ItemFood)
{
ItemFood itemfood = (ItemFood) itemstack.getItem();
if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < maxTamedHealth)
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
this.heal((float) itemfood.func_150905_g(itemstack));
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null);
}
return true;
}
}
}
if (this.getOwner() instanceof EntityPlayer && SpellHelper.getUsername(par1EntityPlayer).equalsIgnoreCase(SpellHelper.getUsername((EntityPlayer) this.getOwner())) && !this.isBreedingItem(itemstack))
{
if (!this.worldObj.isRemote)
{
this.aiSit.setSitting(!this.isSitting());
this.isJumping = false;
this.setPathToEntity(null);
this.setTarget(null);
this.setAttackTarget(null);
}
this.sendSittingMessageToPlayer(par1EntityPlayer, !this.isSitting());
}
} else if (itemstack != null && itemstack.getItem().equals(ModItems.weakBloodOrb) && !this.isAngry())
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null);
}
if (!this.worldObj.isRemote)
{
if (this.rand.nextInt(1) == 0)
{
this.setTamed(true);
this.setPathToEntity(null);
this.setAttackTarget(null);
this.aiSit.setSitting(true);
this.setHealth(maxTamedHealth);
this.func_152115_b(par1EntityPlayer.getUniqueID().toString());
this.playTameEffect(true);
this.worldObj.setEntityState(this, (byte) 7);
} else
{
this.playTameEffect(false);
this.worldObj.setEntityState(this, (byte) 6);
}
}
return true;
}
return super.interact(par1EntityPlayer);
}
/**
* Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on
* the animal type)
*/
public boolean isBreedingItem(ItemStack par1ItemStack)
{
return false;
//return par1ItemStack == null ? false : (!(Item.itemsList[par1ItemStack.itemID] instanceof ItemFood) ? false : ((ItemFood)Item.itemsList[par1ItemStack.itemID]).isWolfsFavoriteMeat());
}
/**
* Determines whether this wolf is angry or not.
*/
public boolean isAngry()
{
return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0;
}
/**
* Sets whether this wolf is angry or not.
*/
public void setAngry(boolean par1)
{
byte b0 = this.dataWatcher.getWatchableObjectByte(16);
if (par1)
{
this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 2)));
} else
{
this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & -3)));
}
}
/**
* Determines if an entity can be despawned, used on idle far away entities
*/
protected boolean canDespawn()
{
//return !this.isTamed() && this.ticksExisted > 2400;
return false;
}
public boolean func_142018_a(EntityLivingBase par1EntityLivingBase, EntityLivingBase par2EntityLivingBase)
{
if (!(par1EntityLivingBase instanceof EntityCreeper) && !(par1EntityLivingBase instanceof EntityGhast))
{
if (par1EntityLivingBase instanceof EntityFallenAngel)
{
EntityFallenAngel entitywolf = (EntityFallenAngel) par1EntityLivingBase;
if (entitywolf.isTamed() && entitywolf.getOwner() == par2EntityLivingBase)
{
return false;
}
}
return par1EntityLivingBase instanceof EntityPlayer && par2EntityLivingBase instanceof EntityPlayer && !((EntityPlayer) par2EntityLivingBase).canAttackPlayer((EntityPlayer) par1EntityLivingBase) ? false : !(par1EntityLivingBase instanceof EntityHorse) || !((EntityHorse) par1EntityLivingBase).isTame();
} else
{
return false;
}
}
/**
* Attack the specified entity using a ranged attack.
*/

View file

@ -1,6 +1,5 @@
package WayofTime.alchemicalWizardry.common.entity.mob;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IRangedAttackMob;
import net.minecraft.entity.SharedMonsterAttributes;
@ -14,22 +13,11 @@ 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.EntityHorse;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.ModItems;
import WayofTime.alchemicalWizardry.common.EntityAITargetAggro;
import WayofTime.alchemicalWizardry.common.entity.projectile.IceProjectile;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
public class EntityIceDemon extends EntityDemon implements IRangedAttackMob
{
@ -79,345 +67,6 @@ public class EntityIceDemon extends EntityDemon implements IRangedAttackMob
}
}
/**
* 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, this.getHealth());
}
protected void entityInit()
{
super.entityInit();
this.dataWatcher.addObject(18, this.getHealth());
}
/**
* Plays step sound at given x, y, z for the entity
*/
protected void playStepSound(int par1, int par2, int par3, int par4)
{
this.playSound("mob.zombie.step", 0.15F, 1.0F);
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
par1NBTTagCompound.setBoolean("Angry", this.isAngry());
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
this.setAngry(par1NBTTagCompound.getBoolean("Angry"));
this.setCombatTask();
}
/**
* Returns the sound this mob makes while it's alive.
*/
protected String getLivingSound()
{
return "none";
}
/**
* Returns the sound this mob makes when it is hurt.
*/
protected String getHurtSound()
{
return "mob.irongolem.hit";
}
/**
* Returns the sound this mob makes on death.
*/
protected String getDeathSound()
{
return "mob.irongolem.death";
}
/**
* Returns the volume for the sounds this mob makes.
*/
protected float getSoundVolume()
{
return 0.4F;
}
/**
* Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
* use this to react to sunlight and start to burn.
*/
public void onLivingUpdate()
{
super.onLivingUpdate();
int range = 2;
Vec3 blockVector = SpellHelper.getEntityBlockVector(this);
int xCoord = (int) (blockVector.xCoord);
int yCoord = (int) (blockVector.yCoord);
int zCoord = (int) (blockVector.zCoord);
for (int i = -range; i <= range; i++)
{
for (int j = -range; j <= range; j++)
{
for (int k = -range; k <= range; k++)
{
if (worldObj.rand.nextFloat() < 0.25f)
{
SpellHelper.freezeWaterBlock(worldObj, xCoord + i, yCoord + j, zCoord + k);
}
}
}
}
}
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
super.onUpdate();
}
public float getEyeHeight()
{
return this.height * 0.8F;
}
/**
* The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently
* use in wolves.
*/
public int getVerticalFaceSpeed()
{
return this.isSitting() ? 20 : super.getVerticalFaceSpeed();
}
/**
* Called when the entity is attacked.
*/
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
{
if (this.isEntityInvulnerable())
{
return false;
} else
{
Entity entity = par1DamageSource.getEntity();
this.aiSit.setSitting(false);
if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow))
{
par2 = (par2 + 1.0F) / 2.0F;
}
return super.attackEntityFrom(par1DamageSource, par2);
}
}
public boolean attackEntityAsMob(Entity par1Entity)
{
int i = this.isTamed() ? 4 : 2;
return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i);
}
public void setTamed(boolean par1)
{
super.setTamed(par1);
if (par1)
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxTamedHealth);
} else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxUntamedHealth);
}
}
/**
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
*/
@Override
public boolean interact(EntityPlayer par1EntityPlayer)
{
ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
if (this.isTamed())
{
if (itemstack != null)
{
if (itemstack.getItem() instanceof ItemFood)
{
ItemFood itemfood = (ItemFood) itemstack.getItem();
if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < maxTamedHealth)
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
this.heal((float) itemfood.func_150905_g(itemstack));
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null);
}
return true;
}
}
}
if (this.getOwner() instanceof EntityPlayer && SpellHelper.getUsername(par1EntityPlayer).equalsIgnoreCase(SpellHelper.getUsername((EntityPlayer) this.getOwner())) && !this.isBreedingItem(itemstack))
{
if (!this.worldObj.isRemote)
{
this.aiSit.setSitting(!this.isSitting());
this.isJumping = false;
this.setPathToEntity(null);
this.setTarget(null);
this.setAttackTarget(null);
}
this.sendSittingMessageToPlayer(par1EntityPlayer, !this.isSitting());
}
} else if (itemstack != null && itemstack.getItem().equals(ModItems.weakBloodOrb) && !this.isAngry())
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null);
}
if (!this.worldObj.isRemote)
{
if (this.rand.nextInt(1) == 0)
{
this.setTamed(true);
this.setPathToEntity(null);
this.setAttackTarget(null);
this.aiSit.setSitting(true);
this.setHealth(maxTamedHealth);
this.func_152115_b(par1EntityPlayer.getUniqueID().toString());
this.playTameEffect(true);
this.worldObj.setEntityState(this, (byte) 7);
} else
{
this.playTameEffect(false);
this.worldObj.setEntityState(this, (byte) 6);
}
}
return true;
}
return super.interact(par1EntityPlayer);
}
/**
* Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on
* the animal type)
*/
public boolean isBreedingItem(ItemStack par1ItemStack)
{
return false;
}
/**
* Determines whether this wolf is angry or not.
*/
public boolean isAngry()
{
return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0;
}
/**
* Sets whether this wolf is angry or not.
*/
public void setAngry(boolean par1)
{
byte b0 = this.dataWatcher.getWatchableObjectByte(16);
if (par1)
{
this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 2)));
} else
{
this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & -3)));
}
}
/**
* Determines if an entity can be despawned, used on idle far away entities
*/
protected boolean canDespawn()
{
return false;
}
public boolean func_142018_a(EntityLivingBase par1EntityLivingBase, EntityLivingBase par2EntityLivingBase)
{
if (!(par1EntityLivingBase instanceof EntityCreeper) && !(par1EntityLivingBase instanceof EntityGhast))
{
if (par1EntityLivingBase instanceof EntityIceDemon)
{
EntityIceDemon entitywolf = (EntityIceDemon) par1EntityLivingBase;
if (entitywolf.isTamed() && entitywolf.getOwner() == par2EntityLivingBase)
{
return false;
}
}
return par1EntityLivingBase instanceof EntityPlayer && par2EntityLivingBase instanceof EntityPlayer && !((EntityPlayer) par2EntityLivingBase).canAttackPlayer((EntityPlayer) par1EntityLivingBase) ? false : !(par1EntityLivingBase instanceof EntityHorse) || !((EntityHorse) par1EntityLivingBase).isTame();
} else
{
return false;
}
}
/**
* Attack the specified entity using a ranged attack.
*/

View file

@ -1,23 +1,21 @@
package WayofTime.alchemicalWizardry.common.entity.mob;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.ModItems;
import WayofTime.alchemicalWizardry.common.EntityAITargetAggro;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.*;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityGhast;
import net.minecraft.entity.passive.EntityHorse;
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.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
import net.minecraft.pathfinding.PathNavigateGround;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.EntityAITargetAggro;
public class EntityLowerGuardian extends EntityDemon
{
@ -29,7 +27,7 @@ public class EntityLowerGuardian extends EntityDemon
{
super(par1World, AlchemicalWizardry.entityLowerGuardianID);
this.setSize(0.7F, 1.8F);
this.getNavigator().setAvoidsWater(true);
((PathNavigateGround)this.getNavigator()).func_179690_a(true);
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(2, new EntityAIAttackOnCollide(this, 1.0D, true));
this.tasks.addTask(3, this.aiSit);
@ -63,342 +61,8 @@ public class EntityLowerGuardian extends EntityDemon
}
}
/**
* Returns true if the newer Entity AI code should be run
*/
public boolean isAIEnabled()
public EntityAgeable createChild(EntityAgeable par1EntityAgeable)
{
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, this.getHealth());
}
protected void entityInit()
{
super.entityInit();
this.dataWatcher.addObject(18, this.getHealth());
}
/**
* Plays step sound at given x, y, z for the entity
*/
protected void playStepSound(int par1, int par2, int par3, int par4)
{
this.playSound("mob.zombie.step", 0.15F, 1.0F);
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
par1NBTTagCompound.setBoolean("Angry", this.isAngry());
par1NBTTagCompound.setByte("attackTimer", (byte) attackTimer);
par1NBTTagCompound.setBoolean("isAggro", this.isAggro());
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
this.setAngry(par1NBTTagCompound.getBoolean("Angry"));
attackTimer = par1NBTTagCompound.getByte("attackTimer");
}
/**
* 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;
}
/**
* Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
* use this to react to sunlight and start to burn.
*/
public void onLivingUpdate()
{
super.onLivingUpdate();
if (attackTimer > 0)
{
attackTimer--;
}
}
public int getAttackTimer()
{
return attackTimer;
}
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
super.onUpdate();
}
public float getEyeHeight()
{
return this.height * 0.8F;
}
/**
* The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently
* use in wolves.
*/
public int getVerticalFaceSpeed()
{
return this.isSitting() ? 20 : super.getVerticalFaceSpeed();
}
/**
* Called when the entity is attacked.
*/
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
{
if (this.isEntityInvulnerable())
{
return false;
} else
{
Entity entity = par1DamageSource.getEntity();
this.aiSit.setSitting(false);
if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow))
{
par2 = (par2 + 1.0F) / 2.0F;
}
return super.attackEntityFrom(par1DamageSource, par2);
}
}
public boolean attackEntityAsMob(Entity par1Entity)
{
this.attackTimer = 10;
this.worldObj.setEntityState(this, (byte) 4);
boolean flag = par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) (7 + this.rand.nextInt(15)));
if (flag)
{
par1Entity.motionY += 0.4000000059604645D;
}
this.playSound("mob.irongolem.throw", 1.0F, 1.0F);
return flag;
}
public void setTamed(boolean par1)
{
super.setTamed(par1);
if (par1)
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxTamedHealth);
} else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxUntamedHealth);
}
}
/**
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
*/
@Override
public boolean interact(EntityPlayer par1EntityPlayer)
{
ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
if (this.isTamed())
{
if (itemstack != null)
{
if (itemstack.getItem() instanceof ItemFood)
{
ItemFood itemfood = (ItemFood) itemstack.getItem();
if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < maxTamedHealth)
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
this.heal((float) itemfood.func_150905_g(itemstack));
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null);
}
return true;
}
}
}
if (this.getOwner() instanceof EntityPlayer && SpellHelper.getUsername(par1EntityPlayer).equalsIgnoreCase(SpellHelper.getUsername((EntityPlayer) this.getOwner())) && !this.isBreedingItem(itemstack))
{
if (!this.worldObj.isRemote)
{
this.aiSit.setSitting(!this.isSitting());
this.isJumping = false;
this.setPathToEntity(null);
this.setTarget(null);
this.setAttackTarget(null);
}
this.sendSittingMessageToPlayer(par1EntityPlayer, !this.isSitting());
}
} else if (itemstack != null && itemstack.getItem().equals(ModItems.weakBloodOrb) && !this.isAngry())
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null);
}
if (!this.worldObj.isRemote)
{
if (this.rand.nextInt(1) == 0)
{
this.setTamed(true);
this.setPathToEntity(null);
this.setAttackTarget(null);
this.aiSit.setSitting(true);
this.setHealth(maxTamedHealth);
this.func_152115_b(par1EntityPlayer.getUniqueID().toString());
this.playTameEffect(true);
this.worldObj.setEntityState(this, (byte) 7);
} else
{
this.playTameEffect(false);
this.worldObj.setEntityState(this, (byte) 6);
}
}
return true;
}
return super.interact(par1EntityPlayer);
}
/**
* Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on
* the animal type)
*/
public boolean isBreedingItem(ItemStack par1ItemStack)
{
return false;
}
/**
* Determines whether this wolf is angry or not.
*/
public boolean isAngry()
{
return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0;
}
/**
* Sets whether this wolf is angry or not.
*/
public void setAngry(boolean par1)
{
byte b0 = this.dataWatcher.getWatchableObjectByte(16);
if (par1)
{
this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 2)));
} else
{
this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & -3)));
}
}
/**
* Determines if an entity can be despawned, used on idle far away entities
*/
protected boolean canDespawn()
{
return false;
}
public boolean func_142018_a(EntityLivingBase par1EntityLivingBase, EntityLivingBase par2EntityLivingBase)
{
if (!(par1EntityLivingBase instanceof EntityCreeper) && !(par1EntityLivingBase instanceof EntityGhast))
{
if (par1EntityLivingBase instanceof EntityLowerGuardian)
{
EntityLowerGuardian entitywolf = (EntityLowerGuardian) par1EntityLivingBase;
if (entitywolf.isTamed() && entitywolf.getOwner() == par2EntityLivingBase)
{
return false;
}
}
return par1EntityLivingBase instanceof EntityPlayer && par2EntityLivingBase instanceof EntityPlayer && !((EntityPlayer) par2EntityLivingBase).canAttackPlayer((EntityPlayer) par1EntityLivingBase) ? false : !(par1EntityLivingBase instanceof EntityHorse) || !((EntityHorse) par1EntityLivingBase).isTame();
} else
{
return false;
}
return this.spawnBabyAnimal(par1EntityAgeable);
}
}

View file

@ -1,24 +1,22 @@
package WayofTime.alchemicalWizardry.common.entity.mob;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.ModItems;
import WayofTime.alchemicalWizardry.common.EntityAITargetAggro;
import WayofTime.alchemicalWizardry.common.entity.projectile.HolyProjectile;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.*;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityGhast;
import net.minecraft.entity.passive.EntityHorse;
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.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
import net.minecraft.pathfinding.PathNavigateGround;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.EntityAITargetAggro;
import WayofTime.alchemicalWizardry.common.entity.projectile.HolyProjectile;
public class EntityShade extends EntityDemon
{
@ -31,7 +29,7 @@ public class EntityShade extends EntityDemon
{
super(par1World, AlchemicalWizardry.entityShadeID);
this.setSize(0.8F, 2.0F);
this.getNavigator().setAvoidsWater(true);
((PathNavigateGround)this.getNavigator()).func_179690_a(true);
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(2, this.aiSit);
this.tasks.addTask(3, new EntityAIAttackOnCollide(this, 1.0D, true));
@ -69,328 +67,6 @@ public class EntityShade extends EntityDemon
}
}
/**
* 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, this.getHealth());
}
protected void entityInit()
{
super.entityInit();
this.dataWatcher.addObject(18, this.getHealth());
}
/**
* Plays step sound at given x, y, z for the entity
*/
protected void playStepSound(int par1, int par2, int par3, int par4)
{
this.playSound("mob.zombie.step", 0.15F, 1.0F);
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
par1NBTTagCompound.setBoolean("Angry", this.isAngry());
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
this.setAngry(par1NBTTagCompound.getBoolean("Angry"));
this.setCombatTask();
}
/**
* Returns the sound this mob makes while it's alive.
*/
protected String getLivingSound()
{
//TODO change sounds
return "none";
}
/**
* Returns the sound this mob makes when it is hurt.
*/
protected String getHurtSound()
{
return "none";
}
/**
* Returns the sound this mob makes on death.
*/
protected String getDeathSound()
{
return "none";
}
/**
* Returns the volume for the sounds this mob makes.
*/
protected float getSoundVolume()
{
return 0.4F;
}
/**
* Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
* use this to react to sunlight and start to burn.
*/
public void onLivingUpdate()
{
super.onLivingUpdate();
}
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
super.onUpdate();
}
public float getEyeHeight()
{
return this.height * 0.8F;
}
/**
* The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently
* use in wolves.
*/
public int getVerticalFaceSpeed()
{
return this.isSitting() ? 20 : super.getVerticalFaceSpeed();
}
/**
* Called when the entity is attacked.
*/
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
{
if (this.isEntityInvulnerable())
{
return false;
} else
{
Entity entity = par1DamageSource.getEntity();
this.aiSit.setSitting(false);
if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow))
{
par2 = (par2 + 1.0F) / 2.0F;
}
return super.attackEntityFrom(par1DamageSource, par2);
}
}
public boolean attackEntityAsMob(Entity par1Entity)
{
int i = this.isTamed() ? 6 : 7;
return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i);
}
public void setTamed(boolean par1)
{
super.setTamed(par1);
if (par1)
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxTamedHealth);
} else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxUntamedHealth);
}
}
/**
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
*/
@Override
public boolean interact(EntityPlayer par1EntityPlayer)
{
ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
if (this.isTamed())
{
if (itemstack != null)
{
if (itemstack.getItem() instanceof ItemFood)
{
ItemFood itemfood = (ItemFood) itemstack.getItem();
if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < maxTamedHealth)
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
this.heal((float) itemfood.func_150905_g(itemstack));
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null);
}
return true;
}
}
}
if (this.getOwner() instanceof EntityPlayer && SpellHelper.getUsername(par1EntityPlayer).equalsIgnoreCase(SpellHelper.getUsername((EntityPlayer) this.getOwner())) && !this.isBreedingItem(itemstack))
{
if (!this.worldObj.isRemote)
{
this.aiSit.setSitting(!this.isSitting());
this.isJumping = false;
this.setPathToEntity(null);
this.setTarget(null);
this.setAttackTarget(null);
}
this.sendSittingMessageToPlayer(par1EntityPlayer, !this.isSitting());
}
} else if (itemstack != null && itemstack.getItem().equals(ModItems.weakBloodOrb) && !this.isAngry())
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack) null);
}
if (!this.worldObj.isRemote)
{
if (this.rand.nextInt(1) == 0)
{
this.setTamed(true);
this.setPathToEntity(null);
this.setAttackTarget(null);
this.aiSit.setSitting(true);
this.setHealth(maxTamedHealth);
this.func_152115_b(par1EntityPlayer.getUniqueID().toString());
this.playTameEffect(true);
this.worldObj.setEntityState(this, (byte) 7);
} else
{
this.playTameEffect(false);
this.worldObj.setEntityState(this, (byte) 6);
}
}
return true;
}
return super.interact(par1EntityPlayer);
}
/**
* Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on
* the animal type)
*/
public boolean isBreedingItem(ItemStack par1ItemStack)
{
return false;
}
/**
* Determines whether this wolf is angry or not.
*/
public boolean isAngry()
{
return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0;
}
/**
* Sets whether this wolf is angry or not.
*/
public void setAngry(boolean par1)
{
byte b0 = this.dataWatcher.getWatchableObjectByte(16);
if (par1)
{
this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 2)));
} else
{
this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & -3)));
}
}
/**
* Determines if an entity can be despawned, used on idle far away entities
*/
protected boolean canDespawn()
{
return false;
}
public boolean func_142018_a(EntityLivingBase par1EntityLivingBase, EntityLivingBase par2EntityLivingBase)
{
if (!(par1EntityLivingBase instanceof EntityCreeper) && !(par1EntityLivingBase instanceof EntityGhast))
{
if (par1EntityLivingBase instanceof EntityBoulderFist)
{
EntityBoulderFist entitywolf = (EntityBoulderFist) par1EntityLivingBase;
if (entitywolf.isTamed() && entitywolf.getOwner() == par2EntityLivingBase)
{
return false;
}
}
return par1EntityLivingBase instanceof EntityPlayer && par2EntityLivingBase instanceof EntityPlayer && !((EntityPlayer) par2EntityLivingBase).canAttackPlayer((EntityPlayer) par1EntityLivingBase) ? false : !(par1EntityLivingBase instanceof EntityHorse) || !((EntityHorse) par1EntityLivingBase).isTame();
} else
{
return false;
}
}
/**
* Attack the specified entity using a ranged attack.
*/
public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2)
{
HolyProjectile hol = new HolyProjectile(worldObj, this, par1EntityLivingBase, 1.8f, 0f, 5, 600);

View file

@ -1,22 +1,24 @@
package WayofTime.alchemicalWizardry.common.entity.mob;
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.player.EntityPlayer;
import net.minecraft.pathfinding.PathNavigateGround;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.ModItems;
import WayofTime.alchemicalWizardry.common.EntityAITargetAggro;
import WayofTime.alchemicalWizardry.common.entity.projectile.MudProjectile;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import net.minecraft.entity.*;
import net.minecraft.entity.ai.*;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityGhast;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
public class EntitySmallEarthGolem extends EntityDemon implements IRangedAttackMob
{
@ -30,7 +32,7 @@ public class EntitySmallEarthGolem extends EntityDemon implements IRangedAttackM
{
super(par1World, AlchemicalWizardry.entitySmallEarthGolemID);
this.setSize(0.2F, 1.0F);
this.getNavigator().setAvoidsWater(true);
((PathNavigateGround)this.getNavigator()).func_179690_a(true);
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(2, this.aiSit);
this.tasks.addTask(3, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F));
@ -66,325 +68,7 @@ public class EntitySmallEarthGolem extends EntityDemon implements IRangedAttackM
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxUntamedHealth);
}
}
/**
* Returns true if the newer Entity AI code should be run
*/
public boolean isAIEnabled()
{
return true;
}
/**
* Sets the active target the Task system uses for tracking
*/
public void setAttackTarget(EntityLivingBase par1EntityLivingBase)
{
super.setAttackTarget(par1EntityLivingBase);
if (par1EntityLivingBase == null)
{
this.setAngry(false);
} else if (!this.isTamed())
{
this.setAngry(true);
}
}
/**
* main AI tick function, replaces updateEntityActionState
*/
protected void updateAITick()
{
this.dataWatcher.updateObject(18, this.getHealth());
}
protected void entityInit()
{
super.entityInit();
this.dataWatcher.addObject(18, this.getHealth());
}
/**
* Plays step sound at given x, y, z for the entity
*/
protected void playStepSound(int par1, int par2, int par3, int par4)
{
this.playSound("mob.zombie.step", 0.15F, 1.0F);
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
par1NBTTagCompound.setBoolean("Angry", this.isAngry());
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
this.setAngry(par1NBTTagCompound.getBoolean("Angry"));
this.setCombatTask();
}
/**
* Returns the sound this mob makes while it's alive.
*/
protected String getLivingSound()
{
return "none";
}
/**
* Returns the sound this mob makes when it is hurt.
*/
protected String getHurtSound()
{
return "mob.irongolem.hit";
}
/**
* Returns the sound this mob makes on death.
*/
protected String getDeathSound()
{
return "mob.irongolem.death";
}
/**
* Returns the volume for the sounds this mob makes.
*/
protected float getSoundVolume()
{
return 0.4F;
}
/**
* Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
* use this to react to sunlight and start to burn.
*/
public void onLivingUpdate()
{
super.onLivingUpdate();
}
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
super.onUpdate();
}
public float getEyeHeight()
{
return this.height * 0.8F;
}
/**
* The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently
* use in wolves.
*/
public int getVerticalFaceSpeed()
{
return this.isSitting() ? 20 : super.getVerticalFaceSpeed();
}
/**
* Called when the entity is attacked.
*/
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
{
if (this.isEntityInvulnerable())
{
return false;
} else
{
Entity entity = par1DamageSource.getEntity();
this.aiSit.setSitting(false);
if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow))
{
par2 = (par2 + 1.0F) / 2.0F;
}
return super.attackEntityFrom(par1DamageSource, par2);
}
}
public boolean attackEntityAsMob(Entity par1Entity)
{
int i = this.isTamed() ? 4 : 2;
return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i);
}
public void setTamed(boolean par1)
{
super.setTamed(par1);
if (par1)
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxTamedHealth);
} else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxUntamedHealth);
}
}
/**
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
*/
@Override
public boolean interact(EntityPlayer par1EntityPlayer)
{
ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
if (this.isTamed())
{
if (itemstack != null)
{
if (itemstack.getItem() instanceof ItemFood)
{
ItemFood itemfood = (ItemFood) itemstack.getItem();
if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < maxTamedHealth)
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
this.heal((float) itemfood.func_150905_g(itemstack));
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null);
}
return true;
}
}
}
if (this.getOwner() instanceof EntityPlayer && SpellHelper.getUsername(par1EntityPlayer).equalsIgnoreCase(SpellHelper.getUsername((EntityPlayer) this.getOwner())) && !this.isBreedingItem(itemstack))
{
if (!this.worldObj.isRemote)
{
this.aiSit.setSitting(!this.isSitting());
this.isJumping = false;
this.setPathToEntity(null);
this.setTarget(null);
this.setAttackTarget(null);
}
this.sendSittingMessageToPlayer(par1EntityPlayer, !this.isSitting());
}
} else if (itemstack != null && itemstack.getItem().equals(ModItems.weakBloodOrb) && !this.isAngry())
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack) null);
}
if (!this.worldObj.isRemote)
{
if (this.rand.nextInt(1) == 0)
{
this.setTamed(true);
this.setPathToEntity(null);
this.setAttackTarget(null);
this.aiSit.setSitting(true);
this.setHealth(maxTamedHealth);
this.func_152115_b(par1EntityPlayer.getUniqueID().toString());
this.playTameEffect(true);
this.worldObj.setEntityState(this, (byte) 7);
} else
{
this.playTameEffect(false);
this.worldObj.setEntityState(this, (byte) 6);
}
}
return true;
}
return super.interact(par1EntityPlayer);
}
/**
* Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on
* the animal type)
*/
public boolean isBreedingItem(ItemStack par1ItemStack)
{
return false;
}
/**
* Determines whether this wolf is angry or not.
*/
public boolean isAngry()
{
return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0;
}
/**
* Sets whether this wolf is angry or not.
*/
public void setAngry(boolean par1)
{
byte b0 = this.dataWatcher.getWatchableObjectByte(16);
if (par1)
{
this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 2)));
} else
{
this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & -3)));
}
}
/**
* Determines if an entity can be despawned, used on idle far away entities
*/
protected boolean canDespawn()
{
return false;
}
public boolean func_142018_a(EntityLivingBase par1EntityLivingBase, EntityLivingBase par2EntityLivingBase)
{
if (!(par1EntityLivingBase instanceof EntityCreeper) && !(par1EntityLivingBase instanceof EntityGhast))
{
if (par1EntityLivingBase instanceof EntitySmallEarthGolem)
{
EntitySmallEarthGolem entitywolf = (EntitySmallEarthGolem) par1EntityLivingBase;
if (entitywolf.isTamed() && entitywolf.getOwner() == par2EntityLivingBase)
{
return false;
}
}
return par1EntityLivingBase instanceof EntityPlayer && par2EntityLivingBase instanceof EntityPlayer && !((EntityPlayer) par2EntityLivingBase).canAttackPlayer((EntityPlayer) par1EntityLivingBase) ? false : !(par1EntityLivingBase instanceof EntityHorse) || !((EntityHorse) par1EntityLivingBase).isTame();
} else
{
return false;
}
}
/**
* Attack the specified entity using a ranged attack.
*/

View file

@ -1,22 +1,24 @@
package WayofTime.alchemicalWizardry.common.entity.mob;
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.player.EntityPlayer;
import net.minecraft.pathfinding.PathNavigateGround;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.ModItems;
import WayofTime.alchemicalWizardry.common.EntityAITargetAggro;
import WayofTime.alchemicalWizardry.common.entity.projectile.FireProjectile;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import net.minecraft.entity.*;
import net.minecraft.entity.ai.*;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityGhast;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
public class EntityWingedFireDemon extends EntityDemon implements IRangedAttackMob
{
@ -30,7 +32,7 @@ public class EntityWingedFireDemon extends EntityDemon implements IRangedAttackM
{
super(par1World, AlchemicalWizardry.entityWingedFireDemonID);
this.setSize(0.7F, 1.8F);
this.getNavigator().setAvoidsWater(true);
((PathNavigateGround)this.getNavigator()).func_179690_a(true);
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(2, this.aiSit);
this.tasks.addTask(3, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F));
@ -71,338 +73,12 @@ public class EntityWingedFireDemon extends EntityDemon implements IRangedAttackM
//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, this.getHealth());
}
protected void entityInit()
{
super.entityInit();
this.dataWatcher.addObject(18, this.getHealth());
}
/**
* Plays step sound at given x, y, z for the entity
*/
protected void playStepSound(int par1, int par2, int par3, int par4)
{
this.playSound("mob.zombie.step", 0.15F, 1.0F);
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
par1NBTTagCompound.setBoolean("Angry", this.isAngry());
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
this.setAngry(par1NBTTagCompound.getBoolean("Angry"));
this.setCombatTask();
}
/**
* Returns the sound this mob makes while it's alive.
*/
protected String getLivingSound()
{
return "mob.blaze.breathe";
}
/**
* Returns the sound this mob makes when it is hurt.
*/
protected String getHurtSound()
{
return "mob.blaze.hit";
}
/**
* Returns the sound this mob makes on death.
*/
protected String getDeathSound()
{
return "mob.blaze.death";
}
/**
* Returns the volume for the sounds this mob makes.
*/
protected float getSoundVolume()
{
return 0.4F;
}
/**
* Returns the item ID for the item the mob drops on death.
*/
protected int getDropItemId()
{
return -1;
}
/**
* Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
* use this to react to sunlight and start to burn.
*/
public void onLivingUpdate()
{
super.onLivingUpdate();
}
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
super.onUpdate();
}
public float getEyeHeight()
{
return this.height * 0.8F;
}
/**
* The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently
* use in wolves.
*/
public int getVerticalFaceSpeed()
{
return this.isSitting() ? 20 : super.getVerticalFaceSpeed();
}
/**
* Called when the entity is attacked.
*/
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
{
if (this.isEntityInvulnerable())
{
return false;
} else
{
Entity entity = par1DamageSource.getEntity();
this.aiSit.setSitting(false);
if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow))
{
par2 = (par2 + 1.0F) / 2.0F;
}
return super.attackEntityFrom(par1DamageSource, par2);
}
}
public boolean attackEntityAsMob(Entity par1Entity)
{
int i = this.isTamed() ? 4 : 2;
return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i);
}
public void setTamed(boolean par1)
{
super.setTamed(par1);
if (par1)
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxTamedHealth);
} else
{
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxUntamedHealth);
}
}
/**
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
*/
@Override
public boolean interact(EntityPlayer par1EntityPlayer)
{
ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
if (this.isTamed())
{
if (itemstack != null)
{
if (itemstack.getItem() instanceof ItemFood)
{
ItemFood itemfood = (ItemFood) itemstack.getItem();
if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < maxTamedHealth)
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
this.heal((float) itemfood.func_150905_g(itemstack));
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null);
}
return true;
}
}
}
if (this.getOwner() instanceof EntityPlayer && SpellHelper.getUsername(par1EntityPlayer).equalsIgnoreCase(SpellHelper.getUsername((EntityPlayer) this.getOwner())) && !this.isBreedingItem(itemstack))
{
if (!this.worldObj.isRemote)
{
this.aiSit.setSitting(!this.isSitting());
this.isJumping = false;
this.setPathToEntity(null);
this.setTarget(null);
this.setAttackTarget(null);
}
this.sendSittingMessageToPlayer(par1EntityPlayer, !this.isSitting());
}
} else if (itemstack != null && itemstack.getItem().equals(ModItems.weakBloodOrb) && !this.isAngry())
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null);
}
if (!this.worldObj.isRemote)
{
if (this.rand.nextInt(1) == 0)
{
this.setTamed(true);
this.setPathToEntity(null);
this.setAttackTarget(null);
this.aiSit.setSitting(true);
this.setHealth(maxTamedHealth);
this.func_152115_b(par1EntityPlayer.getUniqueID().toString());
this.playTameEffect(true);
this.worldObj.setEntityState(this, (byte) 7);
} else
{
this.playTameEffect(false);
this.worldObj.setEntityState(this, (byte) 6);
}
}
return true;
}
return super.interact(par1EntityPlayer);
}
/**
* Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on
* the animal type)
*/
public boolean isBreedingItem(ItemStack par1ItemStack)
{
return false;
}
/**
* Determines whether this wolf is angry or not.
*/
public boolean isAngry()
{
return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0;
}
/**
* Sets whether this wolf is angry or not.
*/
public void setAngry(boolean par1)
{
byte b0 = this.dataWatcher.getWatchableObjectByte(16);
if (par1)
{
this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 2)));
} else
{
this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & -3)));
}
}
/**
* Determines if an entity can be despawned, used on idle far away entities
*/
protected boolean canDespawn()
{
return false;
}
public boolean func_142018_a(EntityLivingBase par1EntityLivingBase, EntityLivingBase par2EntityLivingBase)
{
if (!(par1EntityLivingBase instanceof EntityCreeper) && !(par1EntityLivingBase instanceof EntityGhast))
{
if (par1EntityLivingBase instanceof EntityWingedFireDemon)
{
EntityWingedFireDemon entitywolf = (EntityWingedFireDemon) par1EntityLivingBase;
if (entitywolf.isTamed() && entitywolf.getOwner() == par2EntityLivingBase)
{
return false;
}
}
return par1EntityLivingBase instanceof EntityPlayer && par2EntityLivingBase instanceof EntityPlayer && !((EntityPlayer) par2EntityLivingBase).canAttackPlayer((EntityPlayer) par1EntityLivingBase) ? false : !(par1EntityLivingBase instanceof EntityHorse) || !((EntityHorse) par1EntityLivingBase).isTame();
} else
{
return false;
}
}
/**
* Attack the specified entity using a ranged attack.
*/
public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2)
{
this.worldObj.playAuxSFXAtEntity(null, 1009, (int) this.posX, (int) this.posY, (int) this.posZ, 0);
this.worldObj.playAuxSFXAtEntity(null, 1009, this.getPosition(), 0);
FireProjectile hol = new FireProjectile(worldObj, this, par1EntityLivingBase, 1.8f, 0f, 20, 600);
this.worldObj.spawnEntityInWorld(hol);
}

View file

@ -1,15 +1,12 @@
package WayofTime.alchemicalWizardry.common.entity.mob;
import pneumaticCraft.api.PneumaticRegistry;
import cpw.mods.fml.common.Optional;
import net.minecraft.entity.Entity;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.book.BloodMagicGuide;
import amerifrance.guideapi.api.GuideRegistry;
import cpw.mods.fml.common.Optional;
public class MailOrderEntityItem extends EntityItem
{
@ -31,7 +28,7 @@ public class MailOrderEntityItem extends EntityItem
public MailOrderEntityItem(World world, Entity original, ItemStack stack)
{
this(world, original.posX, original.posY, original.posZ);
this.delayBeforeCanPickup = 20;
this.setDefaultPickupDelay();
this.motionX = original.motionX;
this.motionY = original.motionY;
this.motionZ = original.motionZ;
@ -57,11 +54,11 @@ public class MailOrderEntityItem extends EntityItem
this.deliverItemViaDrone(this.posX, this.posY, this.posZ);
}else
{
EntityItem entity = new BookEntityItem(worldObj, this.posX, this.posY, this.posZ, GuideRegistry.getItemStackForBook(BloodMagicGuide.bloodMagicGuide));
entity.lifespan = 6000;
entity.delayBeforeCanPickup = 20;
entity.motionY = 1;
worldObj.spawnEntityInWorld(entity);
// EntityItem entity = new BookEntityItem(worldObj, this.posX, this.posY, this.posZ, GuideRegistry.getItemStackForBook(BloodMagicGuide.bloodMagicGuide));
// entity.lifespan = 6000;
// entity.setDefaultPickupDelay();
// entity.motionY = 1;
// worldObj.spawnEntityInWorld(entity);
}
this.setDead();
@ -71,6 +68,6 @@ public class MailOrderEntityItem extends EntityItem
@Optional.Method(modid = "PneumaticCraft")
public void deliverItemViaDrone(double x, double y, double z)
{
PneumaticRegistry.getInstance().deliverItemsAmazonStyle(worldObj, (int)x, (int)y, (int)z, GuideRegistry.getItemStackForBook(BloodMagicGuide.bloodMagicGuide));
// PneumaticRegistry.getInstance().deliverItemsAmazonStyle(worldObj, (int)x, (int)y, (int)z, GuideRegistry.getItemStackForBook(BloodMagicGuide.bloodMagicGuide));
}
}

View file

@ -204,7 +204,7 @@ public class EnergyBlastProjectile extends Entity implements IProjectile, IThrow
if (shootingEntity == null)
{
List players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(posX - 1, posY - 1, posZ - 1, posX + 1, posY + 1, posZ + 1));
List players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(posX - 1, posY - 1, posZ - 1, posX + 1, posY + 1, posZ + 1));
Iterator i = players.iterator();
double closestDistance = Double.MAX_VALUE;
EntityPlayer closestPlayer = null;

View file

@ -151,7 +151,7 @@ public class EntityEnergyBazookaSecondaryProjectile extends EnergyBlastProjectil
if (shootingEntity == null)
{
List players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(posX - 1, posY - 1, posZ - 1, posX + 1, posY + 1, posZ + 1));
List players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(posX - 1, posY - 1, posZ - 1, posX + 1, posY + 1, posZ + 1));
Iterator i = players.iterator();
double closestDistance = Double.MAX_VALUE;
EntityPlayer closestPlayer = null;

View file

@ -79,10 +79,6 @@ public class HolyProjectile extends EnergyBlastProjectile
}
}
if (worldObj.isAirBlock((int) this.posX, (int) this.posY, (int) this.posZ))
{
}
spawnHitParticles("magicCrit", 8);
this.setDead();
}
@ -90,7 +86,7 @@ public class HolyProjectile extends EnergyBlastProjectile
@Override
public void doFiringParticles()
{
SpellHelper.sendParticleToAllAround(worldObj, posX, posY, posZ, 30, worldObj.provider.dimensionId, "mobSpellAmbient", posX + smallGauss(0.1D), posY + smallGauss(0.1D), posZ + smallGauss(0.1D), 0.5D, 0.5D, 0.5D);
SpellHelper.sendParticleToAllAround(worldObj, posX, posY, posZ, 30, worldObj.provider.dimensionId, "mobSpell", posX, posY, posZ, 1.0F, 1.0F, 1.0F);
SpellHelper.sendParticleToAllAround(worldObj, posX, posY, posZ, 30, worldObj.provider.getDimensionId(), "mobSpellAmbient", posX + smallGauss(0.1D), posY + smallGauss(0.1D), posZ + smallGauss(0.1D), 0.5D, 0.5D, 0.5D);
SpellHelper.sendParticleToAllAround(worldObj, posX, posY, posZ, 30, worldObj.provider.getDimensionId(), "mobSpell", posX, posY, posZ, 1.0F, 1.0F, 1.0F);
}
}

View file

@ -94,7 +94,7 @@ public class IceProjectile extends EnergyBlastProjectile
@Override
public void doFiringParticles()
{
SpellHelper.sendParticleToAllAround(worldObj, posX, posY, posZ, 30, worldObj.provider.dimensionId, "mobSpellAmbient", posX + smallGauss(0.1D), posY + smallGauss(0.1D), posZ + smallGauss(0.1D), 0.5D, 0.5D, 0.5D);
SpellHelper.sendParticleToAllAround(worldObj, posX, posY, posZ, 30, worldObj.provider.dimensionId, "explode", posX, posY, posZ, gaussian(motionX), gaussian(motionY), gaussian(motionZ));
SpellHelper.sendParticleToAllAround(worldObj, posX, posY, posZ, 30, worldObj.provider.getDimensionId(), "mobSpellAmbient", posX + smallGauss(0.1D), posY + smallGauss(0.1D), posZ + smallGauss(0.1D), 0.5D, 0.5D, 0.5D);
SpellHelper.sendParticleToAllAround(worldObj, posX, posY, posZ, 30, worldObj.provider.getDimensionId(), "explode", posX, posY, posZ, gaussian(motionX), gaussian(motionY), gaussian(motionZ));
}
}

View file

@ -90,8 +90,8 @@ public class LightningBoltProjectile extends EnergyBlastProjectile
@Override
public void doFiringParticles()
{
SpellHelper.sendParticleToAllAround(worldObj, posX, posY, posZ, 30, worldObj.provider.dimensionId, "mobSpellAmbient", posX + smallGauss(0.1D), posY + smallGauss(0.1D), posZ + smallGauss(0.1D), 0.5D, 0.5D, 0.5D);
SpellHelper.sendParticleToAllAround(worldObj, posX, posY, posZ, 30, worldObj.provider.dimensionId, "mobSpell", posX, posY, posZ, 1.0F, 1.0F, 1.0F);
SpellHelper.sendParticleToAllAround(worldObj, posX, posY, posZ, 30, worldObj.provider.getDimensionId(), "mobSpellAmbient", posX + smallGauss(0.1D), posY + smallGauss(0.1D), posZ + smallGauss(0.1D), 0.5D, 0.5D, 0.5D);
SpellHelper.sendParticleToAllAround(worldObj, posX, posY, posZ, 30, worldObj.provider.getDimensionId(), "mobSpell", posX, posY, posZ, 1.0F, 1.0F, 1.0F);
}
@Override

View file

@ -94,8 +94,8 @@ public class MudProjectile extends EnergyBlastProjectile
@Override
public void doFiringParticles()
{
SpellHelper.sendParticleToAllAround(worldObj, posX, posY, posZ, 30, worldObj.provider.dimensionId, "mobSpellAmbient", posX + smallGauss(0.1D), posY + smallGauss(0.1D), posZ + smallGauss(0.1D), 0.5D, 0.5D, 0.5D);
SpellHelper.sendParticleToAllAround(worldObj, posX, posY, posZ, 30, worldObj.provider.dimensionId, "mobSpell", posX, posY, posZ, 0.5F, 0.297F, 0.0664F);
SpellHelper.sendParticleToAllAround(worldObj, posX, posY, posZ, 30, worldObj.provider.getDimensionId(), "mobSpellAmbient", posX + smallGauss(0.1D), posY + smallGauss(0.1D), posZ + smallGauss(0.1D), 0.5D, 0.5D, 0.5D);
SpellHelper.sendParticleToAllAround(worldObj, posX, posY, posZ, 30, worldObj.provider.getDimensionId(), "mobSpell", posX, posY, posZ, 0.5F, 0.297F, 0.0664F);
}
@Override

View file

@ -138,8 +138,8 @@ public class TeleportProjectile extends EnergyBlastProjectile
@Override
public void doFiringParticles()
{
SpellHelper.sendParticleToAllAround(worldObj, posX, posY, posZ, 30, worldObj.provider.dimensionId, "mobSpellAmbient", posX + smallGauss(0.1D), posY + smallGauss(0.1D), posZ + smallGauss(0.1D), 0.5D, 0.5D, 0.5D);
SpellHelper.sendParticleToAllAround(worldObj, posX, posY, posZ, 30, worldObj.provider.dimensionId, "portal", posX, posY, posZ, -motionX, -motionY, -motionZ);
SpellHelper.sendParticleToAllAround(worldObj, posX, posY, posZ, 30, worldObj.provider.getDimensionId(), "mobSpellAmbient", posX + smallGauss(0.1D), posY + smallGauss(0.1D), posZ + smallGauss(0.1D), 0.5D, 0.5D, 0.5D);
SpellHelper.sendParticleToAllAround(worldObj, posX, posY, posZ, 30, worldObj.provider.getDimensionId(), "portal", posX, posY, posZ, -motionX, -motionY, -motionZ);
}
@Override

View file

@ -84,7 +84,7 @@ public class WaterProjectile extends EnergyBlastProjectile
@Override
public void doFiringParticles()
{
SpellHelper.sendParticleToAllAround(worldObj, posX, posY, posZ, 30, worldObj.provider.dimensionId, "portal", posX, posY, posZ, -motionX, -motionY, -motionZ);
SpellHelper.sendParticleToAllAround(worldObj, posX, posY, posZ, 30, worldObj.provider.dimensionId, "mobSpellAmbient", posX + smallGauss(0.1D), posY + smallGauss(0.1D), posZ + smallGauss(0.1D), 0.5D, 0.5D, 0.5D);
SpellHelper.sendParticleToAllAround(worldObj, posX, posY, posZ, 30, worldObj.provider.getDimensionId(), "portal", posX, posY, posZ, -motionX, -motionY, -motionZ);
SpellHelper.sendParticleToAllAround(worldObj, posX, posY, posZ, 30, worldObj.provider.getDimensionId(), "mobSpellAmbient", posX + smallGauss(0.1D), posY + smallGauss(0.1D), posZ + smallGauss(0.1D), 0.5D, 0.5D, 0.5D);
}
}

View file

@ -81,7 +81,7 @@ public class WindGustProjectile extends EnergyBlastProjectile
@Override
public void doFiringParticles()
{
SpellHelper.sendParticleToAllAround(worldObj, posX, posY, posZ, 30, worldObj.provider.dimensionId, "mobSpellAmbient", posX + smallGauss(0.1D), posY + smallGauss(0.1D), posZ + smallGauss(0.1D), 0.5D, 0.5D, 0.5D);
SpellHelper.sendParticleToAllAround(worldObj, posX, posY, posZ, 30, worldObj.provider.dimensionId, "mobSpell", posX, posY, posZ, 1.0F, 1.0F, 1.0F);
SpellHelper.sendParticleToAllAround(worldObj, posX, posY, posZ, 30, worldObj.provider.getDimensionId(), "mobSpellAmbient", posX + smallGauss(0.1D), posY + smallGauss(0.1D), posZ + smallGauss(0.1D), 0.5D, 0.5D, 0.5D);
SpellHelper.sendParticleToAllAround(worldObj, posX, posY, posZ, 30, worldObj.provider.getDimensionId(), "mobSpell", posX, posY, posZ, 1.0F, 1.0F, 1.0F);
}
}

View file

@ -1,83 +0,0 @@
package WayofTime.alchemicalWizardry.common.harvest;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.api.harvest.IHarvestHandler;
import cpw.mods.fml.common.registry.GameRegistry;
public class AgriCraftCropHarvestHandler implements IHarvestHandler
{
public Block harvestBlock;
public Method isMature;
public Method harvest;
public AgriCraftCropHarvestHandler()
{
this.harvestBlock = getBlockForString("AgriCraft:crops");
if(this.harvestBlock != null)
{
try {
Class clazz = Class.forName("com.InfinityRaider.AgriCraft.blocks.BlockCrop");
if(clazz != null)
{
isMature = clazz.getMethod("isMature", World.class, int.class, int.class, int.class);
harvest = clazz.getMethod("harvest", World.class, int.class, int.class, int.class);
}
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchMethodException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public boolean isHarvesterValid()
{
return harvestBlock != null && isMature != null && harvest != null;
}
public static Block getBlockForString(String str)
{
String[] parts = str.split(":");
String modId = parts[0];
String name = parts[1];
return GameRegistry.findBlock(modId, name);
}
public boolean canHandleBlock(Block block)
{
return block == harvestBlock;
}
@Override
public boolean harvestAndPlant(World world, int xCoord, int yCoord, int zCoord, Block block, int meta)
{
if (!this.canHandleBlock(block))
{
return false;
}
try {
return (Boolean)(isMature.invoke(block, world, xCoord, yCoord, zCoord)) && (Boolean)(harvest.invoke(block, world, xCoord, yCoord, zCoord));
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return false;
}
}

View file

@ -3,12 +3,13 @@ package WayofTime.alchemicalWizardry.common.harvest;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.BlockCrops;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.IPlantable;
import WayofTime.alchemicalWizardry.api.harvest.IHarvestHandler;
@ -22,10 +23,6 @@ public class BloodMagicHarvestHandler implements IHarvestHandler
public int getHarvestMeta(Block block)
{
if(block instanceof BlockCrops)
{
}
if (block == Blocks.wheat)
{
return 7;
@ -46,9 +43,9 @@ public class BloodMagicHarvestHandler implements IHarvestHandler
}
@Override
public boolean harvestAndPlant(World world, int xCoord, int yCoord, int zCoord, Block block, int meta)
public boolean harvestAndPlant(World world, BlockPos pos, Block block, IBlockState state)
{
if (!this.canHandleBlock(block) || meta != this.getHarvestMeta(block))
if (!this.canHandleBlock(block) || block.getMetaFromState(state) != this.getHarvestMeta(block))
{
return false;
}
@ -62,7 +59,7 @@ public class BloodMagicHarvestHandler implements IHarvestHandler
int fortune = 0;
List<ItemStack> list = block.getDrops(world, xCoord, yCoord, zCoord, meta, fortune);
List<ItemStack> list = block.getDrops(world, pos, state, fortune);
boolean foundAndRemovedSeed = false;
for (ItemStack stack : list)
@ -92,16 +89,15 @@ public class BloodMagicHarvestHandler implements IHarvestHandler
if (foundAndRemovedSeed)
{
int plantMeta = seed.getPlantMetadata(world, xCoord, yCoord, zCoord);
Block plantBlock = seed.getPlant(world, xCoord, yCoord, zCoord);
IBlockState plantState = seed.getPlant(world, pos);
world.func_147480_a(xCoord, yCoord, zCoord, false);
world.destroyBlock(pos, false);
world.setBlock(xCoord, yCoord, zCoord, plantBlock, plantMeta, 3);
world.setBlockState(pos, plantState, 3);
for (ItemStack stack : list)
{
EntityItem itemEnt = new EntityItem(world, xCoord, yCoord, zCoord, stack);
EntityItem itemEnt = new EntityItem(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, stack);
world.spawnEntityInWorld(itemEnt);
}

View file

@ -1,9 +1,11 @@
package WayofTime.alchemicalWizardry.common.harvest;
import WayofTime.alchemicalWizardry.api.harvest.IHarvestHandler;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.api.harvest.IHarvestHandler;
public class CactusReedHarvestHandler implements IHarvestHandler
{
@ -13,19 +15,19 @@ public class CactusReedHarvestHandler implements IHarvestHandler
}
@Override
public boolean harvestAndPlant(World world, int xCoord, int yCoord, int zCoord, Block block, int meta)
public boolean harvestAndPlant(World world, BlockPos pos, Block block, IBlockState state)
{
if (!this.canHandleBlock(block))
{
return false;
}
if (world.getBlock(xCoord, yCoord - 1, zCoord) != block || world.getBlock(xCoord, yCoord - 2, zCoord) != block)
if (world.getBlockState(pos.offsetDown(1)).getBlock() != block || world.getBlockState(pos.offsetDown(2)).getBlock() != block)
{
return false;
}
world.func_147480_a(xCoord, yCoord, zCoord, true);
world.destroyBlock(pos, true);
return true;
}

View file

@ -1,17 +1,18 @@
package WayofTime.alchemicalWizardry.common.harvest;
import WayofTime.alchemicalWizardry.api.harvest.IHarvestHandler;
import net.minecraft.block.Block;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.IPlantable;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.IPlantable;
import WayofTime.alchemicalWizardry.api.harvest.IHarvestHandler;
public class GenericItemStackHarvestHandler implements IHarvestHandler
{
public Block harvestBlock;
public int harvestMeta;
public ItemStack harvestItem;
@ -30,15 +31,15 @@ public class GenericItemStackHarvestHandler implements IHarvestHandler
return block == harvestBlock;
}
public int getHarvestMeta(Block block)
public int getHarvestMeta()
{
return harvestMeta;
}
@Override
public boolean harvestAndPlant(World world, int xCoord, int yCoord, int zCoord, Block block, int meta)
public boolean harvestAndPlant(World world, BlockPos pos, Block block, IBlockState state)
{
if (!this.canHandleBlock(block) || meta != this.getHarvestMeta(block))
if (!this.canHandleBlock(block) || block.getMetaFromState(state) != this.getHarvestMeta())
{
return false;
}
@ -47,14 +48,14 @@ public class GenericItemStackHarvestHandler implements IHarvestHandler
if (seed == null)
{
world.func_147480_a(xCoord, yCoord, zCoord, true);
world.destroyBlock(pos, true);
return true;
} else
{
int fortune = 0;
List<ItemStack> list = block.getDrops(world, xCoord, yCoord, zCoord, meta, fortune);
List<ItemStack> list = block.getDrops(world, pos, state, fortune);
boolean foundAndRemovedSeed = false;
for (ItemStack stack : list)
@ -85,16 +86,15 @@ public class GenericItemStackHarvestHandler implements IHarvestHandler
if (foundAndRemovedSeed)
{
int plantMeta = seed.getPlantMetadata(world, xCoord, yCoord, zCoord);
Block plantBlock = seed.getPlant(world, xCoord, yCoord, zCoord);
IBlockState plantState = seed.getPlant(world, pos);
world.func_147480_a(xCoord, yCoord, zCoord, false);
world.destroyBlock(pos, false);
world.setBlock(xCoord, yCoord, zCoord, plantBlock, plantMeta, 3);
world.setBlockState(pos, plantState, 3);
for (ItemStack stack : list)
{
EntityItem itemEnt = new EntityItem(world, xCoord, yCoord, zCoord, stack);
EntityItem itemEnt = new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), stack);
world.spawnEntityInWorld(itemEnt);
}

View file

@ -1,10 +1,12 @@
package WayofTime.alchemicalWizardry.common.harvest;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.Item;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.api.harvest.IHarvestHandler;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.world.World;
public class GenericPamSeedlessFruitHarvestHandler implements IHarvestHandler
{
@ -45,22 +47,22 @@ public class GenericPamSeedlessFruitHarvestHandler implements IHarvestHandler
return block == harvestBlock;
}
public int getHarvestMeta(Block block)
public int getHarvestMeta()
{
return harvestMeta;
}
@Override
public boolean harvestAndPlant(World world, int xCoord, int yCoord, int zCoord, Block block, int meta)
public boolean harvestAndPlant(World world, BlockPos pos, Block block, IBlockState state)
{
if (!this.canHandleBlock(block) || meta != this.getHarvestMeta(block))
if (!this.canHandleBlock(block) || block.getMetaFromState(state) != this.getHarvestMeta())
{
return false;
}
world.func_147480_a(xCoord, yCoord, zCoord, true);
world.destroyBlock(pos, true);
world.setBlock(xCoord, yCoord, zCoord, harvestBlock, resetMeta, 3);
world.setBlockState(pos, harvestBlock.getStateFromMeta(resetMeta), 3);
return true;
}

View file

@ -1,15 +1,17 @@
package WayofTime.alchemicalWizardry.common.harvest;
import WayofTime.alchemicalWizardry.api.harvest.IHarvestHandler;
import cpw.mods.fml.common.registry.GameRegistry;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.IPlantable;
import java.util.List;
import WayofTime.alchemicalWizardry.api.harvest.IHarvestHandler;
import cpw.mods.fml.common.registry.GameRegistry;
public class GenericSeededHarvestHandler implements IHarvestHandler
{
@ -57,15 +59,15 @@ public class GenericSeededHarvestHandler implements IHarvestHandler
return block == harvestBlock;
}
public int getHarvestMeta(Block block)
public int getHarvestMeta()
{
return harvestMeta;
}
@Override
public boolean harvestAndPlant(World world, int xCoord, int yCoord, int zCoord, Block block, int meta)
public boolean harvestAndPlant(World world, BlockPos pos, Block block, IBlockState state)
{
if (!this.canHandleBlock(block) || meta != this.getHarvestMeta(block))
if (!this.canHandleBlock(block) || block.getMetaFromState(state) != this.getHarvestMeta())
{
return false;
}
@ -74,14 +76,14 @@ public class GenericSeededHarvestHandler implements IHarvestHandler
if (seed == null)
{
world.func_147480_a(xCoord, yCoord, zCoord, true);
world.destroyBlock(pos, true);
return true;
} else
{
int fortune = 0;
List<ItemStack> list = block.getDrops(world, xCoord, yCoord, zCoord, meta, fortune);
List<ItemStack> list = block.getDrops(world, pos, state, fortune);
boolean foundAndRemovedSeed = false;
for (ItemStack stack : list)
@ -111,16 +113,15 @@ public class GenericSeededHarvestHandler implements IHarvestHandler
if (foundAndRemovedSeed)
{
int plantMeta = seed.getPlantMetadata(world, xCoord, yCoord, zCoord);
Block plantBlock = seed.getPlant(world, xCoord, yCoord, zCoord);
IBlockState plantState = seed.getPlant(world, pos);
world.func_147480_a(xCoord, yCoord, zCoord, false);
world.destroyBlock(pos, false);
world.setBlock(xCoord, yCoord, zCoord, plantBlock, plantMeta, 3);
world.setBlockState(pos, plantState, 3);
for (ItemStack stack : list)
{
EntityItem itemEnt = new EntityItem(world, xCoord, yCoord, zCoord, stack);
EntityItem itemEnt = new EntityItem(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, stack);
world.spawnEntityInWorld(itemEnt);
}

View file

@ -1,9 +1,11 @@
package WayofTime.alchemicalWizardry.common.harvest;
import WayofTime.alchemicalWizardry.api.harvest.IHarvestHandler;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.api.harvest.IHarvestHandler;
public class GourdHarvestHandler implements IHarvestHandler
{
@ -13,13 +15,13 @@ public class GourdHarvestHandler implements IHarvestHandler
}
@Override
public boolean harvestAndPlant(World world, int xCoord, int yCoord, int zCoord, Block block, int meta)
public boolean harvestAndPlant(World world, BlockPos pos, Block block, IBlockState state)
{
if (!this.canHandleBlock(block))
{
return false;
}
world.func_147480_a(xCoord, yCoord, zCoord, true);
world.destroyBlock(pos, true);
return true;
}
}

View file

@ -117,7 +117,7 @@ public class BoundAxe extends ItemAxe implements IBindable
par1ItemStack.getTagCompound().setInteger("worldTimeDelay", (int) (par2World.getWorldTime() - 1) % 200);
return par1ItemStack;
}
if (par2World.isRemote)
{
return par1ItemStack;
@ -128,11 +128,6 @@ public class BoundAxe extends ItemAxe implements IBindable
return par1ItemStack;
}
if (AlchemicalWizardry.disableBoundToolsRightClick)
{
return par1ItemStack;
}
if (par3EntityPlayer.isPotionActive(AlchemicalWizardry.customPotionInhibit))
{
return par1ItemStack;

View file

@ -131,11 +131,6 @@ public class BoundPickaxe extends ItemPickaxe implements IBindable
return par1ItemStack;
}
if (AlchemicalWizardry.disableBoundToolsRightClick)
{
return par1ItemStack;
}
if (par3EntityPlayer.isPotionActive(AlchemicalWizardry.customPotionInhibit))
{
return par1ItemStack;

View file

@ -132,11 +132,6 @@ public class BoundShovel extends ItemSpade implements IBindable
return par1ItemStack;
}
if (AlchemicalWizardry.disableBoundToolsRightClick)
{
return par1ItemStack;
}
if (par3EntityPlayer.isPotionActive(AlchemicalWizardry.customPotionInhibit))
{
return par1ItemStack;

View file

@ -64,7 +64,7 @@ public class CheatyItem extends Item implements IBindable
double posY = par3EntityPlayer.posY;
double posZ = par3EntityPlayer.posZ;
world.playSoundEffect((double) ((float) posX + 0.5F), (double) ((float) posY + 0.5F), (double) ((float) posZ + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
SpellHelper.sendIndexedParticleToAllAround(world, posX, posY, posZ, 20, world.provider.dimensionId, 4, posX, posY, posZ);
SpellHelper.sendIndexedParticleToAllAround(world, posX, posY, posZ, 20, world.provider.getDimensionId(), 4, posX, posY, posZ);
}
if (par3EntityPlayer.worldObj.isRemote)

View file

@ -95,7 +95,7 @@ public class DaggerOfSacrifice extends EnergyItems
for (int i = 0; i < 8; i++)
{
SpellHelper.sendIndexedParticleToAllAround(world, posX, posY, posZ, 20, world.provider.dimensionId, 1, posX, posY, posZ);
SpellHelper.sendIndexedParticleToAllAround(world, posX, posY, posZ, 20, world.provider.getDimensionId(), 1, posX, posY, posZ);
}
par2EntityLivingBase.setHealth(-1);

View file

@ -1,7 +1,9 @@
package WayofTime.alchemicalWizardry.common.items;
import java.util.List;
import WayofTime.alchemicalWizardry.api.summoningRegistry.SummoningRegistry;
import WayofTime.alchemicalWizardry.common.entity.mob.EntityDemon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
@ -20,11 +22,8 @@ import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.api.summoningRegistry.SummoningRegistry;
import WayofTime.alchemicalWizardry.common.entity.mob.EntityDemon;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
public class DemonPlacer extends Item
{
@ -75,8 +74,6 @@ public class DemonPlacer extends Item
((EntityLiving) entity).setCustomNameTag(par1ItemStack.getDisplayName());
}
if (!par2EntityPlayer.capabilities.isCreativeMode)
{
--par1ItemStack.stackSize;
@ -165,16 +162,12 @@ public class DemonPlacer extends Item
entityliving.renderYawOffset = entityliving.rotationYaw;
if (entityliving instanceof EntityDemon)
{
Entity owner = SpellHelper.getPlayerForUsername(DemonPlacer.getOwnerName(itemStack));
if(owner != null)
{
((EntityDemon) entityliving).func_152115_b(owner.getPersistentID().toString());
((EntityDemon) entityliving).func_152115_b(DemonPlacer.getOwnerName(itemStack));
if (!DemonPlacer.getOwnerName(itemStack).equals(""))
{
((EntityDemon) entityliving).setTamed(true);
}
}
if (!DemonPlacer.getOwnerName(itemStack).equals(""))
{
((EntityDemon) entityliving).setTamed(true);
}
}
par0World.spawnEntityInWorld(entity);

View file

@ -66,7 +66,7 @@ public class EnergyBattery extends Item implements ArmourUpgrade, IBindable, IBl
double posY = par3EntityPlayer.posY;
double posZ = par3EntityPlayer.posZ;
world.playSoundEffect((double) ((float) posX + 0.5F), (double) ((float) posY + 0.5F), (double) ((float) posZ + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
SpellHelper.sendIndexedParticleToAllAround(world, posX, posY, posZ, 20, world.provider.dimensionId, 4, posX, posY, posZ);
SpellHelper.sendIndexedParticleToAllAround(world, posX, posY, posZ, 20, world.provider.getDimensionId(), 4, posX, posY, posZ);
}
NBTTagCompound itemTag = par1ItemStack.getTagCompound();

View file

@ -76,7 +76,7 @@ public class EnergyItems extends Item implements IBindable
double posY = player.posY;
double posZ = player.posZ;
SpellHelper.sendIndexedParticleToAllAround(world, posX, posY, posZ, 20, world.provider.dimensionId, 4, posX, posY, posZ);
SpellHelper.sendIndexedParticleToAllAround(world, posX, posY, posZ, 20, world.provider.getDimensionId(), 4, posX, posY, posZ);
world.playSoundEffect((double) ((float) player.posX + 0.5F), (double) ((float) player.posY + 0.5F), (double) ((float) player.posZ + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
}
}

View file

@ -121,7 +121,6 @@ public class EnergySword extends ItemSword
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
super.onItemRightClick(par1ItemStack, par2World, par3EntityPlayer);
if (!EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking())
{
this.setActivated(par1ItemStack, !getActivated(par1ItemStack));

View file

@ -61,7 +61,7 @@ public class ItemDiabloKey extends EnergyItems
double posY = par3EntityPlayer.posY;
double posZ = par3EntityPlayer.posZ;
world.playSoundEffect((double) ((float) posX + 0.5F), (double) ((float) posY + 0.5F), (double) ((float) posZ + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
SpellHelper.sendIndexedParticleToAllAround(world, posX, posY, posZ, 20, world.provider.dimensionId, 4, posX, posY, posZ);
SpellHelper.sendIndexedParticleToAllAround(world, posX, posY, posZ, 20, world.provider.getDimensionId(), 4, posX, posY, posZ);
}
if (!par3EntityPlayer.worldObj.isRemote && !(par3EntityPlayer.getClass().equals(EntityPlayerMP.class)))

View file

@ -9,7 +9,6 @@ import WayofTime.alchemicalWizardry.common.tileEntity.TEMasterStone;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
@ -50,41 +49,52 @@ public class ItemRitualDismantler extends EnergyItems
public boolean breakRitualStoneAtMasterStone(ItemStack stack, EntityPlayer player, World world, int x, int y, int z)
{
ItemStack[] playerInventory = player.inventory.mainInventory;
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TEMasterStone)
{
TEMasterStone masterStone = (TEMasterStone) tileEntity;
int direction = masterStone.getDirection();
int freeSpace = -1;
String ritualName = Rituals.checkValidRitual(world, x, y, z);
List<RitualComponent> ritualList = Rituals.getRitualList(ritualName);
List<RitualComponent> ritualList = Rituals.getRitualList(masterStone.getCurrentRitual());
if (ritualList == null)
{
return false;
}
for (int i = 0; i < playerInventory.length; i++)
{
if (playerInventory[i] == null)
{
freeSpace = i;
break;
}
}
for (RitualComponent rc : ritualList)
{
if (!world.isAirBlock(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction)) && world.getBlock(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction)) instanceof RitualStone)
{
if (EnergyItems.syphonBatteries(stack, player, getEnergyUsed()) || player.capabilities.isCreativeMode)
if (freeSpace >= 0)
{
world.setBlockToAir(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction));
EntityItem entityItem = new EntityItem(world, player.posX, player.posY, player.posZ, new ItemStack(ModBlocks.ritualStone));
if (world.isRemote)
if (EnergyItems.syphonBatteries(stack, player, getEnergyUsed()) || player.capabilities.isCreativeMode)
{
world.playAuxSFX(2005, x, y + 1, z, 0);
}
else
{
world.spawnEntityInWorld(entityItem);
world.setBlockToAir(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction));
player.inventory.addItemStackToInventory(new ItemStack(ModBlocks.ritualStone));
if (world.isRemote)
{
world.playAuxSFX(2005, x, y + 1, z, 0);
return true;
}
}
return true;
}
}
}
return true;
}
return false;

View file

@ -1,17 +1,18 @@
package WayofTime.alchemicalWizardry.common.items;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.BlockPos;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
import java.util.List;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class TelepositionFocus extends EnergyItems
{
@ -111,6 +112,11 @@ public class TelepositionFocus extends EnergyItems
return 0;
}
}
public BlockPos getBlockPos(ItemStack stack)
{
return new BlockPos(xCoord(stack), yCoord(stack), zCoord(stack));
}
public int getFocusLevel()
{

View file

@ -8,6 +8,7 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@ -57,12 +58,6 @@ public class BoundArmour extends ItemArmor implements IAlchemyGoggles, ISpecialA
setMaxDamage(1000);
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
}
@Override
public boolean isItemTool(ItemStack stack)
{
return false;
}
ModelBiped model1 = null;
ModelBiped model2 = null;

View file

@ -102,7 +102,7 @@ public abstract class OmegaArmour extends BoundArmour
if(this.storeDimensionID())
{
this.setDimensionIDStored(itemStack, world.provider.dimensionId);
this.setDimensionIDStored(itemStack, world.provider.getDimensionId());
}
if(this.storeYLevel())

View file

@ -223,7 +223,7 @@ public class ItemAttunedCrystal extends Item implements IReagentManipulator
return itemStack;
}
if (dimension != world.provider.dimensionId || Math.abs(coords.xCoord - x) > maxDistance || Math.abs(coords.yCoord - y) > maxDistance || Math.abs(coords.zCoord - z) > maxDistance)
if (dimension != world.provider.getDimensionId() || Math.abs(coords.xCoord - x) > maxDistance || Math.abs(coords.yCoord - y) > maxDistance || Math.abs(coords.zCoord - z) > maxDistance)
{
player.addChatComponentMessage(new ChatComponentTranslation("message.attunedcrystal.error.toofar"));
return itemStack;
@ -261,7 +261,7 @@ public class ItemAttunedCrystal extends Item implements IReagentManipulator
world.markBlockForUpdate(coords.xCoord, coords.yCoord, coords.zCoord);
} else
{
int dimension = world.provider.dimensionId;
int dimension = world.provider.getDimensionId();
this.setDimension(itemStack, dimension);
this.setCoordinates(itemStack, new Int3(x, y, z));

View file

@ -155,8 +155,8 @@ public class SigilOfMagnetism extends EnergyItems implements ArmourUpgrade, IHol
float posX = Math.round(par3Entity.posX);
float posY = (float) (par3Entity.posY - par3Entity.getEyeHeight());
float posZ = Math.round(par3Entity.posZ);
List<EntityItem> entities = par3EntityPlayer.worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(posX - 0.5f, posY - 0.5f, posZ - 0.5f, posX + 0.5f, posY + 0.5f, posZ + 0.5f).expand(range, verticalRange, range));
List<EntityXPOrb> xpOrbs = par3EntityPlayer.worldObj.getEntitiesWithinAABB(EntityXPOrb.class, AxisAlignedBB.getBoundingBox(posX - 0.5f, posY - 0.5f, posZ - 0.5f, posX + 0.5f, posY + 0.5f, posZ + 0.5f).expand(range, verticalRange, range));
List<EntityItem> entities = par3EntityPlayer.worldObj.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(posX - 0.5f, posY - 0.5f, posZ - 0.5f, posX + 0.5f, posY + 0.5f, posZ + 0.5f).expand(range, verticalRange, range));
List<EntityXPOrb> xpOrbs = par3EntityPlayer.worldObj.getEntitiesWithinAABB(EntityXPOrb.class, new AxisAlignedBB(posX - 0.5f, posY - 0.5f, posZ - 0.5f, posX + 0.5f, posY + 0.5f, posZ + 0.5f).expand(range, verticalRange, range));
for (EntityItem entity : entities)
{
@ -184,8 +184,8 @@ public class SigilOfMagnetism extends EnergyItems implements ArmourUpgrade, IHol
float posX = Math.round(player.posX);
float posY = (float) (player.posY - player.getEyeHeight());
float posZ = Math.round(player.posZ);
List<EntityItem> entities = player.worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(posX - 0.5f, posY - 0.5f, posZ - 0.5f, posX + 0.5f, posY + 0.5f, posZ + 0.5f).expand(range, verticalRange, range));
List<EntityXPOrb> xpOrbs = player.worldObj.getEntitiesWithinAABB(EntityXPOrb.class, AxisAlignedBB.getBoundingBox(posX - 0.5f, posY - 0.5f, posZ - 0.5f, posX + 0.5f, posY + 0.5f, posZ + 0.5f).expand(range, verticalRange, range));
List<EntityItem> entities = player.worldObj.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(posX - 0.5f, posY - 0.5f, posZ - 0.5f, posX + 0.5f, posY + 0.5f, posZ + 0.5f).expand(range, verticalRange, range));
List<EntityXPOrb> xpOrbs = player.worldObj.getEntitiesWithinAABB(EntityXPOrb.class, new AxisAlignedBB(posX - 0.5f, posY - 0.5f, posZ - 0.5f, posX + 0.5f, posY + 0.5f, posZ + 0.5f).expand(range, verticalRange, range));
for (EntityItem entity : entities)
{

View file

@ -252,7 +252,7 @@ public class SigilOfTheBridge extends EnergyItems implements ArmourUpgrade, ISig
}
int range = 2;
int verticalOffset = -2;
int verticalOffset = -1;
if (player.isSneaking())
{

View file

@ -6,6 +6,7 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.IChatComponent;
import java.util.UUID;
@ -136,13 +137,13 @@ public class InventoryHolding implements IInventory
}
@Override
public String getInventoryName()
public String getName()
{
return "SigilOfHolding";
}
@Override
public boolean hasCustomInventoryName()
public boolean hasCustomName()
{
return false;
}
@ -166,13 +167,13 @@ public class InventoryHolding implements IInventory
}
@Override
public void openInventory()
public void openInventory(EntityPlayer player)
{
// NOOP
}
@Override
public void closeInventory()
public void closeInventory(EntityPlayer player)
{
// NOOP
}
@ -224,7 +225,7 @@ public class InventoryHolding implements IInventory
public static boolean hasTag(ItemStack itemStack, String keyName)
{
return itemStack != null && itemStack.stackTagCompound != null && itemStack.stackTagCompound.hasKey(keyName);
return itemStack != null && itemStack.getTagCompound() != null && itemStack.getTagCompound().hasKey(keyName);
}
public static boolean hasUUID(ItemStack itemStack)
@ -246,7 +247,7 @@ public class InventoryHolding implements IInventory
private static void initNBTTagCompound(ItemStack itemStack)
{
if (itemStack.stackTagCompound == null)
if (itemStack.getTagCompound() == null)
{
itemStack.setTagCompound(new NBTTagCompound());
}
@ -256,6 +257,36 @@ public class InventoryHolding implements IInventory
{
initNBTTagCompound(itemStack);
itemStack.stackTagCompound.setLong(keyName, keyValue);
itemStack.getTagCompound().setLong(keyName, keyValue);
}
@Override
public IChatComponent getDisplayName() {
// TODO Auto-generated method stub
return null;
}
@Override
public int getField(int id) {
// TODO Auto-generated method stub
return 0;
}
@Override
public void setField(int id, int value) {
// TODO Auto-generated method stub
}
@Override
public int getFieldCount() {
// TODO Auto-generated method stub
return 0;
}
@Override
public void clear() {
// TODO Auto-generated method stub
}
}

View file

@ -1,14 +1,14 @@
package WayofTime.alchemicalWizardry.common.items.sigil.holding;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityClientPlayerMP;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.event.MouseEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ScrollHelper
@ -16,7 +16,7 @@ public class ScrollHelper
@SubscribeEvent
public void onMouseEvent(MouseEvent event)
{
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;
if (event.dwheel != 0 && player != null && player.isSneaking())
{

View file

@ -19,7 +19,7 @@ import cpw.mods.fml.relauncher.SideOnly;
public class SigilOfHolding extends EnergyItems
{
private static int invSize = 5;
private static int invSize = 4;
private static final String NBT_CURRENT_SIGIL = "CurrentSigil";
@ -83,7 +83,7 @@ public class SigilOfHolding extends EnergyItems
par3List.add(StatCollector.translateToLocal("tooltip.item.currentitem") + " " + item.getDisplayName());
}
for (int i = 0; i < invSize; i++)
for (int i = 0; i <= invSize; i++)
{
if (inv[i] != null)
{
@ -156,41 +156,11 @@ public class SigilOfHolding extends EnergyItems
return par1ItemStack;
}
@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
{
if (checkAndSetItemOwner(stack, player))
{
int currentSlot = getCurrentItem(stack);
ItemStack[] inv = getInternalInventory(stack);
if (inv == null)
{
return false;
}
ItemStack itemUsed = inv[currentSlot];
if (itemUsed == null)
{
return false;
}
boolean bool = itemUsed.getItem().onItemUseFirst(stack, player, world, x, y, z, side, hitX, hitY, hitZ);
saveInventory(stack, inv);
return bool;
}
return false;
}
public static int next(int mode)
{
int index = mode + 1;
if (index >= invSize)
if (index >= invSize + 1)
{
index = 0;
}
@ -212,10 +182,10 @@ public class SigilOfHolding extends EnergyItems
private static void initModeTag(ItemStack itemStack)
{
if (itemStack.stackTagCompound == null)
if (itemStack.getTagCompound() == null)
{
itemStack.stackTagCompound = new NBTTagCompound();
itemStack.stackTagCompound.setInteger(NBT_CURRENT_SIGIL, invSize);
itemStack.getTagCompound() = new NBTTagCompound();
itemStack.getTagCompound().setInteger(NBT_CURRENT_SIGIL, invSize);
}
}
@ -239,7 +209,7 @@ public class SigilOfHolding extends EnergyItems
if (itemStack != null && itemStack.getItem() instanceof SigilOfHolding)
{
initModeTag(itemStack);
int currentSigil = itemStack.stackTagCompound.getInteger(NBT_CURRENT_SIGIL);
int currentSigil = itemStack.getTagCompound().getInteger(NBT_CURRENT_SIGIL);
currentSigil = MathHelper.clamp_int(currentSigil, 0, invSize);
return currentSigil;
}
@ -270,7 +240,7 @@ public class SigilOfHolding extends EnergyItems
NBTTagCompound tag = tagList.getCompoundTagAt(i);
int slot = tag.getByte("Slot");
if (slot >= 0 && slot < invSize)
if (slot >= 0 && slot <= invSize)
{
inv[slot] = ItemStack.loadItemStackFromNBT(tag);
}
@ -290,7 +260,7 @@ public class SigilOfHolding extends EnergyItems
NBTTagList itemList = new NBTTagList();
for (int i = 0; i < invSize; i++)
for (int i = 0; i <= invSize; i++)
{
if (inventory[i] != null)
{
@ -309,7 +279,7 @@ public class SigilOfHolding extends EnergyItems
if (itemStack != null && itemStack.getItem() instanceof SigilOfHolding)
{
initModeTag(itemStack);
itemStack.stackTagCompound.setInteger(NBT_CURRENT_SIGIL, mode);
itemStack.getTagCompound().setInteger(NBT_CURRENT_SIGIL, mode);
}
}
@ -331,7 +301,7 @@ public class SigilOfHolding extends EnergyItems
return;
}
for (int i = 0; i < invSize; i++)
for (int i = 0; i <= invSize; i++)
{
if (inv[i] == null)
{

View file

@ -1,6 +1,5 @@
package WayofTime.alchemicalWizardry.common.omega;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@ -35,13 +34,13 @@ public class OmegaParadigmEarth extends OmegaParadigm
{
if(player.posY < 50 && player.getHealth() < player.getMaxHealth())
{
player.addPotionEffect(new PotionEffect(Potion.regeneration.id, 200, 0, true));
player.addPotionEffect(new PotionEffect(Potion.regeneration.id, 200, 0, true, false));
}
}
if(player.posY > 100)
{
player.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionHeavyHeart.id, 200, 0, true));
player.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionHeavyHeart.id, 200, 0, true, false));
}
}

View file

@ -35,25 +35,25 @@ public class OmegaParadigmFire extends OmegaParadigm
boolean isInLava = player.isInsideOfMaterial(Material.lava);
if(player.isBurning() && player.getHealth() < player.getMaxHealth())
{
player.addPotionEffect(new PotionEffect(Potion.regeneration.id, 200, isInLava ? 1 : 0, true));
player.addPotionEffect(new PotionEffect(Potion.regeneration.id, 200, isInLava ? 1 : 0, true, false));
}
if(player.isBurning())
{
player.addPotionEffect(new PotionEffect(Potion.damageBoost.id, isInLava ? 400 : 200, isInLava ? 1 : 0, true));
player.addPotionEffect(new PotionEffect(Potion.damageBoost.id, isInLava ? 400 : 200, isInLava ? 1 : 0, true, false));
}
if(player.isInWater())
{
player.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 200, 2, true));
player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 200, 2, true));
player.addPotionEffect(new PotionEffect(Potion.weakness.id, 200, 1, true));
player.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 200, 2, true, false));
player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 200, 2, true, false));
player.addPotionEffect(new PotionEffect(Potion.weakness.id, 200, 1, true, false));
}
}
if(player.isBurning())
{
player.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 200, 0, true));
player.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 200, 0, true, false));
}
}

View file

@ -7,6 +7,7 @@ import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentRegistry;
@ -35,14 +36,14 @@ public class OmegaParadigmWater extends OmegaParadigm
@Override
public void onUpdate(World world, EntityPlayer player, ItemStack stack)
{
player.addPotionEffect(new PotionEffect(Potion.waterBreathing.id, 3, 0, true));
player.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionAmphibian.id, 3, 0, true));
player.addPotionEffect(new PotionEffect(Potion.waterBreathing.id, 3, 0, true, false));
player.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionAmphibian.id, 3, 0, true, false));
if(world.getWorldTime() % 100 == 0 && !world.isRemote)
{
if(player.isInWater() && player.getHealth() < player.getMaxHealth())
{
player.addPotionEffect(new PotionEffect(Potion.regeneration.id, 200, 0, true));
player.addPotionEffect(new PotionEffect(Potion.regeneration.id, 200, 0, true, false));
}
}
}
@ -52,7 +53,7 @@ public class OmegaParadigmWater extends OmegaParadigm
{
if(entity instanceof EntityLivingBase)
{
((EntityLivingBase) entity).addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionDrowning.id, 100, 1, true));
((EntityLivingBase) entity).addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionDrowning.id, 100, 1, true, false));
}
return true;
}
@ -74,7 +75,7 @@ public class OmegaParadigmWater extends OmegaParadigm
{
for(int k=-range; k<=range; k++)
{
TEMimicBlock.createMimicBlockAtLocation(world, x+i, y+j, z+k, 300, Blocks.water, 0, ReagentRegistry.aquasalusReagent);
TEMimicBlock.createMimicBlockAtLocation(world, new BlockPos(x+i, y+j, z+k), 300, Blocks.water.getDefaultState(), ReagentRegistry.aquasalusReagent);
}
}
}

View file

@ -33,7 +33,7 @@ public class OmegaParadigmWind extends OmegaParadigm
{
if(world.getWorldTime() % 100 == 0 && !world.isRemote && player.posY > 128 && player.getHealth() < player.getMaxHealth())
{
player.addPotionEffect(new PotionEffect(Potion.regeneration.id, 200, player.posY > 128 + 64 ? 1 : 0, true));
player.addPotionEffect(new PotionEffect(Potion.regeneration.id, 200, player.posY > 128 + 64 ? 1 : 0, true, false));
}
player.fallDistance = 0;

View file

@ -1,6 +1,7 @@
package WayofTime.alchemicalWizardry.common.renderer;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
@ -48,7 +49,7 @@ public class AlchemyCircleRenderer extends MRSRenderer
GL11.glPushMatrix();
float f1 = 1.0f;
Tessellator tessellator = Tessellator.instance;
Tessellator tessellator = Tessellator.getInstance();
this.bindTexture(resourceLocation);
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F);
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F);
@ -61,22 +62,23 @@ public class AlchemyCircleRenderer extends MRSRenderer
// GL11.glDepthMask(false);
tessellator.startDrawingQuads();
tessellator.setColorRGBA(colourRed, colourGreen, colourBlue, colourIntensity);
WorldRenderer wr = tessellator.getWorldRenderer();
wr.startDrawingQuads();
wr.func_178961_b(colourRed, colourGreen, colourBlue, colourIntensity);
GL11.glTranslated(x + 0.5 + xOffset, y + 0.5 + (yOffset - initialY) * (tile.getRunningTime() / 100d) + initialY, z + 0.5 + zOffset);
float rotationAngle = (float) (720.0 * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL);
GL11.glRotatef(rotationAngle, 0F, 1F, 0F); //Rotate on planar axis
tessellator.setBrightness(240);
// tessellator.setBrightness(240);
double finalRadius = (radius) * (tile.getRunningTime() / 100d);
tessellator.addVertexWithUV(-finalRadius, 0, -finalRadius, 0.0d, 0.0d);
tessellator.addVertexWithUV(finalRadius, 0, -finalRadius, 1.0d, 0.0d);
tessellator.addVertexWithUV(finalRadius, 0, finalRadius, 1.0d, 1.0d);
tessellator.addVertexWithUV(-finalRadius, 0, finalRadius, 0.0d, 1.0d);
wr.addVertexWithUV(-finalRadius, 0, -finalRadius, 0.0d, 0.0d);
wr.addVertexWithUV(finalRadius, 0, -finalRadius, 1.0d, 0.0d);
wr.addVertexWithUV(finalRadius, 0, finalRadius, 1.0d, 1.0d);
wr.addVertexWithUV(-finalRadius, 0, finalRadius, 0.0d, 1.0d);
tessellator.draw();

View file

@ -1,13 +1,16 @@
package WayofTime.alchemicalWizardry.common.renderer;
import WayofTime.alchemicalWizardry.api.ColourAndCoords;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import WayofTime.alchemicalWizardry.api.ColourAndCoords;
public class BeamRenderer
{
private static final ResourceLocation field_110629_a = new ResourceLocation("textures/entity/beacon_beam.png");
@ -53,7 +56,7 @@ public class BeamRenderer
protected static void bindTexture(ResourceLocation p_147499_1_)
{
TextureManager texturemanager = TileEntityRendererDispatcher.instance.field_147553_e;
TextureManager texturemanager = TileEntityRendererDispatcher.instance.renderEngine;
if (texturemanager != null)
{
@ -74,7 +77,7 @@ public class BeamRenderer
GL11.glPushMatrix();
float f1 = 1.0f;
Tessellator tessellator = Tessellator.instance;
Tessellator tessellator = Tessellator.getInstance();
BeamRenderer.bindTexture(field_110629_a);
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F);
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F);
@ -87,9 +90,10 @@ public class BeamRenderer
GL11.glDepthMask(false);
WorldRenderer wr = tessellator.getWorldRenderer();
tessellator.startDrawingQuads();
tessellator.setColorRGBA(colourRed, colourGreen, colourBlue, colourIntensity);
wr.startDrawingQuads();
wr.func_178961_b(colourRed, colourGreen, colourBlue, colourIntensity);
double inside = -(this.size / 2d);
double outside = 1.0d - (0.50d - this.size / 2d) - 0.5d;
@ -116,24 +120,24 @@ public class BeamRenderer
double offset = 0;
tessellator.setBrightness(240);
// tessellator.setBrightness(240);
float s = 1F / 16F;
tessellator.addVertexWithUV(d26, d18, d19, d28, d30);
tessellator.addVertexWithUV(offset, d18, d19, d28, d29);
tessellator.addVertexWithUV(offset, d20, d21, d27, d29);
tessellator.addVertexWithUV(d26, d20, d21, d27, d30);
tessellator.addVertexWithUV(d26, d24, d25, d28, d30);
tessellator.addVertexWithUV(offset, d24, d25, d28, d29);
tessellator.addVertexWithUV(offset, d22, d23, d27, d29);
tessellator.addVertexWithUV(d26, d22, d23, d27, d30);
tessellator.addVertexWithUV(d26, d20, d21, d28, d30);
tessellator.addVertexWithUV(offset, d20, d21, d28, d29);
tessellator.addVertexWithUV(offset, d24, d25, d27, d29);
tessellator.addVertexWithUV(d26, d24, d25, d27, d30);
tessellator.addVertexWithUV(d26, d22, d23, d28, d30);
tessellator.addVertexWithUV(offset, d22, d23, d28, d29);
tessellator.addVertexWithUV(offset, d18, d19, d27, d29);
tessellator.addVertexWithUV(d26, d18, d19, d27, d30);
wr.addVertexWithUV(d26, d18, d19, d28, d30);
wr.addVertexWithUV(offset, d18, d19, d28, d29);
wr.addVertexWithUV(offset, d20, d21, d27, d29);
wr.addVertexWithUV(d26, d20, d21, d27, d30);
wr.addVertexWithUV(d26, d24, d25, d28, d30);
wr.addVertexWithUV(offset, d24, d25, d28, d29);
wr.addVertexWithUV(offset, d22, d23, d27, d29);
wr.addVertexWithUV(d26, d22, d23, d27, d30);
wr.addVertexWithUV(d26, d20, d21, d28, d30);
wr.addVertexWithUV(offset, d20, d21, d28, d29);
wr.addVertexWithUV(offset, d24, d25, d27, d29);
wr.addVertexWithUV(d26, d24, d25, d27, d30);
wr.addVertexWithUV(d26, d22, d23, d28, d30);
wr.addVertexWithUV(offset, d22, d23, d28, d29);
wr.addVertexWithUV(offset, d18, d19, d27, d29);
wr.addVertexWithUV(d26, d18, d19, d27, d30);
tessellator.draw();
GL11.glDepthMask(true);

View file

@ -39,7 +39,7 @@ public class RenderAlchemicCalcinator extends TileEntitySpecialRenderer
}
@Override
public void renderTileEntityAt(TileEntity tileEntity, double d0, double d1, double d2, float f)
public void renderTileEntityAt(TileEntity tileEntity, double d0, double d1, double d2, float f, int i)
{
if (tileEntity instanceof TEAlchemicCalcinator)
{

View file

@ -0,0 +1,196 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
* File Created @ [Apr 9, 2014, 11:20:26 PM (GMT)]
*/
package WayofTime.alchemicalWizardry.common.renderer.block;
import org.lwjgl.opengl.ARBFragmentShader;
import org.lwjgl.opengl.ARBShaderObjects;
import org.lwjgl.opengl.ARBVertexShader;
import org.lwjgl.opengl.GL11;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
public final class ShaderHelper
{
private static final int VERT = ARBVertexShader.GL_VERTEX_SHADER_ARB;
private static final int FRAG = ARBFragmentShader.GL_FRAGMENT_SHADER_ARB;
public static int beam = 0;
public static void initShaders()
{
beam = createProgram(null, "/assets/alchemicalwizardry/shaders/beam.frag");
}
public static void useShaderWithProps(int shader, Object... props)
{
ARBShaderObjects.glUseProgramObjectARB(shader);
if (shader != 0 && props.length % 2 == 0)
{
int propCount = props.length / 2;
for (int i = 0; i < propCount; i++)
{
String propName = (String) props[i * 2];
Object propVal = props[i * 2 + 1];
int uniform = ARBShaderObjects.glGetUniformLocationARB(shader, propName);
if (propVal instanceof Integer)
ARBShaderObjects.glUniform1iARB(uniform, (Integer) propVal);
if (propVal instanceof Float)
ARBShaderObjects.glUniform1fARB(uniform, (Float) propVal);
}
}
}
public static void useShader(int shader)
{
useShaderWithProps(shader);
}
public static void releaseShader()
{
useShader(0);
}
public static boolean useShaders()
{
return true;
}
// Most of the code taken from the LWJGL wiki
// http://lwjgl.org/wiki/index.php?title=GLSL_Shaders_with_LWJGL
private static int createProgram(String vert, String frag)
{
int vertId = 0, fragId = 0, program = 0;
if (vert != null)
vertId = createShader(vert, VERT);
if (frag != null)
fragId = createShader(frag, FRAG);
program = ARBShaderObjects.glCreateProgramObjectARB();
if (program == 0)
return 0;
if (vert != null)
ARBShaderObjects.glAttachObjectARB(program, vertId);
if (frag != null)
ARBShaderObjects.glAttachObjectARB(program, fragId);
ARBShaderObjects.glLinkProgramARB(program);
if (ARBShaderObjects.glGetObjectParameteriARB(program, ARBShaderObjects.GL_OBJECT_LINK_STATUS_ARB) == GL11.GL_FALSE)
{
return 0;
}
ARBShaderObjects.glValidateProgramARB(program);
if (ARBShaderObjects.glGetObjectParameteriARB(program, ARBShaderObjects.GL_OBJECT_VALIDATE_STATUS_ARB) == GL11.GL_FALSE)
{
return 0;
}
return program;
}
private static int createShader(String filename, int shaderType)
{
int shader = 0;
try
{
shader = ARBShaderObjects.glCreateShaderObjectARB(shaderType);
if (shader == 0)
return 0;
ARBShaderObjects.glShaderSourceARB(shader, readFileAsString(filename));
ARBShaderObjects.glCompileShaderARB(shader);
if (ARBShaderObjects.glGetObjectParameteriARB(shader, ARBShaderObjects.GL_OBJECT_COMPILE_STATUS_ARB) == GL11.GL_FALSE)
throw new RuntimeException("Error creating shader: " + getLogInfo(shader));
return shader;
} catch (Exception e)
{
ARBShaderObjects.glDeleteObjectARB(shader);
e.printStackTrace();
return -1;
}
}
private static String getLogInfo(int obj)
{
return ARBShaderObjects.glGetInfoLogARB(obj, ARBShaderObjects.glGetObjectParameteriARB(obj, ARBShaderObjects.GL_OBJECT_INFO_LOG_LENGTH_ARB));
}
private static String readFileAsString(String filename) throws Exception
{
StringBuilder source = new StringBuilder();
InputStream in = ShaderHelper.class.getResourceAsStream(filename);
Exception exception = null;
BufferedReader reader;
if (in == null)
return "";
try
{
reader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
Exception innerExc = null;
try
{
String line;
while ((line = reader.readLine()) != null)
source.append(line).append('\n');
} catch (Exception exc)
{
exception = exc;
} finally
{
try
{
reader.close();
} catch (Exception exc)
{
if (innerExc == null)
innerExc = exc;
else exc.printStackTrace();
}
}
if (innerExc != null)
throw innerExc;
} catch (Exception exc)
{
exception = exc;
} finally
{
try
{
in.close();
} catch (Exception exc)
{
if (exception == null)
exception = exc;
else exc.printStackTrace();
}
if (exception != null)
throw exception;
}
return source.toString();
}
}

View file

@ -2,8 +2,9 @@ package WayofTime.alchemicalWizardry.common.renderer.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.AdvancedModelLoader;
import net.minecraftforge.client.model.IModelCustom;
@ -57,21 +58,22 @@ public class ModelBloodAltar extends ModelBase
GL11.glPopMatrix();
}
public void renderBloodLevel(IIcon icon)
public void renderBloodLevel(TextureAtlasSprite icon)
{
Tessellator tessellator = Tessellator.instance;
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer wr = tessellator.getWorldRenderer();
double minU = (double) icon.getInterpolatedU(0);
double maxU = (double) icon.getInterpolatedU(16);
double minV = (double) icon.getInterpolatedV(0);
double maxV = (double) icon.getInterpolatedV(16);
tessellator.startDrawingQuads();
tessellator.setNormal(0, 1, 0);
tessellator.addVertexWithUV(1, 0, 1, maxU, maxV);
tessellator.addVertexWithUV(1, 0, 0, maxU, minV);
tessellator.addVertexWithUV(0, 0, 0, minU, minV);
tessellator.addVertexWithUV(0, 0, 1, minU, maxV);
wr.startDrawingQuads();
wr.func_178980_d(0, 1, 0); //setNormal
wr.addVertexWithUV(1, 0, 1, maxU, maxV);
wr.addVertexWithUV(1, 0, 0, maxU, minV);
wr.addVertexWithUV(0, 0, 0, minU, minV);
wr.addVertexWithUV(0, 0, 1, minU, maxV);
tessellator.draw();
}
}

View file

@ -3,6 +3,7 @@ package WayofTime.alchemicalWizardry.common.renderer.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.monster.EntityBlaze;
import net.minecraft.world.World;
public class ModelElemental extends ModelBase
@ -70,10 +71,11 @@ public class ModelElemental extends ModelBase
return;
}
float ratio = 0.1f;
float rot = (entity.worldObj.getWorldTime() + f) * ratio;
Shape1.rotateAngleX = rot;
Shape2.rotateAngleZ = rot;
Shape3.rotateAngleY = rot;
int ratio = 20;
float rot = (entity.worldObj.getWorldTime() % ratio) / ratio;
Shape1.rotateAngleX = f / 5;
Shape2.rotateAngleZ = f / 5;
Shape3.rotateAngleY = f / 5;
EntityBlaze d;
}
}

View file

@ -1,25 +1,25 @@
package WayofTime.alchemicalWizardry.common.rituals;
import java.util.HashSet;
import java.util.Set;
import WayofTime.alchemicalWizardry.api.Int3;
import WayofTime.alchemicalWizardry.api.rituals.LocalRitualStorage;
import WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon.IHoardDemon;
public class LocalStorageAlphaPact extends LocalRitualStorage
{
public static Set<IHoardDemon> hoardList = new HashSet();
public void thrallDemon(IHoardDemon demon)
{
if(demon instanceof IHoardDemon)
{
boolean enthrall = ((IHoardDemon) demon).thrallDemon(new Int3(this.xCoord, this.yCoord, this.zCoord));
if(enthrall)
{
this.hoardList.add((IHoardDemon)demon);
}
}
}
}
//package WayofTime.alchemicalWizardry.common.rituals;
//
//import java.util.HashSet;
//import java.util.Set;
//
//import WayofTime.alchemicalWizardry.api.Int3;
//import WayofTime.alchemicalWizardry.api.rituals.LocalRitualStorage;
//import WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon.IHoardDemon;
//
//public class LocalStorageAlphaPact extends LocalRitualStorage
//{
// public static Set<IHoardDemon> hoardList = new HashSet();
//
// public void thrallDemon(IHoardDemon demon)
// {
// if(demon instanceof IHoardDemon)
// {
// boolean enthrall = ((IHoardDemon) demon).thrallDemon(new Int3(this.xCoord, this.yCoord, this.zCoord));
// if(enthrall)
// {
// this.hoardList.add((IHoardDemon)demon);
// }
// }
// }
//}

View file

@ -1,179 +1,178 @@
package WayofTime.alchemicalWizardry.common.rituals;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone;
import WayofTime.alchemicalWizardry.api.rituals.LocalRitualStorage;
import WayofTime.alchemicalWizardry.api.rituals.RitualComponent;
import WayofTime.alchemicalWizardry.api.rituals.RitualEffect;
import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
import WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon.EntityMinorDemonGrunt;
import WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon.IHoardDemon;
public class RitualEffectAlphaPact extends RitualEffect
{
Random rand = new Random();
@Override
public void performEffect(IMasterRitualStone ritualStone)
{
String owner = ritualStone.getOwner();
int currentEssence = SoulNetworkHandler.getCurrentEssence(owner);
World world = ritualStone.getWorld();
int x = ritualStone.getXCoord();
int y = ritualStone.getYCoord();
int z = ritualStone.getZCoord();
if (world.getWorldTime() % 20 != 0)
{
return;
}
LocalRitualStorage stor = ritualStone.getLocalStorage();
if(stor instanceof LocalStorageAlphaPact)
{
LocalStorageAlphaPact storage = (LocalStorageAlphaPact)stor;
Object[] demonList = storage.hoardList.toArray();
for(Object demon : demonList)
{
if(demon instanceof EntityLivingBase)
{
if(!((EntityLivingBase) demon).isEntityAlive())
{
System.out.println(storage.hoardList.remove(demon));
}
}
}
System.out.println("Hi!");
int summons = 0;
int horizontalRange = 25;
int verticalRange = 20;
if(storage.hoardList.isEmpty())
{
IHoardDemon demon = this.getRandomDemonForStage(world, x, y, z, horizontalRange, verticalRange);
if(demon instanceof EntityLivingBase)
{
world.spawnEntityInWorld((EntityLivingBase)demon);
storage.thrallDemon(demon);
}
}else
{
}
}
}
public IHoardDemon getRandomDemonForStage(World world, int x, int y, int z, int horizontalRange, int verticalRange)
{
EntityLivingBase entityLiving = new EntityMinorDemonGrunt(world);
boolean isGood = false;
for(int n=0; n<100; n++)
{
double newX = x + (rand.nextInt(horizontalRange) - horizontalRange) + 0.5;
double newY = y + (double) (rand.nextInt((int) verticalRange));
double newZ = z + (rand.nextInt(horizontalRange) - horizontalRange) + 0.5;
entityLiving.posX = newX;
entityLiving.posY = newY;
entityLiving.posZ = newZ;
int i = MathHelper.floor_double(entityLiving.posX);
int j = MathHelper.floor_double(entityLiving.posY);
int k = MathHelper.floor_double(entityLiving.posZ);
Block l;
if (entityLiving.worldObj.blockExists(i, j, k))
{
boolean flag1 = false;
while (!flag1 && j > 0)
{
l = entityLiving.worldObj.getBlock(i, j - 1, k);
if (l != null && l.getMaterial().blocksMovement())
{
flag1 = true;
} else
{
--entityLiving.posY;
--j;
}
}
}
if(entityLiving.worldObj.getCollidingBoundingBoxes(entityLiving, entityLiving.boundingBox).isEmpty() && !entityLiving.worldObj.isAnyLiquid(entityLiving.boundingBox))
{
entityLiving.setPositionAndUpdate(newX, newY, newZ);
isGood = true;
}
}
if(isGood = false)
{
return null;
}
return (IHoardDemon)entityLiving;
}
public int spawnMoreDemons(LocalStorageAlphaPact storage)
{
return 5;
}
@Override
public int getCostPerRefresh()
{
return 1;
}
public LocalRitualStorage getNewLocalStorage()
{
return new LocalStorageAlphaPact();
}
@Override
public List<RitualComponent> getRitualComponentList()
{
ArrayList<RitualComponent> omegaRitual = new ArrayList();
this.addCornerRunes(omegaRitual, 1, 0, RitualComponent.BLANK);
this.addOffsetRunes(omegaRitual, 2, 1, 0, RitualComponent.FIRE);
this.addParallelRunes(omegaRitual, 4, 0, RitualComponent.WATER);
this.addParallelRunes(omegaRitual, 5, 0, RitualComponent.EARTH);
this.addCornerRunes(omegaRitual, 4, 0, RitualComponent.AIR);
this.addOffsetRunes(omegaRitual, 3, 4, 0, RitualComponent.AIR);
this.addParallelRunes(omegaRitual, 5, 1, RitualComponent.WATER);
this.addParallelRunes(omegaRitual, 5, 2, RitualComponent.EARTH);
this.addParallelRunes(omegaRitual, 4, 3, RitualComponent.WATER);
this.addParallelRunes(omegaRitual, 4, 4, RitualComponent.WATER);
this.addParallelRunes(omegaRitual, 3, 5, RitualComponent.BLANK);
this.addParallelRunes(omegaRitual, 2, 5, RitualComponent.FIRE);
this.addParallelRunes(omegaRitual, 1, 5, RitualComponent.DUSK);
this.addOffsetRunes(omegaRitual, 5, 3, 1, RitualComponent.WATER);
this.addOffsetRunes(omegaRitual, 6, 3, 1, RitualComponent.DUSK);
this.addOffsetRunes(omegaRitual, 6, 4, 1, RitualComponent.FIRE);
this.addOffsetRunes(omegaRitual, 6, 5, 1, RitualComponent.BLANK);
this.addCornerRunes(omegaRitual, 4, 2, RitualComponent.FIRE);
this.addCornerRunes(omegaRitual, 4, 3, RitualComponent.AIR);
this.addCornerRunes(omegaRitual, 4, 4, RitualComponent.AIR);
this.addOffsetRunes(omegaRitual, 4, 3, 2, RitualComponent.BLANK);
this.addCornerRunes(omegaRitual, 3, 5, RitualComponent.EARTH);
this.addOffsetRunes(omegaRitual, 2, 3, 5, RitualComponent.AIR);
return omegaRitual;
}
}
//package WayofTime.alchemicalWizardry.common.rituals;
//
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Random;
//
//import net.minecraft.block.Block;
//import net.minecraft.entity.EntityLivingBase;
//import net.minecraft.util.BlockPos;
//import net.minecraft.util.MathHelper;
//import net.minecraft.world.World;
//import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone;
//import WayofTime.alchemicalWizardry.api.rituals.LocalRitualStorage;
//import WayofTime.alchemicalWizardry.api.rituals.RitualComponent;
//import WayofTime.alchemicalWizardry.api.rituals.RitualEffect;
//import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
//import WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon.EntityMinorDemonGrunt;
//import WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon.IHoardDemon;
//
//public class RitualEffectAlphaPact extends RitualEffect
//{
// Random rand = new Random();
//
// @Override
// public void performEffect(IMasterRitualStone ritualStone)
// {
// String owner = ritualStone.getOwner();
//
// int currentEssence = SoulNetworkHandler.getCurrentEssence(owner);
// World world = ritualStone.getWorldObj();
// BlockPos pos = ritualStone.getPosition();
//
// if (world.getWorldTime() % 20 != 0)
// {
// return;
// }
//
// LocalRitualStorage stor = ritualStone.getLocalStorage();
// if(stor instanceof LocalStorageAlphaPact)
// {
// LocalStorageAlphaPact storage = (LocalStorageAlphaPact)stor;
//
// Object[] demonList = storage.hoardList.toArray();
//
// for(Object demon : demonList)
// {
// if(demon instanceof EntityLivingBase)
// {
// if(!((EntityLivingBase) demon).isEntityAlive())
// {
// System.out.println(storage.hoardList.remove(demon));
// }
// }
// }
//
// System.out.println("Hi!");
//
// int summons = 0;
//
// int horizontalRange = 25;
// int verticalRange = 20;
//
// if(storage.hoardList.isEmpty())
// {
// IHoardDemon demon = this.getRandomDemonForStage(world, x, y, z, horizontalRange, verticalRange);
// if(demon instanceof EntityLivingBase)
// {
// world.spawnEntityInWorld((EntityLivingBase)demon);
// storage.thrallDemon(demon);
// }
// }else
// {
// }
// }
// }
//
// public IHoardDemon getRandomDemonForStage(World world, int x, int y, int z, int horizontalRange, int verticalRange)
// {
// EntityLivingBase entityLiving = new EntityMinorDemonGrunt(world);
//
// boolean isGood = false;
// for(int n=0; n<100; n++)
// {
// double newX = x + (rand.nextInt(horizontalRange) - horizontalRange) + 0.5;
// double newY = y + (double) (rand.nextInt((int) verticalRange));
// double newZ = z + (rand.nextInt(horizontalRange) - horizontalRange) + 0.5;
//
// entityLiving.posX = newX;
// entityLiving.posY = newY;
// entityLiving.posZ = newZ;
//
// int i = MathHelper.floor_double(entityLiving.posX);
// int j = MathHelper.floor_double(entityLiving.posY);
// int k = MathHelper.floor_double(entityLiving.posZ);
// Block l;
//
// if (entityLiving.worldObj.blockExists(i, j, k))
// {
// boolean flag1 = false;
//
// while (!flag1 && j > 0)
// {
// l = entityLiving.worldObj.getBlock(i, j - 1, k);
//
// if (l != null && l.getMaterial().blocksMovement())
// {
// flag1 = true;
// } else
// {
// --entityLiving.posY;
// --j;
// }
// }
// }
//
// if(entityLiving.worldObj.getCollidingBoundingBoxes(entityLiving, entityLiving.boundingBox).isEmpty() && !entityLiving.worldObj.isAnyLiquid(entityLiving.boundingBox))
// {
// entityLiving.setPositionAndUpdate(newX, newY, newZ);
// isGood = true;
// }
// }
//
// if(isGood = false)
// {
// return null;
// }
//
// return (IHoardDemon)entityLiving;
// }
//
// public int spawnMoreDemons(LocalStorageAlphaPact storage)
// {
// return 5;
// }
//
// @Override
// public int getCostPerRefresh()
// {
// return 1;
// }
//
// public LocalRitualStorage getNewLocalStorage()
// {
// return new LocalStorageAlphaPact();
// }
//
// @Override
// public List<RitualComponent> getRitualComponentList()
// {
// ArrayList<RitualComponent> omegaRitual = new ArrayList();
//
// this.addCornerRunes(omegaRitual, 1, 0, RitualComponent.BLANK);
// this.addOffsetRunes(omegaRitual, 2, 1, 0, RitualComponent.FIRE);
// this.addParallelRunes(omegaRitual, 4, 0, RitualComponent.WATER);
// this.addParallelRunes(omegaRitual, 5, 0, RitualComponent.EARTH);
// this.addCornerRunes(omegaRitual, 4, 0, RitualComponent.AIR);
// this.addOffsetRunes(omegaRitual, 3, 4, 0, RitualComponent.AIR);
// this.addParallelRunes(omegaRitual, 5, 1, RitualComponent.WATER);
// this.addParallelRunes(omegaRitual, 5, 2, RitualComponent.EARTH);
// this.addParallelRunes(omegaRitual, 4, 3, RitualComponent.WATER);
// this.addParallelRunes(omegaRitual, 4, 4, RitualComponent.WATER);
// this.addParallelRunes(omegaRitual, 3, 5, RitualComponent.BLANK);
// this.addParallelRunes(omegaRitual, 2, 5, RitualComponent.FIRE);
// this.addParallelRunes(omegaRitual, 1, 5, RitualComponent.DUSK);
// this.addOffsetRunes(omegaRitual, 5, 3, 1, RitualComponent.WATER);
// this.addOffsetRunes(omegaRitual, 6, 3, 1, RitualComponent.DUSK);
// this.addOffsetRunes(omegaRitual, 6, 4, 1, RitualComponent.FIRE);
// this.addOffsetRunes(omegaRitual, 6, 5, 1, RitualComponent.BLANK);
// this.addCornerRunes(omegaRitual, 4, 2, RitualComponent.FIRE);
// this.addCornerRunes(omegaRitual, 4, 3, RitualComponent.AIR);
// this.addCornerRunes(omegaRitual, 4, 4, RitualComponent.AIR);
// this.addOffsetRunes(omegaRitual, 4, 3, 2, RitualComponent.BLANK);
// this.addCornerRunes(omegaRitual, 3, 5, RitualComponent.EARTH);
// this.addOffsetRunes(omegaRitual, 2, 3, 5, RitualComponent.AIR);
//
// return omegaRitual;
// }
//}

View file

@ -11,6 +11,7 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import java.util.ArrayList;
@ -28,10 +29,8 @@ public class RitualEffectAnimalGrowth extends RitualEffect
String owner = ritualStone.getOwner();
int currentEssence = SoulNetworkHandler.getCurrentEssence(owner);
World world = ritualStone.getWorld();
int x = ritualStone.getXCoord();
int y = ritualStone.getYCoord();
int z = ritualStone.getZCoord();
World world = ritualStone.getWorldObj();
BlockPos pos = ritualStone.getPosition();
if (world.getWorldTime() % 20 != 0)
{
@ -40,7 +39,7 @@ public class RitualEffectAnimalGrowth extends RitualEffect
double range = 2;
AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox((double) x, (double) y + 1, (double) z, (double) (x + 1), (double) (y + 3), (double) (z + 1)).expand(range, 0, range);
AxisAlignedBB axisalignedbb = new AxisAlignedBB((double) x, (double) y + 1, (double) z, (double) (x + 1), (double) (y + 3), (double) (z + 1)).expand(range, 0, range);
List<EntityAgeable> list = world.getEntitiesWithinAABB(EntityAgeable.class, axisalignedbb);
int entityCount = 0;

View file

@ -9,6 +9,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import java.util.ArrayList;
@ -30,10 +31,8 @@ public class RitualEffectApiaryOverclock extends RitualEffect
}
int currentEssence = data.currentEssence;
World world = ritualStone.getWorld();
int x = ritualStone.getXCoord();
int y = ritualStone.getYCoord();
int z = ritualStone.getZCoord();
World world = ritualStone.getWorldObj();
BlockPos pos = ritualStone.getPosition();
if (currentEssence < this.getCostPerRefresh())

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