server client split world classes

This commit is contained in:
Sen 2025-05-13 17:02:57 +02:00
parent 66e9f68eee
commit 6e77090c5b
247 changed files with 1309 additions and 1187 deletions

View file

@ -66,7 +66,6 @@ import client.renderer.chunk.RenderChunk;
import client.renderer.entity.RenderItem;
import client.renderer.entity.RenderManager;
import client.renderer.particle.EffectRenderer;
import client.renderer.particle.EntityFirework;
import client.renderer.texture.ColormapLoader;
import client.renderer.texture.EntityTexManager;
import client.renderer.texture.TextureManager;
@ -95,7 +94,7 @@ import client.window.Keysym;
import client.window.Wheel;
import client.window.Window;
import client.window.WindowEvent;
import common.IClient;
import client.world.WorldClient;
import common.biome.Biome;
import common.block.Block;
import common.collect.Lists;
@ -106,7 +105,6 @@ import common.entity.animal.EntityHorse;
import common.entity.npc.Energy;
import common.entity.npc.EntityNPC;
import common.entity.types.EntityLiving;
import common.entity.types.IEntityFX;
import common.future.Futures;
import common.future.ListenableFuture;
import common.future.ListenableFutureTask;
@ -127,8 +125,6 @@ import common.log.Log;
import common.log.LogLevel;
import common.log.Message;
import common.material.Material;
import common.model.ParticleType;
import common.nbt.NBTTagCompound;
import common.network.IThreadListener;
import common.network.NetConnection;
import common.network.PacketDecoder;
@ -149,7 +145,6 @@ import common.properties.IProperty;
import common.rng.Random;
import common.sound.EventType;
import common.sound.PositionedSound;
import common.sound.Sound;
import common.util.BlockPos;
import common.util.BoundingBox;
import common.util.CharValidator;
@ -164,7 +159,6 @@ import common.world.Chunk;
import common.world.LightType;
import common.world.State;
import common.world.World;
import common.world.WorldClient;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.Channel;
import io.netty.channel.ChannelException;
@ -196,7 +190,7 @@ import io.netty.handler.timeout.ReadTimeoutHandler;
[[oder einfach einen Toaster mit nem LCD und Maus]]
*/
public class Client implements IThreadListener, IClient {
public class Client implements IThreadListener {
public static class SyncFunction implements IntFunction {
public void apply(IntVar cv, int value) {
Client.CLIENT.sync(value);
@ -1271,7 +1265,7 @@ public class Client implements IThreadListener, IClient {
if ((this.pointed.type != ObjectType.BLOCK || this.world.getState(this.pointed.block).getBlock().getMaterial() == Material.air) && itemstack != null && itemstack.getItem().onAction(itemstack, this.player, this.world, ItemControl.PRIMARY, null))
{
this.player.swingItem();
this.player.sendQueue.addToSendQueue(new CPacketAction(Action.ITEM_ACTION, ItemControl.PRIMARY.ordinal()));
this.player.client.addToSendQueue(new CPacketAction(Action.ITEM_ACTION, ItemControl.PRIMARY.ordinal()));
this.leftClickCounter = 10;
return;
}
@ -1323,7 +1317,7 @@ public class Client implements IThreadListener, IClient {
if ((this.pointed.type != ObjectType.BLOCK || this.world.getState(this.pointed.block).getBlock().getMaterial() == Material.air) && itemstack != null && itemstack.getItem().onAction(itemstack, this.player, this.world, ItemControl.SECONDARY, null))
{
this.player.swingItem();
this.player.sendQueue.addToSendQueue(new CPacketAction(Action.ITEM_ACTION, ItemControl.SECONDARY.ordinal()));
this.player.client.addToSendQueue(new CPacketAction(Action.ITEM_ACTION, ItemControl.SECONDARY.ordinal()));
return;
}
@ -1389,7 +1383,7 @@ public class Client implements IThreadListener, IClient {
if (this.pointed != null)
{
if(this.player.getHeldItem() != null && this.player.getHeldItem().getItem().onAction(this.player.getHeldItem(), this.player, this.world, ItemControl.TERTIARY, null)) {
this.player.sendQueue.addToSendQueue(new CPacketAction(Action.ITEM_ACTION, ItemControl.TERTIARY.ordinal()));
this.player.client.addToSendQueue(new CPacketAction(Action.ITEM_ACTION, ItemControl.TERTIARY.ordinal()));
return;
}
@ -1436,7 +1430,7 @@ public class Client implements IThreadListener, IClient {
inventoryplayer.setCurrentItem(item, meta, flag1);
if(this.itemCheat) {
this.player.sendQueue.addToSendQueue(new CPacketCheat(new ItemStack(item, 1, meta), inventoryplayer.currentItem, this.ctrl()));
this.player.client.addToSendQueue(new CPacketCheat(new ItemStack(item, 1, meta), inventoryplayer.currentItem, this.ctrl()));
}
}
}
@ -1446,7 +1440,7 @@ public class Client implements IThreadListener, IClient {
if (this.pointed != null)
{
if(this.player.getHeldItem() != null && this.player.getHeldItem().getItem().onAction(this.player.getHeldItem(), this.player, this.world, ItemControl.QUARTERNARY, null)) {
this.player.sendQueue.addToSendQueue(new CPacketAction(Action.ITEM_ACTION, ItemControl.QUARTERNARY.ordinal()));
this.player.client.addToSendQueue(new CPacketAction(Action.ITEM_ACTION, ItemControl.QUARTERNARY.ordinal()));
return;
}
}
@ -1522,7 +1516,7 @@ public class Client implements IThreadListener, IClient {
public ClientPlayer getNetHandler()
{
return this.player != null ? (ClientPlayer)this.player.sendQueue : null;
return this.player != null ? (ClientPlayer)this.player.client : null;
}
// public void setSkin(BufferedImage skin, String id, ModelType model, boolean slim)
@ -1569,7 +1563,7 @@ public class Client implements IThreadListener, IClient {
public void performAction(Action action) {
if(this.player != null)
this.player.sendQueue.addToSendQueue(new CPacketAction(action));
this.player.client.addToSendQueue(new CPacketAction(action));
}
public void setBossStatus(EntityLiving entity) {
@ -1805,7 +1799,7 @@ public class Client implements IThreadListener, IClient {
ticked / 1000L, (ticked / 100L) % 10L
) +
(this.serverInfo != null ? "\n" + this.serverInfo : "")
// WorldServer world = this.server.getWorld(this.theWorld.dimension.getDimensionId());
// IWorldServer world = this.server.getWorld(this.theWorld.dimension.getDimensionId());
// if(world != null)
// list.add("Seed: " + world.getSeed());
;
@ -3342,82 +3336,4 @@ public class Client implements IThreadListener, IClient {
}
}, "File Browser listener").start();
}
public void makeFireworks(double x, double y, double z, double motionX, double motionY, double motionZ, NBTTagCompound compund)
{
this.effectRenderer.addEffect(new EntityFirework.StarterFX(this.world, x, y, z, motionX, motionY, motionZ, this.effectRenderer, compund));
}
public int getRenderDistance() {
return this.renderDistance;
}
public float getGravity() {
return this.gravity;
}
public int getTimeFactor() {
return this.timeFactor;
}
public boolean hasDayCycle() {
return this.dayCycle;
}
public void playSound(Sound sound) {
this.soundManager.playSound(sound);
}
public EntityNPC getPlayer() {
return this.player;
}
public IEntityFX spawnEffectParticle(int particleId, double xCoord, double yCoord, double zCoord, double xSpeed, double ySpeed, double zSpeed,
int[] parameters) {
return this.effectRenderer.spawnEffectParticle(particleId, xCoord, yCoord, zCoord, xSpeed, ySpeed, zSpeed, parameters);
}
public void addBlockDestroyEffects(BlockPos pos, State state) {
this.effectRenderer.addBlockDestroyEffects(pos, state);
}
public void sendBlockBreakProgress(int breakerId, BlockPos pos, int progress) {
this.renderGlobal.sendBlockBreakProgress(breakerId, pos, progress);
}
public void markBlocksForUpdate(int x1, int y1, int z1, int x2, int y2, int z2) {
this.renderGlobal.markBlocksForUpdate(x1, y1, z1, x2, y2, z2);
}
public void emitParticleAtEntity(Entity entityIn, ParticleType particleTypes) {
this.effectRenderer.emitParticleAtEntity(entityIn, particleTypes);
}
public boolean isJumping() {
return this.jump;
}
public boolean isSprinting() {
return this.sprint;
}
public boolean isSneaking() {
return this.sneak;
}
public float getMoveForward() {
return this.moveForward;
}
public float getMoveStrafe() {
return this.moveStrafe;
}
public void setMoveForward(float value) {
this.moveForward = value;
}
public void setMoveStrafe(float value) {
this.moveStrafe = value;
}
}

View file

@ -1,6 +1,7 @@
package client;
import client.network.ClientPlayer;
import client.world.WorldClient;
import common.block.Block;
import common.entity.Entity;
import common.entity.npc.EntityNPC;
@ -20,7 +21,6 @@ import common.util.Facing;
import common.util.Vec3;
import common.world.State;
import common.world.World;
import common.world.WorldClient;
public class PlayerController
{
@ -471,7 +471,7 @@ public class PlayerController
public EntityNPC createPlayerEntity(WorldClient worldIn, int type)
{
EntityNPC player = (EntityNPC)EntityRegistry.createEntityByID(type, worldIn);
player.setClientPlayer(this.gm, this.netClientHandler);
player.setClientPlayer(this.netClientHandler);
return player;
}

View file

@ -215,7 +215,7 @@ public class GuiConsole extends Gui implements Textbox.Callback {
s = argv[argv.length - 1];
Iterable<String> res = pre.startsWith("#") ?
(argv.length == 1 ? this.gm.getVars() : (argv.length == 2 ? getVarCompletion(argv[0].substring(1)) : Lists.newArrayList())) :
(this.gm.player == null ? Lists.newArrayList() : ((ClientPlayer)this.gm.player.sendQueue).getPlayerNames());
(this.gm.player == null ? Lists.newArrayList() : ((ClientPlayer)this.gm.player.client).getPlayerNames());
if(argv.length == 1 && pre.startsWith("#"))
s = s.substring(1);
for(String s1 : res) {
@ -255,7 +255,7 @@ public class GuiConsole extends Gui implements Textbox.Callback {
if(this.gm.player != null) {
currentText = currentText.substring(1);
this.prefixFirst = currentText.split(" ", -1).length == 1 ? "/" : null;
this.gm.player.sendQueue.addToSendQueue(new CPacketComplete(currentText, eid, blockpos));
this.gm.player.client.addToSendQueue(new CPacketComplete(currentText, eid, blockpos));
this.waitingOnAutocomplete = true;
}
}

View file

@ -350,7 +350,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
public void use(ActButton elem, Mode action) {
if(GuiChar.this.gm.player != null) {
GuiChar.this.waiting = false;
GuiChar.this.gm.player.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_ALIGN, align.ordinal()));
GuiChar.this.gm.player.client.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_ALIGN, align.ordinal()));
for(ActButton btn : alignBtns) {
btn.enabled = btn != elem;
}
@ -363,7 +363,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
public void use(Slider elem, int value) {
if(GuiChar.this.gm.player != null) {
GuiChar.this.waiting = false;
GuiChar.this.gm.player.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_HEIGHT, value));
GuiChar.this.gm.player.client.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_HEIGHT, value));
}
}
}, "Spieler-Größe", "cm")).enabled = this.gm.player == null || this.gm.player.getMinSize() != this.gm.player.getMaxSize();
@ -378,8 +378,8 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
if(GuiChar.this.gm.player != null) {
GuiChar.this.gm.displayGuiScreen(GuiLoading.makeWaitTask("Lade Welt ..."));
Dimension dim = UniverseRegistry.getBaseDimensions().get(GuiChar.this.dimension);
GuiChar.this.gm.player.sendQueue.addToSendQueue(new CPacketMessage(CPacketMessage.Type.INFO, descField.getText()));
GuiChar.this.gm.player.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.CLOSE_EDITOR, dim.getDimensionId()));
GuiChar.this.gm.player.client.addToSendQueue(new CPacketMessage(CPacketMessage.Type.INFO, descField.getText()));
GuiChar.this.gm.player.client.addToSendQueue(new CPacketAction(CPacketAction.Action.CLOSE_EDITOR, dim.getDimensionId()));
}
}
}, "Charakter erstellen"));
@ -391,7 +391,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
elem.setText(GuiChar.this.gm.player == null ? "..." : GuiChar.this.gm.player.getCustomNameTag());
else if(GuiChar.this.gm.player != null) {
GuiChar.this.waiting = false;
GuiChar.this.gm.player.sendQueue.addToSendQueue(new CPacketMessage(CPacketMessage.Type.DISPLAY, name));
GuiChar.this.gm.player.client.addToSendQueue(new CPacketMessage(CPacketMessage.Type.DISPLAY, name));
}
}
}

View file

@ -70,7 +70,7 @@ public class GuiClass extends GuiList<GuiClass.ClassEntry> implements ActButton.
public void use(ActButton elem, Mode action) {
ClassEntry entry = this.getSelected();
if(entry != null && GuiClass.this.gm.player != null) {
GuiClass.this.gm.player.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_CLASS, entry.clazz.ordinal()));
GuiClass.this.gm.player.client.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_CLASS, entry.clazz.ordinal()));
this.gm.displayGuiScreen(GuiChar.INSTANCE);
}
}

View file

@ -74,6 +74,6 @@ public class GuiSpecies extends GuiList<GuiSpecies.SpeciesEntry> implements ActB
public void use(ActButton elem, Mode action) {
SpeciesEntry entry = this.getSelected();
if(entry != null && GuiSpecies.this.gm.player != null)
GuiSpecies.this.gm.player.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_SPECIES, EntityRegistry.getEntityID(entry.species.clazz)));
GuiSpecies.this.gm.player.client.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_SPECIES, EntityRegistry.getEntityID(entry.species.clazz)));
}
}

View file

@ -644,7 +644,7 @@ public abstract class GuiContainer extends Gui
if(this.cheatStack != null) {
Slot slot = this.getSlotAtPosition(mouseX, mouseY);
if((mouseButton == 0 || mouseButton == 1) && slot != null && this.gm.player != null && slot.inventory == this.gm.player.inventory)
this.gm.player.sendQueue.addToSendQueue(new CPacketCheat(this.cheatStack, slot.getIndex(), mouseButton == 0 && this.cheatStack.stackSize > 1));
this.gm.player.client.addToSendQueue(new CPacketCheat(this.cheatStack, slot.getIndex(), mouseButton == 0 && this.cheatStack.stackSize > 1));
if(mouseButton != 1 && !this.gm.ctrl())
this.cheatStack = null;
return;
@ -1197,7 +1197,7 @@ public abstract class GuiContainer extends Gui
if(i1 >= 0 && i1 < ITEM_LIST.size()) {
if(slot >= 0 || instant) {
this.gm.player.sendQueue.addToSendQueue(new CPacketCheat(ITEM_LIST.get(i1), slot, full));
this.gm.player.client.addToSendQueue(new CPacketCheat(ITEM_LIST.get(i1), slot, full));
}
else {
this.cheatStack = ITEM_LIST.get(i1).copy();

View file

@ -30,6 +30,7 @@ public class ClientLoginHandler extends NetHandler implements IClientLoginHandle
public void handleLoginSuccess(RPacketLoginSuccess packetIn)
{
this.gm.debugWorld = packetIn.isDebug();
this.networkManager.setConnectionState(PacketRegistry.PLAY);
this.networkManager.setNetHandler(new ClientPlayer(this.gm, this.networkManager));
}

View file

@ -27,6 +27,7 @@ import client.gui.container.GuiRepair;
import client.gui.ingame.GuiSign;
import client.renderer.particle.EntityPickupFX;
import client.renderer.texture.EntityTexManager;
import client.world.WorldClient;
import common.attributes.Attribute;
import common.attributes.AttributeInstance;
import common.attributes.AttributeMap;
@ -126,6 +127,7 @@ import common.packet.SPacketUpdateHealth;
import common.packet.SPacketWorld;
import common.potion.PotionEffect;
import common.rng.Random;
import common.sound.Sound;
import common.tileentity.IInteractionObject;
import common.tileentity.LocalBlockIntercommunication;
import common.tileentity.TileEntity;
@ -137,7 +139,6 @@ import common.world.Chunk;
import common.world.Explosion;
import common.world.Weather;
import common.world.World;
import common.world.WorldClient;
public class ClientPlayer extends NetHandler implements IClientPlayer
{
@ -180,6 +181,52 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
this.netManager = p_i46300_3_;
}
public void playSound(Sound sound) {
this.gameController.getSoundManager().playSound(sound);
}
public void emitParticleAtEntity(Entity entityIn, ParticleType particleTypes) {
this.gameController.effectRenderer.emitParticleAtEntity(entityIn, particleTypes);
}
public boolean isJumping() {
return this.gameController.jump;
}
public boolean isSprinting() {
return this.gameController.sprint;
}
public boolean isSneaking() {
return this.gameController.sneak;
}
public float getMoveForward() {
return this.gameController.moveForward;
}
public float getMoveStrafe() {
return this.gameController.moveStrafe;
}
public void setMoveForward(float value) {
this.gameController.moveForward = value;
}
public void setMoveStrafe(float value) {
this.gameController.moveStrafe = value;
}
public boolean isRenderViewEntity(Entity entity) {
return this.gameController.getRenderViewEntity() == entity;
}
public void updatePlayerMoveState() {
this.gameController.updatePlayerMoveState();
}
/**
* Clears the WorldClient instance associated with this NetHandlerPlayClient
*/
@ -482,7 +529,7 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
float yaw = packetIn.getYaw();
float pitch = packetIn.getPitch();
EntityNPC player = (EntityNPC)EntityRegistry.createEntityByID(packetIn.getEntityType(), this.gameController.world); // new EntityNPC(this.gameController.theWorld); // , /* this.getPlayerInfo( */ packetIn.getUser()); // ).getUser());
player.setOtherPlayer(this.gameController);
player.setOtherPlayer();
player.prevX = player.lastTickPosX = (double)(player.serverPosX = packetIn.getX());
player.prevY = player.lastTickPosY = (double)(player.serverPosY = packetIn.getY());
player.prevZ = player.lastTickPosZ = (double)(player.serverPosZ = packetIn.getZ());

View file

@ -13,6 +13,7 @@ import client.Client;
import client.renderer.particle.EffectRenderer;
import client.renderer.texture.DynamicTexture;
import client.renderer.texture.TextureMap;
import client.world.WorldClient;
import common.biome.Biome;
import common.block.Block;
import common.entity.Entity;
@ -32,7 +33,6 @@ import common.util.ExtMath;
import common.util.HitPosition;
import common.util.Vec3;
import common.world.World;
import common.world.WorldClient;
public class EntityRenderer {
private static final String locationMoltenPng = "textures/world/molten.png";

View file

@ -25,6 +25,7 @@ import client.renderer.texture.TextureAtlasSprite;
import client.renderer.texture.TextureManager;
import client.renderer.texture.TextureMap;
import client.renderer.tileentity.TileEntityRendererDispatcher;
import client.world.WorldClient;
import common.block.Block;
import common.block.BlockChest;
import common.block.BlockSign;
@ -52,7 +53,6 @@ import common.util.Vec3;
import common.util.Vector3f;
import common.world.Chunk;
import common.world.State;
import common.world.WorldClient;
public class RenderGlobal
{

View file

@ -5,12 +5,11 @@ import client.renderer.RenderBuffer;
import client.renderer.texture.TextureAtlasSprite;
import common.entity.Entity;
import common.entity.EntityType;
import common.entity.types.IEntityFX;
import common.nbt.NBTTagCompound;
import common.util.ExtMath;
import common.world.World;
public class EntityFX extends Entity implements IEntityFX
public class EntityFX extends Entity
{
protected int particleTextureIndexX;
protected int particleTextureIndexY;

View file

@ -2,6 +2,7 @@ package client.renderer.particle;
import client.Client;
import client.renderer.RenderBuffer;
import client.world.WorldClient;
import common.entity.Entity;
import common.init.SoundEvent;
import common.item.ItemDye;
@ -10,7 +11,6 @@ import common.nbt.NBTTagList;
import common.util.BoundingBox;
import common.util.ExtMath;
import common.world.World;
import common.world.WorldClient;
public class EntityFirework
{

View file

@ -1,10 +1,10 @@
package client.renderer.particle;
import client.renderer.RenderBuffer;
import client.world.WorldClient;
import common.entity.Entity;
import common.model.ParticleType;
import common.world.World;
import common.world.WorldClient;
public class EntityParticleEmitter extends EntityFX
{

View file

@ -0,0 +1,102 @@
package client.world;
import java.util.List;
import java.util.function.Predicate;
import common.block.Block;
import common.entity.Entity;
import common.init.Blocks;
import common.tileentity.TileEntity;
import common.util.BlockPos;
import common.util.BoundingBox;
import common.world.Chunk;
import common.world.LightType;
public class EmptyChunk extends Chunk {
public EmptyChunk(WorldClient world) {
super(world, 0, 0);
}
public int getHeight(int x, int z) {
return 0;
}
public void genHeights() {
}
public void genSkyLight() {
}
public Block getBlock(BlockPos pos) {
return Blocks.air;
}
public int getOpacity(BlockPos pos) {
return 255;
}
public int getMeta(BlockPos pos) {
return 0;
}
public int getLight(LightType type, BlockPos pos) {
return type.defValue;
}
public void setLight(LightType type, BlockPos pos, int value) {
}
public int getLightSub(BlockPos pos, int amount) {
return 0;
}
public void addEntity(Entity entity) {
}
public void removeEntity(Entity entity) {
}
public boolean canSeeSky(BlockPos pos) {
return false;
}
public TileEntity getTileEntity(BlockPos pos, TileEntity.EnumCreateEntityType type) {
return null;
}
public void addTileEntity(TileEntity tile) {
}
public void addTileEntity(BlockPos pos, TileEntity tile) {
}
public void removeTileEntity(BlockPos pos) {
}
public void onChunkLoad() {
}
public void onChunkUnload() {
}
public void setModified() {
}
public void getEntities(Entity exclude, BoundingBox bb, List<Entity> list, Predicate<? super Entity> pred) {
}
public <T extends Entity> void getEntities(Class<? extends T> clazz, BoundingBox bb, List<T> list, Predicate<? super T> pred) {
}
public boolean isDirty() {
return false;
}
public boolean isEmpty() {
return true;
}
public boolean isEmpty(int bottom, int top) {
return true;
}
}

View file

@ -0,0 +1,933 @@
package client.world;
import java.util.List;
import java.util.Set;
import client.Client;
import client.renderer.particle.EntityFX;
import client.renderer.particle.EntityFirework;
import common.biome.Biome;
import common.block.Block;
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.ItemRegistry;
import common.init.Items;
import common.init.SoundEvent;
import common.item.ItemDye;
import common.log.Log;
import common.material.Material;
import common.model.ParticleType;
import common.nbt.NBTTagCompound;
import common.rng.Random;
import common.sound.MovingSoundMinecart;
import common.sound.PositionedSound;
import common.tileentity.TileEntity;
import common.util.BlockPos;
import common.util.ChunkPos;
import common.util.ExtMath;
import common.util.LongHashMap;
import common.util.Vec3;
import common.util.BlockPos.MutableBlockPos;
import common.world.Chunk;
import common.world.AWorldClient;
import common.world.State;
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<Chunk> chunkMapping = new LongHashMap();
private final List<Chunk> chunkListing = Lists.<Chunk>newArrayList();
private final Chunk blankChunk = new EmptyChunk(this);
// public final Profiler profiler;
protected int lastLightning;
protected Vec3 lightColor = new Vec3(0xffffff);
public WorldClient(Client gm, boolean debug, Dimension dim)
{
super(dim, debug);
this.gm = gm;
this.calculateInitialSkylight();
this.calculateInitialWeather();
this.setGravity(this.gm.gravity);
this.setTimeFactor(this.gm.timeFactor);
// this.setDifficulty(this.gm.difficulty);
}
public void tick()
{
// this.info.tick();
if (this.gm.dayCycle)
{
this.daytime += this.timeFactor;
}
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 (Chunk chunk : this.chunkListing)
{
chunk.update(System.currentTimeMillis() - time > 5L);
}
if (System.currentTimeMillis() - time > 100L)
{
Log.JNI.info("Warnung: 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;
Chunk 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)
{
if (load)
{
if(this.chunkMapping.getValueByKey(LongHashMap.packInt(x, z)) != null)
this.doPreChunk(x, z, false);
Chunk chunk = new Chunk(this, x, z);
this.chunkMapping.add(LongHashMap.packInt(x, z), chunk);
this.chunkListing.add(chunk);
chunk.setLoaded(true);
}
else
{
Chunk chunk = this.getChunk(x, z);
if (!chunk.isEmpty())
{
chunk.onChunkUnload();
}
this.chunkMapping.remove(LongHashMap.packInt(x, z));
this.chunkListing.remove(chunk);
}
if (!load)
{
this.markBlockRangeForRenderUpdate(x * 16, 0, z * 16, x * 16 + 15, 512, 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().randomDisplayTick(this, pos, state, rand);
}
// if(this.canShowVoidParticles()) {
for(int n = 0; n < 1000; n++) {
float x = ((float)posX) + (rand.floatv() - rand.floatv() - 0.5f) * 32.0f;
float y = -64.0f + rand.floatv() * 65.0f; // * 68.0f;
float z = ((float)posZ) + (rand.floatv() - rand.floatv() - 0.5f) * 32.0f;
this.spawnParticle(ParticleType.SUSPENDED_DEPTH, (double)x, (double)y, (double)z, 0.0D, 0.0D, 0.0D);
}
// }
}
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 void makeFireworks(double x, double y, double z, double motionX, double motionY, double motionZ, NBTTagCompound compund)
{
this.gm.effectRenderer.addEffect(new EntityFirework.StarterFX(this.gm.world, x, y, z, motionX, motionY, motionZ, this.gm.effectRenderer, compund));
}
public Chunk getChunk(int x, int z)
{
Chunk chunk = this.chunkMapping.getValueByKey(LongHashMap.packInt(x, z));
return chunk == null ? this.blankChunk : chunk;
}
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 particleType, double xCoord, double yCoord, double zCoord, double xOffset, double yOffset,
double zOffset, int... data) {
this.spawnEntityFX(particleType, particleType.getShouldIgnoreRange(), xCoord, yCoord, zCoord, xOffset, yOffset, zOffset, data);
}
public EntityFX spawnEntityFX(ParticleType particle, boolean ignoreRange, double xCoord, double yCoord, double zCoord, double xOffset, double yOffset, double zOffset, int[] parameters)
{
if (this.gm.getRenderViewEntity() != null)
{
int particleID = particle.getParticleID();
// int i = this.gm.particleSetting;
//
// if (i == 1 && this.rand.zrange(3) == 0)
// {
// i = 2;
// }
double d0 = this.gm.getRenderViewEntity().posX - xCoord;
double d1 = this.gm.getRenderViewEntity().posY - yCoord;
double d2 = this.gm.getRenderViewEntity().posZ - zCoord;
if (ignoreRange)
{
return this.gm.effectRenderer.spawnEffectParticle(particleID, xCoord, yCoord, zCoord, xOffset, yOffset, zOffset, parameters);
}
else
{
double d3 = 16.0D;
if(d0 * d0 + d1 * d1 + d2 * d2 > 256.0D)
return null;
return this.gm.effectRenderer.spawnEffectParticle(particleID, xCoord, yCoord, zCoord, xOffset, yOffset, zOffset, parameters);
}
}
return null;
}
// 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(ItemRegistry.getItemFromBlock(Blocks.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 < 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;
double d8 = (double)l * d20 + this.rand.gaussian() * 0.01D;
double d10 = -0.03D + this.rand.gaussian() * 0.01D;
double d12 = (double)i * d20 + this.rand.gaussian() * 0.01D;
this.spawnEntityFX(ParticleType.SMOKE_NORMAL, ParticleType.SMOKE_NORMAL.getShouldIgnoreRange(), d21, d4, d6, d8, d10, d12, new int[0]);
}
return;
case 2001:
Block block = BlockRegistry.getBlockById(data & 4095);
if (block.getMaterial() != Material.air)
{
this.gm.getSoundManager().playSound(new PositionedSound(block.sound.getBreakSound(), 1.0F, /* block.sound.getFrequency() * 0.8F, */ (float)blockPosIn.getX() + 0.5F, (float)blockPosIn.getY() + 0.5F, (float)blockPosIn.getZ() + 0.5F));
}
this.gm.effectRenderer.addBlockDestroyEffects(blockPosIn, block.getStateFromMeta(data >> 12 & 255));
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.spawnEntityFX(ParticleType.ITEM_CRACK, ParticleType.ITEM_CRACK.getShouldIgnoreRange(), d13, d14, d16, this.rand.gaussian() * 0.15D, this.rand.doublev() * 0.2D, this.rand.gaussian() * 0.15D, new int[] {ItemRegistry.getIdFromItem(Items.potion), data});
}
ParticleType enumparticletypes = ParticleType.WATER_SPLASH;
float f = 1.0F;
float f1 = 1.0F;
float f2 = 1.0F;
if((data & 16383) != 0) {
int j1 = Items.potion.getColorFromDamage(data);
f = (float)(j1 >> 16 & 255) / 255.0F;
f1 = (float)(j1 >> 8 & 255) / 255.0F;
f2 = (float)(j1 >> 0 & 255) / 255.0F;
enumparticletypes = ParticleType.SPELL;
if (Items.potion.isEffectInstant(data))
{
enumparticletypes = ParticleType.SPELL_INSTANT;
}
}
for (int l1 = 0; l1 < 100; ++l1)
{
double d22 = this.rand.doublev() * 4.0D;
double d23 = this.rand.doublev() * Math.PI * 2.0D;
double d24 = Math.cos(d23) * d22;
double d9 = 0.01D + this.rand.doublev() * 0.5D;
double d11 = Math.sin(d23) * d22;
EntityFX entityfx = this.spawnEntityFX(enumparticletypes, enumparticletypes.getShouldIgnoreRange(), d13 + d24 * 0.1D, d14 + 0.3D, d16 + d11 * 0.1D, d24, d9, d11, new int[0]);
if (entityfx != null)
{
if(enumparticletypes != ParticleType.WATER_SPLASH) {
float f3 = 0.75F + this.rand.floatv() * 0.25F;
entityfx.setRBGColorF(f * f3, f1 * f3, f2 * f3);
}
entityfx.multiplyVelocity((float)d22);
}
}
this.playSoundAtPos(blockPosIn, SoundEvent.GLASS, 1.0F);
break;
case 2004:
for (int k = 0; k < 20; ++k)
{
double d3 = (double)blockPosIn.getX() + 0.5D + ((double)this.rand.floatv() - 0.5D) * 2.0D;
double d5 = (double)blockPosIn.getY() + 0.5D + ((double)this.rand.floatv() - 0.5D) * 2.0D;
double d7 = (double)blockPosIn.getZ() + 0.5D + ((double)this.rand.floatv() - 0.5D) * 2.0D;
this.spawnParticle(ParticleType.SMOKE_NORMAL, d3, d5, d7, 0.0D, 0.0D, 0.0D);
this.spawnParticle(ParticleType.FLAME, d3, d5, d7, 0.0D, 0.0D, 0.0D);
}
return;
case 2005:
ItemDye.spawnBonemealParticles(this, blockPosIn, data);
}
}
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.getCelestialAngle(p_72971_1_);
float f1 = 1.0F - (ExtMath.cos(f * (float)Math.PI * 2.0F) * 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 f1 * 0.8F + 0.2F;
}
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));
Biome biome = this.getBiomeGenForCoords(pos);
Vec3 vec;
if(biome.getSkyColor() != 0xffffffff)
vec = new Vec3(biome.getSkyColor());
else
vec = new Vec3(this.dimension.getSkyColor());
if(this.dimension.getType().days) {
float mult = ExtMath.clampf(ExtMath.cos(this.getCelestialAngle(partial) * (float)Math.PI * 2.0F) * 2.0F + 0.5F,
0.0F, 1.0F);
if(this.dimension.getSkyColor() == 0xffffffff) {
float temp = ExtMath.clampf(((biome.getTemperature(pos) + 14.0f) / 40.0f + 0.15f) / 3.0F,
-1.0F, 1.0F);
Vec3 sky = new Vec3(hsvToRGB(0.62222224F - temp * 0.05F, 0.5F + temp * 0.1F, 1.0F));
vec = new Vec3(vec.xCoord * sky.xCoord * mult, vec.yCoord * sky.yCoord * mult, vec.zCoord * sky.zCoord * mult);
}
else {
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;
}
return new Vec3((double)r, (double)g, (double)b);
}
public Vec3 getCloudColour(Entity entity, float partialTicks) {
Vec3 color = new Vec3(this.dimension.getCloudColor());
Biome biome = this.getBiomeGenForCoords(new BlockPos(ExtMath.floord(entity.posX), ExtMath.floord(entity.posY),
ExtMath.floord(entity.posZ)));
if(biome.getCloudColor() != 0xffffffff)
color = new Vec3(biome.getCloudColor());
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.getType().days) {
float sun = ExtMath.clampf(ExtMath.cos(this.getCelestialAngle(partialTicks) * (float)Math.PI * 2.0F) * 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);
}
return new Vec3((double)r, (double)g, (double)b);
}
public Vec3 getFogColor(Entity entity, float partialTicks) {
Vec3 color = new Vec3(this.dimension.getFogColor());
Biome biome = this.getBiomeGenForCoords(new BlockPos(ExtMath.floord(entity.posX), ExtMath.floord(entity.posY),
ExtMath.floord(entity.posZ)));
if(biome.getFogColor() != 0xffffffff)
color = new Vec3(biome.getFogColor());
if(!this.dimension.getType().days)
return color;
float sun = ExtMath.clampf(ExtMath.cos(this.getCelestialAngle(partialTicks) * (float)Math.PI * 2.0F) * 2.0F + 0.5F,
0.0F, 1.0F);
float r = (float)color.xCoord;
float g = (float)color.yCoord;
float b = (float)color.zCoord;
r = r * (sun * 0.94F + 0.06F);
g = g * (sun * 0.94F + 0.06F);
b = b * (sun * 0.91F + 0.09F);
return new Vec3((double)r, (double)g, (double)b);
}
public float getStarBrightness(float partialTicks) {
float f = this.getCelestialAngle(partialTicks);
float f1 = 1.0F - (ExtMath.cos(f * (float)Math.PI * 2.0F) * 2.0F + 0.25F);
f1 = ExtMath.clampf(f1, 0.0F, 1.0F);
return f1 * f1 * this.dimension.getStarBrightness();
}
public float getDeepStarBrightness(float partialTicks) {
float f = this.getCelestialAngle(partialTicks);
float f1 = 1.0F - (ExtMath.cos(f * (float)Math.PI * 2.0F) * 2.0F + 0.25F);
f1 = ExtMath.clampf(f1, 0.0F, 1.0F);
return f1 * f1 * this.dimension.getDeepStarBrightness();
}
public int getLastLightning() {
return this.lastLightning;
}
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();
}
public boolean hasNoChunks() {
return this.chunkListing.isEmpty();
}
}