20w21a ohboi
This commit is contained in:
1 parent
838211edba
commit
bec5259216
40 files changed
+445
-347
No files matched your search
@@ -12,6 +12,7 @@ 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;
|
||||
@@ -190,7 +191,7 @@ public class CarpetEventServer
|
||||
{
|
||||
handler.call(Collections::emptyList, () ->
|
||||
CarpetServer.minecraft_server.getCommandSource().
|
||||
withWorld(CarpetServer.minecraft_server.getWorld(DimensionType.OVERWORLD))
|
||||
withWorld(CarpetServer.minecraft_server.getWorld(DimensionType.field_24753))// OVERWORLD))
|
||||
);
|
||||
}
|
||||
},
|
||||
@@ -201,7 +202,7 @@ public class CarpetEventServer
|
||||
{
|
||||
handler.call(Collections::emptyList, () ->
|
||||
CarpetServer.minecraft_server.getCommandSource().
|
||||
withWorld(CarpetServer.minecraft_server.getWorld(DimensionType.THE_NETHER))
|
||||
withWorld(CarpetServer.minecraft_server.getWorld(DimensionType.field_24754))// THE_NETHER))
|
||||
);
|
||||
}
|
||||
},
|
||||
@@ -212,7 +213,7 @@ public class CarpetEventServer
|
||||
{
|
||||
handler.call(Collections::emptyList, () ->
|
||||
CarpetServer.minecraft_server.getCommandSource().
|
||||
withWorld(CarpetServer.minecraft_server.getWorld(DimensionType.THE_END))
|
||||
withWorld(CarpetServer.minecraft_server.getWorld(DimensionType.field_24755))//THE_END))
|
||||
);
|
||||
}
|
||||
},
|
||||
@@ -530,13 +531,13 @@ public class CarpetEventServer
|
||||
PLAYER_CHANGES_DIMENSION("player_changes_dimension", 5, false)
|
||||
{
|
||||
@Override
|
||||
public void onDimensionChange(ServerPlayerEntity player, Vec3d from, Vec3d to, DimensionType fromDim, DimensionType dimTo)
|
||||
public void onDimensionChange(ServerPlayerEntity player, Vec3d from, Vec3d to, class_5321<DimensionType> fromDim, class_5321<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(Registry.DIMENSION_TYPE.getId(fromDim)));
|
||||
Value toDimStr = new StringValue(NBTSerializableValue.nameFromRegistryId(Registry.DIMENSION_TYPE.getId(dimTo)));
|
||||
Value fromDimStr = new StringValue(NBTSerializableValue.nameFromRegistryId(fromDim.method_29177()));
|
||||
Value toDimStr = new StringValue(NBTSerializableValue.nameFromRegistryId(dimTo.method_29177()));
|
||||
|
||||
handler.call( () -> Arrays.asList(
|
||||
((c, t) -> new EntityValue(player)),
|
||||
@@ -619,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, DimensionType fromDim, DimensionType dimTo) {}
|
||||
public void onDimensionChange(ServerPlayerEntity player, Vec3d from, Vec3d to, class_5321<DimensionType> fromDim, class_5321<DimensionType> dimTo) {}
|
||||
public void onDamage(Entity target, float amount, DamageSource source) { }
|
||||
|
||||
|
||||
|
||||
@@ -403,7 +403,7 @@ public class CarpetExpression
|
||||
|
||||
|
||||
|
||||
private static Value structureToValue(StructureStart structure)
|
||||
private static Value structureToValue(StructureStart<?> structure)
|
||||
{
|
||||
if (structure == null || structure == StructureStart.DEFAULT) return Value.NULL;
|
||||
List<Value> pieces = new ArrayList<>();
|
||||
@@ -1158,12 +1158,15 @@ public class CarpetExpression
|
||||
Map<String, LongSet> references = world.getChunk(pos.getX() >> 4, pos.getZ() >> 4, ChunkStatus.STRUCTURE_REFERENCES).getStructureReferences();
|
||||
if (lv.size() == locator.offset)
|
||||
{
|
||||
//CarpetSettings.LOG.error(references.keySet().stream().collect(Collectors.joining(",")));
|
||||
List<Value> referenceList = references.entrySet().stream().
|
||||
filter(e -> e.getValue()!= null && !e.getValue().isEmpty()).
|
||||
map(e -> new StringValue(FeatureGenerator.structureToFeature.get(e.getKey()).get(0))).collect(Collectors.toList());
|
||||
map(e -> new StringValue(FeatureGenerator.structureToFeature.get(FeatureGenerator.fix(e.getKey())).get(0))).collect(Collectors.toList());
|
||||
return (_c, _t ) -> ListValue.wrap(referenceList);
|
||||
}
|
||||
String simpleStructureName = lv.get(locator.offset).evalValue(c).getString().toLowerCase(Locale.ROOT);
|
||||
//CarpetSettings.LOG.error(FeatureGenerator.featureToStructure.keySet().stream().collect(Collectors.joining(",")));
|
||||
//CarpetSettings.LOG.error(FeatureGenerator.featureToStructure.values().stream().collect(Collectors.joining(",")));
|
||||
String structureName = FeatureGenerator.featureToStructure.get(simpleStructureName);
|
||||
if (structureName == null) return LazyValue.NULL;
|
||||
LongSet structureReferences = references.get(structureName);
|
||||
@@ -1192,7 +1195,7 @@ public class CarpetExpression
|
||||
String reqString = requested.getString();
|
||||
String structureName = FeatureGenerator.featureToStructure.get(reqString);
|
||||
if (structureName == null) throw new InternalExpressionException("Unknown structure: " + reqString);
|
||||
structure = Feature.STRUCTURES.get(structureName.toLowerCase(Locale.ROOT));
|
||||
structure = StructureFeature.field_24842.get(structureName.toLowerCase(Locale.ROOT));
|
||||
if (structure == null) throw new InternalExpressionException("Unsupported structure: " + structureName);
|
||||
}
|
||||
if (lv.size() > locator.offset+1)
|
||||
@@ -1202,19 +1205,19 @@ public class CarpetExpression
|
||||
}
|
||||
if (structure != null)
|
||||
{
|
||||
StructureStart start = FeatureGenerator.shouldStructureStartAt(world, pos, structure, needSize);
|
||||
StructureStart<?> start = FeatureGenerator.shouldStructureStartAt(world, pos, structure, needSize);
|
||||
if (start == null) return LazyValue.NULL;
|
||||
if (!needSize) return LazyValue.TRUE;
|
||||
Value ret = structureToValue(start);
|
||||
return (_c, _t) -> ret;
|
||||
}
|
||||
Map<Value, Value> ret = new HashMap<>();
|
||||
for(StructureFeature<?> str : Feature.STRUCTURES.values())
|
||||
for(StructureFeature<?> str : StructureFeature.field_24842.values())
|
||||
{
|
||||
StructureStart start = FeatureGenerator.shouldStructureStartAt(world, pos, str, needSize);
|
||||
if (start == null) continue;
|
||||
|
||||
Value key = new StringValue(FeatureGenerator.structureToFeature.get(str.getName()).get(0));
|
||||
Value key = new StringValue(FeatureGenerator.structureToFeature.get(FeatureGenerator.fix(str.getName())).get(0));
|
||||
ret.put(key, (!needSize)?Value.NULL:structureToValue(start));
|
||||
}
|
||||
Value retMap = MapValue.wrap(ret);
|
||||
@@ -1227,18 +1230,18 @@ public class CarpetExpression
|
||||
|
||||
ServerWorld world = cc.s.getWorld();
|
||||
BlockPos pos = locator.block.getPos();
|
||||
Map<String, StructureStart> structures = world.getChunk(pos.getX() >> 4, pos.getZ() >> 4, ChunkStatus.STRUCTURE_STARTS).getStructureStarts();
|
||||
Map<String, StructureStart<?>> structures = world.getChunk(pos.getX() >> 4, pos.getZ() >> 4, ChunkStatus.STRUCTURE_STARTS).getStructureStarts();
|
||||
if (lv.size() == locator.offset)
|
||||
{
|
||||
Map<Value, Value> structureList = new HashMap<>();
|
||||
for (Map.Entry<String, StructureStart> entry : structures.entrySet())
|
||||
for (Map.Entry<String, StructureStart<?>> entry : structures.entrySet())
|
||||
{
|
||||
StructureStart start = entry.getValue();
|
||||
StructureStart<?> start = entry.getValue();
|
||||
if (start == StructureStart.DEFAULT)
|
||||
continue;
|
||||
BlockBox box = start.getBoundingBox();
|
||||
structureList.put(
|
||||
new StringValue(FeatureGenerator.structureToFeature.get(entry.getKey()).get(0)),
|
||||
new StringValue(FeatureGenerator.structureToFeature.get(FeatureGenerator.fix(entry.getKey())).get(0)),
|
||||
ListValue.of(ListValue.fromTriple(box.minX, box.minY, box.minZ), ListValue.fromTriple(box.maxX, box.maxY, box.maxZ))
|
||||
);
|
||||
}
|
||||
@@ -1269,7 +1272,7 @@ public class CarpetExpression
|
||||
// technically a world modification. Even if we could let it slide, we will still park it
|
||||
((CarpetContext) c).s.getMinecraftServer().submitAndJoin(() ->
|
||||
{
|
||||
Map<String, StructureStart> structures = world.getChunk(pos).getStructureStarts();
|
||||
Map<String, StructureStart<?>> structures = world.getChunk(pos).getStructureStarts();
|
||||
if (lv.size() == locator.offset + 1)
|
||||
{
|
||||
Boolean res = FeatureGenerator.gridStructure(structureName, ((CarpetContext) c).s.getWorld(), locator.block.getPos());
|
||||
@@ -1284,7 +1287,7 @@ public class CarpetExpression
|
||||
{
|
||||
return;
|
||||
}
|
||||
StructureStart start = structures.get(structureId);
|
||||
StructureStart<?> start = structures.get(structureId);
|
||||
ChunkPos structureChunkPos = new ChunkPos(start.getChunkX(), start.getChunkZ());
|
||||
BlockBox box = start.getBoundingBox();
|
||||
for (int chx = box.minX / 16; chx <= box.maxX / 16; chx++)
|
||||
@@ -2939,7 +2942,7 @@ public class CarpetExpression
|
||||
{
|
||||
long newTime = NumericValue.asNumber(lv.get(0).evalValue(c)).getLong();
|
||||
if (newTime < 0) newTime = 0;
|
||||
((CarpetContext) c).s.getWorld().setTimeOfDay(newTime);
|
||||
((CarpetContext) c).s.getWorld().method_29199(newTime);// setTimeOfDay(newTime);
|
||||
}
|
||||
return (cc, tt) -> time;
|
||||
});
|
||||
@@ -2995,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(Registry.DIMENSION_TYPE.getId(s.getWorld().method_27983()))); // getDImensionType
|
||||
Value retval = new StringValue(NBTSerializableValue.nameFromRegistryId(s.getWorld().method_27983().method_29177())); // getDImensionType
|
||||
return (cc, tt) -> retval;
|
||||
});
|
||||
|
||||
@@ -3026,15 +3029,15 @@ public class CarpetExpression
|
||||
{
|
||||
case "nether":
|
||||
case "the_nether":
|
||||
innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(DimensionType.THE_NETHER));
|
||||
innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(DimensionType.field_24754));
|
||||
break;
|
||||
case "end":
|
||||
case "the_end":
|
||||
innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(DimensionType.THE_END));
|
||||
innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(DimensionType.field_24755));
|
||||
break;
|
||||
case "overworld":
|
||||
case "over_world":
|
||||
innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(DimensionType.OVERWORLD));
|
||||
innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(DimensionType.field_24753));
|
||||
break;
|
||||
default:
|
||||
throw new InternalExpressionException("Incorrect dimension string: "+dimString);
|
||||
|
||||
@@ -25,7 +25,7 @@ public class WorldTools
|
||||
if (region == null) return false;
|
||||
return region.hasChunk(chpos);
|
||||
}
|
||||
Path regionPath = new File(((MinecraftServerInterface )world.getServer()).getCMSession().method_27424(world.getDimension().getType()), "region").toPath();
|
||||
Path regionPath = new File(((MinecraftServerInterface )world.getServer()).getCMSession().method_27424(world.method_27983()), "region").toPath();
|
||||
Path regionFilePath = regionPath.resolve(currentRegionName);
|
||||
File regionFile = regionFilePath.toFile();
|
||||
if (!regionFile.exists())
|
||||
|
||||
@@ -169,7 +169,7 @@ public class BlockValue extends Value
|
||||
public int hashCode()
|
||||
{
|
||||
if (world != null && pos != null )
|
||||
return GlobalPos.create(world.getDimension().getType(), pos).hashCode();
|
||||
return GlobalPos.create(world.method_27983() , pos).hashCode(); //getDimension().getType()
|
||||
return ("b"+getString()).hashCode();
|
||||
}
|
||||
|
||||
|
||||
@@ -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(Registry.DIMENSION_TYPE.getId(e.dimension))));
|
||||
put("dimension", (e, a) -> new StringValue(nameFromRegistryId(e.world.method_27983().method_29177()))); // 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()));
|
||||
|
||||
Reference in new issue
Block a user