Jump to content

Recommended Posts

Posted

I've been trying for a while now to figure out a way to make it so when the player starts using my item, they don't get slowed down. I've tried increasing the players speed when they're using it, but that makes the FOV go crazy, zooming in when I start using it and zooming out when I stop (which is unacceptable seeing as this item sometimes needs to be used rapidly.) I've tried changing the FOV depending on wheather it's starting or stopping using it, but to no avail.

I've also tried using

player.setEating(false);

Which did absolutely nothing.

 

Here's the code for my item ATM:

 

 

package project.main;

import java.util.List;
import java.util.Random;

import org.lwjgl.input.Keyboard;

import project.main.mp2.EntityAnnihilatorBolt;
import project.main.mp2.EntityChargedAnnihilatorBolt;
import project.main.mp2.EntityChargedDarkBolt;
import project.main.mp2.EntityChargedLightBolt;
import project.main.mp2.EntityDarkBolt;
import project.main.mp2.EntityLightBolt;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.EnumAction;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.Icon;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.ArrowLooseEvent;
import net.minecraftforge.event.entity.player.ArrowNockEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class ItemBeam extends Item {

public ItemBeam(int par1) {
	super(par1);
	this.maxStackSize = 1;
	this.setMaxDamage(99999);
}

public static int mode = 1;

public static int t = 0;

public static int missiles;
public static int maxmissiles;

public static boolean hasAnnihilatorBeam;
public static boolean hasDarkBeam;
public static boolean hasLightBeam;
public static boolean hasNovaBeam;
public int tickssinceconsumed;

public void onPlayerStoppedUsing(ItemStack par1ItemStack, World par2World,
		EntityPlayer par3EntityPlayer, int par4) {
//	par3EntityPlayer.capabilities.setPlayerWalkSpeed(.2F);
//	Minecraft.getMinecraft().gameSettings.fovSetting = -.38F;
	ExtendedPlayer props1 = ExtendedPlayer.get(par3EntityPlayer);
	missiles = props1.getMissiles();
	maxmissiles = props1.getMaxMissiles();
	String missilestring = String.valueOf(missiles);
	String maxmissilestring = String.valueOf(maxmissiles);

	EntityPowerBolt entitypowerbolt = new EntityPowerBolt(par2World,
			par3EntityPlayer);
	EntityChargedPowerBolt entitychargedpowerbolt = new EntityChargedPowerBolt(
			par2World, par3EntityPlayer);

	EntityIceBolt entityicebolt = new EntityIceBolt(par2World,
			par3EntityPlayer);
	EntityChargedIceBolt entitychargedicebolt = new EntityChargedIceBolt(
			par2World, par3EntityPlayer);

	EntityWaveBolt entitywavebolt = new EntityWaveBolt(par2World,
			par3EntityPlayer);
	EntityChargedWaveBolt entitychargedwavebolt = new EntityChargedWaveBolt(
			par2World, par3EntityPlayer);

	EntityPlasmaBolt entityplasmabolt = new EntityPlasmaBolt(par2World,
			par3EntityPlayer);
	EntityChargedPlasmaBolt entitychargedplasmabolt = new EntityChargedPlasmaBolt(
			par2World, par3EntityPlayer);

	EntityLightBolt entitylightbolt = new EntityLightBolt(par2World,
			par3EntityPlayer);
	EntityChargedLightBolt entitychargedlightbolt = new EntityChargedLightBolt(
			par2World, par3EntityPlayer);

	EntityDarkBolt entitydarkbolt = new EntityDarkBolt(par2World,
			par3EntityPlayer);
	EntityChargedDarkBolt entitychargeddarkbolt = new EntityChargedDarkBolt(
			par2World, par3EntityPlayer);

	EntityAnnihilatorBolt entityannihilatorbolt = new EntityAnnihilatorBolt(
			par2World, par3EntityPlayer);
	EntityChargedAnnihilatorBolt entitychargedannihilatorbolt = new EntityChargedAnnihilatorBolt(
			par2World, par3EntityPlayer);

	EntityUnchargedNovaBolt entityunchargednovabolt = new EntityUnchargedNovaBolt(
			par2World, par3EntityPlayer);

	EntityFlamethrower entityflamethrower = new EntityFlamethrower(
			par2World, par3EntityPlayer);
	EntityWaveBuster entitywavebuster = new EntityWaveBuster(par2World,
			par3EntityPlayer);
	EntityWaveBusterNoHoming entitywavebusternohoming = new EntityWaveBusterNoHoming(par2World,
			par3EntityPlayer);
	EntityIceSpreader entityicespreader = new EntityIceSpreader(par2World,
			par3EntityPlayer);

	// Insert fireing sound here

	if (!par2World.isRemote) {
		ExtendedPlayer props = ExtendedPlayer.get(par3EntityPlayer);

		hasAnnihilatorBeam = props.hasAnnihilatorBeam();
		hasLightBeam = props.hasLightBeam();
		hasDarkBeam = props.hasDarkBeam();
		hasNovaBeam = props.hasNovaBeam();

		if (t < 60) {
			if (mode == 1) {
				par2World.spawnEntityInWorld(entitypowerbolt);
			}
			if (mode == 2) {
				if (!props.hasDarkBeam()) {
					par2World.spawnEntityInWorld(entityicebolt);
				} else {
					par2World.spawnEntityInWorld(entitydarkbolt);
				}
			}
			if (mode == 3) {
				if (!props.hasAnnihilatorBeam()) {
					par2World.spawnEntityInWorld(entitywavebolt);
				} else {
					par2World.spawnEntityInWorld(entityannihilatorbolt);
				}
			}
			if (mode == 4) {
				if (!props.hasLightBeam() && !props.hasNovaBeam()) {
					par2World.spawnEntityInWorld(entityplasmabolt);
				}

				if (props.hasLightBeam() && !props.hasNovaBeam()) {
					par2World.spawnEntityInWorld(entitylightbolt);
				}
				if (props.hasNovaBeam()) {
					par2World.spawnEntityInWorld(entityunchargednovabolt);
				}
			}

			t = 0;

		} else if (t >= 60) {

			if (mode == 1) {
				par2World.spawnEntityInWorld(entitychargedpowerbolt);
			}
			if (mode == 2) {
				if (!props.hasDarkBeam()) {
					par2World.spawnEntityInWorld(entitychargedicebolt);
				} else {
					par2World.spawnEntityInWorld(entitychargeddarkbolt);
				}
			}
			if (mode == 3) {
				if (!props.hasAnnihilatorBeam()) {
					par2World.spawnEntityInWorld(entitychargedwavebolt);
				} else {
					par2World
							.spawnEntityInWorld(entitychargedannihilatorbolt);
				}
			}
			if (mode == 4) {
				if (!props.hasLightBeam()) {
					par2World.spawnEntityInWorld(entitychargedplasmabolt);
				}

				if (props.hasNovaBeam()) {
					par2World.spawnEntityInWorld(new EntityNovaBolt(
							par2World, par3EntityPlayer));
				}

				if (props.hasLightBeam() && !props.hasNovaBeam()) {
					par2World.spawnEntityInWorld(entitychargedlightbolt);
				}
			}

			t = 0;

		}
	}

}

public int getMaxItemUseDuration(ItemStack par1ItemStack) {
	return 72000;
}

public EnumAction getItemUseAction(ItemStack par1ItemStack) {
	return null;
}

boolean released = false;

public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World,
		EntityPlayer par3EntityPlayer) {
	EntityPhazonBeam entityphazonbeam = new EntityPhazonBeam(par2World,
			par3EntityPlayer);
	par3EntityPlayer.setEating(false);

	ExtendedPlayer props1 = ExtendedPlayer.get(par3EntityPlayer);
	missiles = props1.getMissiles();
	maxmissiles = props1.getMaxMissiles();
	String missilestring = String.valueOf(missiles);
	String maxmissilestring = String.valueOf(maxmissiles);
	if (par3EntityPlayer.isPotionActive(Main.hypermode)
			&& !par2World.isRemote) {
		par2World.spawnEntityInWorld(entityphazonbeam);
		return par1ItemStack;
	}
	par3EntityPlayer.setItemInUse(par1ItemStack,
			this.getMaxItemUseDuration(par1ItemStack));
	return par1ItemStack;

}

public void onUsingItemTick(ItemStack stack, EntityPlayer player, int count) {
	t = t + 1;
	ExtendedPlayer props = ExtendedPlayer.get(player);

	player.setEating(false);
	if (MissileLauncherKeyBind.keyPressed == false) {
		released = true;
	}
	if (!player.worldObj.isRemote) {

		if (t < 60 && MissileLauncherKeyBind.keyPressed && released == true
				&& !player.worldObj.isRemote) {
			if (props.consumeMissiles(1)) {
				player.worldObj.spawnEntityInWorld(new EntityMissile(
						player.worldObj, player));
				released = false;
				t = 0;
			} else {
				player.addChatMessage("No missiles!");

			}
		}
		if (t > 60 && MissileLauncherKeyBind.keyPressed == true
				&& !player.worldObj.isRemote) {

			if (mode == 1) {
				if (props.hasSuperMissiles()) {
					if ((props.consumeMissiles(5)|| player.capabilities.isCreativeMode)  && released == true) {
						player.worldObj
								.spawnEntityInWorld(new EntitySuperMissile(
										player.worldObj, player));
						released = false;
						t = 0;
					} else {
						player.addChatMessage("Not enough missiles!");
					}
				}

				else {
					player.addChatMessage("Super missiles not enabled");
				}
			}

			if (mode == 2) {
				if (props.hasIceSpreader()) {
					if ((props.consumeMissiles(10) || player.capabilities.isCreativeMode) && released == true) {
						player.worldObj
								.spawnEntityInWorld(new EntityIceSpreader(
										player.worldObj, player));
						released = false;
						t = 0;
					} else {
						player.addChatMessage("Not enough missiles!");
					}
				}

				else {
					player.addChatMessage("Ice Spreader not enabled");
				}
			}

			if (mode == 3) {
				if (props.hasWaveBuster()) {

					if (released) {
						if ((props.consumeMissiles(10)|| player.capabilities.isCreativeMode) ) {
							player.worldObj
									.spawnEntityInWorld(new EntityWaveBuster(
											player.worldObj, player));
							released = false;
						} else {
							player.addChatMessage("Not enough missiles!");
						}
					}

					if (!released) {

							if ((props.consumeMissiles(1)|| player.capabilities.isCreativeMode) ) {
								player.worldObj
										.spawnEntityInWorld(new EntityWaveBuster(
												player.worldObj, player));

								released = false;
							} else {
								player.addChatMessage("Not enough missiles!");
							}
						}


					}
			}
			if (mode == 4) {
				if (props.hasFlamethrower()) {

					if (released) {
						if ((props.consumeMissiles(10)|| player.capabilities.isCreativeMode) ) {
							player.worldObj
									.spawnEntityInWorld(new EntityFlamethrower(
											player.worldObj, player));
							released = false;
						} else {
							player.addChatMessage("Not enough missiles!");
						}
					}

					if (!released) {
						if (tickssinceconsumed == 20) {
							tickssinceconsumed = 0;
							if ((props.consumeMissiles(1)|| player.capabilities.isCreativeMode) ) {
								player.worldObj
										.spawnEntityInWorld(new EntityFlamethrower(
												player.worldObj, player));
								released = false;
							} else {
								player.addChatMessage("Not enough missiles!");
							}
						} else {
							if (props.getMissiles() > 0) {
								player.worldObj
										.spawnEntityInWorld(new EntityFlamethrower(
												player.worldObj, player));
								tickssinceconsumed += 1;
							}
						}

					}

				}

				else {
					player.addChatMessage("Flamethrower not enabled");
				}
			}

		}
	}



	if (PowerBeamKeyBind.keyPressed == true) {
		mode = 1;
	}
	if (IceBeamKeyBind.keyPressed == true && props.hasIceBeam()) {
		mode = 2;
	}
	if (WaveBeamKeyBind.keyPressed == true && props.hasWaveBeam()) {
		mode = 3;
	}
	if (PlasmaBeamKeyBind.keyPressed == true && props.hasPlasmaBeam()) {
		mode = 4;
	}

}

@SideOnly(Side.CLIENT)
private Icon[] Texture = new Icon[5];
private Icon iconIndex;

@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)

{
	this.itemIcon = iconRegister.registerIcon("chimera27metroid:powerbeam");

	this.Texture[0] = iconRegister.registerIcon("chimera27metroid:"
			+ "powerbeam");
	this.Texture[1] = iconRegister.registerIcon("chimera27metroid:"
			+ "icebeam");
	this.Texture[2] = iconRegister.registerIcon("chimera27metroid:"
			+ "wavebeam");
	this.Texture[3] = iconRegister.registerIcon("chimera27metroid:"
			+ "plasmabeam");
	this.Texture[4] = iconRegister.registerIcon("chimera27metroid:"
			+ "hyperbeam");

}

@SideOnly(Side.CLIENT)
public Icon getIcon(ItemStack stack, int renderPass, EntityPlayer player,
		ItemStack usingItem, int useRemaining) {

	if (mode == 5) {
		return Texture[4];
	} else if (mode == 4) {
		return Texture[3];
	} else if (mode == 3) {
		return Texture[2];
	} else if (mode == 2) {
		return Texture[1];
	}
	return Texture[0];
}

@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list,
		boolean par4) {
	ExtendedPlayer props = ExtendedPlayer.get(player);

	list.add(EnumChatFormatting.DARK_BLUE
			+ "Right click with upgrades to add them to the beam!");

	list.add(EnumChatFormatting.DARK_BLUE
			+ "Hold right click and press the switch keys to switch!");
	list.add(EnumChatFormatting.DARK_BLUE
			+ "To fire a Missile, hold right click and press 'F'!");
	list.add(EnumChatFormatting.DARK_BLUE
			+ "For a Super Missile, charge up a shot then press 'F'!");

	list.add(EnumChatFormatting.BOLD + "Mode:");
	if (mode == 1) {
		list.add(EnumChatFormatting.GOLD + "Power Beam!");
	}

	if (mode == 2) {
		if (props.hasIceBeam() && !props.hasDarkBeam()) {
			list.add(EnumChatFormatting.AQUA + "Ice Beam!");
		} else {

			list.add(EnumChatFormatting.DARK_PURPLE + "Dark Beam!");

		}
	}

	if (mode == 3) {
		if (props.hasWaveBeam() && !props.hasAnnihilatorBeam()) {
			list.add(EnumChatFormatting.LIGHT_PURPLE + "Wave Beam!");
		}

		else {
			list.add(EnumChatFormatting.GRAY + "Annihilator Beam!");
		}
	}

	if (mode == 4) {
		if (props.hasPlasmaBeam() && !props.hasLightBeam()
				&& !props.hasNovaBeam()) {
			list.add(EnumChatFormatting.RED + "Plasma Beam!");
		}

		if (props.hasPlasmaBeam() && props.hasLightBeam()
				&& !props.hasNovaBeam()) {
			list.add(EnumChatFormatting.WHITE + "Light Beam!");
		}
		if (props.hasNovaBeam()) {
			list.add(EnumChatFormatting.GREEN + "Nova Beam!");
		}
	}

	if (player.isPotionActive(Main.hypermode.id)) {
		list.add(EnumChatFormatting.BLUE + "Phazon Beam!");
	}
	int shift = Minecraft.getMinecraft().gameSettings.keyBindSneak.keyCode;


}
public EnumRarity getRarity(ItemStack par1ItemStack)
    {
        return EnumRarity.rare;
    }
}

 

 

 

I have no idea where to go from here, and am probs missing something obvious that I should be able to see, but anyone know what the heck I should do?

Creator of Metroid Cubed! Power Suits, Beams, Hypermode and more!

width=174 height=100http://i.imgur.com/ghgWmA3.jpg[/img]

Posted

Have you looked at the EntityPlayer code yet to see how it applies the lower speed effect?  you just need to counter that. 

Long time Bukkit & Forge Programmer

Happy to try and help

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.