Skip to content

Commit

Permalink
Merge remote-tracking branch 'Gordon-Frohman/master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Dream-Master committed Feb 3, 2024
2 parents 5e6ba60 + 613d88f commit 68fff55
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 83 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ apiPackage =

# Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/META-INF/
# Example value: mymodid_at.cfg
accessTransformersFile =
accessTransformersFile = twilightforest_at.cfg

# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
usesMixins = false
Expand Down
42 changes: 20 additions & 22 deletions src/main/java/twilightforest/item/ItemTFKnightlyAxe.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.minecraft.item.Item;
import net.minecraft.item.ItemAxe;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import net.minecraft.util.StatCollector;

import com.google.common.collect.Multimap;
Expand All @@ -23,8 +24,8 @@
public class ItemTFKnightlyAxe extends ItemAxe {

private static final int BONUS_DAMAGE = 2;
private EntityPlayer bonusDamagePlayer;
private Entity bonusDamageEntity;
private EntityPlayer bonusDamageAttacker;
private Entity bonusDamageTarget;
private float damageVsEntity;

protected ItemTFKnightlyAxe(Item.ToolMaterial par2EnumToolMaterial) {
Expand Down Expand Up @@ -67,31 +68,26 @@ public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack)
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
// extra damage to unarmored target
if (entity instanceof EntityLivingBase && ((EntityLivingBase) entity).getTotalArmorValue() == 0) {
this.bonusDamageEntity = entity;
this.bonusDamagePlayer = player;
this.bonusDamageTarget = entity;
this.bonusDamageAttacker = player;
}

return false;
}

// /**
// * Returns the damage against a given entity.
// */
// @Override
// public float getDamageVsEntity(Entity par1Entity, ItemStack itemStack)
// {
// if (this.bonusDamagePlayer != null && this.bonusDamageEntity != null && par1Entity == this.bonusDamageEntity)
// {
// this.bonusDamagePlayer.onEnchantmentCritical(par1Entity);
// this.bonusDamagePlayer = null;
// this.bonusDamageEntity = null;
// return this.damageVsEntity + BONUS_DAMAGE;
// }
// else
// {
// return super.getDamageVsEntity(par1Entity, itemStack);
// }
// }
@Override
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) {
if (this.bonusDamageAttacker != null && this.bonusDamageTarget != null && target == this.bonusDamageTarget) {
// System.out.println("Knightly Axe extra damage!");
if (bonusDamageAttacker instanceof EntityPlayer)
((EntityPlayer) this.bonusDamageAttacker).onEnchantmentCritical(bonusDamageTarget);
if (this.bonusDamageTarget instanceof EntityLivingBase) target.lastDamage = 0;
this.bonusDamageTarget.attackEntityFrom(DamageSource.causeMobDamage(bonusDamageAttacker), BONUS_DAMAGE);
this.bonusDamageAttacker = null;
this.bonusDamageTarget = null;
}
return super.hitEntity(stack, target, attacker);
}

/**
* Properly register icon source
Expand All @@ -116,6 +112,8 @@ public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlaye

/**
* Gets a map of item attribute modifiers, used by ItemSword to increase hit damage.
*
* Sergius Onesimus: Probably no need for this anymore since additional damage is now calculated on hit
*/
public Multimap<String, AttributeModifier> getItemAttributeModifiers() {
Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers();
Expand Down
42 changes: 20 additions & 22 deletions src/main/java/twilightforest/item/ItemTFKnightlyPick.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.minecraft.item.Item;
import net.minecraft.item.ItemPickaxe;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import net.minecraft.util.StatCollector;

import com.google.common.collect.Multimap;
Expand All @@ -23,8 +24,8 @@
public class ItemTFKnightlyPick extends ItemPickaxe {

private static final int BONUS_DAMAGE = 2;
private EntityPlayer bonusDamagePlayer;
private Entity bonusDamageEntity;
private EntityPlayer bonusDamageAttacker;
private Entity bonusDamageTarget;
private float damageVsEntity;

protected ItemTFKnightlyPick(Item.ToolMaterial par2EnumToolMaterial) {
Expand Down Expand Up @@ -67,31 +68,26 @@ public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack)
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
// extra damage to armored targets
if (entity instanceof EntityLivingBase && ((EntityLivingBase) entity).getTotalArmorValue() > 0) {
this.bonusDamageEntity = entity;
this.bonusDamagePlayer = player;
this.bonusDamageTarget = entity;
this.bonusDamageAttacker = player;
}

return false;
}

// /**
// * Returns the damage against a given entity.
// */
// @Override
// public float getDamageVsEntity(Entity par1Entity, ItemStack itemStack)
// {
// if (this.bonusDamagePlayer != null && this.bonusDamageEntity != null && par1Entity == this.bonusDamageEntity)
// {
// this.bonusDamagePlayer.onEnchantmentCritical(par1Entity);
// this.bonusDamagePlayer = null;
// this.bonusDamageEntity = null;
// return this.damageVsEntity + BONUS_DAMAGE;
// }
// else
// {
// return super.getDamageVsEntity(par1Entity, itemStack);
// }
// }
@Override
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) {
if (this.bonusDamageAttacker != null && this.bonusDamageTarget != null && target == this.bonusDamageTarget) {
// System.out.println("Knightly Pick extra damage!");
if (bonusDamageAttacker instanceof EntityPlayer)
((EntityPlayer) this.bonusDamageAttacker).onEnchantmentCritical(bonusDamageTarget);
if (this.bonusDamageTarget instanceof EntityLivingBase) target.lastDamage = 0;
this.bonusDamageTarget.attackEntityFrom(DamageSource.causeMobDamage(bonusDamageAttacker), BONUS_DAMAGE);
this.bonusDamageAttacker = null;
this.bonusDamageTarget = null;
}
return super.hitEntity(stack, target, attacker);
}

/**
* Properly register icon source
Expand All @@ -116,6 +112,8 @@ public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlaye

/**
* Gets a map of item attribute modifiers, used by ItemSword to increase hit damage.
*
* Sergius Onesimus: Probably no need for this anymore since additional damage is now calculated on hit
*/
public Multimap<String, AttributeModifier> getItemAttributeModifiers() {
Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers();
Expand Down
41 changes: 18 additions & 23 deletions src/main/java/twilightforest/item/ItemTFKnightlySword.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.util.DamageSource;
import net.minecraft.util.StatCollector;

import cpw.mods.fml.relauncher.Side;
Expand All @@ -19,8 +20,8 @@
public class ItemTFKnightlySword extends ItemSword {

private static final int BONUS_DAMAGE = 2;
private Entity bonusDamageEntity;
private EntityPlayer bonusDamagePlayer;
private Entity bonusDamageTarget;
private EntityPlayer bonusDamageAttacker;

public ItemTFKnightlySword(Item.ToolMaterial par2EnumToolMaterial) {
super(par2EnumToolMaterial);
Expand Down Expand Up @@ -60,32 +61,26 @@ public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack)
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
// extra damage to armored targets
if (entity instanceof EntityLivingBase && ((EntityLivingBase) entity).getTotalArmorValue() > 0) {
this.bonusDamageEntity = entity;
this.bonusDamagePlayer = player;
this.bonusDamageTarget = entity;
this.bonusDamageAttacker = player;
}

return false;
}

// /**
// * Returns the damage against a given entity.
// */
// @Override
// public float getDamageVsEntity(Entity par1Entity, ItemStack itemStack)
// {
// if (this.bonusDamagePlayer != null && this.bonusDamageEntity != null && par1Entity == this.bonusDamageEntity)
// {
// //System.out.println("Minotaur Axe extra damage!");
// this.bonusDamagePlayer.onEnchantmentCritical(par1Entity);
// this.bonusDamagePlayer = null;
// this.bonusDamageEntity = null;
// return super.getDamageVsEntity(par1Entity, itemStack) + BONUS_DAMAGE;
// }
// else
// {
// return super.getDamageVsEntity(par1Entity, itemStack);
// }
// }
@Override
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) {
if (this.bonusDamageAttacker != null && this.bonusDamageTarget != null && target == this.bonusDamageTarget) {
// System.out.println("Knightly Sword extra damage!");
if (bonusDamageAttacker instanceof EntityPlayer)
((EntityPlayer) this.bonusDamageAttacker).onEnchantmentCritical(bonusDamageTarget);
if (this.bonusDamageTarget instanceof EntityLivingBase) target.lastDamage = 0;
this.bonusDamageTarget.attackEntityFrom(DamageSource.causeMobDamage(bonusDamageAttacker), BONUS_DAMAGE);
this.bonusDamageAttacker = null;
this.bonusDamageTarget = null;
}
return super.hitEntity(stack, target, attacker);
}

/**
* Properly register icon source
Expand Down
34 changes: 19 additions & 15 deletions src/main/java/twilightforest/item/ItemTFMinotaurAxe.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemAxe;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import net.minecraft.util.StatCollector;

import com.google.common.collect.Multimap;
Expand All @@ -22,8 +24,8 @@
public class ItemTFMinotaurAxe extends ItemAxe {

public static final int BONUS_CHARGING_DAMAGE = 7;
private Entity bonusDamageEntity;
private EntityPlayer bonusDamagePlayer;
private Entity bonusDamageTarget;
private EntityLivingBase bonusDamageAttacker;
private float damageVsEntity;

protected ItemTFMinotaurAxe(Item.ToolMaterial par2EnumToolMaterial) {
Expand Down Expand Up @@ -55,26 +57,26 @@ public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List<ItemStack
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
// if the player is sprinting, keep the entity, we will do extra damage to it
if (player.isSprinting()) {
this.bonusDamageEntity = entity;
this.bonusDamagePlayer = player;
this.bonusDamageTarget = entity;
this.bonusDamageAttacker = player;
}

return false;
}

/**
* Returns the damage against a given entity.
*/
public float getDamageVsEntity(Entity par1Entity, ItemStack itemStack) {
if (this.bonusDamagePlayer != null && this.bonusDamageEntity != null && par1Entity == this.bonusDamageEntity) {
@Override
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) {
if (this.bonusDamageAttacker != null && this.bonusDamageTarget != null && target == this.bonusDamageTarget) {
// System.out.println("Minotaur Axe extra damage!");
this.bonusDamagePlayer.onEnchantmentCritical(par1Entity);
this.bonusDamagePlayer = null;
this.bonusDamageEntity = null;
return damageVsEntity + BONUS_CHARGING_DAMAGE;
} else {
return damageVsEntity;
if (bonusDamageAttacker instanceof EntityPlayer)
((EntityPlayer) this.bonusDamageAttacker).onEnchantmentCritical(bonusDamageTarget);
if (this.bonusDamageTarget instanceof EntityLivingBase) target.lastDamage = 0;
this.bonusDamageTarget
.attackEntityFrom(DamageSource.causeMobDamage(bonusDamageAttacker), BONUS_CHARGING_DAMAGE);
this.bonusDamageAttacker = null;
this.bonusDamageTarget = null;
}
return super.hitEntity(stack, target, attacker);
}

/**
Expand Down Expand Up @@ -108,6 +110,8 @@ public void registerIcons(IIconRegister par1IconRegister) {

/**
* Gets a map of item attribute modifiers, used by ItemSword to increase hit damage.
*
* Sergius Onesimus: Probably no need for this anymore since additional damage is now calculated on hit
*/
public Multimap<String, AttributeModifier> getItemAttributeModifiers() {
Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers();
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/META-INF/twilightforest_at.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#Fields
public net.minecraft.entity.EntityLivingBase *

0 comments on commit 68fff55

Please sign in to comment.