extend dimension system, remove dim ids
This commit is contained in:
parent
a080ed5583
commit
f613bd2122
46 changed files with 1216 additions and 1283 deletions
|
@ -70,7 +70,7 @@ public class BlockBed extends Block implements Rotatable {
|
|||
}
|
||||
if(player.isEntityAlive() && Math.abs(player.posX - (double)pos.getX()) <= 3.0D
|
||||
&& Math.abs(player.posY - (double)pos.getY()) <= 2.0D && Math.abs(player.posZ - (double)pos.getZ()) <= 3.0D) {
|
||||
player.setSpawnPoint(new WorldPos(pos, player.worldObj.dimension.getDimensionId()));
|
||||
player.setSpawnPoint(new WorldPos(pos, player.worldObj));
|
||||
player.connection.addHotbar(TextColor.DGREEN + "Dein Einstiegspunkt wurde auf %s bei [%s, %s, %s] gesetzt",
|
||||
player.worldObj.dimension.getFormattedName(false), player.getSpawnPoint().getX(),
|
||||
player.getSpawnPoint().getY(), player.getSpawnPoint().getZ());
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package common.dimension;
|
||||
|
||||
public final class Area extends Dimension {
|
||||
Area(int id, String name) {
|
||||
super(id, name);
|
||||
Area() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
public Area(int id, String name, int sky, int fog, float temperature, int brightness) {
|
||||
super(id, name);
|
||||
public Area(int sky, int fog, float temperature, int brightness) {
|
||||
super(false);
|
||||
this.setPhysics(1L, 1L, 0.0f, 10.0f, temperature, brightness);
|
||||
this.setSkyColor(sky).setFogColor(fog);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -6,9 +6,10 @@ import common.collect.Sets;
|
|||
|
||||
public final class Domain extends Nameable implements Comparable<Domain> {
|
||||
public final String id;
|
||||
private final Set<Area> areas = Sets.newTreeSet();
|
||||
private final Set<Area> areas = Sets.newHashSet();
|
||||
|
||||
public Domain(String id) {
|
||||
public Domain(String id, boolean custom) {
|
||||
super(custom);
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
@ -23,8 +24,4 @@ public final class Domain extends Nameable implements Comparable<Domain> {
|
|||
protected String getNameIdentifier() {
|
||||
return "%s";
|
||||
}
|
||||
|
||||
protected String getIdentifier() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,8 @@ public final class Galaxy extends Nameable implements Comparable<Galaxy> {
|
|||
public final String id;
|
||||
private final Set<Sector> sectors = Sets.newTreeSet();
|
||||
|
||||
public Galaxy(String id) {
|
||||
public Galaxy(String id, boolean custom) {
|
||||
super(custom);
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
@ -23,8 +24,4 @@ public final class Galaxy extends Nameable implements Comparable<Galaxy> {
|
|||
protected String getNameIdentifier() {
|
||||
return "Galaxie %s";
|
||||
}
|
||||
|
||||
protected String getIdentifier() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package common.dimension;
|
||||
|
||||
public final class Moon extends Dimension {
|
||||
Moon(int id, String name) {
|
||||
super(id, name);
|
||||
Moon() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
public Moon(int id, String name, int sky, int fog, long orbit, long rotation, float gravity, float temperature, int brightness) {
|
||||
super(id, name);
|
||||
public Moon(int sky, int fog, long orbit, long rotation, float gravity, float temperature, int brightness) {
|
||||
super(false);
|
||||
this.setPhysics(orbit, rotation, 0.0f, gravity, temperature, brightness);
|
||||
this.setTimeQualifier(7);
|
||||
this.setStarBrightness(0.75f).setDeepStarBrightness(0.75f);
|
||||
|
|
|
@ -1,35 +1,31 @@
|
|||
package common.dimension;
|
||||
|
||||
import common.tags.TagObject;
|
||||
|
||||
public abstract class Nameable {
|
||||
protected String customName = null;
|
||||
private final boolean custom;
|
||||
|
||||
private String display = null;
|
||||
|
||||
protected Nameable(boolean custom) {
|
||||
this.custom = custom;
|
||||
}
|
||||
|
||||
public final String getCustomName() {
|
||||
return this.customName;
|
||||
return this.display;
|
||||
}
|
||||
|
||||
public final void setCustomName(String name) {
|
||||
this.customName = name;
|
||||
this.display = name;
|
||||
}
|
||||
|
||||
public void readTags(TagObject tag) {
|
||||
this.customName = tag.hasString("CustomName") ? tag.getString("CustomName") : null;
|
||||
}
|
||||
|
||||
public void writeTags(TagObject tag) {
|
||||
if(this.customName != null)
|
||||
tag.setString("CustomName", this.customName);
|
||||
}
|
||||
public final boolean isCustom() {
|
||||
return this.custom;
|
||||
}
|
||||
|
||||
protected abstract String getNameIdentifier();
|
||||
protected abstract String getIdentifier();
|
||||
|
||||
public final String getNameString() {
|
||||
return this.customName != null && !this.customName.isEmpty()
|
||||
? (this.customName.startsWith("'") && this.customName.endsWith("'") && this.customName.length() > 2
|
||||
? this.customName.substring(1, this.customName.length() - 1) :
|
||||
String.format(this.getNameIdentifier(), this.customName)) :
|
||||
String.format(this.getNameIdentifier(), this.getIdentifier());
|
||||
return this.display.startsWith("'") && this.display.endsWith("'") && this.display.length() > 2
|
||||
? this.display.substring(1, this.display.length() - 1) :
|
||||
String.format(this.getNameIdentifier(), this.display);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,29 +5,29 @@ import java.util.Set;
|
|||
import common.collect.Sets;
|
||||
|
||||
public final class Planet extends Dimension {
|
||||
private final Set<Moon> moons = Sets.newTreeSet();
|
||||
private final Set<Moon> moons = Sets.newHashSet();
|
||||
|
||||
Planet(int id, String name) {
|
||||
super(id, name);
|
||||
Planet() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
public Planet(int id, String name, int sky, int fog, int clouds, long orbit, long rotation, float gravity, float temperature,
|
||||
public Planet(int sky, int fog, int clouds, long orbit, long rotation, float gravity, float temperature,
|
||||
int brightness) {
|
||||
this(id, name, sky, fog, clouds, orbit, rotation, 0.0f, gravity, temperature, brightness);
|
||||
this(sky, fog, clouds, orbit, rotation, 0.0f, gravity, temperature, brightness);
|
||||
}
|
||||
|
||||
public Planet(int id, String name, int sky, int fog, int clouds, long orbit, long rotation, float offset, float gravity,
|
||||
public Planet(int sky, int fog, int clouds, long orbit, long rotation, float offset, float gravity,
|
||||
float temperature) {
|
||||
this(id, name, sky, fog, clouds, orbit, rotation, offset, gravity, temperature, 0);
|
||||
this(sky, fog, clouds, orbit, rotation, offset, gravity, temperature, 0);
|
||||
}
|
||||
|
||||
public Planet(int id, String name, int sky, int fog, int clouds, long orbit, long rotation, float gravity, float temperature) {
|
||||
this(id, name, sky, fog, clouds, orbit, rotation, 0.0f, gravity, temperature, 0);
|
||||
public Planet(int sky, int fog, int clouds, long orbit, long rotation, float gravity, float temperature) {
|
||||
this(sky, fog, clouds, orbit, rotation, 0.0f, gravity, temperature, 0);
|
||||
}
|
||||
|
||||
public Planet(int id, String name, int sky, int fog, int clouds, long orbit, long rotation, float offset, float gravity,
|
||||
public Planet(int sky, int fog, int clouds, long orbit, long rotation, float offset, float gravity,
|
||||
float temperature, int brightness) {
|
||||
super(id, name);
|
||||
super(false);
|
||||
this.setPhysics(orbit, rotation, offset, gravity, temperature, brightness);
|
||||
this.setTimeQualifier(7);
|
||||
this.setStarBrightness(0.5f).setDeepStarBrightness(0.0f);
|
||||
|
|
|
@ -6,9 +6,10 @@ import common.collect.Sets;
|
|||
|
||||
public final class Sector extends Nameable implements Comparable<Sector> {
|
||||
public final String id;
|
||||
private final Set<Star> stars = Sets.newTreeSet();
|
||||
private final Set<Star> stars = Sets.newHashSet();
|
||||
|
||||
public Sector(String id) {
|
||||
public Sector(String id, boolean custom) {
|
||||
super(custom);
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
@ -23,8 +24,4 @@ public final class Sector extends Nameable implements Comparable<Sector> {
|
|||
protected String getNameIdentifier() {
|
||||
return "Sektor %s";
|
||||
}
|
||||
|
||||
protected String getIdentifier() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package common.dimension;
|
||||
|
||||
public final class Semi extends Dimension {
|
||||
Semi(int id, String name) {
|
||||
super(id, name);
|
||||
Semi() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
public Semi(int id, String name, int sky, int fog, int clouds, float temperature, int brightness) {
|
||||
super(id, name);
|
||||
public Semi(int sky, int fog, int clouds, float temperature, int brightness) {
|
||||
super(false);
|
||||
this.setPhysics(1L, 1L, 0.0f, 10.0f, temperature, brightness);
|
||||
this.setStarBrightness(0.5f).setDeepStarBrightness(0.5f);
|
||||
this.setSkyColor(sky).setFogColor(fog).setCloudColor(clouds);
|
||||
|
|
|
@ -6,10 +6,9 @@ public final class Space extends Dimension {
|
|||
public static final Space INSTANCE = new Space();
|
||||
|
||||
private Space() {
|
||||
super(0, "space");
|
||||
super(false);
|
||||
this.setPhysics(1L, 1L, 0.0f, 0.0f, 2.7f, 15).setTimeQualifier(8);
|
||||
this.setBiome(Biome.SPACE).setStarBrightness(1.0f).setDeepStarBrightness(1.0f);
|
||||
this.setCustomName("Der Weltraum");
|
||||
}
|
||||
|
||||
public final DimType getType() {
|
||||
|
|
|
@ -6,14 +6,14 @@ import common.collect.Sets;
|
|||
import common.world.State;
|
||||
|
||||
public final class Star extends Dimension {
|
||||
private final Set<Planet> planets = Sets.newTreeSet();
|
||||
private final Set<Planet> planets = Sets.newHashSet();
|
||||
|
||||
Star(int id, String name) {
|
||||
super(id, name);
|
||||
Star() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
public Star(int id, String name, int color, float gravity, float temp, State surface, int height) {
|
||||
super(id, name);
|
||||
public Star(int color, float gravity, float temp, State surface, int height) {
|
||||
super(false);
|
||||
this.setPhysics(1L, 1L, 0.0f, gravity, temp, 15);
|
||||
this.setTimeQualifier(7);
|
||||
this.setStarBrightness(0.75f).setDeepStarBrightness(0.75f);
|
||||
|
|
|
@ -11,6 +11,7 @@ import common.block.artificial.BlockWall;
|
|||
import common.block.liquid.BlockLiquid;
|
||||
import common.color.TextColor;
|
||||
import common.dimension.DimType;
|
||||
import common.dimension.Dimension;
|
||||
import common.enchantment.Enchantment;
|
||||
import common.enchantment.EnchantmentHelper;
|
||||
import common.entity.effect.EntityLightning;
|
||||
|
@ -268,8 +269,8 @@ public abstract class Entity
|
|||
protected void checkPortal() {
|
||||
if(this.inPortal != null) {
|
||||
if(this.vehicle == null && this.passenger == null && Vars.portals) {
|
||||
int current = this.worldObj.dimension.getDimensionId();
|
||||
int dest = UniverseRegistry.getPortalDest(current, this.inPortal);
|
||||
Dimension current = this.worldObj.dimension;
|
||||
Dimension dest = UniverseRegistry.getPortalDest(current, this.inPortal);
|
||||
if(dest != current) {
|
||||
this.travelToDimension(dest, null, 0.0f, 0.0f, this.inPortal);
|
||||
this.inPortal = null;
|
||||
|
@ -357,8 +358,8 @@ public abstract class Entity
|
|||
protected void onVoidUpdate() {
|
||||
if(!this.worldObj.client && this.worldObj.dimension.getType() != DimType.SPACE) {
|
||||
// this.worldObj.profiler.start("descent");
|
||||
int current = this.worldObj.dimension.getDimensionId();
|
||||
int dim = Vars.voidPortal ? UniverseRegistry.getPortalDest(current, PortalType.VOID) : current;
|
||||
Dimension current = this.worldObj.dimension;
|
||||
Dimension dim = Vars.voidPortal ? UniverseRegistry.getPortalDest(current, PortalType.VOID) : current;
|
||||
if(dim == current) { // && (!(this.isPlayer()) || !((EntityNPCMP)this).creative)) {
|
||||
this.kill();
|
||||
}
|
||||
|
@ -1804,17 +1805,23 @@ public abstract class Entity
|
|||
return (double)this.height * 0.75D;
|
||||
}
|
||||
|
||||
public void teleport(double x, double y, double z, float yaw, float pitch, int dimension) {
|
||||
public void teleport(double x, double y, double z, float yaw, float pitch, Dimension dimension) {
|
||||
if(dimension == null)
|
||||
return;
|
||||
x = ExtMath.clampd(x, -World.MAX_SIZE + 1, World.MAX_SIZE - 1);
|
||||
z = ExtMath.clampd(z, -World.MAX_SIZE + 1, World.MAX_SIZE - 1);
|
||||
this.unmount();
|
||||
Entity entity = this;
|
||||
if(this.worldObj.dimension.getDimensionId() != dimension) {
|
||||
if(this.worldObj.dimension != dimension) {
|
||||
entity = this.travelToDimension(dimension, new BlockPos(x, y, z), yaw, pitch, null);
|
||||
}
|
||||
entity.setLocationAndAngles(x, y, z, yaw, pitch);
|
||||
entity.setRotationYawHead(yaw);
|
||||
}
|
||||
|
||||
public final void teleport(double x, double y, double z, float yaw, float pitch, World world) {
|
||||
this.teleport(x, y, z, yaw, pitch, world.dimension);
|
||||
}
|
||||
|
||||
// protected void setY(double y) {
|
||||
// this.unmount();
|
||||
|
@ -1823,13 +1830,17 @@ public abstract class Entity
|
|||
// }
|
||||
|
||||
public final void teleport(Position pos) {
|
||||
this.teleport(pos.x(), pos.y(), pos.z(), pos.yaw(), pos.pitch(), pos.dim());
|
||||
this.teleport(pos.x(), pos.y(), pos.z(), pos.yaw(), pos.pitch(), pos.getDimension());
|
||||
}
|
||||
|
||||
public final void teleport(BlockPos pos, int dim) {
|
||||
public final void teleport(BlockPos pos, Dimension dim) {
|
||||
this.teleport(((double)pos.getX()) + 0.5, (double)pos.getY(), ((double)pos.getZ()) + 0.5, this.rotYaw, this.rotPitch, dim);
|
||||
}
|
||||
|
||||
public final void teleport(BlockPos pos, World world) {
|
||||
this.teleport(pos, world.dimension);
|
||||
}
|
||||
|
||||
// public final Position getLocation() {
|
||||
// return new Position(this);
|
||||
// }
|
||||
|
@ -2329,7 +2340,7 @@ public abstract class Entity
|
|||
/**
|
||||
* Teleports the entity to another dimension. Params: Dimension number to teleport to
|
||||
*/
|
||||
public Entity travelToDimension(int dimensionId, BlockPos pos, float yaw, float pitch, PortalType portal)
|
||||
public Entity travelToDimension(Dimension dimensionId, BlockPos pos, float yaw, float pitch, PortalType portal)
|
||||
{
|
||||
if (!this.worldObj.client && !this.dead)
|
||||
{
|
||||
|
@ -2619,7 +2630,7 @@ public abstract class Entity
|
|||
}
|
||||
|
||||
public Position getPos() {
|
||||
return new Position(this.posX, this.posY, this.posZ, this.rotYaw, this.rotPitch, this.worldObj.dimension.getDimensionId());
|
||||
return new Position(this.posX, this.posY, this.posZ, this.rotYaw, this.rotPitch, this.worldObj);
|
||||
}
|
||||
|
||||
public abstract EntityType getType();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package common.entity.item;
|
||||
|
||||
import common.collect.Lists;
|
||||
import common.dimension.Dimension;
|
||||
import common.entity.DamageSource;
|
||||
import common.entity.Entity;
|
||||
import common.entity.npc.EntityNPC;
|
||||
|
@ -166,7 +167,7 @@ public abstract class EntityCartContainer extends EntityCart implements ILockabl
|
|||
/**
|
||||
* Teleports the entity to another dimension. Params: Dimension number to teleport to
|
||||
*/
|
||||
public Entity travelToDimension(int dimensionId, BlockPos pos, float yaw, float pitch, PortalType portal)
|
||||
public Entity travelToDimension(Dimension dimensionId, BlockPos pos, float yaw, float pitch, PortalType portal)
|
||||
{
|
||||
this.dropContentsWhenDead = false;
|
||||
return super.travelToDimension(dimensionId, pos, yaw, pitch, portal);
|
||||
|
|
|
@ -2,6 +2,7 @@ package common.entity.item;
|
|||
|
||||
import common.block.Material;
|
||||
import common.color.TextColor;
|
||||
import common.dimension.Dimension;
|
||||
import common.entity.DamageSource;
|
||||
import common.entity.Entity;
|
||||
import common.entity.EntityType;
|
||||
|
@ -477,7 +478,7 @@ public class EntityItem extends Entity
|
|||
/**
|
||||
* Teleports the entity to another dimension. Params: Dimension number to teleport to
|
||||
*/
|
||||
public Entity travelToDimension(int dimensionId, BlockPos pos, float yaw, float pitch, PortalType portal)
|
||||
public Entity travelToDimension(Dimension dimensionId, BlockPos pos, float yaw, float pitch, PortalType portal)
|
||||
{
|
||||
Entity entity = super.travelToDimension(dimensionId, pos, yaw, pitch, portal);
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package common.entity.item;
|
|||
|
||||
import common.block.Material;
|
||||
import common.color.TextColor;
|
||||
import common.dimension.Dimension;
|
||||
import common.entity.DamageSource;
|
||||
import common.entity.Entity;
|
||||
import common.entity.EntityType;
|
||||
|
@ -196,7 +197,7 @@ public class EntityXp extends Entity implements IObjectData
|
|||
}
|
||||
}
|
||||
|
||||
public Entity travelToDimension(int dimensionId, BlockPos pos, float yaw, float pitch, PortalType portal)
|
||||
public Entity travelToDimension(Dimension dimensionId, BlockPos pos, float yaw, float pitch, PortalType portal)
|
||||
{
|
||||
Entity entity = super.travelToDimension(dimensionId, pos, yaw, pitch, portal);
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ import common.block.Block;
|
|||
import common.block.artificial.BlockBed;
|
||||
import common.collect.Lists;
|
||||
import common.color.TextColor;
|
||||
import common.dimension.Dimension;
|
||||
import common.dimension.Space;
|
||||
import common.enchantment.Enchantment;
|
||||
import common.enchantment.EnchantmentHelper;
|
||||
|
@ -48,6 +49,7 @@ import common.init.NameRegistry;
|
|||
import common.init.SoundEvent;
|
||||
import common.init.SpeciesRegistry;
|
||||
import common.init.TradeRegistry;
|
||||
import common.init.UniverseRegistry;
|
||||
import common.init.SpeciesRegistry.ModelType;
|
||||
import common.inventory.Container;
|
||||
import common.inventory.ContainerPlayer;
|
||||
|
@ -206,7 +208,7 @@ public abstract class EntityNPC extends EntityLiving
|
|||
public double chasingPosX;
|
||||
public double chasingPosY;
|
||||
public double chasingPosZ;
|
||||
private WorldPos originPos = new WorldPos(0, 64, 0, Space.INSTANCE.getDimensionId());
|
||||
private WorldPos originPos = new WorldPos(0, 64, 0, Space.INSTANCE);
|
||||
private WorldPos spawnPos;
|
||||
public int experienceLevel;
|
||||
public int experienceTotal;
|
||||
|
@ -2891,13 +2893,13 @@ public abstract class EntityNPC extends EntityLiving
|
|||
}
|
||||
}
|
||||
|
||||
public Entity travelToDimension(int dimensionId, BlockPos pos, float yaw, float pitch, PortalType portal) {
|
||||
public Entity travelToDimension(Dimension dimensionId, BlockPos pos, float yaw, float pitch, PortalType portal) {
|
||||
if(this.connection != null)
|
||||
this.connection.travelToDimension(dimensionId, pos, yaw, pitch, portal);
|
||||
return this.isPlayer() ? this : super.travelToDimension(dimensionId, pos, yaw, pitch, portal);
|
||||
}
|
||||
|
||||
public void teleport(double x, double y, double z, float yaw, float pitch, int dimension) {
|
||||
public void teleport(double x, double y, double z, float yaw, float pitch, Dimension dimension) {
|
||||
if(this.connection != null)
|
||||
this.connection.teleport(x, y, z, yaw, pitch, dimension);
|
||||
else if(!this.isPlayer())
|
||||
|
@ -3458,17 +3460,19 @@ public abstract class EntityNPC extends EntityLiving
|
|||
// this.wakeUpPlayer();
|
||||
// }
|
||||
|
||||
if (tagCompund.hasInt("SpawnX") && tagCompund.hasInt("SpawnY") && tagCompund.hasInt("SpawnZ"))
|
||||
if (tagCompund.hasInt("SpawnX") && tagCompund.hasInt("SpawnY") && tagCompund.hasInt("SpawnZ") && tagCompund.hasString("SpawnDim"))
|
||||
{
|
||||
this.spawnPos = new WorldPos(tagCompund.getInt("SpawnX"), tagCompund.getInt("SpawnY"),
|
||||
tagCompund.getInt("SpawnZ"), tagCompund.getInt("SpawnDim"));
|
||||
Dimension dim = UniverseRegistry.getDimension(tagCompund.getString("SpawnDim"));
|
||||
this.spawnPos = dim == null ? null : new WorldPos(tagCompund.getInt("SpawnX"), tagCompund.getInt("SpawnY"),
|
||||
tagCompund.getInt("SpawnZ"), dim);
|
||||
// this.spawnForced = tagCompund.getBoolean("SpawnForced");
|
||||
}
|
||||
|
||||
if (tagCompund.hasInt("OriginX") && tagCompund.hasInt("OriginY") && tagCompund.hasInt("OriginZ"))
|
||||
if (tagCompund.hasInt("OriginX") && tagCompund.hasInt("OriginY") && tagCompund.hasInt("OriginZ") && tagCompund.hasString("OriginDim"))
|
||||
{
|
||||
this.originPos = new WorldPos(tagCompund.getInt("OriginX"), tagCompund.getInt("OriginY"),
|
||||
tagCompund.getInt("OriginZ"), tagCompund.getInt("OriginDim"));
|
||||
Dimension dim = UniverseRegistry.getDimension(tagCompund.getString("OriginDim"));
|
||||
this.originPos = dim == null ? new WorldPos(0, 64, 0, Space.INSTANCE) : new WorldPos(tagCompund.getInt("OriginX"), tagCompund.getInt("OriginY"),
|
||||
tagCompund.getInt("OriginZ"), dim);
|
||||
}
|
||||
|
||||
// this.foodStats.readNBT(tagCompund);
|
||||
|
@ -3572,19 +3576,25 @@ public abstract class EntityNPC extends EntityLiving
|
|||
|
||||
if (this.spawnPos != null)
|
||||
{
|
||||
tagCompound.setInt("SpawnX", this.spawnPos.getX());
|
||||
tagCompound.setInt("SpawnY", this.spawnPos.getY());
|
||||
tagCompound.setInt("SpawnZ", this.spawnPos.getZ());
|
||||
tagCompound.setInt("SpawnDim", this.spawnPos.getDimension());
|
||||
Dimension dim = this.spawnPos.getDimension();
|
||||
if(dim != null) {
|
||||
tagCompound.setInt("SpawnX", this.spawnPos.getX());
|
||||
tagCompound.setInt("SpawnY", this.spawnPos.getY());
|
||||
tagCompound.setInt("SpawnZ", this.spawnPos.getZ());
|
||||
tagCompound.setString("SpawnDim", UniverseRegistry.getName(dim));
|
||||
}
|
||||
// tagCompound.setBoolean("SpawnForced", this.spawnForced);
|
||||
}
|
||||
|
||||
if (this.originPos != null)
|
||||
{
|
||||
tagCompound.setInt("OriginX", this.originPos.getX());
|
||||
tagCompound.setInt("OriginY", this.originPos.getY());
|
||||
tagCompound.setInt("OriginZ", this.originPos.getZ());
|
||||
tagCompound.setInt("OriginDim", this.originPos.getDimension());
|
||||
Dimension dim = this.originPos.getDimension();
|
||||
if(dim != null) {
|
||||
tagCompound.setInt("OriginX", this.originPos.getX());
|
||||
tagCompound.setInt("OriginY", this.originPos.getY());
|
||||
tagCompound.setInt("OriginZ", this.originPos.getZ());
|
||||
tagCompound.setString("OriginDim", UniverseRegistry.getName(dim));
|
||||
}
|
||||
}
|
||||
|
||||
// this.foodStats.writeNBT(tagCompound);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -16,9 +16,9 @@ public class ItemInfoWand extends ItemWand {
|
|||
public void onUse(ItemStack stack, EntityNPC player, AWorldServer world, Vec3 vec)
|
||||
{
|
||||
Biome biome = world.getBiomeGenForCoords(new BlockPos(vec.xCoord, 0, vec.zCoord));
|
||||
player.connection.addHotbar(TextColor.NEON + "* Position bei Level %d: %.3f %.3f %.3f, %s [%d], %.2f °C", world.dimension.getDimensionId(),
|
||||
player.connection.addHotbar(TextColor.NEON + "* Position in %s: %.3f %.3f %.3f, %s, %.2f °C", world.dimension.getFormattedName(false),
|
||||
vec.xCoord, vec.yCoord, vec.zCoord,
|
||||
biome.display, biome.id, world.getTemperatureC(new BlockPos(vec)));
|
||||
biome.display, world.getTemperatureC(new BlockPos(vec)));
|
||||
}
|
||||
|
||||
public int getRange(ItemStack stack, EntityNPC player) {
|
||||
|
|
|
@ -34,8 +34,8 @@ public class ItemSpaceNavigator extends ItemMagnetic {
|
|||
public String getHotbarText(EntityNPC player, ItemStack stack) {
|
||||
BlockPos pos = player.getPosition();
|
||||
return TextColor.ORANGE + formatImperialTime(player.worldObj, false) + " / " +
|
||||
String.format("%s (%d) bei %d, %d, %d", player.worldObj.dimension.getFormattedName(false) + TextColor.ORANGE,
|
||||
player.worldObj.dimension.getDimensionId(), pos.getX(), pos.getY(), pos.getZ());
|
||||
String.format("%s bei %d, %d, %d", player.worldObj.dimension.getFormattedName(false) + TextColor.ORANGE,
|
||||
pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
||||
public void addInformation(ItemStack stack, EntityNPC player, List<String> tooltip) {
|
||||
|
@ -45,7 +45,7 @@ public class ItemSpaceNavigator extends ItemMagnetic {
|
|||
tooltip.add(TextColor.ORANGE + dims[z]);
|
||||
}
|
||||
BlockPos pos = player.getPosition();
|
||||
tooltip.add(TextColor.ORANGE + String.format("%s (%d) bei %d, %d, %d", player.worldObj.dimension.getFormattedName(false)
|
||||
+ TextColor.ORANGE, player.worldObj.dimension.getDimensionId(), pos.getX(), pos.getY(), pos.getZ()));
|
||||
tooltip.add(TextColor.ORANGE + String.format("%s bei %d, %d, %d", player.worldObj.dimension.getFormattedName(false)
|
||||
+ TextColor.ORANGE, pos.getX(), pos.getY(), pos.getZ()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package common.network;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import common.dimension.Dimension;
|
||||
import common.entity.Entity;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.entity.types.EntityLiving;
|
||||
|
@ -76,8 +77,8 @@ public interface IPlayer extends NetHandler {
|
|||
void addHotbar(String format, Object... args);
|
||||
void sendThrowMessage(ItemStack stack);
|
||||
void resetLastExperience();
|
||||
void travelToDimension(int dimension, BlockPos pos, float yaw, float pitch, PortalType portal);
|
||||
void teleport(double x, double y, double z, float yaw, float pitch, int dimension);
|
||||
void travelToDimension(Dimension dimension, BlockPos pos, float yaw, float pitch, PortalType portal);
|
||||
void teleport(double x, double y, double z, float yaw, float pitch, Dimension dimension);
|
||||
void onItemPickup(Entity entity, int amount);
|
||||
void mountEntity(Entity entity);
|
||||
void openEditSign(TileEntitySign signTile);
|
||||
|
|
|
@ -16,8 +16,7 @@ public class SPacketDimensionName implements Packet<IClientPlayer> {
|
|||
|
||||
public SPacketDimensionName(Dimension dim) {
|
||||
this.fullName = dim.getFormattedName(true);
|
||||
this.customName = dim.getCustomName() != null && dim.getCustomName().length() > 64 ? dim.getCustomName().substring(0, 64) :
|
||||
dim.getCustomName();
|
||||
this.customName = dim.getCustomName();
|
||||
}
|
||||
|
||||
public void processPacket(IClientPlayer handler) {
|
||||
|
@ -25,14 +24,13 @@ public class SPacketDimensionName implements Packet<IClientPlayer> {
|
|||
}
|
||||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException {
|
||||
this.fullName = buf.readString(64);
|
||||
this.customName = buf.readString(64);
|
||||
this.customName = this.customName.isEmpty() ? null : this.customName;
|
||||
this.fullName = buf.readString(4096);
|
||||
this.customName = buf.readString(1024);
|
||||
}
|
||||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException {
|
||||
buf.writeString(this.fullName);
|
||||
buf.writeString(this.customName == null ? "" : this.customName);
|
||||
buf.writeString(this.customName);
|
||||
}
|
||||
|
||||
public String getFullName() {
|
||||
|
|
|
@ -4,38 +4,27 @@ import java.io.IOException;
|
|||
|
||||
import common.dimension.Dimension;
|
||||
import common.network.IClientPlayer;
|
||||
import common.network.Packet;
|
||||
import common.network.PacketBuffer;
|
||||
import common.tags.TagObject;
|
||||
|
||||
public class SPacketJoinGame implements Packet<IClientPlayer> {
|
||||
public class SPacketJoinGame extends SPacketRespawn {
|
||||
private int entityId;
|
||||
private TagObject dimension;
|
||||
private int type;
|
||||
private boolean editor;
|
||||
|
||||
public SPacketJoinGame() {
|
||||
}
|
||||
|
||||
public SPacketJoinGame(int entityIdIn, Dimension dimensionIn, int type, boolean editor) {
|
||||
this.entityId = entityIdIn;
|
||||
this.dimension = dimensionIn.toTags(false);
|
||||
this.type = type;
|
||||
this.editor = editor;
|
||||
public SPacketJoinGame(int id, Dimension dim, int type, boolean editor) {
|
||||
super(dim, type, editor);
|
||||
this.entityId = id;
|
||||
}
|
||||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException {
|
||||
this.entityId = buf.readInt();
|
||||
this.dimension = buf.readTag();
|
||||
this.type = buf.readUnsignedShort();
|
||||
this.editor = buf.readBoolean();
|
||||
super.readPacketData(buf);
|
||||
}
|
||||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException {
|
||||
buf.writeInt(this.entityId);
|
||||
buf.writeTag(this.dimension);
|
||||
buf.writeShort(this.type & 65535);
|
||||
buf.writeBoolean(this.editor);
|
||||
super.writePacketData(buf);
|
||||
}
|
||||
|
||||
public void processPacket(IClientPlayer handler) {
|
||||
|
@ -45,16 +34,4 @@ public class SPacketJoinGame implements Packet<IClientPlayer> {
|
|||
public int getEntityId() {
|
||||
return this.entityId;
|
||||
}
|
||||
|
||||
public Dimension getDimension() {
|
||||
return Dimension.getByTag(this.dimension, false);
|
||||
}
|
||||
|
||||
public int getEntityType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public boolean isInEditor() {
|
||||
return this.editor;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,59 +2,107 @@ package common.packet;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import common.dimension.DimType;
|
||||
import common.dimension.Dimension;
|
||||
import common.init.UniverseRegistry;
|
||||
import common.network.IClientPlayer;
|
||||
import common.network.Packet;
|
||||
import common.network.PacketBuffer;
|
||||
import common.tags.TagObject;
|
||||
|
||||
public class SPacketRespawn implements Packet<IClientPlayer>
|
||||
{
|
||||
private TagObject dimension;
|
||||
private int type;
|
||||
private boolean editor;
|
||||
public class SPacketRespawn implements Packet<IClientPlayer> {
|
||||
private int dimId;
|
||||
private long seed;
|
||||
private DimType dimType;
|
||||
private TagObject dimData;
|
||||
private String dimName;
|
||||
private String dimDisplay;
|
||||
private String dimFull;
|
||||
private int type;
|
||||
private boolean editor;
|
||||
|
||||
public SPacketRespawn()
|
||||
{
|
||||
}
|
||||
public SPacketRespawn() {
|
||||
}
|
||||
|
||||
public SPacketRespawn(Dimension dimensionIn, int type, boolean editor)
|
||||
{
|
||||
this.dimension = dimensionIn.toTags(false);
|
||||
this.type = type;
|
||||
public SPacketRespawn(Dimension dim, int type, boolean editor) {
|
||||
if(dim == null) {
|
||||
this.dimId = -2;
|
||||
}
|
||||
else {
|
||||
this.seed = dim.getSeed();
|
||||
if(dim.isCustom()) {
|
||||
this.dimType = dim.getType();
|
||||
this.dimData = new TagObject();
|
||||
dim.toTags(this.dimData);
|
||||
this.dimName = UniverseRegistry.getName(dim);
|
||||
this.dimDisplay = dim.getCustomName();
|
||||
this.dimFull = dim.getFormattedName(true);
|
||||
this.dimId = -1;
|
||||
}
|
||||
else {
|
||||
this.dimId = UniverseRegistry.getId(dim);
|
||||
}
|
||||
}
|
||||
this.type = type;
|
||||
this.editor = editor;
|
||||
}
|
||||
|
||||
public void processPacket(IClientPlayer handler)
|
||||
{
|
||||
handler.handleRespawn(this);
|
||||
}
|
||||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.dimension = buf.readTag();
|
||||
this.type = buf.readUnsignedShort();
|
||||
this.editor = buf.readBoolean();
|
||||
}
|
||||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeTag(this.dimension);
|
||||
buf.writeShort(this.type & 65535);
|
||||
buf.writeBoolean(this.editor);
|
||||
}
|
||||
}
|
||||
|
||||
public Dimension getDimension()
|
||||
{
|
||||
return Dimension.getByTag(this.dimension, false);
|
||||
}
|
||||
public void processPacket(IClientPlayer handler) {
|
||||
handler.handleRespawn(this);
|
||||
}
|
||||
|
||||
public int getEntityType()
|
||||
{
|
||||
return this.type;
|
||||
}
|
||||
public void readPacketData(PacketBuffer buf) throws IOException {
|
||||
this.dimId = buf.readVarInt();
|
||||
if(this.dimId >= -1)
|
||||
this.seed = buf.readLong();
|
||||
if(this.dimId == -1) {
|
||||
this.dimType = buf.readEnumValue(DimType.class);
|
||||
this.dimData = buf.readTag();
|
||||
this.dimName = buf.readString(1024);
|
||||
this.dimDisplay = buf.readString(1024);
|
||||
this.dimFull = buf.readString(4096);
|
||||
}
|
||||
this.type = buf.readUnsignedShort();
|
||||
this.editor = buf.readBoolean();
|
||||
}
|
||||
|
||||
public boolean isInEditor() {
|
||||
return this.editor;
|
||||
}
|
||||
public void writePacketData(PacketBuffer buf) throws IOException {
|
||||
buf.writeVarInt(this.dimId);
|
||||
if(this.dimId >= -1)
|
||||
buf.writeLong(this.seed);
|
||||
if(this.dimId == -1) {
|
||||
buf.writeEnumValue(this.dimType);
|
||||
buf.writeTag(this.dimData);
|
||||
buf.writeString(this.dimName);
|
||||
buf.writeString(this.dimDisplay);
|
||||
buf.writeString(this.dimFull);
|
||||
}
|
||||
buf.writeShort(this.type & 65535);
|
||||
buf.writeBoolean(this.editor);
|
||||
}
|
||||
|
||||
public Dimension getDimension() {
|
||||
if(this.dimId < -1)
|
||||
return null;
|
||||
Dimension dim = this.dimId >= 0 ? UniverseRegistry.getDimension(this.dimId) : Dimension.create(this.dimType);
|
||||
dim.setSeed(this.seed);
|
||||
if(!dim.isCustom())
|
||||
return dim;
|
||||
dim.fromTags(this.dimData);
|
||||
dim.setCustomName(this.dimDisplay);
|
||||
dim.setDisplayName(this.dimFull);
|
||||
return dim;
|
||||
}
|
||||
|
||||
public String getDimName() {
|
||||
return this.dimName;
|
||||
}
|
||||
|
||||
public int getEntityType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public boolean isInEditor() {
|
||||
return this.editor;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,71 @@
|
|||
package common.util;
|
||||
|
||||
public record Position(double x, double y, double z, float yaw, float pitch, int dim) {
|
||||
import common.dimension.Dimension;
|
||||
import common.init.UniverseRegistry;
|
||||
import common.world.World;
|
||||
|
||||
public class Position extends Vec3 {
|
||||
private final float yaw;
|
||||
private final float pitch;
|
||||
private final int dim;
|
||||
|
||||
private Position(double x, double y, double z, float yaw, float pitch, int dim) {
|
||||
super(x, y, z);
|
||||
this.yaw = yaw;
|
||||
this.pitch = pitch;
|
||||
this.dim = dim;
|
||||
}
|
||||
|
||||
public Position(double x, double y, double z, float yaw, float pitch, Dimension dim) {
|
||||
this(x, y, z, yaw, pitch, UniverseRegistry.getId(dim));
|
||||
}
|
||||
|
||||
public Position(double x, double y, double z, float yaw, float pitch, World world) {
|
||||
this(x, y, z, yaw, pitch, UniverseRegistry.getId(world.dimension));
|
||||
}
|
||||
|
||||
public double x() {
|
||||
return this.xCoord;
|
||||
}
|
||||
|
||||
public double y() {
|
||||
return this.yCoord;
|
||||
}
|
||||
|
||||
public double z() {
|
||||
return this.zCoord;
|
||||
}
|
||||
|
||||
public float yaw() {
|
||||
return this.yaw;
|
||||
}
|
||||
|
||||
public float pitch() {
|
||||
return this.pitch;
|
||||
}
|
||||
|
||||
public Dimension getDimension() {
|
||||
return UniverseRegistry.getDimension(this.dim);
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return this.getDimension() != null;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if(this == obj) {
|
||||
return true;
|
||||
}
|
||||
else if(!(obj instanceof Position)) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
Position pos = (Position)obj;
|
||||
return this.xCoord == pos.xCoord && this.yCoord == pos.yCoord && this.zCoord == pos.zCoord && this.yaw == pos.yaw && this.pitch == pos.pitch && this.dim == pos.dim;
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "(" + this.getDimension() + ", " + this.xCoord + ", " + this.yCoord + ", " + this.zCoord + ", " + this.yaw + ", " + this.pitch + ")";
|
||||
}
|
||||
}
|
||||
|
|
4
common/src/main/java/common/util/Quartet.java
Normal file
4
common/src/main/java/common/util/Quartet.java
Normal file
|
@ -0,0 +1,4 @@
|
|||
package common.util;
|
||||
|
||||
public record Quartet<A, B, C, D>(A first, B second, C third, D fourth) {
|
||||
}
|
|
@ -1,19 +1,35 @@
|
|||
package common.util;
|
||||
|
||||
import common.dimension.Dimension;
|
||||
import common.init.UniverseRegistry;
|
||||
import common.world.World;
|
||||
|
||||
public class WorldPos extends BlockPos {
|
||||
private final int dim;
|
||||
|
||||
public WorldPos(int x, int y, int z, int dim) {
|
||||
private WorldPos(int x, int y, int z, int dim) {
|
||||
super(x, y, z);
|
||||
this.dim = dim;
|
||||
}
|
||||
|
||||
public WorldPos(BlockPos pos, int dim) {
|
||||
this(pos.getX(), pos.getY(), pos.getZ(), dim);
|
||||
public WorldPos(int x, int y, int z, Dimension dim) {
|
||||
this(x, y, z, UniverseRegistry.getId(dim));
|
||||
}
|
||||
|
||||
public WorldPos(int x, int y, int z, World world) {
|
||||
this(x, y, z, UniverseRegistry.getId(world.dimension));
|
||||
}
|
||||
|
||||
public WorldPos(BlockPos pos, Dimension dim) {
|
||||
this(pos.getX(), pos.getY(), pos.getZ(), UniverseRegistry.getId(dim));
|
||||
}
|
||||
|
||||
public WorldPos(BlockPos pos, World world) {
|
||||
this(pos.getX(), pos.getY(), pos.getZ(), UniverseRegistry.getId(world.dimension));
|
||||
}
|
||||
|
||||
public int getDimension() {
|
||||
return this.dim;
|
||||
public Dimension getDimension() {
|
||||
return UniverseRegistry.getDimension(this.dim);
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
|
@ -34,6 +50,6 @@ public class WorldPos extends BlockPos {
|
|||
}
|
||||
|
||||
public String toString() {
|
||||
return this.dim + ";" + this.getX() + ";" + this.getY() + ";" + this.getZ();
|
||||
return "" + this.getDimension() + ";" + this.getX() + ";" + this.getY() + ";" + this.getZ();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ public abstract class AWorldServer extends World {
|
|||
}
|
||||
|
||||
public abstract List<IPlayer> getAllPlayers();
|
||||
public abstract AWorldServer getOtherWorld(int dimension);
|
||||
public abstract AWorldServer getOtherWorld(Dimension dimension);
|
||||
public abstract void placeInDimension(Entity entity, AWorldServer oldWorld, AWorldServer world, BlockPos pos, PortalType portal);
|
||||
public abstract boolean addLoader(BlockPos pos);
|
||||
public abstract boolean removeLoader(BlockPos pos);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue