mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-03-04 06:44:40 +01:00
Ant Schematics
- Fix schematic gametest
This commit is contained in:
parent
f9c774e338
commit
94d17bc34f
6 changed files with 15 additions and 13 deletions
|
@ -51,7 +51,7 @@ public class SchematicInstances {
|
|||
return null;
|
||||
|
||||
StructureTemplate activeTemplate =
|
||||
SchematicItem.loadSchematic(wrapped.holderLookup(Registries.BLOCK), schematic);
|
||||
SchematicItem.loadSchematic(wrapped, schematic);
|
||||
|
||||
if (activeTemplate.getSize()
|
||||
.equals(Vec3i.ZERO))
|
||||
|
|
|
@ -14,6 +14,8 @@ import javax.annotation.Nonnull;
|
|||
|
||||
import net.createmod.catnip.platform.CatnipServices;
|
||||
|
||||
import net.minecraft.core.registries.Registries;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.mojang.logging.LogUtils;
|
||||
|
@ -58,7 +60,7 @@ public class SchematicItem extends Item {
|
|||
super(properties);
|
||||
}
|
||||
|
||||
public static ItemStack create(HolderGetter<Block> lookup, String schematic, String owner) {
|
||||
public static ItemStack create(Level level, String schematic, String owner) {
|
||||
ItemStack blueprint = AllItems.SCHEMATIC.asStack();
|
||||
|
||||
CompoundTag tag = new CompoundTag();
|
||||
|
@ -70,7 +72,7 @@ public class SchematicItem extends Item {
|
|||
tag.putString("Mirror", Mirror.NONE.name());
|
||||
blueprint.setTag(tag);
|
||||
|
||||
writeSize(lookup, blueprint);
|
||||
writeSize(level, blueprint);
|
||||
return blueprint;
|
||||
}
|
||||
|
||||
|
@ -88,9 +90,9 @@ public class SchematicItem extends Item {
|
|||
super.appendHoverText(stack, worldIn, tooltip, flagIn);
|
||||
}
|
||||
|
||||
public static void writeSize(HolderGetter<Block> lookup, ItemStack blueprint) {
|
||||
public static void writeSize(Level level, ItemStack blueprint) {
|
||||
CompoundTag tag = blueprint.getTag();
|
||||
StructureTemplate t = loadSchematic(lookup, blueprint);
|
||||
StructureTemplate t = loadSchematic(level, blueprint);
|
||||
tag.put("Bounds", NBTHelper.writeVec3i(t.getSize()));
|
||||
blueprint.setTag(tag);
|
||||
SchematicInstances.clearHash(blueprint);
|
||||
|
@ -110,7 +112,7 @@ public class SchematicItem extends Item {
|
|||
return settings;
|
||||
}
|
||||
|
||||
public static StructureTemplate loadSchematic(HolderGetter<Block> lookup, ItemStack blueprint) {
|
||||
public static StructureTemplate loadSchematic(Level level, ItemStack blueprint) {
|
||||
StructureTemplate t = new StructureTemplate();
|
||||
String owner = blueprint.getTag()
|
||||
.getString("Owner");
|
||||
|
@ -123,7 +125,7 @@ public class SchematicItem extends Item {
|
|||
Path dir;
|
||||
Path file;
|
||||
|
||||
if (CatnipServices.PLATFORM.getEnv().isServer()) {
|
||||
if (!level.isClientSide()) {
|
||||
dir = Paths.get("schematics", "uploaded").toAbsolutePath();
|
||||
file = Paths.get(owner, schematic);
|
||||
} else {
|
||||
|
@ -138,7 +140,7 @@ public class SchematicItem extends Item {
|
|||
try (DataInputStream stream = new DataInputStream(new BufferedInputStream(
|
||||
new GZIPInputStream(Files.newInputStream(path, StandardOpenOption.READ))))) {
|
||||
CompoundTag nbt = NbtIo.read(stream, new NbtAccounter(0x20000000L));
|
||||
t.load(lookup, nbt);
|
||||
t.load(level.holderLookup(Registries.BLOCK), nbt);
|
||||
} catch (IOException e) {
|
||||
LOGGER.warn("Failed to read schematic", e);
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ public class SchematicPrinter {
|
|||
return;
|
||||
|
||||
StructureTemplate activeTemplate =
|
||||
SchematicItem.loadSchematic(originalWorld.holderLookup(Registries.BLOCK), blueprint);
|
||||
SchematicItem.loadSchematic(originalWorld, blueprint);
|
||||
StructurePlaceSettings settings = SchematicItem.getSettings(blueprint, processNBT);
|
||||
|
||||
schematicAnchor = NbtUtils.readBlockPos(blueprint.getTag()
|
||||
|
|
|
@ -270,7 +270,7 @@ public class ServerSchematicLoader {
|
|||
if (table == null)
|
||||
return;
|
||||
table.finishUpload();
|
||||
table.inventory.setStackInSlot(1, SchematicItem.create(world.holderLookup(Registries.BLOCK), schematic, player.getGameProfile()
|
||||
table.inventory.setStackInSlot(1, SchematicItem.create(world, schematic, player.getGameProfile()
|
||||
.getName()));
|
||||
|
||||
} catch (IOException e) {
|
||||
|
@ -319,7 +319,7 @@ public class ServerSchematicLoader {
|
|||
);
|
||||
if (result != null)
|
||||
player.setItemInHand(InteractionHand.MAIN_HAND,
|
||||
SchematicItem.create(world.holderLookup(Registries.BLOCK), schematic, playerName));
|
||||
SchematicItem.create(world, schematic, playerName));
|
||||
else
|
||||
CreateLang.translate("schematicAndQuill.instant_failed")
|
||||
.style(ChatFormatting.RED)
|
||||
|
|
|
@ -153,7 +153,7 @@ public class SchematicHandler implements IGuiOverlay {
|
|||
private void setupRenderer() {
|
||||
Level clientWorld = Minecraft.getInstance().level;
|
||||
StructureTemplate schematic =
|
||||
SchematicItem.loadSchematic(clientWorld.holderLookup(Registries.BLOCK), activeSchematicItem);
|
||||
SchematicItem.loadSchematic(clientWorld, activeSchematicItem);
|
||||
Vec3i size = schematic.getSize();
|
||||
if (size.equals(Vec3i.ZERO))
|
||||
return;
|
||||
|
|
|
@ -40,7 +40,7 @@ public class TestMisc {
|
|||
level, whiteEndBottom, redEndTop
|
||||
);
|
||||
ItemStack schematic =
|
||||
SchematicItem.create(level.holderLookup(Registries.BLOCK), "schematicannon_gametest.nbt", "Deployer");
|
||||
SchematicItem.create(level, "schematicannon_gametest.nbt", "Deployer");
|
||||
// deploy to pos
|
||||
BlockPos anchor = helper.absolutePos(new BlockPos(1, 2, 1));
|
||||
schematic.getOrCreateTag().putBoolean("Deployed", true);
|
||||
|
|
Loading…
Add table
Reference in a new issue