-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
3,680 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package me.ulrich.structure; | ||
|
||
import me.ulrich.structure.nbt.tag.CompoundTag; | ||
|
||
public class GAttributeModifier { | ||
private String attributeName; | ||
private String name; | ||
private String slot; | ||
private int operation; | ||
private double amount; | ||
private long UUIDMost; | ||
private long UUIDLeast; | ||
|
||
public void read(CompoundTag tag) { | ||
this.attributeName = tag.getString("AttributeName"); | ||
this.name = tag.getString("Name"); | ||
this.slot = tag.getString("Slot"); | ||
this.operation = tag.getInt("Operation"); | ||
this.amount = tag.getDouble("Amount"); | ||
this.UUIDMost = tag.getLong("UUIDMost"); | ||
this.UUIDLeast = tag.getLong("UUIDLeast"); | ||
} | ||
|
||
public String getAttributeName() { | ||
return attributeName; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getSlot() { | ||
return slot; | ||
} | ||
|
||
public int getOperation() { | ||
return operation; | ||
} | ||
|
||
public double getAmount() { | ||
return amount; | ||
} | ||
|
||
public long getUUIDMost() { | ||
return UUIDMost; | ||
} | ||
|
||
public long getUUIDLeast() { | ||
return UUIDLeast; | ||
} | ||
|
||
public static GAttributeModifier readNewModifier(CompoundTag tag) { | ||
GAttributeModifier m = new GAttributeModifier(); | ||
m.read(tag); | ||
return m; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package me.ulrich.structure; | ||
|
||
import me.ulrich.structure.BlockEntityTag.BlockEntityTag; | ||
import me.ulrich.structure.nbt.tag.CompoundTag; | ||
import me.ulrich.structure.nbt.tag.IntTag; | ||
import me.ulrich.structure.nbt.tag.ListTag; | ||
|
||
public class GBlock { | ||
|
||
// format from https://minecraft.gamepedia.com/Structure_block_file_format | ||
|
||
private int x; | ||
private int y; | ||
private int z; | ||
private int state; | ||
private BlockEntityTag nbt; | ||
|
||
public GBlock(int x, int y, int z, int state) { | ||
this.x = x; | ||
this.y = y; | ||
this.z = z; | ||
this.state = state; | ||
} | ||
|
||
public GBlock() { | ||
this.x = 0; | ||
this.y = 0; | ||
this.z = 0; | ||
this.state = 0; | ||
} | ||
|
||
public void read(CompoundTag tag) { | ||
this.state = tag.getInt("state"); | ||
|
||
ListTag<IntTag> pos = tag.getListTag("pos").asIntTagList(); | ||
this.x = pos.get(0).asInt(); | ||
this.y = pos.get(1).asInt(); | ||
this.z = pos.get(2).asInt(); | ||
|
||
if (tag.containsKey("nbt")) { | ||
nbt = BlockEntityTag.readNewEntity(tag.getCompoundTag("nbt"), null); | ||
} | ||
} | ||
|
||
public BlockEntityTag getNBT() { | ||
return nbt; | ||
} | ||
public int getX() { | ||
return x; | ||
} | ||
|
||
public int getY() { | ||
return y; | ||
} | ||
|
||
public int getZ() { | ||
return z; | ||
} | ||
|
||
public int getState() { | ||
return state; | ||
} | ||
|
||
public void setX(int x) { | ||
this.x = x; | ||
} | ||
|
||
public void setY(int y) { | ||
this.y = y; | ||
} | ||
|
||
public void setZ(int z) { | ||
this.z = z; | ||
} | ||
|
||
public void setState(int state) { | ||
this.state = state; | ||
} | ||
|
||
public static GBlock readNewBlock(CompoundTag tag) { | ||
GBlock b = new GBlock(); | ||
b.read(tag); | ||
return b; | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
src/main/java/me/ulrich/structure/GCustomPotionEffect.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package me.ulrich.structure; | ||
|
||
import org.bukkit.potion.PotionEffect; | ||
import org.bukkit.potion.PotionEffectType; | ||
|
||
import me.ulrich.structure.nbt.tag.CompoundTag; | ||
|
||
public class GCustomPotionEffect { | ||
private byte id; | ||
private byte amplifier; | ||
private int duration; | ||
private byte ambient; | ||
private byte showParticles; | ||
private byte showIcon; | ||
|
||
public void read(CompoundTag tag) { | ||
id = tag.getByte("Id"); | ||
amplifier = tag.getByte("Amplifier"); | ||
duration = tag.getInt("Duration"); | ||
ambient = tag.getByte("Ambient"); | ||
showParticles = tag.getByte("ShowParticles"); | ||
showIcon = tag.getByte("ShowIcon"); | ||
} | ||
|
||
public byte getId() { | ||
return id; | ||
} | ||
|
||
public byte getAmplifier() { | ||
return amplifier; | ||
} | ||
|
||
public int getDuration() { | ||
return duration; | ||
} | ||
|
||
public byte getAmbient() { | ||
return ambient; | ||
} | ||
|
||
public byte getShowParticles() { | ||
return showParticles; | ||
} | ||
|
||
public byte getShowIcon() { | ||
return showIcon; | ||
} | ||
|
||
public static GCustomPotionEffect readNewEffect(CompoundTag tag) { | ||
GCustomPotionEffect e = new GCustomPotionEffect(); | ||
e.read(tag); | ||
return e; | ||
} | ||
|
||
@SuppressWarnings("deprecation") | ||
public PotionEffect get() { | ||
return new PotionEffect(PotionEffectType.getById(id), duration, (int)amplifier, getAmbientAsBoolean(), getShowParticlesAsBoolean(), getShowIconAsBoolean()); | ||
} | ||
|
||
private boolean getShowIconAsBoolean() { | ||
if (showIcon == 1) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
private boolean getShowParticlesAsBoolean() { | ||
if (showParticles == 1) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
private boolean getAmbientAsBoolean() { | ||
if (ambient == 1) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package me.ulrich.structure; | ||
|
||
import me.ulrich.structure.nbt.tag.CompoundTag; | ||
|
||
public class GDecoration { | ||
private String id; | ||
private byte type; | ||
private double x; | ||
private double z; | ||
private double rot; | ||
|
||
public void read(CompoundTag tag) { | ||
id = tag.getString("id"); | ||
type = tag.getByte("type"); | ||
x = tag.getDouble("x"); | ||
z = tag.getDouble("z"); | ||
rot = tag.getDouble("rot"); | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public byte getType() { | ||
return type; | ||
} | ||
|
||
public double getX() { | ||
return x; | ||
} | ||
|
||
public double getZ() { | ||
return z; | ||
} | ||
|
||
public double getRot() { | ||
return rot; | ||
} | ||
|
||
public static GDecoration readNewDecoration(CompoundTag tag) { | ||
GDecoration d = new GDecoration(); | ||
d.read(tag); | ||
return d; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package me.ulrich.structure; | ||
|
||
import org.bukkit.potion.PotionEffect; | ||
import org.bukkit.potion.PotionEffectType; | ||
|
||
import me.ulrich.structure.nbt.tag.CompoundTag; | ||
|
||
public class GEffect { | ||
private byte effectId; | ||
private int effectDuration; | ||
|
||
public void read(CompoundTag tag) { | ||
effectId = tag.getByte("EffectId"); | ||
effectDuration = tag.getInt("EffectDuration"); | ||
} | ||
|
||
public byte getEffectId() { | ||
return effectId; | ||
} | ||
|
||
public int getEffectDuration() { | ||
return effectDuration; | ||
} | ||
|
||
public static GEffect readNewEffect(CompoundTag tag) { | ||
GEffect e = new GEffect(); | ||
e.read(tag); | ||
return e; | ||
} | ||
|
||
@SuppressWarnings("deprecation") | ||
public PotionEffect get() { | ||
return new PotionEffect(PotionEffectType.getById(effectId), effectDuration, 1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package me.ulrich.structure; | ||
|
||
import org.bukkit.NamespacedKey; | ||
import org.bukkit.enchantments.Enchantment; | ||
|
||
import me.ulrich.structure.nbt.tag.CompoundTag; | ||
|
||
public class GEnchantment { | ||
private String id; | ||
private int lvl; | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public int getLvl() { | ||
return lvl; | ||
} | ||
|
||
public void read(CompoundTag tag) { | ||
this.id = tag.getString("id"); | ||
this.lvl = tag.getShort("lvl"); | ||
} | ||
|
||
public static GEnchantment readNewEnchantment(CompoundTag tag) { | ||
GEnchantment e = new GEnchantment(); | ||
e.read(tag); | ||
return e; | ||
} | ||
|
||
public Enchantment get() { | ||
return Enchantment.getByKey(NamespacedKey.minecraft(id.replaceFirst("minecraft:", ""))); | ||
} | ||
} |
Oops, something went wrong.