Structure Assist

- Schematic and Quill now creates Air entries in place of any "Structure Void" block
This commit is contained in:
simibubi 2021-09-30 21:31:35 +02:00
parent 34d430989c
commit 4d819b6c9d
4 changed files with 28 additions and 4 deletions

View file

@ -535,9 +535,10 @@ public class BeltTileEntity extends KineticTileEntity implements ILightUpdateLis
@Override @Override
public boolean onLightUpdate(IBlockDisplayReader world, LightType type, GridAlignedBB changed) { public boolean onLightUpdate(IBlockDisplayReader world, LightType type, GridAlignedBB changed) {
if (this.remove) { if (this.remove)
return true; return true;
} if (this.level == null || this.light == null)
return false;
GridAlignedBB beltVolume = getBeltVolume(); GridAlignedBB beltVolume = getBeltVolume();

View file

@ -17,6 +17,7 @@ import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllItems; import com.simibubi.create.AllItems;
import com.simibubi.create.Create; import com.simibubi.create.Create;
import com.simibubi.create.content.schematics.block.SchematicTableTileEntity; import com.simibubi.create.content.schematics.block.SchematicTableTileEntity;
import com.simibubi.create.content.schematics.item.SchematicAndQuillItem;
import com.simibubi.create.content.schematics.item.SchematicItem; import com.simibubi.create.content.schematics.item.SchematicItem;
import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.config.CSchematics; import com.simibubi.create.foundation.config.CSchematics;
@ -319,6 +320,7 @@ public class ServerSchematicLoader {
try (OutputStream outputStream = Files.newOutputStream(path)) { try (OutputStream outputStream = Files.newOutputStream(path)) {
CompoundNBT nbttagcompound = t.save(new CompoundNBT()); CompoundNBT nbttagcompound = t.save(new CompoundNBT());
SchematicAndQuillItem.replaceStructureVoidWithAir(nbttagcompound);
CompressedStreamTools.writeCompressed(nbttagcompound, outputStream); CompressedStreamTools.writeCompressed(nbttagcompound, outputStream);
player.setItemInHand(Hand.MAIN_HAND, SchematicItem.create(schematic, player.getGameProfile().getName())); player.setItemInHand(Hand.MAIN_HAND, SchematicItem.create(schematic, player.getGameProfile().getName()));

View file

@ -15,6 +15,7 @@ import com.simibubi.create.AllSpecialTextures;
import com.simibubi.create.Create; import com.simibubi.create.Create;
import com.simibubi.create.CreateClient; import com.simibubi.create.CreateClient;
import com.simibubi.create.content.schematics.ClientSchematicLoader; import com.simibubi.create.content.schematics.ClientSchematicLoader;
import com.simibubi.create.content.schematics.item.SchematicAndQuillItem;
import com.simibubi.create.content.schematics.packet.InstantSchematicPacket; import com.simibubi.create.content.schematics.packet.InstantSchematicPacket;
import com.simibubi.create.foundation.gui.ScreenOpener; import com.simibubi.create.foundation.gui.ScreenOpener;
import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.networking.AllPackets;
@ -213,7 +214,8 @@ public class SchematicAndQuillHandler {
t.fillFromWorld(Minecraft.getInstance().level, origin, bounds, true, Blocks.AIR); t.fillFromWorld(Minecraft.getInstance().level, origin, bounds, true, Blocks.AIR);
if (string.isEmpty()) if (string.isEmpty())
string = Lang.translate("schematicAndQuill.fallbackName").getString(); string = Lang.translate("schematicAndQuill.fallbackName")
.getString();
String folderPath = "schematics"; String folderPath = "schematics";
FilesHelper.createFolderIfMissing(folderPath); FilesHelper.createFolderIfMissing(folderPath);
@ -225,6 +227,7 @@ public class SchematicAndQuillHandler {
try { try {
outputStream = Files.newOutputStream(path, StandardOpenOption.CREATE); outputStream = Files.newOutputStream(path, StandardOpenOption.CREATE);
CompoundNBT nbttagcompound = t.save(new CompoundNBT()); CompoundNBT nbttagcompound = t.save(new CompoundNBT());
SchematicAndQuillItem.replaceStructureVoidWithAir(nbttagcompound);
CompressedStreamTools.writeCompressed(nbttagcompound, outputStream); CompressedStreamTools.writeCompressed(nbttagcompound, outputStream);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();

View file

@ -1,6 +1,10 @@
package com.simibubi.create.content.schematics.item; package com.simibubi.create.content.schematics.item;
import com.simibubi.create.foundation.utility.NBTHelper;
import net.minecraft.block.Blocks;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.nbt.CompoundNBT;
public class SchematicAndQuillItem extends Item { public class SchematicAndQuillItem extends Item {
@ -8,4 +12,18 @@ public class SchematicAndQuillItem extends Item {
super(properties); super(properties);
} }
public static void replaceStructureVoidWithAir(CompoundNBT nbt) {
String air = Blocks.AIR.getRegistryName()
.toString();
String structureVoid = Blocks.STRUCTURE_VOID.getRegistryName()
.toString();
NBTHelper.iterateCompoundList(nbt.getList("palette", 10), c -> {
if (c.contains("Name") && c.getString("Name")
.equals(structureVoid)) {
c.putString("Name", air);
}
});
}
} }