falling blocks can also tick

This commit is contained in:
gnembon committed 2019-10-30 01:23:52 -03:00
1 parent 6c2ddd68db
commit 5bb959a853
4 files changed
+31

No files matched your search

@@ -18,4 +18,5 @@ public interface EntityInterface
void setDamageCallback(CarpetContext cc, String function, List<Value> extraArgs);
void setRemovedCallback(CarpetContext cc, String function, List<Value> extraArgs);
void setTickCallback(CarpetContext cc, String function, List<Value> extraArgs);
CarpetEventServer.ScheduledCall getTickCallback();
}
@@ -48,6 +48,12 @@ public abstract class Entity_scarpetEventsMixin implements EntityInterface
tickCall = CarpetServer.scriptServer.events.makeTickCall(cc, function, extraArgs);
}
@Override
public CarpetEventServer.ScheduledCall getTickCallback()
{
return tickCall;
}
@Override
public void setDamageCallback(CarpetContext cc, String function, List<Value> extraArgs)
{
@@ -0,0 +1,23 @@
package carpet.mixins;
import carpet.CarpetServer;
import carpet.fakes.EntityInterface;
import net.minecraft.entity.Entity;
import net.minecraft.entity.FallingBlockEntity;
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.CallbackInfo;
@Mixin(FallingBlockEntity.class)
public class FallingBlockEntity_scarpetEventsMixin
{
@Inject(method = "tick", at = @At("HEAD"))
private void onTickCall(CallbackInfo ci)
{
if (((EntityInterface)this).getTickCallback() != null)
{
CarpetServer.scriptServer.events.onEntityTick(((EntityInterface)this).getTickCallback(), (Entity) (Object) this);
}
}
}
+1
View File
@@ -128,6 +128,7 @@
"LivingEntity_scarpetEventsMixin",
"DamageTracker_scarpetEventMixin",
"ServerPlayerEntity_scarpetEventMixin",
"FallingBlockEntity_scarpetEventsMixin",
"PistonBlock_movableTEMixin",