diff options
author | syeyoung <cyong06@naver.com> | 2021-02-26 14:57:15 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-02-26 14:57:15 +0900 |
commit | e429287b83904d4d0576c3cf292a85eabb48c888 (patch) | |
tree | 7d239c05934460dabb8c7a44a8de94fe966efc1e /src/main/java/kr/syeyoung/dungeonsguide | |
parent | 0e2ae080900bcb9c34d2013848bd9d2c5bae1e28 (diff) | |
download | Skyblock-Dungeons-Guide-e429287b83904d4d0576c3cf292a85eabb48c888.tar.gz Skyblock-Dungeons-Guide-e429287b83904d4d0576c3cf292a85eabb48c888.tar.bz2 Skyblock-Dungeons-Guide-e429287b83904d4d0576c3cf292a85eabb48c888.zip |
schematics bruh
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide')
-rw-r--r-- | src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java | 41 | ||||
-rwxr-xr-x | src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/GeneralEditPane.java | 31 |
2 files changed, 67 insertions, 5 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java index b53917ee..e329beb6 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java @@ -16,20 +16,25 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.command.CommandBase; import net.minecraft.command.ICommandSender; +import net.minecraft.nbt.CompressedStreamTools; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ChatComponentText; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; +import net.minecraftforge.fml.relauncher.ReflectionHelper; import javax.crypto.BadPaddingException; import javax.crypto.IllegalBlockSizeException; import javax.crypto.NoSuchPaddingException; import java.awt.*; import java.io.*; +import java.lang.reflect.Method; import java.security.*; import java.security.cert.CertificateException; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.zip.GZIPOutputStream; public class CommandDungeonsGuide extends CommandBase { @Override @@ -191,6 +196,42 @@ public class CommandDungeonsGuide extends CommandBase { } catch (Throwable t) { t.printStackTrace(); } +// } else if (args[0].equals("fixschematic")) { +// File root = new File(e.getDungeonsGuide().getConfigDir(), "schematics"); +// Method method = null; +// try { +// method = NBTTagCompound.class.getDeclaredMethod("write", DataOutput.class); +// method.setAccessible(true); +// } catch (NoSuchMethodException e) { +// e.printStackTrace(); +// return; +// } +// for (File f : root.listFiles()) { +// try { +// NBTTagCompound nbtTagCompound = CompressedStreamTools.readCompressed(new FileInputStream(f)); +// if (nbtTagCompound.getKeySet().isEmpty()) { +// System.out.println("ah"); +// return; +// } +// nbtTagCompound.setString("Materials","Alpha"); +// FileOutputStream fos = new FileOutputStream(f); +// DataOutputStream dataoutputstream = new DataOutputStream(new BufferedOutputStream(new GZIPOutputStream(fos))); +// +// try +// { +// dataoutputstream.writeByte(nbtTagCompound.getId()); +// +// dataoutputstream.writeUTF("Schematic"); +// method.invoke(nbtTagCompound, dataoutputstream); +// } +// finally +// { +// dataoutputstream.close(); +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } } else { sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §e/dg §7-§fOpens configuration gui")); sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §e/dg gui §7-§fOpens configuration gui")); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/GeneralEditPane.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/GeneralEditPane.java index f4450bd2..c23d7c0d 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/GeneralEditPane.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/GeneralEditPane.java @@ -18,9 +18,11 @@ import net.minecraft.util.BlockPos; import net.minecraft.util.ChatComponentText; import java.awt.*; -import java.io.File; +import java.io.*; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.UUID; +import java.util.zip.GZIPOutputStream; public class GeneralEditPane extends MPanel { private DungeonRoom dungeonRoom; @@ -130,13 +132,32 @@ public class GeneralEditPane extends MPanel { public void run() { try { NBTTagCompound nbtTagCompound2 = createNBT(); - NBTTagCompound real = new NBTTagCompound(); - real.setTag("Schematic", nbtTagCompound2); File f=new File(e.getDungeonsGuide().getConfigDir(), "schematics/"+ dungeonRoom.getDungeonRoomInfo().getName()+"-"+dungeonRoom.getDungeonRoomInfo().getUuid().toString()+"-"+ UUID.randomUUID()+".schematic"); - CompressedStreamTools.write(nbtTagCompound2, f); + Method method = null; + try { + method = NBTTagCompound.class.getDeclaredMethod("write", DataOutput.class); + method.setAccessible(true); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + return; + } + FileOutputStream fos = new FileOutputStream(f); + DataOutputStream dataoutputstream = new DataOutputStream(new BufferedOutputStream(new GZIPOutputStream(fos))); + + try + { + dataoutputstream.writeByte(nbtTagCompound2.getId()); + + dataoutputstream.writeUTF("Schematic"); + method.invoke(nbtTagCompound2, dataoutputstream); + } + finally + { + dataoutputstream.close(); + } Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §fSaved to "+f.getName())); } catch (Throwable e) { e.printStackTrace(); @@ -235,7 +256,7 @@ public class GeneralEditPane extends MPanel { compound.setByteArray("Blocks", blocks); compound.setByteArray("Data", meta); - compound.setString("Materials", "Classic"); + compound.setString("Materials", "Alpha"); if (extraEx) { compound.setByteArray("AddBlocks", extranibble); } |