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.Entry;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
@ -97,17 +98,20 @@ import client.window.Wheel;
|
|||
import client.window.Window;
|
||||
import client.window.WindowEvent;
|
||||
import client.world.ChunkClient;
|
||||
import client.world.WorldClient;
|
||||
import client.world.ChunkEmpty;
|
||||
import common.Version;
|
||||
import common.block.Block;
|
||||
import common.collect.Lists;
|
||||
import common.collect.Maps;
|
||||
import common.collect.Sets;
|
||||
import common.color.TextColor;
|
||||
import common.dimension.Dimension;
|
||||
import common.dimension.Space;
|
||||
import common.effect.Effect;
|
||||
import common.effect.StatusEffect;
|
||||
import common.entity.Entity;
|
||||
import common.entity.animal.EntityHorse;
|
||||
import common.entity.item.EntityCart;
|
||||
import common.entity.npc.Energy;
|
||||
import common.entity.npc.EntityCpu;
|
||||
import common.entity.npc.EntityNPC;
|
||||
|
@ -152,18 +156,25 @@ import common.packet.CPacketMessage;
|
|||
import common.packet.HPacketHandshake;
|
||||
import common.packet.CPacketAction.Action;
|
||||
import common.properties.Property;
|
||||
import common.rng.Random;
|
||||
import common.sound.EventType;
|
||||
import common.sound.MovingSoundMinecart;
|
||||
import common.sound.PositionedSound;
|
||||
import common.tileentity.TileEntity;
|
||||
import common.util.BlockPos;
|
||||
import common.util.BoundingBox;
|
||||
import common.util.CharValidator;
|
||||
import common.util.ChunkPos;
|
||||
import common.util.ExtMath;
|
||||
import common.util.Facing;
|
||||
import common.util.HitPosition;
|
||||
import common.util.IntHashMap;
|
||||
import common.util.LongHashMap;
|
||||
import common.util.ParticleType;
|
||||
import common.util.Util;
|
||||
import common.util.Var;
|
||||
import common.util.HitPosition.ObjectType;
|
||||
import common.vars.Vars;
|
||||
import common.world.Chunk;
|
||||
import common.world.LightType;
|
||||
import common.world.State;
|
||||
import common.world.World;
|
||||
|
@ -270,6 +281,92 @@ public class Client implements IThreadListener {
|
|||
|
||||
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 int LOG_BUFFER = 32768;
|
||||
|
@ -295,6 +392,13 @@ public class Client implements IThreadListener {
|
|||
private final long[] frames = new long[240];
|
||||
public final Map<String, Integer> playerList = Maps.<String, Integer>newTreeMap();
|
||||
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 secondary;
|
||||
|
@ -410,12 +514,19 @@ public class Client implements IThreadListener {
|
|||
private AudioInterface audio;
|
||||
private String buffer = "";
|
||||
public PlayerController controller;
|
||||
public WorldClient world;
|
||||
public World world;
|
||||
public EntityNPC player;
|
||||
public HitPosition pointed;
|
||||
public DisplayMode vidMode;
|
||||
public String dimensionName;
|
||||
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")
|
||||
|
@ -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")
|
||||
public int rainParticleRange = 10;
|
||||
@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")
|
||||
public boolean voidFog = true;
|
||||
@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.charEditor = false;
|
||||
this.controller = new PlayerController(this, player);
|
||||
WorldClient world = new WorldClient(this, Space.INSTANCE);
|
||||
this.loadWorld(world, EntityRegistry.getEntityID(EntityCpu.class));
|
||||
this.loadWorld(Space.INSTANCE, EntityRegistry.getEntityID(EntityCpu.class));
|
||||
this.player.setId(0);
|
||||
this.show(null);
|
||||
this.player.flying = true;
|
||||
|
@ -620,6 +730,7 @@ public class Client implements IThreadListener {
|
|||
this.viewEntity = null;
|
||||
this.connection = null;
|
||||
this.world = null;
|
||||
this.resetWorld();
|
||||
this.player = null;
|
||||
this.serverInfo = null;
|
||||
this.lastTickTime = -1;
|
||||
|
@ -865,21 +976,20 @@ public class Client implements IThreadListener {
|
|||
if (this.chunkLoadTimer == 30)
|
||||
{
|
||||
this.chunkLoadTimer = 0;
|
||||
this.world.ensureAreaLoaded(this.player);
|
||||
this.ensureAreaLoaded(this.player);
|
||||
}
|
||||
}
|
||||
this.entityRenderer.updateRenderer();
|
||||
this.renderGlobal.updateClouds();
|
||||
this.world.decrLightning();
|
||||
this.world.updateEntities();
|
||||
}
|
||||
this.soundManager.update();
|
||||
if (this.world != null)
|
||||
{
|
||||
this.world.tick();
|
||||
this.tickWorld();
|
||||
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();
|
||||
}
|
||||
|
@ -1209,7 +1319,7 @@ public class Client implements IThreadListener {
|
|||
if(this.cameraUsed) {
|
||||
this.cameraUsed = false;
|
||||
if(this.world != null)
|
||||
this.world.setLastLightning(1, 0xffffff);
|
||||
this.entityRenderer.setLastLightning(1, 0xffffff);
|
||||
}
|
||||
if(this.isDirty())
|
||||
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.connection = null;
|
||||
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)
|
||||
{
|
||||
|
@ -1517,11 +1633,12 @@ public class Client implements IThreadListener {
|
|||
this.viewEntity = this.player;
|
||||
|
||||
System.gc();
|
||||
return this.world;
|
||||
}
|
||||
|
||||
public void setDimensionAndSpawnPlayer(int type)
|
||||
{
|
||||
this.world.removeAllEntities();
|
||||
this.removeAllEntities();
|
||||
int i = 0;
|
||||
|
||||
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)
|
||||
+ "\n" +
|
||||
String.format("JVM-Reserviert: %d%% %dMB", totalMem * 100L / maxMem, totalMem / 1024L / 1024L);
|
||||
if(this.world == null) {
|
||||
if(this.world == null)
|
||||
return mem;
|
||||
}
|
||||
|
||||
BlockPos blockpos = new BlockPos(this.viewEntity.posX, this.viewEntity.getEntityBoundingBox().minY,
|
||||
this.viewEntity.posZ);
|
||||
|
||||
Entity entity = this.viewEntity;
|
||||
Facing facing = entity.getHorizontalFacing();
|
||||
String dirStr = "Ungültig";
|
||||
switch(facing) {
|
||||
BlockPos pos = new BlockPos(this.viewEntity.posX, this.viewEntity.getEntityBoundingBox().minY, this.viewEntity.posZ);
|
||||
String dirStr;
|
||||
switch(this.viewEntity.getHorizontalFacing()) {
|
||||
case NORTH:
|
||||
default:
|
||||
dirStr = "Norden (Nach negativer Z)";
|
||||
break;
|
||||
case SOUTH:
|
||||
|
@ -1718,28 +1831,7 @@ public class Client implements IThreadListener {
|
|||
dirStr = "Osten (Nach positiver X)";
|
||||
break;
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
ChunkClient chunk = this.getChunk(pos.getX() >> 4, pos.getZ() >> 4);
|
||||
long ticked = System.currentTimeMillis() - this.lastTicked;
|
||||
|
||||
return
|
||||
|
@ -1750,21 +1842,26 @@ public class Client implements IThreadListener {
|
|||
// this.connected != null ? this.connected : "[???]"))),
|
||||
this.renderGlobal.getDebugInfoRenders() + "\n" +
|
||||
this.renderGlobal.getDebugInfoEntities() + "\n" +
|
||||
"Partikel: " + this.effectRenderer.getParticleCount() + ". O: " + this.world.getDebugLoadedEntities() + "\n" +
|
||||
this.world.getInfo() + "\n" +
|
||||
"Partikel: " + this.effectRenderer.getParticleCount() + ". O: " + this.entities.size() + "\n" +
|
||||
"Chunk-Cache: M " + this.chunkMapping.getNumHashElements() + ", L " + this.chunkListing.size() + "\n" +
|
||||
String.format("XYZ: %.3f / %.3f / %.3f", this.viewEntity.posX,
|
||||
this.viewEntity.getEntityBoundingBox().minY, this.viewEntity.posZ) + "\n" +
|
||||
String.format("Block: %d %d %d, R: '%s/%s'", blockpos.getX(), blockpos.getY(), blockpos.getZ(),
|
||||
Util.getRegionFolder(blockpos.getX() >> 4, blockpos.getZ() >> 4),
|
||||
Util.getRegionName(blockpos.getX() >> 4, blockpos.getZ() >> 4)) + "\n" +
|
||||
String.format("Chunk: %d %d %d + %d %d %d, FOV: %.1f °%s", blockpos.getX() >> 4, blockpos.getY() >> 4, blockpos.getZ() >> 4,
|
||||
blockpos.getX() & 15, blockpos.getY() & 15, blockpos.getZ() & 15, this.zooming ?
|
||||
String.format("Block: %d %d %d, R: '%s/%s'", pos.getX(), pos.getY(), pos.getZ(),
|
||||
Util.getRegionFolder(pos.getX() >> 4, pos.getZ() >> 4),
|
||||
Util.getRegionName(pos.getX() >> 4, pos.getZ() >> 4)) + "\n" +
|
||||
String.format("Chunk: %d %d %d + %d %d %d, FOV: %.1f °%s", pos.getX() >> 4, pos.getY() >> 4, pos.getZ() >> 4,
|
||||
pos.getX() & 15, pos.getY() & 15, pos.getZ() & 15, this.zooming ?
|
||||
(this.fov / this.zoomLevel) : this.fov, this.zooming ?
|
||||
String.format(" (Zoom x%.1f)", this.zoomLevel) : "") + "\n" +
|
||||
String.format("Richtung: %s (%.1f / %.1f)", dirStr,
|
||||
ExtMath.wrapf(entity.rotYaw), ExtMath.wrapf(entity.rotPitch)) + "\n" +
|
||||
bline + "\n" +
|
||||
lline + "\n" +
|
||||
ExtMath.wrapf(this.viewEntity.rotYaw), ExtMath.wrapf(this.viewEntity.rotPitch)) + "\n" +
|
||||
String.format("Biom: %.2f K, N: %.2f K, D: %s (%s)", chunk.getTemperature(pos), chunk.getOffset(pos),
|
||||
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",
|
||||
this.world.getDayTime(),
|
||||
this.world.getDayTime() % this.world.dimension.getRotationalPeriod(),
|
||||
|
@ -1774,8 +1871,8 @@ public class Client implements IThreadListener {
|
|||
) + "\n" +
|
||||
String.format("Laub: %s%s, T: %.2f K / %.2f °C, %s (R %.1f, %.1f)",
|
||||
!this.world.dimension.hasSeasons() ? "*" : "",
|
||||
this.world.getLeavesGen(blockpos).getDisplayName(),
|
||||
this.world.getTemperatureK(blockpos), this.world.getTemperatureC(blockpos),
|
||||
this.world.getLeavesGen(pos).getDisplayName(),
|
||||
this.world.getTemperatureK(pos), this.world.getTemperatureC(pos),
|
||||
this.world.getWeather().getDisplay(), this.world.getRainStrength(),
|
||||
this.world.getDarkness()
|
||||
) + "\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) {
|
||||
byte[] data = new byte[w * h * 4];
|
||||
byte[] color = new byte[24];
|
||||
|
|
|
@ -24,7 +24,6 @@ import client.gui.ingame.GuiForm;
|
|||
import client.renderer.texture.EntityTexManager;
|
||||
import client.util.PlayerController;
|
||||
import client.world.ChunkClient;
|
||||
import client.world.WorldClient;
|
||||
import common.block.Block;
|
||||
import common.block.tech.BlockAnvil;
|
||||
import common.block.tech.BlockChest;
|
||||
|
@ -44,9 +43,11 @@ import common.entity.npc.EntityNPC;
|
|||
import common.entity.npc.PlayerCharacter;
|
||||
import common.entity.projectile.EntityProjectile;
|
||||
import common.entity.types.EntityLiving;
|
||||
import common.init.BlockRegistry;
|
||||
import common.init.Blocks;
|
||||
import common.init.EntityRegistry;
|
||||
import common.init.ItemRegistry;
|
||||
import common.init.Items;
|
||||
import common.init.SoundEvent;
|
||||
import common.init.UniverseRegistry;
|
||||
import common.inventory.Container;
|
||||
|
@ -54,6 +55,7 @@ import common.inventory.InventoryBasic;
|
|||
import common.inventory.InventoryPlayer;
|
||||
import common.inventory.InventoryWarpChest;
|
||||
import common.item.ItemStack;
|
||||
import common.item.material.ItemDye;
|
||||
import common.log.Log;
|
||||
import common.network.IClientPlayer;
|
||||
import common.network.NetConnection;
|
||||
|
@ -124,15 +126,21 @@ import common.packet.SPacketTrades;
|
|||
import common.packet.SPacketUpdateDisplay;
|
||||
import common.packet.SPacketUpdateHealth;
|
||||
import common.rng.Random;
|
||||
import common.sound.PositionedSound;
|
||||
import common.sound.Sound;
|
||||
import common.tileentity.TileEntity;
|
||||
import common.tileentity.TileEntityChest;
|
||||
import common.tileentity.Device;
|
||||
import common.tileentity.TileEntityDisplay;
|
||||
import common.tileentity.TileEntitySign;
|
||||
import common.util.BlockPos;
|
||||
import common.util.Pair;
|
||||
import common.util.ParticleType;
|
||||
import common.util.WorldPos;
|
||||
import common.util.BlockPos.MutableBlockPos;
|
||||
import common.village.MerchantRecipeList;
|
||||
import common.world.Explosion;
|
||||
import common.world.State;
|
||||
import common.world.Weather;
|
||||
import common.world.World;
|
||||
|
||||
|
@ -140,7 +148,7 @@ public class ClientPlayer implements IClientPlayer
|
|||
{
|
||||
protected final Client gm;
|
||||
private final NetConnection connection;
|
||||
private WorldClient world;
|
||||
private World world;
|
||||
private boolean loaded;
|
||||
private final Random rand = new Random();
|
||||
|
||||
|
@ -236,9 +244,8 @@ public class ClientPlayer implements IClientPlayer
|
|||
this.gm.dimensionName = packetIn.getDimName();
|
||||
this.gm.charEditor = packetIn.isInEditor();
|
||||
this.gm.controller = new PlayerController(this.gm, this);
|
||||
this.world = new WorldClient(this.gm, packetIn.getDimension());
|
||||
// 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.gm.player.setId(packetIn.getEntityId());
|
||||
this.gm.show(this.gm.charEditor ? GuiChar.INSTANCE : null);
|
||||
|
@ -400,7 +407,7 @@ public class ClientPlayer implements IClientPlayer
|
|||
}
|
||||
|
||||
entity.setId(packetIn.getEntityID());
|
||||
this.world.addEntityToWorld(packetIn.getEntityID(), entity);
|
||||
this.gm.addEntityToWorld(packetIn.getEntityID(), entity);
|
||||
|
||||
if(entity instanceof EntityProjectile projectile) {
|
||||
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);
|
||||
this.world.addEntityToWorld(packetIn.getEntityID(), player);
|
||||
this.gm.addEntityToWorld(packetIn.getEntityID(), player);
|
||||
List<DataWatcher.WatchableObject> list = packetIn.getData();
|
||||
|
||||
if (list != null)
|
||||
|
@ -647,7 +654,7 @@ public class ClientPlayer implements IClientPlayer
|
|||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -713,7 +720,7 @@ public class ClientPlayer implements IClientPlayer
|
|||
this.gm.player.prevY = this.gm.player.posY;
|
||||
this.gm.player.prevZ = this.gm.player.posZ;
|
||||
this.loaded = true;
|
||||
this.world.markReload();
|
||||
this.gm.markReload();
|
||||
// this.gameController.displayGuiScreen(null);
|
||||
// if(this.travelSound) {
|
||||
// this.gameController.getSoundManager().playSound(new PositionedSound(SoundEvent.TELEPORT));
|
||||
|
@ -734,7 +741,7 @@ public class ClientPlayer implements IClientPlayer
|
|||
|
||||
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)
|
||||
{
|
||||
this.world.doPreChunk(packetIn.getChunkX(), packetIn.getChunkZ(), false);
|
||||
this.gm.doPreChunk(packetIn.getChunkX(), packetIn.getChunkZ(), false);
|
||||
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);
|
||||
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());
|
||||
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
|
||||
{
|
||||
|
@ -773,7 +780,7 @@ public class ClientPlayer implements IClientPlayer
|
|||
public void handleBlockChange(SPacketBlockChange packetIn)
|
||||
{
|
||||
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.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.motionY = (double)((float)packetIn.getVelocityY() / 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();
|
||||
|
||||
if (list != null)
|
||||
|
@ -1082,9 +1089,8 @@ public class ClientPlayer implements IClientPlayer
|
|||
// this.travelSound = "portal.travel";
|
||||
// }
|
||||
// Scoreboard scoreboard = this.clientWorldController.getScoreboard();
|
||||
this.world = new WorldClient(this.gm, dim);
|
||||
// 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();
|
||||
}
|
||||
// else if(this.gameController.charEditor) {
|
||||
|
@ -1376,7 +1382,7 @@ public class ClientPlayer implements IClientPlayer
|
|||
public void handleBlockBreakAnim(SPacketBlockBreakAnim packetIn)
|
||||
{
|
||||
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)
|
||||
|
@ -1387,11 +1393,11 @@ public class ClientPlayer implements IClientPlayer
|
|||
{
|
||||
int j = packetIn.getChunkX(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);
|
||||
ChunkClient chunk = this.world.getChunk(j, k);
|
||||
ChunkClient chunk = this.gm.getChunk(j, k);
|
||||
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
|
||||
{
|
||||
|
@ -1430,14 +1436,181 @@ public class ClientPlayer implements IClientPlayer
|
|||
{
|
||||
NetHandler.checkThread(packetIn, this, this.gm, this.world);
|
||||
|
||||
// if (packetIn.isSoundServerwide())
|
||||
// {
|
||||
// this.gameController.theWorld.broadcastSound(packetIn.getSoundType(), packetIn.getSoundPos(), packetIn.getSoundData());
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
this.gm.world.playAuxSFX(packetIn.getSoundType(), packetIn.getSoundPos(), packetIn.getSoundData());
|
||||
// }
|
||||
this.playAuxSFX(packetIn.getSoundType(), packetIn.getSoundPos(), packetIn.getSoundData());
|
||||
}
|
||||
|
||||
private void spawnParticle(ParticleType particle, double xCoord, double yCoord, double zCoord, int data) {
|
||||
this.gm.effectRenderer.spawnParticle(this.gm.getRenderViewEntity(), particle, xCoord, yCoord, zCoord, data);
|
||||
}
|
||||
|
||||
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#")) {
|
||||
// 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)
|
||||
|
@ -1891,7 +2064,7 @@ public class ClientPlayer implements IClientPlayer
|
|||
|
||||
public void handleCelestials(SPacketCelestials packet) {
|
||||
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) {
|
||||
this.world.dimension.setSunColor(packet.getSunColor());
|
||||
this.world.dimension.setMoonColors(packet.getMoonColors());
|
||||
|
|
|
@ -1062,12 +1062,19 @@ public class EffectRenderer {
|
|||
this.layers[i].add(effect);
|
||||
}
|
||||
|
||||
public void spawnParticle(ParticleType type, double x, double y, double z, int data) {
|
||||
Creator creator = this.types.get(type);
|
||||
if(creator != null) {
|
||||
Effect effect = creator.create(x, y, z, data);
|
||||
if(effect != null)
|
||||
this.add(effect);
|
||||
public void spawnParticle(Entity entity, ParticleType type, double x, double y, double z, int data) {
|
||||
if(entity != null) {
|
||||
double dx = entity.posX - x;
|
||||
double dy = entity.posY - y;
|
||||
double dz = entity.posZ - z;
|
||||
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.renderer.texture.DynamicTexture;
|
||||
import client.renderer.texture.TextureMap;
|
||||
import client.world.WorldClient;
|
||||
import common.block.Block;
|
||||
import common.block.Material;
|
||||
import common.effect.Effect;
|
||||
|
@ -25,6 +24,7 @@ import common.init.Items;
|
|||
import common.init.SoundEvent;
|
||||
import common.model.BlockLayer;
|
||||
import common.rng.Random;
|
||||
import common.sound.PositionedSound;
|
||||
import common.util.BlockPos;
|
||||
import common.util.BoundingBox;
|
||||
import common.util.ExtMath;
|
||||
|
@ -70,6 +70,8 @@ public class EntityRenderer {
|
|||
private double cameraYaw;
|
||||
private double cameraPitch;
|
||||
private int frameCount;
|
||||
private int lastLightning;
|
||||
private Vec3 lightColor = new Vec3(0xffffff);
|
||||
|
||||
public EntityRenderer(Client gmIn)
|
||||
{
|
||||
|
@ -139,6 +141,8 @@ public class EntityRenderer {
|
|||
++this.rendererUpdateCount;
|
||||
this.itemRenderer.update();
|
||||
this.addRainParticles();
|
||||
if(this.lastLightning > 0)
|
||||
this.lastLightning -= 1;
|
||||
// this.bossColorModifierPrev = this.bossColorModifier;
|
||||
//
|
||||
// if (BossStatus.hasColorModifier)
|
||||
|
@ -317,19 +321,6 @@ public class EntityRenderer {
|
|||
{
|
||||
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)
|
||||
{
|
||||
int i = player.getItemInUseDuration();
|
||||
|
@ -349,6 +340,65 @@ public class EntityRenderer {
|
|||
|
||||
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
|
||||
|
@ -737,18 +787,163 @@ public class EntityRenderer {
|
|||
this.torchFlickerX += (this.torchFlickerDX - this.torchFlickerX) * 1.0F;
|
||||
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)
|
||||
{
|
||||
if (this.lightmapUpdateNeeded)
|
||||
{
|
||||
WorldClient world = this.gm.world;
|
||||
World world = this.gm.world;
|
||||
|
||||
if (world != null)
|
||||
{
|
||||
float sun = world.getSunBrightness(1.0F);
|
||||
float sun = this.getSunBrightness(1.0F);
|
||||
float msun = sun * 0.95F + 0.05F;
|
||||
float space = world.getSpaceFactor();
|
||||
float space = this.getSpaceFactor();
|
||||
float brightness = (float)world.dimension.getBrightness() / 15.0f;
|
||||
|
||||
for (int n = 0; n < 256; ++n)
|
||||
|
@ -774,16 +969,15 @@ public class EntityRenderer {
|
|||
sgreen = sgreen * (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)world.getLastLightning() - partialTicks;
|
||||
float intens = (float)this.lastLightning - partialTicks;
|
||||
if(intens > 1.0F)
|
||||
intens = 1.0F;
|
||||
float light = world.dimension.hasSkyLight() ? rsky : 1.0f;
|
||||
sred = sred * (1.0F - intens) + (float)lightColor.xCoord * light * intens;
|
||||
sgreen = sgreen * (1.0F - intens) + (float)lightColor.yCoord * light * intens;
|
||||
sblue = sblue * (1.0F - intens) + (float)lightColor.zCoord * light * intens;
|
||||
sred = sred * (1.0F - intens) + (float)this.lightColor.xCoord * light * intens;
|
||||
sgreen = sgreen * (1.0F - intens) + (float)this.lightColor.yCoord * light * intens;
|
||||
sblue = sblue * (1.0F - intens) + (float)this.lightColor.zCoord * light * intens;
|
||||
}
|
||||
|
||||
float bred = block;
|
||||
|
@ -1088,7 +1282,7 @@ public class EntityRenderer {
|
|||
GL11.glPushMatrix();
|
||||
this.setupFog(0, 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)
|
||||
renderGlobalIn.renderClouds(alpha, partialTicks);
|
||||
GlState.disableFog();
|
||||
|
@ -1185,11 +1379,11 @@ public class EntityRenderer {
|
|||
|
||||
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
|
||||
{
|
||||
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)
|
||||
{
|
||||
WorldClient world = this.gm.world;
|
||||
World world = this.gm.world;
|
||||
Entity entity = this.gm.getRenderViewEntity();
|
||||
|
||||
Vec3 fog = new Vec3(world.dimension.getFogColor());
|
||||
|
@ -1351,7 +1545,7 @@ public class EntityRenderer {
|
|||
this.fogColorBlue = this.fogColorBlue * (sun * 0.91F + 0.09F);
|
||||
}
|
||||
|
||||
float space = world.getSpaceFactor();
|
||||
float space = this.getSpaceFactor();
|
||||
if(space > 0.0f) {
|
||||
this.fogColorRed = this.fogColorRed * (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;
|
||||
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.fogColorGreen += ((float)sky.yCoord - this.fogColorGreen) * dist;
|
||||
this.fogColorBlue += ((float)sky.zCoord - this.fogColorBlue) * dist;
|
||||
|
|
|
@ -3,7 +3,7 @@ package client.renderer;
|
|||
import java.util.Arrays;
|
||||
|
||||
import client.world.ChunkClient;
|
||||
import client.world.WorldClient;
|
||||
import client.Client;
|
||||
import common.init.Blocks;
|
||||
import common.tileentity.TileEntity;
|
||||
import common.util.BlockPos;
|
||||
|
@ -21,15 +21,15 @@ public class RegionRenderCache implements IWorldAccess
|
|||
private final int xPos;
|
||||
private final int zPos;
|
||||
private final ChunkClient[][] chunks;
|
||||
private final World world;
|
||||
private final boolean sky;
|
||||
private final BlockPos position;
|
||||
private final boolean empty;
|
||||
private int[] combinedLights;
|
||||
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.zPos = from.getZ() - 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)
|
||||
{
|
||||
if (p_175629_1_ == LightType.SKY && !this.world.dimension.hasSkyLight())
|
||||
if (p_175629_1_ == LightType.SKY && !this.sky)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ import client.renderer.texture.TextureManager;
|
|||
import client.renderer.texture.TextureMap;
|
||||
import client.renderer.tileentity.SpecialRenderer;
|
||||
import client.world.ChunkClient;
|
||||
import client.world.WorldClient;
|
||||
import common.block.Block;
|
||||
import common.collect.Lists;
|
||||
import common.collect.Maps;
|
||||
|
@ -116,7 +115,7 @@ public class RenderGlobal
|
|||
private final TextureManager renderEngine;
|
||||
private final RenderManager renderManager;
|
||||
private final Random rand = new Random();
|
||||
private WorldClient theWorld;
|
||||
private World theWorld;
|
||||
private Set<RenderChunk> chunksToUpdate = new LinkedHashSet<RenderChunk>();
|
||||
private List<RenderGlobal.ContainerLocalRenderInformation> renderInfos = new ArrayList<ContainerLocalRenderInformation>(69696);
|
||||
private final Set<TileEntity> setTileEntities = Sets.<TileEntity>newHashSet();
|
||||
|
@ -409,7 +408,7 @@ public class RenderGlobal
|
|||
/**
|
||||
* set null to clear
|
||||
*/
|
||||
public void setWorldAndLoadRenderers(WorldClient worldClientIn)
|
||||
public void setWorldAndLoadRenderers(World worldClientIn)
|
||||
{
|
||||
// if (this.theWorld != null)
|
||||
// {
|
||||
|
@ -455,7 +454,7 @@ public class RenderGlobal
|
|||
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)
|
||||
{
|
||||
|
@ -506,7 +505,7 @@ public class RenderGlobal
|
|||
SpecialRenderer.entityZ = d5;
|
||||
this.renderManager.setRenderPosition(d3, d4, d5);
|
||||
this.gm.entityRenderer.enableLightmap();
|
||||
List<Entity> list = this.theWorld.getLoadedEntityList();
|
||||
List<Entity> list = this.gm.getEntities();
|
||||
this.countEntitiesTotal = list.size();
|
||||
|
||||
for (int i = 0; i < this.theWorld.effects.size(); ++i)
|
||||
|
@ -531,7 +530,7 @@ public class RenderGlobal
|
|||
GlState.disableTexture2D();
|
||||
GlState.depthMask(false);
|
||||
|
||||
List<TileEntity> tiles = this.theWorld.getLoadedTileList();
|
||||
List<TileEntity> tiles = this.gm.getTiles();
|
||||
|
||||
for (int j = 0; j < tiles.size(); ++j)
|
||||
{
|
||||
|
@ -601,10 +600,10 @@ public class RenderGlobal
|
|||
|
||||
label738:
|
||||
|
||||
for (RenderGlobal.ContainerLocalRenderInformation renderglobal$containerlocalrenderinformation : this.renderInfos)
|
||||
for (RenderGlobal.ContainerLocalRenderInformation render : this.renderInfos)
|
||||
{
|
||||
ChunkClient chunk = this.theWorld.getChunk(renderglobal$containerlocalrenderinformation.renderChunk.getPosition());
|
||||
InheritanceMultiMap<Entity> classinheritancemultimap = chunk.getEntities()[ExtMath.clampi(renderglobal$containerlocalrenderinformation.renderChunk.getPosition().getY() / 16, 0, 31)];
|
||||
ChunkClient chunk = this.gm.getChunk(render.renderChunk.getPosition().getX() >> 4, render.renderChunk.getPosition().getZ() >> 4);
|
||||
InheritanceMultiMap<Entity> classinheritancemultimap = chunk.getEntities()[ExtMath.clampi(render.renderChunk.getPosition().getY() / 16, 0, 31)];
|
||||
|
||||
if (!classinheritancemultimap.isEmpty())
|
||||
{
|
||||
|
@ -897,7 +896,7 @@ public class RenderGlobal
|
|||
{
|
||||
VisGraph visgraph = new VisGraph();
|
||||
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)))
|
||||
{
|
||||
|
@ -1117,7 +1116,7 @@ public class RenderGlobal
|
|||
else if (this.gm.world.dimension.hasSky())
|
||||
{
|
||||
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 f1 = (float)vec3.yCoord;
|
||||
float f2 = (float)vec3.zCoord;
|
||||
|
@ -1252,7 +1251,7 @@ public class RenderGlobal
|
|||
}
|
||||
GlState.disableTexture2D();
|
||||
|
||||
float f15 = this.theWorld.getStarBrightness(partialTicks) * f16;
|
||||
float f15 = this.gm.entityRenderer.getStarBrightness(partialTicks) * f16;
|
||||
if (f15 > 0.0F)
|
||||
{
|
||||
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)
|
||||
{
|
||||
int stars = this.theWorld.dimension.getDeepStarColor(this.theWorld.getDayTime());
|
||||
|
@ -1335,7 +1334,7 @@ public class RenderGlobal
|
|||
this.renderEngine.bindTexture(this.gm.world.dimension.getCloudTexture());
|
||||
GlState.enableBlend();
|
||||
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 f5 = (float)vec3.yCoord;
|
||||
float f6 = (float)vec3.zCoord;
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
package client.renderer;
|
||||
|
||||
import client.renderer.chunk.RenderChunk;
|
||||
import client.world.WorldClient;
|
||||
import client.Client;
|
||||
import common.util.BlockPos;
|
||||
import common.util.ExtMath;
|
||||
|
||||
public class ViewFrustum
|
||||
{
|
||||
protected final RenderGlobal renderGlobal;
|
||||
protected final WorldClient world;
|
||||
protected final Client gm;
|
||||
protected int countChunksY;
|
||||
protected int countChunksX;
|
||||
protected int countChunksZ;
|
||||
|
@ -18,10 +18,10 @@ public class ViewFrustum
|
|||
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.world = worldIn;
|
||||
this.gm = worldIn;
|
||||
this.setCountChunksXYZ(renderDistanceChunks);
|
||||
this.createRenderChunks();
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class ViewFrustum
|
|||
{
|
||||
int j1 = (i1 * this.countChunksY + l) * this.countChunksX + k;
|
||||
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.tileentity.SpecialRenderer;
|
||||
import client.renderer.tileentity.ElementRenderer;
|
||||
import client.world.WorldClient;
|
||||
import common.block.Block;
|
||||
import common.block.ITileEntityProvider;
|
||||
import common.collect.Maps;
|
||||
|
@ -33,7 +32,7 @@ import common.world.State;
|
|||
|
||||
public class RenderChunk
|
||||
{
|
||||
private WorldClient world;
|
||||
private Client gm;
|
||||
private final RenderGlobal renderGlobal;
|
||||
public static int renderChunksUpdated;
|
||||
private BlockPos position;
|
||||
|
@ -50,9 +49,9 @@ public class RenderChunk
|
|||
private boolean needsUpdate = true;
|
||||
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.index = indexIn;
|
||||
|
||||
|
@ -127,7 +126,7 @@ public class RenderChunk
|
|||
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);
|
||||
}
|
||||
finally
|
||||
|
@ -142,7 +141,7 @@ public class RenderChunk
|
|||
{
|
||||
++renderChunksUpdated;
|
||||
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))
|
||||
{
|
||||
|
@ -355,7 +354,7 @@ public class RenderChunk
|
|||
public void deleteGlResources()
|
||||
{
|
||||
this.stopCompileTask();
|
||||
this.world = null;
|
||||
this.gm = null;
|
||||
|
||||
for (int i = 0; i < BlockLayer.values().length; ++i)
|
||||
{
|
||||
|
|
|
@ -5,13 +5,13 @@ import java.util.Map;
|
|||
import org.lwjgl.opengl.GL13;
|
||||
|
||||
import client.renderer.GlState;
|
||||
import client.world.WorldClient;
|
||||
import common.collect.Maps;
|
||||
import common.entity.Entity;
|
||||
import common.tileentity.TileEntity;
|
||||
import common.tileentity.TileEntityDisplay;
|
||||
import common.tileentity.TileEntitySign;
|
||||
import common.util.BlockPos;
|
||||
import common.world.World;
|
||||
|
||||
public class 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 WorldClient world;
|
||||
private World world;
|
||||
private double posX;
|
||||
private double posY;
|
||||
private double posZ;
|
||||
|
@ -44,7 +44,7 @@ public class SpecialRenderer {
|
|||
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.posX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double)partial;
|
||||
this.posY = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double)partial;
|
||||
|
|
|
@ -2,7 +2,6 @@ package client.util;
|
|||
|
||||
import client.Client;
|
||||
import client.network.ClientPlayer;
|
||||
import client.world.WorldClient;
|
||||
import common.block.Block;
|
||||
import common.dimension.Dimension;
|
||||
import common.dimension.Space;
|
||||
|
@ -114,7 +113,7 @@ public class PlayerController {
|
|||
this.stack = this.gm.player.getHeldItem();
|
||||
this.damage = 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.hitting = false;
|
||||
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.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;
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
float f = (float)(hit.xCoord - (double)pos.getX());
|
||||
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);
|
||||
player.setClientPlayer(this.handler);
|
||||
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.world.LightType;
|
||||
import common.world.State;
|
||||
import common.world.World;
|
||||
|
||||
public class ChunkEmpty extends ChunkClient {
|
||||
private static final List<State> STATES = Lists.<State>newArrayList();
|
||||
|
@ -54,7 +55,7 @@ public class ChunkEmpty extends ChunkClient {
|
|||
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);
|
||||
this.debug = debug;
|
||||
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();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue