Started by
NestyG
on
Topic category: Help with MCreator software
Ever since the 1.9 combat update Swords changed. Now there is a bar that determines how fast you can swing your sword. If you swing before it fills up again, you wont do 100% damage.
On the wiki this thing is described as speed and recovery time.
On MCreator when you make a Sword there is still the old code. What is the new code needed to change these 2 things? And how would I implement it into MCreator's custom code?
Highlight your mod element and click on "edit code of selected code element"
@#1 I know how to do that, I don't know what is the code for the new damage/speed and stuff system.
Try fiddling with this section of the code o.O Im honestly not too sure! haha I havent messed around with the new sword system too much, since most of my modding is for minecraft 1.7.10
Item.ToolMaterial enumt = EnumHelper.addToolMaterial("MODELEMENTNAME", 1, 100, 4F, 5, 2);
block = (Item) (new ItemSword(enumt) {
public Set<String> getToolClasses(ItemStack stack) {
HashMap<String, Integer> ret = new HashMap<String, Integer>();
ret.put("sword", 1);
return ret.keySet();
The best way to figure your way around mCreator is simple trial and error since you cant really "break" intangible 1s and 0s lol. Just dive in and figure out what does what ;)
You need override getAttributeModifiers() method.
@#3 I'm not an expert in Java (or coding in general) could you help me a little more than that?
(To be more specific I'd like to have some sort of code, where I just need to copy it somewhere in the class of the Sword and modify the values depending on what I want.)
[spoiler]
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) {
final Multimap<String, AttributeModifier> modifiers = super.getAttributeModifiers(slot, stack);
if (slot == EntityEquipmentSlot.MAINHAND) {
replaceModifier(modifiers, SharedMonsterAttributes.ATTACK_SPEED, ATTACK_SPEED_MODIFIER, 1.5);
}
return modifiers;
}
private void replaceModifier(Multimap<String, AttributeModifier> modifierMultimap, IAttribute attribute, UUID id, double multiplier) {
// Get the modifiers for the specified attribute
final Collection<AttributeModifier> modifiers = modifierMultimap.get(attribute.getAttributeUnlocalizedName());
final Optional<AttributeModifier> modifierOptional = modifiers.stream().filter(attributeModifier -> attributeModifier.getID().equals(id)).findFirst();
if (modifierOptional.isPresent()) {
final AttributeModifier modifier = modifierOptional.get();
modifiers.remove(modifier);
modifiers.add(new AttributeModifier(modifier.getID(), modifier.getName(), modifier.getAmount() * multiplier, modifier.getOperation()));
}
}
[/spoiler]
Also you need these imports
import com.google.common.collect.Multimap;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.ai.attributes.IAttribute;
import net.minecraft.inventory.EntityEquipmentSlot;
import java.util.Collection;
import java.util.Optional;
import java.util.UUID;
@#4 Can you get any more awesome? lol
@#4 Do I just add that code at the end of the "SteelSword.java" for example?
Also could I add you on skype/Discord?
@#4.2 Also Thanks, and sorry, it's my first time doing this stuff.
@#4 When I try to recompile it, it gives me these errors:
warning: [options] bootstrap class path not set in conjunction with -source 1.6
C:\Pylo\MCreator170\forge\build\sources\main\java\mod\mcreator\mcreator_steelSword.java:100: error: lambda expressions are not supported in -source 1.6
final Optional<AttributeModifier>modifierOptional = modifiers.stream().filter(attributeModifier -> attributeModifier.getID().equals(id)).findFirst();
^
(use -source 8 or higher to enable lambda expressions)
C:\Pylo\MCreator170\forge\build\sources\main\java\mod\mcreator\mcreator_steelSword.java:107: error: not a statement
modifier.getAmount() * multiplier;
^
2 errors
1 warning
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Do you have the code in instance of ItemSword (something like new ItemSword(enumt){ THE CODE } ) , or in a class extending ItemSword?
(Like class ItemPlatinumSword extends ItemSword{
public ItemPlatinumSword(ItemMaterial mat){
super(mat);
}
THE CODE
}
@#5 http://puu.sh/rErmp/44ed617383.png
http://puu.sh/rEro0/d4424039a6.png
This is all I have.
Also, I'll ask again, could you maybe add me on Discord?
I'm Melkyal#2161 on Discord.
@#5.1
Put it after this part
public Set<String> getToolClasses(ItemStack stack) {
HashMap<String, Integer> ret = new HashMap<String, Integer>();
ret.put("sword", 1);
return ret.keySet();}
And to the Discord , simply I do not use , it is fist time I heard about it. :D
@#5.1.1 Sorry, but what is it that I should put after that? The @Override code, or that new thing you said about the new ItemSword(enumt){ THE CODE } ?
What about skype? I'm the_osu on there