Paper/src/main/java/org/bukkit/craftbukkit/CraftBlockChangeDelegate.java
Nate Mortensen 39719fff74 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.
2013-12-02 21:03:57 -07:00

36 Zeilen
980 B
Java

package org.bukkit.craftbukkit;
import net.minecraft.server.Block;
import net.minecraft.server.World;
import org.bukkit.BlockChangeDelegate;
public class CraftBlockChangeDelegate {
private final BlockChangeDelegate delegate;
public CraftBlockChangeDelegate(BlockChangeDelegate delegate) {
this.delegate = delegate;
}
public BlockChangeDelegate getDelegate() {
return delegate;
}
public Block getType(int x, int y, int z) {
return Block.e(this.delegate.getTypeId(x, y, z));
}
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);
}
}
public boolean isEmpty(int x, int y, int z) {
return delegate.isEmpty(x, y, z);
}
}