Fixed staves and orbs particles
-Also fixed air stuff SMP crash
This commit is contained in:
parent
c38060919f
commit
06f1cbcce9
10 changed files with 66 additions and 97 deletions
|
|
@ -1,15 +1,13 @@
|
|||
package mysticworld.items;
|
||||
|
||||
import cpw.mods.fml.common.ObfuscationReflectionHelper;
|
||||
import mysticworld.MysticWorld;
|
||||
import mysticworld.entity.EntityChargeAir;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
public class ItemStaffAir extends ItemStaff {
|
||||
public ItemStaffAir() {
|
||||
super();
|
||||
|
|
@ -17,64 +15,45 @@ public class ItemStaffAir extends ItemStaff {
|
|||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
|
||||
if (itemStack.stackTagCompound == null)
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
if (!itemStack.stackTagCompound.getBoolean("charging")) {
|
||||
itemStack.stackTagCompound.setBoolean("charging", true);
|
||||
}
|
||||
player.setItemInUse(itemStack, this.getMaxItemUseDuration(itemStack));
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxItemUseDuration(ItemStack itemStack){
|
||||
return 3*20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerStoppedUsing(ItemStack itemStack, World world, EntityPlayer player, int time) {
|
||||
int charge = getMaxItemUseDuration(itemStack)-time;
|
||||
if (charge > 0) {
|
||||
if (!world.isRemote) {
|
||||
world.playAuxSFXAtEntity(null, 1009, (int) player.posX, (int) player.posY, (int) player.posZ, 0);
|
||||
world.spawnEntityInWorld(new EntityChargeAir(world, player, 1.0f + charge * (5.0f * (1 / (float) getMaxItemUseDuration(itemStack))), charge * (2.5D * (1.0D / getMaxItemUseDuration(itemStack)))));
|
||||
itemStack.damageItem(1, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack itemStack, World world, Entity entity, int par4, boolean par5) {
|
||||
if (itemStack.stackTagCompound == null)
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
EntityPlayer player = (EntityPlayer) entity;
|
||||
ItemStack currentItem = player.inventory.getCurrentItem();
|
||||
itemStack.stackTagCompound.setInteger("maxChargeTime", 3 * 20);
|
||||
if (currentItem != null) {
|
||||
if (currentItem.getItem() == itemStack.getItem()) {
|
||||
player.fallDistance = 0.0F;
|
||||
chargeEffect(itemStack, world, player);
|
||||
if (!Mouse.isButtonDown(1)) {
|
||||
if (itemStack.stackTagCompound.getInteger("chargeTime") > 0) {
|
||||
if (!world.isRemote) {
|
||||
world.playAuxSFXAtEntity(null, 1009, (int) player.posX, (int) player.posY, (int) player.posZ, 0);
|
||||
world.spawnEntityInWorld(new EntityChargeAir(world, player, 1.0f + ((itemStack.stackTagCompound.getInteger("chargeTime")) * (5.0f * (1 / (float) itemStack.stackTagCompound
|
||||
.getInteger("maxChargeTime")))), (itemStack.stackTagCompound.getInteger("chargeTime")) * (2.5D * (1.0D / itemStack.stackTagCompound.getInteger("maxChargeTime")))));
|
||||
itemStack.damageItem(1, player);
|
||||
}
|
||||
}
|
||||
resetData(itemStack);
|
||||
} else {
|
||||
if (itemStack.stackTagCompound.getBoolean("charging") == true) {
|
||||
incrementData(itemStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
resetData(itemStack);
|
||||
}
|
||||
if (itemStack.stackTagCompound.getInteger("chargeTime") > itemStack.stackTagCompound.getInteger("maxChargeTime")) {
|
||||
itemStack.stackTagCompound.setInteger("chargeTime", itemStack.stackTagCompound.getInteger("maxChargeTime"));
|
||||
public void onUpdate(ItemStack itemStack, World world, Entity entity, int par4, boolean current) {
|
||||
if (current) {
|
||||
entity.fallDistance = 0.0F;
|
||||
if(entity instanceof EntityPlayer){
|
||||
if(((EntityPlayer) entity).isUsingItem()){
|
||||
int charge = ObfuscationReflectionHelper.getPrivateValue(EntityPlayer.class,(EntityPlayer) entity, "itemInUseCount", "field_71072_f");
|
||||
chargeEffect(itemStack, world, entity, getMaxItemUseDuration(itemStack) - charge);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void chargeEffect(ItemStack itemStack, World world, EntityPlayer player) {
|
||||
private void chargeEffect(ItemStack itemStack, World world, Entity player, int charge) {
|
||||
double particleX = (player.posX - 0.5D) + rand.nextDouble();
|
||||
double particleY = player.posY + (player.height / itemStack.stackTagCompound.getInteger("maxChargeTime") * itemStack.stackTagCompound.getInteger("chargeTime"));
|
||||
double particleY = player.posY + (charge * player.height / getMaxItemUseDuration(itemStack));
|
||||
double particleZ = (player.posZ - 0.5D) + rand.nextDouble();
|
||||
float particleScale = ((itemStack.stackTagCompound.getInteger("chargeTime")) * (5.0f * (1 / (float) itemStack.stackTagCompound.getInteger("maxChargeTime"))));
|
||||
if (!world.isRemote)
|
||||
MysticWorld.proxy.airFeetFX(world, particleX, particleY, particleZ, 1.0f + particleScale, 15);
|
||||
}
|
||||
|
||||
private void incrementData(ItemStack itemStack) {
|
||||
itemStack.stackTagCompound.setInteger("chargeTime", itemStack.stackTagCompound.getInteger("chargeTime") + 1);
|
||||
}
|
||||
|
||||
private void resetData(ItemStack itemStack) {
|
||||
itemStack.stackTagCompound.setInteger("chargeTime", 0);
|
||||
itemStack.stackTagCompound.setBoolean("charging", false);
|
||||
float particleScale = charge * (5.0f * (1 / (float) getMaxItemUseDuration(itemStack)));
|
||||
MysticWorld.proxy.airFeetFX(world, particleX, particleY, particleZ, 1.0f + particleScale, 15);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue