This commit is contained in:
gnembon committed 2020-05-21 14:23:04 -03:00
1 parent 42ba5a9f03
commit cf817c2e39
25 files changed
+91 -92

No files matched your search

@@ -12,7 +12,6 @@ import carpet.script.value.StringValue;
import carpet.script.value.Value;
import carpet.utils.Messenger;
import net.minecraft.block.BlockState;
import net.minecraft.class_5321;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.entity.Entity;
@@ -29,6 +28,7 @@ import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.dimension.DimensionType;
import org.apache.commons.lang3.tuple.Pair;
@@ -191,7 +191,7 @@ public class CarpetEventServer
{
handler.call(Collections::emptyList, () ->
CarpetServer.minecraft_server.getCommandSource().
withWorld(CarpetServer.minecraft_server.getWorld(DimensionType.field_24753))// OVERWORLD))
withWorld(CarpetServer.minecraft_server.getWorld(DimensionType.OVERWORLD_REGISTRY_KEY))
);
}
},
@@ -202,7 +202,7 @@ public class CarpetEventServer
{
handler.call(Collections::emptyList, () ->
CarpetServer.minecraft_server.getCommandSource().
withWorld(CarpetServer.minecraft_server.getWorld(DimensionType.field_24754))// THE_NETHER))
withWorld(CarpetServer.minecraft_server.getWorld(DimensionType.THE_NETHER_REGISTRY_KEY))
);
}
},
@@ -213,7 +213,7 @@ public class CarpetEventServer
{
handler.call(Collections::emptyList, () ->
CarpetServer.minecraft_server.getCommandSource().
withWorld(CarpetServer.minecraft_server.getWorld(DimensionType.field_24755))//THE_END))
withWorld(CarpetServer.minecraft_server.getWorld(DimensionType.THE_END_REGISTRY_KEY))
);
}
},
@@ -531,13 +531,13 @@ public class CarpetEventServer
PLAYER_CHANGES_DIMENSION("player_changes_dimension", 5, false)
{
@Override
public void onDimensionChange(ServerPlayerEntity player, Vec3d from, Vec3d to, class_5321<DimensionType> fromDim, class_5321<DimensionType> dimTo)
public void onDimensionChange(ServerPlayerEntity player, Vec3d from, Vec3d to, RegistryKey<DimensionType> fromDim, RegistryKey<DimensionType> dimTo)
{
// eligibility already checked in mixin
Value fromValue = ListValue.fromTriple(from.x, from.y, from.z);
Value toValue = (to == null)?Value.NULL:ListValue.fromTriple(to.x, to.y, to.z);
Value fromDimStr = new StringValue(NBTSerializableValue.nameFromRegistryId(fromDim.method_29177()));
Value toDimStr = new StringValue(NBTSerializableValue.nameFromRegistryId(dimTo.method_29177()));
Value fromDimStr = new StringValue(NBTSerializableValue.nameFromRegistryId(fromDim.getValue()));
Value toDimStr = new StringValue(NBTSerializableValue.nameFromRegistryId(dimTo.getValue()));
handler.call( () -> Arrays.asList(
((c, t) -> new EntityValue(player)),
@@ -620,7 +620,7 @@ public class CarpetEventServer
public void onBlockBroken(ServerPlayerEntity player, BlockPos pos, BlockState previousBS) { }
public void onBlockPlaced(ServerPlayerEntity player, BlockPos pos, Hand enumhand, ItemStack itemstack) { }
public void onEntityAction(ServerPlayerEntity player, Entity entity, Hand enumhand) { }
public void onDimensionChange(ServerPlayerEntity player, Vec3d from, Vec3d to, class_5321<DimensionType> fromDim, class_5321<DimensionType> dimTo) {}
public void onDimensionChange(ServerPlayerEntity player, Vec3d from, Vec3d to, RegistryKey<DimensionType> fromDim, RegistryKey<DimensionType> dimTo) {}
public void onDamage(Entity target, float amount, DamageSource source) { }
@@ -2998,7 +2998,7 @@ public class CarpetExpression
this.expr.addLazyFunction("current_dimension", 0, (c, t, lv) -> {
ServerCommandSource s = ((CarpetContext)c).s;
Value retval = new StringValue(NBTSerializableValue.nameFromRegistryId(s.getWorld().method_27983().method_29177())); // getDImensionType
Value retval = new StringValue(NBTSerializableValue.nameFromRegistryId(s.getWorld().method_27983().getValue())); // getDImensionType
return (cc, tt) -> retval;
});
@@ -3029,15 +3029,15 @@ public class CarpetExpression
{
case "nether":
case "the_nether":
innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(DimensionType.field_24754));
innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(DimensionType.THE_NETHER_REGISTRY_KEY));
break;
case "end":
case "the_end":
innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(DimensionType.field_24755));
innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(DimensionType.THE_END_REGISTRY_KEY));
break;
case "overworld":
case "over_world":
innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(DimensionType.field_24753));
innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(DimensionType.OVERWORLD_REGISTRY_KEY));
break;
default:
throw new InternalExpressionException("Incorrect dimension string: "+dimString);
@@ -15,8 +15,8 @@ import carpet.utils.Messenger;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.tree.CommandNode;
import net.minecraft.class_5218;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.util.WorldSavePath;
import net.minecraft.util.math.BlockPos;
import java.io.File;
@@ -76,7 +76,7 @@ public class CarpetScriptServer
public Module getModule(String name, boolean allowLibraries)
{
File folder = CarpetServer.minecraft_server.method_27050(class_5218.field_24188).resolve("scripts").toFile();
File folder = CarpetServer.minecraft_server.method_27050(WorldSavePath.ROOT).resolve("scripts").toFile();
File[] listOfFiles = folder.listFiles();
if (listOfFiles != null)
for (File script : listOfFiles)
@@ -110,7 +110,7 @@ public class CarpetScriptServer
if (!mi.isLibrary()) moduleNames.add(mi.getName());
}
}
File folder = CarpetServer.minecraft_server.method_27050(class_5218.field_24188).resolve("scripts").toFile();
File folder = CarpetServer.minecraft_server.method_27050(WorldSavePath.ROOT).resolve("scripts").toFile();
File[] listOfFiles = folder.listFiles();
if (listOfFiles == null)
return moduleNames;
@@ -1,8 +1,8 @@
package carpet.script.bundled;
import carpet.CarpetServer;
import net.minecraft.class_5218;
import net.minecraft.nbt.Tag;
import net.minecraft.util.WorldSavePath;
import java.io.File;
import java.nio.file.Files;
@@ -35,7 +35,7 @@ public abstract class Module
public static Tag getData(Module module, String file, boolean isShared)
{
if (!isShared && (module == null || module.getName() == null)) return null;
File dataFile = CarpetServer.minecraft_server.method_27050(class_5218.field_24188).resolve("scripts/"+getDescriptor(module, file, isShared)+".nbt").toFile();
File dataFile = CarpetServer.minecraft_server.method_27050(WorldSavePath.ROOT).resolve("scripts/"+getDescriptor(module, file, isShared)+".nbt").toFile();
if (!Files.exists(dataFile.toPath()) || !(dataFile.isFile())) return null;
return read(dataFile);
}
@@ -43,7 +43,7 @@ public abstract class Module
public static boolean saveData(Module module, String file, Tag globalState, boolean isShared)
{
if (!isShared && (module == null || module.getName() == null)) return false;
File dataFile =CarpetServer.minecraft_server.method_27050(class_5218.field_24188).resolve("scripts/"+getDescriptor(module, file, isShared)+".nbt").toFile();
File dataFile =CarpetServer.minecraft_server.method_27050(WorldSavePath.ROOT).resolve("scripts/"+getDescriptor(module, file, isShared)+".nbt").toFile();
if (!Files.exists(dataFile.toPath().getParent()) && !dataFile.getParentFile().mkdirs()) return false;
return write(globalState, dataFile);
}
@@ -249,7 +249,7 @@ public class EntityValue extends Value
put("immune_to_fire", (e, a) -> new NumericValue(e.isFireImmune()));
put("invulnerable", (e, a) -> new NumericValue(e.isInvulnerable()));
put("dimension", (e, a) -> new StringValue(nameFromRegistryId(e.world.method_27983().method_29177()))); // getDimId
put("dimension", (e, a) -> new StringValue(nameFromRegistryId(e.world.method_27983().getValue()))); // getDimId
put("height", (e, a) -> new NumericValue(e.getDimensions(EntityPose.STANDING).height));
put("width", (e, a) -> new NumericValue(e.getDimensions(EntityPose.STANDING).width));
put("eye_height", (e, a) -> new NumericValue(e.getStandingEyeHeight()));