Skip to content

Commit

Permalink
Merge pull request #223 from GlowstoneMC/1.9
Browse files Browse the repository at this point in the history
1.9
  • Loading branch information
mastercoms committed Mar 2, 2016
2 parents aafa1f9 + 2ffd210 commit 806c5d1
Show file tree
Hide file tree
Showing 165 changed files with 1,885 additions and 1,321 deletions.
2 changes: 1 addition & 1 deletion Glowkit
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,18 @@ The enhanced Glowstone fork with an emphasis on performance, control and compati

Currently the major changes from Glowstone include:

* Tracks the [Spigot 1.8.8 update of the Bukkit API](https://hub.spigotmc.org/javadocs/bukkit/)
* Tracks the [Spigot 1.9 update of the Bukkit API](https://hub.spigotmc.org/javadocs/bukkit/)
* New features merged in, adapted for PaperSpigot's update of the Bukkit API (see [features](#features) below for details)
* Multi-API plugin support, integrates with [Bukkit2Sponge](https://github.com/GlowstonePlusPlus/Bukkit2Sponge) for [SpongeAPI](https://github.com/SpongePowered/SpongeAPI) plugin loading
* Builds using Maven

##Downloads

If you don't want to build from source, prebuilt jar files are available to download from:
* **[Latest successful build](https://bamboo.gserv.me/browse/GSPP-SRV/latestSuccessful/artifact/shared/Server-JAR/glowstone++-1.8.9-SNAPSHOT.jar)** - recomended

* **[gserv.me](https://bamboo.gserv.me/browse/GSPP-SRV)** - all builds, no login required
* **[gserv.me](https://bamboo.gserv.me/browse/GSPP-SRV17)** - all builds, no login required

* [![Build Status](https://circleci.com/gh/GlowstonePlusPlus/GlowstonePlusPlus.svg?style=svg)](https://circleci.com/gh/GlowstonePlusPlus/GlowstonePlusPlus/tree/master) **[CircleCI](https://circleci.com/gh/GlowstonePlusPlus/GlowstonePlusPlus/tree/master)** - click the latest build then expand "Artifacts" (if it does not show, try logging in with GitHub)
* [![Build Status](https://circleci.com/gh/GlowstonePlusPlus/GlowstonePlusPlus.svg?style=svg)](https://circleci.com/gh/GlowstonePlusPlus/GlowstonePlusPlus/tree/master) **[CircleCI](https://circleci.com/gh/GlowstoneMC/GlowstonePlusPlus/tree/1.9)** - click the latest build then expand "Artifacts" (if it does not show, try logging in with GitHub)

##Building

Expand All @@ -43,12 +42,12 @@ cd GlowstonePlusPlus
./setup.sh
```

The final jar will be placed in `target/` named `glowstone++-1.8.9-SNAPSHOT.jar`.
The final jar will be placed in `target/` named `glowstone++-1.9-SNAPSHOT.jar`.

##Running

Running Glowstone++ is simple because its dependencies are shaded into the output
jar at compile time. Simply execute `java -jar glowstone++-1.8.9-SNAPSHOT.jar` along with any
jar at compile time. Simply execute `java -jar glowstone++-1.9-SNAPSHOT.jar` along with any
extra JVM options desired. A variety of command-line options are also available -
run `java -jar glowstone++.jar --help` for more information.

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>net.glowstoneplusplus</groupId>
<artifactId>glowstoneplusplus</artifactId>
<version>1.8.9-SNAPSHOT</version>
<version>1.9-SNAPSHOT</version>
<name>GlowstonePlusPlus</name>
<url>https://github.com/GlowstonePlusPlus/GlowstonePlusPlus</url>

Expand All @@ -15,7 +15,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<bukkit.version>1.8.8-R0.1-SNAPSHOT</bukkit.version>
<bukkit.version>1.9-R0.1-SNAPSHOT</bukkit.version>
</properties>

<parent>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/glowstone/Explosion.java
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ private Vector distanceToHead(LivingEntity entity) {
///////////////////////////////////////
// Visualize
private void playOutSoundAndParticles() {
world.playSound(location, Sound.EXPLODE, 4, (1.0F + (random.nextFloat() - random.nextFloat()) * 0.2F) * 0.7F);
world.playSound(location, Sound.ENTITY_GENERIC_EXPLODE, 4, (1.0F + (random.nextFloat() - random.nextFloat()) * 0.2F) * 0.7F);

if (this.power >= 2.0F && this.breakBlocks) {
// send huge explosion
Expand Down
103 changes: 39 additions & 64 deletions src/main/java/net/glowstone/GlowChunk.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package net.glowstone;

import com.flowpowered.networking.util.ByteBufUtils;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import lombok.Data;
import net.glowstone.block.GlowBlock;
import net.glowstone.block.GlowBlockState;
Expand All @@ -9,6 +12,7 @@
import net.glowstone.entity.GlowEntity;
import net.glowstone.net.message.play.game.ChunkDataMessage;
import net.glowstone.util.NibbleArray;
import net.glowstone.util.VariableValueArray;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.entity.Entity;
Expand Down Expand Up @@ -611,6 +615,19 @@ public ChunkDataMessage toMessage(boolean skylight) {
return toMessage(skylight, true, 0);
}

private static final int PACKET_DATA_ARRAY_LENGTH = (ChunkSection.ARRAY_SIZE * 2) / 8;
private static final byte[] PACKET_DATA_ARRAY_LENGTH_BYTES;

static {
final ByteBuf buf = Unpooled.buffer();
try {
ByteBufUtils.writeVarInt(buf, PACKET_DATA_ARRAY_LENGTH);
PACKET_DATA_ARRAY_LENGTH_BYTES = buf.array().clone();
} finally {
buf.release();
}
}

/**
* Creates a new {@link ChunkDataMessage} which can be sent to a client to stream
* parts of this chunk to them.
Expand All @@ -621,100 +638,58 @@ public ChunkDataMessage toMessage(boolean skylight, boolean entireChunk, int sec
load();

// filter sectionBitmask based on actual chunk contents
int sectionCount;
if (sections == null) {
sectionBitmask = 0;
sectionCount = 0;
} else {
final int maxBitmask = (1 << sections.length) - 1;
if (entireChunk) {
sectionBitmask = maxBitmask;
sectionCount = sections.length;
} else {
sectionBitmask &= maxBitmask;
sectionCount = countBits(sectionBitmask);
}

for (int i = 0; i < sections.length; ++i) {
if (sections[i] == null || sections[i].count == 0) {
// remove empty sections from bitmask
sectionBitmask &= ~(1 << i);
sectionCount--;
}
}
}

// calculate how big the data will need to be
int byteSize = 0;
ByteBuf buf = Unpooled.buffer();

if (sections != null) {
final int numBlocks = WIDTH * HEIGHT * SEC_DEPTH;
int sectionSize = numBlocks * 5 / 2; // (data and metadata combo) * 2 + blockLight/2
if (skylight) {
sectionSize += numBlocks / 2; // + skyLight/2
}
byteSize += sectionCount * sectionSize;
}

if (entireChunk) {
byteSize += 256; // + biomes
}

byte[] tileData = new byte[byteSize];
int pos = 0;

if (sections != null) {
if (this.sections != null) {
// get the list of sections
ChunkSection[] sendSections = new ChunkSection[sectionCount];
for (int i = 0, j = 0, mask = 1; i < sections.length; ++i, mask <<= 1) {
if ((sectionBitmask & mask) != 0) {
sendSections[j++] = sections[i];
for (int i = 0; i < this.sections.length; ++i) {
if ((sectionBitmask & (1 << i)) == 0) {
continue;
}
}

for (ChunkSection sec : sendSections) {
for (char t : sec.types) {
tileData[pos++] = (byte) (t & 0xff);
tileData[pos++] = (byte) (t >> 8);
ChunkSection section = this.sections[i];
VariableValueArray array = new VariableValueArray(13, section.types.length);
buf.writeByte(array.getBitsPerValue()); // Bit per value -> Currently fixed at 13!!!
ByteBufUtils.writeVarInt(buf, 0); // Palette size -> 0 -> Use the global palette
for (int j = 0; j < section.types.length; j++) {
array.set(j, section.types[j]);
}
}

for (ChunkSection sec : sendSections) {
byte[] blockLight = sec.blockLight.getRawData();
System.arraycopy(blockLight, 0, tileData, pos, blockLight.length);
pos += blockLight.length;
}

if (skylight) {
for (ChunkSection sec : sendSections) {
byte[] skyLight = sec.skyLight.getRawData();
System.arraycopy(skyLight, 0, tileData, pos, skyLight.length);
pos += skyLight.length;
long[] backing = array.getBacking();
ByteBufUtils.writeVarInt(buf, backing.length);
buf.ensureWritable(backing.length * 8 + section.blockLight.byteSize() + (skylight ? section.skyLight.byteSize() : 0));
for (long value : backing) {
buf.writeLong(value);
}
buf.writeBytes(section.blockLight.getRawData());
if (skylight) {
buf.writeBytes(section.skyLight.getRawData());
}
}
}

// biomes
if (entireChunk) {
for (int i = 0; i < 256; ++i) {
tileData[pos++] = biomes[i];
}
}

if (pos != byteSize) {
throw new IllegalStateException("only wrote " + pos + " out of expected " + byteSize + " bytes");
buf.writeBytes(this.biomes);
}

return new ChunkDataMessage(x, z, entireChunk, sectionBitmask, tileData);
}

private int countBits(int v) {
// http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetKernighan
int c;
for (c = 0; v > 0; c++) {
v &= v - 1;
}
return c;
return new ChunkDataMessage(x, z, entireChunk, sectionBitmask, buf);
}

/**
Expand Down
17 changes: 15 additions & 2 deletions src/main/java/net/glowstone/GlowServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
import org.apache.commons.lang3.Validate;
import org.bukkit.*;
import org.bukkit.World.Environment;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarFlag;
import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar;
import org.bukkit.command.*;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.serialization.ConfigurationSerialization;
Expand Down Expand Up @@ -95,12 +99,12 @@ public final class GlowServer implements Server {
/**
* The game version supported by the server.
*/
public static final String GAME_VERSION = "1.8.9";
public static final String GAME_VERSION = "1.9";

/**
* The protocol version supported by the server.
*/
public static final int PROTOCOL_VERSION = 47;
public static final int PROTOCOL_VERSION = 107;
/**
* A list of all the active {@link net.glowstone.net.GlowSession}s.
*/
Expand Down Expand Up @@ -1649,6 +1653,11 @@ public ChunkGenerator.ChunkData createChunkData(World world) {
return new GlowChunkData(world);
}

@Override
public BossBar createBossBar(String s, BarColor barColor, BarStyle barStyle, BarFlag... barFlags) {
return null;
}

@Override
public void configureDbConfig(com.avaje.ebean.config.ServerConfig dbConfig) {
DataSourceConfig ds = new DataSourceConfig();
Expand Down Expand Up @@ -1804,6 +1813,10 @@ public int getMaxBuildHeight() {
.MAX_BUILD_HEIGHT)));
}

public boolean getClassicWater() {
return config.getBoolean(ServerConfig.Key.WATER_CLASSIC);
}

public String getConsolePrompt() {
return config.getString(ServerConfig.Key.CONSOLE_PROMPT);
}
Expand Down
72 changes: 60 additions & 12 deletions src/main/java/net/glowstone/GlowWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -1259,18 +1259,6 @@ public Entity spawnEntity(Location loc, EntityType type) {
return spawn(loc, type.getEntityClass());
}

@Override
@Deprecated
public LivingEntity spawnCreature(Location loc, EntityType type) {
return (LivingEntity) spawn(loc, type.getEntityClass());
}

@Override
@Deprecated
public LivingEntity spawnCreature(Location loc, CreatureType type) {
return (LivingEntity) spawn(loc, type.getEntityClass());
}

private GlowLightningStrike strikeLightningFireEvent(final Location loc, final boolean effect) {
final GlowLightningStrike strike = new GlowLightningStrike(loc, effect, random);
final LightningStrikeEvent event = new LightningStrikeEvent(this, strike);
Expand Down Expand Up @@ -1647,6 +1635,66 @@ public WorldBorder getWorldBorder() {
return null;
}

@Override
public void spawnParticle(Particle particle, Location location, int i) {

}

@Override
public void spawnParticle(Particle particle, double v, double v1, double v2, int i) {

}

@Override
public <T> void spawnParticle(Particle particle, Location location, int i, T t) {

}

@Override
public <T> void spawnParticle(Particle particle, double v, double v1, double v2, int i, T t) {

}

@Override
public void spawnParticle(Particle particle, Location location, int i, double v, double v1, double v2) {

}

@Override
public void spawnParticle(Particle particle, double v, double v1, double v2, int i, double v3, double v4, double v5) {

}

@Override
public <T> void spawnParticle(Particle particle, Location location, int i, double v, double v1, double v2, T t) {

}

@Override
public <T> void spawnParticle(Particle particle, double v, double v1, double v2, int i, double v3, double v4, double v5, T t) {

}

@Override
public void spawnParticle(Particle particle, Location location, int i, double v, double v1, double v2, double v3) {

}

@Override
public void spawnParticle(Particle particle, double v, double v1, double v2, int i, double v3, double v4, double v5, double v6) {

}

@Override
public <T> void spawnParticle(Particle particle, Location location, int i, double v, double v1, double v2, double v3, T t) {

}

@Override
public <T> void spawnParticle(Particle particle, double v, double v1, double v2, int i, double v3, double v4, double v5, double v6, T t) {

}

public GameRuleManager getGameRuleMap() {
return gameRules;
}
Expand Down

0 comments on commit 806c5d1

Please sign in to comment.