mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
"Spawner Support"
This commit is contained in:
parent
1e832ed0eb
commit
30b8619dd1
@ -19,6 +19,7 @@ public interface TileData<T extends TileState> extends Cloneable {
|
|||||||
KList<TileData<? extends TileState>> registry = new KList<>();
|
KList<TileData<? extends TileState>> registry = new KList<>();
|
||||||
|
|
||||||
registry.add(new TileSign());
|
registry.add(new TileSign());
|
||||||
|
registry.add(new TileSpawner());
|
||||||
|
|
||||||
return registry;
|
return registry;
|
||||||
}
|
}
|
||||||
|
64
src/main/java/com/volmit/iris/object/tile/TileSpawner.java
Normal file
64
src/main/java/com/volmit/iris/object/tile/TileSpawner.java
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
package com.volmit.iris.object.tile;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import net.querz.nbt.tag.CompoundTag;
|
||||||
|
import net.querz.nbt.tag.ListTag;
|
||||||
|
import org.bukkit.block.CreatureSpawner;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
import org.bukkit.block.data.type.WallSign;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class TileSpawner implements TileData<CreatureSpawner> {
|
||||||
|
public static int id = TileData.id;
|
||||||
|
private EntityType entityType;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isApplicable(BlockData data) {
|
||||||
|
return data instanceof org.bukkit.block.data.type.Sign || data instanceof WallSign;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toBukkit(CreatureSpawner t) {
|
||||||
|
t.setSpawnedType(entityType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fromBukkit(CreatureSpawner sign) {
|
||||||
|
entityType = sign.getSpawnedType();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileSpawner clone() {
|
||||||
|
TileSpawner ts = new TileSpawner();
|
||||||
|
ts.setEntityType(getEntityType());
|
||||||
|
return ts;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toBinary(DataOutputStream out) throws IOException {
|
||||||
|
out.writeShort(id);
|
||||||
|
out.writeShort(entityType.ordinal());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fromBinary(DataInputStream in) throws IOException {
|
||||||
|
entityType = EntityType.values()[in.readShort()];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toNBT(CompoundTag tag) {
|
||||||
|
ListTag<CompoundTag> potentials = (ListTag<CompoundTag>) ListTag.createUnchecked(CompoundTag.class);
|
||||||
|
CompoundTag t = new CompoundTag();
|
||||||
|
CompoundTag ent = new CompoundTag();
|
||||||
|
ent.putString("id", entityType.getKey().toString());
|
||||||
|
t.put("Entity", ent);
|
||||||
|
t.putInt("Weight", 1);
|
||||||
|
potentials.add(t);
|
||||||
|
tag.put("SpawnPotentials", potentials);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user