-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merge compatibility-1.7.10 branch with this one
- Loading branch information
Showing
7 changed files
with
76 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/tk/blackwolf12333/grieflog/compatibility/v1_7_R4/ChangesSender.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package tk.blackwolf12333.grieflog.compatibility.v1_7_R4; | ||
|
||
import java.util.HashSet; | ||
|
||
import org.bukkit.Chunk; | ||
import org.bukkit.entity.Player; | ||
|
||
import tk.blackwolf12333.grieflog.rollback.SendChangesTask; | ||
import tk.blackwolf12333.grieflog.compatibility.ChangesSenderInterface; | ||
|
||
public class ChangesSender implements ChangesSenderInterface { | ||
@SuppressWarnings("unchecked") | ||
@Override | ||
public void sendChanges(SendChangesTask task, HashSet<Chunk> chunks) { | ||
HashSet<net.minecraft.server.v1_7_R4.ChunkCoordIntPair> pairs = new HashSet<net.minecraft.server.v1_7_R4.ChunkCoordIntPair>(); | ||
for (Chunk c : chunks) { | ||
pairs.add(new net.minecraft.server.v1_7_R4.ChunkCoordIntPair(c.getX(), c.getZ())); | ||
} | ||
|
||
for (Player p : task.getPlayers()) { | ||
HashSet<net.minecraft.server.v1_7_R4.ChunkCoordIntPair> queued = new HashSet<net.minecraft.server.v1_7_R4.ChunkCoordIntPair>(); | ||
if (p != null) { | ||
net.minecraft.server.v1_7_R4.EntityPlayer ep = ((org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer) p).getHandle(); | ||
for (Object o : ep.chunkCoordIntPairQueue) { | ||
queued.add((net.minecraft.server.v1_7_R4.ChunkCoordIntPair) o); | ||
} | ||
for (net.minecraft.server.v1_7_R4.ChunkCoordIntPair pair : pairs) { | ||
if (!queued.contains(pair)) { | ||
ep.chunkCoordIntPairQueue.add(pair); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/tk/blackwolf12333/grieflog/compatibility/v1_7_R4/FastBlockSetter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package tk.blackwolf12333.grieflog.compatibility.v1_7_R4; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.Chunk; | ||
import org.bukkit.Material; | ||
|
||
import tk.blackwolf12333.grieflog.compatibility.FastBlockSetterInterface; | ||
|
||
public class FastBlockSetter implements FastBlockSetterInterface { | ||
@Override | ||
public void setBlockFast(int x, int y, int z, String world, int typeID, byte data) { | ||
Chunk c = Bukkit.getWorld(world).getChunkAt(x >> 4, z >> 4); | ||
net.minecraft.server.v1_7_R4.Chunk chunk = ((org.bukkit.craftbukkit.v1_7_R4.CraftChunk) c).getHandle(); | ||
net.minecraft.server.v1_7_R4.Block block = this.getBlockType(typeID); | ||
chunk.a(x & 15, y, z & 15, block, data); // sets the block at (x,y,z) | ||
} | ||
|
||
private net.minecraft.server.v1_7_R4.Block getBlockType(int typeID) { | ||
for(Material m : Material.values()) { | ||
if(m.getId() == typeID) { | ||
try { | ||
return (net.minecraft.server.v1_7_R4.Block) net.minecraft.server.v1_7_R4.Blocks.class.getDeclaredField(m.toString()).get(null); | ||
} catch (SecurityException e) { | ||
e.printStackTrace(); | ||
} catch (NoSuchFieldException e) { | ||
e.printStackTrace(); | ||
} catch (IllegalArgumentException e) { | ||
e.printStackTrace(); | ||
} catch (IllegalAccessException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
return net.minecraft.server.v1_7_R4.Blocks.AIR; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters