24w39a
This commit is contained in:
1 parent
ad8680826d
commit
85d848c488
21 files changed
+80
-32
No files matched your search
@@ -884,7 +884,7 @@ public class CarpetEventServer
|
||||
new NumericValue(amount),
|
||||
StringValue.of(source.getMsgId()),
|
||||
source.getEntity() == null ? Value.NULL : new EntityValue(source.getEntity())
|
||||
), target::createCommandSourceStack);
|
||||
), () -> target.getServer().createCommandSourceStack());
|
||||
}
|
||||
};
|
||||
public static final Event PLAYER_DEALS_DAMAGE = new Event("player_deals_damage", 3, false)
|
||||
@@ -894,7 +894,7 @@ public class CarpetEventServer
|
||||
{
|
||||
return handler.call(() ->
|
||||
Arrays.asList(new EntityValue(source.getEntity()), new NumericValue(amount), new EntityValue(target)),
|
||||
() -> source.getEntity().createCommandSourceStack()
|
||||
() -> source.getEntity().getServer().createCommandSourceStack()
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -16,8 +16,11 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public class EntityEventsGroup
|
||||
@@ -167,7 +170,7 @@ public class EntityEventsGroup
|
||||
public CarpetEventServer.CallbackResult call(CarpetEventServer.Callback tickCall, Entity entity, Object... args)
|
||||
{
|
||||
assert args.length == argcount - 1;
|
||||
return tickCall.execute(entity.createCommandSourceStack(), makeArgs(entity, args));
|
||||
return tickCall.execute((entity instanceof ServerPlayer player ? player.createCommandSourceStack() : entity.getServer().createCommandSourceStack()), makeArgs(entity, args));
|
||||
}
|
||||
|
||||
protected List<Value> makeArgs(Entity entity, Object... args)
|
||||
|
||||
@@ -67,11 +67,11 @@ public class SnoopyCommandSource extends CommandSourceStack
|
||||
|
||||
public SnoopyCommandSource(ServerPlayer player, Component[] error, List<Component> output)
|
||||
{
|
||||
super(player, player.position(), player.getRotationVector(),
|
||||
super(player.commandSource(), player.position(), player.getRotationVector(),
|
||||
player.level() instanceof final ServerLevel serverLevel ? serverLevel : null,
|
||||
player.server.getProfilePermissions(player.getGameProfile()), player.getName().getString(), player.getDisplayName(),
|
||||
player.level().getServer(), player);
|
||||
this.output = player;
|
||||
this.output = player.commandSource();
|
||||
this.position = player.position();
|
||||
this.world = player.level() instanceof final ServerLevel serverLevel ? serverLevel : null;
|
||||
this.level = player.server.getProfilePermissions(player.getGameProfile());
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package carpet.script.value;
|
||||
|
||||
import carpet.fakes.FoodDataInterface;
|
||||
import carpet.script.external.Vanilla;
|
||||
import carpet.script.utils.Tracer;
|
||||
import carpet.script.CarpetContext;
|
||||
@@ -302,11 +303,11 @@ public class EntityValue extends Value
|
||||
EntityType.TRIDENT, EntityType.WITHER_SKULL, EntityType.FISHING_BOBBER, EntityType.SHULKER_BULLET
|
||||
);
|
||||
Set<EntityType<?>> deads = Set.of(
|
||||
EntityType.AREA_EFFECT_CLOUD, EntityType.MARKER, EntityType.BOAT, EntityType.END_CRYSTAL,
|
||||
EntityType.AREA_EFFECT_CLOUD, EntityType.MARKER, EntityType.END_CRYSTAL,
|
||||
EntityType.EVOKER_FANGS, EntityType.EXPERIENCE_ORB, EntityType.EYE_OF_ENDER,
|
||||
EntityType.FALLING_BLOCK, EntityType.ITEM, EntityType.ITEM_FRAME, EntityType.GLOW_ITEM_FRAME,
|
||||
EntityType.LEASH_KNOT, EntityType.LIGHTNING_BOLT, EntityType.PAINTING,
|
||||
EntityType.TNT, EntityType.ARMOR_STAND, EntityType.CHEST_BOAT
|
||||
EntityType.TNT, EntityType.ARMOR_STAND
|
||||
|
||||
);
|
||||
Set<EntityType<?>> minecarts = Set.of(
|
||||
@@ -336,7 +337,7 @@ public class EntityValue extends Value
|
||||
);
|
||||
|
||||
Set<EntityType<?>> living = allTypes.stream().filter(et ->
|
||||
!deads.contains(et) && !projectiles.contains(et) && !minecarts.contains(et)
|
||||
!deads.contains(et) && !projectiles.contains(et) && !minecarts.contains(et) && !et.is(EntityTypeTags.BOAT)
|
||||
).collect(Collectors.toSet());
|
||||
|
||||
Set<EntityType<?>> regular = allTypes.stream().filter(et ->
|
||||
@@ -550,7 +551,7 @@ public class EntityValue extends Value
|
||||
put("persistence", (e, a) -> e instanceof Mob mob ? BooleanValue.of(mob.isPersistenceRequired()) : Value.NULL);
|
||||
put("hunger", (e, a) -> e instanceof Player player ? new NumericValue(player.getFoodData().getFoodLevel()) : Value.NULL);
|
||||
put("saturation", (e, a) -> e instanceof Player player ? new NumericValue(player.getFoodData().getSaturationLevel()) : Value.NULL);
|
||||
put("exhaustion", (e, a) -> e instanceof Player player ? new NumericValue(player.getFoodData().getExhaustionLevel()) : Value.NULL);
|
||||
put("exhaustion", (e, a) -> e instanceof Player player ? new NumericValue(((FoodDataInterface)player.getFoodData()).getCMExhaustionLevel()) : Value.NULL);
|
||||
put("absorption", (e, a) -> e instanceof Player player ? new NumericValue(player.getAbsorptionAmount()) : Value.NULL);
|
||||
put("xp", (e, a) -> e instanceof Player player ? new NumericValue(player.totalExperience) : Value.NULL);
|
||||
put("xp_level", (e, a) -> e instanceof Player player ? new NumericValue(player.experienceLevel) : Value.NULL);
|
||||
@@ -1040,7 +1041,7 @@ public class EntityValue extends Value
|
||||
|
||||
}
|
||||
});*/
|
||||
put("kill", (e, v) -> e.kill());
|
||||
put("kill", (e, v) -> e.kill((ServerLevel) e.level()));
|
||||
put("location", (e, v) ->
|
||||
{
|
||||
if (!(v instanceof ListValue lv))
|
||||
@@ -1605,7 +1606,7 @@ public class EntityValue extends Value
|
||||
put("exhaustion", (e, v) -> {
|
||||
if (e instanceof Player p)
|
||||
{
|
||||
p.getFoodData().setExhaustion(NumericValue.asNumber(v).getFloat());
|
||||
((FoodDataInterface)p.getFoodData()).setExhaustion(NumericValue.asNumber(v).getFloat());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user