changes to entity load handler / not backwards compatible
This commit is contained in:
1 parent
f2aae4ec92
commit
481fc97545
4 files changed
+48
-6
No files matched your search
@@ -0,0 +1,38 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.script.CarpetEventServer;
|
||||
import carpet.script.CarpetScriptServer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.server.world.ServerEntityManager;
|
||||
import net.minecraft.world.entity.EntityLike;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(ServerEntityManager.class)
|
||||
public class ServerEntityManager_scarpetMixin
|
||||
{
|
||||
@Inject(method = "addEntity(Lnet/minecraft/world/entity/EntityLike;Z)Z", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/entity/EntityTrackingStatus;shouldTick()Z"
|
||||
))
|
||||
private void handleAddedEntity(EntityLike entityLike, boolean existing, CallbackInfoReturnable<Boolean> cir)
|
||||
{
|
||||
Entity entity = (Entity)entityLike;
|
||||
CarpetEventServer.Event event = CarpetEventServer.Event.ENTITY_LOAD.get(entity.getType());
|
||||
if (event != null)
|
||||
{
|
||||
if (event.isNeeded())
|
||||
{
|
||||
event.onEntityAction(entity, !existing);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CarpetScriptServer.LOG.error("Failed to handle entity type " + entity.getType().getTranslationKey());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,7 +26,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
import static carpet.script.CarpetEventServer.Event.ENTITY_LOAD;
|
||||
import static carpet.script.CarpetEventServer.Event.EXPLOSION;
|
||||
import static carpet.script.CarpetEventServer.Event.LIGHTNING;
|
||||
|
||||
@@ -46,6 +45,8 @@ public class ServerWorld_scarpetMixin implements ServerWorldInterface
|
||||
if (LIGHTNING.isNeeded()) LIGHTNING.onWorldEventFlag((ServerWorld) (Object)this, blockPos, bl2?1:0);
|
||||
}
|
||||
|
||||
/*
|
||||
moved to ServerEntityManager_scarpetMixin in 1.17
|
||||
@Redirect(method = "addEntity", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/world/ServerEntityManager;addEntity(Lnet/minecraft/world/entity/EntityLike;)Z"
|
||||
@@ -66,6 +67,7 @@ public class ServerWorld_scarpetMixin implements ServerWorldInterface
|
||||
};
|
||||
return success;
|
||||
}
|
||||
*/
|
||||
|
||||
@Inject(method = "createExplosion", at = @At("HEAD"))
|
||||
private void handleExplosion(/*@Nullable*/ Entity entity, /*@Nullable*/ DamageSource damageSource, /*@Nullable*/ ExplosionBehavior explosionBehavior, double d, double e, double f, float g, boolean bl, Explosion.DestructionType destructionType, CallbackInfoReturnable<Explosion> cir)
|
||||
|
||||
Reference in new issue
Block a user