Skip to content

Commit

Permalink
优化代码
Browse files Browse the repository at this point in the history
  • Loading branch information
plusls committed Aug 10, 2020
1 parent b2c222a commit ca62c44
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import net.minecraft.entity.Npc;
import net.minecraft.entity.passive.AbstractTraderEntity;
import net.minecraft.entity.passive.PassiveEntity;
import net.minecraft.inventory.InventoryChangedListener;
import net.minecraft.inventory.SimpleInventory;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.village.Trader;
Expand All @@ -17,7 +16,7 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(AbstractTraderEntity.class)
public abstract class MixinAbstractTraderEntity extends PassiveEntity implements Npc, Trader, InventoryChangedListener {
public abstract class MixinAbstractTraderEntity extends PassiveEntity implements Npc, Trader {
@Final
@Dynamic
@Shadow
Expand All @@ -28,10 +27,7 @@ public MixinAbstractTraderEntity(World world) {
}

// mojang 的 SimpleInventory 实现的有问题,readTags 时不会清空原有数据需要手动清空
@Inject(method = "readCustomDataFromTag(Lnet/minecraft/nbt/CompoundTag;)V",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/inventory/SimpleInventory;readTags(Lnet/minecraft/nbt/ListTag;)V",
ordinal = 0))
@Inject(method = "readCustomDataFromTag(Lnet/minecraft/nbt/CompoundTag;)V", at = @At(value = "HEAD"))
private void preReadTags(CompoundTag tag, CallbackInfo info) {
if (this.world.isClient()) {
this.inventory.clear();
Expand Down

0 comments on commit ca62c44

Please sign in to comment.