This commit is contained in:
gnembon committed 2021-04-02 18:38:55 -03:00
1 parent 3756ca9f86
commit 5dd2a12aa7
20 files changed
+61 -79

No files matched your search

@@ -470,7 +470,7 @@ public class ScriptCommand
CarpetScriptHost host = getHost(context);
BlockBox area = BlockBox.create(a, b);
CarpetExpression cexpr = new CarpetExpression(host.main, expr, source, origin);
int int_1 = area.getBlockCountX() * area.getBlockCountY() * area.method_35414(); // X Y Z
int int_1 = area.getBlockCountX() * area.getBlockCountY() * area.getBlockCountZ(); // X Y Z
if (int_1 > CarpetSettings.fillLimit)
{
Messenger.m(source, "r too many blocks to evaluate: " + int_1);
@@ -480,11 +480,11 @@ public class ScriptCommand
CarpetSettings.impendingFillSkipUpdates = !CarpetSettings.fillUpdates;
try
{
for (int x = area.method_35420(); x <= area.method_35417(); x++) //minx maxx
for (int x = area.getMinX(); x <= area.getMaxX(); x++)
{
for (int y = area.method_35415(); y <= area.method_35418(); y++) // miny maxy
for (int y = area.getMinY(); y <= area.getMaxY(); y++)
{
for (int z = area.method_35416(); z <= area.method_35419(); z++) // minz maxz
for (int z = area.getMinZ(); z <= area.getMaxZ(); z++)
{
try
{
@@ -519,29 +519,29 @@ public class ScriptCommand
CarpetScriptHost host = getHost(context);
BlockBox area = BlockBox.create(a, b);
CarpetExpression cexpr = new CarpetExpression(host.main, expr, source, origin);
int int_1 = area.getBlockCountX() * area.getBlockCountY() * area.method_35414();
int int_1 = area.getBlockCountX() * area.getBlockCountY() * area.getBlockCountZ();
if (int_1 > CarpetSettings.fillLimit)
{
Messenger.m(source, "r too many blocks to evaluate: "+ int_1);
return 1;
}
boolean[][][] volume = new boolean[area.getBlockCountY()][area.method_35414()][area.getBlockCountX()]; //X then Y then Z got messedup
boolean[][][] volume = new boolean[area.getBlockCountX()][area.getBlockCountY()][area.getBlockCountZ()]; //X then Y then Z got messedup
BlockPos.Mutable mbpos = origin.mutableCopy();
ServerWorld world = source.getWorld();
for (int x = area.method_35420(); x <= area.method_35417(); x++) //minx maxx
for (int x = area.getMinX(); x <= area.getMaxX(); x++)
{
for (int y = area.method_35415(); y <= area.method_35418(); y++) // miny maxy
for (int y = area.getMinY(); y <= area.getMaxY(); y++)
{
for (int z = area.method_35416(); z <= area.method_35419(); z++) // minz maxz
for (int z = area.getMinZ(); z <= area.getMaxZ(); z++)
{
try
{
if (cexpr.fillAndScanCommand(host, x, y, z))
{
volume[x-area.method_35420()][y-area.method_35415()][z-area.method_35416()]=true;
volume[x-area.getMinX()][y-area.getMinY()][z-area.getMinZ()]=true;
}
}
catch (CarpetExpressionException e)
@@ -555,12 +555,12 @@ public class ScriptCommand
}
}
}
final int maxx = area.getBlockCountY()-1; //x
final int maxy = area.method_35414()-1; //y
final int maxz = area.getBlockCountX()-1; //z
final int maxx = area.getBlockCountX()-1;
final int maxy = area.getBlockCountY()-1;
final int maxz = area.getBlockCountZ()-1;
if ("outline".equalsIgnoreCase(mode))
{
boolean[][][] newVolume = new boolean[area.getBlockCountY()][area.method_35414()][area.getBlockCountX()]; //X then Y then Z got messedup
boolean[][][] newVolume = new boolean[area.getBlockCountX()][area.getBlockCountY()][area.getBlockCountZ()];
for (int x = 0; x <= maxx; x++)
{
for (int y = 0; y <= maxy; y++)
@@ -596,7 +596,7 @@ public class ScriptCommand
{
if (volume[x][y][z])
{
mbpos.set(x+area.method_35420(), y+area.method_35415(), z+area.method_35416());
mbpos.set(x+area.getMinX(), y+area.getMinY(), z+area.getMinZ());
if (replacement == null || replacement.test(
new CachedBlockPosition( world, mbpos, true)))
{
@@ -624,7 +624,7 @@ public class ScriptCommand
{
if (volume[x][y][z])
{
mbpos.set(x+area.method_35420(), y+area.method_35415(), z+area.method_35416());
mbpos.set(x+area.getMinX(), y+area.getMinY(), z+area.getMinZ());
Block blokc = world.getBlockState(mbpos).getBlock();
world.updateNeighbors(mbpos, blokc);
}
@@ -632,7 +632,7 @@ public class ScriptCommand
}
}
}
Messenger.m(source, "gi Affected "+affected+" blocks in "+area.getBlockCountX() * area.getBlockCountY() * area.method_35414()+" block volume");
Messenger.m(source, "gi Affected "+affected+" blocks in "+area.getBlockCountX() * area.getBlockCountY() * area.getBlockCountZ()+" block volume");
return 1;
}
}
@@ -1,6 +1,5 @@
package carpet.fakes;
import net.minecraft.class_6067;
import net.minecraft.inventory.Inventory;
public interface InventoryBearerInterface
@@ -226,7 +226,7 @@ public class BlockRotator
{
Direction sourceFace = source.getBlockState().get(DispenserBlock.FACING);
World world = source.getWorld();
BlockPos blockpos = source.getBlockPos().method_35851(sourceFace); // offset
BlockPos blockpos = source.getBlockPos().offset(sourceFace); // offset
BlockState iblockstate = world.getBlockState(blockpos);
Block block = iblockstate.getBlock();
@@ -49,7 +49,7 @@ public class FeatureGenerator
return custom.plop(world, pos);
}
Identifier id = new Identifier(featureName);
ConfiguredStructureFeature<?, ?> structureFeature = world.getRegistryManager().get(Registry.CONFIGURED_STRUCTURE_FEATURE_WORLDGEN).get(id);
ConfiguredStructureFeature<?, ?> structureFeature = world.getRegistryManager().get(Registry.CONFIGURED_STRUCTURE_FEATURE_KEY).get(id);
if (structureFeature != null)
{
return ((StructureFeatureInterface)structureFeature.feature).plopAnywhere(
@@ -58,7 +58,7 @@ public class FeatureGenerator
}
ConfiguredFeature<?, ?> feature = world.getRegistryManager().get(Registry.CONFIGURED_FEATURE_WORLDGEN).get(id);
ConfiguredFeature<?, ?> feature = world.getRegistryManager().get(Registry.CONFIGURED_FEATURE_KEY).get(id);
if (feature != null)
{
CarpetSettings.skipGenerationChecks = true;
@@ -77,7 +77,7 @@ public class FeatureGenerator
public static ConfiguredStructureFeature<?, ?> resolveConfiguredStructure(String name, ServerWorld world, BlockPos pos)
{
Identifier id = new Identifier(name);
ConfiguredStructureFeature<?, ?> configuredStructureFeature = world.getRegistryManager().get(Registry.CONFIGURED_STRUCTURE_FEATURE_WORLDGEN).get(id);
ConfiguredStructureFeature<?, ?> configuredStructureFeature = world.getRegistryManager().get(Registry.CONFIGURED_STRUCTURE_FEATURE_KEY).get(id);
if (configuredStructureFeature != null) return configuredStructureFeature;
StructureFeature<?> structureFeature = Registry.STRUCTURE_FEATURE.get(id);
if (structureFeature == null) return null;
@@ -137,7 +137,7 @@ public class FeatureGenerator
{
ConfiguredStructureFeature<?, ?> configuredFeature = world.getBiome(pos).getGenerationSettings().method_30978(structure.configure(null));
if (configuredFeature.config != null || !tryHard) return configuredFeature;
return world.getRegistryManager().get(Registry.CONFIGURED_STRUCTURE_FEATURE_WORLDGEN).getEntries().stream().
return world.getRegistryManager().get(Registry.CONFIGURED_STRUCTURE_FEATURE_KEY).getEntries().stream().
filter(cS -> cS.getValue().feature == structure).
findFirst().map(Map.Entry::getValue).orElse(null);
}
@@ -33,7 +33,7 @@ public abstract class FluidBlock_renewableBlackstoneMixin
for(Direction direction : Direction.values())
{
if (direction != Direction.DOWN) {
BlockPos blockPos = pos.method_35851(direction); // offset
BlockPos blockPos = pos.offset(direction); // offset
if (world.getBlockState(blockPos).isOf(Blocks.BLUE_ICE)) {
world.setBlockState(pos, Blocks.BLACKSTONE.getDefaultState());
playExtinguishSound(world, pos);
@@ -36,7 +36,7 @@ public abstract class HopperBlockEntityMixin extends LootableContainerBlockEntit
if (CarpetSettings.hopperCounters) {
DyeColor wool_color = WoolTool.getWoolColorAtPosition(
world,
blockPos.method_35851(blockState.get(HopperBlock.FACING))); // offset
blockPos.offset(blockState.get(HopperBlock.FACING))); // offset
if (wool_color != null)
{
for (int i = 0; i < inventory.size(); ++i)
@@ -1,21 +0,0 @@
package carpet.mixins;
import carpet.fakes.InventoryBearerInterface;
import net.minecraft.entity.mob.PillagerEntity;
import net.minecraft.inventory.Inventory;
import net.minecraft.inventory.SimpleInventory;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@Mixin(PillagerEntity.class)
public class PillagerEntity_scarpetMixin implements InventoryBearerInterface
{
@Shadow @Final private SimpleInventory inventory;
@Override
public Inventory getCMInventory()
{
return inventory;
}
}
@@ -196,7 +196,7 @@ public abstract class PistonHandler_customStickyMixin
// stickyDirection = blockState_1.get(FacingBlock.FACING);
//}
return stickyDirection == null || this.tryMove(blockPos_1.method_35851(stickyDirection), stickyDirection); //offset
return stickyDirection == null || this.tryMove(blockPos_1.offset(stickyDirection), stickyDirection); //offset
}
@@ -56,7 +56,7 @@ public abstract class StructureFeatureMixin<C extends FeatureConfig> implements
structurestart.generateStructure(world, world.getStructureAccessor(), generator, rand,box, new ChunkPos(j, k));
}
//structurestart.notifyPostProcessAt(new ChunkPos(j, k));
int i = Math.max(box.getBlockCountY(),box.getBlockCountX())/16+1; // X Z
int i = Math.max(box.getBlockCountX(),box.getBlockCountZ())/16+1;
//int i = getRadius();
for (int k1 = j - i; k1 <= j + i; ++k1)
@@ -788,13 +788,13 @@ public class Auxiliary {
ListValue.wrap(Registry.FEATURE.getIds().stream().sorted().map(ValueConversions::of).collect(Collectors.toList()))
);
plopData.put(StringValue.of("configured_features"),
ListValue.wrap(registryManager.get(Registry.CONFIGURED_FEATURE_WORLDGEN).getIds().stream().sorted().map(ValueConversions::of).collect(Collectors.toList()))
ListValue.wrap(registryManager.get(Registry.CONFIGURED_FEATURE_KEY).getIds().stream().sorted().map(ValueConversions::of).collect(Collectors.toList()))
);
plopData.put(StringValue.of("structures"),
ListValue.wrap(Registry.STRUCTURE_FEATURE.getIds().stream().sorted().map(ValueConversions::of).collect(Collectors.toList()))
);
plopData.put(StringValue.of("configured_structures"),
ListValue.wrap(registryManager.get(Registry.CONFIGURED_STRUCTURE_FEATURE_WORLDGEN).getIds().stream().sorted().map(ValueConversions::of).collect(Collectors.toList()))
ListValue.wrap(registryManager.get(Registry.CONFIGURED_STRUCTURE_FEATURE_KEY).getIds().stream().sorted().map(ValueConversions::of).collect(Collectors.toList()))
);
Value ret = MapValue.wrap(plopData);
return (_c, _t) -> ret;
@@ -1188,7 +1188,7 @@ public class Auxiliary {
if (!existing_worlds.containsKey(registryKey))
{
addeds.add(ValueConversions.of(registryKey.getValue()));
RegistryKey<World> registryKey2 = RegistryKey.of(Registry.DIMENSION, registryKey.getValue());
RegistryKey<World> registryKey2 = RegistryKey.of(Registry.WORLD_KEY, registryKey.getValue());
DimensionType dimensionType3 = entry.getValue().getDimensionType();
ChunkGenerator chunkGenerator3 = entry.getValue().getChunkGenerator();
UnmodifiableLevelProperties unmodifiableLevelProperties = new UnmodifiableLevelProperties(saveProperties, ((ServerWorldInterface) server.getOverworld()).getWorldPropertiesCM());
@@ -216,10 +216,10 @@ public class BlockIterators {
List<Value> neighbours = new ArrayList<>();
neighbours.add(new BlockValue(null, world, center.up()));
neighbours.add(new BlockValue(null, world, center.down()));
neighbours.add(new BlockValue(null, world, center.method_35861())); // north
neighbours.add(new BlockValue(null, world, center.method_35859())); // sourh
neighbours.add(new BlockValue(null, world, center.method_35855())); // east
neighbours.add(new BlockValue(null, world, center.method_35857())); // west
neighbours.add(new BlockValue(null, world, center.north()));
neighbours.add(new BlockValue(null, world, center.south()));
neighbours.add(new BlockValue(null, world, center.east()));
neighbours.add(new BlockValue(null, world, center.west()));
Value retval = ListValue.wrap(neighbours);
return (c_, t_) -> retval;
});
@@ -1307,7 +1307,7 @@ public class WorldAccess {
BlockBox box = start.setBoundingBoxFromChildren();
structureList.put(
new StringValue(NBTSerializableValue.nameFromRegistryId(Registry.STRUCTURE_FEATURE.getId(entry.getKey()))),
ListValue.of(ListValue.fromTriple(box.method_35420(), box.method_35415(), box.method_35416()), ListValue.fromTriple(box.method_35417(), box.method_35418(), box.method_35419()))
ListValue.of(ListValue.fromTriple(box.getMinX(), box.getMinY(), box.getMinZ()), ListValue.fromTriple(box.getMaxX(), box.getMaxY(), box.getMaxZ()))
);
}
Value ret = MapValue.wrap(structureList);
@@ -1357,9 +1357,9 @@ public class WorldAccess {
StructureStart<?> start = structures.get(structure);
ChunkPos structureChunkPos = start.getPos(); // new ChunkPos(start.getChunkX(), start.getChunkZ());
BlockBox box = start.setBoundingBoxFromChildren();
for (int chx = box.method_35420() / 16; chx <= box.method_35417() / 16; chx++) // minx maxx
for (int chx = box.getMinX() / 16; chx <= box.getMaxX() / 16; chx++) // minx maxx
{
for (int chz = box.method_35416() / 16; chz <= box.method_35419() / 16; chz++) //minZ maxZ
for (int chz = box.getMinZ() / 16; chz <= box.getMaxZ() / 16; chz++) //minZ maxZ
{
ChunkPos chpos = new ChunkPos(chx, chz);
// getting a chunk will convert it to full, allowing to modify references
@@ -34,7 +34,7 @@ public class BiomeInfo
put("scale", (w, b) -> NumericValue.of(b.getScale()));
put("features", (w, b) -> {
Registry<ConfiguredFeature<?,?>> registry = w.getRegistryManager().get(Registry.CONFIGURED_FEATURE_WORLDGEN);
Registry<ConfiguredFeature<?,?>> registry = w.getRegistryManager().get(Registry.CONFIGURED_FEATURE_KEY);
return ListValue.wrap(
b.getGenerationSettings().getFeatures().stream().map(step ->
ListValue.wrap(step.stream().map(cfp ->
@@ -44,7 +44,7 @@ public class BiomeInfo
);
});
put("structures", (w, b) -> {
Registry<ConfiguredStructureFeature<?,?>> registry = w.getRegistryManager().get(Registry.CONFIGURED_STRUCTURE_FEATURE_WORLDGEN);
Registry<ConfiguredStructureFeature<?,?>> registry = w.getRegistryManager().get(Registry.CONFIGURED_STRUCTURE_FEATURE_KEY);
return ListValue.wrap(b.getGenerationSettings().getStructureFeatures().stream().map(str -> ValueConversions.of(registry.getId(str.get()))));
});
}};
@@ -314,7 +314,7 @@ public class ShapeDispatcher
key = 0;
followEntity = -1;
shapeDimension = RegistryKey.of(Registry.DIMENSION, new Identifier(options.get("dim").getString()));
shapeDimension = RegistryKey.of(Registry.WORLD_KEY, new Identifier(options.get("dim").getString()));
if (options.containsKey("follow"))
{
followEntity = NumericValue.asNumber(options.getOrDefault("follow", optional.get("follow"))).getInt();
@@ -100,20 +100,20 @@ public class WorldTools
DimensionType dimensionType2;
if (dimensionOptions == null) {
dimensionType2 = server.getRegistryManager().getMutable(Registry.DIMENSION_TYPE_KEY).getOrThrow(DimensionType.OVERWORLD_REGISTRY_KEY);
chunkGenerator2 = GeneratorOptions.createOverworldGenerator(server.getRegistryManager().get(Registry.BIOME_KEY), server.getRegistryManager().get(Registry.NOISE_SETTINGS_WORLDGEN), (new Random()).nextLong());
chunkGenerator2 = GeneratorOptions.createOverworldGenerator(server.getRegistryManager().get(Registry.BIOME_KEY), server.getRegistryManager().get(Registry.CHUNK_GENERATOR_SETTINGS_KEY), (new Random()).nextLong());
} else {
dimensionType2 = dimensionOptions.getDimensionType();
chunkGenerator2 = dimensionOptions.getChunkGenerator();
}
RegistryKey<World> customWorld = RegistryKey.of(Registry.DIMENSION, worldId);
RegistryKey<World> customWorld = RegistryKey.of(Registry.WORLD_KEY, worldId);
//chunkGenerator2 = GeneratorOptions.createOverworldGenerator(server.getRegistryManager().get(Registry.BIOME_KEY), server.getRegistryManager().get(Registry.NOISE_SETTINGS_WORLDGEN), (seed==null)?l:seed);
chunkGenerator2 = new NoiseChunkGenerator(
new VanillaLayeredBiomeSource((seed==null)?l:seed, false, false, server.getRegistryManager().get(Registry.BIOME_KEY)),
(seed==null)?l:seed,
() -> server.getRegistryManager().get(Registry.NOISE_SETTINGS_WORLDGEN).getOrThrow(ChunkGeneratorSettings.OVERWORLD)
() -> server.getRegistryManager().get(Registry.CHUNK_GENERATOR_SETTINGS_KEY).getOrThrow(ChunkGeneratorSettings.OVERWORLD)
);
ServerWorld serverWorld = new ServerWorld(
@@ -15,11 +15,11 @@ import net.minecraft.block.ChestBlock;
import net.minecraft.block.InventoryProvider;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.ChestBlockEntity;
import net.minecraft.class_6067;
import net.minecraft.command.argument.ItemStackArgument;
import net.minecraft.command.argument.ItemStringReader;
import net.minecraft.command.argument.NbtPathArgumentType;
import net.minecraft.entity.Entity;
import net.minecraft.entity.InventoryOwner;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.passive.MerchantEntity;
@@ -226,8 +226,8 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
Entity e = ((EntityValue) v1).getEntity();
if (e instanceof PlayerEntity) inv = ((PlayerEntity) e).getInventory();
else if (e instanceof Inventory) inv = (Inventory) e;
else if (e instanceof class_6067) inv = ((class_6067) e).method_35199(); // getInentory // now covers pillagers
else if (e instanceof InventoryBearerInterface) inv = ((InventoryBearerInterface)e).getCMInventory();
else if (e instanceof InventoryOwner) inv = ((InventoryOwner) e).getInventory();
else if (e instanceof InventoryBearerInterface) inv = ((InventoryBearerInterface)e).getCMInventory(); // horse only
else if (e instanceof LivingEntity) return new InventoryLocator(e, e.getBlockPos(), new EquipmentInventory((MobEntity) e), offset+1);
if (inv == null)
return null;
@@ -302,27 +302,32 @@ public class ValueConversions
);
}
public static Value of(BlockBox box)
{
return ListValue.of(
ListValue.fromTriple(box.getMinX(), box.getMinY(), box.getMinZ()),
ListValue.fromTriple(box.getMaxX(), box.getMaxY(), box.getMaxZ())
);
}
public static Value of(StructureStart<?> structure)
{
if (structure == null || structure == StructureStart.DEFAULT) return Value.NULL;
BlockBox boundingBox = structure.setBoundingBoxFromChildren();
if (boundingBox.method_35417() < boundingBox.method_35420() || boundingBox.method_35418() < boundingBox.method_35415() || boundingBox.method_35419() < boundingBox.method_35416()) return Value.NULL;
if (boundingBox.getMaxX() < boundingBox.getMinX() || boundingBox.getMaxY() < boundingBox.getMinY() || boundingBox.getMaxZ() < boundingBox.getMinZ()) return Value.NULL;
Map<Value, Value> ret = new HashMap<>();
ret.put(new StringValue("box"), ListValue.of(
ListValue.fromTriple(boundingBox.method_35420(), boundingBox.method_35415(), boundingBox.method_35416()),
ListValue.fromTriple(boundingBox.method_35417(), boundingBox.method_35418(), boundingBox.method_35419())
));
ret.put(new StringValue("box"), of(boundingBox));
List<Value> pieces = new ArrayList<>();
for (StructurePiece piece : structure.getChildren())
{
BlockBox box = piece.getBoundingBox();
if (box.method_35417() >= box.method_35420() && box.method_35418() >= box.method_35415() && box.method_35419() >= box.method_35416())
if (box.getMaxX() >= box.getMinX() && box.getMaxY() >= box.getMinY() && box.getMaxZ() >= box.getMinZ())
{
pieces.add(ListValue.of(
new StringValue(NBTSerializableValue.nameFromRegistryId(Registry.STRUCTURE_PIECE.getId(piece.getType()))),
(piece.getFacing() == null) ? Value.NULL : new StringValue(piece.getFacing().getName()),
ListValue.fromTriple(box.method_35420(), box.method_35415(), box.method_35416()),
ListValue.fromTriple(box.method_35417(), box.method_35418(), box.method_35419())
ListValue.fromTriple(box.getMinX(), box.getMinY(), box.getMinZ()),
ListValue.fromTriple(box.getMaxX(), box.getMaxY(), box.getMaxZ())
));
}
}
+1 -1
View File
@@ -184,7 +184,7 @@ public class BlockInfo
put(Material.REPAIR_STATION , "anvil" );
put(Material.BARRIER , "barrier" );
put(Material.PISTON , "piston" );
put(Material.UNUSED_PLANT , "coral" );
put(Material.MOSS_BLOCK , "moss" );
put(Material.GOURD , "gourd" );
put(Material.EGG , "dragon_egg" );
put(Material.CAKE , "cake" );