From 18400e8457eb130b451d872de2f35f489c604556 Mon Sep 17 00:00:00 2001 From: LexManos Date: Tue, 19 Mar 2019 21:21:37 -0700 Subject: [PATCH] Revive CapabilityProvider on entity revive. Madders should NOT need this, as caps are copied via NBT. --- patches/minecraft/net/minecraft/entity/Entity.java.patch | 7 +++++-- .../common/capabilities/CapabilityProvider.java | 5 +++++ .../net/minecraftforge/event/AttachCapabilitiesEvent.java | 3 +-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/patches/minecraft/net/minecraft/entity/Entity.java.patch b/patches/minecraft/net/minecraft/entity/Entity.java.patch index 5bd851cb9..65acef178 100644 --- a/patches/minecraft/net/minecraft/entity/Entity.java.patch +++ b/patches/minecraft/net/minecraft/entity/Entity.java.patch @@ -288,7 +288,7 @@ this.field_70170_p.field_72984_F.func_76319_b(); worldserver.func_82742_i(); worldserver1.func_82742_i(); -@@ -2592,4 +2628,60 @@ +@@ -2592,4 +2628,63 @@ public double func_212107_bY() { return this.field_211517_W; } @@ -347,5 +347,8 @@ + public void onRemovedFromWorld() { this.isAddedToWorld = false; } + + @Override -+ public void revive() { this.field_70128_L = false; } ++ public void revive() { ++ this.field_70128_L = false; ++ this.reviveCaps(); ++ } } diff --git a/src/main/java/net/minecraftforge/common/capabilities/CapabilityProvider.java b/src/main/java/net/minecraftforge/common/capabilities/CapabilityProvider.java index 62de77668..cd7237160 100644 --- a/src/main/java/net/minecraftforge/common/capabilities/CapabilityProvider.java +++ b/src/main/java/net/minecraftforge/common/capabilities/CapabilityProvider.java @@ -106,6 +106,11 @@ public abstract class CapabilityProvider> implem disp.invalidate(); } + protected void reviveCaps() + { + this.valid = true; //Stupid players don't copy the entity when transporting across worlds. + } + @Override @Nonnull public LazyOptional getCapability(@Nonnull Capability cap, @Nullable EnumFacing side) diff --git a/src/main/java/net/minecraftforge/event/AttachCapabilitiesEvent.java b/src/main/java/net/minecraftforge/event/AttachCapabilitiesEvent.java index fc8399222..9d25d3fe9 100644 --- a/src/main/java/net/minecraftforge/event/AttachCapabilitiesEvent.java +++ b/src/main/java/net/minecraftforge/event/AttachCapabilitiesEvent.java @@ -82,9 +82,8 @@ public class AttachCapabilitiesEvent extends GenericEvent return view; } - /** - * Adds a callback that is fired when the attacked object is invalidated. + * Adds a callback that is fired when the attached object is invalidated. * Such as a Entity/TileEntity being removed from world. * All attached providers should invalidate all of their held capability instances. */