Speed and recovery time of a Sword?

Started by NestyG on

Topic category: Help with MCreator software

Last seen on 08:47, 30. Nov 2016
Joined Oct 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Speed and recovery time of a Sword?

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?

Last seen on 22:00, 11. Nov 2019
Joined Aug 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Highlight your mod element
Mon, 10/10/2016 - 12:43

Highlight your mod element and click on "edit code of selected code element"

Last seen on 08:47, 30. Nov 2016
Joined Oct 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:Highlight your mod element
Mon, 10/10/2016 - 14:47

@#1 I know how to do that, I don't know what is the code for the new damage/speed and stuff system.

Last seen on 22:00, 11. Nov 2019
Joined Aug 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Try fiddling with this
Mon, 10/10/2016 - 15:01

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 ;)

Last seen on 17:17, 10. Jan 2024
Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You need override
Mon, 10/10/2016 - 15:11

You need override getAttributeModifiers() method.

Last seen on 08:47, 30. Nov 2016
Joined Oct 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:You need override
Mon, 10/10/2016 - 15:24

@#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.)

Last seen on 17:17, 10. Jan 2024
Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Spoiler: Highlight to view
Mon, 10/10/2016 - 15:42

[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;

Last seen on 22:00, 11. Nov 2019
Joined Aug 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:Spoiler: Highlight to view
Mon, 10/10/2016 - 15:48

@#4 Can you get any more awesome? lol

Last seen on 08:47, 30. Nov 2016
Joined Oct 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:Spoiler: Highlight to view
Mon, 10/10/2016 - 15:49

@#4 Do I just add that code at the end of the "SteelSword.java" for example?

Also could I add you on skype/Discord?

Last seen on 08:47, 30. Nov 2016
Joined Oct 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:RE:Spoiler: Highlight to view
Mon, 10/10/2016 - 15:49

@#4.2 Also Thanks, and sorry, it's my first time doing this stuff. 

Last seen on 08:47, 30. Nov 2016
Joined Oct 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:Spoiler: Highlight to view
Mon, 10/10/2016 - 18:15

@#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.

Last seen on 17:17, 10. Jan 2024
Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Do you have the code in
Mon, 10/10/2016 - 19:13

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

}
 

Last seen on 17:17, 10. Jan 2024
Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:RE:Do you have the code in
Mon, 10/10/2016 - 19:46

@#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

Last seen on 08:47, 30. Nov 2016
Joined Oct 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:RE:RE:Do you have the code in
Mon, 10/10/2016 - 19:50

@#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