Jump to content

Recommended Posts

Posted

I'm trying to make some tools that work better in The End. Currently I'm doing this:

    public float getStrVsBlock(ItemStack stack, IBlockState state)
    {
        float strength = super.getStrVsBlock(stack, state);
        //TODO: make this not client only
        if(Minecraft.getMinecraft().thePlayer.dimension == 1) {
        	strength *= 8;
        }
        
        return strength;
    }
    
    /**
     * ItemStack sensitive version of getItemAttributeModifiers
     */
    public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack)
    {
    	Multimap<String, AttributeModifier> multimap = HashMultimap.<String, AttributeModifier>create();
        
        double atk = (double)this.attackDamage;
        //TODO: make this not client only
        try {
        if(Minecraft.getMinecraft() != null && Minecraft.getMinecraft().thePlayer != null && Minecraft.getMinecraft().thePlayer.dimension == 1) {
        	atk *= 4;
        }
        } finally {
        	
        }

        if (slot == EntityEquipmentSlot.MAINHAND)
        {
            multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", atk, 0));
            multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -2.4000000953674316D, 0));
        }

        return multimap;
    }

However, since Minecraft is a client-only class, this will crash a server. I don't know of a way I can get a player from an ItemStack, IBlockState, or EntityEquipmentSlot. I could potentially use NBT data that gets set when the tool is equipped, but that seems messy and a little hacky and I'd rather not do it if there's a better way. Any ideas?

I'll put something here when I have something of value I need to put at the end of every post. For now it's this mostly pointless text.

Posted

That solves half of it, though I now need to make the sword deal quadruple damage. I'm trying to use this:

@SubscribeEvent
public void enditeLivingAttackEvent(LivingAttackEvent e) {
	System.out.println("enditeLivingAttackEvent!");
	if(e.getEntity() != null && e.getEntity().dimension == 1 && e.getSource().getSourceOfDamage() instanceof EntityLiving) {
		System.out.println("entity isn't null, is in end, and was attacked by EntityLiving!");
		EntityLiving attacker = (EntityLiving) e.getSource().getSourceOfDamage();
		if(attacker.getHeldItem(EnumHand.MAIN_HAND) != null && attacker.getHeldItem(EnumHand.MAIN_HAND).getItem() == EWOTItems.enditeSword) {
			System.out.println("IT'S SUPER EFFECTIVE!");
			e.getEntityLiving().attackEntityFrom(DamageSource.generic, e.getAmount() * 3);
		}
	}
}

But it's not working. If possible I'd like to use something similar to the code in my first post so that the tooltip showing the attack damage updates, though I'd understand if that wasn't possible without making a coremod (which sounds like a bad idea).

I'll put something here when I have something of value I need to put at the end of every post. For now it's this mostly pointless text.

Posted

Is the code being executed? Are you in the end when testing?

As for tooltips, you can use

ItemTooltipEvent

to change the tooltip of any item.

I'll look into messing with the tooltip in a bit.

It is executing - "enditeLivingAttackEvent!" is printed every time something takes damage (sometimes several times - no idea what's causing that), but it never progresses past that. I've tested it both in and out of The End and it doesn't do anything out of the ordinary either way.

I'll put something here when I have something of value I need to put at the end of every post. For now it's this mostly pointless text.

Posted

Alright - I discovered e.getSource().getSourceOfDamage() instanceof EntityLiving is returning false. Now the question is what can I do about that? Is there a different event I should be using?

I'll put something here when I have something of value I need to put at the end of every post. For now it's this mostly pointless text.

Posted

I'm the stupid one - I didn't even check EntityPlayer!

 

It's kinda working now - the main problem is that it's now making endermen teleport, as well as the more minor problem of not technically having the attack come from the attacker. I'm pretty sure it's because I'm attacking as DamageSource.generic, so that may have to change. There doesn't seem to be any way to set LivingAttackEvent.amount, so I'm not really sure what to do from here.

 

BTW Here's the current code:

@SubscribeEvent
public void enditeLivingAttackEvent(LivingAttackEvent e) {
if(e.getEntity().dimension == 1 && e.getSource().getSourceOfDamage() instanceof EntityLivingBase) {
	EntityLivingBase attacker = (EntityLivingBase) e.getSource().getSourceOfDamage();
	if(attacker.getHeldItem(EnumHand.MAIN_HAND) != null && attacker.getHeldItem(EnumHand.MAIN_HAND).getItem() == EWOTItems.enditeSword) {
		//Not sure what to do here
	}
}
}

I'll put something here when I have something of value I need to put at the end of every post. For now it's this mostly pointless text.

Posted

It's working perfectly now - thanks so much!

Here's my finished code for everything, in case someone in the future want to do a similar thing:

@SubscribeEvent
public void enditeBreakSpeedEvent(PlayerEvent.BreakSpeed e) {
	if(e.getEntityPlayer().getHeldItem(EnumHand.MAIN_HAND) != null && e.getEntityPlayer().getHeldItem(EnumHand.MAIN_HAND).getItem() instanceof IEndTool && e.getEntityPlayer().dimension == 1) {
		e.setNewSpeed(e.getOriginalSpeed() * ;
	}
}

@SubscribeEvent
public void enditeLivingHurtEvent(LivingHurtEvent e) {
	if(e.getEntity().dimension == 1 && e.getSource().getEntity() instanceof EntityLivingBase) {
		EntityLivingBase attacker = (EntityLivingBase) e.getSource().getEntity();
		if(attacker.getHeldItem(EnumHand.MAIN_HAND) != null && attacker.getHeldItem(EnumHand.MAIN_HAND).getItem() == EWOTItems.enditeSword) {
			e.setAmount(e.getAmount() * 4);
		}
	}
}

I'll put something here when I have something of value I need to put at the end of every post. For now it's this mostly pointless text.

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

    • "I want to understand how complex mods with ASM transformation and coremods work, such as Xray or AntiXray. Why do they break when you simply rename packages? What features of their architecture make refactoring difficult? And what techniques are used to protect these mods? I am interested in technical aspects in order to better understand the bytecode and Forge loader system."
    • I can't figure out if you're looking for help trying to steal someone elses work, or cheat at the game....
    • Title: Why Is It So Hard to Rename and Restructure Mods Like Xray or AntiXray? 🤔 Post text: Hey everyone! I’ve been digging into Minecraft modding for a while and have one big question that I can’t figure out on my own. Maybe someone with more experience could help or give me some advice. Here’s the issue: When I take a “normal” Minecraft mod — for example, one that just adds some blocks or new items — I can easily change its structure, package names, or even rebrand it entirely. It’s straightforward. But as soon as I try this with cheat-type mods like XrayMod or AntiXray, everything falls apart. Even if I just rename the classes, refactor the packages, or hide its identity somehow, the mod either breaks or stops working properly. XrayMod in particular is proving to be a nightmare to modify without losing its core function. So my question is — why is this so much harder with cheat mods like Xray? Is there something fundamentally different about how they’re coded, loaded, or protected that prevents simple renaming or restructuring? And if so, how can I actually learn to understand someone else’s cheat mod enough to safely refactor it without breaking the core features? I’ve already been spending over two months trying to figure this out and haven’t gotten anywhere. It feels like there must be some trick or knowledge I’m missing. Would really appreciate any thoughts, tips, or references — maybe there are guides or techniques for understanding cheat-mod internals? Or if you’ve successfully “disguised” a cheat mod like Xray before, I’d love to hear how you did it. Thanks in advance for any help or discussion. ✌️
    • just started making cinamatic contect check it out on my channel or check out my facebook page    Humbug City Minecraft Youtube https://www.youtube.com/watch?v=v2N6OveKwno https://www.facebook.com/profile.php?id=61575866982337  
    • Where did you get the schematic? Source/Link? And do use an own modpack or a pre-configured from curseforge? If yes, which one On a later time, I can make some tests on my own - but I need the schematic and the modpack name
  • Topics

×
×
  • Create New...

Important Information

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