minimize client world class
This commit is contained in:
parent
eec61c9258
commit
76e018b4ed
62 changed files with 1183 additions and 1338 deletions
|
@ -23,6 +23,7 @@ import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
@ -97,17 +98,20 @@ import client.window.Wheel;
|
||||||
import client.window.Window;
|
import client.window.Window;
|
||||||
import client.window.WindowEvent;
|
import client.window.WindowEvent;
|
||||||
import client.world.ChunkClient;
|
import client.world.ChunkClient;
|
||||||
import client.world.WorldClient;
|
import client.world.ChunkEmpty;
|
||||||
import common.Version;
|
import common.Version;
|
||||||
import common.block.Block;
|
import common.block.Block;
|
||||||
import common.collect.Lists;
|
import common.collect.Lists;
|
||||||
import common.collect.Maps;
|
import common.collect.Maps;
|
||||||
|
import common.collect.Sets;
|
||||||
import common.color.TextColor;
|
import common.color.TextColor;
|
||||||
|
import common.dimension.Dimension;
|
||||||
import common.dimension.Space;
|
import common.dimension.Space;
|
||||||
import common.effect.Effect;
|
import common.effect.Effect;
|
||||||
import common.effect.StatusEffect;
|
import common.effect.StatusEffect;
|
||||||
import common.entity.Entity;
|
import common.entity.Entity;
|
||||||
import common.entity.animal.EntityHorse;
|
import common.entity.animal.EntityHorse;
|
||||||
|
import common.entity.item.EntityCart;
|
||||||
import common.entity.npc.Energy;
|
import common.entity.npc.Energy;
|
||||||
import common.entity.npc.EntityCpu;
|
import common.entity.npc.EntityCpu;
|
||||||
import common.entity.npc.EntityNPC;
|
import common.entity.npc.EntityNPC;
|
||||||
|
@ -152,18 +156,25 @@ import common.packet.CPacketMessage;
|
||||||
import common.packet.HPacketHandshake;
|
import common.packet.HPacketHandshake;
|
||||||
import common.packet.CPacketAction.Action;
|
import common.packet.CPacketAction.Action;
|
||||||
import common.properties.Property;
|
import common.properties.Property;
|
||||||
|
import common.rng.Random;
|
||||||
import common.sound.EventType;
|
import common.sound.EventType;
|
||||||
|
import common.sound.MovingSoundMinecart;
|
||||||
import common.sound.PositionedSound;
|
import common.sound.PositionedSound;
|
||||||
|
import common.tileentity.TileEntity;
|
||||||
import common.util.BlockPos;
|
import common.util.BlockPos;
|
||||||
import common.util.BoundingBox;
|
import common.util.BoundingBox;
|
||||||
import common.util.CharValidator;
|
import common.util.CharValidator;
|
||||||
|
import common.util.ChunkPos;
|
||||||
import common.util.ExtMath;
|
import common.util.ExtMath;
|
||||||
import common.util.Facing;
|
|
||||||
import common.util.HitPosition;
|
import common.util.HitPosition;
|
||||||
|
import common.util.IntHashMap;
|
||||||
|
import common.util.LongHashMap;
|
||||||
|
import common.util.ParticleType;
|
||||||
import common.util.Util;
|
import common.util.Util;
|
||||||
import common.util.Var;
|
import common.util.Var;
|
||||||
import common.util.HitPosition.ObjectType;
|
import common.util.HitPosition.ObjectType;
|
||||||
import common.vars.Vars;
|
import common.vars.Vars;
|
||||||
|
import common.world.Chunk;
|
||||||
import common.world.LightType;
|
import common.world.LightType;
|
||||||
import common.world.State;
|
import common.world.State;
|
||||||
import common.world.World;
|
import common.world.World;
|
||||||
|
@ -270,6 +281,92 @@ public class Client implements IThreadListener {
|
||||||
|
|
||||||
private record DebugFunction(Keysym key, DebugRunner runner, String help) {
|
private record DebugFunction(Keysym key, DebugRunner runner, String help) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final class WorldClient extends World {
|
||||||
|
public WorldClient(Dimension dim) {
|
||||||
|
super(dim, true);
|
||||||
|
this.calculateInitialSkylight();
|
||||||
|
this.calculateInitialWeather();
|
||||||
|
this.updatePhysics();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean spawnEntityInWorld(Entity entityIn) {
|
||||||
|
boolean flag = super.spawnEntityInWorld(entityIn);
|
||||||
|
Client.this.spawnEntityInWorld(flag, entityIn);
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeEntity(Entity entityIn) {
|
||||||
|
super.removeEntity(entityIn);
|
||||||
|
Client.this.removeEntity(entityIn);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onEntityAdded(Entity entityIn) {
|
||||||
|
Client.this.onEntityAdded(entityIn);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onEntityRemoved(Entity entityIn) {
|
||||||
|
Client.this.onEntityRemoved(entityIn);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Entity getEntityByID(int id) {
|
||||||
|
return id == Client.this.player.getId() ? Client.this.player : super.getEntityByID(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void playSound(double x, double y, double z, SoundEvent sound, float volume) {
|
||||||
|
Client.this.getSoundManager().playSound(new PositionedSound(sound, volume, (float)x, (float)y, (float)z));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Chunk getChunk(int x, int z) {
|
||||||
|
return Client.this.getChunk(x, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Chunk getChunk(BlockPos pos) {
|
||||||
|
return Client.this.getChunk(pos.getX() >> 4, pos.getZ() >> 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected float getTemperature(BlockPos pos) {
|
||||||
|
if(!isValid(pos))
|
||||||
|
return 0.0f;
|
||||||
|
ChunkClient chunk = Client.this.getChunk(pos.getX() >> 4, pos.getZ() >> 4);
|
||||||
|
return pos.getY() > 64 ? chunk.getTemperature(pos) - (chunk.getOffset(pos) + (float)pos.getY() - 64.0F) / 15.0f : chunk.getTemperature(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean isLoaded(int x, int z, boolean allowEmpty) {
|
||||||
|
return allowEmpty || !Client.this.getChunk(x, z).isDummy();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void spawnParticle(ParticleType particle, double xCoord, double yCoord, double zCoord, int data) {
|
||||||
|
Client.this.effectRenderer.spawnParticle(Client.this.getRenderViewEntity(), particle, xCoord, yCoord, zCoord, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void playAuxSFX(EntityNPC player, int sfxType, BlockPos blockPosIn, int data) {
|
||||||
|
if(Client.this.getNetHandler() != null)
|
||||||
|
Client.this.getNetHandler().playAuxSFX(sfxType, blockPosIn, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void markBlockForUpdate(BlockPos pos) {
|
||||||
|
int x = pos.getX();
|
||||||
|
int y = pos.getY();
|
||||||
|
int z = pos.getZ();
|
||||||
|
Client.this.renderGlobal.markBlocksForUpdate(x - 1, y - 1, z - 1, x + 1, y + 1, z + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void notifyLightSet(BlockPos pos) {
|
||||||
|
int x = pos.getX();
|
||||||
|
int y = pos.getY();
|
||||||
|
int z = pos.getZ();
|
||||||
|
Client.this.renderGlobal.markBlocksForUpdate(x - 1, y - 1, z - 1, x + 1, y + 1, z + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void markBlockRangeForRenderUpdate(int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||||
|
Client.this.renderGlobal.markBlocksForUpdate(x1 - 1, y1 - 1, z1 - 1, x2 + 1, y2 + 1, z2 + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastLightning(int last, int color) {
|
||||||
|
Client.this.entityRenderer.setLastLightning(last, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static final String VERSION = Version.NAME + " Client " + Util.VERSION;
|
public static final String VERSION = Version.NAME + " Client " + Util.VERSION;
|
||||||
public static final int LOG_BUFFER = 32768;
|
public static final int LOG_BUFFER = 32768;
|
||||||
|
@ -295,6 +392,13 @@ public class Client implements IThreadListener {
|
||||||
private final long[] frames = new long[240];
|
private final long[] frames = new long[240];
|
||||||
public final Map<String, Integer> playerList = Maps.<String, Integer>newTreeMap();
|
public final Map<String, Integer> playerList = Maps.<String, Integer>newTreeMap();
|
||||||
public final List<PlayerCharacter> characterList = Lists.<PlayerCharacter>newArrayList();
|
public final List<PlayerCharacter> characterList = Lists.<PlayerCharacter>newArrayList();
|
||||||
|
private final Set<Entity> entityList = Sets.<Entity>newHashSet();
|
||||||
|
private final Set<Entity> spawnQueue = Sets.<Entity>newHashSet();
|
||||||
|
private final Set<ChunkPos> previousActive = Sets.<ChunkPos>newHashSet();
|
||||||
|
private final LongHashMap<ChunkClient> chunkMapping = new LongHashMap();
|
||||||
|
private final List<ChunkClient> chunkListing = Lists.<ChunkClient>newArrayList();
|
||||||
|
private final Set<Long> emptyChunkListing = Sets.<Long>newHashSet();
|
||||||
|
private final Set<Long> nextEmptyChunkListing = Sets.<Long>newHashSet();
|
||||||
|
|
||||||
private boolean primary;
|
private boolean primary;
|
||||||
private boolean secondary;
|
private boolean secondary;
|
||||||
|
@ -410,12 +514,19 @@ public class Client implements IThreadListener {
|
||||||
private AudioInterface audio;
|
private AudioInterface audio;
|
||||||
private String buffer = "";
|
private String buffer = "";
|
||||||
public PlayerController controller;
|
public PlayerController controller;
|
||||||
public WorldClient world;
|
public World world;
|
||||||
public EntityNPC player;
|
public EntityNPC player;
|
||||||
public HitPosition pointed;
|
public HitPosition pointed;
|
||||||
public DisplayMode vidMode;
|
public DisplayMode vidMode;
|
||||||
public String dimensionName;
|
public String dimensionName;
|
||||||
public String message;
|
public String message;
|
||||||
|
private ChunkClient emptyChunk;
|
||||||
|
private ChunkClient outsideChunk;
|
||||||
|
|
||||||
|
private List<Entity> entities;
|
||||||
|
private List<Entity> unloaded;
|
||||||
|
private List<TileEntity> tiles;
|
||||||
|
private IntHashMap<Entity> entityIds;
|
||||||
|
|
||||||
|
|
||||||
@Variable(name = "chunk_view_distance", category = CVarCategory.RENDER, min = 2, max = 16, callback = DistanceFunction.class, display = "Sichtweite", unit = "Chunks")
|
@Variable(name = "chunk_view_distance", category = CVarCategory.RENDER, min = 2, max = 16, callback = DistanceFunction.class, display = "Sichtweite", unit = "Chunks")
|
||||||
|
@ -484,7 +595,7 @@ public class Client implements IThreadListener {
|
||||||
@Variable(name = "draw_rain_particle_range", category = CVarCategory.RENDER, min = 0, max = 25, display = "Regen-Partikel-Radius")
|
@Variable(name = "draw_rain_particle_range", category = CVarCategory.RENDER, min = 0, max = 25, display = "Regen-Partikel-Radius")
|
||||||
public int rainParticleRange = 10;
|
public int rainParticleRange = 10;
|
||||||
@Variable(name = "draw_void_particles", category = CVarCategory.RENDER, display = "Partikel in der Tiefe")
|
@Variable(name = "draw_void_particles", category = CVarCategory.RENDER, display = "Partikel in der Tiefe")
|
||||||
public boolean voidParticles = true;
|
private boolean voidParticles = true;
|
||||||
@Variable(name = "draw_void_fog", category = CVarCategory.RENDER, display = "Nebel in der Tiefe")
|
@Variable(name = "draw_void_fog", category = CVarCategory.RENDER, display = "Nebel in der Tiefe")
|
||||||
public boolean voidFog = true;
|
public boolean voidFog = true;
|
||||||
@Variable(name = "crosshair_size", category = CVarCategory.GUI, min = 0, max = 32, display = "Größe des Fadenkreuzes")
|
@Variable(name = "crosshair_size", category = CVarCategory.GUI, min = 0, max = 32, display = "Größe des Fadenkreuzes")
|
||||||
|
@ -601,8 +712,7 @@ public class Client implements IThreadListener {
|
||||||
this.debugWorld = true;
|
this.debugWorld = true;
|
||||||
this.charEditor = false;
|
this.charEditor = false;
|
||||||
this.controller = new PlayerController(this, player);
|
this.controller = new PlayerController(this, player);
|
||||||
WorldClient world = new WorldClient(this, Space.INSTANCE);
|
this.loadWorld(Space.INSTANCE, EntityRegistry.getEntityID(EntityCpu.class));
|
||||||
this.loadWorld(world, EntityRegistry.getEntityID(EntityCpu.class));
|
|
||||||
this.player.setId(0);
|
this.player.setId(0);
|
||||||
this.show(null);
|
this.show(null);
|
||||||
this.player.flying = true;
|
this.player.flying = true;
|
||||||
|
@ -620,6 +730,7 @@ public class Client implements IThreadListener {
|
||||||
this.viewEntity = null;
|
this.viewEntity = null;
|
||||||
this.connection = null;
|
this.connection = null;
|
||||||
this.world = null;
|
this.world = null;
|
||||||
|
this.resetWorld();
|
||||||
this.player = null;
|
this.player = null;
|
||||||
this.serverInfo = null;
|
this.serverInfo = null;
|
||||||
this.lastTickTime = -1;
|
this.lastTickTime = -1;
|
||||||
|
@ -865,21 +976,20 @@ public class Client implements IThreadListener {
|
||||||
if (this.chunkLoadTimer == 30)
|
if (this.chunkLoadTimer == 30)
|
||||||
{
|
{
|
||||||
this.chunkLoadTimer = 0;
|
this.chunkLoadTimer = 0;
|
||||||
this.world.ensureAreaLoaded(this.player);
|
this.ensureAreaLoaded(this.player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.entityRenderer.updateRenderer();
|
this.entityRenderer.updateRenderer();
|
||||||
this.renderGlobal.updateClouds();
|
this.renderGlobal.updateClouds();
|
||||||
this.world.decrLightning();
|
|
||||||
this.world.updateEntities();
|
this.world.updateEntities();
|
||||||
}
|
}
|
||||||
this.soundManager.update();
|
this.soundManager.update();
|
||||||
if (this.world != null)
|
if (this.world != null)
|
||||||
{
|
{
|
||||||
this.world.tick();
|
this.tickWorld();
|
||||||
if (this.world != null)
|
if (this.world != null)
|
||||||
{
|
{
|
||||||
this.world.displayTick(ExtMath.floord(this.player.posX), ExtMath.floord(this.player.posY), ExtMath.floord(this.player.posZ));
|
this.displayTick(ExtMath.floord(this.player.posX), ExtMath.floord(this.player.posY), ExtMath.floord(this.player.posZ));
|
||||||
}
|
}
|
||||||
this.effectRenderer.update();
|
this.effectRenderer.update();
|
||||||
}
|
}
|
||||||
|
@ -1209,7 +1319,7 @@ public class Client implements IThreadListener {
|
||||||
if(this.cameraUsed) {
|
if(this.cameraUsed) {
|
||||||
this.cameraUsed = false;
|
this.cameraUsed = false;
|
||||||
if(this.world != null)
|
if(this.world != null)
|
||||||
this.world.setLastLightning(1, 0xffffff);
|
this.entityRenderer.setLastLightning(1, 0xffffff);
|
||||||
}
|
}
|
||||||
if(this.isDirty())
|
if(this.isDirty())
|
||||||
this.save();
|
this.save();
|
||||||
|
@ -1489,12 +1599,18 @@ public class Client implements IThreadListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadWorld(WorldClient world, int type)
|
public World loadWorld(Dimension dim, int type)
|
||||||
{
|
{
|
||||||
|
this.resetWorld();
|
||||||
this.viewEntity = null;
|
this.viewEntity = null;
|
||||||
this.connection = null;
|
this.connection = null;
|
||||||
this.soundManager.stopSounds();
|
this.soundManager.stopSounds();
|
||||||
this.world = world;
|
this.world = new WorldClient(dim);
|
||||||
|
this.entities = this.world.entities;
|
||||||
|
this.unloaded = this.world.unloaded;
|
||||||
|
this.tiles = this.world.tiles;
|
||||||
|
this.entityIds = this.world.entityIds;
|
||||||
|
this.initWorld();
|
||||||
|
|
||||||
if (this.renderGlobal != null)
|
if (this.renderGlobal != null)
|
||||||
{
|
{
|
||||||
|
@ -1517,11 +1633,12 @@ public class Client implements IThreadListener {
|
||||||
this.viewEntity = this.player;
|
this.viewEntity = this.player;
|
||||||
|
|
||||||
System.gc();
|
System.gc();
|
||||||
|
return this.world;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDimensionAndSpawnPlayer(int type)
|
public void setDimensionAndSpawnPlayer(int type)
|
||||||
{
|
{
|
||||||
this.world.removeAllEntities();
|
this.removeAllEntities();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
if (this.player != null)
|
if (this.player != null)
|
||||||
|
@ -1694,18 +1811,14 @@ public class Client implements IThreadListener {
|
||||||
String mem = String.format("JVM-Speicher: %d%% %d/%dMB", usedMem * 100L / maxMem, usedMem / 1024L / 1024L, maxMem / 1024L / 1024L)
|
String mem = String.format("JVM-Speicher: %d%% %d/%dMB", usedMem * 100L / maxMem, usedMem / 1024L / 1024L, maxMem / 1024L / 1024L)
|
||||||
+ "\n" +
|
+ "\n" +
|
||||||
String.format("JVM-Reserviert: %d%% %dMB", totalMem * 100L / maxMem, totalMem / 1024L / 1024L);
|
String.format("JVM-Reserviert: %d%% %dMB", totalMem * 100L / maxMem, totalMem / 1024L / 1024L);
|
||||||
if(this.world == null) {
|
if(this.world == null)
|
||||||
return mem;
|
return mem;
|
||||||
}
|
|
||||||
|
|
||||||
BlockPos blockpos = new BlockPos(this.viewEntity.posX, this.viewEntity.getEntityBoundingBox().minY,
|
BlockPos pos = new BlockPos(this.viewEntity.posX, this.viewEntity.getEntityBoundingBox().minY, this.viewEntity.posZ);
|
||||||
this.viewEntity.posZ);
|
String dirStr;
|
||||||
|
switch(this.viewEntity.getHorizontalFacing()) {
|
||||||
Entity entity = this.viewEntity;
|
|
||||||
Facing facing = entity.getHorizontalFacing();
|
|
||||||
String dirStr = "Ungültig";
|
|
||||||
switch(facing) {
|
|
||||||
case NORTH:
|
case NORTH:
|
||||||
|
default:
|
||||||
dirStr = "Norden (Nach negativer Z)";
|
dirStr = "Norden (Nach negativer Z)";
|
||||||
break;
|
break;
|
||||||
case SOUTH:
|
case SOUTH:
|
||||||
|
@ -1718,28 +1831,7 @@ public class Client implements IThreadListener {
|
||||||
dirStr = "Osten (Nach positiver X)";
|
dirStr = "Osten (Nach positiver X)";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
ChunkClient chunk = this.getChunk(pos.getX() >> 4, pos.getZ() >> 4);
|
||||||
String bline;
|
|
||||||
String lline;
|
|
||||||
if(this.world.isBlockLoaded(blockpos)) {
|
|
||||||
ChunkClient chunk = this.world.getChunk(blockpos);
|
|
||||||
bline = String.format("Biom: %.2f K, N: %.2f K, D: %s (%s)", chunk.getTemperature(blockpos), chunk.getOffset(blockpos),
|
|
||||||
TextColor.stripCodes(this.world.dimension.getDisplay()),
|
|
||||||
this.dimensionName == null ? UniverseRegistry.getName(this.world.dimension) : this.dimensionName);
|
|
||||||
lline = "Licht: " + chunk.getLightSub(blockpos, 0) + " (" + chunk.getLight(LightType.SKY, blockpos) + " Himmel, "
|
|
||||||
+ chunk.getLight(LightType.BLOCK, blockpos) + " Blöcke, " + String.format(
|
|
||||||
"%.1f", this.world.getSunBrightness(1.0f) * 15.0f) + " Welt), A: "
|
|
||||||
+ String.format("%.1f °", this.world.getCelestialAngle(1.0f));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
bline = "Biom: <?>, D: " +
|
|
||||||
TextColor.stripCodes(this.world.dimension.getDisplay()) +
|
|
||||||
" (" + (this.dimensionName == null ? UniverseRegistry.getName(this.world.dimension) : this.dimensionName) + ")";
|
|
||||||
lline = "Licht: " + String.format(
|
|
||||||
"%.1f", this.world.getSunBrightness(1.0f) * 15.0f) + " Welt, A: "
|
|
||||||
+ String.format("%.1f °", this.world.getCelestialAngle(1.0f));
|
|
||||||
}
|
|
||||||
|
|
||||||
long ticked = System.currentTimeMillis() - this.lastTicked;
|
long ticked = System.currentTimeMillis() - this.lastTicked;
|
||||||
|
|
||||||
return
|
return
|
||||||
|
@ -1750,21 +1842,26 @@ public class Client implements IThreadListener {
|
||||||
// this.connected != null ? this.connected : "[???]"))),
|
// this.connected != null ? this.connected : "[???]"))),
|
||||||
this.renderGlobal.getDebugInfoRenders() + "\n" +
|
this.renderGlobal.getDebugInfoRenders() + "\n" +
|
||||||
this.renderGlobal.getDebugInfoEntities() + "\n" +
|
this.renderGlobal.getDebugInfoEntities() + "\n" +
|
||||||
"Partikel: " + this.effectRenderer.getParticleCount() + ". O: " + this.world.getDebugLoadedEntities() + "\n" +
|
"Partikel: " + this.effectRenderer.getParticleCount() + ". O: " + this.entities.size() + "\n" +
|
||||||
this.world.getInfo() + "\n" +
|
"Chunk-Cache: M " + this.chunkMapping.getNumHashElements() + ", L " + this.chunkListing.size() + "\n" +
|
||||||
String.format("XYZ: %.3f / %.3f / %.3f", this.viewEntity.posX,
|
String.format("XYZ: %.3f / %.3f / %.3f", this.viewEntity.posX,
|
||||||
this.viewEntity.getEntityBoundingBox().minY, this.viewEntity.posZ) + "\n" +
|
this.viewEntity.getEntityBoundingBox().minY, this.viewEntity.posZ) + "\n" +
|
||||||
String.format("Block: %d %d %d, R: '%s/%s'", blockpos.getX(), blockpos.getY(), blockpos.getZ(),
|
String.format("Block: %d %d %d, R: '%s/%s'", pos.getX(), pos.getY(), pos.getZ(),
|
||||||
Util.getRegionFolder(blockpos.getX() >> 4, blockpos.getZ() >> 4),
|
Util.getRegionFolder(pos.getX() >> 4, pos.getZ() >> 4),
|
||||||
Util.getRegionName(blockpos.getX() >> 4, blockpos.getZ() >> 4)) + "\n" +
|
Util.getRegionName(pos.getX() >> 4, pos.getZ() >> 4)) + "\n" +
|
||||||
String.format("Chunk: %d %d %d + %d %d %d, FOV: %.1f °%s", blockpos.getX() >> 4, blockpos.getY() >> 4, blockpos.getZ() >> 4,
|
String.format("Chunk: %d %d %d + %d %d %d, FOV: %.1f °%s", pos.getX() >> 4, pos.getY() >> 4, pos.getZ() >> 4,
|
||||||
blockpos.getX() & 15, blockpos.getY() & 15, blockpos.getZ() & 15, this.zooming ?
|
pos.getX() & 15, pos.getY() & 15, pos.getZ() & 15, this.zooming ?
|
||||||
(this.fov / this.zoomLevel) : this.fov, this.zooming ?
|
(this.fov / this.zoomLevel) : this.fov, this.zooming ?
|
||||||
String.format(" (Zoom x%.1f)", this.zoomLevel) : "") + "\n" +
|
String.format(" (Zoom x%.1f)", this.zoomLevel) : "") + "\n" +
|
||||||
String.format("Richtung: %s (%.1f / %.1f)", dirStr,
|
String.format("Richtung: %s (%.1f / %.1f)", dirStr,
|
||||||
ExtMath.wrapf(entity.rotYaw), ExtMath.wrapf(entity.rotPitch)) + "\n" +
|
ExtMath.wrapf(this.viewEntity.rotYaw), ExtMath.wrapf(this.viewEntity.rotPitch)) + "\n" +
|
||||||
bline + "\n" +
|
String.format("Biom: %.2f K, N: %.2f K, D: %s (%s)", chunk.getTemperature(pos), chunk.getOffset(pos),
|
||||||
lline + "\n" +
|
TextColor.stripCodes(this.world.dimension.getDisplay()),
|
||||||
|
this.dimensionName == null ? UniverseRegistry.getName(this.world.dimension) : this.dimensionName) + "\n" +
|
||||||
|
"Licht: " + chunk.getLightSub(pos, 0) + " (" + chunk.getLight(LightType.SKY, pos) + " Himmel, "
|
||||||
|
+ chunk.getLight(LightType.BLOCK, pos) + " Blöcke, " + String.format(
|
||||||
|
"%.1f", this.entityRenderer.getSunBrightness(1.0f) * 15.0f) + " Welt), A: "
|
||||||
|
+ String.format("%.1f °", this.world.getCelestialAngle(1.0f)) + "\n" +
|
||||||
String.format("Zeit: %d T, R %d / %d T, U %d / %d T",
|
String.format("Zeit: %d T, R %d / %d T, U %d / %d T",
|
||||||
this.world.getDayTime(),
|
this.world.getDayTime(),
|
||||||
this.world.getDayTime() % this.world.dimension.getRotationalPeriod(),
|
this.world.getDayTime() % this.world.dimension.getRotationalPeriod(),
|
||||||
|
@ -1774,8 +1871,8 @@ public class Client implements IThreadListener {
|
||||||
) + "\n" +
|
) + "\n" +
|
||||||
String.format("Laub: %s%s, T: %.2f K / %.2f °C, %s (R %.1f, %.1f)",
|
String.format("Laub: %s%s, T: %.2f K / %.2f °C, %s (R %.1f, %.1f)",
|
||||||
!this.world.dimension.hasSeasons() ? "*" : "",
|
!this.world.dimension.hasSeasons() ? "*" : "",
|
||||||
this.world.getLeavesGen(blockpos).getDisplayName(),
|
this.world.getLeavesGen(pos).getDisplayName(),
|
||||||
this.world.getTemperatureK(blockpos), this.world.getTemperatureC(blockpos),
|
this.world.getTemperatureK(pos), this.world.getTemperatureC(pos),
|
||||||
this.world.getWeather().getDisplay(), this.world.getRainStrength(),
|
this.world.getWeather().getDisplay(), this.world.getRainStrength(),
|
||||||
this.world.getDarkness()
|
this.world.getDarkness()
|
||||||
) + "\n" +
|
) + "\n" +
|
||||||
|
@ -3225,6 +3322,348 @@ public class Client implements IThreadListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void displayTick(int posX, int posY, int posZ) {
|
||||||
|
int range = 16;
|
||||||
|
Random rand = new Random();
|
||||||
|
BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos();
|
||||||
|
for(int n = 0; n < 1000; n++) {
|
||||||
|
int x = posX + rand.zrange(range) - rand.zrange(range);
|
||||||
|
int y = posY + rand.zrange(range) - rand.zrange(range);
|
||||||
|
int z = posZ + rand.zrange(range) - rand.zrange(range);
|
||||||
|
pos.set(x, y, z);
|
||||||
|
State state = this.world.getState(pos);
|
||||||
|
state.getBlock().displayTick(this.world, pos, state, rand);
|
||||||
|
}
|
||||||
|
if(this.world.dimension.hasVoidFog() && this.voidParticles && posY < 32) {
|
||||||
|
for(int n = 0; n < 1000; n++) {
|
||||||
|
float x = ((float)posX) + (rand.floatv() - rand.floatv() - 0.5f) * 32.0f;
|
||||||
|
float y = (posY < -32 ? (float)posY - 32.0f : -64.0f) + rand.floatv() * 65.0f;
|
||||||
|
float z = ((float)posZ) + (rand.floatv() - rand.floatv() - 0.5f) * 32.0f;
|
||||||
|
if(y < -64.0f || rand.floatv() >= (64.0f + y) / 64.0f)
|
||||||
|
this.world.spawnParticle(ParticleType.DEPTH, (double)x, (double)y, (double)z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initWorld() {
|
||||||
|
this.emptyChunk = new ChunkEmpty(this.world, false, this.debugWorld);
|
||||||
|
this.outsideChunk = new ChunkEmpty(this.world, true, this.debugWorld);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void resetWorld() {
|
||||||
|
this.entityList.clear();
|
||||||
|
this.spawnQueue.clear();
|
||||||
|
this.previousActive.clear();
|
||||||
|
this.chunkMapping.clear();
|
||||||
|
this.chunkListing.clear();
|
||||||
|
this.emptyChunkListing.clear();
|
||||||
|
this.nextEmptyChunkListing.clear();
|
||||||
|
this.emptyChunk = null;
|
||||||
|
this.outsideChunk = null;
|
||||||
|
this.entityRenderer.resetLightning();
|
||||||
|
this.entities = null;
|
||||||
|
this.unloaded = null;
|
||||||
|
this.tiles = null;
|
||||||
|
this.entityIds = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChunkClient getChunk(int x, int z) {
|
||||||
|
ChunkClient chunk = this.chunkMapping.getValueByKey(LongHashMap.packInt(x, z));
|
||||||
|
return chunk == null ? this.getEmptyChunk(x, z) : chunk;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ChunkClient getEmptyChunk(int x, int z) {
|
||||||
|
int size = this.world.dimension.getSize() / 16;
|
||||||
|
return x < -size || z < -size || x >= size || z >= size ? this.outsideChunk : this.emptyChunk;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void markBlockRangeForRenderUpdate(int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||||
|
this.renderGlobal.markBlocksForUpdate(x1 - 1, y1 - 1, z1 - 1, x2 + 1, y2 + 1, z2 + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void markReload(int cx, int cz, int range) {
|
||||||
|
this.nextEmptyChunkListing.clear();
|
||||||
|
for(int x = cx - range; x <= cx + range; x++) {
|
||||||
|
for(int z = cz - range; z <= cz + range; z++) {
|
||||||
|
long id = LongHashMap.packInt(x, z);
|
||||||
|
if(this.chunkMapping.getValueByKey(id) != null) {
|
||||||
|
if(this.emptyChunkListing.contains(id)) {
|
||||||
|
this.emptyChunkListing.remove(id);
|
||||||
|
this.nextEmptyChunkListing.add(id);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
this.chunkMapping.add(id, this.getEmptyChunk(x, z));
|
||||||
|
this.emptyChunkListing.remove(id);
|
||||||
|
this.nextEmptyChunkListing.add(id);
|
||||||
|
this.markBlockRangeForRenderUpdate(x << 4, -World.MAX_SIZE_Y, z << 4, (x << 4) + 15, World.MAX_SIZE_Y, (z << 4) + 15);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(Long id : this.emptyChunkListing) {
|
||||||
|
this.chunkMapping.remove(id);
|
||||||
|
int x = LongHashMap.getX(id);
|
||||||
|
int z = LongHashMap.getZ(id);
|
||||||
|
this.markBlockRangeForRenderUpdate(x << 4, -World.MAX_SIZE_Y, z << 4, (x << 4) + 15, World.MAX_SIZE_Y, (z << 4) + 15);
|
||||||
|
}
|
||||||
|
this.emptyChunkListing.clear();
|
||||||
|
this.emptyChunkListing.addAll(this.nextEmptyChunkListing);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void markReload() {
|
||||||
|
if(this.player != null && !this.charEditor)
|
||||||
|
this.markReload((int)this.player.posX >> 4, (int)this.player.posZ >> 4, this.renderDistance + 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExterminated(boolean exterminated) {
|
||||||
|
this.world.dimension.setExterminated(exterminated);
|
||||||
|
this.initWorld();
|
||||||
|
this.markReload();
|
||||||
|
for(Long id : this.emptyChunkListing) {
|
||||||
|
int x = LongHashMap.getX(id);
|
||||||
|
int z = LongHashMap.getZ(id);
|
||||||
|
this.chunkMapping.add(id, this.getEmptyChunk(x, z));
|
||||||
|
this.markBlockRangeForRenderUpdate(x << 4, -World.MAX_SIZE_Y, z << 4, (x << 4) + 15, World.MAX_SIZE_Y, (z << 4) + 15);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void tickWorld()
|
||||||
|
{
|
||||||
|
this.world.updatePhysics();
|
||||||
|
this.markReload();
|
||||||
|
|
||||||
|
if (Vars.dayCycle)
|
||||||
|
{
|
||||||
|
this.world.setDayTime(this.world.getDayTime() + (long)Vars.timeFlow);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 10 && !this.spawnQueue.isEmpty(); ++i)
|
||||||
|
{
|
||||||
|
Entity entity = (Entity)this.spawnQueue.iterator().next();
|
||||||
|
this.spawnQueue.remove(entity);
|
||||||
|
|
||||||
|
if (!this.entities.contains(entity))
|
||||||
|
{
|
||||||
|
this.world.spawnEntityInWorld(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
long time = System.currentTimeMillis();
|
||||||
|
for (ChunkClient chunk : this.chunkListing)
|
||||||
|
{
|
||||||
|
chunk.update(System.currentTimeMillis() - time > 5L);
|
||||||
|
}
|
||||||
|
if (System.currentTimeMillis() - time > 100L)
|
||||||
|
{
|
||||||
|
Log.TICK.warn("Render-Chunk-Tick dauerte " + (System.currentTimeMillis() - time) + " ms");
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<ChunkPos> active = this.world.setActivePlayerChunksAndCheckLight(this.renderDistance);
|
||||||
|
this.previousActive.retainAll(active);
|
||||||
|
|
||||||
|
if (this.previousActive.size() == active.size())
|
||||||
|
{
|
||||||
|
this.previousActive.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
for (ChunkPos chunkcoordintpair : active)
|
||||||
|
{
|
||||||
|
if (!this.previousActive.contains(chunkcoordintpair))
|
||||||
|
{
|
||||||
|
int j = chunkcoordintpair.x * 16;
|
||||||
|
int k = chunkcoordintpair.z * 16;
|
||||||
|
ChunkClient chunk = this.getChunk(chunkcoordintpair.x, chunkcoordintpair.z);
|
||||||
|
chunk.enqueueRelight();
|
||||||
|
this.previousActive.add(chunkcoordintpair);
|
||||||
|
++i;
|
||||||
|
|
||||||
|
if (i >= 10)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void doPreChunk(int x, int z, boolean load)
|
||||||
|
{
|
||||||
|
long id = LongHashMap.packInt(x, z);
|
||||||
|
if (load)
|
||||||
|
{
|
||||||
|
if(this.chunkMapping.getValueByKey(id) != null)
|
||||||
|
this.doPreChunk(x, z, false);
|
||||||
|
ChunkClient chunk = new ChunkClient(this.world, x, z);
|
||||||
|
this.chunkMapping.add(id, chunk);
|
||||||
|
this.chunkListing.add(chunk);
|
||||||
|
chunk.setLoaded();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ChunkClient chunk = this.getChunk(x, z);
|
||||||
|
chunk.onChunkUnload();
|
||||||
|
this.chunkMapping.remove(id);
|
||||||
|
this.chunkListing.remove(chunk);
|
||||||
|
this.emptyChunkListing.remove(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!load)
|
||||||
|
{
|
||||||
|
this.markBlockRangeForRenderUpdate(x * 16, -World.MAX_SIZE_Y, z * 16, x * 16 + 15, World.MAX_SIZE_Y, z * 16 + 15);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addEntityToWorld(int entityID, Entity entityToSpawn)
|
||||||
|
{
|
||||||
|
Entity entity = this.world.getEntityByID(entityID);
|
||||||
|
|
||||||
|
if (entity != null)
|
||||||
|
{
|
||||||
|
this.world.removeEntity(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.entityList.add(entityToSpawn);
|
||||||
|
entityToSpawn.setId(entityID);
|
||||||
|
|
||||||
|
if (!this.world.spawnEntityInWorld(entityToSpawn))
|
||||||
|
{
|
||||||
|
this.spawnQueue.add(entityToSpawn);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.entityIds.addKey(entityID, entityToSpawn);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Entity removeEntityFromWorld(int entityID)
|
||||||
|
{
|
||||||
|
Entity entity = this.entityIds.removeObject(entityID);
|
||||||
|
|
||||||
|
if (entity != null)
|
||||||
|
{
|
||||||
|
this.entityList.remove(entity);
|
||||||
|
this.world.removeEntity(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeAllEntities()
|
||||||
|
{
|
||||||
|
this.entities.removeAll(this.unloaded);
|
||||||
|
|
||||||
|
for (int i = 0; i < this.unloaded.size(); ++i)
|
||||||
|
{
|
||||||
|
Entity entity = this.unloaded.get(i);
|
||||||
|
int j = entity.chunkCoordX;
|
||||||
|
int k = entity.chunkCoordZ;
|
||||||
|
|
||||||
|
if (entity.addedToChunk)
|
||||||
|
{
|
||||||
|
this.getChunk(j, k).removeEntity(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int l = 0; l < this.unloaded.size(); ++l)
|
||||||
|
{
|
||||||
|
this.onEntityRemoved(this.unloaded.get(l));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.unloaded.clear();
|
||||||
|
|
||||||
|
for (int i1 = 0; i1 < this.entities.size(); ++i1)
|
||||||
|
{
|
||||||
|
Entity entity1 = this.entities.get(i1);
|
||||||
|
|
||||||
|
if (entity1.vehicle != null)
|
||||||
|
{
|
||||||
|
if (!entity1.vehicle.dead && entity1.vehicle.passenger == entity1)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
entity1.vehicle.passenger = null;
|
||||||
|
entity1.vehicle = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entity1.dead)
|
||||||
|
{
|
||||||
|
int j1 = entity1.chunkCoordX;
|
||||||
|
int k1 = entity1.chunkCoordZ;
|
||||||
|
|
||||||
|
if (entity1.addedToChunk)
|
||||||
|
{
|
||||||
|
this.getChunk(j1, k1).removeEntity(entity1);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.entities.remove(i1--);
|
||||||
|
this.onEntityRemoved(entity1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void spawnEntityInWorld(boolean flag, Entity entityIn)
|
||||||
|
{
|
||||||
|
this.entityList.add(entityIn);
|
||||||
|
if (!flag)
|
||||||
|
{
|
||||||
|
this.spawnQueue.add(entityIn);
|
||||||
|
}
|
||||||
|
else if (entityIn instanceof EntityCart)
|
||||||
|
{
|
||||||
|
this.soundManager.playSound(new MovingSoundMinecart((EntityCart)entityIn));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeEntity(Entity entityIn)
|
||||||
|
{
|
||||||
|
this.entityList.remove(entityIn);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onEntityAdded(Entity entityIn)
|
||||||
|
{
|
||||||
|
if (this.spawnQueue.contains(entityIn))
|
||||||
|
{
|
||||||
|
this.spawnQueue.remove(entityIn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onEntityRemoved(Entity entityIn)
|
||||||
|
{
|
||||||
|
boolean flag = false;
|
||||||
|
|
||||||
|
if (this.entityList.contains(entityIn))
|
||||||
|
{
|
||||||
|
if (entityIn.isEntityAlive())
|
||||||
|
{
|
||||||
|
this.spawnQueue.add(entityIn);
|
||||||
|
flag = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.entityList.remove(entityIn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ensureAreaLoaded(Entity entity) {
|
||||||
|
int x = ExtMath.floord(entity.posX / 16.0D);
|
||||||
|
int z = ExtMath.floord(entity.posZ / 16.0D);
|
||||||
|
int r = 2;
|
||||||
|
for(int cx = x - r; cx <= x + r; ++cx) {
|
||||||
|
for(int cz = z - r; cz <= z + r; ++cz) {
|
||||||
|
this.getChunk(cx, cz);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!this.entities.contains(entity))
|
||||||
|
this.entities.add(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Entity> getEntities() {
|
||||||
|
return this.entities;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TileEntity> getTiles() {
|
||||||
|
return this.tiles;
|
||||||
|
}
|
||||||
|
|
||||||
private static byte[] genTriwave(int w, int h, int color1, int color2, int color3, int color4, int color5, int color6) {
|
private static byte[] genTriwave(int w, int h, int color1, int color2, int color3, int color4, int color5, int color6) {
|
||||||
byte[] data = new byte[w * h * 4];
|
byte[] data = new byte[w * h * 4];
|
||||||
byte[] color = new byte[24];
|
byte[] color = new byte[24];
|
||||||
|
|
|
@ -24,7 +24,6 @@ import client.gui.ingame.GuiForm;
|
||||||
import client.renderer.texture.EntityTexManager;
|
import client.renderer.texture.EntityTexManager;
|
||||||
import client.util.PlayerController;
|
import client.util.PlayerController;
|
||||||
import client.world.ChunkClient;
|
import client.world.ChunkClient;
|
||||||
import client.world.WorldClient;
|
|
||||||
import common.block.Block;
|
import common.block.Block;
|
||||||
import common.block.tech.BlockAnvil;
|
import common.block.tech.BlockAnvil;
|
||||||
import common.block.tech.BlockChest;
|
import common.block.tech.BlockChest;
|
||||||
|
@ -44,9 +43,11 @@ import common.entity.npc.EntityNPC;
|
||||||
import common.entity.npc.PlayerCharacter;
|
import common.entity.npc.PlayerCharacter;
|
||||||
import common.entity.projectile.EntityProjectile;
|
import common.entity.projectile.EntityProjectile;
|
||||||
import common.entity.types.EntityLiving;
|
import common.entity.types.EntityLiving;
|
||||||
|
import common.init.BlockRegistry;
|
||||||
import common.init.Blocks;
|
import common.init.Blocks;
|
||||||
import common.init.EntityRegistry;
|
import common.init.EntityRegistry;
|
||||||
import common.init.ItemRegistry;
|
import common.init.ItemRegistry;
|
||||||
|
import common.init.Items;
|
||||||
import common.init.SoundEvent;
|
import common.init.SoundEvent;
|
||||||
import common.init.UniverseRegistry;
|
import common.init.UniverseRegistry;
|
||||||
import common.inventory.Container;
|
import common.inventory.Container;
|
||||||
|
@ -54,6 +55,7 @@ import common.inventory.InventoryBasic;
|
||||||
import common.inventory.InventoryPlayer;
|
import common.inventory.InventoryPlayer;
|
||||||
import common.inventory.InventoryWarpChest;
|
import common.inventory.InventoryWarpChest;
|
||||||
import common.item.ItemStack;
|
import common.item.ItemStack;
|
||||||
|
import common.item.material.ItemDye;
|
||||||
import common.log.Log;
|
import common.log.Log;
|
||||||
import common.network.IClientPlayer;
|
import common.network.IClientPlayer;
|
||||||
import common.network.NetConnection;
|
import common.network.NetConnection;
|
||||||
|
@ -124,15 +126,21 @@ import common.packet.SPacketTrades;
|
||||||
import common.packet.SPacketUpdateDisplay;
|
import common.packet.SPacketUpdateDisplay;
|
||||||
import common.packet.SPacketUpdateHealth;
|
import common.packet.SPacketUpdateHealth;
|
||||||
import common.rng.Random;
|
import common.rng.Random;
|
||||||
|
import common.sound.PositionedSound;
|
||||||
import common.sound.Sound;
|
import common.sound.Sound;
|
||||||
import common.tileentity.TileEntity;
|
import common.tileentity.TileEntity;
|
||||||
|
import common.tileentity.TileEntityChest;
|
||||||
import common.tileentity.Device;
|
import common.tileentity.Device;
|
||||||
import common.tileentity.TileEntityDisplay;
|
import common.tileentity.TileEntityDisplay;
|
||||||
import common.tileentity.TileEntitySign;
|
import common.tileentity.TileEntitySign;
|
||||||
|
import common.util.BlockPos;
|
||||||
import common.util.Pair;
|
import common.util.Pair;
|
||||||
|
import common.util.ParticleType;
|
||||||
import common.util.WorldPos;
|
import common.util.WorldPos;
|
||||||
|
import common.util.BlockPos.MutableBlockPos;
|
||||||
import common.village.MerchantRecipeList;
|
import common.village.MerchantRecipeList;
|
||||||
import common.world.Explosion;
|
import common.world.Explosion;
|
||||||
|
import common.world.State;
|
||||||
import common.world.Weather;
|
import common.world.Weather;
|
||||||
import common.world.World;
|
import common.world.World;
|
||||||
|
|
||||||
|
@ -140,7 +148,7 @@ public class ClientPlayer implements IClientPlayer
|
||||||
{
|
{
|
||||||
protected final Client gm;
|
protected final Client gm;
|
||||||
private final NetConnection connection;
|
private final NetConnection connection;
|
||||||
private WorldClient world;
|
private World world;
|
||||||
private boolean loaded;
|
private boolean loaded;
|
||||||
private final Random rand = new Random();
|
private final Random rand = new Random();
|
||||||
|
|
||||||
|
@ -236,9 +244,8 @@ public class ClientPlayer implements IClientPlayer
|
||||||
this.gm.dimensionName = packetIn.getDimName();
|
this.gm.dimensionName = packetIn.getDimName();
|
||||||
this.gm.charEditor = packetIn.isInEditor();
|
this.gm.charEditor = packetIn.isInEditor();
|
||||||
this.gm.controller = new PlayerController(this.gm, this);
|
this.gm.controller = new PlayerController(this.gm, this);
|
||||||
this.world = new WorldClient(this.gm, packetIn.getDimension());
|
|
||||||
// this.gameController.gameSettings.difficulty = packetIn.getDifficulty();
|
// this.gameController.gameSettings.difficulty = packetIn.getDifficulty();
|
||||||
this.gm.loadWorld(this.world, packetIn.getEntityType());
|
this.world = this.gm.loadWorld(packetIn.getDimension(), packetIn.getEntityType());
|
||||||
// this.gameController.thePlayer.dimension = this.clientWorldController.dimension.getDimensionId();
|
// this.gameController.thePlayer.dimension = this.clientWorldController.dimension.getDimensionId();
|
||||||
this.gm.player.setId(packetIn.getEntityId());
|
this.gm.player.setId(packetIn.getEntityId());
|
||||||
this.gm.show(this.gm.charEditor ? GuiChar.INSTANCE : null);
|
this.gm.show(this.gm.charEditor ? GuiChar.INSTANCE : null);
|
||||||
|
@ -400,7 +407,7 @@ public class ClientPlayer implements IClientPlayer
|
||||||
}
|
}
|
||||||
|
|
||||||
entity.setId(packetIn.getEntityID());
|
entity.setId(packetIn.getEntityID());
|
||||||
this.world.addEntityToWorld(packetIn.getEntityID(), entity);
|
this.gm.addEntityToWorld(packetIn.getEntityID(), entity);
|
||||||
|
|
||||||
if(entity instanceof EntityProjectile projectile) {
|
if(entity instanceof EntityProjectile projectile) {
|
||||||
projectile.setAcceleration((double)packetIn.getSpeedX() / 8000.0D, (double)packetIn.getSpeedY() / 8000.0D, (double)packetIn.getSpeedZ() / 8000.0D);
|
projectile.setAcceleration((double)packetIn.getSpeedX() / 8000.0D, (double)packetIn.getSpeedY() / 8000.0D, (double)packetIn.getSpeedZ() / 8000.0D);
|
||||||
|
@ -537,7 +544,7 @@ public class ClientPlayer implements IClientPlayer
|
||||||
}
|
}
|
||||||
|
|
||||||
player.setPositionAndRotation(x, y, z, yaw, pitch);
|
player.setPositionAndRotation(x, y, z, yaw, pitch);
|
||||||
this.world.addEntityToWorld(packetIn.getEntityID(), player);
|
this.gm.addEntityToWorld(packetIn.getEntityID(), player);
|
||||||
List<DataWatcher.WatchableObject> list = packetIn.getData();
|
List<DataWatcher.WatchableObject> list = packetIn.getData();
|
||||||
|
|
||||||
if (list != null)
|
if (list != null)
|
||||||
|
@ -647,7 +654,7 @@ public class ClientPlayer implements IClientPlayer
|
||||||
|
|
||||||
for (int i = 0; i < packetIn.getEntityIDs().length; ++i)
|
for (int i = 0; i < packetIn.getEntityIDs().length; ++i)
|
||||||
{
|
{
|
||||||
this.world.removeEntityFromWorld(packetIn.getEntityIDs()[i]);
|
this.gm.removeEntityFromWorld(packetIn.getEntityIDs()[i]);
|
||||||
EntityTexManager.setTexture(packetIn.getEntityIDs()[i], null, null);
|
EntityTexManager.setTexture(packetIn.getEntityIDs()[i], null, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -713,7 +720,7 @@ public class ClientPlayer implements IClientPlayer
|
||||||
this.gm.player.prevY = this.gm.player.posY;
|
this.gm.player.prevY = this.gm.player.posY;
|
||||||
this.gm.player.prevZ = this.gm.player.posZ;
|
this.gm.player.prevZ = this.gm.player.posZ;
|
||||||
this.loaded = true;
|
this.loaded = true;
|
||||||
this.world.markReload();
|
this.gm.markReload();
|
||||||
// this.gameController.displayGuiScreen(null);
|
// this.gameController.displayGuiScreen(null);
|
||||||
// if(this.travelSound) {
|
// if(this.travelSound) {
|
||||||
// this.gameController.getSoundManager().playSound(new PositionedSound(SoundEvent.TELEPORT));
|
// this.gameController.getSoundManager().playSound(new PositionedSound(SoundEvent.TELEPORT));
|
||||||
|
@ -734,7 +741,7 @@ public class ClientPlayer implements IClientPlayer
|
||||||
|
|
||||||
for (SPacketMultiBlockChange.BlockUpdateData update : packetIn.getChangedBlocks())
|
for (SPacketMultiBlockChange.BlockUpdateData update : packetIn.getChangedBlocks())
|
||||||
{
|
{
|
||||||
this.world.invalidateRegionAndSetBlock(SPacketMultiBlockChange.getPos(packetIn.getChunkPos(), update.getRawPos()), update.getBlockState());
|
this.world.setState(SPacketMultiBlockChange.getPos(packetIn.getChunkPos(), update.getRawPos()), update.getBlockState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -749,17 +756,17 @@ public class ClientPlayer implements IClientPlayer
|
||||||
{
|
{
|
||||||
if (packetIn.getExtractedExtend().length == 0)
|
if (packetIn.getExtractedExtend().length == 0)
|
||||||
{
|
{
|
||||||
this.world.doPreChunk(packetIn.getChunkX(), packetIn.getChunkZ(), false);
|
this.gm.doPreChunk(packetIn.getChunkX(), packetIn.getChunkZ(), false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.world.doPreChunk(packetIn.getChunkX(), packetIn.getChunkZ(), true);
|
this.gm.doPreChunk(packetIn.getChunkX(), packetIn.getChunkZ(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// this.clientWorldController.invalidateBlockReceiveRegion(packetIn.getChunkX() << 4, 0, packetIn.getChunkZ() << 4, (packetIn.getChunkX() << 4) + 15, 512, (packetIn.getChunkZ() << 4) + 15);
|
// this.clientWorldController.invalidateBlockReceiveRegion(packetIn.getChunkX() << 4, 0, packetIn.getChunkZ() << 4, (packetIn.getChunkX() << 4) + 15, 512, (packetIn.getChunkZ() << 4) + 15);
|
||||||
ChunkClient chunk = this.world.getChunk(packetIn.getChunkX(), packetIn.getChunkZ());
|
ChunkClient chunk = this.gm.getChunk(packetIn.getChunkX(), packetIn.getChunkZ());
|
||||||
chunk.setData(packetIn.getExtractedDataBytes(), packetIn.getExtractedExtend(), packetIn.hasBiomes());
|
chunk.setData(packetIn.getExtractedDataBytes(), packetIn.getExtractedExtend(), packetIn.hasBiomes());
|
||||||
this.world.markBlockRangeForRenderUpdate(packetIn.getChunkX() << 4, -World.MAX_SIZE_Y, packetIn.getChunkZ() << 4, (packetIn.getChunkX() << 4) + 15, World.MAX_SIZE_Y, (packetIn.getChunkZ() << 4) + 15);
|
this.gm.markBlockRangeForRenderUpdate(packetIn.getChunkX() << 4, -World.MAX_SIZE_Y, packetIn.getChunkZ() << 4, (packetIn.getChunkX() << 4) + 15, World.MAX_SIZE_Y, (packetIn.getChunkZ() << 4) + 15);
|
||||||
|
|
||||||
if (!packetIn.hasBiomes() || !this.world.dimension.hasSkyLight()) // TODO: check
|
if (!packetIn.hasBiomes() || !this.world.dimension.hasSkyLight()) // TODO: check
|
||||||
{
|
{
|
||||||
|
@ -773,7 +780,7 @@ public class ClientPlayer implements IClientPlayer
|
||||||
public void handleBlockChange(SPacketBlockChange packetIn)
|
public void handleBlockChange(SPacketBlockChange packetIn)
|
||||||
{
|
{
|
||||||
NetHandler.checkThread(packetIn, this, this.gm, this.world);
|
NetHandler.checkThread(packetIn, this, this.gm, this.world);
|
||||||
this.world.invalidateRegionAndSetBlock(packetIn.getBlockPosition(), packetIn.getBlockState());
|
this.world.setState(packetIn.getBlockPosition(), packetIn.getBlockState());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -806,7 +813,7 @@ public class ClientPlayer implements IClientPlayer
|
||||||
this.world.playSoundAtEntity(entity, SoundEvent.POP, 0.2F);
|
this.world.playSoundAtEntity(entity, SoundEvent.POP, 0.2F);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.world.removeEntityFromWorld(packetIn.getCollectedItemEntityID());
|
this.gm.removeEntityFromWorld(packetIn.getCollectedItemEntityID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -952,7 +959,7 @@ public class ClientPlayer implements IClientPlayer
|
||||||
entitylivingbase.motionX = (double)((float)packetIn.getVelocityX() / 8000.0F);
|
entitylivingbase.motionX = (double)((float)packetIn.getVelocityX() / 8000.0F);
|
||||||
entitylivingbase.motionY = (double)((float)packetIn.getVelocityY() / 8000.0F);
|
entitylivingbase.motionY = (double)((float)packetIn.getVelocityY() / 8000.0F);
|
||||||
entitylivingbase.motionZ = (double)((float)packetIn.getVelocityZ() / 8000.0F);
|
entitylivingbase.motionZ = (double)((float)packetIn.getVelocityZ() / 8000.0F);
|
||||||
this.world.addEntityToWorld(packetIn.getEntityID(), entitylivingbase);
|
this.gm.addEntityToWorld(packetIn.getEntityID(), entitylivingbase);
|
||||||
List<DataWatcher.WatchableObject> list = packetIn.getMetadata();
|
List<DataWatcher.WatchableObject> list = packetIn.getMetadata();
|
||||||
|
|
||||||
if (list != null)
|
if (list != null)
|
||||||
|
@ -1082,9 +1089,8 @@ public class ClientPlayer implements IClientPlayer
|
||||||
// this.travelSound = "portal.travel";
|
// this.travelSound = "portal.travel";
|
||||||
// }
|
// }
|
||||||
// Scoreboard scoreboard = this.clientWorldController.getScoreboard();
|
// Scoreboard scoreboard = this.clientWorldController.getScoreboard();
|
||||||
this.world = new WorldClient(this.gm, dim);
|
|
||||||
// this.clientWorldController.setWorldScoreboard(scoreboard);
|
// this.clientWorldController.setWorldScoreboard(scoreboard);
|
||||||
this.gm.loadWorld(this.world, packetIn.getEntityType());
|
this.world = this.gm.loadWorld(dim, packetIn.getEntityType());
|
||||||
// this.gameController.thePlayer.dimension = dim.getDimensionId();
|
// this.gameController.thePlayer.dimension = dim.getDimensionId();
|
||||||
}
|
}
|
||||||
// else if(this.gameController.charEditor) {
|
// else if(this.gameController.charEditor) {
|
||||||
|
@ -1376,7 +1382,7 @@ public class ClientPlayer implements IClientPlayer
|
||||||
public void handleBlockBreakAnim(SPacketBlockBreakAnim packetIn)
|
public void handleBlockBreakAnim(SPacketBlockBreakAnim packetIn)
|
||||||
{
|
{
|
||||||
NetHandler.checkThread(packetIn, this, this.gm, this.world);
|
NetHandler.checkThread(packetIn, this, this.gm, this.world);
|
||||||
this.gm.world.sendBlockBreakProgress(packetIn.getBreakerId(), packetIn.getPosition(), packetIn.getProgress());
|
this.gm.renderGlobal.sendBlockBreakProgress(packetIn.getBreakerId(), packetIn.getPosition(), packetIn.getProgress());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleMapChunkBulk(SPacketMapChunkBulk packetIn)
|
public void handleMapChunkBulk(SPacketMapChunkBulk packetIn)
|
||||||
|
@ -1387,11 +1393,11 @@ public class ClientPlayer implements IClientPlayer
|
||||||
{
|
{
|
||||||
int j = packetIn.getChunkX(i);
|
int j = packetIn.getChunkX(i);
|
||||||
int k = packetIn.getChunkZ(i);
|
int k = packetIn.getChunkZ(i);
|
||||||
this.world.doPreChunk(j, k, true);
|
this.gm.doPreChunk(j, k, true);
|
||||||
// this.clientWorldController.invalidateBlockReceiveRegion(j << 4, 0, k << 4, (j << 4) + 15, 512, (k << 4) + 15);
|
// this.clientWorldController.invalidateBlockReceiveRegion(j << 4, 0, k << 4, (j << 4) + 15, 512, (k << 4) + 15);
|
||||||
ChunkClient chunk = this.world.getChunk(j, k);
|
ChunkClient chunk = this.gm.getChunk(j, k);
|
||||||
chunk.setData(packetIn.getChunkBytes(i), packetIn.getChunkExtend(i), true);
|
chunk.setData(packetIn.getChunkBytes(i), packetIn.getChunkExtend(i), true);
|
||||||
this.world.markBlockRangeForRenderUpdate(j << 4, -World.MAX_SIZE_Y, k << 4, (j << 4) + 15, World.MAX_SIZE_Y, (k << 4) + 15);
|
this.gm.markBlockRangeForRenderUpdate(j << 4, -World.MAX_SIZE_Y, k << 4, (j << 4) + 15, World.MAX_SIZE_Y, (k << 4) + 15);
|
||||||
|
|
||||||
if (!this.world.dimension.hasSkyLight()) // TODO: check
|
if (!this.world.dimension.hasSkyLight()) // TODO: check
|
||||||
{
|
{
|
||||||
|
@ -1430,14 +1436,181 @@ public class ClientPlayer implements IClientPlayer
|
||||||
{
|
{
|
||||||
NetHandler.checkThread(packetIn, this, this.gm, this.world);
|
NetHandler.checkThread(packetIn, this, this.gm, this.world);
|
||||||
|
|
||||||
// if (packetIn.isSoundServerwide())
|
this.playAuxSFX(packetIn.getSoundType(), packetIn.getSoundPos(), packetIn.getSoundData());
|
||||||
// {
|
}
|
||||||
// this.gameController.theWorld.broadcastSound(packetIn.getSoundType(), packetIn.getSoundPos(), packetIn.getSoundData());
|
|
||||||
// }
|
private void spawnParticle(ParticleType particle, double xCoord, double yCoord, double zCoord, int data) {
|
||||||
// else
|
this.gm.effectRenderer.spawnParticle(this.gm.getRenderViewEntity(), particle, xCoord, yCoord, zCoord, data);
|
||||||
// {
|
}
|
||||||
this.gm.world.playAuxSFX(packetIn.getSoundType(), packetIn.getSoundPos(), packetIn.getSoundData());
|
|
||||||
// }
|
private void spawnParticle(ParticleType particle, double xCoord, double yCoord, double zCoord) {
|
||||||
|
this.gm.effectRenderer.spawnParticle(this.gm.getRenderViewEntity(), particle, xCoord, yCoord, zCoord, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void playSoundAtPos(BlockPos pos, SoundEvent sound, float volume)
|
||||||
|
{
|
||||||
|
this.gm.getSoundManager().playSound(new PositionedSound(sound, volume, (float)pos.getX() + 0.5f, (float)pos.getY() + 0.5f, (float)pos.getZ() + 0.5f));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void playAuxSFX(int sfxType, BlockPos blockPosIn, int data)
|
||||||
|
{
|
||||||
|
switch (sfxType)
|
||||||
|
{
|
||||||
|
case 1000:
|
||||||
|
this.playSoundAtPos(blockPosIn, SoundEvent.CLICK, 1.0F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1001:
|
||||||
|
this.playSoundAtPos(blockPosIn, SoundEvent.CLICK, 1.0F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1002:
|
||||||
|
this.playSoundAtPos(blockPosIn, SoundEvent.THROW, 1.0F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1003:
|
||||||
|
this.playSoundAtPos(blockPosIn, SoundEvent.DOOR, 1.0F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1004:
|
||||||
|
this.playSoundAtPos(blockPosIn, SoundEvent.FIZZ, 0.5F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1005:
|
||||||
|
this.playSoundAtPos(blockPosIn, SoundEvent.TELEPORT, 10.0F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1006:
|
||||||
|
this.playSoundAtPos(blockPosIn, SoundEvent.DOOR, 1.0F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1007:
|
||||||
|
this.playSoundAtPos(blockPosIn, SoundEvent.SPELL, 10.0F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1008:
|
||||||
|
this.playSoundAtPos(blockPosIn, SoundEvent.FIREBALL, 10.0F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1009:
|
||||||
|
this.playSoundAtPos(blockPosIn, SoundEvent.FIREBALL, 2.0F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1013:
|
||||||
|
this.playSoundAtPos(blockPosIn, SoundEvent.TELEPORT_REV, 0.5F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1014:
|
||||||
|
this.playSoundAtPos(blockPosIn, SoundEvent.METAL, 2.0F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1015:
|
||||||
|
this.playSoundAtPos(blockPosIn, SoundEvent.BAT_TAKEOFF, 0.05F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1016:
|
||||||
|
this.playSoundAtPos(blockPosIn, SoundEvent.FIREBALL, 2.0F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1017:
|
||||||
|
this.playSoundAtPos(blockPosIn, SoundEvent.EXPLODE, 20.0f);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1020:
|
||||||
|
this.playSoundAtPos(blockPosIn, SoundEvent.ANVIL_BREAK, 1.0F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1021:
|
||||||
|
this.playSoundAtPos(blockPosIn, SoundEvent.ANVIL_USE, 1.0F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1022:
|
||||||
|
this.playSoundAtPos(blockPosIn, SoundEvent.ANVIL_LAND, 0.3F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1023:
|
||||||
|
this.playSoundAtPos(blockPosIn, SoundEvent.GLASS, 1.0F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1024:
|
||||||
|
this.playSoundAtPos(blockPosIn, SoundEvent.CLICK, 1.0F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1025:
|
||||||
|
MutableBlockPos pos = new MutableBlockPos(blockPosIn.getX(), blockPosIn.getY(), blockPosIn.getZ());
|
||||||
|
for(int z = 0; z < 1000; z++) {
|
||||||
|
this.spawnParticle(ParticleType.EXPLOSION_HUGE,
|
||||||
|
(double)pos.getX() + this.rand.gaussian() * 128.0, (double)pos.getY() + this.rand.gaussian() * 2.0, (double)pos.getZ() + this.rand.gaussian() * 128.0);
|
||||||
|
}
|
||||||
|
for(int z = 0; z < 1000; z++) {
|
||||||
|
this.spawnParticle(ParticleType.EXPLOSION_NORMAL,
|
||||||
|
(double)pos.getX() + this.rand.gaussian() * 128.0, (double)pos.getY() + this.rand.gaussian() * 2.0, (double)pos.getZ() + this.rand.gaussian() * 128.0, 100);
|
||||||
|
}
|
||||||
|
for(int z = 0; z < 30; z++) {
|
||||||
|
this.playSoundAtPos(pos.set(blockPosIn.getX() + this.rand.range(-128, 128),
|
||||||
|
blockPosIn.getY() + this.rand.range(-4, 4), blockPosIn.getZ() + this.rand.range(-128, 128)),
|
||||||
|
SoundEvent.EXPLODE, 30.0F);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2000:
|
||||||
|
int l = data % 3 - 1;
|
||||||
|
int i = data / 3 % 3 - 1;
|
||||||
|
double d15 = (double)blockPosIn.getX() + (double)l * 0.6D + 0.5D;
|
||||||
|
double d17 = (double)blockPosIn.getY() + 0.5D;
|
||||||
|
double d19 = (double)blockPosIn.getZ() + (double)i * 0.6D + 0.5D;
|
||||||
|
|
||||||
|
for (int k1 = 0; k1 < 10; ++k1)
|
||||||
|
{
|
||||||
|
double d20 = this.rand.doublev() * 0.2D + 0.01D;
|
||||||
|
double d21 = d15 + (double)l * 0.01D + (this.rand.doublev() - 0.5D) * (double)i * 0.5D;
|
||||||
|
double d4 = d17 + (this.rand.doublev() - 0.5D) * 0.5D;
|
||||||
|
double d6 = d19 + (double)i * 0.01D + (this.rand.doublev() - 0.5D) * (double)l * 0.5D;
|
||||||
|
this.spawnParticle(ParticleType.SMOKE, d21, d4, d6);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
case 2001:
|
||||||
|
State state = BlockRegistry.byId(data);
|
||||||
|
|
||||||
|
if (state != null && state.getBlock() != Blocks.air)
|
||||||
|
{
|
||||||
|
this.gm.getSoundManager().playSound(new PositionedSound(state.getBlock().getSound().getBreakSound(), 1.0F, /* block.sound.getFrequency() * 0.8F, */ (float)blockPosIn.getX() + 0.5F, (float)blockPosIn.getY() + 0.5F, (float)blockPosIn.getZ() + 0.5F));
|
||||||
|
}
|
||||||
|
if(state != null)
|
||||||
|
this.gm.effectRenderer.destroyBlock(blockPosIn, state);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2002:
|
||||||
|
double d13 = (double)blockPosIn.getX();
|
||||||
|
double d14 = (double)blockPosIn.getY();
|
||||||
|
double d16 = (double)blockPosIn.getZ();
|
||||||
|
|
||||||
|
for (int i1 = 0; i1 < 8; ++i1)
|
||||||
|
{
|
||||||
|
this.spawnParticle(ParticleType.ITEM_CRACK, d13, d14, d16, ItemRegistry.getId(Items.water_bottle));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int l1 = 0; l1 < 100; ++l1)
|
||||||
|
{
|
||||||
|
this.spawnParticle(ParticleType.POTION, d13, d14, d16, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.playSoundAtPos(blockPosIn, SoundEvent.GLASS, 1.0F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2005:
|
||||||
|
ItemDye.spawnBonemealParticles(this.gm.world, blockPosIn, data);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2016:
|
||||||
|
TileEntity te = this.gm.world.getTileEntity(blockPosIn);
|
||||||
|
if(te instanceof TileEntityChest chest) {
|
||||||
|
chest.setUsing(data);
|
||||||
|
this.gm.world.markBlockForUpdate(blockPosIn);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
|
@ -1668,7 +1841,7 @@ public class ClientPlayer implements IClientPlayer
|
||||||
// else if(packetIn.getSoundName().startsWith("music#")) {
|
// else if(packetIn.getSoundName().startsWith("music#")) {
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
this.gm.world.playSound(packetIn.getX(), packetIn.getY(), packetIn.getZ(), packetIn.getSound(), packetIn.getVolume());
|
this.gm.getSoundManager().playSound(new PositionedSound(packetIn.getSound(), packetIn.getVolume(), (float)packetIn.getX(), (float)packetIn.getY(), (float)packetIn.getZ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void handleDisplay(S48PacketDisplay packetIn)
|
// public void handleDisplay(S48PacketDisplay packetIn)
|
||||||
|
@ -1891,7 +2064,7 @@ public class ClientPlayer implements IClientPlayer
|
||||||
|
|
||||||
public void handleCelestials(SPacketCelestials packet) {
|
public void handleCelestials(SPacketCelestials packet) {
|
||||||
NetHandler.checkThread(packet, this, this.gm, this.world);
|
NetHandler.checkThread(packet, this, this.gm, this.world);
|
||||||
this.world.setExterminated(packet.getExterminated());
|
this.gm.setExterminated(packet.getExterminated());
|
||||||
if(this.world.dimension.getType() == DimType.PLANET || this.world.dimension.getType() == DimType.MOON) {
|
if(this.world.dimension.getType() == DimType.PLANET || this.world.dimension.getType() == DimType.MOON) {
|
||||||
this.world.dimension.setSunColor(packet.getSunColor());
|
this.world.dimension.setSunColor(packet.getSunColor());
|
||||||
this.world.dimension.setMoonColors(packet.getMoonColors());
|
this.world.dimension.setMoonColors(packet.getMoonColors());
|
||||||
|
|
|
@ -1062,12 +1062,19 @@ public class EffectRenderer {
|
||||||
this.layers[i].add(effect);
|
this.layers[i].add(effect);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void spawnParticle(ParticleType type, double x, double y, double z, int data) {
|
public void spawnParticle(Entity entity, ParticleType type, double x, double y, double z, int data) {
|
||||||
Creator creator = this.types.get(type);
|
if(entity != null) {
|
||||||
if(creator != null) {
|
double dx = entity.posX - x;
|
||||||
Effect effect = creator.create(x, y, z, data);
|
double dy = entity.posY - y;
|
||||||
if(effect != null)
|
double dz = entity.posZ - z;
|
||||||
this.add(effect);
|
if(type.isUnlimited() || dx * dx + dy * dy + dz * dz <= 256.0D) {
|
||||||
|
Creator creator = this.types.get(type);
|
||||||
|
if(creator != null) {
|
||||||
|
Effect effect = creator.create(x, y, z, data);
|
||||||
|
if(effect != null)
|
||||||
|
this.add(effect);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ import org.lwjgl.opengl.GL13;
|
||||||
import client.Client;
|
import client.Client;
|
||||||
import client.renderer.texture.DynamicTexture;
|
import client.renderer.texture.DynamicTexture;
|
||||||
import client.renderer.texture.TextureMap;
|
import client.renderer.texture.TextureMap;
|
||||||
import client.world.WorldClient;
|
|
||||||
import common.block.Block;
|
import common.block.Block;
|
||||||
import common.block.Material;
|
import common.block.Material;
|
||||||
import common.effect.Effect;
|
import common.effect.Effect;
|
||||||
|
@ -25,6 +24,7 @@ import common.init.Items;
|
||||||
import common.init.SoundEvent;
|
import common.init.SoundEvent;
|
||||||
import common.model.BlockLayer;
|
import common.model.BlockLayer;
|
||||||
import common.rng.Random;
|
import common.rng.Random;
|
||||||
|
import common.sound.PositionedSound;
|
||||||
import common.util.BlockPos;
|
import common.util.BlockPos;
|
||||||
import common.util.BoundingBox;
|
import common.util.BoundingBox;
|
||||||
import common.util.ExtMath;
|
import common.util.ExtMath;
|
||||||
|
@ -70,6 +70,8 @@ public class EntityRenderer {
|
||||||
private double cameraYaw;
|
private double cameraYaw;
|
||||||
private double cameraPitch;
|
private double cameraPitch;
|
||||||
private int frameCount;
|
private int frameCount;
|
||||||
|
private int lastLightning;
|
||||||
|
private Vec3 lightColor = new Vec3(0xffffff);
|
||||||
|
|
||||||
public EntityRenderer(Client gmIn)
|
public EntityRenderer(Client gmIn)
|
||||||
{
|
{
|
||||||
|
@ -139,6 +141,8 @@ public class EntityRenderer {
|
||||||
++this.rendererUpdateCount;
|
++this.rendererUpdateCount;
|
||||||
this.itemRenderer.update();
|
this.itemRenderer.update();
|
||||||
this.addRainParticles();
|
this.addRainParticles();
|
||||||
|
if(this.lastLightning > 0)
|
||||||
|
this.lastLightning -= 1;
|
||||||
// this.bossColorModifierPrev = this.bossColorModifier;
|
// this.bossColorModifierPrev = this.bossColorModifier;
|
||||||
//
|
//
|
||||||
// if (BossStatus.hasColorModifier)
|
// if (BossStatus.hasColorModifier)
|
||||||
|
@ -317,19 +321,6 @@ public class EntityRenderer {
|
||||||
{
|
{
|
||||||
float f = 1.0F;
|
float f = 1.0F;
|
||||||
|
|
||||||
// if (player.flying)
|
|
||||||
// {
|
|
||||||
// f *= 1.1F;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// AttributeInstance iattributeinstance = player.getEntityAttribute(Attributes.MOVEMENT_SPEED);
|
|
||||||
// f = (float)((double)f * ((iattributeinstance.getAttributeValue() / 0.1D + 1.0D) / 2.0D));
|
|
||||||
|
|
||||||
// if (Float.isNaN(f) || Float.isInfinite(f))
|
|
||||||
// {
|
|
||||||
// f = 1.0F;
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (player.isUsingItem() && player.getItemInUse().getItem() == Items.bow)
|
if (player.isUsingItem() && player.getItemInUse().getItem() == Items.bow)
|
||||||
{
|
{
|
||||||
int i = player.getItemInUseDuration();
|
int i = player.getItemInUseDuration();
|
||||||
|
@ -349,6 +340,65 @@ public class EntityRenderer {
|
||||||
|
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int hsvToRGB(float hue, float saturation, float value)
|
||||||
|
{
|
||||||
|
int i = (int)(hue * 6.0F) % 6;
|
||||||
|
float f = hue * 6.0F - (float)i;
|
||||||
|
float f1 = value * (1.0F - saturation);
|
||||||
|
float f2 = value * (1.0F - f * saturation);
|
||||||
|
float f3 = value * (1.0F - (1.0F - f) * saturation);
|
||||||
|
float f4;
|
||||||
|
float f5;
|
||||||
|
float f6;
|
||||||
|
|
||||||
|
switch (i)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
f4 = value;
|
||||||
|
f5 = f3;
|
||||||
|
f6 = f1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
f4 = f2;
|
||||||
|
f5 = value;
|
||||||
|
f6 = f1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
f4 = f1;
|
||||||
|
f5 = value;
|
||||||
|
f6 = f3;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
f4 = f1;
|
||||||
|
f5 = f2;
|
||||||
|
f6 = value;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
f4 = f3;
|
||||||
|
f5 = f1;
|
||||||
|
f6 = value;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 5:
|
||||||
|
f4 = value;
|
||||||
|
f5 = f1;
|
||||||
|
f6 = f2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new RuntimeException("Something went wrong when converting from HSV to RGB. Input was " + hue + ", " + saturation + ", " + value);
|
||||||
|
}
|
||||||
|
|
||||||
|
int j = ExtMath.clampi((int)(f4 * 255.0F), 0, 255);
|
||||||
|
int k = ExtMath.clampi((int)(f5 * 255.0F), 0, 255);
|
||||||
|
int l = ExtMath.clampi((int)(f6 * 255.0F), 0, 255);
|
||||||
|
return j << 16 | k << 8 | l;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes the field of view of the player depending on if they are underwater or not
|
* Changes the field of view of the player depending on if they are underwater or not
|
||||||
|
@ -737,18 +787,163 @@ public class EntityRenderer {
|
||||||
this.torchFlickerX += (this.torchFlickerDX - this.torchFlickerX) * 1.0F;
|
this.torchFlickerX += (this.torchFlickerDX - this.torchFlickerX) * 1.0F;
|
||||||
this.lightmapUpdateNeeded = true;
|
this.lightmapUpdateNeeded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void resetLightning() {
|
||||||
|
this.lastLightning = 0;
|
||||||
|
this.lightColor = new Vec3(0xffffff);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLastLightning() {
|
||||||
|
return this.lastLightning;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec3 getLightColor() {
|
||||||
|
return this.lightColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastLightning(int last, int color) {
|
||||||
|
this.lastLightning = last;
|
||||||
|
this.lightColor = new Vec3(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getSunBrightness(float partial) {
|
||||||
|
float f = this.gm.world.getDayPhase(partial);
|
||||||
|
float f1 = 1.0F - (ExtMath.cos(f) * 2.0F + 0.2F);
|
||||||
|
f1 = ExtMath.clampf(f1, 0.0F, 1.0F);
|
||||||
|
f1 = 1.0F - f1;
|
||||||
|
f1 = (float)((double)f1 * (1.0D - (double)(this.gm.world.getRainStrength() * 5.0F) / 16.0D));
|
||||||
|
f1 = (float)((double)f1 * (1.0D - (double)(this.gm.world.getDarkness() * 5.0F) / 16.0D));
|
||||||
|
return Math.max(f1 * 0.8F + 0.2F, this.getSpaceFactor());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec3 getSkyColor(Entity entity, float partial) {
|
||||||
|
BlockPos pos = new BlockPos(ExtMath.floord(entity.posX), ExtMath.floord(entity.posY),
|
||||||
|
ExtMath.floord(entity.posZ));
|
||||||
|
Vec3 vec;
|
||||||
|
if(this.gm.world.dimension.isExterminated())
|
||||||
|
vec = new Vec3(0x101010);
|
||||||
|
else
|
||||||
|
vec = new Vec3(this.gm.world.dimension.getSkyColor());
|
||||||
|
if(this.gm.world.dimension.hasDaylight()) {
|
||||||
|
float mult = ExtMath.clampf(ExtMath.cos(this.gm.world.getDayPhase(partial)) * 2.0F + 0.5F, 0.0F, 1.0F);
|
||||||
|
vec = new Vec3(vec.xCoord * mult, vec.yCoord * mult, vec.zCoord * mult);
|
||||||
|
}
|
||||||
|
float r = (float)vec.xCoord;
|
||||||
|
float g = (float)vec.yCoord;
|
||||||
|
float b = (float)vec.zCoord;
|
||||||
|
|
||||||
|
float rain = this.gm.world.getRainStrength();
|
||||||
|
if(rain > 0.0F) {
|
||||||
|
float mul = (r * 0.3F + g * 0.59F + b * 0.11F) * 0.6F;
|
||||||
|
float shift = 1.0F - rain * 0.75F;
|
||||||
|
r = r * shift + mul * (1.0F - shift);
|
||||||
|
g = g * shift + mul * (1.0F - shift);
|
||||||
|
b = b * shift + mul * (1.0F - shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
float dark = this.gm.world.getDarkness();
|
||||||
|
if(dark > 0.0F) {
|
||||||
|
float mul = (r * 0.3F + g * 0.59F + b * 0.11F) * 0.2F;
|
||||||
|
float shift = 1.0F - dark * 0.75F;
|
||||||
|
r = r * shift + mul * (1.0F - shift);
|
||||||
|
g = g * shift + mul * (1.0F - shift);
|
||||||
|
b = b * shift + mul * (1.0F - shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.lastLightning > 0) {
|
||||||
|
float light = (float)this.lastLightning - partial;
|
||||||
|
if(light > 1.0F)
|
||||||
|
light = 1.0F;
|
||||||
|
// light = light * 0.45F;
|
||||||
|
r = r * (1.0F - light) + (float)this.lightColor.xCoord * light;
|
||||||
|
g = g * (1.0F - light) + (float)this.lightColor.yCoord * light;
|
||||||
|
b = b * (1.0F - light) + (float)this.lightColor.zCoord * light;
|
||||||
|
}
|
||||||
|
|
||||||
|
float space = this.getSpaceFactor();
|
||||||
|
if(space > 0.0f) {
|
||||||
|
r = r * (1.0F - space);
|
||||||
|
g = g * (1.0F - space);
|
||||||
|
b = b * (1.0F - space);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Vec3((double)r, (double)g, (double)b);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec3 getCloudColor(Entity entity, float partialTicks) {
|
||||||
|
Vec3 color = new Vec3(this.gm.world.dimension.getCloudColor());
|
||||||
|
if(this.gm.world.dimension.isExterminated())
|
||||||
|
color = new Vec3(0x000000);
|
||||||
|
float r = (float)color.xCoord;
|
||||||
|
float g = (float)color.yCoord;
|
||||||
|
float b = (float)color.zCoord;
|
||||||
|
|
||||||
|
float rain = this.gm.world.getRainStrength();
|
||||||
|
if(rain > 0.0F) {
|
||||||
|
float mul = (r * 0.3F + g * 0.59F + b * 0.11F) * 0.6F;
|
||||||
|
float shift = 1.0F - rain * 0.95F;
|
||||||
|
r = r * shift + mul * (1.0F - shift);
|
||||||
|
g = g * shift + mul * (1.0F - shift);
|
||||||
|
b = b * shift + mul * (1.0F - shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.gm.world.dimension.hasDaylight()) {
|
||||||
|
float sun = ExtMath.clampf(ExtMath.cos(this.gm.world.getDayPhase(partialTicks)) * 2.0F + 0.5F,
|
||||||
|
0.0F, 1.0F);
|
||||||
|
r = r * (sun * 0.9F + 0.1F);
|
||||||
|
g = g * (sun * 0.9F + 0.1F);
|
||||||
|
b = b * (sun * 0.85F + 0.15F);
|
||||||
|
}
|
||||||
|
|
||||||
|
float dark = this.gm.world.getDarkness();
|
||||||
|
if(dark > 0.0F) {
|
||||||
|
float mul = (r * 0.3F + g * 0.59F + b * 0.11F) * 0.2F;
|
||||||
|
float shift = 1.0F - dark * 0.95F;
|
||||||
|
r = r * shift + mul * (1.0F - shift);
|
||||||
|
g = g * shift + mul * (1.0F - shift);
|
||||||
|
b = b * shift + mul * (1.0F - shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
float space = this.getSpaceFactor();
|
||||||
|
if(space > 0.0f) {
|
||||||
|
r = r * (1.0F - space);
|
||||||
|
g = g * (1.0F - space);
|
||||||
|
b = b * (1.0F - space);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Vec3((double)r, (double)g, (double)b);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getStarBrightness(float partialTicks) {
|
||||||
|
float f = this.gm.world.getDayPhase(partialTicks);
|
||||||
|
float f1 = 1.0F - (ExtMath.cos(f) * 2.0F + 0.25F);
|
||||||
|
f1 = ExtMath.clampf(f1, 0.0F, 1.0F);
|
||||||
|
return Math.max(f1 * f1 * this.gm.world.dimension.getStarBrightness(), this.getSpaceFactor());
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getDeepStarBrightness(float partialTicks) {
|
||||||
|
float f = this.gm.world.getDayPhase(partialTicks);
|
||||||
|
float f1 = 1.0F - (ExtMath.cos(f) * 2.0F + 0.25F);
|
||||||
|
f1 = ExtMath.clampf(f1, 0.0F, 1.0F);
|
||||||
|
return Math.max(f1 * f1 * this.gm.world.dimension.getDeepStarBrightness(), this.getSpaceFactor());
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getSpaceFactor() {
|
||||||
|
Entity entity = this.gm.getRenderViewEntity();
|
||||||
|
return entity == null ? 0.0f : (float)this.gm.world.getSpaceFactor(entity.posX, entity.posY, entity.posZ);
|
||||||
|
}
|
||||||
|
|
||||||
private void updateLightmap(float partialTicks)
|
private void updateLightmap(float partialTicks)
|
||||||
{
|
{
|
||||||
if (this.lightmapUpdateNeeded)
|
if (this.lightmapUpdateNeeded)
|
||||||
{
|
{
|
||||||
WorldClient world = this.gm.world;
|
World world = this.gm.world;
|
||||||
|
|
||||||
if (world != null)
|
if (world != null)
|
||||||
{
|
{
|
||||||
float sun = world.getSunBrightness(1.0F);
|
float sun = this.getSunBrightness(1.0F);
|
||||||
float msun = sun * 0.95F + 0.05F;
|
float msun = sun * 0.95F + 0.05F;
|
||||||
float space = world.getSpaceFactor();
|
float space = this.getSpaceFactor();
|
||||||
float brightness = (float)world.dimension.getBrightness() / 15.0f;
|
float brightness = (float)world.dimension.getBrightness() / 15.0f;
|
||||||
|
|
||||||
for (int n = 0; n < 256; ++n)
|
for (int n = 0; n < 256; ++n)
|
||||||
|
@ -774,16 +969,15 @@ public class EntityRenderer {
|
||||||
sgreen = sgreen * (1.0F - space) + space;
|
sgreen = sgreen * (1.0F - space) + space;
|
||||||
sblue = sblue * (1.0F - space) + space;
|
sblue = sblue * (1.0F - space) + space;
|
||||||
}
|
}
|
||||||
if (world.getLastLightning() > 0)
|
if (this.lastLightning > 0)
|
||||||
{
|
{
|
||||||
Vec3 lightColor = world.getLightColor();
|
float intens = (float)this.lastLightning - partialTicks;
|
||||||
float intens = (float)world.getLastLightning() - partialTicks;
|
|
||||||
if(intens > 1.0F)
|
if(intens > 1.0F)
|
||||||
intens = 1.0F;
|
intens = 1.0F;
|
||||||
float light = world.dimension.hasSkyLight() ? rsky : 1.0f;
|
float light = world.dimension.hasSkyLight() ? rsky : 1.0f;
|
||||||
sred = sred * (1.0F - intens) + (float)lightColor.xCoord * light * intens;
|
sred = sred * (1.0F - intens) + (float)this.lightColor.xCoord * light * intens;
|
||||||
sgreen = sgreen * (1.0F - intens) + (float)lightColor.yCoord * light * intens;
|
sgreen = sgreen * (1.0F - intens) + (float)this.lightColor.yCoord * light * intens;
|
||||||
sblue = sblue * (1.0F - intens) + (float)lightColor.zCoord * light * intens;
|
sblue = sblue * (1.0F - intens) + (float)this.lightColor.zCoord * light * intens;
|
||||||
}
|
}
|
||||||
|
|
||||||
float bred = block;
|
float bred = block;
|
||||||
|
@ -1088,7 +1282,7 @@ public class EntityRenderer {
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
this.setupFog(0, partialTicks);
|
this.setupFog(0, partialTicks);
|
||||||
// renderGlobalIn.renderClouds(partialTicks);
|
// renderGlobalIn.renderClouds(partialTicks);
|
||||||
float alpha = 0.8F * (1.0f - this.gm.world.getSpaceFactor());
|
float alpha = 0.8F * (1.0f - this.getSpaceFactor());
|
||||||
if(this.gm.world.dimension.hasWeather() && alpha > 0.5f)
|
if(this.gm.world.dimension.hasWeather() && alpha > 0.5f)
|
||||||
renderGlobalIn.renderClouds(alpha, partialTicks);
|
renderGlobalIn.renderClouds(alpha, partialTicks);
|
||||||
GlState.disableFog();
|
GlState.disableFog();
|
||||||
|
@ -1185,11 +1379,11 @@ public class EntityRenderer {
|
||||||
|
|
||||||
if (d1 > (double)(blockpos.getY() + 1) && world.getPrecipitationHeight(blockpos).getY() > ExtMath.floorf((float)blockpos.getY()))
|
if (d1 > (double)(blockpos.getY() + 1) && world.getPrecipitationHeight(blockpos).getY() > ExtMath.floorf((float)blockpos.getY()))
|
||||||
{
|
{
|
||||||
this.gm.world.playSound(d0, d1, d2, n >= j ? this.pickMoltenSound() : SoundEvent.RAIN, n >= j ? 0.2f : 0.1F);
|
this.gm.getSoundManager().playSound(new PositionedSound(n >= j ? this.pickMoltenSound() : SoundEvent.RAIN, n >= j ? 0.2f : 0.1F, (float)d0, (float)d1, (float)d2));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.gm.world.playSound(d0, d1, d2, n >= j ? this.pickMoltenSound() : SoundEvent.RAIN, n >= j ? 0.4f : 0.2F);
|
this.gm.getSoundManager().playSound(new PositionedSound(n >= j ? this.pickMoltenSound() : SoundEvent.RAIN, n >= j ? 0.4f : 0.2F, (float)d0, (float)d1, (float)d2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1330,7 +1524,7 @@ public class EntityRenderer {
|
||||||
|
|
||||||
private void updateFogColor(float partial)
|
private void updateFogColor(float partial)
|
||||||
{
|
{
|
||||||
WorldClient world = this.gm.world;
|
World world = this.gm.world;
|
||||||
Entity entity = this.gm.getRenderViewEntity();
|
Entity entity = this.gm.getRenderViewEntity();
|
||||||
|
|
||||||
Vec3 fog = new Vec3(world.dimension.getFogColor());
|
Vec3 fog = new Vec3(world.dimension.getFogColor());
|
||||||
|
@ -1351,7 +1545,7 @@ public class EntityRenderer {
|
||||||
this.fogColorBlue = this.fogColorBlue * (sun * 0.91F + 0.09F);
|
this.fogColorBlue = this.fogColorBlue * (sun * 0.91F + 0.09F);
|
||||||
}
|
}
|
||||||
|
|
||||||
float space = world.getSpaceFactor();
|
float space = this.getSpaceFactor();
|
||||||
if(space > 0.0f) {
|
if(space > 0.0f) {
|
||||||
this.fogColorRed = this.fogColorRed * (1.0F - space);
|
this.fogColorRed = this.fogColorRed * (1.0F - space);
|
||||||
this.fogColorGreen = this.fogColorGreen * (1.0F - space);
|
this.fogColorGreen = this.fogColorGreen * (1.0F - space);
|
||||||
|
@ -1378,7 +1572,7 @@ public class EntityRenderer {
|
||||||
|
|
||||||
float dist = 0.25F + 0.75F * (float)this.gm.renderDistance / 32.0F;
|
float dist = 0.25F + 0.75F * (float)this.gm.renderDistance / 32.0F;
|
||||||
dist = 1.0F - (float)Math.pow((double)dist, 0.25D);
|
dist = 1.0F - (float)Math.pow((double)dist, 0.25D);
|
||||||
Vec3 sky = world.getSkyColor(this.gm.getRenderViewEntity(), partial);
|
Vec3 sky = this.getSkyColor(this.gm.getRenderViewEntity(), partial);
|
||||||
this.fogColorRed += ((float)sky.xCoord - this.fogColorRed) * dist;
|
this.fogColorRed += ((float)sky.xCoord - this.fogColorRed) * dist;
|
||||||
this.fogColorGreen += ((float)sky.yCoord - this.fogColorGreen) * dist;
|
this.fogColorGreen += ((float)sky.yCoord - this.fogColorGreen) * dist;
|
||||||
this.fogColorBlue += ((float)sky.zCoord - this.fogColorBlue) * dist;
|
this.fogColorBlue += ((float)sky.zCoord - this.fogColorBlue) * dist;
|
||||||
|
|
|
@ -3,7 +3,7 @@ package client.renderer;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import client.world.ChunkClient;
|
import client.world.ChunkClient;
|
||||||
import client.world.WorldClient;
|
import client.Client;
|
||||||
import common.init.Blocks;
|
import common.init.Blocks;
|
||||||
import common.tileentity.TileEntity;
|
import common.tileentity.TileEntity;
|
||||||
import common.util.BlockPos;
|
import common.util.BlockPos;
|
||||||
|
@ -21,15 +21,15 @@ public class RegionRenderCache implements IWorldAccess
|
||||||
private final int xPos;
|
private final int xPos;
|
||||||
private final int zPos;
|
private final int zPos;
|
||||||
private final ChunkClient[][] chunks;
|
private final ChunkClient[][] chunks;
|
||||||
private final World world;
|
private final boolean sky;
|
||||||
private final BlockPos position;
|
private final BlockPos position;
|
||||||
private final boolean empty;
|
private final boolean empty;
|
||||||
private int[] combinedLights;
|
private int[] combinedLights;
|
||||||
private State[] blockStates;
|
private State[] blockStates;
|
||||||
|
|
||||||
public RegionRenderCache(WorldClient world, BlockPos from, BlockPos to, int sub)
|
public RegionRenderCache(Client world, BlockPos from, BlockPos to, int sub)
|
||||||
{
|
{
|
||||||
this.world = world;
|
this.sky = world.world.dimension.hasSkyLight();
|
||||||
this.xPos = from.getX() - sub >> 4;
|
this.xPos = from.getX() - sub >> 4;
|
||||||
this.zPos = from.getZ() - sub >> 4;
|
this.zPos = from.getZ() - sub >> 4;
|
||||||
int x2 = to.getX() + sub >> 4;
|
int x2 = to.getX() + sub >> 4;
|
||||||
|
@ -140,7 +140,7 @@ public class RegionRenderCache implements IWorldAccess
|
||||||
|
|
||||||
private int getLightForExt(LightType p_175629_1_, BlockPos pos)
|
private int getLightForExt(LightType p_175629_1_, BlockPos pos)
|
||||||
{
|
{
|
||||||
if (p_175629_1_ == LightType.SKY && !this.world.dimension.hasSkyLight())
|
if (p_175629_1_ == LightType.SKY && !this.sky)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,6 @@ import client.renderer.texture.TextureManager;
|
||||||
import client.renderer.texture.TextureMap;
|
import client.renderer.texture.TextureMap;
|
||||||
import client.renderer.tileentity.SpecialRenderer;
|
import client.renderer.tileentity.SpecialRenderer;
|
||||||
import client.world.ChunkClient;
|
import client.world.ChunkClient;
|
||||||
import client.world.WorldClient;
|
|
||||||
import common.block.Block;
|
import common.block.Block;
|
||||||
import common.collect.Lists;
|
import common.collect.Lists;
|
||||||
import common.collect.Maps;
|
import common.collect.Maps;
|
||||||
|
@ -116,7 +115,7 @@ public class RenderGlobal
|
||||||
private final TextureManager renderEngine;
|
private final TextureManager renderEngine;
|
||||||
private final RenderManager renderManager;
|
private final RenderManager renderManager;
|
||||||
private final Random rand = new Random();
|
private final Random rand = new Random();
|
||||||
private WorldClient theWorld;
|
private World theWorld;
|
||||||
private Set<RenderChunk> chunksToUpdate = new LinkedHashSet<RenderChunk>();
|
private Set<RenderChunk> chunksToUpdate = new LinkedHashSet<RenderChunk>();
|
||||||
private List<RenderGlobal.ContainerLocalRenderInformation> renderInfos = new ArrayList<ContainerLocalRenderInformation>(69696);
|
private List<RenderGlobal.ContainerLocalRenderInformation> renderInfos = new ArrayList<ContainerLocalRenderInformation>(69696);
|
||||||
private final Set<TileEntity> setTileEntities = Sets.<TileEntity>newHashSet();
|
private final Set<TileEntity> setTileEntities = Sets.<TileEntity>newHashSet();
|
||||||
|
@ -409,7 +408,7 @@ public class RenderGlobal
|
||||||
/**
|
/**
|
||||||
* set null to clear
|
* set null to clear
|
||||||
*/
|
*/
|
||||||
public void setWorldAndLoadRenderers(WorldClient worldClientIn)
|
public void setWorldAndLoadRenderers(World worldClientIn)
|
||||||
{
|
{
|
||||||
// if (this.theWorld != null)
|
// if (this.theWorld != null)
|
||||||
// {
|
// {
|
||||||
|
@ -455,7 +454,7 @@ public class RenderGlobal
|
||||||
this.setTileEntities.clear();
|
this.setTileEntities.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.viewFrustum = new ViewFrustum(this.theWorld, this.gm.renderDistance, this);
|
this.viewFrustum = new ViewFrustum(this.gm, this.gm.renderDistance, this);
|
||||||
|
|
||||||
if (this.theWorld != null)
|
if (this.theWorld != null)
|
||||||
{
|
{
|
||||||
|
@ -506,7 +505,7 @@ public class RenderGlobal
|
||||||
SpecialRenderer.entityZ = d5;
|
SpecialRenderer.entityZ = d5;
|
||||||
this.renderManager.setRenderPosition(d3, d4, d5);
|
this.renderManager.setRenderPosition(d3, d4, d5);
|
||||||
this.gm.entityRenderer.enableLightmap();
|
this.gm.entityRenderer.enableLightmap();
|
||||||
List<Entity> list = this.theWorld.getLoadedEntityList();
|
List<Entity> list = this.gm.getEntities();
|
||||||
this.countEntitiesTotal = list.size();
|
this.countEntitiesTotal = list.size();
|
||||||
|
|
||||||
for (int i = 0; i < this.theWorld.effects.size(); ++i)
|
for (int i = 0; i < this.theWorld.effects.size(); ++i)
|
||||||
|
@ -531,7 +530,7 @@ public class RenderGlobal
|
||||||
GlState.disableTexture2D();
|
GlState.disableTexture2D();
|
||||||
GlState.depthMask(false);
|
GlState.depthMask(false);
|
||||||
|
|
||||||
List<TileEntity> tiles = this.theWorld.getLoadedTileList();
|
List<TileEntity> tiles = this.gm.getTiles();
|
||||||
|
|
||||||
for (int j = 0; j < tiles.size(); ++j)
|
for (int j = 0; j < tiles.size(); ++j)
|
||||||
{
|
{
|
||||||
|
@ -601,10 +600,10 @@ public class RenderGlobal
|
||||||
|
|
||||||
label738:
|
label738:
|
||||||
|
|
||||||
for (RenderGlobal.ContainerLocalRenderInformation renderglobal$containerlocalrenderinformation : this.renderInfos)
|
for (RenderGlobal.ContainerLocalRenderInformation render : this.renderInfos)
|
||||||
{
|
{
|
||||||
ChunkClient chunk = this.theWorld.getChunk(renderglobal$containerlocalrenderinformation.renderChunk.getPosition());
|
ChunkClient chunk = this.gm.getChunk(render.renderChunk.getPosition().getX() >> 4, render.renderChunk.getPosition().getZ() >> 4);
|
||||||
InheritanceMultiMap<Entity> classinheritancemultimap = chunk.getEntities()[ExtMath.clampi(renderglobal$containerlocalrenderinformation.renderChunk.getPosition().getY() / 16, 0, 31)];
|
InheritanceMultiMap<Entity> classinheritancemultimap = chunk.getEntities()[ExtMath.clampi(render.renderChunk.getPosition().getY() / 16, 0, 31)];
|
||||||
|
|
||||||
if (!classinheritancemultimap.isEmpty())
|
if (!classinheritancemultimap.isEmpty())
|
||||||
{
|
{
|
||||||
|
@ -897,7 +896,7 @@ public class RenderGlobal
|
||||||
{
|
{
|
||||||
VisGraph visgraph = new VisGraph();
|
VisGraph visgraph = new VisGraph();
|
||||||
BlockPos blockpos = new BlockPos(pos.getX() >> 4 << 4, pos.getY() >> 4 << 4, pos.getZ() >> 4 << 4);
|
BlockPos blockpos = new BlockPos(pos.getX() >> 4 << 4, pos.getY() >> 4 << 4, pos.getZ() >> 4 << 4);
|
||||||
ChunkClient chunk = this.theWorld.getChunk(blockpos);
|
ChunkClient chunk = this.gm.getChunk(blockpos.getX() >> 4, blockpos.getZ() >> 4);
|
||||||
|
|
||||||
for (BlockPos.MutableBlockPos blockpos$mutableblockpos : BlockPos.getAllInBoxMutable(blockpos, blockpos.add(15, 15, 15)))
|
for (BlockPos.MutableBlockPos blockpos$mutableblockpos : BlockPos.getAllInBoxMutable(blockpos, blockpos.add(15, 15, 15)))
|
||||||
{
|
{
|
||||||
|
@ -1117,7 +1116,7 @@ public class RenderGlobal
|
||||||
else if (this.gm.world.dimension.hasSky())
|
else if (this.gm.world.dimension.hasSky())
|
||||||
{
|
{
|
||||||
GlState.disableTexture2D();
|
GlState.disableTexture2D();
|
||||||
Vec3 vec3 = this.theWorld.getSkyColor(this.gm.getRenderViewEntity(), partialTicks);
|
Vec3 vec3 = this.gm.entityRenderer.getSkyColor(this.gm.getRenderViewEntity(), partialTicks);
|
||||||
float f = (float)vec3.xCoord;
|
float f = (float)vec3.xCoord;
|
||||||
float f1 = (float)vec3.yCoord;
|
float f1 = (float)vec3.yCoord;
|
||||||
float f2 = (float)vec3.zCoord;
|
float f2 = (float)vec3.zCoord;
|
||||||
|
@ -1252,7 +1251,7 @@ public class RenderGlobal
|
||||||
}
|
}
|
||||||
GlState.disableTexture2D();
|
GlState.disableTexture2D();
|
||||||
|
|
||||||
float f15 = this.theWorld.getStarBrightness(partialTicks) * f16;
|
float f15 = this.gm.entityRenderer.getStarBrightness(partialTicks) * f16;
|
||||||
if (f15 > 0.0F)
|
if (f15 > 0.0F)
|
||||||
{
|
{
|
||||||
int stars = this.theWorld.dimension.getStarColor(this.theWorld.getDayTime());
|
int stars = this.theWorld.dimension.getStarColor(this.theWorld.getDayTime());
|
||||||
|
@ -1279,7 +1278,7 @@ public class RenderGlobal
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
f15 = this.theWorld.getDeepStarBrightness(partialTicks) * f16;
|
f15 = this.gm.entityRenderer.getDeepStarBrightness(partialTicks) * f16;
|
||||||
if (f15 > 0.0F)
|
if (f15 > 0.0F)
|
||||||
{
|
{
|
||||||
int stars = this.theWorld.dimension.getDeepStarColor(this.theWorld.getDayTime());
|
int stars = this.theWorld.dimension.getDeepStarColor(this.theWorld.getDayTime());
|
||||||
|
@ -1335,7 +1334,7 @@ public class RenderGlobal
|
||||||
this.renderEngine.bindTexture(this.gm.world.dimension.getCloudTexture());
|
this.renderEngine.bindTexture(this.gm.world.dimension.getCloudTexture());
|
||||||
GlState.enableBlend();
|
GlState.enableBlend();
|
||||||
GlState.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
|
GlState.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
|
||||||
Vec3 vec3 = this.theWorld.getCloudColour(this.gm.getRenderViewEntity(), partialTicks);
|
Vec3 vec3 = this.gm.entityRenderer.getCloudColor(this.gm.getRenderViewEntity(), partialTicks);
|
||||||
float f4 = (float)vec3.xCoord;
|
float f4 = (float)vec3.xCoord;
|
||||||
float f5 = (float)vec3.yCoord;
|
float f5 = (float)vec3.yCoord;
|
||||||
float f6 = (float)vec3.zCoord;
|
float f6 = (float)vec3.zCoord;
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
package client.renderer;
|
package client.renderer;
|
||||||
|
|
||||||
import client.renderer.chunk.RenderChunk;
|
import client.renderer.chunk.RenderChunk;
|
||||||
import client.world.WorldClient;
|
import client.Client;
|
||||||
import common.util.BlockPos;
|
import common.util.BlockPos;
|
||||||
import common.util.ExtMath;
|
import common.util.ExtMath;
|
||||||
|
|
||||||
public class ViewFrustum
|
public class ViewFrustum
|
||||||
{
|
{
|
||||||
protected final RenderGlobal renderGlobal;
|
protected final RenderGlobal renderGlobal;
|
||||||
protected final WorldClient world;
|
protected final Client gm;
|
||||||
protected int countChunksY;
|
protected int countChunksY;
|
||||||
protected int countChunksX;
|
protected int countChunksX;
|
||||||
protected int countChunksZ;
|
protected int countChunksZ;
|
||||||
|
@ -18,10 +18,10 @@ public class ViewFrustum
|
||||||
return i < 0 ? -((-i - 1) / 16) - 1 : i / 16;
|
return i < 0 ? -((-i - 1) / 16) - 1 : i / 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ViewFrustum(WorldClient worldIn, int renderDistanceChunks, RenderGlobal p_i46246_3_)
|
public ViewFrustum(Client worldIn, int renderDistanceChunks, RenderGlobal p_i46246_3_)
|
||||||
{
|
{
|
||||||
this.renderGlobal = p_i46246_3_;
|
this.renderGlobal = p_i46246_3_;
|
||||||
this.world = worldIn;
|
this.gm = worldIn;
|
||||||
this.setCountChunksXYZ(renderDistanceChunks);
|
this.setCountChunksXYZ(renderDistanceChunks);
|
||||||
this.createRenderChunks();
|
this.createRenderChunks();
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ public class ViewFrustum
|
||||||
{
|
{
|
||||||
int j1 = (i1 * this.countChunksY + l) * this.countChunksX + k;
|
int j1 = (i1 * this.countChunksY + l) * this.countChunksX + k;
|
||||||
BlockPos blockpos = new BlockPos(k * 16, l * 16, i1 * 16);
|
BlockPos blockpos = new BlockPos(k * 16, l * 16, i1 * 16);
|
||||||
this.renderChunks[j1] = new RenderChunk(this.world, this.renderGlobal, blockpos, j++);
|
this.renderChunks[j1] = new RenderChunk(this.gm, this.renderGlobal, blockpos, j++);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ import client.renderer.RenderGlobal;
|
||||||
import client.renderer.VertexBuffer;
|
import client.renderer.VertexBuffer;
|
||||||
import client.renderer.tileentity.SpecialRenderer;
|
import client.renderer.tileentity.SpecialRenderer;
|
||||||
import client.renderer.tileentity.ElementRenderer;
|
import client.renderer.tileentity.ElementRenderer;
|
||||||
import client.world.WorldClient;
|
|
||||||
import common.block.Block;
|
import common.block.Block;
|
||||||
import common.block.ITileEntityProvider;
|
import common.block.ITileEntityProvider;
|
||||||
import common.collect.Maps;
|
import common.collect.Maps;
|
||||||
|
@ -33,7 +32,7 @@ import common.world.State;
|
||||||
|
|
||||||
public class RenderChunk
|
public class RenderChunk
|
||||||
{
|
{
|
||||||
private WorldClient world;
|
private Client gm;
|
||||||
private final RenderGlobal renderGlobal;
|
private final RenderGlobal renderGlobal;
|
||||||
public static int renderChunksUpdated;
|
public static int renderChunksUpdated;
|
||||||
private BlockPos position;
|
private BlockPos position;
|
||||||
|
@ -50,9 +49,9 @@ public class RenderChunk
|
||||||
private boolean needsUpdate = true;
|
private boolean needsUpdate = true;
|
||||||
private EnumMap<Facing, BlockPos> mapEnumFacing = Maps.newEnumMap(Facing.class);
|
private EnumMap<Facing, BlockPos> mapEnumFacing = Maps.newEnumMap(Facing.class);
|
||||||
|
|
||||||
public RenderChunk(WorldClient worldIn, RenderGlobal renderGlobalIn, BlockPos blockPosIn, int indexIn)
|
public RenderChunk(Client worldIn, RenderGlobal renderGlobalIn, BlockPos blockPosIn, int indexIn)
|
||||||
{
|
{
|
||||||
this.world = worldIn;
|
this.gm = worldIn;
|
||||||
this.renderGlobal = renderGlobalIn;
|
this.renderGlobal = renderGlobalIn;
|
||||||
this.index = indexIn;
|
this.index = indexIn;
|
||||||
|
|
||||||
|
@ -127,7 +126,7 @@ public class RenderChunk
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
iblockaccess = new RegionRenderCache(this.world, blockpos.add(-1, -1, -1), blockpos1.add(1, 1, 1), 1);
|
iblockaccess = new RegionRenderCache(this.gm, blockpos.add(-1, -1, -1), blockpos1.add(1, 1, 1), 1);
|
||||||
generator.setCompiledChunk(compiledchunk);
|
generator.setCompiledChunk(compiledchunk);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -142,7 +141,7 @@ public class RenderChunk
|
||||||
{
|
{
|
||||||
++renderChunksUpdated;
|
++renderChunksUpdated;
|
||||||
boolean[] aboolean = new boolean[BlockLayer.values().length];
|
boolean[] aboolean = new boolean[BlockLayer.values().length];
|
||||||
BlockRenderer blockrendererdispatcher = Client.CLIENT.getBlockRendererDispatcher();
|
BlockRenderer blockrendererdispatcher = this.gm.getBlockRendererDispatcher();
|
||||||
|
|
||||||
for (BlockPos.MutableBlockPos blockpos$mutableblockpos : BlockPos.getAllInBoxMutable(blockpos, blockpos1))
|
for (BlockPos.MutableBlockPos blockpos$mutableblockpos : BlockPos.getAllInBoxMutable(blockpos, blockpos1))
|
||||||
{
|
{
|
||||||
|
@ -355,7 +354,7 @@ public class RenderChunk
|
||||||
public void deleteGlResources()
|
public void deleteGlResources()
|
||||||
{
|
{
|
||||||
this.stopCompileTask();
|
this.stopCompileTask();
|
||||||
this.world = null;
|
this.gm = null;
|
||||||
|
|
||||||
for (int i = 0; i < BlockLayer.values().length; ++i)
|
for (int i = 0; i < BlockLayer.values().length; ++i)
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,13 +5,13 @@ import java.util.Map;
|
||||||
import org.lwjgl.opengl.GL13;
|
import org.lwjgl.opengl.GL13;
|
||||||
|
|
||||||
import client.renderer.GlState;
|
import client.renderer.GlState;
|
||||||
import client.world.WorldClient;
|
|
||||||
import common.collect.Maps;
|
import common.collect.Maps;
|
||||||
import common.entity.Entity;
|
import common.entity.Entity;
|
||||||
import common.tileentity.TileEntity;
|
import common.tileentity.TileEntity;
|
||||||
import common.tileentity.TileEntityDisplay;
|
import common.tileentity.TileEntityDisplay;
|
||||||
import common.tileentity.TileEntitySign;
|
import common.tileentity.TileEntitySign;
|
||||||
import common.util.BlockPos;
|
import common.util.BlockPos;
|
||||||
|
import common.world.World;
|
||||||
|
|
||||||
public class SpecialRenderer {
|
public class SpecialRenderer {
|
||||||
public static SpecialRenderer instance = new SpecialRenderer();
|
public static SpecialRenderer instance = new SpecialRenderer();
|
||||||
|
@ -21,7 +21,7 @@ public class SpecialRenderer {
|
||||||
|
|
||||||
private final Map<Class<? extends TileEntity>, ElementRenderer<? extends TileEntity>> renderers = Maps.<Class<? extends TileEntity>, ElementRenderer<? extends TileEntity>>newHashMap();
|
private final Map<Class<? extends TileEntity>, ElementRenderer<? extends TileEntity>> renderers = Maps.<Class<? extends TileEntity>, ElementRenderer<? extends TileEntity>>newHashMap();
|
||||||
|
|
||||||
private WorldClient world;
|
private World world;
|
||||||
private double posX;
|
private double posX;
|
||||||
private double posY;
|
private double posY;
|
||||||
private double posZ;
|
private double posZ;
|
||||||
|
@ -44,7 +44,7 @@ public class SpecialRenderer {
|
||||||
return (ElementRenderer<T>)(tile == null ? null : this.getRenderer(tile.getClass()));
|
return (ElementRenderer<T>)(tile == null ? null : this.getRenderer(tile.getClass()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPosition(WorldClient world, Entity entity, float partial) {
|
public void setPosition(World world, Entity entity, float partial) {
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.posX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double)partial;
|
this.posX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double)partial;
|
||||||
this.posY = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double)partial;
|
this.posY = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double)partial;
|
||||||
|
|
|
@ -2,7 +2,6 @@ package client.util;
|
||||||
|
|
||||||
import client.Client;
|
import client.Client;
|
||||||
import client.network.ClientPlayer;
|
import client.network.ClientPlayer;
|
||||||
import client.world.WorldClient;
|
|
||||||
import common.block.Block;
|
import common.block.Block;
|
||||||
import common.dimension.Dimension;
|
import common.dimension.Dimension;
|
||||||
import common.dimension.Space;
|
import common.dimension.Space;
|
||||||
|
@ -114,7 +113,7 @@ public class PlayerController {
|
||||||
this.stack = this.gm.player.getHeldItem();
|
this.stack = this.gm.player.getHeldItem();
|
||||||
this.damage = 0.0F;
|
this.damage = 0.0F;
|
||||||
this.stepCounter = 0.0F;
|
this.stepCounter = 0.0F;
|
||||||
this.gm.world.sendBlockBreakProgress(this.gm.player.getId(), this.position, (int)(this.damage * 10.0F) - 1);
|
this.gm.renderGlobal.sendBlockBreakProgress(this.gm.player.getId(), this.position, (int)(this.damage * 10.0F) - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +126,7 @@ public class PlayerController {
|
||||||
this.handler.addToSendQueue(new CPacketBreak(CPacketBreak.Action.ABORT_DESTROY_BLOCK, this.position, Facing.DOWN));
|
this.handler.addToSendQueue(new CPacketBreak(CPacketBreak.Action.ABORT_DESTROY_BLOCK, this.position, Facing.DOWN));
|
||||||
this.hitting = false;
|
this.hitting = false;
|
||||||
this.damage = 0.0F;
|
this.damage = 0.0F;
|
||||||
this.gm.world.sendBlockBreakProgress(this.gm.player.getId(), this.position, -1);
|
this.gm.renderGlobal.sendBlockBreakProgress(this.gm.player.getId(), this.position, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +169,7 @@ public class PlayerController {
|
||||||
this.delay = 5;
|
this.delay = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.gm.world.sendBlockBreakProgress(this.gm.player.getId(), this.position, (int)(this.damage * 10.0F) - 1);
|
this.gm.renderGlobal.sendBlockBreakProgress(this.gm.player.getId(), this.position, (int)(this.damage * 10.0F) - 1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -213,7 +212,7 @@ public class PlayerController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean clickRight(EntityNPC player, WorldClient world, ItemStack stack, BlockPos pos, Facing side, Vec3 hit) {
|
public boolean clickRight(EntityNPC player, World world, ItemStack stack, BlockPos pos, Facing side, Vec3 hit) {
|
||||||
this.syncItem();
|
this.syncItem();
|
||||||
float f = (float)(hit.xCoord - (double)pos.getX());
|
float f = (float)(hit.xCoord - (double)pos.getX());
|
||||||
float f1 = (float)(hit.yCoord - (double)pos.getY());
|
float f1 = (float)(hit.yCoord - (double)pos.getY());
|
||||||
|
@ -279,7 +278,7 @@ public class PlayerController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityNPC createPlayerEntity(WorldClient world, int type) {
|
public EntityNPC createPlayerEntity(World world, int type) {
|
||||||
EntityNPC player = (EntityNPC)EntityRegistry.createEntityByID(type, world);
|
EntityNPC player = (EntityNPC)EntityRegistry.createEntityByID(type, world);
|
||||||
player.setClientPlayer(this.handler);
|
player.setClientPlayer(this.handler);
|
||||||
if(!this.gm.charEditor && this.gm.selectedCharacter >= 0 && this.gm.selectedCharacter < this.gm.characterList.size()) {
|
if(!this.gm.charEditor && this.gm.selectedCharacter >= 0 && this.gm.selectedCharacter < this.gm.characterList.size()) {
|
||||||
|
|
|
@ -15,6 +15,7 @@ import common.util.BoundingBox;
|
||||||
import common.util.ExtMath;
|
import common.util.ExtMath;
|
||||||
import common.world.LightType;
|
import common.world.LightType;
|
||||||
import common.world.State;
|
import common.world.State;
|
||||||
|
import common.world.World;
|
||||||
|
|
||||||
public class ChunkEmpty extends ChunkClient {
|
public class ChunkEmpty extends ChunkClient {
|
||||||
private static final List<State> STATES = Lists.<State>newArrayList();
|
private static final List<State> STATES = Lists.<State>newArrayList();
|
||||||
|
@ -54,7 +55,7 @@ public class ChunkEmpty extends ChunkClient {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChunkEmpty(WorldClient world, boolean out, boolean debug) {
|
public ChunkEmpty(World world, boolean out, boolean debug) {
|
||||||
super(world, out ? Integer.MAX_VALUE : 0, 0);
|
super(world, out ? Integer.MAX_VALUE : 0, 0);
|
||||||
this.debug = debug;
|
this.debug = debug;
|
||||||
this.liquidY = world.dimension.getSeaLevel() - 1;
|
this.liquidY = world.dimension.getSeaLevel() - 1;
|
||||||
|
|
|
@ -1,930 +0,0 @@
|
||||||
package client.world;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import client.Client;
|
|
||||||
import common.collect.Lists;
|
|
||||||
import common.collect.Sets;
|
|
||||||
import common.dimension.Dimension;
|
|
||||||
import common.entity.Entity;
|
|
||||||
import common.entity.item.EntityCart;
|
|
||||||
import common.entity.npc.EntityNPC;
|
|
||||||
import common.init.BlockRegistry;
|
|
||||||
import common.init.Blocks;
|
|
||||||
import common.init.ItemRegistry;
|
|
||||||
import common.init.Items;
|
|
||||||
import common.init.SoundEvent;
|
|
||||||
import common.item.material.ItemDye;
|
|
||||||
import common.log.Log;
|
|
||||||
import common.rng.Random;
|
|
||||||
import common.sound.MovingSoundMinecart;
|
|
||||||
import common.sound.PositionedSound;
|
|
||||||
import common.tileentity.TileEntity;
|
|
||||||
import common.tileentity.TileEntityChest;
|
|
||||||
import common.util.BlockPos;
|
|
||||||
import common.util.ChunkPos;
|
|
||||||
import common.util.ExtMath;
|
|
||||||
import common.util.LongHashMap;
|
|
||||||
import common.util.ParticleType;
|
|
||||||
import common.util.Vec3;
|
|
||||||
import common.vars.Vars;
|
|
||||||
import common.util.BlockPos.MutableBlockPos;
|
|
||||||
import common.world.AWorldClient;
|
|
||||||
import common.world.State;
|
|
||||||
import common.world.World;
|
|
||||||
|
|
||||||
public class WorldClient extends AWorldClient
|
|
||||||
{
|
|
||||||
private static final int DISPLAY_RANGE = 16;
|
|
||||||
|
|
||||||
private final Client gm;
|
|
||||||
private final Set<Entity> entityList = Sets.<Entity>newHashSet();
|
|
||||||
private final Set<Entity> spawnQueue = Sets.<Entity>newHashSet();
|
|
||||||
private final Set<ChunkPos> previousActive = Sets.<ChunkPos>newHashSet();
|
|
||||||
private final LongHashMap<ChunkClient> chunkMapping = new LongHashMap();
|
|
||||||
private final List<ChunkClient> chunkListing = Lists.<ChunkClient>newArrayList();
|
|
||||||
private final Set<Long> emptyChunkListing = Sets.<Long>newHashSet();
|
|
||||||
private final Set<Long> nextEmptyChunkListing = Sets.<Long>newHashSet();
|
|
||||||
|
|
||||||
private ChunkClient emptyChunk;
|
|
||||||
private ChunkClient outsideChunk;
|
|
||||||
protected int lastLightning;
|
|
||||||
protected Vec3 lightColor = new Vec3(0xffffff);
|
|
||||||
|
|
||||||
public WorldClient(Client gm, Dimension dim)
|
|
||||||
{
|
|
||||||
super(dim);
|
|
||||||
this.gm = gm;
|
|
||||||
this.emptyChunk = new ChunkEmpty(this, false, this.gm.debugWorld);
|
|
||||||
this.outsideChunk = new ChunkEmpty(this, true, this.gm.debugWorld);
|
|
||||||
this.calculateInitialSkylight();
|
|
||||||
this.calculateInitialWeather();
|
|
||||||
this.updatePhysics();
|
|
||||||
// this.setDifficulty(this.gm.difficulty);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ChunkClient getEmptyChunk(int x, int z) {
|
|
||||||
int size = this.dimension.getSize() / 16;
|
|
||||||
return x < -size || z < -size || x >= size || z >= size ? this.outsideChunk : this.emptyChunk;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void markReload(int cx, int cz, int range) {
|
|
||||||
this.nextEmptyChunkListing.clear();
|
|
||||||
for(int x = cx - range; x <= cx + range; x++) {
|
|
||||||
for(int z = cz - range; z <= cz + range; z++) {
|
|
||||||
long id = LongHashMap.packInt(x, z);
|
|
||||||
if(this.chunkMapping.getValueByKey(id) != null) {
|
|
||||||
if(this.emptyChunkListing.contains(id)) {
|
|
||||||
this.emptyChunkListing.remove(id);
|
|
||||||
this.nextEmptyChunkListing.add(id);
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
this.chunkMapping.add(id, this.getEmptyChunk(x, z));
|
|
||||||
this.emptyChunkListing.remove(id);
|
|
||||||
this.nextEmptyChunkListing.add(id);
|
|
||||||
this.markBlockRangeForRenderUpdate(x << 4, -World.MAX_SIZE_Y, z << 4, (x << 4) + 15, World.MAX_SIZE_Y, (z << 4) + 15);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for(Long id : this.emptyChunkListing) {
|
|
||||||
this.chunkMapping.remove(id);
|
|
||||||
int x = LongHashMap.getX(id);
|
|
||||||
int z = LongHashMap.getZ(id);
|
|
||||||
this.markBlockRangeForRenderUpdate(x << 4, -World.MAX_SIZE_Y, z << 4, (x << 4) + 15, World.MAX_SIZE_Y, (z << 4) + 15);
|
|
||||||
}
|
|
||||||
this.emptyChunkListing.clear();
|
|
||||||
this.emptyChunkListing.addAll(this.nextEmptyChunkListing);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void markReload() {
|
|
||||||
if(this.gm.player != null && !this.gm.charEditor)
|
|
||||||
this.markReload((int)this.gm.player.posX >> 4, (int)this.gm.player.posZ >> 4, this.gm.renderDistance + 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setExterminated(boolean exterminated) {
|
|
||||||
this.dimension.setExterminated(exterminated);
|
|
||||||
this.emptyChunk = new ChunkEmpty(this, false, this.gm.debugWorld);
|
|
||||||
this.outsideChunk = new ChunkEmpty(this, true, this.gm.debugWorld);
|
|
||||||
this.markReload();
|
|
||||||
for(Long id : this.emptyChunkListing) {
|
|
||||||
int x = LongHashMap.getX(id);
|
|
||||||
int z = LongHashMap.getZ(id);
|
|
||||||
this.chunkMapping.add(id, this.getEmptyChunk(x, z));
|
|
||||||
this.markBlockRangeForRenderUpdate(x << 4, -World.MAX_SIZE_Y, z << 4, (x << 4) + 15, World.MAX_SIZE_Y, (z << 4) + 15);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void tick()
|
|
||||||
{
|
|
||||||
this.updatePhysics();
|
|
||||||
this.markReload();
|
|
||||||
// this.info.tick();
|
|
||||||
|
|
||||||
if (Vars.dayCycle)
|
|
||||||
{
|
|
||||||
this.daytime += Vars.timeFlow;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < 10 && !this.spawnQueue.isEmpty(); ++i)
|
|
||||||
{
|
|
||||||
Entity entity = (Entity)this.spawnQueue.iterator().next();
|
|
||||||
this.spawnQueue.remove(entity);
|
|
||||||
|
|
||||||
if (!this.entities.contains(entity))
|
|
||||||
{
|
|
||||||
this.spawnEntityInWorld(entity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
long time = System.currentTimeMillis();
|
|
||||||
for (ChunkClient chunk : this.chunkListing)
|
|
||||||
{
|
|
||||||
chunk.update(System.currentTimeMillis() - time > 5L);
|
|
||||||
}
|
|
||||||
if (System.currentTimeMillis() - time > 100L)
|
|
||||||
{
|
|
||||||
Log.TICK.warn("Render-Chunk-Tick dauerte " + (System.currentTimeMillis() - time) + " ms");
|
|
||||||
}
|
|
||||||
this.updateBlocks();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void updateBlocks()
|
|
||||||
{
|
|
||||||
this.setActivePlayerChunksAndCheckLight(this.gm.renderDistance);
|
|
||||||
this.previousActive.retainAll(this.active);
|
|
||||||
|
|
||||||
if (this.previousActive.size() == this.active.size())
|
|
||||||
{
|
|
||||||
this.previousActive.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
for (ChunkPos chunkcoordintpair : this.active)
|
|
||||||
{
|
|
||||||
if (!this.previousActive.contains(chunkcoordintpair))
|
|
||||||
{
|
|
||||||
int j = chunkcoordintpair.x * 16;
|
|
||||||
int k = chunkcoordintpair.z * 16;
|
|
||||||
ChunkClient chunk = this.getChunk(chunkcoordintpair.x, chunkcoordintpair.z);
|
|
||||||
chunk.enqueueRelight();
|
|
||||||
this.previousActive.add(chunkcoordintpair);
|
|
||||||
++i;
|
|
||||||
|
|
||||||
if (i >= 10)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void doPreChunk(int x, int z, boolean load)
|
|
||||||
{
|
|
||||||
long id = LongHashMap.packInt(x, z);
|
|
||||||
if (load)
|
|
||||||
{
|
|
||||||
if(this.chunkMapping.getValueByKey(id) != null)
|
|
||||||
this.doPreChunk(x, z, false);
|
|
||||||
ChunkClient chunk = new ChunkClient(this, x, z);
|
|
||||||
this.chunkMapping.add(id, chunk);
|
|
||||||
this.chunkListing.add(chunk);
|
|
||||||
chunk.setLoaded();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ChunkClient chunk = this.getChunk(x, z);
|
|
||||||
chunk.onChunkUnload();
|
|
||||||
this.chunkMapping.remove(id);
|
|
||||||
this.chunkListing.remove(chunk);
|
|
||||||
this.emptyChunkListing.remove(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!load)
|
|
||||||
{
|
|
||||||
this.markBlockRangeForRenderUpdate(x * 16, -World.MAX_SIZE_Y, z * 16, x * 16 + 15, World.MAX_SIZE_Y, z * 16 + 15);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean spawnEntityInWorld(Entity entityIn)
|
|
||||||
{
|
|
||||||
boolean flag = super.spawnEntityInWorld(entityIn);
|
|
||||||
this.entityList.add(entityIn);
|
|
||||||
|
|
||||||
if (!flag)
|
|
||||||
{
|
|
||||||
this.spawnQueue.add(entityIn);
|
|
||||||
}
|
|
||||||
else if (entityIn instanceof EntityCart)
|
|
||||||
{
|
|
||||||
this.gm.getSoundManager().playSound(new MovingSoundMinecart((EntityCart)entityIn));
|
|
||||||
}
|
|
||||||
|
|
||||||
return flag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeEntity(Entity entityIn)
|
|
||||||
{
|
|
||||||
super.removeEntity(entityIn);
|
|
||||||
this.entityList.remove(entityIn);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void onEntityAdded(Entity entityIn)
|
|
||||||
{
|
|
||||||
if (this.spawnQueue.contains(entityIn))
|
|
||||||
{
|
|
||||||
this.spawnQueue.remove(entityIn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void onEntityRemoved(Entity entityIn)
|
|
||||||
{
|
|
||||||
boolean flag = false;
|
|
||||||
|
|
||||||
if (this.entityList.contains(entityIn))
|
|
||||||
{
|
|
||||||
if (entityIn.isEntityAlive())
|
|
||||||
{
|
|
||||||
this.spawnQueue.add(entityIn);
|
|
||||||
flag = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.entityList.remove(entityIn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addEntityToWorld(int entityID, Entity entityToSpawn)
|
|
||||||
{
|
|
||||||
Entity entity = this.getEntityByID(entityID);
|
|
||||||
|
|
||||||
if (entity != null)
|
|
||||||
{
|
|
||||||
this.removeEntity(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.entityList.add(entityToSpawn);
|
|
||||||
entityToSpawn.setId(entityID);
|
|
||||||
|
|
||||||
if (!this.spawnEntityInWorld(entityToSpawn))
|
|
||||||
{
|
|
||||||
this.spawnQueue.add(entityToSpawn);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.entityIds.addKey(entityID, entityToSpawn);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Entity getEntityByID(int id)
|
|
||||||
{
|
|
||||||
return (Entity)(id == this.gm.player.getId() ? this.gm.player : super.getEntityByID(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Entity removeEntityFromWorld(int entityID)
|
|
||||||
{
|
|
||||||
Entity entity = (Entity)this.entityIds.removeObject(entityID);
|
|
||||||
|
|
||||||
if (entity != null)
|
|
||||||
{
|
|
||||||
this.entityList.remove(entity);
|
|
||||||
this.removeEntity(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
return entity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean invalidateRegionAndSetBlock(BlockPos pos, State state)
|
|
||||||
{
|
|
||||||
return super.setState(pos, state, 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
// public boolean canShowVoidParticles() {
|
|
||||||
// return this.gm.voidParticles; // && this.dimension.getType().voidPortal;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public void displayTick(int posX, int posY, int posZ) {
|
|
||||||
Random rand = new Random();
|
|
||||||
BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos();
|
|
||||||
for(int n = 0; n < 1000; n++) {
|
|
||||||
int x = posX + rand.zrange(DISPLAY_RANGE) - rand.zrange(DISPLAY_RANGE);
|
|
||||||
int y = posY + rand.zrange(DISPLAY_RANGE) - rand.zrange(DISPLAY_RANGE);
|
|
||||||
int z = posZ + rand.zrange(DISPLAY_RANGE) - rand.zrange(DISPLAY_RANGE);
|
|
||||||
pos.set(x, y, z);
|
|
||||||
State state = this.getState(pos);
|
|
||||||
state.getBlock().displayTick(this, pos, state, rand);
|
|
||||||
}
|
|
||||||
if(this.dimension.hasVoidFog() && this.gm.voidParticles && posY < 32) {
|
|
||||||
for(int n = 0; n < 1000; n++) {
|
|
||||||
float x = ((float)posX) + (rand.floatv() - rand.floatv() - 0.5f) * 32.0f;
|
|
||||||
float y = (posY < -32 ? (float)posY - 32.0f : -64.0f) + rand.floatv() * 65.0f;
|
|
||||||
float z = ((float)posZ) + (rand.floatv() - rand.floatv() - 0.5f) * 32.0f;
|
|
||||||
if(y < -64.0f || rand.floatv() >= (64.0f + y) / 64.0f)
|
|
||||||
this.spawnParticle(ParticleType.DEPTH, (double)x, (double)y, (double)z);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeAllEntities()
|
|
||||||
{
|
|
||||||
this.entities.removeAll(this.unloaded);
|
|
||||||
|
|
||||||
for (int i = 0; i < this.unloaded.size(); ++i)
|
|
||||||
{
|
|
||||||
Entity entity = (Entity)this.unloaded.get(i);
|
|
||||||
int j = entity.chunkCoordX;
|
|
||||||
int k = entity.chunkCoordZ;
|
|
||||||
|
|
||||||
if (entity.addedToChunk && this.isLoaded(j, k, true))
|
|
||||||
{
|
|
||||||
this.getChunk(j, k).removeEntity(entity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int l = 0; l < this.unloaded.size(); ++l)
|
|
||||||
{
|
|
||||||
this.onEntityRemoved((Entity)this.unloaded.get(l));
|
|
||||||
}
|
|
||||||
|
|
||||||
this.unloaded.clear();
|
|
||||||
|
|
||||||
for (int i1 = 0; i1 < this.entities.size(); ++i1)
|
|
||||||
{
|
|
||||||
Entity entity1 = (Entity)this.entities.get(i1);
|
|
||||||
|
|
||||||
if (entity1.vehicle != null)
|
|
||||||
{
|
|
||||||
if (!entity1.vehicle.dead && entity1.vehicle.passenger == entity1)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
entity1.vehicle.passenger = null;
|
|
||||||
entity1.vehicle = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (entity1.dead)
|
|
||||||
{
|
|
||||||
int j1 = entity1.chunkCoordX;
|
|
||||||
int k1 = entity1.chunkCoordZ;
|
|
||||||
|
|
||||||
if (entity1.addedToChunk && this.isLoaded(j1, k1, true))
|
|
||||||
{
|
|
||||||
this.getChunk(j1, k1).removeEntity(entity1);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.entities.remove(i1--);
|
|
||||||
this.onEntityRemoved(entity1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void playSound(double x, double y, double z, SoundEvent sound, float volume)
|
|
||||||
{
|
|
||||||
// if(this.gm.oldStepSounds && (soundName.equals("random.swim") || soundName.equals("step.ladder")))
|
|
||||||
// return;
|
|
||||||
// if(this.gm.oldStepSounds && soundName.startsWith("step."))
|
|
||||||
// soundName = "dig." + soundName.substring(5);
|
|
||||||
// if(this.gm.oldStepSounds && soundName.equals("random.swim_splash"))
|
|
||||||
// soundName = "random.splash";
|
|
||||||
// double d0 = this.gm.getRenderViewEntity().getDistanceSq(x, y, z);
|
|
||||||
PositionedSound positionedsoundrecord = new PositionedSound(sound, volume, /* pitch, */ (float)x, (float)y, (float)z);
|
|
||||||
|
|
||||||
// if (distanceDelay && d0 > 100.0D)
|
|
||||||
// {
|
|
||||||
// double d1 = Math.sqrt(d0) / 40.0D;
|
|
||||||
// this.gm.getSoundHandler().playDelayedSound(positionedsoundrecord, (int)(d1 * 20.0D));
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
this.gm.getSoundManager().playSound(positionedsoundrecord);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChunkClient getChunk(int x, int z)
|
|
||||||
{
|
|
||||||
ChunkClient chunk = this.chunkMapping.getValueByKey(LongHashMap.packInt(x, z));
|
|
||||||
return chunk == null ? this.getEmptyChunk(x, z) : chunk;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChunkClient getChunk(BlockPos pos) {
|
|
||||||
return this.getChunk(pos.getX() >> 4, pos.getZ() >> 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected float getTemperature(BlockPos pos) {
|
|
||||||
if(!this.isBlockLoaded(pos))
|
|
||||||
return 0.0f;
|
|
||||||
ChunkClient chunk = this.getChunk(pos);
|
|
||||||
return pos.getY() > 64 ? chunk.getTemperature(pos) - (chunk.getOffset(pos) + (float)pos.getY() - 64.0F) / 15.0f : chunk.getTemperature(pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean isLoaded(int x, int z, boolean allowEmpty) {
|
|
||||||
return allowEmpty || !this.getChunk(x, z).isDummy();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getInfo()
|
|
||||||
{
|
|
||||||
return "Chunk-Cache: M " + this.chunkMapping.getNumHashElements() + ", L " + this.chunkListing.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void playSound(SoundEvent sound, double x, double y, double z, float volume)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// public void spawnParticle(EnumParticleTypes particleType, boolean force, double xCoord, double yCoord, double zCoord, double xOffset,
|
|
||||||
// double yOffset, double zOffset, int... data) {
|
|
||||||
// this.spawnParticle(particleType.getParticleID(), particleType.getShouldIgnoreRange() | force, xCoord, yCoord, zCoord, xOffset, yOffset,
|
|
||||||
// zOffset, data);
|
|
||||||
// }
|
|
||||||
|
|
||||||
public void spawnParticle(ParticleType particle, double xCoord, double yCoord, double zCoord, int data) {
|
|
||||||
if (this.gm.getRenderViewEntity() != null)
|
|
||||||
{
|
|
||||||
double d0 = this.gm.getRenderViewEntity().posX - xCoord;
|
|
||||||
double d1 = this.gm.getRenderViewEntity().posY - yCoord;
|
|
||||||
double d2 = this.gm.getRenderViewEntity().posZ - zCoord;
|
|
||||||
if(particle.isUnlimited() || d0 * d0 + d1 * d1 + d2 * d2 <= 256.0D)
|
|
||||||
this.gm.effectRenderer.spawnParticle(particle, xCoord, yCoord, zCoord, data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// public void broadcastSound(int soundID, BlockPos pos, int data)
|
|
||||||
// {
|
|
||||||
// switch (soundID)
|
|
||||||
// {
|
|
||||||
//// case 1013:
|
|
||||||
// case 1018:
|
|
||||||
// if (this.gm.getRenderViewEntity() != null)
|
|
||||||
// {
|
|
||||||
// double d0 = (double)pos.getX() - this.gm.getRenderViewEntity().posX;
|
|
||||||
// double d1 = (double)pos.getY() - this.gm.getRenderViewEntity().posY;
|
|
||||||
// double d2 = (double)pos.getZ() - this.gm.getRenderViewEntity().posZ;
|
|
||||||
// double d3 = Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2);
|
|
||||||
// double d4 = this.gm.getRenderViewEntity().posX;
|
|
||||||
// double d5 = this.gm.getRenderViewEntity().posY;
|
|
||||||
// double d6 = this.gm.getRenderViewEntity().posZ;
|
|
||||||
//
|
|
||||||
// if (d3 > 0.0D)
|
|
||||||
// {
|
|
||||||
// d4 += d0 / d3 * 2.0D;
|
|
||||||
// d5 += d1 / d3 * 2.0D;
|
|
||||||
// d6 += d2 / d3 * 2.0D;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//// if (soundID == 1013)
|
|
||||||
//// {
|
|
||||||
//// this.playSound(d4, d5, d6, "mob.wither.spawn", 1.0F, 1.0F);
|
|
||||||
//// }
|
|
||||||
//// else
|
|
||||||
//// {
|
|
||||||
// this.playSound(d4, d5, d6, "mob.dragon.end", 5.0F, 1.0F);
|
|
||||||
//// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// default:
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
private void playSoundAtPos(BlockPos pos, SoundEvent sound, float volume)
|
|
||||||
{
|
|
||||||
this.playSound((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, sound, volume);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void playAuxSFX(EntityNPC player, int sfxType, BlockPos blockPosIn, int data)
|
|
||||||
{
|
|
||||||
switch (sfxType)
|
|
||||||
{
|
|
||||||
case 1000:
|
|
||||||
this.playSoundAtPos(blockPosIn, SoundEvent.CLICK, 1.0F);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1001:
|
|
||||||
this.playSoundAtPos(blockPosIn, SoundEvent.CLICK, 1.0F);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1002:
|
|
||||||
this.playSoundAtPos(blockPosIn, SoundEvent.THROW, 1.0F);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1003:
|
|
||||||
this.playSoundAtPos(blockPosIn, SoundEvent.DOOR, 1.0F);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1004:
|
|
||||||
this.playSoundAtPos(blockPosIn, SoundEvent.FIZZ, 0.5F);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1005:
|
|
||||||
this.playSoundAtPos(blockPosIn, SoundEvent.TELEPORT, 10.0F);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1006:
|
|
||||||
this.playSoundAtPos(blockPosIn, SoundEvent.DOOR, 1.0F);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1007:
|
|
||||||
this.playSoundAtPos(blockPosIn, SoundEvent.SPELL, 10.0F);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1008:
|
|
||||||
this.playSoundAtPos(blockPosIn, SoundEvent.FIREBALL, 10.0F);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1009:
|
|
||||||
this.playSoundAtPos(blockPosIn, SoundEvent.FIREBALL, 2.0F);
|
|
||||||
break;
|
|
||||||
|
|
||||||
// case 1010:
|
|
||||||
// this.playSoundAtPos(blockPosIn, "dig.wood", 0.6F, (random.floatv() - random.floatv()) * 0.2F + 1.0F);
|
|
||||||
// break;
|
|
||||||
|
|
||||||
// case 1011:
|
|
||||||
// this.playSoundAtPos(blockPosIn, "random.metal", 2.0F, (random.floatv() - random.floatv()) * 0.2F + 1.0F);
|
|
||||||
// break;
|
|
||||||
|
|
||||||
// case 1012:
|
|
||||||
// this.playSoundAtPos(blockPosIn, "dig.wood", 2.0F, (random.floatv() - random.floatv()) * 0.2F + 1.0F);
|
|
||||||
// break;
|
|
||||||
|
|
||||||
case 1013:
|
|
||||||
this.playSoundAtPos(blockPosIn, SoundEvent.TELEPORT_REV, 0.5F);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1014:
|
|
||||||
this.playSoundAtPos(blockPosIn, SoundEvent.METAL, 2.0F);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1015:
|
|
||||||
this.playSoundAtPos(blockPosIn, SoundEvent.BAT_TAKEOFF, 0.05F);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1016:
|
|
||||||
this.playSoundAtPos(blockPosIn, SoundEvent.FIREBALL, 2.0F);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1017:
|
|
||||||
this.playSoundAtPos(blockPosIn, SoundEvent.EXPLODE, 20.0f);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1020:
|
|
||||||
this.playSoundAtPos(blockPosIn, SoundEvent.ANVIL_BREAK, 1.0F);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1021:
|
|
||||||
this.playSoundAtPos(blockPosIn, SoundEvent.ANVIL_USE, 1.0F);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1022:
|
|
||||||
this.playSoundAtPos(blockPosIn, SoundEvent.ANVIL_LAND, 0.3F);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1023:
|
|
||||||
// double d131 = (double)blockPosIn.getX();
|
|
||||||
// double d141 = (double)blockPosIn.getY();
|
|
||||||
// double d161 = (double)blockPosIn.getZ();
|
|
||||||
// for (int i1 = 0; i1 < 8; ++i1) {
|
|
||||||
// this.spawnEntityFX(EnumParticleTypes.ITEM_CRACK, EnumParticleTypes.ITEM_CRACK.getShouldIgnoreRange(),
|
|
||||||
// d131, d141, d161, random.gaussian() * 0.15D, random.doublev() * 0.2D, random.gaussian() * 0.15D,
|
|
||||||
// new int[] {ItemRegistry.getIdFromItem(Items.glass), 0});
|
|
||||||
// }
|
|
||||||
this.playSoundAtPos(blockPosIn, SoundEvent.GLASS, 1.0F);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1024:
|
|
||||||
this.playSoundAtPos(blockPosIn, SoundEvent.CLICK, 1.0F);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1025:
|
|
||||||
MutableBlockPos pos = new MutableBlockPos(blockPosIn.getX(), blockPosIn.getY(), blockPosIn.getZ());
|
|
||||||
for(int z = 0; z < 1000; z++) {
|
|
||||||
this.spawnParticle(ParticleType.EXPLOSION_HUGE,
|
|
||||||
(double)pos.getX() + this.rand.gaussian() * 128.0, (double)pos.getY() + this.rand.gaussian() * 2.0, (double)pos.getZ() + this.rand.gaussian() * 128.0);
|
|
||||||
}
|
|
||||||
for(int z = 0; z < 1000; z++) {
|
|
||||||
this.spawnParticle(ParticleType.EXPLOSION_NORMAL,
|
|
||||||
(double)pos.getX() + this.rand.gaussian() * 128.0, (double)pos.getY() + this.rand.gaussian() * 2.0, (double)pos.getZ() + this.rand.gaussian() * 128.0, 100);
|
|
||||||
}
|
|
||||||
for(int z = 0; z < 30; z++) {
|
|
||||||
this.playSoundAtPos(pos.set(blockPosIn.getX() + this.rand.range(-128, 128),
|
|
||||||
blockPosIn.getY() + this.rand.range(-4, 4), blockPosIn.getZ() + this.rand.range(-128, 128)),
|
|
||||||
SoundEvent.EXPLODE, 30.0F);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2000:
|
|
||||||
int l = data % 3 - 1;
|
|
||||||
int i = data / 3 % 3 - 1;
|
|
||||||
double d15 = (double)blockPosIn.getX() + (double)l * 0.6D + 0.5D;
|
|
||||||
double d17 = (double)blockPosIn.getY() + 0.5D;
|
|
||||||
double d19 = (double)blockPosIn.getZ() + (double)i * 0.6D + 0.5D;
|
|
||||||
|
|
||||||
for (int k1 = 0; k1 < 10; ++k1)
|
|
||||||
{
|
|
||||||
double d20 = this.rand.doublev() * 0.2D + 0.01D;
|
|
||||||
double d21 = d15 + (double)l * 0.01D + (this.rand.doublev() - 0.5D) * (double)i * 0.5D;
|
|
||||||
double d4 = d17 + (this.rand.doublev() - 0.5D) * 0.5D;
|
|
||||||
double d6 = d19 + (double)i * 0.01D + (this.rand.doublev() - 0.5D) * (double)l * 0.5D;
|
|
||||||
this.spawnParticle(ParticleType.SMOKE, d21, d4, d6);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
|
|
||||||
case 2001:
|
|
||||||
State state = BlockRegistry.byId(data);
|
|
||||||
|
|
||||||
if (state != null && state.getBlock() != Blocks.air)
|
|
||||||
{
|
|
||||||
this.gm.getSoundManager().playSound(new PositionedSound(state.getBlock().getSound().getBreakSound(), 1.0F, /* block.sound.getFrequency() * 0.8F, */ (float)blockPosIn.getX() + 0.5F, (float)blockPosIn.getY() + 0.5F, (float)blockPosIn.getZ() + 0.5F));
|
|
||||||
}
|
|
||||||
if(state != null)
|
|
||||||
this.gm.effectRenderer.destroyBlock(blockPosIn, state);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2002:
|
|
||||||
double d13 = (double)blockPosIn.getX();
|
|
||||||
double d14 = (double)blockPosIn.getY();
|
|
||||||
double d16 = (double)blockPosIn.getZ();
|
|
||||||
|
|
||||||
for (int i1 = 0; i1 < 8; ++i1)
|
|
||||||
{
|
|
||||||
this.spawnParticle(ParticleType.ITEM_CRACK, d13, d14, d16, ItemRegistry.getId(Items.water_bottle));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int l1 = 0; l1 < 100; ++l1)
|
|
||||||
{
|
|
||||||
this.spawnParticle(ParticleType.POTION, d13, d14, d16, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.playSoundAtPos(blockPosIn, SoundEvent.GLASS, 1.0F);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2005:
|
|
||||||
ItemDye.spawnBonemealParticles(this, blockPosIn, data);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2016:
|
|
||||||
TileEntity te = this.getTileEntity(blockPosIn);
|
|
||||||
if(te instanceof TileEntityChest chest) {
|
|
||||||
chest.setUsing(data);
|
|
||||||
this.markBlockForUpdate(blockPosIn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void markBlockForUpdate(BlockPos pos)
|
|
||||||
{
|
|
||||||
int i = pos.getX();
|
|
||||||
int j = pos.getY();
|
|
||||||
int k = pos.getZ();
|
|
||||||
this.gm.renderGlobal.markBlocksForUpdate(i - 1, j - 1, k - 1, i + 1, j + 1, k + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void notifyLightSet(BlockPos pos)
|
|
||||||
{
|
|
||||||
int i = pos.getX();
|
|
||||||
int j = pos.getY();
|
|
||||||
int k = pos.getZ();
|
|
||||||
this.gm.renderGlobal.markBlocksForUpdate(i - 1, j - 1, k - 1, i + 1, j + 1, k + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void markBlockRangeForRenderUpdate(int x1, int y1, int z1, int x2, int y2, int z2)
|
|
||||||
{
|
|
||||||
this.gm.renderGlobal.markBlocksForUpdate(x1 - 1, y1 - 1, z1 - 1, x2 + 1, y2 + 1, z2 + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendBlockBreakProgress(int breakerId, BlockPos pos, int progress)
|
|
||||||
{
|
|
||||||
this.gm.renderGlobal.sendBlockBreakProgress(breakerId, pos, progress);
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getSunBrightness(float p_72971_1_) {
|
|
||||||
float f = this.getDayPhase(p_72971_1_);
|
|
||||||
float f1 = 1.0F - (ExtMath.cos(f) * 2.0F + 0.2F);
|
|
||||||
f1 = ExtMath.clampf(f1, 0.0F, 1.0F);
|
|
||||||
f1 = 1.0F - f1;
|
|
||||||
f1 = (float)((double)f1 * (1.0D - (double)(this.getRainStrength() * 5.0F) / 16.0D));
|
|
||||||
f1 = (float)((double)f1 * (1.0D - (double)(this.getDarkness() * 5.0F) / 16.0D));
|
|
||||||
return Math.max(f1 * 0.8F + 0.2F, this.getSpaceFactor());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int hsvToRGB(float hue, float saturation, float value)
|
|
||||||
{
|
|
||||||
int i = (int)(hue * 6.0F) % 6;
|
|
||||||
float f = hue * 6.0F - (float)i;
|
|
||||||
float f1 = value * (1.0F - saturation);
|
|
||||||
float f2 = value * (1.0F - f * saturation);
|
|
||||||
float f3 = value * (1.0F - (1.0F - f) * saturation);
|
|
||||||
float f4;
|
|
||||||
float f5;
|
|
||||||
float f6;
|
|
||||||
|
|
||||||
switch (i)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
f4 = value;
|
|
||||||
f5 = f3;
|
|
||||||
f6 = f1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
f4 = f2;
|
|
||||||
f5 = value;
|
|
||||||
f6 = f1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
f4 = f1;
|
|
||||||
f5 = value;
|
|
||||||
f6 = f3;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
f4 = f1;
|
|
||||||
f5 = f2;
|
|
||||||
f6 = value;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 4:
|
|
||||||
f4 = f3;
|
|
||||||
f5 = f1;
|
|
||||||
f6 = value;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 5:
|
|
||||||
f4 = value;
|
|
||||||
f5 = f1;
|
|
||||||
f6 = f2;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new RuntimeException("Something went wrong when converting from HSV to RGB. Input was " + hue + ", " + saturation + ", " + value);
|
|
||||||
}
|
|
||||||
|
|
||||||
int j = ExtMath.clampi((int)(f4 * 255.0F), 0, 255);
|
|
||||||
int k = ExtMath.clampi((int)(f5 * 255.0F), 0, 255);
|
|
||||||
int l = ExtMath.clampi((int)(f6 * 255.0F), 0, 255);
|
|
||||||
return j << 16 | k << 8 | l;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vec3 getSkyColor(Entity entity, float partial) {
|
|
||||||
BlockPos pos = new BlockPos(ExtMath.floord(entity.posX), ExtMath.floord(entity.posY),
|
|
||||||
ExtMath.floord(entity.posZ));
|
|
||||||
Vec3 vec;
|
|
||||||
if(this.dimension.isExterminated())
|
|
||||||
vec = new Vec3(0x101010);
|
|
||||||
else
|
|
||||||
vec = new Vec3(this.dimension.getSkyColor());
|
|
||||||
if(this.dimension.hasDaylight()) {
|
|
||||||
float mult = ExtMath.clampf(ExtMath.cos(this.getDayPhase(partial)) * 2.0F + 0.5F, 0.0F, 1.0F);
|
|
||||||
vec = new Vec3(vec.xCoord * mult, vec.yCoord * mult, vec.zCoord * mult);
|
|
||||||
}
|
|
||||||
float r = (float)vec.xCoord;
|
|
||||||
float g = (float)vec.yCoord;
|
|
||||||
float b = (float)vec.zCoord;
|
|
||||||
|
|
||||||
float rain = this.getRainStrength();
|
|
||||||
if(rain > 0.0F) {
|
|
||||||
float mul = (r * 0.3F + g * 0.59F + b * 0.11F) * 0.6F;
|
|
||||||
float shift = 1.0F - rain * 0.75F;
|
|
||||||
r = r * shift + mul * (1.0F - shift);
|
|
||||||
g = g * shift + mul * (1.0F - shift);
|
|
||||||
b = b * shift + mul * (1.0F - shift);
|
|
||||||
}
|
|
||||||
|
|
||||||
float dark = this.getDarkness();
|
|
||||||
if(dark > 0.0F) {
|
|
||||||
float mul = (r * 0.3F + g * 0.59F + b * 0.11F) * 0.2F;
|
|
||||||
float shift = 1.0F - dark * 0.75F;
|
|
||||||
r = r * shift + mul * (1.0F - shift);
|
|
||||||
g = g * shift + mul * (1.0F - shift);
|
|
||||||
b = b * shift + mul * (1.0F - shift);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this.lastLightning > 0) {
|
|
||||||
float light = (float)this.lastLightning - partial;
|
|
||||||
if(light > 1.0F)
|
|
||||||
light = 1.0F;
|
|
||||||
// light = light * 0.45F;
|
|
||||||
r = r * (1.0F - light) + (float)this.lightColor.xCoord * light;
|
|
||||||
g = g * (1.0F - light) + (float)this.lightColor.yCoord * light;
|
|
||||||
b = b * (1.0F - light) + (float)this.lightColor.zCoord * light;
|
|
||||||
}
|
|
||||||
|
|
||||||
float space = this.getSpaceFactor();
|
|
||||||
if(space > 0.0f) {
|
|
||||||
r = r * (1.0F - space);
|
|
||||||
g = g * (1.0F - space);
|
|
||||||
b = b * (1.0F - space);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Vec3((double)r, (double)g, (double)b);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vec3 getCloudColour(Entity entity, float partialTicks) {
|
|
||||||
Vec3 color = new Vec3(this.dimension.getCloudColor());
|
|
||||||
if(this.dimension.isExterminated())
|
|
||||||
color = new Vec3(0x000000);
|
|
||||||
float r = (float)color.xCoord;
|
|
||||||
float g = (float)color.yCoord;
|
|
||||||
float b = (float)color.zCoord;
|
|
||||||
|
|
||||||
float rain = this.getRainStrength();
|
|
||||||
if(rain > 0.0F) {
|
|
||||||
float mul = (r * 0.3F + g * 0.59F + b * 0.11F) * 0.6F;
|
|
||||||
float shift = 1.0F - rain * 0.95F;
|
|
||||||
r = r * shift + mul * (1.0F - shift);
|
|
||||||
g = g * shift + mul * (1.0F - shift);
|
|
||||||
b = b * shift + mul * (1.0F - shift);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this.dimension.hasDaylight()) {
|
|
||||||
float sun = ExtMath.clampf(ExtMath.cos(this.getDayPhase(partialTicks)) * 2.0F + 0.5F,
|
|
||||||
0.0F, 1.0F);
|
|
||||||
r = r * (sun * 0.9F + 0.1F);
|
|
||||||
g = g * (sun * 0.9F + 0.1F);
|
|
||||||
b = b * (sun * 0.85F + 0.15F);
|
|
||||||
}
|
|
||||||
|
|
||||||
float dark = this.getDarkness();
|
|
||||||
if(dark > 0.0F) {
|
|
||||||
float mul = (r * 0.3F + g * 0.59F + b * 0.11F) * 0.2F;
|
|
||||||
float shift = 1.0F - dark * 0.95F;
|
|
||||||
r = r * shift + mul * (1.0F - shift);
|
|
||||||
g = g * shift + mul * (1.0F - shift);
|
|
||||||
b = b * shift + mul * (1.0F - shift);
|
|
||||||
}
|
|
||||||
|
|
||||||
float space = this.getSpaceFactor();
|
|
||||||
if(space > 0.0f) {
|
|
||||||
r = r * (1.0F - space);
|
|
||||||
g = g * (1.0F - space);
|
|
||||||
b = b * (1.0F - space);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Vec3((double)r, (double)g, (double)b);
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getStarBrightness(float partialTicks) {
|
|
||||||
float f = this.getDayPhase(partialTicks);
|
|
||||||
float f1 = 1.0F - (ExtMath.cos(f) * 2.0F + 0.25F);
|
|
||||||
f1 = ExtMath.clampf(f1, 0.0F, 1.0F);
|
|
||||||
return Math.max(f1 * f1 * this.dimension.getStarBrightness(), this.getSpaceFactor());
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getDeepStarBrightness(float partialTicks) {
|
|
||||||
float f = this.getDayPhase(partialTicks);
|
|
||||||
float f1 = 1.0F - (ExtMath.cos(f) * 2.0F + 0.25F);
|
|
||||||
f1 = ExtMath.clampf(f1, 0.0F, 1.0F);
|
|
||||||
return Math.max(f1 * f1 * this.dimension.getDeepStarBrightness(), this.getSpaceFactor());
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getSpaceFactor() {
|
|
||||||
Entity entity = this.gm.getRenderViewEntity();
|
|
||||||
return entity == null ? 0.0f : (float)this.getSpaceFactor(entity.posX, entity.posY, entity.posZ);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLastLightning() {
|
|
||||||
return this.lastLightning;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vec3 getLightColor() {
|
|
||||||
return this.lightColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void decrLightning() {
|
|
||||||
if(this.lastLightning > 0)
|
|
||||||
this.lastLightning -= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLastLightning(int last, int color) {
|
|
||||||
this.lastLightning = last;
|
|
||||||
this.lightColor = new Vec3(color);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ensureAreaLoaded(Entity entityIn) {
|
|
||||||
int i = ExtMath.floord(entityIn.posX / 16.0D);
|
|
||||||
int j = ExtMath.floord(entityIn.posZ / 16.0D);
|
|
||||||
int k = 2;
|
|
||||||
|
|
||||||
for(int l = i - k; l <= i + k; ++l) {
|
|
||||||
for(int i1 = j - k; i1 <= j + k; ++i1) {
|
|
||||||
this.getChunk(l, i1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!this.entities.contains(entityIn)) {
|
|
||||||
this.entities.add(entityIn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Entity> getLoadedEntityList() {
|
|
||||||
return this.entities;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<TileEntity> getLoadedTileList() {
|
|
||||||
return this.tiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDebugLoadedEntities() {
|
|
||||||
return "" + this.entities.size();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -54,7 +54,6 @@ import common.vars.Vars;
|
||||||
import common.world.Explosion;
|
import common.world.Explosion;
|
||||||
import common.world.IBlockAccess;
|
import common.world.IBlockAccess;
|
||||||
import common.world.IWorldAccess;
|
import common.world.IWorldAccess;
|
||||||
import common.world.AWorldClient;
|
|
||||||
import common.world.State;
|
import common.world.State;
|
||||||
import common.world.World;
|
import common.world.World;
|
||||||
import common.world.AWorldServer;
|
import common.world.AWorldServer;
|
||||||
|
@ -845,7 +844,7 @@ public class Block {
|
||||||
public void tick(AWorldServer world, BlockPos pos, State state, Random rand) {
|
public void tick(AWorldServer world, BlockPos pos, State state, Random rand) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayTick(AWorldClient world, BlockPos pos, State state, Random rand) {
|
public void displayTick(World world, BlockPos pos, State state, Random rand) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onStartBreak(World world, BlockPos pos, EntityNPC player) {
|
public void onStartBreak(World world, BlockPos pos, EntityNPC player) {
|
||||||
|
@ -896,7 +895,7 @@ public class Block {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onUpdate(World world, BlockPos pos, State state, Block neighbor) {
|
public void onUpdate(AWorldServer world, BlockPos pos, State state, Block neighbor) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onAdded(AWorldServer world, BlockPos pos, State state) {
|
public void onAdded(AWorldServer world, BlockPos pos, State state) {
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class BlockFalling extends Block {
|
||||||
world.scheduleUpdate(pos, this, this.tickRate(world, pos));
|
world.scheduleUpdate(pos, this, this.tickRate(world, pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onUpdate(World world, BlockPos pos, State state, Block neighbor) {
|
public void onUpdate(AWorldServer world, BlockPos pos, State state, Block neighbor) {
|
||||||
world.scheduleUpdate(pos, this, this.tickRate(world, pos));
|
world.scheduleUpdate(pos, this, this.tickRate(world, pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ import common.util.ExtMath;
|
||||||
import common.util.Facing;
|
import common.util.Facing;
|
||||||
import common.util.Identifyable;
|
import common.util.Identifyable;
|
||||||
import common.util.WorldPos;
|
import common.util.WorldPos;
|
||||||
|
import common.world.AWorldServer;
|
||||||
import common.world.IWorldAccess;
|
import common.world.IWorldAccess;
|
||||||
import common.world.State;
|
import common.world.State;
|
||||||
import common.world.World;
|
import common.world.World;
|
||||||
|
@ -102,7 +103,7 @@ public class BlockBed extends Block implements Rotatable {
|
||||||
this.setBedBounds();
|
this.setBedBounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onUpdate(World worldIn, BlockPos pos, State state, Block neighborBlock) {
|
public void onUpdate(AWorldServer worldIn, BlockPos pos, State state, Block neighborBlock) {
|
||||||
Facing enumfacing = (Facing)state.getValue(FACING);
|
Facing enumfacing = (Facing)state.getValue(FACING);
|
||||||
if(state.getValue(PART) == BlockBed.EnumPartType.HEAD) {
|
if(state.getValue(PART) == BlockBed.EnumPartType.HEAD) {
|
||||||
if(worldIn.getState(pos.offset(enumfacing.getOpposite())).getBlock() != this)
|
if(worldIn.getState(pos.offset(enumfacing.getOpposite())).getBlock() != this)
|
||||||
|
|
|
@ -13,6 +13,7 @@ import common.rng.Random;
|
||||||
import common.util.BlockPos;
|
import common.util.BlockPos;
|
||||||
import common.util.BoundingBox;
|
import common.util.BoundingBox;
|
||||||
import common.util.Facing;
|
import common.util.Facing;
|
||||||
|
import common.world.AWorldServer;
|
||||||
import common.world.IWorldAccess;
|
import common.world.IWorldAccess;
|
||||||
import common.world.State;
|
import common.world.State;
|
||||||
import common.world.World;
|
import common.world.World;
|
||||||
|
@ -162,7 +163,7 @@ public class BlockCake extends Block
|
||||||
/**
|
/**
|
||||||
* Called when a neighboring block changes.
|
* Called when a neighboring block changes.
|
||||||
*/
|
*/
|
||||||
public void onUpdate(World worldIn, BlockPos pos, State state, Block neighborBlock)
|
public void onUpdate(AWorldServer worldIn, BlockPos pos, State state, Block neighborBlock)
|
||||||
{
|
{
|
||||||
if (!this.canBlockStay(worldIn, pos))
|
if (!this.canBlockStay(worldIn, pos))
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,6 +9,7 @@ import common.model.ModelProvider;
|
||||||
import common.model.GuiPosition;
|
import common.model.GuiPosition;
|
||||||
import common.util.BlockPos;
|
import common.util.BlockPos;
|
||||||
import common.util.Facing;
|
import common.util.Facing;
|
||||||
|
import common.world.AWorldServer;
|
||||||
import common.world.IWorldAccess;
|
import common.world.IWorldAccess;
|
||||||
import common.world.State;
|
import common.world.State;
|
||||||
import common.world.World;
|
import common.world.World;
|
||||||
|
@ -71,7 +72,7 @@ public class BlockCarpet extends Block
|
||||||
/**
|
/**
|
||||||
* Called when a neighboring block changes.
|
* Called when a neighboring block changes.
|
||||||
*/
|
*/
|
||||||
public void onUpdate(World worldIn, BlockPos pos, State state, Block neighborBlock)
|
public void onUpdate(AWorldServer worldIn, BlockPos pos, State state, Block neighborBlock)
|
||||||
{
|
{
|
||||||
this.checkForDrop(worldIn, pos, state);
|
this.checkForDrop(worldIn, pos, state);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import common.util.Facing;
|
||||||
import common.util.HitPosition;
|
import common.util.HitPosition;
|
||||||
import common.util.Identifyable;
|
import common.util.Identifyable;
|
||||||
import common.util.Vec3;
|
import common.util.Vec3;
|
||||||
|
import common.world.AWorldServer;
|
||||||
import common.world.IBlockAccess;
|
import common.world.IBlockAccess;
|
||||||
import common.world.IWorldAccess;
|
import common.world.IWorldAccess;
|
||||||
import common.world.State;
|
import common.world.State;
|
||||||
|
@ -192,7 +193,7 @@ public class BlockDoor extends Block implements Rotatable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onUpdate(World world, BlockPos pos, State state, Block neighbor) {
|
public void onUpdate(AWorldServer world, BlockPos pos, State state, Block neighbor) {
|
||||||
if(state.getValue(HALF) == EnumDoorHalf.UPPER) {
|
if(state.getValue(HALF) == EnumDoorHalf.UPPER) {
|
||||||
BlockPos lower = pos.down();
|
BlockPos lower = pos.down();
|
||||||
State bottom = world.getState(lower);
|
State bottom = world.getState(lower);
|
||||||
|
@ -358,9 +359,9 @@ public class BlockDoor extends Block implements Rotatable {
|
||||||
State iblockstate = door.getState().withProperty(BlockDoor.FACING, facing).withProperty(BlockDoor.HINGE, flag2 ? BlockDoor.EnumHingePosition.RIGHT : BlockDoor.EnumHingePosition.LEFT);
|
State iblockstate = door.getState().withProperty(BlockDoor.FACING, facing).withProperty(BlockDoor.HINGE, flag2 ? BlockDoor.EnumHingePosition.RIGHT : BlockDoor.EnumHingePosition.LEFT);
|
||||||
worldIn.setState(pos, iblockstate.withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.LOWER), 2);
|
worldIn.setState(pos, iblockstate.withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.LOWER), 2);
|
||||||
worldIn.setState(blockpos2, iblockstate.withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER), 2);
|
worldIn.setState(blockpos2, iblockstate.withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER), 2);
|
||||||
if(update) {
|
if(update && !worldIn.client) {
|
||||||
worldIn.notifyNeighborsOfStateChange(pos, door);
|
((AWorldServer)worldIn).notifyNeighborsOfStateChange(pos, door);
|
||||||
worldIn.notifyNeighborsOfStateChange(blockpos2, door);
|
((AWorldServer)worldIn).notifyNeighborsOfStateChange(blockpos2, door);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,7 @@ public class BlockDragonEgg extends Block
|
||||||
/**
|
/**
|
||||||
* Called when a neighboring block changes.
|
* Called when a neighboring block changes.
|
||||||
*/
|
*/
|
||||||
public void onUpdate(World worldIn, BlockPos pos, State state, Block neighborBlock)
|
public void onUpdate(AWorldServer worldIn, BlockPos pos, State state, Block neighborBlock)
|
||||||
{
|
{
|
||||||
worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn, pos));
|
worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn, pos));
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ import common.util.Facing;
|
||||||
import common.util.ParticleType;
|
import common.util.ParticleType;
|
||||||
import common.util.PortalType;
|
import common.util.PortalType;
|
||||||
import common.world.IWorldAccess;
|
import common.world.IWorldAccess;
|
||||||
import common.world.AWorldClient;
|
|
||||||
import common.world.State;
|
import common.world.State;
|
||||||
import common.world.World;
|
import common.world.World;
|
||||||
|
|
||||||
|
@ -92,7 +91,7 @@ public class BlockFloorPortal extends Block
|
||||||
entityIn.setPortal(PortalType.FLOOR);
|
entityIn.setPortal(PortalType.FLOOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayTick(AWorldClient worldIn, BlockPos pos, State state, Random rand)
|
public void displayTick(World worldIn, BlockPos pos, State state, Random rand)
|
||||||
{
|
{
|
||||||
double d0 = (double)((float)pos.getX() + rand.floatv());
|
double d0 = (double)((float)pos.getX() + rand.floatv());
|
||||||
double d1 = (double)((float)pos.getY() + 0.8F);
|
double d1 = (double)((float)pos.getY() + 0.8F);
|
||||||
|
|
|
@ -177,7 +177,7 @@ public class BlockFlowerPot extends Block
|
||||||
/**
|
/**
|
||||||
* Called when a neighboring block changes.
|
* Called when a neighboring block changes.
|
||||||
*/
|
*/
|
||||||
public void onUpdate(World worldIn, BlockPos pos, State state, Block neighborBlock)
|
public void onUpdate(AWorldServer worldIn, BlockPos pos, State state, Block neighborBlock)
|
||||||
{
|
{
|
||||||
if (!worldIn.isBlockSolid(pos.down()))
|
if (!worldIn.isBlockSolid(pos.down()))
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,6 +14,7 @@ import common.properties.Property;
|
||||||
import common.util.BlockPos;
|
import common.util.BlockPos;
|
||||||
import common.util.BoundingBox;
|
import common.util.BoundingBox;
|
||||||
import common.util.Facing;
|
import common.util.Facing;
|
||||||
|
import common.world.AWorldServer;
|
||||||
import common.world.IWorldAccess;
|
import common.world.IWorldAccess;
|
||||||
import common.world.State;
|
import common.world.State;
|
||||||
import common.world.World;
|
import common.world.World;
|
||||||
|
@ -113,7 +114,7 @@ public class BlockLadder extends Block implements Rotatable
|
||||||
/**
|
/**
|
||||||
* Called when a neighboring block changes.
|
* Called when a neighboring block changes.
|
||||||
*/
|
*/
|
||||||
public void onUpdate(World worldIn, BlockPos pos, State state, Block neighborBlock)
|
public void onUpdate(AWorldServer worldIn, BlockPos pos, State state, Block neighborBlock)
|
||||||
{
|
{
|
||||||
Facing enumfacing = (Facing)state.getValue(FACING);
|
Facing enumfacing = (Facing)state.getValue(FACING);
|
||||||
|
|
||||||
|
|
|
@ -22,8 +22,8 @@ import common.util.BoundingBox;
|
||||||
import common.util.Facing;
|
import common.util.Facing;
|
||||||
import common.util.ParticleType;
|
import common.util.ParticleType;
|
||||||
import common.util.PortalType;
|
import common.util.PortalType;
|
||||||
|
import common.world.AWorldServer;
|
||||||
import common.world.IWorldAccess;
|
import common.world.IWorldAccess;
|
||||||
import common.world.AWorldClient;
|
|
||||||
import common.world.State;
|
import common.world.State;
|
||||||
import common.world.World;
|
import common.world.World;
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ public class BlockPortal extends Block
|
||||||
/**
|
/**
|
||||||
* Called when a neighboring block changes.
|
* Called when a neighboring block changes.
|
||||||
*/
|
*/
|
||||||
public void onUpdate(World worldIn, BlockPos pos, State state, Block neighborBlock)
|
public void onUpdate(AWorldServer worldIn, BlockPos pos, State state, Block neighborBlock)
|
||||||
{
|
{
|
||||||
Facing.Axis enumfacing$axis = (Facing.Axis)state.getValue(AXIS);
|
Facing.Axis enumfacing$axis = (Facing.Axis)state.getValue(AXIS);
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ public class BlockPortal extends Block
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayTick(AWorldClient worldIn, BlockPos pos, State state, Random rand)
|
public void displayTick(World worldIn, BlockPos pos, State state, Random rand)
|
||||||
{
|
{
|
||||||
// if (rand.chance(100))
|
// if (rand.chance(100))
|
||||||
// {
|
// {
|
||||||
|
|
|
@ -28,7 +28,6 @@ import common.util.Vec3;
|
||||||
import common.world.Explosion;
|
import common.world.Explosion;
|
||||||
import common.world.IBlockAccess;
|
import common.world.IBlockAccess;
|
||||||
import common.world.IWorldAccess;
|
import common.world.IWorldAccess;
|
||||||
import common.world.AWorldClient;
|
|
||||||
import common.world.State;
|
import common.world.State;
|
||||||
import common.world.World;
|
import common.world.World;
|
||||||
import common.world.AWorldServer;
|
import common.world.AWorldServer;
|
||||||
|
@ -561,7 +560,7 @@ public class BlockStairs extends Block implements Rotatable
|
||||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayTick(AWorldClient worldIn, BlockPos pos, State state, Random rand)
|
public void displayTick(World worldIn, BlockPos pos, State state, Random rand)
|
||||||
{
|
{
|
||||||
this.base.displayTick(worldIn, pos, state, rand);
|
this.base.displayTick(worldIn, pos, state, rand);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class BlockBush extends Block
|
||||||
/**
|
/**
|
||||||
* Called when a neighboring block changes.
|
* Called when a neighboring block changes.
|
||||||
*/
|
*/
|
||||||
public void onUpdate(World worldIn, BlockPos pos, State state, Block neighborBlock)
|
public void onUpdate(AWorldServer worldIn, BlockPos pos, State state, Block neighborBlock)
|
||||||
{
|
{
|
||||||
super.onUpdate(worldIn, pos, state, neighborBlock);
|
super.onUpdate(worldIn, pos, state, neighborBlock);
|
||||||
this.checkAndDropBlock(worldIn, pos, state);
|
this.checkAndDropBlock(worldIn, pos, state);
|
||||||
|
|
|
@ -109,7 +109,7 @@ public class BlockCactus extends Block
|
||||||
/**
|
/**
|
||||||
* Called when a neighboring block changes.
|
* Called when a neighboring block changes.
|
||||||
*/
|
*/
|
||||||
public void onUpdate(World worldIn, BlockPos pos, State state, Block neighborBlock)
|
public void onUpdate(AWorldServer worldIn, BlockPos pos, State state, Block neighborBlock)
|
||||||
{
|
{
|
||||||
if (!this.canBlockStay(worldIn, pos))
|
if (!this.canBlockStay(worldIn, pos))
|
||||||
{
|
{
|
||||||
|
|
|
@ -113,7 +113,7 @@ public class BlockFarmland extends Block
|
||||||
/**
|
/**
|
||||||
* Called when a neighboring block changes.
|
* Called when a neighboring block changes.
|
||||||
*/
|
*/
|
||||||
public void onUpdate(World worldIn, BlockPos pos, State state, Block neighborBlock)
|
public void onUpdate(AWorldServer worldIn, BlockPos pos, State state, Block neighborBlock)
|
||||||
{
|
{
|
||||||
super.onUpdate(worldIn, pos, state, neighborBlock);
|
super.onUpdate(worldIn, pos, state, neighborBlock);
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,8 @@ import common.util.BlockPos;
|
||||||
import common.util.ParticleType;
|
import common.util.ParticleType;
|
||||||
import common.vars.Vars;
|
import common.vars.Vars;
|
||||||
import common.world.IWorldAccess;
|
import common.world.IWorldAccess;
|
||||||
import common.world.AWorldClient;
|
|
||||||
import common.world.State;
|
import common.world.State;
|
||||||
|
import common.world.World;
|
||||||
import common.world.AWorldServer;
|
import common.world.AWorldServer;
|
||||||
|
|
||||||
public class BlockMycelium extends Block
|
public class BlockMycelium extends Block
|
||||||
|
@ -70,7 +70,7 @@ public class BlockMycelium extends Block
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayTick(AWorldClient worldIn, BlockPos pos, State state, Random rand)
|
public void displayTick(World worldIn, BlockPos pos, State state, Random rand)
|
||||||
{
|
{
|
||||||
super.displayTick(worldIn, pos, state, rand);
|
super.displayTick(worldIn, pos, state, rand);
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ public class BlockReed extends Block
|
||||||
/**
|
/**
|
||||||
* Called when a neighboring block changes.
|
* Called when a neighboring block changes.
|
||||||
*/
|
*/
|
||||||
public void onUpdate(World worldIn, BlockPos pos, State state, Block neighborBlock)
|
public void onUpdate(AWorldServer worldIn, BlockPos pos, State state, Block neighborBlock)
|
||||||
{
|
{
|
||||||
this.checkForDrop(worldIn, pos, state);
|
this.checkForDrop(worldIn, pos, state);
|
||||||
}
|
}
|
||||||
|
|
|
@ -214,7 +214,7 @@ public class BlockVine extends Block
|
||||||
/**
|
/**
|
||||||
* Called when a neighboring block changes.
|
* Called when a neighboring block changes.
|
||||||
*/
|
*/
|
||||||
public void onUpdate(World worldIn, BlockPos pos, State state, Block neighborBlock)
|
public void onUpdate(AWorldServer worldIn, BlockPos pos, State state, Block neighborBlock)
|
||||||
{
|
{
|
||||||
if (!worldIn.client && !this.recheckGrownSides(worldIn, pos, state))
|
if (!worldIn.client && !this.recheckGrownSides(worldIn, pos, state))
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,7 +23,6 @@ import common.util.Vec3;
|
||||||
import common.vars.Vars;
|
import common.vars.Vars;
|
||||||
import common.world.IBlockAccess;
|
import common.world.IBlockAccess;
|
||||||
import common.world.IWorldAccess;
|
import common.world.IWorldAccess;
|
||||||
import common.world.AWorldClient;
|
|
||||||
import common.world.State;
|
import common.world.State;
|
||||||
import common.world.World;
|
import common.world.World;
|
||||||
import common.world.AWorldServer;
|
import common.world.AWorldServer;
|
||||||
|
@ -237,7 +236,7 @@ public abstract class BlockLiquid extends Block
|
||||||
return this.opaque ? BlockLayer.SOLID : BlockLayer.TRANSLUCENT;
|
return this.opaque ? BlockLayer.SOLID : BlockLayer.TRANSLUCENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayTick(AWorldClient worldIn, BlockPos pos, State state, Random rand)
|
public void displayTick(World worldIn, BlockPos pos, State state, Random rand)
|
||||||
{
|
{
|
||||||
double d0 = (double)pos.getX();
|
double d0 = (double)pos.getX();
|
||||||
double d1 = (double)pos.getY();
|
double d1 = (double)pos.getY();
|
||||||
|
@ -288,7 +287,7 @@ public abstract class BlockLiquid extends Block
|
||||||
/**
|
/**
|
||||||
* Called when a neighboring block changes.
|
* Called when a neighboring block changes.
|
||||||
*/
|
*/
|
||||||
public void onUpdate(World worldIn, BlockPos pos, State state, Block neighborBlock)
|
public void onUpdate(AWorldServer worldIn, BlockPos pos, State state, Block neighborBlock)
|
||||||
{
|
{
|
||||||
this.checkForMixing(worldIn, pos, state);
|
this.checkForMixing(worldIn, pos, state);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class BlockStaticLiquid extends BlockLiquid
|
||||||
/**
|
/**
|
||||||
* Called when a neighboring block changes.
|
* Called when a neighboring block changes.
|
||||||
*/
|
*/
|
||||||
public void onUpdate(World worldIn, BlockPos pos, State state, Block neighborBlock)
|
public void onUpdate(AWorldServer worldIn, BlockPos pos, State state, Block neighborBlock)
|
||||||
{
|
{
|
||||||
if (!this.checkForMixing(worldIn, pos, state))
|
if (!this.checkForMixing(worldIn, pos, state))
|
||||||
{
|
{
|
||||||
|
@ -42,7 +42,7 @@ public class BlockStaticLiquid extends BlockLiquid
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateLiquid(World worldIn, BlockPos pos, State state)
|
private void updateLiquid(AWorldServer worldIn, BlockPos pos, State state)
|
||||||
{
|
{
|
||||||
worldIn.setState(pos, this.dynamicBlock.getState().withProperty(LEVEL, state.getValue(LEVEL)), 2);
|
worldIn.setState(pos, this.dynamicBlock.getState().withProperty(LEVEL, state.getValue(LEVEL)), 2);
|
||||||
worldIn.scheduleUpdate(pos, this.dynamicBlock, this.tickRate(worldIn, pos));
|
worldIn.scheduleUpdate(pos, this.dynamicBlock, this.tickRate(worldIn, pos));
|
||||||
|
|
|
@ -5,15 +5,15 @@ import common.block.Material;
|
||||||
import common.rng.Random;
|
import common.rng.Random;
|
||||||
import common.util.BlockPos;
|
import common.util.BlockPos;
|
||||||
import common.util.ParticleType;
|
import common.util.ParticleType;
|
||||||
import common.world.AWorldClient;
|
|
||||||
import common.world.State;
|
import common.world.State;
|
||||||
|
import common.world.World;
|
||||||
|
|
||||||
public class BlockBedrock extends Block {
|
public class BlockBedrock extends Block {
|
||||||
public BlockBedrock() {
|
public BlockBedrock() {
|
||||||
super(Material.SOLID);
|
super(Material.SOLID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayTick(AWorldClient worldIn, BlockPos pos, State state, Random rand)
|
public void displayTick(World worldIn, BlockPos pos, State state, Random rand)
|
||||||
{
|
{
|
||||||
if(/* worldIn.canShowVoidParticles() && */ pos.getY() <= 5 && rand.chance(8)) {
|
if(/* worldIn.canShowVoidParticles() && */ pos.getY() <= 5 && rand.chance(8)) {
|
||||||
worldIn.spawnParticle(ParticleType.DEPTH, (double)pos.getX() + rand.floatv(), (double)(pos.getY()+1) + (rand.floatv() * 0.5f),
|
worldIn.spawnParticle(ParticleType.DEPTH, (double)pos.getX() + rand.floatv(), (double)(pos.getY()+1) + (rand.floatv() * 0.5f),
|
||||||
|
|
|
@ -25,7 +25,6 @@ import common.util.PortalType;
|
||||||
import common.vars.Vars;
|
import common.vars.Vars;
|
||||||
import common.world.IBlockAccess;
|
import common.world.IBlockAccess;
|
||||||
import common.world.IWorldAccess;
|
import common.world.IWorldAccess;
|
||||||
import common.world.AWorldClient;
|
|
||||||
import common.world.State;
|
import common.world.State;
|
||||||
import common.world.World;
|
import common.world.World;
|
||||||
import common.world.AWorldServer;
|
import common.world.AWorldServer;
|
||||||
|
@ -322,7 +321,7 @@ public class BlockFire extends Block
|
||||||
/**
|
/**
|
||||||
* Called when a neighboring block changes.
|
* Called when a neighboring block changes.
|
||||||
*/
|
*/
|
||||||
public void onUpdate(World worldIn, BlockPos pos, State state, Block neighborBlock)
|
public void onUpdate(AWorldServer worldIn, BlockPos pos, State state, Block neighborBlock)
|
||||||
{
|
{
|
||||||
if (!worldIn.isBlockSolid(pos.down()) && !this.canNeighborCatchFire(worldIn, pos))
|
if (!worldIn.isBlockSolid(pos.down()) && !this.canNeighborCatchFire(worldIn, pos))
|
||||||
{
|
{
|
||||||
|
@ -346,7 +345,7 @@ public class BlockFire extends Block
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayTick(AWorldClient worldIn, BlockPos pos, State state, Random rand)
|
public void displayTick(World worldIn, BlockPos pos, State state, Random rand)
|
||||||
{
|
{
|
||||||
if (rand.chance(24))
|
if (rand.chance(24))
|
||||||
{
|
{
|
||||||
|
|
|
@ -88,7 +88,7 @@ public class BlockSnow extends Block
|
||||||
/**
|
/**
|
||||||
* Called when a neighboring block changes.
|
* Called when a neighboring block changes.
|
||||||
*/
|
*/
|
||||||
public void onUpdate(World worldIn, BlockPos pos, State state, Block neighborBlock)
|
public void onUpdate(AWorldServer worldIn, BlockPos pos, State state, Block neighborBlock)
|
||||||
{
|
{
|
||||||
this.checkAndDropBlock(worldIn, pos, state);
|
this.checkAndDropBlock(worldIn, pos, state);
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,7 +94,7 @@ public abstract class BlockBasePressurePlate extends Block
|
||||||
/**
|
/**
|
||||||
* Called when a neighboring block changes.
|
* Called when a neighboring block changes.
|
||||||
*/
|
*/
|
||||||
public void onUpdate(World worldIn, BlockPos pos, State state, Block neighborBlock)
|
public void onUpdate(AWorldServer worldIn, BlockPos pos, State state, Block neighborBlock)
|
||||||
{
|
{
|
||||||
if (!this.canBePlacedOn(worldIn, pos.down()))
|
if (!this.canBePlacedOn(worldIn, pos.down()))
|
||||||
{
|
{
|
||||||
|
@ -132,7 +132,7 @@ public abstract class BlockBasePressurePlate extends Block
|
||||||
|
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
{
|
{
|
||||||
this.updateState(worldIn, pos, state, i);
|
this.updateState((AWorldServer)worldIn, pos, state, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ public abstract class BlockBasePressurePlate extends Block
|
||||||
/**
|
/**
|
||||||
* Updates the pressure plate when stepped on
|
* Updates the pressure plate when stepped on
|
||||||
*/
|
*/
|
||||||
protected void updateState(World worldIn, BlockPos pos, State state, int oldSignal)
|
protected void updateState(AWorldServer worldIn, BlockPos pos, State state, int oldSignal)
|
||||||
{
|
{
|
||||||
int i = this.computeSignalStrength(worldIn, pos);
|
int i = this.computeSignalStrength(worldIn, pos);
|
||||||
boolean flag = oldSignal > 0;
|
boolean flag = oldSignal > 0;
|
||||||
|
@ -191,7 +191,7 @@ public abstract class BlockBasePressurePlate extends Block
|
||||||
/**
|
/**
|
||||||
* Notify block and block below of changes
|
* Notify block and block below of changes
|
||||||
*/
|
*/
|
||||||
protected void updateNeighbors(World worldIn, BlockPos pos)
|
protected void updateNeighbors(AWorldServer worldIn, BlockPos pos)
|
||||||
{
|
{
|
||||||
worldIn.notifyNeighborsOfStateChange(pos, this);
|
worldIn.notifyNeighborsOfStateChange(pos, this);
|
||||||
worldIn.notifyNeighborsOfStateChange(pos.down(), this);
|
worldIn.notifyNeighborsOfStateChange(pos.down(), this);
|
||||||
|
|
|
@ -20,7 +20,6 @@ import common.util.BlockPos;
|
||||||
import common.util.BoundingBox;
|
import common.util.BoundingBox;
|
||||||
import common.util.Facing;
|
import common.util.Facing;
|
||||||
import common.util.ParticleType;
|
import common.util.ParticleType;
|
||||||
import common.world.AWorldClient;
|
|
||||||
import common.world.State;
|
import common.world.State;
|
||||||
import common.world.World;
|
import common.world.World;
|
||||||
import common.world.AWorldServer;
|
import common.world.AWorldServer;
|
||||||
|
@ -415,7 +414,7 @@ public class BlockBrewingStand extends Block implements ITileEntityProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayTick(AWorldClient worldIn, BlockPos pos, State state, Random rand)
|
public void displayTick(World worldIn, BlockPos pos, State state, Random rand)
|
||||||
{
|
{
|
||||||
double d0 = (double)((float)pos.getX() + 0.4F + rand.floatv() * 0.2F);
|
double d0 = (double)((float)pos.getX() + 0.4F + rand.floatv() * 0.2F);
|
||||||
double d1 = (double)((float)pos.getY() + 0.7F + rand.floatv() * 0.3F);
|
double d1 = (double)((float)pos.getY() + 0.7F + rand.floatv() * 0.3F);
|
||||||
|
|
|
@ -113,7 +113,7 @@ public class BlockButton extends Block implements Directional
|
||||||
/**
|
/**
|
||||||
* Called when a neighboring block changes.
|
* Called when a neighboring block changes.
|
||||||
*/
|
*/
|
||||||
public void onUpdate(World worldIn, BlockPos pos, State state, Block neighborBlock)
|
public void onUpdate(AWorldServer worldIn, BlockPos pos, State state, Block neighborBlock)
|
||||||
{
|
{
|
||||||
if (this.checkForDrop(worldIn, pos, state) && !canPlaceButtonOn(worldIn, pos, ((Facing)state.getValue(FACING)).getOpposite()))
|
if (this.checkForDrop(worldIn, pos, state) && !canPlaceButtonOn(worldIn, pos, ((Facing)state.getValue(FACING)).getOpposite()))
|
||||||
{
|
{
|
||||||
|
@ -189,8 +189,10 @@ public class BlockButton extends Block implements Directional
|
||||||
worldIn.setState(pos, state.withProperty(POWERED, Boolean.valueOf(true)), 3);
|
worldIn.setState(pos, state.withProperty(POWERED, Boolean.valueOf(true)), 3);
|
||||||
worldIn.markBlockRangeForRenderUpdate(pos, pos);
|
worldIn.markBlockRangeForRenderUpdate(pos, pos);
|
||||||
worldIn.playSound(SoundEvent.CLICK, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, 0.3F);
|
worldIn.playSound(SoundEvent.CLICK, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, 0.3F);
|
||||||
this.notifyNeighbors(worldIn, pos, (Facing)state.getValue(FACING));
|
if(!worldIn.client) {
|
||||||
worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn, null));
|
this.notifyNeighbors((AWorldServer)worldIn, pos, (Facing)state.getValue(FACING));
|
||||||
|
((AWorldServer)worldIn).scheduleUpdate(pos, this, this.tickRate(worldIn, null));
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -249,13 +251,13 @@ public class BlockButton extends Block implements Directional
|
||||||
{
|
{
|
||||||
if (!((Boolean)state.getValue(POWERED)).booleanValue())
|
if (!((Boolean)state.getValue(POWERED)).booleanValue())
|
||||||
{
|
{
|
||||||
this.checkForArrows(worldIn, pos, state);
|
this.checkForArrows((AWorldServer)worldIn, pos, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkForArrows(World worldIn, BlockPos pos, State state)
|
private void checkForArrows(AWorldServer worldIn, BlockPos pos, State state)
|
||||||
{
|
{
|
||||||
this.updateBlockBounds(state);
|
this.updateBlockBounds(state);
|
||||||
List <? extends Entity > list = worldIn.<Entity>getEntitiesWithinAABB(EntityArrow.class, new BoundingBox((double)pos.getX() + this.minX, (double)pos.getY() + this.minY, (double)pos.getZ() + this.minZ, (double)pos.getX() + this.maxX, (double)pos.getY() + this.maxY, (double)pos.getZ() + this.maxZ));
|
List <? extends Entity > list = worldIn.<Entity>getEntitiesWithinAABB(EntityArrow.class, new BoundingBox((double)pos.getX() + this.minX, (double)pos.getY() + this.minY, (double)pos.getZ() + this.minZ, (double)pos.getX() + this.maxX, (double)pos.getY() + this.maxY, (double)pos.getZ() + this.maxZ));
|
||||||
|
@ -284,7 +286,7 @@ public class BlockButton extends Block implements Directional
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void notifyNeighbors(World worldIn, BlockPos pos, Facing facing)
|
private void notifyNeighbors(AWorldServer worldIn, BlockPos pos, Facing facing)
|
||||||
{
|
{
|
||||||
worldIn.notifyNeighborsOfStateChange(pos, this);
|
worldIn.notifyNeighborsOfStateChange(pos, this);
|
||||||
worldIn.notifyNeighborsOfStateChange(pos.offset(facing.getOpposite()), this);
|
worldIn.notifyNeighborsOfStateChange(pos.offset(facing.getOpposite()), this);
|
||||||
|
|
|
@ -20,7 +20,6 @@ import common.tileentity.TileEntityFurnace;
|
||||||
import common.util.BlockPos;
|
import common.util.BlockPos;
|
||||||
import common.util.Facing;
|
import common.util.Facing;
|
||||||
import common.util.ParticleType;
|
import common.util.ParticleType;
|
||||||
import common.world.AWorldClient;
|
|
||||||
import common.world.State;
|
import common.world.State;
|
||||||
import common.world.World;
|
import common.world.World;
|
||||||
import common.world.AWorldServer;
|
import common.world.AWorldServer;
|
||||||
|
@ -74,7 +73,7 @@ public class BlockFurnace extends Block implements ITileEntityProvider, Rotatabl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void displayTick(AWorldClient worldIn, BlockPos pos, State state, Random rand)
|
public void displayTick(World worldIn, BlockPos pos, State state, Random rand)
|
||||||
{
|
{
|
||||||
if (this.isBurning)
|
if (this.isBurning)
|
||||||
{
|
{
|
||||||
|
|
|
@ -143,7 +143,7 @@ public class BlockLever extends Block
|
||||||
/**
|
/**
|
||||||
* Called when a neighboring block changes.
|
* Called when a neighboring block changes.
|
||||||
*/
|
*/
|
||||||
public void onUpdate(World worldIn, BlockPos pos, State state, Block neighborBlock)
|
public void onUpdate(AWorldServer worldIn, BlockPos pos, State state, Block neighborBlock)
|
||||||
{
|
{
|
||||||
if (this.checkDrop(worldIn, pos, state) && !canPlaceLeverOn(worldIn, pos, ((BlockLever.EnumOrientation)state.getValue(FACING)).getFacing().getOpposite()))
|
if (this.checkDrop(worldIn, pos, state) && !canPlaceLeverOn(worldIn, pos, ((BlockLever.EnumOrientation)state.getValue(FACING)).getFacing().getOpposite()))
|
||||||
{
|
{
|
||||||
|
@ -212,9 +212,9 @@ public class BlockLever extends Block
|
||||||
state = state.cycleProperty(POWERED);
|
state = state.cycleProperty(POWERED);
|
||||||
worldIn.setState(pos, state, 3);
|
worldIn.setState(pos, state, 3);
|
||||||
worldIn.playSound(SoundEvent.CLICK, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, 0.3F);
|
worldIn.playSound(SoundEvent.CLICK, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, 0.3F);
|
||||||
worldIn.notifyNeighborsOfStateChange(pos, this);
|
((AWorldServer)worldIn).notifyNeighborsOfStateChange(pos, this);
|
||||||
Facing enumfacing = ((BlockLever.EnumOrientation)state.getValue(FACING)).getFacing();
|
Facing enumfacing = ((BlockLever.EnumOrientation)state.getValue(FACING)).getFacing();
|
||||||
worldIn.notifyNeighborsOfStateChange(pos.offset(enumfacing.getOpposite()), this);
|
((AWorldServer)worldIn).notifyNeighborsOfStateChange(pos.offset(enumfacing.getOpposite()), this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ import common.util.BlockPos;
|
||||||
import common.util.Facing;
|
import common.util.Facing;
|
||||||
import common.util.ParticleType;
|
import common.util.ParticleType;
|
||||||
import common.vars.Vars;
|
import common.vars.Vars;
|
||||||
import common.world.AWorldClient;
|
|
||||||
import common.world.State;
|
import common.world.State;
|
||||||
import common.world.World;
|
import common.world.World;
|
||||||
import common.world.AWorldServer;
|
import common.world.AWorldServer;
|
||||||
|
@ -54,7 +53,7 @@ public class BlockLitTorch extends BlockTorch {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayTick(AWorldClient worldIn, BlockPos pos, State state, Random rand) {
|
public void displayTick(World worldIn, BlockPos pos, State state, Random rand) {
|
||||||
if(this.unlit.getParticleColor() == 0xffffffff) {
|
if(this.unlit.getParticleColor() == 0xffffffff) {
|
||||||
Facing enumfacing = (Facing)state.getValue(FACING);
|
Facing enumfacing = (Facing)state.getValue(FACING);
|
||||||
double d0 = (double)pos.getX() + 0.5D;
|
double d0 = (double)pos.getX() + 0.5D;
|
||||||
|
|
|
@ -44,7 +44,7 @@ public abstract class BlockMachine extends Block implements Rotatable, ITileEnti
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onUpdate(World worldIn, BlockPos pos, State state, Block neighborBlock) {
|
public void onUpdate(AWorldServer worldIn, BlockPos pos, State state, Block neighborBlock) {
|
||||||
this.updateState(worldIn, pos, state);
|
this.updateState(worldIn, pos, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,14 +33,14 @@ public class BlockPistonBase extends Block implements Directional
|
||||||
{
|
{
|
||||||
private static class BlockPistonStructureHelper
|
private static class BlockPistonStructureHelper
|
||||||
{
|
{
|
||||||
private final World world;
|
private final AWorldServer world;
|
||||||
private final BlockPos pistonPos;
|
private final BlockPos pistonPos;
|
||||||
private final BlockPos blockToMove;
|
private final BlockPos blockToMove;
|
||||||
private final Facing moveDirection;
|
private final Facing moveDirection;
|
||||||
private final List<BlockPos> toMove = Lists.<BlockPos>newArrayList();
|
private final List<BlockPos> toMove = Lists.<BlockPos>newArrayList();
|
||||||
private final List<BlockPos> toDestroy = Lists.<BlockPos>newArrayList();
|
private final List<BlockPos> toDestroy = Lists.<BlockPos>newArrayList();
|
||||||
|
|
||||||
public BlockPistonStructureHelper(World worldIn, BlockPos posIn, Facing pistonFacing, boolean extending)
|
public BlockPistonStructureHelper(AWorldServer worldIn, BlockPos posIn, Facing pistonFacing, boolean extending)
|
||||||
{
|
{
|
||||||
this.world = worldIn;
|
this.world = worldIn;
|
||||||
this.pistonPos = posIn;
|
this.pistonPos = posIn;
|
||||||
|
@ -277,14 +277,14 @@ public class BlockPistonBase extends Block implements Directional
|
||||||
|
|
||||||
if (!worldIn.client)
|
if (!worldIn.client)
|
||||||
{
|
{
|
||||||
this.checkForMove(worldIn, pos, state);
|
this.checkForMove((AWorldServer)worldIn, pos, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a neighboring block changes.
|
* Called when a neighboring block changes.
|
||||||
*/
|
*/
|
||||||
public void onUpdate(World worldIn, BlockPos pos, State state, Block neighborBlock)
|
public void onUpdate(AWorldServer worldIn, BlockPos pos, State state, Block neighborBlock)
|
||||||
{
|
{
|
||||||
if (!worldIn.client)
|
if (!worldIn.client)
|
||||||
{
|
{
|
||||||
|
@ -309,7 +309,7 @@ public class BlockPistonBase extends Block implements Directional
|
||||||
return this.getState().withProperty(FACING, getFacingFromEntity(worldIn, pos, placer)).withProperty(EXTENDED, Boolean.valueOf(false));
|
return this.getState().withProperty(FACING, getFacingFromEntity(worldIn, pos, placer)).withProperty(EXTENDED, Boolean.valueOf(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkForMove(World worldIn, BlockPos pos, State state)
|
private void checkForMove(AWorldServer worldIn, BlockPos pos, State state)
|
||||||
{
|
{
|
||||||
Facing enumfacing = (Facing)state.getValue(FACING);
|
Facing enumfacing = (Facing)state.getValue(FACING);
|
||||||
boolean flag = this.shouldBeExtended(worldIn, pos, enumfacing);
|
boolean flag = this.shouldBeExtended(worldIn, pos, enumfacing);
|
||||||
|
@ -349,7 +349,7 @@ public class BlockPistonBase extends Block implements Directional
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldBeExtended(World worldIn, BlockPos pos, Facing facing)
|
private boolean shouldBeExtended(AWorldServer worldIn, BlockPos pos, Facing facing)
|
||||||
{
|
{
|
||||||
// for (Facing enumfacing : Facing.values())
|
// for (Facing enumfacing : Facing.values())
|
||||||
// {
|
// {
|
||||||
|
@ -443,12 +443,6 @@ public class BlockPistonBase extends Block implements Directional
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Facing getFacing(int meta)
|
|
||||||
{
|
|
||||||
int i = meta & 7;
|
|
||||||
return i > 5 ? Facing.getFront(0) : Facing.getFront(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Facing getFacingFromEntity(World worldIn, BlockPos clickedBlock, EntityLiving entityIn)
|
public static Facing getFacingFromEntity(World worldIn, BlockPos clickedBlock, EntityLiving entityIn)
|
||||||
{
|
{
|
||||||
if (ExtMath.absf((float)entityIn.posX - (float)clickedBlock.getX()) < 2.0F && ExtMath.absf((float)entityIn.posZ - (float)clickedBlock.getZ()) < 2.0F)
|
if (ExtMath.absf((float)entityIn.posX - (float)clickedBlock.getX()) < 2.0F && ExtMath.absf((float)entityIn.posZ - (float)clickedBlock.getZ()) < 2.0F)
|
||||||
|
@ -469,7 +463,7 @@ public class BlockPistonBase extends Block implements Directional
|
||||||
return entityIn.getHorizontalFacing().getOpposite();
|
return entityIn.getHorizontalFacing().getOpposite();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canPush(Block blockIn, World worldIn, BlockPos pos, Facing direction, boolean allowDestroy)
|
public static boolean canPush(Block blockIn, AWorldServer worldIn, BlockPos pos, Facing direction, boolean allowDestroy)
|
||||||
{
|
{
|
||||||
if (blockIn == Blocks.obsidian)
|
if (blockIn == Blocks.obsidian)
|
||||||
{
|
{
|
||||||
|
@ -523,7 +517,7 @@ public class BlockPistonBase extends Block implements Directional
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean doMove(World worldIn, BlockPos pos, Facing direction, boolean extending)
|
private boolean doMove(AWorldServer worldIn, BlockPos pos, Facing direction, boolean extending)
|
||||||
{
|
{
|
||||||
if (!extending)
|
if (!extending)
|
||||||
{
|
{
|
||||||
|
@ -594,7 +588,7 @@ public class BlockPistonBase extends Block implements Directional
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void launchWithSlimeBlock(World world, BlockPos pos, Facing pistonFacing, boolean extending)
|
private void launchWithSlimeBlock(AWorldServer world, BlockPos pos, Facing pistonFacing, boolean extending)
|
||||||
{
|
{
|
||||||
float step = 0.25f;
|
float step = 0.25f;
|
||||||
|
|
||||||
|
|
|
@ -174,7 +174,7 @@ public class BlockPistonHead extends Block implements Directional
|
||||||
/**
|
/**
|
||||||
* Called when a neighboring block changes.
|
* Called when a neighboring block changes.
|
||||||
*/
|
*/
|
||||||
public void onUpdate(World worldIn, BlockPos pos, State state, Block neighborBlock)
|
public void onUpdate(AWorldServer worldIn, BlockPos pos, State state, Block neighborBlock)
|
||||||
{
|
{
|
||||||
Facing enumfacing = (Facing)state.getValue(FACING);
|
Facing enumfacing = (Facing)state.getValue(FACING);
|
||||||
BlockPos blockpos = pos.offset(enumfacing.getOpposite());
|
BlockPos blockpos = pos.offset(enumfacing.getOpposite());
|
||||||
|
|
|
@ -107,7 +107,7 @@ public class BlockRail extends Block
|
||||||
/**
|
/**
|
||||||
* Called when a neighboring block changes.
|
* Called when a neighboring block changes.
|
||||||
*/
|
*/
|
||||||
public void onUpdate(World worldIn, BlockPos pos, State state, Block neighborBlock)
|
public void onUpdate(AWorldServer worldIn, BlockPos pos, State state, Block neighborBlock)
|
||||||
{
|
{
|
||||||
if (!worldIn.client)
|
if (!worldIn.client)
|
||||||
{
|
{
|
||||||
|
|
|
@ -123,7 +123,7 @@ public abstract class BlockTorch extends Block implements Directional
|
||||||
/**
|
/**
|
||||||
* Called when a neighboring block changes.
|
* Called when a neighboring block changes.
|
||||||
*/
|
*/
|
||||||
public void onUpdate(World worldIn, BlockPos pos, State state, Block neighborBlock)
|
public void onUpdate(AWorldServer worldIn, BlockPos pos, State state, Block neighborBlock)
|
||||||
{
|
{
|
||||||
this.onNeighborChangeInternal(worldIn, pos, state);
|
this.onNeighborChangeInternal(worldIn, pos, state);
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ public class BlockTripWire extends Block
|
||||||
/**
|
/**
|
||||||
* Called when a neighboring block changes.
|
* Called when a neighboring block changes.
|
||||||
*/
|
*/
|
||||||
public void onUpdate(World worldIn, BlockPos pos, State state, Block neighborBlock)
|
public void onUpdate(AWorldServer worldIn, BlockPos pos, State state, Block neighborBlock)
|
||||||
{
|
{
|
||||||
boolean flag = ((Boolean)state.getValue(SUSPENDED)).booleanValue();
|
boolean flag = ((Boolean)state.getValue(SUSPENDED)).booleanValue();
|
||||||
boolean flag1 = !worldIn.isBlockSolid(pos.down());
|
boolean flag1 = !worldIn.isBlockSolid(pos.down());
|
||||||
|
@ -137,7 +137,7 @@ public class BlockTripWire extends Block
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void notifyHook(World worldIn, BlockPos pos, State state)
|
private void notifyHook(AWorldServer worldIn, BlockPos pos, State state)
|
||||||
{
|
{
|
||||||
for (Facing enumfacing : new Facing[] {Facing.SOUTH, Facing.WEST})
|
for (Facing enumfacing : new Facing[] {Facing.SOUTH, Facing.WEST})
|
||||||
{
|
{
|
||||||
|
@ -173,7 +173,7 @@ public class BlockTripWire extends Block
|
||||||
{
|
{
|
||||||
if (!((Boolean)state.getValue(POWERED)).booleanValue())
|
if (!((Boolean)state.getValue(POWERED)).booleanValue())
|
||||||
{
|
{
|
||||||
this.updateState(worldIn, pos);
|
this.updateState((AWorldServer)worldIn, pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -189,7 +189,7 @@ public class BlockTripWire extends Block
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateState(World worldIn, BlockPos pos)
|
private void updateState(AWorldServer worldIn, BlockPos pos)
|
||||||
{
|
{
|
||||||
State iblockstate = worldIn.getState(pos);
|
State iblockstate = worldIn.getState(pos);
|
||||||
boolean flag = ((Boolean)iblockstate.getValue(POWERED)).booleanValue();
|
boolean flag = ((Boolean)iblockstate.getValue(POWERED)).booleanValue();
|
||||||
|
|
|
@ -106,13 +106,14 @@ public class BlockTripWireHook extends Block implements Rotatable
|
||||||
*/
|
*/
|
||||||
public void onPlace(World worldIn, BlockPos pos, State state, EntityLiving placer)
|
public void onPlace(World worldIn, BlockPos pos, State state, EntityLiving placer)
|
||||||
{
|
{
|
||||||
this.triggerHookAt(worldIn, pos, state, false, false, -1, (State)null);
|
if(!worldIn.client)
|
||||||
|
this.triggerHookAt((AWorldServer)worldIn, pos, state, false, false, -1, (State)null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a neighboring block changes.
|
* Called when a neighboring block changes.
|
||||||
*/
|
*/
|
||||||
public void onUpdate(World worldIn, BlockPos pos, State state, Block neighborBlock)
|
public void onUpdate(AWorldServer worldIn, BlockPos pos, State state, Block neighborBlock)
|
||||||
{
|
{
|
||||||
if (neighborBlock != this)
|
if (neighborBlock != this)
|
||||||
{
|
{
|
||||||
|
@ -129,7 +130,7 @@ public class BlockTripWireHook extends Block implements Rotatable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void triggerHookAt(World worldIn, BlockPos pos, State hookState, boolean removed, boolean triggered, int wireDist, State wireState)
|
public void triggerHookAt(AWorldServer worldIn, BlockPos pos, State hookState, boolean removed, boolean triggered, int wireDist, State wireState)
|
||||||
{
|
{
|
||||||
Facing enumfacing = (Facing)hookState.getValue(FACING);
|
Facing enumfacing = (Facing)hookState.getValue(FACING);
|
||||||
boolean attached = ((Boolean)hookState.getValue(ATTACHED)).booleanValue();
|
boolean attached = ((Boolean)hookState.getValue(ATTACHED)).booleanValue();
|
||||||
|
@ -227,7 +228,7 @@ public class BlockTripWireHook extends Block implements Rotatable
|
||||||
this.triggerHookAt(worldIn, pos, state, false, true, -1, (State)null);
|
this.triggerHookAt(worldIn, pos, state, false, true, -1, (State)null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void playerTriggerSounds(World worldIn, BlockPos pos, boolean attached, boolean powered, boolean wasAttached, boolean wasPowered)
|
private void playerTriggerSounds(AWorldServer worldIn, BlockPos pos, boolean attached, boolean powered, boolean wasAttached, boolean wasPowered)
|
||||||
{
|
{
|
||||||
if (powered && !wasPowered)
|
if (powered && !wasPowered)
|
||||||
{
|
{
|
||||||
|
@ -247,7 +248,7 @@ public class BlockTripWireHook extends Block implements Rotatable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void notifyTriggered(World worldIn, BlockPos pos, Facing face)
|
private void notifyTriggered(AWorldServer worldIn, BlockPos pos, Facing face)
|
||||||
{
|
{
|
||||||
worldIn.notifyNeighborsOfStateChange(pos, this);
|
worldIn.notifyNeighborsOfStateChange(pos, this);
|
||||||
worldIn.notifyNeighborsOfStateChange(pos.offset(face.getOpposite()), this);
|
worldIn.notifyNeighborsOfStateChange(pos.offset(face.getOpposite()), this);
|
||||||
|
|
|
@ -19,7 +19,6 @@ import common.rng.Random;
|
||||||
import common.util.BlockPos;
|
import common.util.BlockPos;
|
||||||
import common.util.Facing;
|
import common.util.Facing;
|
||||||
import common.util.ParticleType;
|
import common.util.ParticleType;
|
||||||
import common.world.AWorldClient;
|
|
||||||
import common.world.State;
|
import common.world.State;
|
||||||
import common.world.World;
|
import common.world.World;
|
||||||
|
|
||||||
|
@ -106,7 +105,7 @@ public class BlockWarpChest extends Block implements Rotatable
|
||||||
// return new TileEntityWarpChest();
|
// return new TileEntityWarpChest();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public void displayTick(AWorldClient worldIn, BlockPos pos, State state, Random rand)
|
public void displayTick(World worldIn, BlockPos pos, State state, Random rand)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 3; ++i)
|
for (int i = 0; i < 3; ++i)
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,6 +15,7 @@ import common.tileentity.TileEntitySign;
|
||||||
import common.util.BlockPos;
|
import common.util.BlockPos;
|
||||||
import common.util.ExtMath;
|
import common.util.ExtMath;
|
||||||
import common.util.Facing;
|
import common.util.Facing;
|
||||||
|
import common.world.AWorldServer;
|
||||||
import common.world.IWorldAccess;
|
import common.world.IWorldAccess;
|
||||||
import common.world.State;
|
import common.world.State;
|
||||||
import common.world.World;
|
import common.world.World;
|
||||||
|
@ -39,7 +40,7 @@ public class BlockStandingSign extends BlockSign implements Rotatable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onUpdate(World worldIn, BlockPos pos, State state, Block neighborBlock)
|
public void onUpdate(AWorldServer worldIn, BlockPos pos, State state, Block neighborBlock)
|
||||||
{
|
{
|
||||||
if (!worldIn.getState(pos.down()).getBlock().getMaterial().isSolid())
|
if (!worldIn.getState(pos.down()).getBlock().getMaterial().isSolid())
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,9 +7,9 @@ import common.model.ModelProvider;
|
||||||
import common.model.ModelRotation;
|
import common.model.ModelRotation;
|
||||||
import common.util.BlockPos;
|
import common.util.BlockPos;
|
||||||
import common.util.Facing;
|
import common.util.Facing;
|
||||||
|
import common.world.AWorldServer;
|
||||||
import common.world.IWorldAccess;
|
import common.world.IWorldAccess;
|
||||||
import common.world.State;
|
import common.world.State;
|
||||||
import common.world.World;
|
|
||||||
|
|
||||||
public class BlockWallSign extends BlockSign implements Rotatable
|
public class BlockWallSign extends BlockSign implements Rotatable
|
||||||
{
|
{
|
||||||
|
@ -42,7 +42,7 @@ public class BlockWallSign extends BlockSign implements Rotatable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onUpdate(World worldIn, BlockPos pos, State state, Block neighborBlock)
|
public void onUpdate(AWorldServer worldIn, BlockPos pos, State state, Block neighborBlock)
|
||||||
{
|
{
|
||||||
Facing enumfacing = (Facing)state.getValue(FACING);
|
Facing enumfacing = (Facing)state.getValue(FACING);
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@ import common.util.ExtMath;
|
||||||
import common.util.ParticleType;
|
import common.util.ParticleType;
|
||||||
import common.util.Vec3;
|
import common.util.Vec3;
|
||||||
import common.vars.Vars;
|
import common.vars.Vars;
|
||||||
import common.world.AWorldClient;
|
|
||||||
import common.world.World;
|
import common.world.World;
|
||||||
|
|
||||||
public class EntityDragon extends EntityLiving implements IEntityMultiPart
|
public class EntityDragon extends EntityLiving implements IEntityMultiPart
|
||||||
|
@ -110,7 +109,7 @@ public class EntityDragon extends EntityLiving implements IEntityMultiPart
|
||||||
|
|
||||||
if (f1 <= -0.3F && f >= -0.3F) // && !this.isSilent())
|
if (f1 <= -0.3F && f >= -0.3F) // && !this.isSilent())
|
||||||
{
|
{
|
||||||
((AWorldClient)this.worldObj).playSound(this.posX, this.posY, this.posZ, SoundEvent.DRAGON_WINGS, 5.0F);
|
this.worldObj.playSound(this.posX, this.posY, this.posZ, SoundEvent.DRAGON_WINGS, 5.0F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@ import common.init.SoundEvent;
|
||||||
import common.util.BlockPos;
|
import common.util.BlockPos;
|
||||||
import common.util.BoundingBox;
|
import common.util.BoundingBox;
|
||||||
import common.vars.Vars;
|
import common.vars.Vars;
|
||||||
import common.world.AWorldClient;
|
|
||||||
import common.world.World;
|
import common.world.World;
|
||||||
|
|
||||||
public class EntityLightning extends EntityWeatherEffect
|
public class EntityLightning extends EntityWeatherEffect
|
||||||
|
@ -74,11 +73,8 @@ public class EntityLightning extends EntityWeatherEffect
|
||||||
|
|
||||||
if (this.lightningState >= 0)
|
if (this.lightningState >= 0)
|
||||||
{
|
{
|
||||||
if (this.worldObj.client)
|
this.worldObj.setLastLightning(2, this.color);
|
||||||
{
|
if (!this.worldObj.client)
|
||||||
((AWorldClient)this.worldObj).setLastLightning(2, this.color);
|
|
||||||
}
|
|
||||||
else // if(this.damage > 0)
|
|
||||||
{
|
{
|
||||||
double d0 = 3.0D;
|
double d0 = 3.0D;
|
||||||
List<Entity> list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, new BoundingBox(this.posX - d0, this.posY - d0, this.posZ - d0, this.posX + d0, this.posY + 6.0D + d0, this.posZ + d0));
|
List<Entity> list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, new BoundingBox(this.posX - d0, this.posY - d0, this.posZ - d0, this.posX + d0, this.posY + 6.0D + d0, this.posZ + d0));
|
||||||
|
|
|
@ -4,7 +4,6 @@ import common.ai.AISmallFireballAttack;
|
||||||
import common.init.SoundEvent;
|
import common.init.SoundEvent;
|
||||||
import common.rng.Random;
|
import common.rng.Random;
|
||||||
import common.util.ParticleType;
|
import common.util.ParticleType;
|
||||||
import common.world.AWorldClient;
|
|
||||||
import common.world.World;
|
import common.world.World;
|
||||||
|
|
||||||
public class EntityDarkMage extends EntityHoveringNPC {
|
public class EntityDarkMage extends EntityHoveringNPC {
|
||||||
|
@ -85,7 +84,7 @@ public class EntityDarkMage extends EntityHoveringNPC {
|
||||||
{
|
{
|
||||||
if(this.worldObj.client && this.isAttacking()) {
|
if(this.worldObj.client && this.isAttacking()) {
|
||||||
if(this.rand.chance(24)) { // && !this.isSilent()) {
|
if(this.rand.chance(24)) { // && !this.isSilent()) {
|
||||||
((AWorldClient)this.worldObj).playSound(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D, SoundEvent.FIRE,
|
this.worldObj.playSound(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D, SoundEvent.FIRE,
|
||||||
1.0F + this.rand.floatv());
|
1.0F + this.rand.floatv());
|
||||||
}
|
}
|
||||||
for(int i = 0; i < 2; ++i) {
|
for(int i = 0; i < 2; ++i) {
|
||||||
|
|
|
@ -96,7 +96,6 @@ import common.util.Vec3;
|
||||||
import common.util.WorldPos;
|
import common.util.WorldPos;
|
||||||
import common.vars.Vars;
|
import common.vars.Vars;
|
||||||
import common.village.MerchantRecipeList;
|
import common.village.MerchantRecipeList;
|
||||||
import common.world.AWorldClient;
|
|
||||||
import common.world.World;
|
import common.world.World;
|
||||||
import common.world.AWorldServer;
|
import common.world.AWorldServer;
|
||||||
|
|
||||||
|
@ -2075,7 +2074,7 @@ public abstract class EntityNPC extends EntityLiving
|
||||||
if(this.connection != null)
|
if(this.connection != null)
|
||||||
this.connection.playSound(name, volume);
|
this.connection.playSound(name, volume);
|
||||||
else if(this.client != null)
|
else if(this.client != null)
|
||||||
((AWorldClient)this.worldObj).playSound(this.posX, this.posY, this.posZ, name, volume);
|
this.worldObj.playSound(this.posX, this.posY, this.posZ, name, volume);
|
||||||
else if(!this.slave)
|
else if(!this.slave)
|
||||||
super.playSound(name, volume);
|
super.playSound(name, volume);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import common.item.ItemStack;
|
||||||
import common.tags.TagObject;
|
import common.tags.TagObject;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import common.util.BoundingBox;
|
import common.util.BoundingBox;
|
||||||
|
import common.world.AWorldServer;
|
||||||
|
|
||||||
public class TileEntityChest extends TileEntity implements ITickable, IInventory
|
public class TileEntityChest extends TileEntity implements ITickable, IInventory
|
||||||
{
|
{
|
||||||
|
@ -239,8 +240,10 @@ public class TileEntityChest extends TileEntity implements ITickable, IInventory
|
||||||
|
|
||||||
++this.numPlayersUsing;
|
++this.numPlayersUsing;
|
||||||
this.worldObj.playAuxSFX(2016, this.pos, this.numPlayersUsing);
|
this.worldObj.playAuxSFX(2016, this.pos, this.numPlayersUsing);
|
||||||
this.worldObj.notifyNeighborsOfStateChange(this.pos, this.getBlockType());
|
if(!this.worldObj.client) {
|
||||||
this.worldObj.notifyNeighborsOfStateChange(this.pos.down(), this.getBlockType());
|
((AWorldServer)this.worldObj).notifyNeighborsOfStateChange(this.pos, this.getBlockType());
|
||||||
|
((AWorldServer)this.worldObj).notifyNeighborsOfStateChange(this.pos.down(), this.getBlockType());
|
||||||
|
}
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,8 +253,10 @@ public class TileEntityChest extends TileEntity implements ITickable, IInventory
|
||||||
{
|
{
|
||||||
--this.numPlayersUsing;
|
--this.numPlayersUsing;
|
||||||
this.worldObj.playAuxSFX(2016, this.pos, this.numPlayersUsing);
|
this.worldObj.playAuxSFX(2016, this.pos, this.numPlayersUsing);
|
||||||
this.worldObj.notifyNeighborsOfStateChange(this.pos, this.getBlockType());
|
if(!this.worldObj.client) {
|
||||||
this.worldObj.notifyNeighborsOfStateChange(this.pos.down(), this.getBlockType());
|
((AWorldServer)this.worldObj).notifyNeighborsOfStateChange(this.pos, this.getBlockType());
|
||||||
|
((AWorldServer)this.worldObj).notifyNeighborsOfStateChange(this.pos.down(), this.getBlockType());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,14 @@ public class LongHashMap<V>
|
||||||
{
|
{
|
||||||
this.mask = this.hashArray.length - 1;
|
this.mask = this.hashArray.length - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
this.hashArray = new LongHashMap.Entry[4096];
|
||||||
|
this.numHashElements = 0;
|
||||||
|
this.mask = this.hashArray.length - 1;
|
||||||
|
this.capacity = 3072;
|
||||||
|
this.modCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the hashed key given the original key
|
* returns the hashed key given the original key
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
package common.world;
|
|
||||||
|
|
||||||
import common.dimension.Dimension;
|
|
||||||
import common.init.SoundEvent;
|
|
||||||
|
|
||||||
public abstract class AWorldClient extends World {
|
|
||||||
protected AWorldClient(Dimension dim) {
|
|
||||||
super(dim, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void playSound(double x, double y, double z, SoundEvent sound, float volume);
|
|
||||||
public abstract void setLastLightning(int last, int color);
|
|
||||||
}
|
|
|
@ -52,4 +52,6 @@ public abstract class AWorldServer extends World {
|
||||||
public abstract void generateTree(BlockPos pos, State state, Random rand);
|
public abstract void generateTree(BlockPos pos, State state, Random rand);
|
||||||
public abstract float getGenTemperature(int x, int z);
|
public abstract float getGenTemperature(int x, int z);
|
||||||
public abstract float getGenHumidity(int x, int z);
|
public abstract float getGenHumidity(int x, int z);
|
||||||
|
public abstract void scheduleUpdate(BlockPos pos, Block blockIn, int delay);
|
||||||
|
public abstract void notifyNeighborsOfStateChange(BlockPos pos, Block blockType);
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,14 +57,14 @@ public abstract class World implements IWorldAccess {
|
||||||
public final boolean client;
|
public final boolean client;
|
||||||
public final Random rand = new Random();
|
public final Random rand = new Random();
|
||||||
public final List<Entity> entities = Lists.<Entity>newArrayList();
|
public final List<Entity> entities = Lists.<Entity>newArrayList();
|
||||||
protected final List<Entity> unloaded = Lists.<Entity>newArrayList();
|
public final List<Entity> unloaded = Lists.<Entity>newArrayList();
|
||||||
protected final List<TileEntity> tiles = Lists.<TileEntity>newArrayList();
|
public final List<TileEntity> tiles = Lists.<TileEntity>newArrayList();
|
||||||
protected final List<TileEntity> tickable = Lists.<TileEntity>newArrayList();
|
protected final List<TileEntity> tickable = Lists.<TileEntity>newArrayList();
|
||||||
protected final List<TileEntity> addedTiles = Lists.<TileEntity>newArrayList();
|
protected final List<TileEntity> addedTiles = Lists.<TileEntity>newArrayList();
|
||||||
protected final List<TileEntity> removeTiles = Lists.<TileEntity>newArrayList();
|
protected final List<TileEntity> removeTiles = Lists.<TileEntity>newArrayList();
|
||||||
public final List<EntityNPC> players = Lists.<EntityNPC>newArrayList();
|
public final List<EntityNPC> players = Lists.<EntityNPC>newArrayList();
|
||||||
public final List<Entity> effects = Lists.<Entity>newArrayList();
|
public final List<Entity> effects = Lists.<Entity>newArrayList();
|
||||||
protected final IntHashMap<Entity> entityIds = new IntHashMap();
|
public final IntHashMap<Entity> entityIds = new IntHashMap();
|
||||||
protected final Set<ChunkPos> active = Sets.<ChunkPos>newHashSet();
|
protected final Set<ChunkPos> active = Sets.<ChunkPos>newHashSet();
|
||||||
protected final int[] lightUpdate = new int[32768];
|
protected final int[] lightUpdate = new int[32768];
|
||||||
public final Dimension dimension;
|
public final Dimension dimension;
|
||||||
|
@ -187,8 +187,6 @@ public abstract class World implements IWorldAccess {
|
||||||
return this.formatTime(player == null ? null : player.getOrigin().getDimension(), days);
|
return this.formatTime(player == null ? null : player.getOrigin().getDimension(), days);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract float getTemperature(BlockPos pos);
|
|
||||||
|
|
||||||
public boolean isAirBlock(BlockPos pos) {
|
public boolean isAirBlock(BlockPos pos) {
|
||||||
return this.getState(pos).getBlock() == Blocks.air;
|
return this.getState(pos).getBlock() == Blocks.air;
|
||||||
}
|
}
|
||||||
|
@ -240,8 +238,6 @@ public abstract class World implements IWorldAccess {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract boolean isLoaded(int x, int z, boolean allowEmpty);
|
|
||||||
|
|
||||||
public Chunk getChunk(BlockPos pos) {
|
public Chunk getChunk(BlockPos pos) {
|
||||||
return this.getChunk(pos.getX() >> 4, pos.getZ() >> 4);
|
return this.getChunk(pos.getX() >> 4, pos.getZ() >> 4);
|
||||||
}
|
}
|
||||||
|
@ -251,37 +247,19 @@ public abstract class World implements IWorldAccess {
|
||||||
* 4 prevents the block from being re-rendered on client worlds
|
* 4 prevents the block from being re-rendered on client worlds
|
||||||
*/
|
*/
|
||||||
public boolean setState(BlockPos pos, State newState, int flags) {
|
public boolean setState(BlockPos pos, State newState, int flags) {
|
||||||
if(!isValid(pos)) {
|
if(!isValid(pos))
|
||||||
return false;
|
return false;
|
||||||
}
|
Chunk chunk = this.getChunk(pos);
|
||||||
else {
|
Block block = newState.getBlock();
|
||||||
Chunk chunk = this.getChunk(pos);
|
State iblockstate = chunk.setState(pos, newState);
|
||||||
Block block = newState.getBlock();
|
if(iblockstate == null)
|
||||||
State iblockstate = chunk.setState(pos, newState);
|
return false;
|
||||||
|
Block block1 = iblockstate.getBlock();
|
||||||
if(iblockstate == null) {
|
if(block.getLightOpacity() != block1.getLightOpacity() || block.getLight() != block1.getLight())
|
||||||
return false;
|
this.checkLight(pos);
|
||||||
}
|
if((flags & 2) != 0 && (flags & 4) == 0 && chunk.isPopulated())
|
||||||
else {
|
this.markBlockForUpdate(pos);
|
||||||
Block block1 = iblockstate.getBlock();
|
return true;
|
||||||
|
|
||||||
if(block.getLightOpacity() != block1.getLightOpacity() || block.getLight() != block1.getLight()) {
|
|
||||||
// this.profiler.start("checkLight");
|
|
||||||
this.checkLight(pos);
|
|
||||||
// this.profiler.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
if((flags & 2) != 0 && (!this.client || (flags & 4) == 0) && chunk.isPopulated()) {
|
|
||||||
this.markBlockForUpdate(pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!this.client && (flags & 1) != 0) {
|
|
||||||
this.notifyNeighborsOfStateChange(pos, iblockstate.getBlock());
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setState(BlockPos pos, State state) {
|
public boolean setState(BlockPos pos, State state) {
|
||||||
|
@ -330,49 +308,6 @@ public abstract class World implements IWorldAccess {
|
||||||
this.markBlockRangeForRenderUpdate(rangeMin.getX(), rangeMin.getY(), rangeMin.getZ(), rangeMax.getX(), rangeMax.getY(), rangeMax.getZ());
|
this.markBlockRangeForRenderUpdate(rangeMin.getX(), rangeMin.getY(), rangeMin.getZ(), rangeMax.getX(), rangeMax.getY(), rangeMax.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void notifyNeighborsOfStateChange(BlockPos pos, Block blockType) {
|
|
||||||
this.notifyBlockOfStateChange(pos.west(), blockType);
|
|
||||||
this.notifyBlockOfStateChange(pos.east(), blockType);
|
|
||||||
this.notifyBlockOfStateChange(pos.down(), blockType);
|
|
||||||
this.notifyBlockOfStateChange(pos.up(), blockType);
|
|
||||||
this.notifyBlockOfStateChange(pos.north(), blockType);
|
|
||||||
this.notifyBlockOfStateChange(pos.south(), blockType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void notifyNeighborsOfStateExcept(BlockPos pos, Block blockType, Facing skipSide) {
|
|
||||||
if(skipSide != Facing.WEST) {
|
|
||||||
this.notifyBlockOfStateChange(pos.west(), blockType);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(skipSide != Facing.EAST) {
|
|
||||||
this.notifyBlockOfStateChange(pos.east(), blockType);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(skipSide != Facing.DOWN) {
|
|
||||||
this.notifyBlockOfStateChange(pos.down(), blockType);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(skipSide != Facing.UP) {
|
|
||||||
this.notifyBlockOfStateChange(pos.up(), blockType);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(skipSide != Facing.NORTH) {
|
|
||||||
this.notifyBlockOfStateChange(pos.north(), blockType);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(skipSide != Facing.SOUTH) {
|
|
||||||
this.notifyBlockOfStateChange(pos.south(), blockType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void notifyBlockOfStateChange(BlockPos pos, final Block blockIn) {
|
|
||||||
if(!this.client) {
|
|
||||||
State iblockstate = this.getState(pos);
|
|
||||||
|
|
||||||
iblockstate.getBlock().onUpdate(this, pos, iblockstate, blockIn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canSeeSky(BlockPos pos) {
|
public boolean canSeeSky(BlockPos pos) {
|
||||||
return this.getChunk(pos).canSeeSky(pos);
|
return this.getChunk(pos).canSeeSky(pos);
|
||||||
}
|
}
|
||||||
|
@ -1546,7 +1481,7 @@ public abstract class World implements IWorldAccess {
|
||||||
this.temp = this.getBaseTemperature() + this.weather.getTemperature();
|
this.temp = this.getBaseTemperature() + this.weather.getTemperature();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setActivePlayerChunksAndCheckLight(int l) {
|
public Set<ChunkPos> setActivePlayerChunksAndCheckLight(int l) {
|
||||||
this.active.clear();
|
this.active.clear();
|
||||||
// this.profiler.start("buildList");
|
// this.profiler.start("buildList");
|
||||||
|
|
||||||
|
@ -1575,6 +1510,8 @@ public abstract class World implements IWorldAccess {
|
||||||
int j2 = ExtMath.floord(entityplayer1.posZ) + this.rand.zrange(11) - 5;
|
int j2 = ExtMath.floord(entityplayer1.posZ) + this.rand.zrange(11) - 5;
|
||||||
this.checkLight(new BlockPos(l1, i2, j2));
|
this.checkLight(new BlockPos(l1, i2, j2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return this.active;
|
||||||
|
|
||||||
// this.profiler.end();
|
// this.profiler.end();
|
||||||
}
|
}
|
||||||
|
@ -2029,23 +1966,35 @@ public abstract class World implements IWorldAccess {
|
||||||
this.playAuxSFX(null, type, pos, data);
|
this.playAuxSFX(null, type, pos, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void scheduleUpdate(BlockPos pos, Block blockIn, int delay) {
|
public final void spawnParticle(ParticleType particleType, double xCoord, double yCoord, double zCoord) {
|
||||||
|
this.spawnParticle(particleType, xCoord, yCoord, zCoord, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void playSound(SoundEvent sound, double x, double y, double z, float volume) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void playSound(double x, double y, double z, SoundEvent sound, float volume) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastLightning(int last, int color) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void spawnParticle(ParticleType particleType, double xCoord, double yCoord, double zCoord, int data) {
|
public void spawnParticle(ParticleType particleType, double xCoord, double yCoord, double zCoord, int data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void spawnParticle(ParticleType particleType, double xCoord, double yCoord, double zCoord) {
|
public void markBlockRangeForRenderUpdate(int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||||
this.spawnParticle(particleType, xCoord, yCoord, zCoord, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void notifyLightSet(BlockPos pos) {
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract float getTemperature(BlockPos pos);
|
||||||
|
protected abstract boolean isLoaded(int x, int z, boolean allowEmpty);
|
||||||
public abstract Chunk getChunk(int x, int z);
|
public abstract Chunk getChunk(int x, int z);
|
||||||
public abstract void markBlockForUpdate(BlockPos pos);
|
public abstract void markBlockForUpdate(BlockPos pos);
|
||||||
protected abstract void notifyLightSet(BlockPos pos);
|
|
||||||
public abstract void markBlockRangeForRenderUpdate(int x1, int y1, int z1, int x2, int y2, int z2);
|
|
||||||
public abstract void playSound(SoundEvent sound, double x, double y, double z, float volume);
|
|
||||||
protected abstract void onEntityAdded(Entity entityIn);
|
protected abstract void onEntityAdded(Entity entityIn);
|
||||||
protected abstract void onEntityRemoved(Entity entityIn);
|
protected abstract void onEntityRemoved(Entity entityIn);
|
||||||
public abstract void playAuxSFX(EntityNPC player, int sfxType, BlockPos blockPosIn, int data);
|
public abstract void playAuxSFX(EntityNPC player, int sfxType, BlockPos blockPosIn, int data);
|
||||||
public abstract void sendBlockBreakProgress(int breakerId, BlockPos pos, int progress);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,6 +83,7 @@ import common.packet.SPacketSignEditorOpen;
|
||||||
import common.packet.SPacketPlayerAbilities;
|
import common.packet.SPacketPlayerAbilities;
|
||||||
import common.packet.SPacketTabComplete;
|
import common.packet.SPacketTabComplete;
|
||||||
import common.packet.SPacketAnimation;
|
import common.packet.SPacketAnimation;
|
||||||
|
import common.packet.SPacketBlockBreakAnim;
|
||||||
import common.packet.SPacketBlockChange;
|
import common.packet.SPacketBlockChange;
|
||||||
import common.packet.SPacketCharacterList;
|
import common.packet.SPacketCharacterList;
|
||||||
import common.packet.SPacketChunkData;
|
import common.packet.SPacketChunkData;
|
||||||
|
@ -933,6 +934,25 @@ public class Player extends User implements Executor, IPlayer
|
||||||
return new SPacketMapChunkBulk(xPositions, zPositions, chunksData, sky);
|
return new SPacketMapChunkBulk(xPositions, zPositions, chunksData, sky);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void sendBlockBreakProgress(BlockPos pos, int progress)
|
||||||
|
{
|
||||||
|
for (Player conn : this.server.getPlayers())
|
||||||
|
{
|
||||||
|
EntityNPC player = conn.getPresentEntity();
|
||||||
|
if (player != null && player.worldObj == this.entity.worldObj && player != this.entity)
|
||||||
|
{
|
||||||
|
double d0 = (double)pos.getX() - player.posX;
|
||||||
|
double d1 = (double)pos.getY() - player.posY;
|
||||||
|
double d2 = (double)pos.getZ() - player.posZ;
|
||||||
|
|
||||||
|
if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D)
|
||||||
|
{
|
||||||
|
conn.sendPacket(new SPacketBlockBreakAnim(this.entity.getId(), pos, progress));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void updateEntity()
|
public void updateEntity()
|
||||||
{
|
{
|
||||||
|
@ -1045,7 +1065,7 @@ public class Player extends User implements Executor, IPlayer
|
||||||
|
|
||||||
if (j != this.durabilityRemainingOnBlock)
|
if (j != this.durabilityRemainingOnBlock)
|
||||||
{
|
{
|
||||||
this.entity.worldObj.sendBlockBreakProgress(this.entity.getId(), this.removingPos, j);
|
this.sendBlockBreakProgress(this.removingPos, j);
|
||||||
this.durabilityRemainingOnBlock = j;
|
this.durabilityRemainingOnBlock = j;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1062,7 +1082,7 @@ public class Player extends User implements Executor, IPlayer
|
||||||
|
|
||||||
if (block1 == Blocks.air)
|
if (block1 == Blocks.air)
|
||||||
{
|
{
|
||||||
this.entity.worldObj.sendBlockBreakProgress(this.entity.getId(), this.startPos, -1);
|
this.sendBlockBreakProgress(this.startPos, -1);
|
||||||
this.durabilityRemainingOnBlock = -1;
|
this.durabilityRemainingOnBlock = -1;
|
||||||
this.isDestroyingBlock = false;
|
this.isDestroyingBlock = false;
|
||||||
}
|
}
|
||||||
|
@ -1074,7 +1094,7 @@ public class Player extends User implements Executor, IPlayer
|
||||||
|
|
||||||
if (l != this.durabilityRemainingOnBlock)
|
if (l != this.durabilityRemainingOnBlock)
|
||||||
{
|
{
|
||||||
this.entity.worldObj.sendBlockBreakProgress(this.entity.getId(), this.startPos, l);
|
this.sendBlockBreakProgress(this.startPos, l);
|
||||||
this.durabilityRemainingOnBlock = l;
|
this.durabilityRemainingOnBlock = l;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1121,7 +1141,7 @@ public class Player extends User implements Executor, IPlayer
|
||||||
this.isDestroyingBlock = true;
|
this.isDestroyingBlock = true;
|
||||||
this.startPos = pos;
|
this.startPos = pos;
|
||||||
int i = (int)(f * 10.0F);
|
int i = (int)(f * 10.0F);
|
||||||
this.entity.worldObj.sendBlockBreakProgress(this.entity.getId(), pos, i);
|
this.sendBlockBreakProgress(pos, i);
|
||||||
this.durabilityRemainingOnBlock = i;
|
this.durabilityRemainingOnBlock = i;
|
||||||
}
|
}
|
||||||
// }
|
// }
|
||||||
|
@ -1141,7 +1161,7 @@ public class Player extends User implements Executor, IPlayer
|
||||||
if (f >= 0.7F)
|
if (f >= 0.7F)
|
||||||
{
|
{
|
||||||
this.isDestroyingBlock = false;
|
this.isDestroyingBlock = false;
|
||||||
this.entity.worldObj.sendBlockBreakProgress(this.entity.getId(), pos, -1);
|
this.sendBlockBreakProgress(pos, -1);
|
||||||
this.tryHarvestBlock(pos);
|
this.tryHarvestBlock(pos);
|
||||||
}
|
}
|
||||||
else if (!this.receivedFinishDiggingPacket)
|
else if (!this.receivedFinishDiggingPacket)
|
||||||
|
@ -1158,7 +1178,7 @@ public class Player extends User implements Executor, IPlayer
|
||||||
public void cancelDestroyingBlock()
|
public void cancelDestroyingBlock()
|
||||||
{
|
{
|
||||||
this.isDestroyingBlock = false;
|
this.isDestroyingBlock = false;
|
||||||
this.entity.worldObj.sendBlockBreakProgress(this.entity.getId(), this.startPos, -1);
|
this.sendBlockBreakProgress(this.startPos, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean removeBlock(BlockPos pos)
|
private boolean removeBlock(BlockPos pos)
|
||||||
|
|
|
@ -73,6 +73,7 @@ import common.util.Vec3;
|
||||||
import common.vars.Vars;
|
import common.vars.Vars;
|
||||||
import common.village.Village;
|
import common.village.Village;
|
||||||
import common.world.BlockArray;
|
import common.world.BlockArray;
|
||||||
|
import common.world.Chunk;
|
||||||
import common.world.Explosion;
|
import common.world.Explosion;
|
||||||
import common.world.AWorldServer;
|
import common.world.AWorldServer;
|
||||||
import common.world.LightType;
|
import common.world.LightType;
|
||||||
|
@ -405,7 +406,7 @@ public final class WorldServer extends AWorldServer {
|
||||||
this.dimension.setTimeExisted(this.time += 1L);
|
this.dimension.setTimeExisted(this.time += 1L);
|
||||||
// this.dataModified = true;
|
// this.dataModified = true;
|
||||||
if(Vars.dayCycle) // {
|
if(Vars.dayCycle) // {
|
||||||
this.daytime += Vars.timeFlow;
|
this.daytime += (long)Vars.timeFlow;
|
||||||
// if(this.dimension.getType().dayCycle)
|
// if(this.dimension.getType().dayCycle)
|
||||||
// this.season = this.getSeasonByTime();
|
// this.season = this.getSeasonByTime();
|
||||||
// }
|
// }
|
||||||
|
@ -1676,14 +1677,6 @@ public final class WorldServer extends AWorldServer {
|
||||||
{
|
{
|
||||||
this.sendNear(x, y, z, volume > 1.0F ? (double)(16.0F * volume) : 16.0D, new SPacketSoundEffect(sound, x, y, z, volume));
|
this.sendNear(x, y, z, volume > 1.0F ? (double)(16.0F * volume) : 16.0D, new SPacketSoundEffect(sound, x, y, z, volume));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void markBlockRangeForRenderUpdate(int x1, int y1, int z1, int x2, int y2, int z2)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void notifyLightSet(BlockPos pos)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void playAuxSFX(EntityNPC player, int sfxType, BlockPos blockPosIn, int data)
|
public void playAuxSFX(EntityNPC player, int sfxType, BlockPos blockPosIn, int data)
|
||||||
{
|
{
|
||||||
|
@ -1695,25 +1688,6 @@ public final class WorldServer extends AWorldServer {
|
||||||
// this.server.sendPacket(new S28PacketEffect(soundID, pos, data, true));
|
// this.server.sendPacket(new S28PacketEffect(soundID, pos, data, true));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public void sendBlockBreakProgress(int breakerId, BlockPos pos, int progress)
|
|
||||||
{
|
|
||||||
for (Player conn : this.server.getPlayers())
|
|
||||||
{
|
|
||||||
EntityNPC player = conn.getPresentEntity();
|
|
||||||
if (player != null && player.worldObj == this && player.getId() != breakerId)
|
|
||||||
{
|
|
||||||
double d0 = (double)pos.getX() - player.posX;
|
|
||||||
double d1 = (double)pos.getY() - player.posY;
|
|
||||||
double d2 = (double)pos.getZ() - player.posZ;
|
|
||||||
|
|
||||||
if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D)
|
|
||||||
{
|
|
||||||
conn.sendPacket(new SPacketBlockBreakAnim(breakerId, pos, progress));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updatePlayerInstances() {
|
private void updatePlayerInstances() {
|
||||||
long time = this.time;
|
long time = this.time;
|
||||||
|
|
||||||
|
@ -2046,6 +2020,24 @@ public final class WorldServer extends AWorldServer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean setState(BlockPos pos, State newState, int flags) {
|
||||||
|
if(!isValid(pos))
|
||||||
|
return false;
|
||||||
|
Chunk chunk = this.getChunk(pos);
|
||||||
|
Block block = newState.getBlock();
|
||||||
|
State iblockstate = chunk.setState(pos, newState);
|
||||||
|
if(iblockstate == null)
|
||||||
|
return false;
|
||||||
|
Block block1 = iblockstate.getBlock();
|
||||||
|
if(block.getLightOpacity() != block1.getLightOpacity() || block.getLight() != block1.getLight())
|
||||||
|
this.checkLight(pos);
|
||||||
|
if((flags & 2) != 0 && chunk.isPopulated())
|
||||||
|
this.markBlockForUpdate(pos);
|
||||||
|
if((flags & 1) != 0)
|
||||||
|
this.notifyNeighborsOfStateChange(pos, iblockstate.getBlock());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public final boolean setBlock(BlockPos pos, ClipboardBlock block) {
|
public final boolean setBlock(BlockPos pos, ClipboardBlock block) {
|
||||||
// int x = position.getBlockX();
|
// int x = position.getBlockX();
|
||||||
|
@ -2625,6 +2617,20 @@ public final class WorldServer extends AWorldServer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void notifyNeighborsOfStateChange(BlockPos pos, Block blockType) {
|
||||||
|
this.notifyBlockOfStateChange(pos.west(), blockType);
|
||||||
|
this.notifyBlockOfStateChange(pos.east(), blockType);
|
||||||
|
this.notifyBlockOfStateChange(pos.down(), blockType);
|
||||||
|
this.notifyBlockOfStateChange(pos.up(), blockType);
|
||||||
|
this.notifyBlockOfStateChange(pos.north(), blockType);
|
||||||
|
this.notifyBlockOfStateChange(pos.south(), blockType);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void notifyBlockOfStateChange(BlockPos pos, final Block blockIn) {
|
||||||
|
State iblockstate = this.getState(pos);
|
||||||
|
iblockstate.getBlock().onUpdate(this, pos, iblockstate, blockIn);
|
||||||
|
}
|
||||||
|
|
||||||
private static SPacketMultiBlockChange getPacket(int amount, long[] list, ChunkServer chunk) {
|
private static SPacketMultiBlockChange getPacket(int amount, long[] list, ChunkServer chunk) {
|
||||||
ChunkPos pos = new ChunkPos(chunk.xPos, chunk.zPos);
|
ChunkPos pos = new ChunkPos(chunk.xPos, chunk.zPos);
|
||||||
SPacketMultiBlockChange.BlockUpdateData[] changes = new SPacketMultiBlockChange.BlockUpdateData[amount];
|
SPacketMultiBlockChange.BlockUpdateData[] changes = new SPacketMultiBlockChange.BlockUpdateData[amount];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue