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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Minecraft 1.21.4 requires a new model definition file for each item, which you don't have. These can be created through Data Generation, specifically the ModelProvider, BlockModelGenerators and ItemModelGenerators classes.
    • Hi,  I'm using Forge 47.3.0 for Minecraft 1.20.1 I apologise if this is obvious I am very new to modding for Minecraft. I sucessfully made a mod that launched without errors or crashes (without it doing anything) but in order to add the features I need, I need to add "Custom Portal API [Forge]" as a dependency. However no matter the way I've tried to acheive this, it crashes. I am pretty sure it's not the way I'm putting it in the repositories, the dependencies or the way I'm refrencing it, as I've a hundred diffrent combinations and multiple Maven methods. And on all those diffrent variations I still get this crash: pastebin.com/UhumzZCZ Any tips would be invaluable as I've been loosing my mind over this!
    • Hi, i'm really having problems trying to set the texture to my custom item. I thought i'm doing everything correctly, but all i see is the missing texture block for my item. I am trying this for over a week now and getting really frustrated. The only time i could make the texture work, was when i used an older Forge version (52.0.1) for Minecraft (1.21.4). Was there a fundamental change for textures and models somewhere between versions that i'm missing? I started with Forge 54.1.0 and had this problem, so in my frustration i tried many things: Upgrading to Forge 54.1.1, created multiple new projects, workspaces, redownloaded everything and setting things up multiple times, as it was suggested in an older thread. Therea are no errors in the console logs, but maybe i'm blind, so i pasted the console logs to pastebin anyway: https://pastebin.com/zAM8RiUN The only time i see an error is when i change the models JSON file to an incorrect JSON which makes sense and that suggests to me it is actually reading the JSON file.   I set the github repository to public, i would be so thankful if anyone could take a look and tell me what i did wrong: https://github.com/xLorkin/teleport_pug_forge   As a note: i'm pretty new to modding, this is my first mod ever. But i'm used to programming. I had some up and downs, but through reading the documentation, using google and experimenting, i could solve all other problems. I only started modding for Minecraft because my son is such a big fan and wanted this mod.
    • Please read the FAQ (link in orange bar at top of page), and post logs as described there.
    • Hello fellow Minecrafters! I recently returned to Minecraft and realized I needed a wiki that displays basic information easily and had great user navigation. That’s why I decided to build: MinecraftSearch — a site by a Minecraft fan, for Minecraft fans. Key Features So Far Straight-to-the-Point Info: No extra fluff; just the essentials on items, mobs, recipes, loot and more. Clean & Intuitive Layout: Easy navigation so you spend less time scrolling and more time playing. Optimized Search: Search for anything—items, mobs, blocks—and get results instantly. What I’m Thinking of Adding More data/information: Catch chances for fishing rod, traveling villager trades, biomes info and a lot more. The website is still under development and need a lot more data added. Community Contributions: Potential for user-uploaded tips for items/mobs/blocks in the future. Feature Requests Welcome: Your ideas could shape how the wiki evolves! You can see my roadmap at the About page https://minecraftsearch.com/about I’d love for you to check out MinecraftSearch and see if it helps you find the info you need faster. Feedback is crucial—I want to develop this further based on what the community needs most, so please let me know what you think. Thanks, and happy crafting!
  • Topics

×
×
  • Create New...

Important Information

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