Its outside of the scope of this tutorial but I'll help anyways cause this is an easy fix. When you use methods like addPotionEffect() they take a potion effect object as an argument. So your code would be hitEntity.addPotionEffect(new PotionEffect(Stuff here));
Also i was trying to play sound to player using world.playSound() and world.playSoundAtEntity() when armor is on , but System in eclipse writes me "unknown sound event".
Also i was trying to play sound to player using world.playSound() and world.playSoundAtEntity() when armor is on , but System in eclipse writes me "unknown sound event".
What version are you using? In some versions of 1.7.10 Forge doesn't really work with sounds.
It is really that easy! However, you SHOULD NOT do anything with the player that would be disabled once the armor is taken off. For example, do not set player.capabilities.canFly to true then try to set it to false when the player is not wearing the armor because the method will no longer be called when the player is not wearing the armor. Potion effects are ok because the game will remove them once the timer runs out.
I don't really understand this. I know this isn't part of your tutorial, but in my mod, my one chestplate's effect is that when it's worn, the player can fly, but you said not to do that, so how would I set that up? Is there also a way to add enchantment effects? And for this:
(Potion.moveSlowdown.id, 500, 4) could you expalin where this came from? I dont know how to code the potion effects. Sorry, I know I asked a lot but I am having trouble giving my items effects.
For flying: Write a tick handler that checks if the player is wearing your chest plate.
Enchantments: The enchantment helper class should be able to help you out
Potion explanation: If you're modding you should know about constructors and how they work... That initializes the potion effect. The first parameter is the id of the potion effect we want applied, the second one is the duration(In ticks), and the third is the level of the potion.
I don't really understand this. I know this isn't part of your tutorial, but in my mod, my one chestplate's effect is that when it's worn, the player can fly, but you said not to do that, so how would I set that up? Is there also a way to add enchantment effects? And for this:
(Potion.moveSlowdown.id, 500, 4) could you expalin where this came from? I dont know how to code the potion effects. Sorry, I know I asked a lot but I am having trouble giving my items effects.
Thank you so much. I tried watching tutorials on how to do some of these things on youtube, and I realized that I have my mod coded differently than most other people. In the videos I watched, they all created separate classes for each individual item, but the way I learned to code the mod has a completely different setup.
This is essentially what mine looks like
package net.mymodc.mod;
import net.minecraft.block.Block;
@Mod(modid = mymod.modid, version = mymod.version)
public class mymod {
public static final String modid = "mymod";
public static final String version = "Alpha v0.1";
public static CreativeTabs mymodTab;
public static Item itemMyItem;
@EventHandler
public void PreInit(FMLPreInitializationEvent preEvent){
itemMyItem = new SGWItems().setUnlocalizedName("MyItem");
GameRegistry.registerItem(itemMyItem, "MyItem");
@EventHandler
public void Init(FMLInitializationEvent event){
}
@EventHandler
public void PostInit(FMLPostInitializationEvent postEvent){
}
in which the only classes I create are the ones for my item set, in this case SGWItems()
while the other people's code looks like this
package net.mymodc.mod;
import net.minecraft.block.Block;
@Mod(modid = mymod.modid, version = mymod.version)
public static final String version = "Alpha v0.1";
@Mod.Instance(MODID)
public static Item itemMyItem = new MyItem(5555)
@EventHandler
public void Init(FMLInitializationEvent event){
}
@EventHandler
public void PostInit(FMLPostInitializationEvent postEvent){
In which case they create a class for MyItem
I guess what I'm getting at is that I'm wondering if there's a way to add effects to my items the way I'm doing it, or if I will need to code the way that they do in the second thing i pasted. Thanks again.
Ok say i wanted like fire particles to appear when im holing a sword how would i do that and would the sword have to be named something specific in the code?
What my goal is, i want to recreate this sword but as a mod...
(Here is what it looks like)
The sword is called The sword of Dianite (If the video doesn't load, just refresh and go to 46 mins and 6 seconds) and it has a cool fire particle effect that i want to recreate can you help?
Ok say i wanted like fire particles to appear when im holing a sword how would i do that and would the sword have to be named something specific in the code?
What my goal is, i want to recreate this sword but as a mod...
(Here is what it looks like)
The sword is called The sword of Dianite (If the video doesn't load, just refresh and go to 46 mins and 6 seconds) and it has a cool fire particle effect that i want to recreate can you help?
The Meaning of Life, the Universe, and Everything.
Join Date:
9/1/2014
Posts:
63
Member Details
That causes extreme LAG haha. is there a way to make it only add the potion effect every like 30 seconds and make it last 30 seconds instead of every second?
That causes extreme LAG haha. is there a way to make it only add the potion effect every like 30 seconds and make it last 30 seconds instead of every second?
Quote from 3man7»
Just found a tutorial here that uses the onUpdate method. Works great for me
@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) {
super.onUpdate(stack, world, entity, par4, par5);
EntityPlayer player = (EntityPlayer) entity;
ItemStack equipped = player.getCurrentEquippedItem();
if(equipped == stack) {
player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 5, 0));
}
}
Credit goes to
this causes lag only when I have fancy graphics on probably because I don't know how to allocate more ram to my dev environment client and I am using 128x128 textures, so i wasn't saying your code causes lag, I should have quoted not just hit "reply"
and I changed it to this and it helped a little:
@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) {
super.onUpdate(stack, world, entity, par4, par5);
EntityPlayer player = (EntityPlayer) entity;
ItemStack equipped = player.getCurrentEquippedItem();
if(equipped != null && equipped == stack) {
hey im new to java script and modding. is there any chance you could create a very basic, step by step tutorial on how to create these type of items?
if that's possible that would be amazing!
Cheers
Well, its Java, not JavaScript. If you're looking for a begginers tutorial. I recommend that first you learn the basics of Java then look for one in the tutorials section of this forum. Thats how I got started.
hey im new to java script and modding. is there any chance you could create a very basic, step by step tutorial on how to create these type of items?
if that's possible that would be amazing!
Cheers
Well, its Java, not JavaScript. If you're looking for a begginers tutorial. I recommend that first you learn the basics of Java then look for one in the tutorials section of this forum. Thats how I got started.
I am making a mode with all sorts of weapons and i want to know if there is anyway to Add enchantments to the Item like Fire Aspect and such. i looked all over the internet didn't see anything.
@Override
public boolean hitEntity(ItemStack stack, EntityLivingBase hitEntity, EntityLivingBase attackingEntity) {
hitEntity.addPotionEffect"(Potion.moveSlowdown.id, 1, 1);
}"
the area in " is the area with the error
Its outside of the scope of this tutorial but I'll help anyways cause this is an easy fix. When you use methods like addPotionEffect() they take a potion effect object as an argument. So your code would be hitEntity.addPotionEffect(new PotionEffect(Stuff here));
Check out all my mods here: Link Removed!
What version are you using? In some versions of 1.7.10 Forge doesn't really work with sounds.
I 'm trying on both 1.7.2 and 1.7.10
Check out all my mods here: Link Removed!
I can't say I know what to do. Sorry.
I don't really understand this. I know this isn't part of your tutorial, but in my mod, my one chestplate's effect is that when it's worn, the player can fly, but you said not to do that, so how would I set that up? Is there also a way to add enchantment effects? And for this:
Enchantments: The enchantment helper class should be able to help you out
Potion explanation: If you're modding you should know about constructors and how they work... That initializes the potion effect. The first parameter is the id of the potion effect we want applied, the second one is the duration(In ticks), and the third is the level of the potion.
This is essentially what mine looks like
package net.mymodc.mod;
import net.minecraft.block.Block;
@Mod(modid = mymod.modid, version = mymod.version)
public class mymod {
public static final String modid = "mymod";
public static final String version = "Alpha v0.1";
public static CreativeTabs mymodTab;
public static Item itemMyItem;
@EventHandler
public void PreInit(FMLPreInitializationEvent preEvent){
itemMyItem = new SGWItems().setUnlocalizedName("MyItem");
GameRegistry.registerItem(itemMyItem, "MyItem");
@EventHandler
public void Init(FMLInitializationEvent event){
}
@EventHandler
public void PostInit(FMLPostInitializationEvent postEvent){
}
in which the only classes I create are the ones for my item set, in this case SGWItems()
while the other people's code looks like this
package net.mymodc.mod;
import net.minecraft.block.Block;
@Mod(modid = mymod.modid, version = mymod.version)
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
public class mymod {
public static final String modid = "mymod";
public static final String version = "Alpha v0.1";
@Mod.Instance(MODID)
public static Item itemMyItem = new MyItem(5555)
@EventHandler
public void Init(FMLInitializationEvent event){
}
@EventHandler
public void PostInit(FMLPostInitializationEvent postEvent){
In which case they create a class for MyItem
I guess what I'm getting at is that I'm wondering if there's a way to add effects to my items the way I'm doing it, or if I will need to code the way that they do in the second thing i pasted. Thanks again.
What my goal is, i want to recreate this sword but as a mod...
(Here is what it looks like)
The sword is called The sword of Dianite (If the video doesn't load, just refresh and go to 46 mins and 6 seconds) and it has a cool fire particle effect that i want to recreate can you help?
Outside of the scope of this tutorial.
if(!player.hasPotionEffect(effect) {
player.addPotionEffect(effect);
}
Sorry I was actually replying to this:
this causes lag only when I have fancy graphics on probably because I don't know how to allocate more ram to my dev environment client and I am using 128x128 textures, so i wasn't saying your code causes lag, I should have quoted not just hit "reply"
and I changed it to this and it helped a little:
@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) {
super.onUpdate(stack, world, entity, par4, par5);
EntityPlayer player = (EntityPlayer) entity;
ItemStack equipped = player.getCurrentEquippedItem();
if(equipped != null && equipped == stack) {
player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 5, 100));
}
}
so thanks for that!
Well, its Java, not JavaScript. If you're looking for a begginers tutorial. I recommend that first you learn the basics of Java then look for one in the tutorials section of this forum. Thats how I got started.
Well, its Java, not JavaScript. If you're looking for a begginers tutorial. I recommend that first you learn the basics of Java then look for one in the tutorials section of this forum. Thats how I got started.
This has nothing to do with command blocks