split client and server 3
This commit is contained in:
parent
b17efb5b07
commit
d37bb7f6cc
7 changed files with 118 additions and 41 deletions
24
java/src/game/IClient.java
Normal file
24
java/src/game/IClient.java
Normal file
|
@ -0,0 +1,24 @@
|
|||
package game;
|
||||
|
||||
import game.entity.Entity;
|
||||
import game.entity.npc.EntityNPC;
|
||||
import game.entity.types.IEntityFX;
|
||||
import game.nbt.NBTTagCompound;
|
||||
import game.sound.Sound;
|
||||
import game.world.BlockPos;
|
||||
import game.world.State;
|
||||
|
||||
public interface IClient {
|
||||
int getRenderDistance();
|
||||
float getGravity();
|
||||
int getTimeFactor();
|
||||
boolean hasDayCycle();
|
||||
void playSound(Sound sound);
|
||||
EntityNPC getPlayer();
|
||||
Entity getRenderViewEntity();
|
||||
void makeFireworks(double x, double y, double z, double motionX, double motionY, double motionZ, NBTTagCompound compund);
|
||||
IEntityFX spawnEffectParticle(int particleId, double xCoord, double yCoord, double zCoord, double xSpeed, double ySpeed, double zSpeed, int[] parameters);
|
||||
void addBlockDestroyEffects(BlockPos pos, State state);
|
||||
void sendBlockBreakProgress(int breakerId, BlockPos pos, int progress);
|
||||
void markBlocksForUpdate(int x1, int y1, int z1, int x2, int y2, int z2);
|
||||
}
|
|
@ -14,20 +14,12 @@ import game.world.WorldServer;
|
|||
|
||||
public interface IServer {
|
||||
List<IPlayer> getIPlayers();
|
||||
|
||||
void sendPacket(Packet packet);
|
||||
|
||||
void sendPacket(Packet packet, int dimension);
|
||||
|
||||
void sendNear(double x, double y, double z, double radius, int dimension, Packet packet);
|
||||
|
||||
void sendNearExcept(EntityNPC except, double x, double y, double z, double radius, int dimension, Packet packet);
|
||||
|
||||
Map<String, Position> getWarps();
|
||||
|
||||
List<WorldServer> getWorlds();
|
||||
|
||||
WorldServer getWorld(int dimension);
|
||||
|
||||
void placeInDimension(Entity entity, WorldServer oldWorld, WorldServer world, BlockPos pos, PortalType portal);
|
||||
}
|
11
java/src/game/entity/types/IEntityFX.java
Normal file
11
java/src/game/entity/types/IEntityFX.java
Normal file
|
@ -0,0 +1,11 @@
|
|||
package game.entity.types;
|
||||
|
||||
import client.renderer.particle.EntityFX;
|
||||
|
||||
public interface IEntityFX {
|
||||
|
||||
EntityFX multiplyVelocity(float multiplier);
|
||||
|
||||
void setRBGColorF(float particleRedIn, float particleGreenIn, float particleBlueIn);
|
||||
|
||||
}
|
|
@ -3,9 +3,7 @@ package game.world;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import client.Game;
|
||||
import client.renderer.particle.EntityFX;
|
||||
import client.renderer.particle.EntityFirework;
|
||||
import game.IClient;
|
||||
import game.biome.Biome;
|
||||
import game.block.Block;
|
||||
import game.collect.Lists;
|
||||
|
@ -14,6 +12,7 @@ import game.dimension.Dimension;
|
|||
import game.entity.Entity;
|
||||
import game.entity.item.EntityCart;
|
||||
import game.entity.npc.EntityNPC;
|
||||
import game.entity.types.IEntityFX;
|
||||
import game.init.BlockRegistry;
|
||||
import game.init.ItemRegistry;
|
||||
import game.init.Items;
|
||||
|
@ -34,7 +33,7 @@ public class WorldClient extends World
|
|||
{
|
||||
private static final int DISPLAY_RANGE = 16;
|
||||
|
||||
private final Game gm = Game.getGame();
|
||||
private final IClient 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();
|
||||
|
@ -45,14 +44,14 @@ public class WorldClient extends World
|
|||
protected int lastLightning;
|
||||
protected Vec3 lightColor = new Vec3(0xffffff);
|
||||
|
||||
public WorldClient(boolean debug, Dimension dim)
|
||||
public WorldClient(IClient gm, boolean debug, Dimension dim)
|
||||
{
|
||||
super(dim, true, debug);
|
||||
// this.gm = profiler;
|
||||
this.gm = gm;
|
||||
this.calculateInitialSkylight();
|
||||
this.calculateInitialWeather();
|
||||
this.setGravity(this.gm.gravity);
|
||||
this.setTimeFactor(this.gm.timeFactor);
|
||||
this.setGravity(this.gm.getGravity());
|
||||
this.setTimeFactor(this.gm.getTimeFactor());
|
||||
// this.setDifficulty(this.gm.difficulty);
|
||||
}
|
||||
|
||||
|
@ -60,7 +59,7 @@ public class WorldClient extends World
|
|||
{
|
||||
// this.info.tick();
|
||||
|
||||
if (this.gm.dayCycle)
|
||||
if (this.gm.hasDayCycle())
|
||||
{
|
||||
this.daytime += this.timeFactor;
|
||||
}
|
||||
|
@ -89,7 +88,7 @@ public class WorldClient extends World
|
|||
|
||||
protected void updateBlocks()
|
||||
{
|
||||
this.setActivePlayerChunksAndCheckLight(this.gm.renderDistance);
|
||||
this.setActivePlayerChunksAndCheckLight(this.gm.getRenderDistance());
|
||||
this.previousActive.retainAll(this.active);
|
||||
|
||||
if (this.previousActive.size() == this.active.size())
|
||||
|
@ -157,7 +156,7 @@ public class WorldClient extends World
|
|||
}
|
||||
else if (entityIn instanceof EntityCart)
|
||||
{
|
||||
this.gm.getSoundManager().playSound(new MovingSoundMinecart((EntityCart)entityIn));
|
||||
this.gm.playSound(new MovingSoundMinecart((EntityCart)entityIn));
|
||||
}
|
||||
|
||||
return flag;
|
||||
|
@ -217,7 +216,7 @@ public class WorldClient extends World
|
|||
|
||||
public Entity getEntityByID(int id)
|
||||
{
|
||||
return (Entity)(id == this.gm.thePlayer.getId() ? this.gm.thePlayer : super.getEntityByID(id));
|
||||
return (Entity)(id == this.gm.getPlayer().getId() ? this.gm.getPlayer() : super.getEntityByID(id));
|
||||
}
|
||||
|
||||
public Entity removeEntityFromWorld(int entityID)
|
||||
|
@ -335,13 +334,13 @@ public class WorldClient extends World
|
|||
// }
|
||||
// else
|
||||
// {
|
||||
this.gm.getSoundManager().playSound(positionedsoundrecord);
|
||||
this.gm.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, x, y, z, motionX, motionY, motionZ, this.gm.effectRenderer, compund));
|
||||
this.gm.makeFireworks(x, y, z, motionX, motionY, motionZ, compund);
|
||||
}
|
||||
|
||||
public Chunk getChunk(int x, int z)
|
||||
|
@ -370,9 +369,9 @@ public class WorldClient extends World
|
|||
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)
|
||||
public IEntityFX spawnEntityFX(ParticleType particle, boolean ignoreRange, double xCoord, double yCoord, double zCoord, double xOffset, double yOffset, double zOffset, int[] parameters)
|
||||
{
|
||||
if (this.gm != null && this.gm.getRenderViewEntity() != null && this.gm.effectRenderer != null)
|
||||
if (this.gm.getRenderViewEntity() != null)
|
||||
{
|
||||
int particleID = particle.getParticleID();
|
||||
// int i = this.gm.particleSetting;
|
||||
|
@ -388,18 +387,17 @@ public class WorldClient extends World
|
|||
|
||||
if (ignoreRange)
|
||||
{
|
||||
return this.gm.effectRenderer.spawnEffectParticle(particleID, xCoord, yCoord, zCoord, xOffset, yOffset, zOffset, parameters);
|
||||
return this.gm.spawnEffectParticle(particleID, xCoord, yCoord, zCoord, xOffset, yOffset, zOffset, parameters);
|
||||
}
|
||||
else
|
||||
{
|
||||
double d3 = 16.0D;
|
||||
return d0 * d0 + d1 * d1 + d2 * d2 > 256.0D ? null : (/* i > 1 ? null : */ this.gm.effectRenderer.spawnEffectParticle(particleID, xCoord, yCoord, zCoord, xOffset, yOffset, zOffset, parameters));
|
||||
if(d0 * d0 + d1 * d1 + d2 * d2 > 256.0D)
|
||||
return null;
|
||||
return this.gm.spawnEffectParticle(particleID, xCoord, yCoord, zCoord, xOffset, yOffset, zOffset, parameters);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// public void broadcastSound(int soundID, BlockPos pos, int data)
|
||||
|
@ -583,10 +581,10 @@ public class WorldClient extends World
|
|||
|
||||
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.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));
|
||||
this.gm.addBlockDestroyEffects(blockPosIn, block.getStateFromMeta(data >> 12 & 255));
|
||||
break;
|
||||
|
||||
case 2002:
|
||||
|
@ -623,7 +621,7 @@ public class WorldClient extends World
|
|||
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]);
|
||||
IEntityFX 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)
|
||||
{
|
||||
|
@ -660,7 +658,7 @@ public class WorldClient extends World
|
|||
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);
|
||||
this.gm.markBlocksForUpdate(i - 1, j - 1, k - 1, i + 1, j + 1, k + 1);
|
||||
}
|
||||
|
||||
public void notifyLightSet(BlockPos pos)
|
||||
|
@ -668,17 +666,17 @@ public class WorldClient extends World
|
|||
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);
|
||||
this.gm.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);
|
||||
this.gm.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);
|
||||
this.gm.sendBlockBreakProgress(breakerId, pos, progress);
|
||||
}
|
||||
|
||||
public float getSunBrightness(float p_72971_1_) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue