mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-27 23:47:38 +01:00
Structure Assist
- Schematic and Quill now creates Air entries in place of any "Structure Void" block
This commit is contained in:
parent
34d430989c
commit
4d819b6c9d
4 changed files with 28 additions and 4 deletions
|
@ -535,9 +535,10 @@ public class BeltTileEntity extends KineticTileEntity implements ILightUpdateLis
|
|||
|
||||
@Override
|
||||
public boolean onLightUpdate(IBlockDisplayReader world, LightType type, GridAlignedBB changed) {
|
||||
if (this.remove) {
|
||||
if (this.remove)
|
||||
return true;
|
||||
}
|
||||
if (this.level == null || this.light == null)
|
||||
return false;
|
||||
|
||||
GridAlignedBB beltVolume = getBeltVolume();
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ import com.simibubi.create.AllBlocks;
|
|||
import com.simibubi.create.AllItems;
|
||||
import com.simibubi.create.Create;
|
||||
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.foundation.config.AllConfigs;
|
||||
import com.simibubi.create.foundation.config.CSchematics;
|
||||
|
@ -319,6 +320,7 @@ public class ServerSchematicLoader {
|
|||
|
||||
try (OutputStream outputStream = Files.newOutputStream(path)) {
|
||||
CompoundNBT nbttagcompound = t.save(new CompoundNBT());
|
||||
SchematicAndQuillItem.replaceStructureVoidWithAir(nbttagcompound);
|
||||
CompressedStreamTools.writeCompressed(nbttagcompound, outputStream);
|
||||
player.setItemInHand(Hand.MAIN_HAND, SchematicItem.create(schematic, player.getGameProfile().getName()));
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import com.simibubi.create.AllSpecialTextures;
|
|||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.CreateClient;
|
||||
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.foundation.gui.ScreenOpener;
|
||||
import com.simibubi.create.foundation.networking.AllPackets;
|
||||
|
@ -126,7 +127,7 @@ public class SchematicAndQuillHandler {
|
|||
firstPos = selectedPos;
|
||||
Lang.sendStatus(player, "schematicAndQuill.firstPos");
|
||||
}
|
||||
|
||||
|
||||
public void discard() {
|
||||
ClientPlayerEntity player = Minecraft.getInstance().player;
|
||||
firstPos = null;
|
||||
|
@ -213,7 +214,8 @@ public class SchematicAndQuillHandler {
|
|||
t.fillFromWorld(Minecraft.getInstance().level, origin, bounds, true, Blocks.AIR);
|
||||
|
||||
if (string.isEmpty())
|
||||
string = Lang.translate("schematicAndQuill.fallbackName").getString();
|
||||
string = Lang.translate("schematicAndQuill.fallbackName")
|
||||
.getString();
|
||||
|
||||
String folderPath = "schematics";
|
||||
FilesHelper.createFolderIfMissing(folderPath);
|
||||
|
@ -225,6 +227,7 @@ public class SchematicAndQuillHandler {
|
|||
try {
|
||||
outputStream = Files.newOutputStream(path, StandardOpenOption.CREATE);
|
||||
CompoundNBT nbttagcompound = t.save(new CompoundNBT());
|
||||
SchematicAndQuillItem.replaceStructureVoidWithAir(nbttagcompound);
|
||||
CompressedStreamTools.writeCompressed(nbttagcompound, outputStream);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
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.nbt.CompoundNBT;
|
||||
|
||||
public class SchematicAndQuillItem extends Item {
|
||||
|
||||
|
@ -8,4 +12,18 @@ public class SchematicAndQuillItem extends Item {
|
|||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue