mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-30 22:44:17 +01:00
Maintain old setType method in WorldGenerator. Fixes BUKKIT-4915
WorldGenerator setType and setTypeAndData have their arguments changed to add in support for CraftBlockChangeDelegate, which changes the method signature. This change in the method signature breaks any WorldGenerators that aren't modified to use CraftBlockChangeDelegate. This commit fixes the issue by readding the old method and maintaining the CraftBlockChangeDelegate method. This makes it so that there is a compatible method for both CraftBlockChangeDelegate WorldGenerators and unmodified WorldGenerators. Additionally, this commit reduces and corrects the diffs in WorldGenerator, moving the fix for layering violations to CraftBlockChangeDelegate.
This commit is contained in:
parent
a721fe8473
commit
39719fff74
@ -20,23 +20,31 @@ public abstract class WorldGenerator {
|
|||||||
|
|
||||||
public void a(double d0, double d1, double d2) {}
|
public void a(double d0, double d1, double d2) {}
|
||||||
|
|
||||||
// CraftBukkit - change signature
|
protected void setType(World world, int i, int j, int k, Block block) {
|
||||||
protected void setType(CraftBlockChangeDelegate world, int i, int j, int k, Block block) {
|
|
||||||
this.setTypeAndData(world, i, j, k, block, 0);
|
this.setTypeAndData(world, i, j, k, block, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// CraftBukkit - change signature
|
// CraftBukkit start - Duplicate method to add support for CraftBlockChangeDelegate
|
||||||
|
protected void setType(CraftBlockChangeDelegate world, int i, int j, int k, Block block) {
|
||||||
|
this.setTypeAndData(world, i, j, k, block, 0);
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
|
|
||||||
|
protected void setTypeAndData(World world, int i, int j, int k, Block block, int l) {
|
||||||
|
if (this.a) {
|
||||||
|
world.setTypeAndData(i, j, k, block, l, 3);
|
||||||
|
} else {
|
||||||
|
world.setTypeAndData(i, j, k, block, l, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CraftBukkit start - Duplicate method to add support for CraftBlockChangeDelegate
|
||||||
protected void setTypeAndData(CraftBlockChangeDelegate world, int i, int j, int k, Block block, int l) {
|
protected void setTypeAndData(CraftBlockChangeDelegate world, int i, int j, int k, Block block, int l) {
|
||||||
if (this.a) {
|
if (this.a) {
|
||||||
world.setTypeAndData(i, j, k, block, l, 3);
|
world.setTypeAndData(i, j, k, block, l, 3);
|
||||||
} else {
|
|
||||||
// CraftBukkit start - Layering violation :(
|
|
||||||
if (world.getDelegate() instanceof World) {
|
|
||||||
((World) world.getDelegate()).setTypeAndData(i, j, k, block, l, 2);
|
|
||||||
} else {
|
} else {
|
||||||
world.setTypeAndData(i, j, k, block, l, 2);
|
world.setTypeAndData(i, j, k, block, l, 2);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package org.bukkit.craftbukkit;
|
package org.bukkit.craftbukkit;
|
||||||
|
|
||||||
import net.minecraft.server.Block;
|
import net.minecraft.server.Block;
|
||||||
|
import net.minecraft.server.World;
|
||||||
|
|
||||||
import org.bukkit.BlockChangeDelegate;
|
import org.bukkit.BlockChangeDelegate;
|
||||||
|
|
||||||
@ -19,9 +20,14 @@ public class CraftBlockChangeDelegate {
|
|||||||
return Block.e(this.delegate.getTypeId(x, y, z));
|
return Block.e(this.delegate.getTypeId(x, y, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTypeAndData(int x, int y, int z, Block block, int data, int light) {
|
public void setTypeAndData(int x, int y, int z, Block block, int data, int updateFlag) {
|
||||||
|
// Layering violation :(
|
||||||
|
if (delegate instanceof World) {
|
||||||
|
((World) delegate).setTypeAndData(x, y, z, block, data, 2);
|
||||||
|
} else {
|
||||||
delegate.setRawTypeIdAndData(x, y, z, Block.b(block), data);
|
delegate.setRawTypeIdAndData(x, y, z, Block.b(block), data);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isEmpty(int x, int y, int z) {
|
public boolean isEmpty(int x, int y, int z) {
|
||||||
return delegate.isEmpty(x, y, z);
|
return delegate.isEmpty(x, y, z);
|
||||||
|
Loading…
Reference in New Issue
Block a user