24w39a
This commit is contained in:
1 parent
ad8680826d
commit
85d848c488
21 files changed
+80
-32
No files matched your search
+1
-1
@@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx1G
|
||||
|
||||
# Fabric Properties
|
||||
# check https://fabricmc.net/develop/
|
||||
minecraft_version=24w38a
|
||||
minecraft_version=24w39a
|
||||
loader_version=0.16.5
|
||||
jsr305_version=3.0.2
|
||||
fabric_version=0.102.0+1.21
|
||||
|
||||
@@ -304,7 +304,7 @@ public class SettingsManager {
|
||||
/**
|
||||
* Calling this method is not supported.
|
||||
*/
|
||||
public void inspectClientsideCommand(CommandSourceStack source, String string)
|
||||
public void inspectClientsideCommand(String string)
|
||||
{
|
||||
if (string.startsWith("/" + identifier + " "))
|
||||
{
|
||||
@@ -316,9 +316,9 @@ public class SettingsManager {
|
||||
if (rules.containsKey(rule) && rules.get(rule).canBeToggledClientSide())
|
||||
{
|
||||
try {
|
||||
rules.get(rule).set(source, strOption);
|
||||
rules.get(rule).set(null, strOption);
|
||||
} catch (InvalidRuleValueException e) {
|
||||
e.notifySource(rule, source);
|
||||
//e.notifySource(rule, source);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,7 +223,8 @@ public class PlayerCommand
|
||||
private static int kill(CommandContext<CommandSourceStack> context)
|
||||
{
|
||||
if (cantReMove(context)) return 0;
|
||||
getPlayer(context).kill();
|
||||
ServerPlayer player = getPlayer(context);
|
||||
player.kill(player.serverLevel());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package carpet.fakes;
|
||||
|
||||
public interface FoodDataInterface
|
||||
{
|
||||
float getCMExhaustionLevel();
|
||||
|
||||
void setExhaustion(float aFloat);
|
||||
}
|
||||
@@ -35,7 +35,7 @@ public abstract class ClientPacketListener_clientCommandMixin extends ClientComm
|
||||
if (CarpetServer.minecraft_server == null && !CarpetClient.isCarpet() && minecraft.player != null)
|
||||
{
|
||||
LocalPlayer playerSource = minecraft.player;
|
||||
CarpetServer.forEachManager(sm -> sm.inspectClientsideCommand(playerSource.createCommandSourceStack(), "/" + string));
|
||||
CarpetServer.forEachManager(sm -> sm.inspectClientsideCommand("/" + string));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.fakes.FoodDataInterface;
|
||||
import net.minecraft.world.food.FoodData;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(FoodData.class)
|
||||
public class FoodData_scarpetMixin implements FoodDataInterface
|
||||
{
|
||||
@Shadow private float exhaustionLevel;
|
||||
|
||||
@Override
|
||||
public float getCMExhaustionLevel()
|
||||
{
|
||||
return exhaustionLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExhaustion(float aFloat)
|
||||
{
|
||||
exhaustionLevel = aFloat;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
@@ -22,6 +23,6 @@ public abstract class LivingEntity_cleanLogsMixin extends Entity
|
||||
@Redirect(method = "die", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;hasCustomName()Z"))
|
||||
private boolean shouldLogDeaths(LivingEntity livingEntity)
|
||||
{
|
||||
return livingEntity.hasCustomName() && CarpetSettings.cleanLogs && level().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES);
|
||||
return livingEntity.hasCustomName() && CarpetSettings.cleanLogs && livingEntity.getServer().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES);
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,7 @@ public abstract class LivingEntity_maxCollisionsMixin extends Entity
|
||||
int maxEntityCramming =-1;
|
||||
if (CarpetSettings.maxEntityCollisions > 0)
|
||||
{
|
||||
maxEntityCramming = this.level().getGameRules().getInt(GameRules.RULE_MAX_ENTITY_CRAMMING);
|
||||
maxEntityCramming = this.getServer().getGameRules().getInt(GameRules.RULE_MAX_ENTITY_CRAMMING);
|
||||
entities = ((LevelInterface) this.level()).getOtherEntitiesLimited(
|
||||
this,
|
||||
this.getBoundingBox(),
|
||||
@@ -50,7 +50,7 @@ public abstract class LivingEntity_maxCollisionsMixin extends Entity
|
||||
}
|
||||
|
||||
if (!entities.isEmpty()) {
|
||||
if (maxEntityCramming < 0) maxEntityCramming = this.level().getGameRules().getInt(GameRules.RULE_MAX_ENTITY_CRAMMING);
|
||||
if (maxEntityCramming < 0) maxEntityCramming = this.getServer().getGameRules().getInt(GameRules.RULE_MAX_ENTITY_CRAMMING);
|
||||
if (maxEntityCramming > 0 && entities.size() > maxEntityCramming - 1 && this.random.nextInt(4) == 0) {
|
||||
int candidates = 0;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package carpet.mixins;
|
||||
import carpet.fakes.EntityInterface;
|
||||
import carpet.fakes.LivingEntityInterface;
|
||||
import carpet.script.EntityEventsGroup;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
@@ -42,7 +43,7 @@ public abstract class LivingEntity_scarpetEventsMixin extends Entity implements
|
||||
target = "Lnet/minecraft/world/entity/LivingEntity;getDamageAfterArmorAbsorb(Lnet/minecraft/world/damagesource/DamageSource;F)F",
|
||||
shift = At.Shift.BEFORE
|
||||
))
|
||||
private void entityTakingDamage(DamageSource source, float amount, CallbackInfo ci)
|
||||
private void entityTakingDamage(ServerLevel serverLevel, DamageSource source, float amount, CallbackInfo ci)
|
||||
{
|
||||
((EntityInterface)this).getEventContainer().onEvent(EntityEventsGroup.Event.ON_DAMAGE, amount, source);
|
||||
// this is not applicable since its not a playr for sure
|
||||
|
||||
@@ -2,6 +2,7 @@ package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
@@ -57,7 +58,7 @@ public abstract class Player_parrotMixin extends LivingEntity
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "hurt", at = @At(value = "INVOKE",
|
||||
@Redirect(method = "hurtServer", at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/entity/player/Player;removeEntitiesOnShoulder()V"))
|
||||
private void cancelDropShoulderEntities2(Player playerEntity)
|
||||
{
|
||||
@@ -76,9 +77,9 @@ public abstract class Player_parrotMixin extends LivingEntity
|
||||
this.setShoulderEntityRight(new CompoundTag());
|
||||
}
|
||||
|
||||
@Inject(method = "hurt", at = @At(value = "INVOKE", shift = At.Shift.BEFORE,
|
||||
@Inject(method = "hurtServer", at = @At(value = "INVOKE", shift = At.Shift.BEFORE,
|
||||
target = "Lnet/minecraft/world/entity/player/Player;removeEntitiesOnShoulder()V"))
|
||||
private void onDamage(DamageSource damageSource_1, float float_1, CallbackInfoReturnable<Boolean> cir)
|
||||
private void onDamage(ServerLevel serverLevel, DamageSource damageSource_1, float float_1, CallbackInfoReturnable<Boolean> cir)
|
||||
{
|
||||
if (CarpetSettings.persistentParrots && !this.isShiftKeyDown())
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@ package carpet.mixins;
|
||||
|
||||
import carpet.fakes.EntityInterface;
|
||||
import carpet.script.EntityEventsGroup;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
@@ -36,7 +37,7 @@ public abstract class Player_scarpetEventsMixin extends LivingEntity
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/entity/player/Player;getDamageAfterArmorAbsorb(Lnet/minecraft/world/damagesource/DamageSource;F)F"
|
||||
))
|
||||
private void playerTakingDamage(DamageSource source, float amount, CallbackInfo ci)
|
||||
private void playerTakingDamage(ServerLevel serverLevel, DamageSource source, float amount, CallbackInfo ci)
|
||||
{
|
||||
// version of LivingEntity_scarpetEventsMixin::entityTakingDamage
|
||||
((EntityInterface)this).getEventContainer().onEvent(EntityEventsGroup.Event.ON_DAMAGE, amount, source);
|
||||
|
||||
@@ -44,6 +44,8 @@ import static carpet.script.CarpetEventServer.Event.CHUNK_UNLOADED;
|
||||
public abstract class ServerLevel_scarpetMixin extends Level implements ServerWorldInterface
|
||||
{
|
||||
|
||||
@Shadow public abstract GameRules getGameRules();
|
||||
|
||||
protected ServerLevel_scarpetMixin(WritableLevelData writableLevelData, ResourceKey<Level> resourceKey, RegistryAccess registryAccess, Holder<DimensionType> holder, boolean bl, boolean bl2, long l, int i)
|
||||
{
|
||||
super(writableLevelData, resourceKey, registryAccess, holder, bl, bl2, l, i);
|
||||
|
||||
@@ -2,6 +2,7 @@ package carpet.mixins;
|
||||
|
||||
import carpet.utils.WoolTool;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.WoolCarpetBlock;
|
||||
@@ -17,12 +18,13 @@ public abstract class WoolCarpetBlock_placeMixin extends Block
|
||||
super(block$Settings_1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context)
|
||||
{
|
||||
BlockState state = super.getStateForPlacement(context);
|
||||
if (context.getPlayer() != null && !context.getLevel().isClientSide)
|
||||
{ // getColor()
|
||||
WoolTool.carpetPlacedAction(((WoolCarpetBlock)(Object)this).getColor(), context.getPlayer(), context.getClickedPos(), (ServerLevel) context.getLevel());
|
||||
WoolTool.carpetPlacedAction(((WoolCarpetBlock)(Object)this).getColor(), (ServerPlayer) context.getPlayer(), context.getClickedPos(), (ServerLevel) context.getLevel());
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ public class EntityPlayerMPFake extends ServerPlayer
|
||||
}
|
||||
|
||||
@Override
|
||||
public void kill()
|
||||
public void kill(ServerLevel level)
|
||||
{
|
||||
kill(Messenger.s("Killed"));
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.minecraft.network.chat.HoverEvent;
|
||||
import net.minecraft.network.chat.Style;
|
||||
import net.minecraft.network.chat.TextColor;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
@@ -243,7 +244,7 @@ public class Messenger
|
||||
}
|
||||
public static void m(Player player, Object ... fields)
|
||||
{
|
||||
player.sendSystemMessage(Messenger.c(fields));
|
||||
((ServerPlayer)player).sendSystemMessage(Messenger.c(fields));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -287,7 +288,7 @@ public class Messenger
|
||||
|
||||
public static void send(Player player, Collection<Component> lines)
|
||||
{
|
||||
lines.forEach(message -> player.sendSystemMessage(message));
|
||||
lines.forEach(message -> ((ServerPlayer)player).sendSystemMessage(message));
|
||||
}
|
||||
public static void send(CommandSourceStack source, Collection<Component> lines)
|
||||
{
|
||||
@@ -301,7 +302,7 @@ public class Messenger
|
||||
LOG.error("Message not delivered: "+message);
|
||||
server.sendSystemMessage(Component.literal(message));
|
||||
Component txt = c("gi "+message);
|
||||
for (Player entityplayer : server.getPlayerList().getPlayers())
|
||||
for (ServerPlayer entityplayer : server.getPlayerList().getPlayers())
|
||||
{
|
||||
entityplayer.sendSystemMessage(txt);
|
||||
}
|
||||
@@ -311,7 +312,7 @@ public class Messenger
|
||||
if (server == null)
|
||||
LOG.error("Message not delivered: "+message.getString());
|
||||
server.sendSystemMessage(message);
|
||||
for (Player entityplayer : server.getPlayerList().getPlayers())
|
||||
for (ServerPlayer entityplayer : server.getPlayerList().getPlayers())
|
||||
{
|
||||
entityplayer.sendSystemMessage(message);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
@@ -60,7 +61,7 @@ public class WoolTool
|
||||
* <li>Green - Prints the contents of the counter of the colour of wool underneath the carpet</li>
|
||||
* </ul>
|
||||
*/
|
||||
public static void carpetPlacedAction(DyeColor color, Player placer, BlockPos pos, ServerLevel worldIn)
|
||||
public static void carpetPlacedAction(DyeColor color, ServerPlayer placer, BlockPos pos, ServerLevel worldIn)
|
||||
{
|
||||
if (!CarpetSettings.carpets)
|
||||
{
|
||||
|
||||
@@ -149,6 +149,7 @@
|
||||
"SystemReport_addScarpetAppsMixin",
|
||||
"CommandNode_scarpetCommandsMixin",
|
||||
"CommandDispatcher_scarpetCommandsMixin",
|
||||
"FoodData_scarpetMixin",
|
||||
|
||||
"RecipeManager_scarpetMixin",
|
||||
"BlockInput_scarpetMixin",
|
||||
|
||||
Reference in new issue
Block a user