cleanup of scarpet dependencies
This commit is contained in:
1 parent
fd93785fec
commit
75d94b0570
71 files changed
+1623
-1014
No files matched your search
@@ -3,7 +3,6 @@ package carpet.script.value;
|
||||
import carpet.script.exception.InternalExpressionException;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class AbstractListValue extends Value implements Iterable<Value>
|
||||
|
||||
@@ -21,7 +21,6 @@ import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Direction.Axis;
|
||||
import net.minecraft.core.GlobalPos;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.StringTag;
|
||||
@@ -38,7 +37,6 @@ import net.minecraft.world.level.block.state.properties.Property;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static carpet.script.value.NBTSerializableValue.nameFromRegistryId;
|
||||
|
||||
@@ -46,7 +44,6 @@ public class BlockValue extends Value
|
||||
{
|
||||
private BlockState blockState;
|
||||
private final BlockPos pos;
|
||||
@NotNull
|
||||
private final Level world;
|
||||
private CompoundTag data;
|
||||
|
||||
@@ -143,7 +140,7 @@ public class BlockValue extends Value
|
||||
}
|
||||
|
||||
|
||||
public BlockValue(final BlockState state, @NotNull final Level world, final BlockPos position)
|
||||
public BlockValue(final BlockState state, final Level world, final BlockPos position)
|
||||
{
|
||||
this.world = world;
|
||||
blockState = state;
|
||||
@@ -151,7 +148,7 @@ public class BlockValue extends Value
|
||||
data = null;
|
||||
}
|
||||
|
||||
public BlockValue(final BlockState state, @NotNull final Level world, final BlockPos position, final CompoundTag nbt)
|
||||
public BlockValue(final BlockState state, final Level world, final BlockPos position, final CompoundTag nbt)
|
||||
{
|
||||
this.world = world;
|
||||
blockState = state;
|
||||
|
||||
@@ -1,19 +1,14 @@
|
||||
package carpet.script.value;
|
||||
|
||||
import carpet.fakes.EntityInterface;
|
||||
import carpet.fakes.ItemEntityInterface;
|
||||
import carpet.fakes.LivingEntityInterface;
|
||||
import carpet.fakes.MobEntityInterface;
|
||||
import carpet.fakes.ServerPlayerEntityInterface;
|
||||
import carpet.fakes.ServerPlayerInteractionManagerInterface;
|
||||
import carpet.helpers.Tracer;
|
||||
import carpet.network.ServerNetworkHandler;
|
||||
import carpet.patches.EntityPlayerMPFake;
|
||||
import carpet.script.external.Vanilla;
|
||||
import carpet.script.utils.Tracer;
|
||||
import carpet.script.CarpetContext;
|
||||
import carpet.script.CarpetScriptServer;
|
||||
import carpet.script.EntityEventsGroup;
|
||||
import carpet.script.argument.Vector3Argument;
|
||||
import carpet.script.exception.InternalExpressionException;
|
||||
import carpet.script.external.Carpet;
|
||||
import carpet.script.utils.EntityTools;
|
||||
import carpet.script.utils.InputValidator;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
@@ -96,7 +91,6 @@ import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static carpet.script.value.NBTSerializableValue.nameFromRegistryId;
|
||||
import static carpet.utils.MobAI.genericJump;
|
||||
|
||||
// TODO: decide whether copy(entity) should duplicate entity in the world.
|
||||
public class EntityValue extends Value
|
||||
@@ -136,7 +130,7 @@ public class EntityValue extends Value
|
||||
|
||||
public Entity getEntity()
|
||||
{
|
||||
if (entity instanceof ServerPlayer && ((ServerPlayerEntityInterface) entity).isInvalidEntityObject())
|
||||
if (entity instanceof final ServerPlayer serverPlayer && Vanilla.ServerPlayer_isInvalidEntityObject(serverPlayer))
|
||||
{
|
||||
final ServerPlayer newPlayer = entity.getServer().getPlayerList().getPlayer(entity.getUUID());
|
||||
if (newPlayer != null)
|
||||
@@ -449,7 +443,7 @@ public class EntityValue extends Value
|
||||
put("is_ridden", (e, a) -> BooleanValue.of(e.isVehicle()));
|
||||
put("passengers", (e, a) -> ListValue.wrap(e.getPassengers().stream().map(EntityValue::new)));
|
||||
put("mount", (e, a) -> (e.getVehicle() != null) ? new EntityValue(e.getVehicle()) : Value.NULL);
|
||||
put("unmountable", (e, a) -> BooleanValue.of(((EntityInterface) e).isPermanentVehicle()));
|
||||
put("unmountable", (e, a) -> BooleanValue.of(Vanilla.Entity_isPermanentVehicle(e)));
|
||||
// deprecated
|
||||
put("tags", (e, a) -> ListValue.wrap(e.getTags().stream().map(StringValue::new)));
|
||||
|
||||
@@ -505,9 +499,9 @@ public class EntityValue extends Value
|
||||
put("offering_flower", (e, a) -> e instanceof final IronGolem ig ? BooleanValue.of(ig.getOfferFlowerTick() > 0) : Value.NULL);
|
||||
put("item", (e, a) -> e instanceof final ItemEntity ie ? ValueConversions.of(ie.getItem(), e.getServer().registryAccess()) : e instanceof final ItemFrame frame ? ValueConversions.of(frame.getItem(), e.getServer().registryAccess()) : Value.NULL);
|
||||
put("count", (e, a) -> (e instanceof final ItemEntity ie) ? new NumericValue(ie.getItem().getCount()) : Value.NULL);
|
||||
put("pickup_delay", (e, a) -> (e instanceof ItemEntity) ? new NumericValue(((ItemEntityInterface) e).getPickupDelayCM()) : Value.NULL);
|
||||
put("portal_cooldown", (e, a) -> new NumericValue(((EntityInterface) e).getPublicNetherPortalCooldown()));
|
||||
put("portal_timer", (e, a) -> new NumericValue(((EntityInterface) e).getPortalTimer()));
|
||||
put("pickup_delay", (e, a) -> (e instanceof final ItemEntity ie) ? new NumericValue(Vanilla.ItemEntity_getPickupDelay(ie)) : Value.NULL);
|
||||
put("portal_cooldown", (e, a) -> new NumericValue(Vanilla.Entity_getPublicNetherPortalCooldown(e)));
|
||||
put("portal_timer", (e, a) -> new NumericValue(Vanilla.Entity_getPortalTimer(e)));
|
||||
// ItemEntity -> despawn timer via ssGetAge
|
||||
put("is_baby", (e, a) -> (e instanceof final LivingEntity le) ? BooleanValue.of(le.isBaby()) : Value.NULL);
|
||||
put("target", (e, a) -> {
|
||||
@@ -544,7 +538,7 @@ public class EntityValue extends Value
|
||||
put("swimming", (e, a) -> e.isSwimming() ? Value.TRUE : Value.FALSE);
|
||||
put("swinging", (e, a) -> e instanceof final LivingEntity le ? BooleanValue.of(le.swinging) : Value.NULL);
|
||||
put("air", (e, a) -> new NumericValue(e.getAirSupply()));
|
||||
put("language", (e, a) -> !(e instanceof ServerPlayer) ? NULL : StringValue.of(((ServerPlayerEntityInterface) e).getLanguage()));
|
||||
put("language", (e, a) -> !(e instanceof final ServerPlayer p) ? NULL : StringValue.of(Vanilla.ServerPlayer_getLanguage(p)));
|
||||
put("persistence", (e, a) -> e instanceof final Mob mob ? BooleanValue.of(mob.isPersistenceRequired()) : Value.NULL);
|
||||
put("hunger", (e, a) -> e instanceof final Player player ? new NumericValue(player.getFoodData().getFoodLevel()) : Value.NULL);
|
||||
put("saturation", (e, a) -> e instanceof final Player player ? new NumericValue(player.getFoodData().getSaturationLevel()) : Value.NULL);
|
||||
@@ -554,7 +548,7 @@ public class EntityValue extends Value
|
||||
put("xp_level", (e, a) -> e instanceof final Player player ? new NumericValue(player.experienceLevel) : Value.NULL);
|
||||
put("xp_progress", (e, a) -> e instanceof final Player player ? new NumericValue(player.experienceProgress) : Value.NULL);
|
||||
put("score", (e, a) -> e instanceof final Player player ? new NumericValue(player.getScore()) : Value.NULL);
|
||||
put("jumping", (e, a) -> e instanceof LivingEntity ? ((LivingEntityInterface) e).isJumpingCM() ? Value.TRUE : Value.FALSE : Value.NULL);
|
||||
put("jumping", (e, a) -> e instanceof final LivingEntity le ? Vanilla.LivingEntity_isJumping(le) ? Value.TRUE : Value.FALSE : Value.NULL);
|
||||
put("gamemode", (e, a) -> e instanceof final ServerPlayer sp ? new StringValue(sp.gameMode.getGameModeForPlayer().getName()) : Value.NULL);
|
||||
put("path", (e, a) -> {
|
||||
if (e instanceof final Mob mob)
|
||||
@@ -610,9 +604,10 @@ public class EntityValue extends Value
|
||||
put("player_type", (e, a) -> {
|
||||
if (e instanceof final Player p)
|
||||
{
|
||||
if (e instanceof final EntityPlayerMPFake fake)
|
||||
final String moddedType = Carpet.isModdedPlayer(p);
|
||||
if (moddedType != null)
|
||||
{
|
||||
return new StringValue(fake.isAShadow ? "shadow" : "fake");
|
||||
return StringValue.of(moddedType);
|
||||
}
|
||||
final MinecraftServer server = p.getCommandSenderWorld().getServer();
|
||||
if (server.isDedicatedServer())
|
||||
@@ -635,7 +630,7 @@ public class EntityValue extends Value
|
||||
return Value.NULL;
|
||||
});
|
||||
|
||||
put("client_brand", (e, a) -> e instanceof final ServerPlayer sp ? StringValue.of(ServerNetworkHandler.getPlayerStatus(sp)) : Value.NULL);
|
||||
put("client_brand", (e, a) -> e instanceof final ServerPlayer sp ? StringValue.of(Carpet.getPlayerStatus(sp)) : Value.NULL);
|
||||
put("team", (e, a) -> e.getTeam() == null ? Value.NULL : new StringValue(e.getTeam().getName()));
|
||||
put("ping", (e, a) -> e instanceof final ServerPlayer sp ? new NumericValue(sp.latency) : Value.NULL);
|
||||
|
||||
@@ -703,8 +698,7 @@ public class EntityValue extends Value
|
||||
put("active_block", (e, a) -> {
|
||||
if (e instanceof final ServerPlayer sp)
|
||||
{
|
||||
final ServerPlayerInteractionManagerInterface manager = (ServerPlayerInteractionManagerInterface) (sp.gameMode);
|
||||
final BlockPos pos = manager.getCurrentBreakingBlock();
|
||||
final BlockPos pos = Vanilla.ServerPlayerGameMode_getCurrentBlockPosition(sp.gameMode);
|
||||
if (pos == null)
|
||||
{
|
||||
return Value.NULL;
|
||||
@@ -717,8 +711,7 @@ public class EntityValue extends Value
|
||||
put("breaking_progress", (e, a) -> {
|
||||
if (e instanceof final ServerPlayer sp)
|
||||
{
|
||||
final ServerPlayerInteractionManagerInterface manager = (ServerPlayerInteractionManagerInterface) (sp.gameMode);
|
||||
final int progress = manager.getCurrentBlockBreakingProgress();
|
||||
final int progress = Vanilla.ServerPlayerGameMode_getCurrentBlockBreakingProgress (sp.gameMode);
|
||||
return progress < 0 ? Value.NULL : new NumericValue(progress);
|
||||
}
|
||||
return Value.NULL;
|
||||
@@ -1204,7 +1197,7 @@ public class EntityValue extends Value
|
||||
|
||||
put("persistence", (e, v) ->
|
||||
{
|
||||
if (!(e instanceof Mob))
|
||||
if (!(e instanceof final Mob mob))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -1212,7 +1205,7 @@ public class EntityValue extends Value
|
||||
{
|
||||
v = Value.TRUE;
|
||||
}
|
||||
((MobEntityInterface) e).setPersistence(v.getBoolean());
|
||||
Vanilla.Mob_setPersistence(mob, v.getBoolean());
|
||||
});
|
||||
|
||||
put("dismount", (e, v) -> e.stopRiding());
|
||||
@@ -1226,7 +1219,7 @@ public class EntityValue extends Value
|
||||
sp.connection.send(new ClientboundSetPassengersPacket(e));
|
||||
}
|
||||
});
|
||||
put("unmountable", (e, v) -> ((EntityInterface) e).setPermanentVehicle(v == null || v.getBoolean()));
|
||||
put("unmountable", (e, v) -> Vanilla.Entity_setPermanentVehicle(e, v == null || v.getBoolean()));
|
||||
put("drop_passengers", (e, v) -> e.ejectPassengers());
|
||||
put("mount_passengers", (e, v) -> {
|
||||
if (v == null)
|
||||
@@ -1316,8 +1309,8 @@ public class EntityValue extends Value
|
||||
if (v.isNull())
|
||||
{
|
||||
ec.restrictTo(BlockPos.ZERO, -1);
|
||||
final Map<String, Goal> tasks = ((MobEntityInterface) ec).getTemporaryTasks();
|
||||
((MobEntityInterface) ec).getAI(false).removeGoal(tasks.get("home"));
|
||||
final Map<String, Goal> tasks = Vanilla.Mob_getTemporaryTasks(ec);
|
||||
Vanilla.Mob_getAI(ec, false).removeGoal(tasks.get("home"));
|
||||
tasks.remove("home");
|
||||
return;
|
||||
}
|
||||
@@ -1349,12 +1342,12 @@ public class EntityValue extends Value
|
||||
}
|
||||
|
||||
ec.restrictTo(pos, distance);
|
||||
final Map<String, Goal> tasks = ((MobEntityInterface) ec).getTemporaryTasks();
|
||||
final Map<String, Goal> tasks = Vanilla.Mob_getTemporaryTasks(ec);
|
||||
if (!tasks.containsKey("home"))
|
||||
{
|
||||
final Goal task = new MoveTowardsRestrictionGoal(ec, 1.0D);
|
||||
tasks.put("home", task);
|
||||
((MobEntityInterface) ec).getAI(false).addGoal(10, task);
|
||||
Vanilla.Mob_getAI(ec, false).addGoal(10, task);
|
||||
}
|
||||
}); //requires mixing
|
||||
|
||||
@@ -1430,7 +1423,7 @@ public class EntityValue extends Value
|
||||
{
|
||||
throw new InternalExpressionException("'portal_cooldown' requires a value to set");
|
||||
}
|
||||
((EntityInterface) e).setPublicNetherPortalCooldown(NumericValue.asNumber(v).getInt());
|
||||
Vanilla.Entity_setPublicNetherPortalCooldown(e, NumericValue.asNumber(v).getInt());
|
||||
});
|
||||
|
||||
put("portal_timer", (e, v) ->
|
||||
@@ -1439,7 +1432,7 @@ public class EntityValue extends Value
|
||||
{
|
||||
throw new InternalExpressionException("'portal_timer' requires a value to set");
|
||||
}
|
||||
((EntityInterface) e).setPortalTimer(NumericValue.asNumber(v).getInt());
|
||||
Vanilla.Entity_setPortalTimer(e, NumericValue.asNumber(v).getInt());
|
||||
});
|
||||
|
||||
put("ai", (e, v) ->
|
||||
@@ -1555,13 +1548,13 @@ public class EntityValue extends Value
|
||||
});
|
||||
|
||||
put("jump", (e, v) -> {
|
||||
if (e instanceof LivingEntity)
|
||||
if (e instanceof final LivingEntity le)
|
||||
{
|
||||
((LivingEntityInterface) e).doJumpCM();
|
||||
Vanilla.LivingEntity_setJumping(le);
|
||||
}
|
||||
else
|
||||
{
|
||||
genericJump(e);
|
||||
EntityTools.genericJump(e);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1671,8 +1664,7 @@ public class EntityValue extends Value
|
||||
if (e instanceof final ServerPlayer sp)
|
||||
{
|
||||
final int progress = (a == null || a.isNull()) ? -1 : NumericValue.asNumber(a).getInt();
|
||||
final ServerPlayerInteractionManagerInterface manager = (ServerPlayerInteractionManagerInterface) (sp.gameMode);
|
||||
manager.setBlockBreakingProgress(progress);
|
||||
Vanilla.ServerPlayerGameMode_setBlockBreakingProgress(sp.gameMode, progress);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1740,7 +1732,7 @@ public class EntityValue extends Value
|
||||
{
|
||||
throw new InternalExpressionException("Unknown entity event: " + eventName);
|
||||
}
|
||||
((EntityInterface) getEntity()).getEventContainer().addEvent(event, cc.host, fun, args);
|
||||
Vanilla.Entity_getEventContainer(getEntity()).addEvent(event, cc.host, fun, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package carpet.script.value;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.script.CarpetScriptServer;
|
||||
import carpet.script.Context;
|
||||
import carpet.script.Expression;
|
||||
import carpet.script.Fluff;
|
||||
@@ -18,7 +18,6 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.nbt.StringTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
@@ -200,7 +199,7 @@ public class FunctionValue extends Value implements Fluff.ILazyFunction
|
||||
final Value param = lv.evalValue(c, Context.NONE);
|
||||
if (param instanceof FunctionUnpackedArgumentsValue)
|
||||
{
|
||||
CarpetSettings.LOG.error("How did we get here?");
|
||||
CarpetScriptServer.LOG.error("How did we get here?");
|
||||
params.addAll(((ListValue) param).getItems());
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package carpet.script.value;
|
||||
|
||||
import carpet.fakes.InventoryBearerInterface;
|
||||
import carpet.script.CarpetContext;
|
||||
import carpet.script.exception.InternalExpressionException;
|
||||
import carpet.script.exception.ThrowStatement;
|
||||
import carpet.script.exception.Throwables;
|
||||
import carpet.script.external.Vanilla;
|
||||
import carpet.script.utils.EquipmentInventory;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
@@ -44,6 +44,7 @@ import net.minecraft.world.WorldlyContainerHolder;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntitySelector;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.animal.horse.AbstractHorse;
|
||||
import net.minecraft.world.entity.npc.InventoryCarrier;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -280,9 +281,9 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
|
||||
{
|
||||
inv = io.getInventory();
|
||||
}
|
||||
else if (e instanceof final InventoryBearerInterface ibi)
|
||||
else if (e instanceof final AbstractHorse ibi)
|
||||
{
|
||||
inv = ibi.getCMInventory(); // horse only
|
||||
inv = Vanilla.AbstractHorse_getInventory(ibi); // horse only
|
||||
}
|
||||
else if (e instanceof final LivingEntity le)
|
||||
{
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
package carpet.script.value;
|
||||
|
||||
import carpet.CarpetServer;
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.fakes.ScreenHandlerInterface;
|
||||
|
||||
import carpet.script.CarpetScriptHost;
|
||||
import carpet.script.CarpetScriptServer;
|
||||
import carpet.script.Context;
|
||||
@@ -12,6 +8,7 @@ import carpet.script.exception.InternalExpressionException;
|
||||
import carpet.script.exception.InvalidCallbackException;
|
||||
import carpet.script.exception.ThrowStatement;
|
||||
import carpet.script.exception.Throwables;
|
||||
import carpet.script.external.Vanilla;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@@ -31,7 +28,32 @@ import net.minecraft.world.SimpleContainer;
|
||||
import net.minecraft.world.SimpleMenuProvider;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.*;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.inventory.AbstractFurnaceMenu;
|
||||
import net.minecraft.world.inventory.AnvilMenu;
|
||||
import net.minecraft.world.inventory.BeaconMenu;
|
||||
import net.minecraft.world.inventory.BlastFurnaceMenu;
|
||||
import net.minecraft.world.inventory.BrewingStandMenu;
|
||||
import net.minecraft.world.inventory.CartographyTableMenu;
|
||||
import net.minecraft.world.inventory.ChestMenu;
|
||||
import net.minecraft.world.inventory.ClickType;
|
||||
import net.minecraft.world.inventory.ContainerListener;
|
||||
import net.minecraft.world.inventory.CraftingMenu;
|
||||
import net.minecraft.world.inventory.DataSlot;
|
||||
import net.minecraft.world.inventory.EnchantmentMenu;
|
||||
import net.minecraft.world.inventory.FurnaceMenu;
|
||||
import net.minecraft.world.inventory.GrindstoneMenu;
|
||||
import net.minecraft.world.inventory.HopperMenu;
|
||||
import net.minecraft.world.inventory.LecternMenu;
|
||||
import net.minecraft.world.inventory.LegacySmithingMenu;
|
||||
import net.minecraft.world.inventory.LoomMenu;
|
||||
import net.minecraft.world.inventory.MerchantMenu;
|
||||
import net.minecraft.world.inventory.ShulkerBoxMenu;
|
||||
import net.minecraft.world.inventory.SimpleContainerData;
|
||||
import net.minecraft.world.inventory.Slot;
|
||||
import net.minecraft.world.inventory.SmithingMenu;
|
||||
import net.minecraft.world.inventory.SmokerMenu;
|
||||
import net.minecraft.world.inventory.StonecutterMenu;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.Recipe;
|
||||
|
||||
@@ -47,6 +69,7 @@ public class ScreenValue extends Value
|
||||
private final FunctionValue callback;
|
||||
private final String hostname;
|
||||
private final ServerPlayer player;
|
||||
private final CarpetScriptServer scriptServer;
|
||||
|
||||
public static Map<String, ScarpetScreenHandlerFactory> screenHandlerFactories;
|
||||
|
||||
@@ -96,6 +119,7 @@ public class ScreenValue extends Value
|
||||
}
|
||||
this.callback = callback;
|
||||
this.hostname = c.host.getName();
|
||||
this.scriptServer = (CarpetScriptServer) c.host.scriptServer();
|
||||
this.player = player;
|
||||
final MenuProvider factory = this.createScreenHandlerFactory();
|
||||
if (factory == null)
|
||||
@@ -167,18 +191,19 @@ public class ScreenValue extends Value
|
||||
final Value actionValue = StringValue.of(action);
|
||||
final Value dataValue = MapValue.wrap(data);
|
||||
final List<Value> args = Arrays.asList(this, playerValue, actionValue, dataValue);
|
||||
final CarpetScriptHost appHost = CarpetServer.scriptServer.getAppHostByName(this.hostname);
|
||||
final CarpetScriptHost appHost = scriptServer.getAppHostByName(this.hostname);
|
||||
if (appHost == null)
|
||||
{
|
||||
this.close();
|
||||
this.screenHandler = null;
|
||||
return false;
|
||||
}
|
||||
final CommandSourceStack source = player.createCommandSourceStack().withPermission(CarpetSettings.runPermissionLevel);
|
||||
final int runPermissionLevel = Vanilla.MinecraftServer_getRunPermissionLevel(player.server);
|
||||
final CommandSourceStack source = player.createCommandSourceStack().withPermission(runPermissionLevel);
|
||||
final CarpetScriptHost executingHost = appHost.retrieveForExecution(source, player);
|
||||
try
|
||||
{
|
||||
final Value cancelValue = executingHost.callUDF(source.withPermission(CarpetSettings.runPermissionLevel), callback, args);
|
||||
final Value cancelValue = executingHost.callUDF(source, callback, args);
|
||||
return cancelValue.getString().equals("cancel");
|
||||
}
|
||||
catch (final NullPointerException | InvalidCallbackException | IntegrityException error)
|
||||
@@ -255,7 +280,7 @@ public class ScreenValue extends Value
|
||||
{
|
||||
if (screenHandlerClass.isInstance(this.screenHandler))
|
||||
{
|
||||
return ((ScreenHandlerInterface) this.screenHandler).getProperty(propertyIndex);
|
||||
return Vanilla.AbstractContainerMenu_getDataSlot(this.screenHandler, propertyIndex);
|
||||
}
|
||||
if (!this.isOpen())
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package carpet.script.value;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.script.CarpetScriptServer;
|
||||
import carpet.script.exception.InternalExpressionException;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
@@ -46,7 +46,7 @@ public abstract class Value implements Comparable<Value>, Cloneable
|
||||
catch (final CloneNotSupportedException e)
|
||||
{
|
||||
// should not happen
|
||||
CarpetSettings.LOG.error("Failed to clone variable", e);
|
||||
CarpetScriptServer.LOG.error("Failed to clone variable", e);
|
||||
throw new InternalExpressionException("Variable of type " + getTypeString() + " is not cloneable. Tell gnembon about it, this shoudn't happen");
|
||||
}
|
||||
copy.boundVariable = value;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package carpet.script.value;
|
||||
|
||||
import carpet.fakes.BlockPredicateInterface;
|
||||
import carpet.script.exception.InternalExpressionException;
|
||||
import carpet.script.exception.ThrowStatement;
|
||||
import carpet.script.exception.Throwables;
|
||||
import carpet.utils.BlockInfo;
|
||||
import carpet.script.external.Carpet;
|
||||
import carpet.script.external.Vanilla;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import net.minecraft.advancements.critereon.MinMaxBounds;
|
||||
@@ -83,7 +83,7 @@ public class ValueConversions
|
||||
|
||||
public static Value of(final MaterialColor color)
|
||||
{
|
||||
return ListValue.of(StringValue.of(BlockInfo.mapColourName.get(color)), ofRGB(color.col));
|
||||
return ListValue.of(StringValue.of(Carpet.getMapColorNames().get(color)), ofRGB(color.col));
|
||||
}
|
||||
|
||||
public static <T extends Number> Value of(final MinMaxBounds<T> range)
|
||||
@@ -451,13 +451,13 @@ public class ValueConversions
|
||||
|
||||
public static Value ofBlockPredicate(final RegistryAccess registryAccess, final Predicate<BlockInWorld> blockPredicate)
|
||||
{
|
||||
final BlockPredicateInterface predicateData = (BlockPredicateInterface) blockPredicate;
|
||||
final Vanilla.BlockPredicatePayload payload = Vanilla.BlockPredicatePayload.of(blockPredicate);
|
||||
final Registry<Block> blocks = registryAccess.registryOrThrow(Registries.BLOCK);
|
||||
return ListValue.of(
|
||||
predicateData.getCMBlockState() == null ? Value.NULL : of(blocks.getKey(predicateData.getCMBlockState().getBlock())),
|
||||
predicateData.getCMBlockTagKey() == null ? Value.NULL : of(blocks.getTag(predicateData.getCMBlockTagKey()).get().key()),
|
||||
MapValue.wrap(predicateData.getCMProperties()),
|
||||
predicateData.getCMDataTag() == null ? Value.NULL : new NBTSerializableValue(predicateData.getCMDataTag())
|
||||
payload.state() == null ? Value.NULL : of(blocks.getKey(payload.state().getBlock())),
|
||||
payload.tagKey() == null ? Value.NULL : of(blocks.getTag(payload.tagKey()).get().key()),
|
||||
MapValue.wrap(payload.properties()),
|
||||
payload.tag() == null ? Value.NULL : new NBTSerializableValue(payload.tag())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user