mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-19 03:49:14 +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
@@ -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