Skip to content

Commit

Permalink
fixed legendary tooltips compat
Browse files Browse the repository at this point in the history
  • Loading branch information
Globox1997 committed Aug 23, 2023
1 parent e4d31a4 commit 00117a7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public abstract class ArmorStandEntityMixin {

@Unique
private boolean isGenerated = true;
@Unique
private boolean isClient = true;

@Inject(method = "writeCustomDataToNbt", at = @At("TAIL"))
private void writeCustomDataToNbtMixin(NbtCompound nbt, CallbackInfo info) {
Expand All @@ -37,11 +39,12 @@ private void readCustomDataFromNbtMixin(NbtCompound nbt, CallbackInfo info) {
@Inject(method = "interactAt", at = @At("HEAD"))
private void interactAt(PlayerEntity player, Vec3d hitPos, Hand hand, CallbackInfoReturnable<ActionResult> info) {
this.isGenerated = false;
this.isClient = player.getWorld().isClient();
}

@Inject(method = "equipStack", at = @At("HEAD"))
private void equipStackMixin(EquipmentSlot slot, ItemStack stack, CallbackInfo info) {
if (this.isGenerated && ConfigInit.CONFIG.lootContainerModifier) {
if (!this.isClient && this.isGenerated && ConfigInit.CONFIG.lootContainerModifier) {
ModifierUtils.setItemStackAttribute(null, stack, false);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/draylar/tiered/mixin/LootTableMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ public class LootTableMixin {
// lambda injection
@Inject(method = "method_331", at = @At(value = "INVOKE", target = "Ljava/util/function/Consumer;accept(Ljava/lang/Object;)V", ordinal = 0))
private static void processStacksMixin(ServerWorld world, Consumer<ItemStack> lootConsumer, ItemStack itemStack, CallbackInfo info) {
if (ConfigInit.CONFIG.lootContainerModifier) {
if (!world.isClient() && ConfigInit.CONFIG.lootContainerModifier) {
ModifierUtils.setItemStackAttribute(null, itemStack, false);
}
}

@Inject(method = "method_331", at = @At(value = "INVOKE", target = "Ljava/util/function/Consumer;accept(Ljava/lang/Object;)V", ordinal = 1), locals = LocalCapture.CAPTURE_FAILSOFT)
private static void processStacksMixin(ServerWorld world, Consumer<ItemStack> lootConsumer, ItemStack itemStack, CallbackInfo info, int i, ItemStack itemStack2) {
if (ConfigInit.CONFIG.lootContainerModifier) {
if (!world.isClient() && ConfigInit.CONFIG.lootContainerModifier) {
ModifierUtils.setItemStackAttribute(null, itemStack2, false);
}
}

@Inject(method = "supplyInventory", at = @At(value = "INVOKE", target = "Lnet/minecraft/inventory/Inventory;setStack(ILnet/minecraft/item/ItemStack;)V", ordinal = 1), locals = LocalCapture.CAPTURE_FAILSOFT)
private void supplyInventoryMixin(Inventory inventory, LootContextParameterSet parameters, long seed, CallbackInfo info, LootContext lootContext, ObjectArrayList<ItemStack> objectArrayList,
Random random, List<Integer> list, ObjectListIterator<ItemStack> var9, ItemStack itemStack) {
if (ConfigInit.CONFIG.lootContainerModifier) {
if (!lootContext.getWorld().isClient() && ConfigInit.CONFIG.lootContainerModifier) {
ModifierUtils.setItemStackAttribute(null, itemStack, false);
}
}
Expand Down

0 comments on commit 00117a7

Please sign in to comment.