Jump to content

[SOLVED][1.7.10]Manipulating damage when a certain item is in players inventory.


Recommended Posts

So I have made a few items that will manipulate the damage done to or by the player and I have succesfully made a check that checks whether this is the case.

I want to check how much damage is done (in both cases) and decrease or increase the total damage by half the amount.


Item A is there to increase the damage done by the player to other entities by 50%. - The Black Diamond Ring in this case.

Item B is there to decrease the damage done to the player by other entities by 50%.


To do this I thought it would be best to do this in a forge event and the entityAttacked(LivingAttackEvent event) seemed perfect for that.


So far I have not found a way to alter the amount of damage done by that specific attack so I made it so the entity is attacked another time but now its damageSource is "bonus magic" so that the event wont trigger my check.


My code to do this so far:

    public void entityAttacked(LivingAttackEvent event){
       if(!(event.entityLiving instanceof EntityPlayer)){
              EntityLiving attackedEnt = (EntityLiving) event.entityLiving;
      DamageSource attackSource = event.source;
      Entity player = event.source.getEntity();
              if(player instanceof EntityPlayer){
                     EntityPlayer thePlayer = (EntityPlayer)player;
                     if("generic".equals(attackSource.damageType) || "magic".equals(attackSource.damageType) || 
		           System.out.println("Normal Damage : " + event.ammount);
		           System.out.println("Bonus Damage from Ring : " + event.ammount / 2);
		           attackedEnt.attackEntityFrom(new DamageSource("bonus magic"), event.ammount / 2);

private boolean checkPlayerHasAmulet(EntityPlayer player){
ItemStack[] inventoryPlayer = player.inventory.mainInventory;
for(int i = 0; i < inventoryPlayer.length;i++){
    ItemStack stack = inventoryPlayer[i];
    if(stack != null){
	if(stack.stackSize > 0){
	    Item item = stack.getItem();
	    // Check if Black Diamond Ring is in your hotbar
	    if(item.equals(SoulItems.BlackdiamondAmuletRing.get()) && i < 9){
		item.setDamage(stack, item.getDamage(stack) + 1);
		return true;
return true;


As you can probably see I now attack the entity with half the event.ammount (which is always 0.5, or in cases of a critical attack 0.75) as somehow the event.ammount is always 1, it seems it uses the base player damage or something.


Is there any way to check how much damage is actually done? And is there perhaps an easier way to go about doing this?

Link to comment
Share on other sites

This topic is now closed to further replies.

  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • no this one https://pastebin.com/5uMxHeWf
    • I am in such a mess. I have lost over 4.7m due to a scammer... It started as bank wires and then bitcoin. it is hard to imagine but it is true and can send any proof, then I tried to use a couple of recovery companies and was as well. Graphic design has been more than just a hobby for me since high school—it has become a thriving career. Starting in my parents' garage, I eventually expanded to my office, running a successful graphic design business. However, like many, I faced the need to diversify my investments due to inflation. This led me to invest 60.16 in Bitcoin, a decision that paid off handsomely as my investment grew to 4.7m over time. This financial windfall allowed me to upgrade my equipment and take on more ambitious projects, furthering the growth of my business. Unfortunately, my excitement was abruptly cut short when I fell victim to a hacking incident. Malware infected my computer, giving hackers access to my Bitcoin wallet. The devastation of potentially losing all my hard-earned savings and plans weighed heavily on me. At this dire moment, a fellow designer suggested Linux Cyber Security Company as a potential solution. Desperate for a lifeline, I reached out to them, hoping for a miracle. The response from Linux Cyber Security Company was prompt, incredibly professional, and effective. Their team quickly traced the hacker’s activities and recovered most of my funds, alleviating a significant amount of stress and uncertainty. Beyond the recovery, they took the time to educate me on essential practices to secure my Bitcoin holdings better. They emphasized using antivirus software to prevent malware infections, avoiding suspicious downloads, and the added security provided by hardware wallets. This experience served as a critical wake-up call for me. It highlighted the vulnerabilities inherent in digital assets and underscored the importance of robust security measures. Thanks to the guidance and expertise of Linux Cyber Security Company, I now feel more equipped to protect my digital assets proactively. Their insights have empowered me to implement stronger security protocols in my business operations and personal finances alike. With my Bitcoin funds securely recovered and a newfound understanding of digital security best practices, I am more confident in navigating future challenges. This journey has reinforced my commitment to safeguarding my hard-earned assets and leveraging technology responsibly. I am optimistic about the growth opportunities ahead, creatively in graphic design and prudently in investment strategies. In conclusion, while the hacking incident was a setback, it ultimately became a catalyst for enhancing my digital security awareness and resilience. I am grateful to Linux Cyber Security Company for their expertise and support during a challenging time, enabling me to continue pursuing my passion for graphic design with renewed confidence and financial stability. Contact a professional company I am sure they can help you with your case too, Website [www.linuxcybersecurity.com Email the team; info@)(linuxcybersecurity.com
    • https://pastebin.com/B2HnBZTa
    • it was easy villager mate, thanks ill see how to do it without that mod! thanks
  • Topics

  • Create New...

Important Information

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