mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-25 14:34:28 +00:00
Remove entity.remove(keepData) functions because Mojang changed entity removal mechanics.
If a modder wishes to use the capabilities from a invalid entity. They must manually call reviveCaps/invalidateCaps themselves.
This commit is contained in:
1 parent
06804675be
commit
9ec1e24dc5
19 files changed
+106
-186
No files matched your search
@@ -102,14 +102,14 @@
|
||||
}
|
||||
|
||||
+ public void removePlayer(ServerPlayer p_8850_, boolean keepData) {
|
||||
+ p_8850_.remove(keepData);
|
||||
+ p_8850_.m_146870_();
|
||||
+ this.removeEntity(p_8850_, keepData);
|
||||
+ }
|
||||
+
|
||||
+ public void removeEntityComplete(Entity p_8865_, boolean keepData) {
|
||||
+ if(p_8865_.isMultipartEntity()) {
|
||||
+ for(net.minecraftforge.entity.PartEntity<?> parts : p_8865_.getParts()) {
|
||||
+ parts.remove(keepData);
|
||||
+ parts.m_146870_();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
@@ -125,7 +125,7 @@
|
||||
+ }
|
||||
+
|
||||
+ p_8865_.onRemovedFromWorld();
|
||||
+ p_8865_.remove(keepData);
|
||||
+ p_8865_.m_146870_();
|
||||
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityLeaveWorldEvent(p_8865_, this));
|
||||
+ }
|
||||
+
|
||||
|
||||
@@ -65,34 +65,6 @@
|
||||
ServerLevel serverlevel = p_11287_.m_9236_();
|
||||
p_11287_.m_36220_(Stats.f_12989_);
|
||||
this.m_6765_(p_11287_);
|
||||
@@ -328,7 +_,7 @@
|
||||
p_11287_.m_19877_();
|
||||
serverlevel.m_143261_(p_11287_, Entity.RemovalReason.UNLOADED_WITH_PLAYER);
|
||||
p_11287_.m_8960_().m_135978_();
|
||||
- this.f_11196_.remove(p_11287_);
|
||||
+ this.removePlayer(p_11287_);
|
||||
this.f_11195_.m_129901_().m_136305_(p_11287_);
|
||||
UUID uuid = p_11287_.m_142081_();
|
||||
ServerPlayer serverplayer = this.f_11197_.get(uuid);
|
||||
@@ -390,8 +_,8 @@
|
||||
}
|
||||
|
||||
public ServerPlayer m_11236_(ServerPlayer p_11237_, boolean p_11238_) {
|
||||
- this.f_11196_.remove(p_11237_);
|
||||
- p_11237_.m_9236_().m_143261_(p_11237_, Entity.RemovalReason.DISCARDED);
|
||||
+ this.removePlayer(p_11237_);
|
||||
+ p_11237_.m_9236_().removePlayer(p_11237_, true); // Forge: keep data until copyFrom called
|
||||
BlockPos blockpos = p_11237_.m_8961_();
|
||||
float f = p_11237_.m_8962_();
|
||||
boolean flag = p_11237_.m_8964_();
|
||||
@@ -407,6 +_,7 @@
|
||||
ServerPlayer serverplayer = new ServerPlayer(this.f_11195_, serverlevel1, p_11237_.m_36316_());
|
||||
serverplayer.f_8906_ = p_11237_.f_8906_;
|
||||
serverplayer.m_9015_(p_11237_, p_11238_);
|
||||
+ p_11237_.remove(false); // Forge: clone event had a chance to see old data, now discard it
|
||||
serverplayer.m_20234_(p_11237_.m_142049_());
|
||||
serverplayer.m_36163_(p_11237_.m_5737_());
|
||||
|
||||
@@ -447,10 +_,11 @@
|
||||
this.m_11229_(serverplayer, serverlevel1);
|
||||
this.m_11289_(serverplayer);
|
||||
|
||||
@@ -38,20 +38,14 @@
|
||||
}
|
||||
|
||||
public boolean m_20039_(BlockPos p_20040_, BlockState p_20041_) {
|
||||
@@ -339,6 +_,13 @@
|
||||
@@ -335,6 +_,7 @@
|
||||
if (p_146834_ == Entity.RemovalReason.KILLED) {
|
||||
this.m_146850_(GameEvent.f_157809_);
|
||||
}
|
||||
+ this.invalidateCaps();
|
||||
|
||||
}
|
||||
|
||||
public void m_142036_() {
|
||||
+ this.remove(false);
|
||||
+ }
|
||||
+
|
||||
+ public void remove(boolean keepData) {
|
||||
+ this.m_146870_();
|
||||
+ if (!keepData)
|
||||
+ this.invalidateCaps();
|
||||
}
|
||||
|
||||
public void m_20124_(Pose p_20125_) {
|
||||
@@ -599,13 +_,13 @@
|
||||
double d0 = vec3.f_82479_;
|
||||
double d1 = vec3.f_82480_;
|
||||
|
||||
@@ -505,7 +505,7 @@
|
||||
}
|
||||
|
||||
public boolean m_5830_() {
|
||||
@@ -3198,6 +_,58 @@
|
||||
@@ -3198,6 +_,63 @@
|
||||
|
||||
public void m_21190_(InteractionHand p_21191_) {
|
||||
this.m_21166_(p_21191_ == InteractionHand.MAIN_HAND ? EquipmentSlot.MAINHAND : EquipmentSlot.OFFHAND);
|
||||
@@ -544,7 +544,7 @@
|
||||
+ return this instanceof net.minecraft.world.entity.animal.Pig;
|
||||
+ }
|
||||
+
|
||||
+ private final net.minecraftforge.common.util.LazyOptional<?>[] handlers = net.minecraftforge.items.wrapper.EntityEquipmentInvWrapper.create(this);
|
||||
+ private net.minecraftforge.common.util.LazyOptional<?>[] handlers = net.minecraftforge.items.wrapper.EntityEquipmentInvWrapper.create(this);
|
||||
+
|
||||
+ @Override
|
||||
+ public <T> net.minecraftforge.common.util.LazyOptional<T> getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, @Nullable Direction facing) {
|
||||
@@ -557,10 +557,15 @@
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ protected void invalidateCaps() {
|
||||
+ public void invalidateCaps() {
|
||||
+ super.invalidateCaps();
|
||||
+ for (int x = 0; x < handlers.length; x++)
|
||||
+ handlers[x].invalidate();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void reviveCaps() {
|
||||
+ handlers = net.minecraftforge.items.wrapper.EntityEquipmentInvWrapper.create(this);
|
||||
}
|
||||
|
||||
public AABB m_6921_() {
|
||||
@@ -26,7 +26,7 @@
|
||||
+ f_20891_ = 0;
|
||||
+ entity = null;
|
||||
+ } else if (result == net.minecraftforge.eventbus.api.Event.Result.ALLOW) {
|
||||
+ this.remove(false);
|
||||
+ this.m_146870_();
|
||||
+ entity = null;
|
||||
+ }
|
||||
if (entity != null) {
|
||||
|
||||
@@ -18,49 +18,47 @@
|
||||
this.m_5851_(SoundSource.PLAYERS);
|
||||
this.m_146852_(GameEvent.f_157781_, p_28941_);
|
||||
if (!this.f_19853_.f_46443_) {
|
||||
@@ -235,6 +_,45 @@
|
||||
@@ -141,7 +_,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ @Override
|
||||
+ public java.util.List<ItemStack> onSheared(@javax.annotation.Nullable Player player, @javax.annotation.Nonnull ItemStack item, Level world, BlockPos pos, int fortune) {
|
||||
+ return shearInternal(player == null ? SoundSource.BLOCKS : SoundSource.PLAYERS);
|
||||
+ }
|
||||
+
|
||||
public void m_5851_(SoundSource p_28924_) {
|
||||
+ shearInternal(p_28924_).forEach(s -> this.f_19853_.m_7967_(new ItemEntity(this.f_19853_, this.m_20185_(), this.m_20227_(1.0D), this.m_20189_(), s)));
|
||||
+ }
|
||||
+
|
||||
+ private java.util.List<ItemStack> shearInternal(SoundSource p_28924_) {
|
||||
this.f_19853_.m_6269_((Player)null, this, SoundEvents.f_12075_, p_28924_, 1.0F, 1.0F);
|
||||
if (!this.f_19853_.m_5776_()) {
|
||||
((ServerLevel)this.f_19853_).m_8767_(ParticleTypes.f_123813_, this.m_20185_(), this.m_20227_(0.5D), this.m_20189_(), 1, 0.0D, 0.0D, 0.0D, 0.0D);
|
||||
@@ -162,10 +_,13 @@
|
||||
cow.m_20331_(this.m_20147_());
|
||||
this.f_19853_.m_7967_(cow);
|
||||
|
||||
+ java.util.List<ItemStack> items = new java.util.ArrayList<>();
|
||||
for(int i = 0; i < 5; ++i) {
|
||||
- this.f_19853_.m_7967_(new ItemEntity(this.f_19853_, this.m_20185_(), this.m_20227_(1.0D), this.m_20189_(), new ItemStack(this.m_28955_().f_28961_.m_60734_())));
|
||||
+ items.add(new ItemStack(this.m_28955_().f_28961_.m_60734_()));
|
||||
}
|
||||
+ return items;
|
||||
}
|
||||
+ return java.util.Collections.emptyList();
|
||||
|
||||
}
|
||||
|
||||
@@ -234,6 +_,11 @@
|
||||
}
|
||||
|
||||
return mushroomcow$mushroomtype2;
|
||||
}
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isShearable(@javax.annotation.Nonnull ItemStack item, Level world, BlockPos pos) {
|
||||
+ return m_6220_();
|
||||
+ }
|
||||
+
|
||||
+ @javax.annotation.Nonnull
|
||||
+ @Override
|
||||
+ public java.util.List<ItemStack> onSheared(@javax.annotation.Nullable Player player, @javax.annotation.Nonnull ItemStack item, Level world, BlockPos pos, int fortune) {
|
||||
+ world.m_6269_(null, this, SoundEvents.f_12075_, player == null ? SoundSource.BLOCKS : SoundSource.PLAYERS, 1.0F, 1.0F);
|
||||
+ if (!world.m_5776_()) {
|
||||
+ ((ServerLevel)this.f_19853_).m_8767_(ParticleTypes.f_123813_, this.m_20185_(), this.m_20227_(0.5D), this.m_20189_(), 1, 0.0D, 0.0D, 0.0D, 0.0D);
|
||||
+ this.remove(false);
|
||||
+ Cow cow = EntityType.f_20557_.m_20615_(this.f_19853_);
|
||||
+ cow.m_7678_(this.m_20185_(), this.m_20186_(), this.m_20189_(), this.m_146909_(), this.m_146908_());
|
||||
+ cow.m_21153_(this.m_21223_());
|
||||
+ cow.f_20883_ = this.f_20883_;
|
||||
+ if (this.m_8077_()) {
|
||||
+ cow.m_6593_(this.m_7770_());
|
||||
+ cow.m_20340_(this.m_20151_());
|
||||
+ }
|
||||
+
|
||||
+ if (this.m_21532_()) {
|
||||
+ cow.m_21530_();
|
||||
+ }
|
||||
+
|
||||
+ cow.m_20331_(this.m_20147_());
|
||||
+ this.f_19853_.m_7967_(cow);
|
||||
+
|
||||
+ java.util.List<ItemStack> items = new java.util.ArrayList<>();
|
||||
+ for (int i = 0; i < 5; ++i) {
|
||||
+ items.add(new ItemStack(this.m_28955_().f_28961_.m_60734_()));
|
||||
+ }
|
||||
+
|
||||
+ return items;
|
||||
+ }
|
||||
+ return java.util.Collections.emptyList();
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
public static enum MushroomType {
|
||||
RED("red", Blocks.f_50073_.m_49966_()),
|
||||
@@ -44,7 +44,7 @@
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ protected void invalidateCaps() {
|
||||
+ public void invalidateCaps() {
|
||||
+ super.invalidateCaps();
|
||||
+ if (itemHandler != null) {
|
||||
+ net.minecraftforge.common.util.LazyOptional<?> oldHandler = itemHandler;
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
+ ItemStack item = this.m_32055_();
|
||||
+ if (!this.f_19853_.f_46443_ && this.f_31985_ >= lifespan) {
|
||||
+ int hook = net.minecraftforge.event.ForgeEventFactory.onItemExpire(this, item);
|
||||
+ if (hook < 0) this.remove(false);
|
||||
+ if (hook < 0) this.m_146870_();
|
||||
+ else this.lifespan += hook;
|
||||
+ }
|
||||
+
|
||||
|
||||
@@ -8,28 +8,6 @@
|
||||
for(int j = 0; j < i * 8; ++j) {
|
||||
float f = this.f_19796_.nextFloat() * ((float)Math.PI * 2F);
|
||||
float f1 = this.f_19796_.nextFloat() * 0.5F + 0.5F;
|
||||
@@ -176,9 +_,10 @@
|
||||
return (EntityType<? extends Slime>)super.m_6095_();
|
||||
}
|
||||
|
||||
- public void m_142687_(Entity.RemovalReason p_149847_) {
|
||||
+ @Override
|
||||
+ public void remove(boolean keepData) {
|
||||
int i = this.m_33632_();
|
||||
- if (!this.f_19853_.f_46443_ && i > 1 && this.m_21224_()) {
|
||||
+ if (!this.f_19853_.f_46443_ && i > 1 && this.m_21224_() && !this.m_146910_()) {
|
||||
Component component = this.m_7770_();
|
||||
boolean flag = this.m_21525_();
|
||||
float f = (float)i / 4.0F;
|
||||
@@ -202,7 +_,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- super.m_142687_(p_149847_);
|
||||
+ super.remove(keepData);
|
||||
}
|
||||
|
||||
public void m_7334_(Entity p_33636_) {
|
||||
@@ -321,6 +_,12 @@
|
||||
public EntityDimensions m_6972_(Pose p_33597_) {
|
||||
return super.m_6972_(p_33597_).m_20388_(0.255F * (float)this.m_33632_());
|
||||
|
||||
@@ -248,18 +248,6 @@
|
||||
this.m_5810_();
|
||||
this.f_19853_.m_7605_(this, (byte)30);
|
||||
}
|
||||
@@ -1212,8 +_,9 @@
|
||||
public void m_7583_() {
|
||||
}
|
||||
|
||||
- public void m_142687_(Entity.RemovalReason p_150097_) {
|
||||
- super.m_142687_(p_150097_);
|
||||
+ @Override
|
||||
+ public void remove(boolean keepData) {
|
||||
+ super.remove(keepData);
|
||||
this.f_36095_.m_6877_(this);
|
||||
if (this.f_36096_ != null) {
|
||||
this.f_36096_.m_6877_(this);
|
||||
@@ -1247,6 +_,7 @@
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
+ event = new net.minecraftforge.event.entity.player.ItemFishedEvent(list, this.f_19861_ ? 2 : 1, this);
|
||||
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event);
|
||||
+ if (event.isCanceled()) {
|
||||
+ this.remove(false);
|
||||
+ this.m_146870_();
|
||||
+ return event.getRodDamage();
|
||||
+ }
|
||||
CriteriaTriggers.f_10553_.m_40416_((ServerPlayer)player, p_37157_, this, list);
|
||||
@@ -60,16 +60,3 @@
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
@@ -470,6 +_,12 @@
|
||||
public void m_5602_(@Nullable Entity p_150154_) {
|
||||
super.m_5602_(p_150154_);
|
||||
this.m_150147_(this);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void remove(boolean keepData) {
|
||||
+ super.remove(keepData);
|
||||
+ m_150147_(null);
|
||||
}
|
||||
|
||||
private void m_150147_(@Nullable FishingHook p_150148_) {
|
||||
+5
-29
@@ -1,27 +1,5 @@
|
||||
--- a/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||
+++ b/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||
@@ -122,12 +_,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
- public void m_142687_(Entity.RemovalReason p_150255_) {
|
||||
- if (!this.f_19853_.f_46443_ && p_150255_.m_146965_()) {
|
||||
+ public Entity changeDimension(ServerLevel p_38246_, net.minecraftforge.common.util.ITeleporter teleporter) {
|
||||
+ this.dropContentsWhenDead(false);
|
||||
+ return super.changeDimension(p_38246_, teleporter);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void remove(boolean keepData) {
|
||||
+ if (!this.f_19853_.f_46443_ && this.dropContents) {
|
||||
Containers.m_18998_(this.f_19853_, this, this);
|
||||
}
|
||||
|
||||
- super.m_142687_(p_150255_);
|
||||
+ super.remove(keepData);
|
||||
}
|
||||
|
||||
protected void m_7380_(CompoundTag p_38248_) {
|
||||
@@ -156,6 +_,8 @@
|
||||
}
|
||||
|
||||
@@ -40,15 +18,12 @@
|
||||
if (p_38255_ != null) {
|
||||
lootcontext$builder.m_78963_(p_38255_.m_36336_()).m_78972_(LootContextParams.f_81455_, p_38255_);
|
||||
}
|
||||
@@ -219,4 +_,27 @@
|
||||
@@ -219,4 +_,25 @@
|
||||
}
|
||||
|
||||
protected abstract AbstractContainerMenu m_7402_(int p_38222_, Inventory p_38223_);
|
||||
+
|
||||
+ // Forge Start
|
||||
+
|
||||
+ private boolean dropContents = this.f_19853_.m_46469_().m_46207_(GameRules.f_46137_);
|
||||
+
|
||||
+ private net.minecraftforge.common.util.LazyOptional<?> itemHandler = net.minecraftforge.common.util.LazyOptional.of(() -> new net.minecraftforge.items.wrapper.InvWrapper(this));
|
||||
+
|
||||
+ @Override
|
||||
@@ -59,12 +34,13 @@
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ protected void invalidateCaps() {
|
||||
+ public void invalidateCaps() {
|
||||
+ super.invalidateCaps();
|
||||
+ itemHandler.invalidate();
|
||||
+ }
|
||||
+
|
||||
+ public void dropContentsWhenDead(boolean value) {
|
||||
+ this.dropContents = value;
|
||||
+ @Override
|
||||
+ public void reviveCaps() {
|
||||
+ itemHandler = net.minecraftforge.common.util.LazyOptional.of(() -> new net.minecraftforge.items.wrapper.InvWrapper(this));
|
||||
+ }
|
||||
}
|
||||
+7
-2
@@ -145,7 +145,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -483,5 +_,28 @@
|
||||
@@ -483,5 +_,33 @@
|
||||
p_58342_.m_36491_(itemstack);
|
||||
}
|
||||
|
||||
@@ -168,9 +168,14 @@
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ protected void invalidateCaps() {
|
||||
+ public void invalidateCaps() {
|
||||
+ super.invalidateCaps();
|
||||
+ for (int x = 0; x < handlers.length; x++)
|
||||
+ handlers[x].invalidate();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void reviveCaps() {
|
||||
+ this.handlers = net.minecraftforge.items.wrapper.SidedInvWrapper.create(this, Direction.UP, Direction.DOWN, Direction.NORTH);
|
||||
}
|
||||
}
|
||||
+7
-2
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java
|
||||
+++ b/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java
|
||||
@@ -82,4 +_,21 @@
|
||||
@@ -82,4 +_,26 @@
|
||||
}
|
||||
|
||||
protected abstract AbstractContainerMenu m_6555_(int p_58627_, Inventory p_58628_);
|
||||
@@ -17,8 +17,13 @@
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ protected void invalidateCaps() {
|
||||
+ public void invalidateCaps() {
|
||||
+ super.invalidateCaps();
|
||||
+ itemHandler.invalidate();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void reviveCaps() {
|
||||
+ itemHandler = net.minecraftforge.common.util.LazyOptional.of(() -> createUnSidedHandler());
|
||||
+ }
|
||||
}
|
||||
+7
-2
@@ -51,7 +51,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,5 +_,28 @@
|
||||
@@ -260,5 +_,33 @@
|
||||
|
||||
protected AbstractContainerMenu m_6555_(int p_58990_, Inventory p_58991_) {
|
||||
return new BrewingStandMenu(p_58990_, p_58991_, this, this.f_58971_);
|
||||
@@ -74,9 +74,14 @@
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ protected void invalidateCaps() {
|
||||
+ public void invalidateCaps() {
|
||||
+ super.invalidateCaps();
|
||||
+ for (int x = 0; x < handlers.length; x++)
|
||||
+ handlers[x].invalidate();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void reviveCaps() {
|
||||
+ this.handlers = net.minecraftforge.items.wrapper.SidedInvWrapper.create(this, Direction.UP, Direction.DOWN, Direction.NORTH);
|
||||
}
|
||||
}
|
||||
+6
-4
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/level/block/entity/ChestBlockEntity.java
|
||||
+++ b/net/minecraft/world/level/block/entity/ChestBlockEntity.java
|
||||
@@ -162,6 +_,43 @@
|
||||
@@ -162,6 +_,45 @@
|
||||
return ChestMenu.m_39237_(p_59082_, p_59083_, this);
|
||||
}
|
||||
|
||||
@@ -35,10 +35,12 @@
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ protected void invalidateCaps() {
|
||||
+ public void invalidateCaps() {
|
||||
+ super.invalidateCaps();
|
||||
+ if (chestHandler != null)
|
||||
+ chestHandler.invalidate();
|
||||
+ if (chestHandler != null) {
|
||||
+ chestHandler.invalidate();
|
||||
+ chestHandler = null;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
public void m_155350_() {
|
||||
|
||||
@@ -755,14 +755,6 @@ public class ForgeHooks
|
||||
{
|
||||
EntityTravelToDimensionEvent event = new EntityTravelToDimensionEvent(entity, dimension);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
if (event.isCanceled())
|
||||
{
|
||||
// Revert variable back to true as it would have been set to false
|
||||
if (entity instanceof AbstractMinecartContainer)
|
||||
{
|
||||
((AbstractMinecartContainer) entity).dropContentsWhenDead(true);
|
||||
}
|
||||
}
|
||||
return !event.isCanceled();
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ public class ForgeInternalHandler
|
||||
Entity newEntity = item.createEntity(event.getWorld(), entity, stack);
|
||||
if (newEntity != null)
|
||||
{
|
||||
entity.remove(false);
|
||||
entity.discard();
|
||||
event.setCanceled(true);
|
||||
BlockableEventLoop<Runnable> executor = LogicalSidedProvider.WORKQUEUE.get(event.getWorld().isClientSide ? LogicalSide.CLIENT : LogicalSide.SERVER);
|
||||
executor.tell(new TickTask(0, () -> event.getWorld().addFreshEntity(newEntity)));
|
||||
@@ -124,7 +124,7 @@ public class ForgeInternalHandler
|
||||
new ForgeCommand(event.getDispatcher());
|
||||
ConfigCommand.register(event.getDispatcher());
|
||||
}
|
||||
|
||||
|
||||
private static LootModifierManager INSTANCE;
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
@@ -97,7 +97,15 @@ public abstract class CapabilityProvider<B extends CapabilityProvider<B>> implem
|
||||
}
|
||||
}
|
||||
|
||||
protected void invalidateCaps()
|
||||
/*
|
||||
* Invalidates all the contained caps, and prevents getCapability from returning a value.
|
||||
* This is usually called when the object in question is removed from the world.
|
||||
* However there may be cases where modders want to copy these 'invalid' caps.
|
||||
* They should call reviveCaps while they are doing their work, and then call invalidateCaps again
|
||||
* when they are finished.
|
||||
* Be sure to make your invalidate callbaks recursion safe.
|
||||
*/
|
||||
public void invalidateCaps()
|
||||
{
|
||||
this.valid = false;
|
||||
final CapabilityDispatcher disp = getCapabilities();
|
||||
@@ -105,7 +113,12 @@ public abstract class CapabilityProvider<B extends CapabilityProvider<B>> implem
|
||||
disp.invalidate();
|
||||
}
|
||||
|
||||
protected void reviveCaps()
|
||||
/*
|
||||
* This function will allow getCability to return values again.
|
||||
* Modders can use this if they need to copy caps from one removed provider to a new one.
|
||||
* It is expected the modders who call this function, then call invalidateCaps() to invalidate the provider again.
|
||||
*/
|
||||
public void reviveCaps()
|
||||
{
|
||||
this.valid = true; //Stupid players don't copy the entity when transporting across worlds.
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user