more entity events and entity item api
This commit is contained in:
1 parent
25b37913f2
commit
06b3f7c532
9 files changed
+121
-21
No files matched your search
@@ -8,6 +8,7 @@ import carpet.script.ScriptHost;
|
||||
import carpet.script.value.Value;
|
||||
import carpet.settings.CarpetSettings;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.damage.DamageSource;
|
||||
import org.lwjgl.system.CallbackI;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -23,16 +24,11 @@ public abstract class Entity_scarpetEventsMixin implements EntityInterface
|
||||
@Shadow public boolean removed;
|
||||
private CarpetEventServer.ScheduledCall deathCall;
|
||||
private CarpetEventServer.ScheduledCall removeCall;
|
||||
private CarpetEventServer.ScheduledCall tickCall;
|
||||
private CarpetEventServer.ScheduledCall damageCall;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onDeathCallback(String reason)
|
||||
{
|
||||
if (deathCall != null)
|
||||
{
|
||||
CarpetServer.scriptServer.events.onEntityDeath(deathCall, (Entity)(Object)this, reason);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDeathCallback(CarpetContext cc, String function, List<Value> extraArgs)
|
||||
@@ -46,6 +42,47 @@ public abstract class Entity_scarpetEventsMixin implements EntityInterface
|
||||
removeCall = CarpetServer.scriptServer.events.makeRemovedCall(cc, function, extraArgs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTickCallback(CarpetContext cc, String function, List<Value> extraArgs)
|
||||
{
|
||||
tickCall = CarpetServer.scriptServer.events.makeTickCall(cc, function, extraArgs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDamageCallback(CarpetContext cc, String function, List<Value> extraArgs)
|
||||
{
|
||||
damageCall = CarpetServer.scriptServer.events.makeDamageCall(cc, function, extraArgs);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDeathCallback(String reason)
|
||||
{
|
||||
if (deathCall != null)
|
||||
{
|
||||
CarpetServer.scriptServer.events.onEntityDeath(deathCall, (Entity)(Object)this, reason);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDamageCallback(float amount, DamageSource source)
|
||||
{
|
||||
if (damageCall != null)
|
||||
{
|
||||
CarpetServer.scriptServer.events.onEntityDamage(damageCall, (Entity)(Object)this, amount, source);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Inject(method = "tick", at = @At("HEAD"))
|
||||
private void onTickCall(CallbackInfo ci)
|
||||
{
|
||||
if (tickCall != null)
|
||||
{
|
||||
CarpetServer.scriptServer.events.onEntityTick(tickCall, (Entity) (Object) this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Inject(method = "remove", at = @At("HEAD"))
|
||||
private void onRemove(CallbackInfo ci)
|
||||
|
||||
Reference in new issue
Block a user