Added client-side LP bar. Need a few more things before I can release, such as when it occurs etc.
This commit is contained in:
parent
dbf4232ca0
commit
b30d6de13c
|
@ -9,6 +9,7 @@ import net.minecraft.entity.item.EntityItem;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
|
@ -16,6 +17,23 @@ import net.minecraft.world.World;
|
|||
|
||||
public class APISpellHelper
|
||||
{
|
||||
public static int getPlayerLPTag(EntityPlayer player)
|
||||
{
|
||||
NBTTagCompound data = player.getEntityData();
|
||||
if(data.hasKey("BM:StoredLP"))
|
||||
{
|
||||
return data.getInteger("BM:StoredLP");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void setPlayerLPTag(EntityPlayer player, int amount)
|
||||
{
|
||||
NBTTagCompound data = player.getEntityData();
|
||||
data.setInteger("BM:StoredLP", amount);
|
||||
}
|
||||
|
||||
public static MovingObjectPosition raytraceFromEntity(World world, Entity player, boolean par3, double range)
|
||||
{
|
||||
float f = 1.0F;
|
||||
|
@ -36,7 +54,7 @@ public class APISpellHelper
|
|||
double d3 = range;
|
||||
if (player instanceof EntityPlayerMP)
|
||||
{
|
||||
d3 = ((EntityPlayerMP) player).theItemInWorldManager.getBlockReachDistance();
|
||||
// d3 = ((EntityPlayerMP) player).theItemInWorldManager.getBlockReachDistance();
|
||||
}
|
||||
Vec3 vec31 = vec3.addVector((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
|
||||
return world.func_147447_a(vec3, vec31, par3, !par3, par3);
|
||||
|
|
|
@ -23,6 +23,7 @@ import WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent;
|
|||
import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentContainerInfo;
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentRegistry;
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentStack;
|
||||
import WayofTime.alchemicalWizardry.api.spell.APISpellHelper;
|
||||
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
|
||||
|
||||
public class RenderHelper
|
||||
|
@ -56,6 +57,7 @@ public class RenderHelper
|
|||
&& !mc.gameSettings.showDebugInfo)
|
||||
{
|
||||
EntityPlayer player = mc.thePlayer;
|
||||
player.getEntityData();
|
||||
World world = mc.theWorld;
|
||||
if (SpellHelper.canPlayerSeeAlchemy(player))
|
||||
{
|
||||
|
@ -72,10 +74,41 @@ public class RenderHelper
|
|||
{
|
||||
renderTestHUD(mc, reagentStack, maxAmount);
|
||||
}
|
||||
|
||||
renderLPHUD(mc, APISpellHelper.getPlayerLPTag(player), 10000000);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void renderLPHUD(Minecraft mc, int lpAmount, int maxAmount)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
int xSize = 32;
|
||||
int ySize = 32;
|
||||
|
||||
int amount = (int) (256 * ((double)(maxAmount - lpAmount) / maxAmount));
|
||||
|
||||
int x = (16 + 32 - xSize) / 2 * 8;
|
||||
int y = (150 - ySize) / 2 * 8;
|
||||
|
||||
ResourceLocation test2 = new ResourceLocation("alchemicalwizardry", "textures/gui/container1.png");
|
||||
GL11.glColor4f(1, 0, 0, 1.0F);
|
||||
mc.getTextureManager().bindTexture(test2);
|
||||
|
||||
GL11.glScalef(1f/8f, 1f/8f, 1f/8f);
|
||||
|
||||
drawTexturedModalRect(x, y + amount, 0, amount, 256, 256 - amount);
|
||||
|
||||
ResourceLocation test = new ResourceLocation("alchemicalwizardry", "textures/gui/lpVial.png");
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
mc.getTextureManager().bindTexture(test);
|
||||
|
||||
|
||||
drawTexturedModalRect(x, y, 0, 0, 256, 256);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
private static List<HUDElement> getHUDElements(Minecraft mc)
|
||||
{
|
||||
|
@ -173,6 +206,7 @@ public class RenderHelper
|
|||
|
||||
private static void renderTestHUD(Minecraft mc, ReagentStack reagentStack, int maxAmount)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
Reagent reagent = reagentStack.reagent;
|
||||
int xSize = 32;
|
||||
int ySize = 32;
|
||||
|
@ -197,7 +231,7 @@ public class RenderHelper
|
|||
|
||||
drawTexturedModalRect(x, y, 0, 0, 256, 256);
|
||||
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public static void renderIcon(int p_94149_1_, int p_94149_2_, IIcon p_94149_3_, int p_94149_4_, int p_94149_5_)
|
||||
|
|
|
@ -15,6 +15,7 @@ import net.minecraft.entity.ai.attributes.AttributeModifier;
|
|||
import net.minecraft.entity.monster.EntityCreeper;
|
||||
import net.minecraft.entity.monster.EntityMob;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.PlayerCapabilities;
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
|
@ -33,6 +34,7 @@ import net.minecraftforge.event.entity.living.LivingSpawnEvent.CheckSpawn;
|
|||
import vazkii.botania.api.internal.IManaBurst;
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.BloodMagicConfiguration;
|
||||
import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
|
||||
import WayofTime.alchemicalWizardry.common.entity.projectile.EnergyBlastProjectile;
|
||||
import WayofTime.alchemicalWizardry.common.items.BoundArmour;
|
||||
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
|
||||
|
@ -267,6 +269,17 @@ public class AlchemicalWizardryEventHooks
|
|||
|
||||
if (entityLiving instanceof EntityPlayer)
|
||||
{
|
||||
if(!entityLiving.worldObj.isRemote)
|
||||
{
|
||||
// APISpellHelper.setPlayerLPTag((EntityPlayer)entityLiving, SoulNetworkHandler.getCurrentEssence(SoulNetworkHandler.getUsername((EntityPlayer)entityLiving)));
|
||||
// ((EntityPlayer) entityLiving).sendPlayerAbilities();
|
||||
|
||||
if(entityLiving instanceof EntityPlayerMP)
|
||||
{
|
||||
// System.out.println("Sending Packet");
|
||||
NewPacketHandler.INSTANCE.sendTo(NewPacketHandler.getLPPacket(SoulNetworkHandler.getCurrentEssence(SoulNetworkHandler.getUsername((EntityPlayer)entityLiving)), 1000), (EntityPlayerMP)entityLiving);
|
||||
}
|
||||
}
|
||||
ObfuscationReflectionHelper.setPrivateValue(PlayerCapabilities.class, ((EntityPlayer) event.entityLiving).capabilities, Float.valueOf(0.1f), new String[]{"walkSpeed", "g", "field_75097_g"});
|
||||
}
|
||||
|
||||
|
@ -304,6 +317,8 @@ public class AlchemicalWizardryEventHooks
|
|||
}
|
||||
}
|
||||
|
||||
// event.entityLiving.getEntityAttribute(SharedMonsterAttributes.movementSpeed).removeAllModifiers();
|
||||
|
||||
if (event.entityLiving.isPotionActive(AlchemicalWizardry.customPotionBoost))
|
||||
{
|
||||
int i = event.entityLiving.getActivePotionEffect(AlchemicalWizardry.customPotionBoost).getAmplifier();
|
||||
|
@ -311,7 +326,11 @@ public class AlchemicalWizardryEventHooks
|
|||
//if(!entity.isSneaking())
|
||||
{
|
||||
float percentIncrease = (i + 1) * 0.05f;
|
||||
|
||||
|
||||
// AttributeModifier speedModifier = new AttributeModifier(new UUID(213241, 3), "Potion Boost", percentIncrease, 0);
|
||||
//
|
||||
// event.entityLiving.getEntityAttribute(SharedMonsterAttributes.movementSpeed).applyModifier(speedModifier);
|
||||
|
||||
if (event.entityLiving instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer entityPlayer = (EntityPlayer) event.entityLiving;
|
||||
|
|
|
@ -2,6 +2,7 @@ package WayofTime.alchemicalWizardry.common;
|
|||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.api.ColourAndCoords;
|
||||
import WayofTime.alchemicalWizardry.api.spell.APISpellHelper;
|
||||
import WayofTime.alchemicalWizardry.common.tileEntity.*;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.network.FMLEmbeddedChannel;
|
||||
|
@ -71,6 +72,7 @@ public enum NewPacketHandler
|
|||
clientChannel.pipeline().addAfter(tileAltarCodec, "VelocityHandler", new VelocityMessageHandler());
|
||||
clientChannel.pipeline().addAfter(tileAltarCodec, "TEMasterStoneHandler", new TEMasterStoneMessageHandler());
|
||||
clientChannel.pipeline().addAfter(tileAltarCodec, "TEReagentConduitHandler", new TEReagentConduitMessageHandler());
|
||||
clientChannel.pipeline().addAfter(tileAltarCodec, "CurrentLPMessageHandler", new CurrentLPMessageHandler());
|
||||
}
|
||||
|
||||
|
||||
|
@ -253,6 +255,18 @@ public enum NewPacketHandler
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class CurrentLPMessageHandler extends SimpleChannelInboundHandler<CurrentLPMessage>
|
||||
{
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext ctx, CurrentLPMessage msg) throws Exception
|
||||
{
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
|
||||
System.out.println("" + msg.currentLP + ", " + msg.maxLP);
|
||||
APISpellHelper.setPlayerLPTag(player, msg.currentLP);
|
||||
}
|
||||
}
|
||||
|
||||
public static class BMMessage
|
||||
{
|
||||
|
@ -363,6 +377,12 @@ public enum NewPacketHandler
|
|||
|
||||
List<ColourAndCoords> destinationList;
|
||||
}
|
||||
|
||||
public static class CurrentLPMessage extends BMMessage
|
||||
{
|
||||
int currentLP;
|
||||
int maxLP;
|
||||
}
|
||||
|
||||
private class TEAltarCodec extends FMLIndexedMessageToMessageCodec<BMMessage>
|
||||
{
|
||||
|
@ -379,6 +399,7 @@ public enum NewPacketHandler
|
|||
addDiscriminator(8, VelocityMessage.class);
|
||||
addDiscriminator(9, TEMasterStoneMessage.class);
|
||||
addDiscriminator(10, TEReagentConduitMessage.class);
|
||||
addDiscriminator(11, CurrentLPMessage.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -580,6 +601,12 @@ public enum NewPacketHandler
|
|||
}
|
||||
|
||||
break;
|
||||
|
||||
case 11:
|
||||
target.writeInt(((CurrentLPMessage) msg).currentLP);
|
||||
target.writeInt(((CurrentLPMessage) msg).maxLP);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -787,6 +814,12 @@ public enum NewPacketHandler
|
|||
((TEReagentConduitMessage) msg).destinationList = list;
|
||||
|
||||
break;
|
||||
|
||||
case 11:
|
||||
((CurrentLPMessage) msg).currentLP = dat.readInt();
|
||||
((CurrentLPMessage) msg).maxLP = dat.readInt();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -931,6 +964,16 @@ public enum NewPacketHandler
|
|||
|
||||
return INSTANCE.channels.get(Side.SERVER).generatePacketFrom(msg);
|
||||
}
|
||||
|
||||
public static Packet getLPPacket(int curLP, int maxLP)
|
||||
{
|
||||
CurrentLPMessage msg = new CurrentLPMessage();
|
||||
msg.index = 11;
|
||||
msg.currentLP = curLP;
|
||||
msg.maxLP = maxLP;
|
||||
|
||||
return INSTANCE.channels.get(Side.SERVER).generatePacketFrom(msg);
|
||||
}
|
||||
|
||||
public void sendTo(Packet message, EntityPlayerMP player)
|
||||
{
|
||||
|
|
|
@ -21,6 +21,7 @@ import net.minecraftforge.event.entity.living.EnderTeleportEvent;
|
|||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade;
|
||||
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
|
||||
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
|
||||
import WayofTime.alchemicalWizardry.common.spell.simple.SpellTeleport;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
@ -87,7 +88,7 @@ public class ItemSigilOfTheAssassin extends EnergyItems implements ArmourUpgrade
|
|||
|
||||
float f = 10.0F;
|
||||
|
||||
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, false, f);
|
||||
MovingObjectPosition movingobjectposition = SpellHelper.raytraceFromEntity(par2World, par3EntityPlayer, false, f);
|
||||
|
||||
if (movingobjectposition == null)
|
||||
{
|
||||
|
@ -95,7 +96,7 @@ public class ItemSigilOfTheAssassin extends EnergyItems implements ArmourUpgrade
|
|||
return par1ItemStack;
|
||||
} else
|
||||
{
|
||||
AlchemicalWizardry.logger.info("Got something!");
|
||||
AlchemicalWizardry.logger.info("Got something! Type of hit: " + movingobjectposition.typeOfHit);
|
||||
|
||||
if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY)
|
||||
{
|
||||
|
@ -206,11 +207,64 @@ public class ItemSigilOfTheAssassin extends EnergyItems implements ArmourUpgrade
|
|||
double d3 = 500.0D;
|
||||
if (p_77621_2_ instanceof EntityPlayerMP)
|
||||
{
|
||||
d3 = ((EntityPlayerMP)p_77621_2_).theItemInWorldManager.getBlockReachDistance();
|
||||
// d3 = ((EntityPlayerMP)p_77621_2_).theItemInWorldManager.getBlockReachDistance();
|
||||
}
|
||||
Vec3 vec31 = vec3.addVector((double)f7 * d3, (double)f6 * d3, (double)f8 * d3);
|
||||
return p_77621_1_.func_147447_a(vec3, vec31, p_77621_3_, !p_77621_3_, false);
|
||||
}
|
||||
|
||||
// public MovingObjectPosition movingObjectPositiongdsa(WOrld worldObj, int posX, int posY, int posZ)
|
||||
// {
|
||||
// Vec3 var17 = Vec3.createVectorHelper(posX, posY, posZ);
|
||||
// Vec3 var3 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
|
||||
// MovingObjectPosition var4 = worldObj.func_147447_a(var17, var3, true, false, false);
|
||||
// var17 = Vec3.createVectorHelper(posX, posY, posZ);
|
||||
// var3 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
|
||||
//
|
||||
// if (var4 != null)
|
||||
// {
|
||||
// var3 = Vec3.createVectorHelper(var4.hitVec.xCoord, var4.hitVec.yCoord, var4.hitVec.zCoord);
|
||||
// }
|
||||
//
|
||||
// Entity var5 = null;
|
||||
// List var6 = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D));
|
||||
// double var7 = 0.0D;
|
||||
// Iterator var9 = var6.iterator();
|
||||
// float var11;
|
||||
//
|
||||
// while (var9.hasNext())
|
||||
// {
|
||||
// Entity var10 = (Entity) var9.next();
|
||||
//
|
||||
// if (var10.canBeCollidedWith() && (var10 != shootingEntity || ticksInAir >= 5))
|
||||
// {
|
||||
// var11 = 0.3F;
|
||||
// AxisAlignedBB var12 = var10.boundingBox.expand(var11, var11, var11);
|
||||
// MovingObjectPosition var13 = var12.calculateIntercept(var17, var3);
|
||||
//
|
||||
// if (var13 != null)
|
||||
// {
|
||||
// double var14 = var17.distanceTo(var13.hitVec);
|
||||
//
|
||||
// if (var14 < var7 || var7 == 0.0D)
|
||||
// {
|
||||
// var5 = var10;
|
||||
// var7 = var14;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (var5 != null)
|
||||
// {
|
||||
// var4 = new MovingObjectPosition(var5);
|
||||
// }
|
||||
//
|
||||
// if (var4 != null)
|
||||
// {
|
||||
// this.onImpact(var4);
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void onArmourUpdate(World world, EntityPlayer player, ItemStack thisItemStack)
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 541 B |
Loading…
Reference in a new issue