From 8a079c98cce49c395f62fbe883ce67ae57f05ee4 Mon Sep 17 00:00:00 2001 From: Daniel Mills Date: Thu, 5 Aug 2021 19:27:30 -0400 Subject: [PATCH] Slices for entities & tiles --- .../volmit/iris/util/matter/MatterEntity.java | 29 +++++++++++ .../volmit/iris/util/matter/MatterTile.java | 29 +++++++++++ .../iris/util/matter/slices/EntityMatter.java | 50 +++++++++++++++++++ .../iris/util/matter/slices/TileMatter.java | 28 +++++------ 4 files changed, 120 insertions(+), 16 deletions(-) create mode 100644 src/main/java/com/volmit/iris/util/matter/MatterEntity.java create mode 100644 src/main/java/com/volmit/iris/util/matter/MatterTile.java create mode 100644 src/main/java/com/volmit/iris/util/matter/slices/EntityMatter.java diff --git a/src/main/java/com/volmit/iris/util/matter/MatterEntity.java b/src/main/java/com/volmit/iris/util/matter/MatterEntity.java new file mode 100644 index 000000000..925087376 --- /dev/null +++ b/src/main/java/com/volmit/iris/util/matter/MatterEntity.java @@ -0,0 +1,29 @@ +/* + * Iris is a World Generator for Minecraft Bukkit Servers + * Copyright (c) 2021 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.volmit.iris.util.matter; + +import com.volmit.iris.util.nbt.tag.CompoundTag; +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class MatterEntity { + private final CompoundTag tileData; +} diff --git a/src/main/java/com/volmit/iris/util/matter/MatterTile.java b/src/main/java/com/volmit/iris/util/matter/MatterTile.java new file mode 100644 index 000000000..87cab3943 --- /dev/null +++ b/src/main/java/com/volmit/iris/util/matter/MatterTile.java @@ -0,0 +1,29 @@ +/* + * Iris is a World Generator for Minecraft Bukkit Servers + * Copyright (c) 2021 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.volmit.iris.util.matter; + +import com.volmit.iris.util.nbt.tag.CompoundTag; +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class MatterTile { + private final CompoundTag tileData; +} diff --git a/src/main/java/com/volmit/iris/util/matter/slices/EntityMatter.java b/src/main/java/com/volmit/iris/util/matter/slices/EntityMatter.java new file mode 100644 index 000000000..0c004bb97 --- /dev/null +++ b/src/main/java/com/volmit/iris/util/matter/slices/EntityMatter.java @@ -0,0 +1,50 @@ +/* + * Iris is a World Generator for Minecraft Bukkit Servers + * Copyright (c) 2021 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.volmit.iris.util.matter.slices; + +import com.volmit.iris.util.matter.MatterEntity; +import com.volmit.iris.util.matter.MatterTile; +import com.volmit.iris.util.matter.Sliced; +import com.volmit.iris.util.nbt.io.NBTUtil; +import com.volmit.iris.util.nbt.tag.CompoundTag; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +@Sliced +public class EntityMatter extends RawMatter { + public EntityMatter() { + this(1, 1, 1); + } + + public EntityMatter(int width, int height, int depth) { + super(width, height, depth, MatterEntity.class); + } + + @Override + public void writeNode(MatterEntity b, DataOutputStream dos) throws IOException { + NBTUtil.write(b.getTileData(), dos, false); + } + + @Override + public MatterEntity readNode(DataInputStream din) throws IOException { + return new MatterEntity((CompoundTag) NBTUtil.read(din, false).getTag()); + } +} diff --git a/src/main/java/com/volmit/iris/util/matter/slices/TileMatter.java b/src/main/java/com/volmit/iris/util/matter/slices/TileMatter.java index 56c4aa313..420046826 100644 --- a/src/main/java/com/volmit/iris/util/matter/slices/TileMatter.java +++ b/src/main/java/com/volmit/iris/util/matter/slices/TileMatter.java @@ -18,37 +18,33 @@ package com.volmit.iris.util.matter.slices; -import com.volmit.iris.engine.parallax.ParallaxAccess; -import com.volmit.iris.engine.parallax.ParallaxWorld; -import com.volmit.iris.util.data.B; +import com.volmit.iris.util.matter.MatterTile; import com.volmit.iris.util.matter.Sliced; -import org.bukkit.World; -import org.bukkit.block.Chest; -import org.bukkit.block.TileState; -import org.bukkit.block.data.BlockData; +import com.volmit.iris.util.nbt.io.NBTUtil; +import com.volmit.iris.util.nbt.tag.CompoundTag; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; @Sliced -public class TileMatter extends RawMatter { +public class TileMatter extends RawMatter { public TileMatter() { this(1, 1, 1); } public TileMatter(int width, int height, int depth) { - super(width, height, depth, TileState.class); + super(width, height, depth, MatterTile.class); + } + + @Override + public void writeNode(MatterTile b, DataOutputStream dos) throws IOException { + NBTUtil.write(b.getTileData(), dos, false); } @Override - public void writeNode(TileState b, DataOutputStream dos) throws IOException { - - } - - @Override - public TileState readNode(DataInputStream din) throws IOException { - return null; + public MatterTile readNode(DataInputStream din) throws IOException { + return new MatterTile((CompoundTag) NBTUtil.read(din, false).getTag()); } }