From 20b6f85310de8f2a67f283ca156d1f847af599b2 Mon Sep 17 00:00:00 2001 From: BrainStone Date: Thu, 27 Jul 2017 02:47:14 +0200 Subject: [PATCH] Updated Sponge --- sponge/build.gradle | 12 +- .../com/boydti/fawe/sponge/FaweSponge.java | 4 +- .../{v1_11 => v1_12}/MutableGenLayer.java | 2 +- .../SpongeChunk_1_12.java} | 44 +++---- .../SpongeQueue_1_12.java} | 109 +++++++++--------- .../SpongeQueue_ALL.java.unused | 0 6 files changed, 87 insertions(+), 84 deletions(-) rename sponge/src/main/java/com/boydti/fawe/sponge/{v1_11 => v1_12}/MutableGenLayer.java (93%) rename sponge/src/main/java/com/boydti/fawe/sponge/{v1_11/SpongeChunk_1_11.java => v1_12/SpongeChunk_1_12.java} (93%) rename sponge/src/main/java/com/boydti/fawe/sponge/{v1_11/SpongeQueue_1_11.java => v1_12/SpongeQueue_1_12.java} (93%) rename sponge/src/main/java/com/boydti/fawe/sponge/{v1_11 => v1_12}/SpongeQueue_ALL.java.unused (100%) diff --git a/sponge/build.gradle b/sponge/build.gradle index 745aa077..2a27d257 100644 --- a/sponge/build.gradle +++ b/sponge/build.gradle @@ -17,12 +17,12 @@ buildscript { } dependencies { classpath 'net.minecrell:VanillaGradle:2.0.3_1' - classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT' + classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT' } } plugins { - id 'org.spongepowered.plugin' version '0.6' + id 'org.spongepowered.plugin' version '0.8.1' } apply plugin: 'net.minecrell.vanilla.server.library' @@ -49,15 +49,15 @@ repositories { dependencies { compile project(':core') - compile 'org.spongepowered:spongeapi:6.0.0-SNAPSHOT' - compile 'org.spongepowered:mixin:0.6.1-SNAPSHOT' + compile 'org.spongepowered:spongeapi:6.1.0-SNAPSHOT' + compile 'org.spongepowered:mixin:0.7-SNAPSHOT' compile 'com.sk89q.worldedit:worldedit-sponge:6.1.7-SNAPSHOT' compile name: 'worldedit-core-6.1.7-SNAPSHOT-dist' } minecraft { - version = "1.11" - mappings = "snapshot_20161116" + version = "1.12" + mappings = "snapshot_20170726" runDir = 'run' } diff --git a/sponge/src/main/java/com/boydti/fawe/sponge/FaweSponge.java b/sponge/src/main/java/com/boydti/fawe/sponge/FaweSponge.java index 51ca18cf..a007812c 100644 --- a/sponge/src/main/java/com/boydti/fawe/sponge/FaweSponge.java +++ b/sponge/src/main/java/com/boydti/fawe/sponge/FaweSponge.java @@ -89,12 +89,12 @@ public class FaweSponge implements IFawe { @Override public FaweQueue getNewQueue(World world, boolean fast) { - return new com.boydti.fawe.sponge.v1_11.SpongeQueue_1_11(getWorldName(world)); + return new com.boydti.fawe.sponge.v1_12.SpongeQueue_1_12(getWorldName(world)); } @Override public FaweQueue getNewQueue(String world, boolean fast) { - return new com.boydti.fawe.sponge.v1_11.SpongeQueue_1_11(world); + return new com.boydti.fawe.sponge.v1_12.SpongeQueue_1_12(world); } @Override diff --git a/sponge/src/main/java/com/boydti/fawe/sponge/v1_11/MutableGenLayer.java b/sponge/src/main/java/com/boydti/fawe/sponge/v1_12/MutableGenLayer.java similarity index 93% rename from sponge/src/main/java/com/boydti/fawe/sponge/v1_11/MutableGenLayer.java rename to sponge/src/main/java/com/boydti/fawe/sponge/v1_12/MutableGenLayer.java index 14e13bea..a47d1368 100644 --- a/sponge/src/main/java/com/boydti/fawe/sponge/v1_11/MutableGenLayer.java +++ b/sponge/src/main/java/com/boydti/fawe/sponge/v1_12/MutableGenLayer.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.sponge.v1_11; +package com.boydti.fawe.sponge.v1_12; import java.util.Arrays; import net.minecraft.world.gen.layer.GenLayer; diff --git a/sponge/src/main/java/com/boydti/fawe/sponge/v1_11/SpongeChunk_1_11.java b/sponge/src/main/java/com/boydti/fawe/sponge/v1_12/SpongeChunk_1_12.java similarity index 93% rename from sponge/src/main/java/com/boydti/fawe/sponge/v1_11/SpongeChunk_1_11.java rename to sponge/src/main/java/com/boydti/fawe/sponge/v1_12/SpongeChunk_1_12.java index 2537860c..26016579 100644 --- a/sponge/src/main/java/com/boydti/fawe/sponge/v1_11/SpongeChunk_1_11.java +++ b/sponge/src/main/java/com/boydti/fawe/sponge/v1_12/SpongeChunk_1_12.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.sponge.v1_11; +package com.boydti.fawe.sponge.v1_12; import com.boydti.fawe.Fawe; import com.boydti.fawe.FaweCache; @@ -39,7 +39,7 @@ import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.IBlockStatePalette; import net.minecraft.world.chunk.storage.ExtendedBlockStorage; -public class SpongeChunk_1_11 extends CharFaweChunk { +public class SpongeChunk_1_12 extends CharFaweChunk { public BlockStateContainer[] sectionPalettes; @@ -52,23 +52,23 @@ public class SpongeChunk_1_11 extends CharFaweChunk { * @param x * @param z */ - public SpongeChunk_1_11(FaweQueue parent, int x, int z) { + public SpongeChunk_1_12(FaweQueue parent, int x, int z) { super(parent, x, z); } - public SpongeChunk_1_11(FaweQueue parent, int x, int z, char[][] ids, short[] count, short[] air, byte[] heightMap) { + public SpongeChunk_1_12(FaweQueue parent, int x, int z, char[][] ids, short[] count, short[] air, byte[] heightMap) { super(parent, x, z, ids, count, air, heightMap); } @Override public CharFaweChunk copy(boolean shallow) { - SpongeChunk_1_11 copy; + SpongeChunk_1_12 copy; if (shallow) { - copy = new SpongeChunk_1_11(getParent(), getX(), getZ(), ids, count, air, heightMap); + copy = new SpongeChunk_1_12(getParent(), getX(), getZ(), ids, count, air, heightMap); copy.biomes = biomes; copy.chunk = chunk; } else { - copy = new SpongeChunk_1_11(getParent(), getX(), getZ(), (char[][]) MainUtil.copyNd(ids), count.clone(), air.clone(), heightMap.clone()); + copy = new SpongeChunk_1_12(getParent(), getX(), getZ(), (char[][]) MainUtil.copyNd(ids), count.clone(), air.clone(), heightMap.clone()); copy.biomes = biomes; copy.chunk = chunk; copy.biomes = biomes.clone(); @@ -124,7 +124,7 @@ public class SpongeChunk_1_11 extends CharFaweChunk { @Override public Chunk getNewChunk() { - World world = ((SpongeQueue_1_11) getParent()).getWorld(); + World world = ((SpongeQueue_1_12) getParent()).getWorld(); return world.getChunkProvider().provideChunk(getX(), getZ()); } @@ -156,14 +156,14 @@ public class SpongeChunk_1_11 extends CharFaweChunk { } @Override - public SpongeChunk_1_11 call() { + public SpongeChunk_1_12 call() { net.minecraft.world.chunk.Chunk nmsChunk = this.getChunk(); int bx = this.getX() << 4; int bz = this.getZ() << 4; nmsChunk.setModified(true); net.minecraft.world.World nmsWorld = getParent().getWorld(); try { - boolean flag = !nmsWorld.provider.getHasNoSky(); + boolean flag = nmsWorld.provider.hasSkyLight(); // Sections ExtendedBlockStorage[] sections = nmsChunk.getBlockStorageArray(); Map tiles = nmsChunk.getTileEntityMap(); @@ -180,14 +180,14 @@ public class SpongeChunk_1_11 extends CharFaweChunk { } else if (count >= 4096) { Collection ents = entities[i]; if (!ents.isEmpty()) { - synchronized (SpongeChunk_1_11.class) { + synchronized (SpongeChunk_1_12.class) { entities[i] = new ClassInheritanceMultiMap<>(Entity.class); } } } else { char[] array = this.getIdArray(i); Collection ents = new ArrayList<>(entities[i]); - synchronized (SpongeChunk_1_11.class) { + synchronized (SpongeChunk_1_12.class) { for (Entity entity : ents) { if (entity instanceof EntityPlayer) { continue; @@ -209,7 +209,7 @@ public class SpongeChunk_1_11 extends CharFaweChunk { Set createdEntities = new HashSet<>(); Set entitiesToSpawn = this.getEntities(); if (!entitiesToSpawn.isEmpty()) { - synchronized (SpongeChunk_1_11.class) { + synchronized (SpongeChunk_1_12.class) { for (CompoundTag nativeTag : entitiesToSpawn) { Map entityTagMap = nativeTag.getValue(); StringTag idTag = (StringTag) entityTagMap.get("Id"); @@ -230,7 +230,7 @@ public class SpongeChunk_1_11 extends CharFaweChunk { if (entityKeys == null) { entityKeys = new HashMap<>(); for (ResourceLocation key : EntityList.getEntityNameList()) { - String currentId = EntityList.func_191302_a(key); + String currentId = EntityList.getTranslationName(key); entityKeys.put(currentId, key); entityKeys.put(key.getResourcePath(), key); } @@ -239,12 +239,12 @@ public class SpongeChunk_1_11 extends CharFaweChunk { if (entityKey != null) { Entity entity = EntityList.createEntityByIDFromName(entityKey, nmsWorld); if (entity != null) { - NBTTagCompound tag = (NBTTagCompound) SpongeQueue_1_11.methodFromNative.invoke(SpongeQueue_1_11.adapter, nativeTag); + NBTTagCompound tag = (NBTTagCompound) SpongeQueue_1_12.methodFromNative.invoke(SpongeQueue_1_12.adapter, nativeTag); entity.readFromNBT(tag); tag.removeTag("UUIDMost"); tag.removeTag("UUIDLeast"); entity.setPositionAndRotation(x, y, z, yaw, pitch); - nmsWorld.spawnEntityInWorld(entity); + nmsWorld.spawnEntity(entity); } } } @@ -272,7 +272,7 @@ public class SpongeChunk_1_11 extends CharFaweChunk { } int k = FaweCache.CACHE_J[ly][lz][lx]; if (array[k] != 0) { - synchronized (SpongeChunk_1_11.class) { + synchronized (SpongeChunk_1_12.class) { tile.getValue().invalidate(); iterator.remove(); } @@ -281,7 +281,7 @@ public class SpongeChunk_1_11 extends CharFaweChunk { } HashSet entsToRemove = this.getEntityRemoves(); if (!entsToRemove.isEmpty()) { - synchronized (SpongeChunk_1_11.class) { + synchronized (SpongeChunk_1_12.class) { for (int i = 0; i < entities.length; i++) { Collection ents = new ArrayList<>(entities[i]); for (Entity entity : ents) { @@ -342,17 +342,17 @@ public class SpongeChunk_1_11 extends CharFaweChunk { continue; case 1: existing = nibble.get(x, y, z); - if (existing != SpongeQueue_1_11.air) { + if (existing != SpongeQueue_1_12.air) { if (existing.getLightValue() > 0) { getParent().getRelighter().addLightUpdate(bx + x, by + y, bz + z); } nonEmptyBlockCount--; } - nibble.set(x, y, z, SpongeQueue_1_11.air); + nibble.set(x, y, z, SpongeQueue_1_12.air); continue; default: existing = nibble.get(x, y, z); - if (existing != SpongeQueue_1_11.air) { + if (existing != SpongeQueue_1_12.air) { if (existing.getLightValue() > 0) { getParent().getRelighter().addLightUpdate(bx + x, by + y, bz + z); } @@ -387,7 +387,7 @@ public class SpongeChunk_1_11 extends CharFaweChunk { BlockPos pos = new BlockPos(x, y, z); // Set pos TileEntity tileEntity = nmsWorld.getTileEntity(pos); if (tileEntity != null) { - NBTTagCompound tag = (NBTTagCompound) SpongeQueue_1_11.methodFromNative.invoke(SpongeQueue_1_11.adapter, nativeTag); + NBTTagCompound tag = (NBTTagCompound) SpongeQueue_1_12.methodFromNative.invoke(SpongeQueue_1_12.adapter, nativeTag); tag.setInteger("x", pos.getX()); tag.setInteger("y", pos.getY()); tag.setInteger("z", pos.getZ()); diff --git a/sponge/src/main/java/com/boydti/fawe/sponge/v1_11/SpongeQueue_1_11.java b/sponge/src/main/java/com/boydti/fawe/sponge/v1_12/SpongeQueue_1_12.java similarity index 93% rename from sponge/src/main/java/com/boydti/fawe/sponge/v1_11/SpongeQueue_1_11.java rename to sponge/src/main/java/com/boydti/fawe/sponge/v1_12/SpongeQueue_1_12.java index a210f461..5b6ce324 100644 --- a/sponge/src/main/java/com/boydti/fawe/sponge/v1_11/SpongeQueue_1_11.java +++ b/sponge/src/main/java/com/boydti/fawe/sponge/v1_12/SpongeQueue_1_12.java @@ -1,26 +1,5 @@ -package com.boydti.fawe.sponge.v1_11; +package com.boydti.fawe.sponge.v1_12; -import com.boydti.fawe.FaweCache; -import com.boydti.fawe.example.CharFaweChunk; -import com.boydti.fawe.example.NMSMappedFaweQueue; -import com.boydti.fawe.object.FaweChunk; -import com.boydti.fawe.object.FawePlayer; -import com.boydti.fawe.object.brush.visualization.VisualChunk; -import java.util.concurrent.atomic.LongAdder; -import com.boydti.fawe.object.visitor.FaweChunkVisitor; -import com.boydti.fawe.sponge.SpongePlayer; -import com.boydti.fawe.util.MainUtil; -import com.boydti.fawe.util.MathMan; -import com.boydti.fawe.util.ReflectionUtils; -import com.sk89q.jnbt.CompoundTag; -import com.sk89q.jnbt.StringTag; -import com.sk89q.jnbt.Tag; -import com.sk89q.worldedit.sponge.SpongeWorldEdit; -import com.sk89q.worldedit.sponge.adapter.SpongeImplAdapter; -import com.sk89q.worldedit.world.biome.BaseBiome; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.ByteBufAllocator; -import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import java.io.File; import java.io.IOException; import java.lang.reflect.Field; @@ -32,6 +11,31 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.UUID; +import java.util.concurrent.atomic.LongAdder; + +import org.spongepowered.api.Sponge; + +import com.boydti.fawe.FaweCache; +import com.boydti.fawe.example.CharFaweChunk; +import com.boydti.fawe.example.NMSMappedFaweQueue; +import com.boydti.fawe.object.FaweChunk; +import com.boydti.fawe.object.FawePlayer; +import com.boydti.fawe.object.brush.visualization.VisualChunk; +import com.boydti.fawe.object.visitor.FaweChunkVisitor; +import com.boydti.fawe.sponge.SpongePlayer; +import com.boydti.fawe.util.MainUtil; +import com.boydti.fawe.util.MathMan; +import com.boydti.fawe.util.ReflectionUtils; +import com.sk89q.jnbt.CompoundTag; +import com.sk89q.jnbt.StringTag; +import com.sk89q.jnbt.Tag; +import com.sk89q.worldedit.sponge.SpongeWorldEdit; +import com.sk89q.worldedit.sponge.adapter.SpongeImplAdapter; +import com.sk89q.worldedit.world.biome.BaseBiome; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.ByteBufAllocator; +import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import net.minecraft.block.Block; import net.minecraft.block.BlockFalling; import net.minecraft.block.state.IBlockState; @@ -58,16 +62,15 @@ import net.minecraft.world.biome.BiomeCache; import net.minecraft.world.biome.BiomeProvider; import net.minecraft.world.chunk.BlockStateContainer; import net.minecraft.world.chunk.Chunk; -import net.minecraft.world.chunk.IChunkGenerator; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.chunk.NibbleArray; import net.minecraft.world.chunk.storage.ExtendedBlockStorage; -import net.minecraft.world.gen.ChunkProviderOverworld; +import net.minecraft.world.gen.ChunkGeneratorOverworld; import net.minecraft.world.gen.ChunkProviderServer; +import net.minecraft.world.gen.IChunkGenerator; import net.minecraft.world.storage.WorldInfo; -import org.spongepowered.api.Sponge; -public class SpongeQueue_1_11 extends NMSMappedFaweQueue { +public class SpongeQueue_1_12 extends NMSMappedFaweQueue { protected final static Method methodFromNative; protected final static Method methodToNative; @@ -103,7 +106,7 @@ public class SpongeQueue_1_11 extends NMSMappedFaweQueue oldWatchers = null; @@ -293,7 +296,7 @@ public class SpongeQueue_1_11 extends NMSMappedFaweQueue) fieldPlayers.get(entry); playerManager.removeEntry(entry); } - mcChunk.onChunkUnload(); + mcChunk.onUnload(); } try { Field droppedChunksSetField = chunkServer.getClass().getDeclaredField("field_73248_b"); @@ -305,11 +308,11 @@ public class SpongeQueue_1_11 extends NMSMappedFaweQueue id2ChunkMap = (Long2ObjectMap) fieldId2ChunkMap.get(chunkServer); id2ChunkMap.remove(pos); - mcChunk = gen.provideChunk(x, z); + mcChunk = gen.generateChunk(x, z); id2ChunkMap.put(pos, mcChunk); if (mcChunk != null) { - mcChunk.onChunkLoad(); - mcChunk.populateChunk(chunkServer, gen); + mcChunk.onLoad(); + mcChunk.populate(chunkServer, gen); } if (oldWatchers != null) { for (EntityPlayerMP player : oldWatchers) { @@ -334,7 +337,7 @@ public class SpongeQueue_1_11 extends NMSMappedFaweQueue map = ReflectionUtils.getMap(nativeTag.getValue()); map.put("Id", new StringTag(id)); previous.setEntity(nativeTag); @@ -500,11 +503,11 @@ public class SpongeQueue_1_11 extends NMSMappedFaweQueue getFaweChunk(int x, int z) { - return new SpongeChunk_1_11(this, x, z); + return new SpongeChunk_1_12(this, x, z); } @Override @@ -568,9 +571,9 @@ public class SpongeQueue_1_11 extends NMSMappedFaweQueue