entity events
This commit is contained in:
1 parent
afb80b62b4
commit
32dc6b17e8
7 files changed
+119
No files matched your search
@@ -6,6 +6,7 @@ import carpet.script.value.EntityValue;
|
||||
import carpet.script.value.ListValue;
|
||||
import carpet.script.value.NumericValue;
|
||||
import carpet.script.value.StringValue;
|
||||
import carpet.settings.CarpetSettings;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
@@ -74,6 +75,11 @@ public class CarpetEventServer
|
||||
{
|
||||
CarpetServer.scriptServer.runas(context_origin, context_source, host, udf, args);
|
||||
}
|
||||
|
||||
public void execute(List<LazyValue> args)
|
||||
{
|
||||
CarpetServer.scriptServer.runas(context_origin, context_source, host, udf, args);
|
||||
}
|
||||
}
|
||||
|
||||
public static class CallbackList
|
||||
@@ -347,4 +353,20 @@ public class CarpetEventServer
|
||||
{
|
||||
eventHandlers.get("player_stops_sprinting").call( () -> Arrays.asList(((c, t) -> new EntityValue(player))), player::getCommandSource);
|
||||
}
|
||||
|
||||
public ScheduledCall makeDeathCall(CarpetContext cc, String function)
|
||||
{
|
||||
UserDefinedFunction udf = cc.host.globalFunctions.get(function);
|
||||
if (udf == null || udf.getArguments().size() != 2)
|
||||
{
|
||||
// call won't match arguments
|
||||
return null;
|
||||
}
|
||||
return new ScheduledCall(cc, function, null, 0);
|
||||
}
|
||||
|
||||
public void onEntityDeath(ScheduledCall call, Entity e, String reason)
|
||||
{
|
||||
call.execute( Arrays.asList( (c, t)-> new EntityValue(e), (c, t)-> new StringValue(reason)));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user