entity events
This commit is contained in:
1 parent
afb80b62b4
commit
32dc6b17e8
7 files changed
+119
No files matched your search
@@ -1,8 +1,12 @@
|
||||
package carpet.script.value;
|
||||
|
||||
import carpet.fakes.EntityInterface;
|
||||
import carpet.fakes.MobEntityInterface;
|
||||
import carpet.helpers.Tracer;
|
||||
import carpet.script.CarpetContext;
|
||||
import carpet.script.Fluff;
|
||||
import carpet.script.exception.InternalExpressionException;
|
||||
import carpet.settings.CarpetSettings;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import net.minecraft.client.network.packet.EntityPositionS2CPacket;
|
||||
@@ -427,6 +431,7 @@ public class EntityValue extends Value
|
||||
|
||||
private static void updateVelocity(Entity e)
|
||||
{
|
||||
e.velocityModified = true;
|
||||
((ServerWorld)e.getEntityWorld()).method_14178().sendToNearbyPlayers(e, new EntityVelocityUpdateS2CPacket(e));
|
||||
}
|
||||
|
||||
@@ -680,6 +685,7 @@ public class EntityValue extends Value
|
||||
}
|
||||
}); //requires mixing
|
||||
|
||||
|
||||
// gamemode
|
||||
// spectate
|
||||
// "fire"
|
||||
@@ -697,4 +703,15 @@ public class EntityValue extends Value
|
||||
// "jump"
|
||||
// "nbt" <-big one, for now use run('data merge entity ...
|
||||
}};
|
||||
|
||||
public void setEvent(CarpetContext cc, String event, String fun)
|
||||
{
|
||||
if (!(events.containsKey(event)))
|
||||
throw new InternalExpressionException("unknown entity event: " + event);
|
||||
events.get(event).accept(cc, entity, fun);
|
||||
}
|
||||
|
||||
private static Map<String, Fluff.TriConsumer<CarpetContext, Entity, String>> events = new HashMap<String, Fluff.TriConsumer<CarpetContext, Entity, String>>() {{
|
||||
put("on_death", (c, e, f) -> { ((EntityInterface)e).setDeathCallback(c, f); });
|
||||
}};
|
||||
}
|
||||
Reference in new issue
Block a user