Skip to content

Commit

Permalink
Fix anyDamage doesn't work for some items (IC2 etc.) (#1586)
Browse files Browse the repository at this point in the history
* fix `anyDamage` doesn't work for some items (IC2 etc.)

* fix null wrapper in IEntityAttributeInstance

* Revert "fix `anyDamage` doesn't work for some items (IC2 etc.)"

This reverts commit eca3bc7.

* rollback the changes for `anyDamage`
  • Loading branch information
friendlyhj committed Nov 11, 2022
1 parent fbb20f3 commit 402bf7c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,14 @@ public static IEntityFishHook getIEntityFishHook(EntityFishHook entity) {
return entity == null ? null : new MCEntityFishHook(entity);
}

public static IEntityAttributeInstance getAttributeInstance(IAttributeInstance instance) {
return instance == null ? null : new MCEntityAttributeInstance(instance);
}

public static IAttributeInstance getAttributeInstance(IEntityAttributeInstance instance) {
return instance == null ? null : ((IAttributeInstance) instance.getInternal());
}

public static AttributeModifier getAttributeModifier(IEntityAttributeModifier modifier) {
return modifier == null ? null : (AttributeModifier) modifier.getInternal();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import crafttweaker.api.minecraft.CraftTweakerMC;
import crafttweaker.api.potions.IPotion;
import crafttweaker.api.potions.IPotionEffect;
import crafttweaker.mc1120.entity.attribute.MCEntityAttributeInstance;
import net.minecraft.entity.EntityLivingBase;

import java.util.List;
Expand Down Expand Up @@ -81,7 +80,7 @@ public IItemStack getHeldItemOffHand() {

@Override
public IEntityAttributeInstance getAttribute(String name) {
return new MCEntityAttributeInstance(entityLivingBase.getAttributeMap().getAttributeInstanceByName(name));
return CraftTweakerMC.getAttributeInstance(entityLivingBase.getAttributeMap().getAttributeInstanceByName(name));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.entity.ai.attributes.IAttributeInstance;

import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -36,6 +37,7 @@ public void setBaseValue(double baseValue) {
@Override
public List<IEntityAttributeModifier> getModifiersByOperation(int operation) {
return attributeInstance.getModifiersByOperation(operation).stream()
.filter(Objects::nonNull)
.map(MCEntityAttributeModifier::new)
.collect(Collectors.toList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ public ILiquidStack getLiquid() {

@Override
public IIngredient anyDamage() {
ItemStack result = stack.copy();
result.setItemDamage(OreDictionary.WILDCARD_VALUE);
ItemStack result = new ItemStack(stack.getItem(), stack.getCount(), OreDictionary.WILDCARD_VALUE);
result.setTagCompound(stack.getTagCompound());
return new MCItemStack(result, tag);
}

Expand Down

0 comments on commit 402bf7c

Please sign in to comment.