-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ed447be
commit 90b1500
Showing
9 changed files
with
194 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 41 additions & 40 deletions
81
src/main/java/github/mcdatapack/more_tools_and_armor/init/ItemInit.java
Large diffs are not rendered by default.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
src/main/java/github/mcdatapack/more_tools_and_armor/item/MoreToolsAndArmorArmorItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package github.mcdatapack.more_tools_and_armor.item; | ||
|
||
import net.minecraft.item.ArmorItem; | ||
import net.minecraft.item.equipment.ArmorMaterial; | ||
import net.minecraft.item.equipment.EquipmentType; | ||
|
||
public class MoreToolsAndArmorArmorItem extends ArmorItem implements MoreToolsAndArmorItem<ArmorMaterial> { | ||
private final ArmorMaterial material; | ||
|
||
public MoreToolsAndArmorArmorItem(ArmorMaterial material, EquipmentType type, Settings settings) { | ||
super(material, type, settings); | ||
this.material = material; | ||
} | ||
|
||
@Override | ||
public ArmorMaterial getMaterial() { | ||
return material; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/github/mcdatapack/more_tools_and_armor/item/MoreToolsAndArmorItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package github.mcdatapack.more_tools_and_armor.item; | ||
|
||
public interface MoreToolsAndArmorItem<T> { | ||
T getMaterial(); | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/github/mcdatapack/more_tools_and_armor/mixns/ability/EndermanEntityMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package github.mcdatapack.more_tools_and_armor.mixns.ability; | ||
|
||
import github.mcdatapack.more_tools_and_armor.util.Abilities; | ||
import net.minecraft.entity.mob.EndermanEntity; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(EndermanEntity.class) | ||
public class EndermanEntityMixin { | ||
@Inject(method = "isPlayerStaring", at = @At("RETURN"), cancellable = true) | ||
private void isPlayerStaring(PlayerEntity player, CallbackInfoReturnable<Boolean> cir) { | ||
if (cir.getReturnValue()) { | ||
if (Abilities.isWearingEndermanSaveArmor(player)) { | ||
cir.setReturnValue(false); | ||
} | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/github/mcdatapack/more_tools_and_armor/mixns/ability/TargetPredicateMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package github.mcdatapack.more_tools_and_armor.mixns.ability; | ||
|
||
import github.mcdatapack.more_tools_and_armor.util.Abilities; | ||
import net.minecraft.entity.LivingEntity; | ||
import net.minecraft.entity.ai.TargetPredicate; | ||
import net.minecraft.entity.mob.AbstractPiglinEntity; | ||
import net.minecraft.entity.mob.EndermanEntity; | ||
import net.minecraft.entity.mob.ZombifiedPiglinEntity; | ||
import net.minecraft.entity.passive.IronGolemEntity; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.server.world.ServerWorld; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(TargetPredicate.class) | ||
public class TargetPredicateMixin { | ||
@Inject(method = "test", at = @At("RETURN"), cancellable = true) | ||
private void canTarget(ServerWorld world, LivingEntity tester, LivingEntity target, CallbackInfoReturnable<Boolean> cir) { | ||
if (tester instanceof IronGolemEntity ironGolem && target instanceof PlayerEntity player) { | ||
if (Abilities.isWearingIronGolemPassiveArmor(player)) { | ||
cir.setReturnValue(false); | ||
} | ||
} | ||
if ((tester instanceof AbstractPiglinEntity piglinEntity || tester instanceof ZombifiedPiglinEntity zombifiedPiglinEntity) && target instanceof PlayerEntity player) { | ||
if (Abilities.isWearingPiglinPassiveArmor(player)) { | ||
cir.setReturnValue(false); | ||
} | ||
} | ||
if (tester instanceof EndermanEntity endermanEntity && target instanceof PlayerEntity player) { | ||
if (Abilities.isWearingEndermanPassiveArmor(player)) { | ||
cir.setReturnValue(false); | ||
} | ||
} | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
src/main/java/github/mcdatapack/more_tools_and_armor/util/Abilities.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package github.mcdatapack.more_tools_and_armor.util; | ||
|
||
import github.mcdatapack.more_tools_and_armor.init.ArmorMaterialInit; | ||
import github.mcdatapack.more_tools_and_armor.item.MoreToolsAndArmorArmorItem; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.item.ItemStack; | ||
|
||
public class Abilities { | ||
public static boolean isWearingEndermanSaveArmor(PlayerEntity player) { | ||
for (ItemStack itemStack : player.getArmorItems()) { | ||
if (itemStack.getItem() instanceof MoreToolsAndArmorArmorItem item) { | ||
if (item.getMaterial() == ArmorMaterialInit.END_DIAMOND || | ||
item.getMaterial() == ArmorMaterialInit.VOID || | ||
item.getMaterial() == ArmorMaterialInit.ONETHDENDERITE || | ||
item.getMaterial() == ArmorMaterialInit.OLED) { | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
public static boolean isWearingPiglinPassiveArmor(PlayerEntity player) { | ||
for (ItemStack itemStack : player.getArmorItems()) { | ||
if (itemStack.getItem() instanceof MoreToolsAndArmorArmorItem item) { | ||
if (item.getMaterial() == ArmorMaterialInit.ONETHDENDERITE || | ||
item.getMaterial() == ArmorMaterialInit.OLED) { | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
public static boolean isWearingIronGolemPassiveArmor(PlayerEntity player) { | ||
for (ItemStack itemStack : player.getArmorItems()) { | ||
if (itemStack.getItem() instanceof MoreToolsAndArmorArmorItem item) { | ||
if (item.getMaterial() == ArmorMaterialInit.OLED) { | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
public static boolean isWearingEndermanPassiveArmor(PlayerEntity player) { | ||
for (ItemStack itemStack : player.getArmorItems()) { | ||
if (itemStack.getItem() instanceof MoreToolsAndArmorArmorItem item) { | ||
if (item.getMaterial() == ArmorMaterialInit.OLED) { | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/main/resources/mixins.more_tools_and_armor-abilities.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"required": true, | ||
"minVersion": "0.8", | ||
"package": "github.mcdatapack.more_tools_and_armor.mixns.ability", | ||
"compatibilityLevel": "JAVA_21", | ||
"mixins": [ | ||
"EndermanEntityMixin", | ||
"TargetPredicateMixin" | ||
], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
} | ||
} |