|
4 | 4 | */ |
5 | 5 | package org.pepsoft.bukkit.bukkitscript.context; |
6 | 6 |
|
7 | | -import java.util.logging.Level; |
8 | | -import net.minecraft.server.v1_7_R3.Chunk; |
| 7 | +import net.minecraft.server.v1_8_R2.Block; |
| 8 | +import net.minecraft.server.v1_8_R2.BlockPosition; |
| 9 | +import net.minecraft.server.v1_8_R2.Chunk; |
| 10 | +import net.minecraft.server.v1_8_R2.IBlockData; |
9 | 11 | import org.bukkit.Material; |
10 | 12 | import org.bukkit.OfflinePlayer; |
11 | 13 | import org.bukkit.World; |
12 | | -import org.bukkit.craftbukkit.v1_7_R3.CraftChunk; |
13 | | -import org.bukkit.craftbukkit.v1_7_R3.CraftWorld; |
| 14 | +import org.bukkit.craftbukkit.v1_8_R2.CraftChunk; |
| 15 | +import org.bukkit.craftbukkit.v1_8_R2.CraftWorld; |
14 | 16 | import org.bukkit.entity.Entity; |
15 | 17 | import org.bukkit.event.EventHandler; |
16 | 18 | import org.bukkit.event.EventPriority; |
|
21 | 23 | import org.pepsoft.bukkit.Constants; |
22 | 24 | import org.pepsoft.bukkit.bukkitscript.BukkitScriptPlugin; |
23 | 25 | import org.pepsoft.bukkit.bukkitscript.Location; |
24 | | -import org.pepsoft.bukkit.bukkitscript.context.Players.PlayerVisitor; |
25 | 26 | import org.pepsoft.bukkit.bukkitscript.context.Players.PlayerProvider; |
| 27 | +import org.pepsoft.bukkit.bukkitscript.context.Players.PlayerVisitor; |
26 | 28 | import org.pepsoft.bukkit.bukkitscript.event.Event; |
27 | 29 |
|
| 30 | +import java.util.logging.Level; |
| 31 | + |
28 | 32 | /** |
29 | 33 | * |
30 | 34 | * @author pepijn |
@@ -176,20 +180,21 @@ public boolean visitEntity(World world, Entity entity) { |
176 | 180 |
|
177 | 181 | void set(int typeId, byte data) { |
178 | 182 | // Go chunk by chunk to try to be as efficient as possible |
| 183 | + IBlockData blockData = Block.getById(typeId).fromLegacyData(data); |
179 | 184 | int chunkX1 = corner1.x >> 4; |
180 | 185 | int chunkX2 = corner2.x >> 4; |
181 | 186 | int chunkZ1 = corner1.z >> 4; |
182 | 187 | int chunkZ2 = corner2.z >> 4; |
183 | 188 | for (int chunkX = chunkX1; chunkX <= chunkX2; chunkX++) { |
184 | 189 | for (int chunkZ = chunkZ1; chunkZ <= chunkZ2; chunkZ++) { |
185 | | - net.minecraft.server.v1_7_R3.World mcWorld = ((CraftWorld) realWorld).getHandle(); |
| 190 | + net.minecraft.server.v1_8_R2.World mcWorld = ((CraftWorld) realWorld).getHandle(); |
186 | 191 | for (int y = corner1.y; y <= corner2.y; y++) { |
187 | 192 | for (int dx = 0; dx < 16; dx++) { |
188 | 193 | for (int dz = 0; dz < 16; dz++) { |
189 | 194 | int x = (chunkX << 4) | dx; |
190 | 195 | int z = (chunkZ << 4) | dz; |
191 | 196 | if ((x >= corner1.x) && (x <= corner2.x) && (z >= corner1.z) && (z <= corner2.z)) { |
192 | | - mcWorld.setTypeAndData(x, y, z, net.minecraft.server.v1_7_R3.Block.e(typeId), data, FLAG_UPDATE | FLAG_MARK_CHUNK_DIRTY | FLAG_ONLY_IF_NOT_STATIC); |
| 197 | + mcWorld.setTypeUpdate(new BlockPosition(x, y, z), blockData); |
193 | 198 | } |
194 | 199 | } |
195 | 200 | } |
@@ -218,7 +223,7 @@ void visitBlocks(int blockTypeId, BlockVisitor visitor) { |
218 | 223 | for (int chunkZ = chunkZ1; chunkZ <= chunkZ2; chunkZ++) { |
219 | 224 | Chunk chunk = ((CraftChunk) this.realWorld.getChunkAt(chunkX, chunkZ)).getHandle(); |
220 | 225 | for (int y = corner1.y; y <= corner2.y; y++) { |
221 | | - if (chunk.i()[(y >> 4)] == null) { |
| 226 | + if (chunk.getSections()[(y >> 4)] == null) { |
222 | 227 | if (blockTypeId == 0) { |
223 | 228 | for (int dx = 0; dx < 16; dx++) { |
224 | 229 | for (int dz = 0; dz < 16; dz++) { |
@@ -263,7 +268,7 @@ void visitBlocks(int blockTypeId, int blockDataMask, int blockDataValue, BlockVi |
263 | 268 | for (int chunkZ = chunkZ1; chunkZ <= chunkZ2; chunkZ++) { |
264 | 269 | Chunk chunk = ((CraftChunk) this.realWorld.getChunkAt(chunkX, chunkZ)).getHandle(); |
265 | 270 | for (int y = corner1.y; y <= corner2.y; y++) { |
266 | | - if (chunk.i()[(y >> 4)] == null) { |
| 271 | + if (chunk.getSections()[(y >> 4)] == null) { |
267 | 272 | if ((blockTypeId == 0) && (blockDataValue == 0)) { |
268 | 273 | for (int dx = 0; dx < 16; dx++) { |
269 | 274 | for (int dz = 0; dz < 16; dz++) { |
@@ -320,13 +325,11 @@ void visitEntities(Class<? extends Entity> entityType, EntityVisitor visitor) { |
320 | 325 | } |
321 | 326 | } |
322 | 327 | } |
| 328 | + |
323 | 329 | private final org.bukkit.World realWorld; |
324 | 330 | private final OfflinePlayer realPlayer; |
325 | 331 | private final Location corner1, corner2; |
326 | 332 | static final EventListener EVENT_LISTENER = new EventListener(); |
327 | | - private static final int FLAG_UPDATE = 0x1; |
328 | | - private static final int FLAG_MARK_CHUNK_DIRTY = 0x2; |
329 | | - private static final int FLAG_ONLY_IF_NOT_STATIC = 0x4; |
330 | 333 |
|
331 | 334 | public interface BlockVisitor { |
332 | 335 | boolean visitBlock(org.bukkit.World world, int x, int y, int z, int blockTypeId, int blockData); |
|
0 commit comments