mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-11-20 02:45:00 +00:00
Cleanup. Cycler uses BaseBlock instead of BlockData directly. Fixed a few BlockType method inaccuracies.
This commit is contained in:
parent
9e877740aa
commit
68fe0d3438
@ -90,21 +90,37 @@ public class BaseBlock {
|
|||||||
* @return if air
|
* @return if air
|
||||||
*/
|
*/
|
||||||
public boolean isAir() {
|
public boolean isAir() {
|
||||||
return type == 0;
|
return type == BlockID.AIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rotate this block 90 degrees.
|
* Rotate this block 90 degrees.
|
||||||
*/
|
*/
|
||||||
public void rotate90() {
|
public int rotate90() {
|
||||||
data = (byte) BlockData.rotate90(type, data);
|
int newData = BlockData.rotate90(type, data);
|
||||||
|
this.data = (byte) newData;
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rotate this block -90 degrees.
|
* Rotate this block -90 degrees.
|
||||||
*/
|
*/
|
||||||
public void rotate90Reverse() {
|
public int rotate90Reverse() {
|
||||||
data = (byte) BlockData.rotate90Reverse(type, data);
|
int newData = BlockData.rotate90Reverse(type, data);
|
||||||
|
this.data = (byte) newData;
|
||||||
|
return newData;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cycle the damage value of the block forward or backward
|
||||||
|
*
|
||||||
|
* @param increment 1 for forward, -1 for backward
|
||||||
|
* @return new data value
|
||||||
|
*/
|
||||||
|
public int cycleData(int increment) {
|
||||||
|
int newData = BlockData.cycle(this.type, this.data, increment);
|
||||||
|
this.data = (byte) newData;
|
||||||
|
return newData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -135,7 +151,7 @@ public class BaseBlock {
|
|||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int ret = type << 3;
|
int ret = type << 3;
|
||||||
if (data != (byte)-1) ret |= data;
|
if (data != (byte) -1) ret |= data;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,6 +110,7 @@ public final class BlockData {
|
|||||||
|
|
||||||
case BlockID.LADDER:
|
case BlockID.LADDER:
|
||||||
case BlockID.WALL_SIGN:
|
case BlockID.WALL_SIGN:
|
||||||
|
case BlockID.CHEST:
|
||||||
case BlockID.FURNACE:
|
case BlockID.FURNACE:
|
||||||
case BlockID.BURNING_FURNACE:
|
case BlockID.BURNING_FURNACE:
|
||||||
case BlockID.DISPENSER:
|
case BlockID.DISPENSER:
|
||||||
@ -268,6 +269,7 @@ public final class BlockData {
|
|||||||
|
|
||||||
case BlockID.LADDER:
|
case BlockID.LADDER:
|
||||||
case BlockID.WALL_SIGN:
|
case BlockID.WALL_SIGN:
|
||||||
|
case BlockID.CHEST:
|
||||||
case BlockID.FURNACE:
|
case BlockID.FURNACE:
|
||||||
case BlockID.BURNING_FURNACE:
|
case BlockID.BURNING_FURNACE:
|
||||||
case BlockID.DISPENSER:
|
case BlockID.DISPENSER:
|
||||||
@ -453,6 +455,7 @@ public final class BlockData {
|
|||||||
|
|
||||||
case BlockID.LADDER:
|
case BlockID.LADDER:
|
||||||
case BlockID.WALL_SIGN:
|
case BlockID.WALL_SIGN:
|
||||||
|
case BlockID.CHEST:
|
||||||
case BlockID.FURNACE:
|
case BlockID.FURNACE:
|
||||||
case BlockID.BURNING_FURNACE:
|
case BlockID.BURNING_FURNACE:
|
||||||
case BlockID.DISPENSER:
|
case BlockID.DISPENSER:
|
||||||
|
@ -397,7 +397,6 @@ public enum BlockType {
|
|||||||
usesData.add(BlockID.LOG);
|
usesData.add(BlockID.LOG);
|
||||||
usesData.add(BlockID.LEAVES);
|
usesData.add(BlockID.LEAVES);
|
||||||
usesData.add(BlockID.DISPENSER);
|
usesData.add(BlockID.DISPENSER);
|
||||||
usesData.add(BlockID.NOTE_BLOCK);
|
|
||||||
usesData.add(BlockID.BED);
|
usesData.add(BlockID.BED);
|
||||||
usesData.add(BlockID.POWERED_RAIL);
|
usesData.add(BlockID.POWERED_RAIL);
|
||||||
usesData.add(BlockID.DETECTOR_RAIL);
|
usesData.add(BlockID.DETECTOR_RAIL);
|
||||||
@ -409,7 +408,9 @@ public enum BlockType {
|
|||||||
usesData.add(BlockID.DOUBLE_STEP);
|
usesData.add(BlockID.DOUBLE_STEP);
|
||||||
usesData.add(BlockID.STEP);
|
usesData.add(BlockID.STEP);
|
||||||
usesData.add(BlockID.TORCH);
|
usesData.add(BlockID.TORCH);
|
||||||
|
usesData.add(BlockID.FIRE);
|
||||||
usesData.add(BlockID.WOODEN_STAIRS);
|
usesData.add(BlockID.WOODEN_STAIRS);
|
||||||
|
usesData.add(BlockID.CHEST);
|
||||||
usesData.add(BlockID.REDSTONE_WIRE);
|
usesData.add(BlockID.REDSTONE_WIRE);
|
||||||
usesData.add(BlockID.CROPS);
|
usesData.add(BlockID.CROPS);
|
||||||
usesData.add(BlockID.SOIL);
|
usesData.add(BlockID.SOIL);
|
||||||
@ -430,6 +431,8 @@ public enum BlockType {
|
|||||||
usesData.add(BlockID.STONE_BUTTON);
|
usesData.add(BlockID.STONE_BUTTON);
|
||||||
usesData.add(BlockID.SNOW);
|
usesData.add(BlockID.SNOW);
|
||||||
usesData.add(BlockID.CACTUS);
|
usesData.add(BlockID.CACTUS);
|
||||||
|
usesData.add(BlockID.REED);
|
||||||
|
usesData.add(BlockID.JUKEBOX);
|
||||||
usesData.add(BlockID.PUMPKIN);
|
usesData.add(BlockID.PUMPKIN);
|
||||||
usesData.add(BlockID.JACKOLANTERN);
|
usesData.add(BlockID.JACKOLANTERN);
|
||||||
usesData.add(BlockID.CAKE_BLOCK);
|
usesData.add(BlockID.CAKE_BLOCK);
|
||||||
@ -880,9 +883,9 @@ public enum BlockType {
|
|||||||
nonDataAttachments.put(BlockID.LONG_GRASS, PlayerDirection.DOWN);
|
nonDataAttachments.put(BlockID.LONG_GRASS, PlayerDirection.DOWN);
|
||||||
nonDataAttachments.put(BlockID.DEAD_BUSH, PlayerDirection.DOWN);
|
nonDataAttachments.put(BlockID.DEAD_BUSH, PlayerDirection.DOWN);
|
||||||
for (int offset = 0; offset <= 8; offset += 8) {
|
for (int offset = 0; offset <= 8; offset += 8) {
|
||||||
dataAttachments.put(attachmentKey(BlockID.PISTON_EXTENSION, offset+0), PlayerDirection.UP);
|
dataAttachments.put(attachmentKey(BlockID.PISTON_EXTENSION, offset + 0), PlayerDirection.UP);
|
||||||
dataAttachments.put(attachmentKey(BlockID.PISTON_EXTENSION, offset+1), PlayerDirection.DOWN);
|
dataAttachments.put(attachmentKey(BlockID.PISTON_EXTENSION, offset + 1), PlayerDirection.DOWN);
|
||||||
addCardinals(BlockID.PISTON_EXTENSION, offset+2, offset+5, offset+3, offset+4);
|
addCardinals(BlockID.PISTON_EXTENSION, offset + 2, offset + 5, offset + 3, offset + 4);
|
||||||
}
|
}
|
||||||
nonDataAttachments.put(BlockID.YELLOW_FLOWER, PlayerDirection.DOWN);
|
nonDataAttachments.put(BlockID.YELLOW_FLOWER, PlayerDirection.DOWN);
|
||||||
nonDataAttachments.put(BlockID.RED_FLOWER, PlayerDirection.DOWN);
|
nonDataAttachments.put(BlockID.RED_FLOWER, PlayerDirection.DOWN);
|
||||||
@ -900,16 +903,16 @@ public enum BlockType {
|
|||||||
nonDataAttachments.put(BlockID.MINECART_TRACKS, PlayerDirection.DOWN);
|
nonDataAttachments.put(BlockID.MINECART_TRACKS, PlayerDirection.DOWN);
|
||||||
addCardinals(BlockID.WALL_SIGN, 2, 5, 3, 4);
|
addCardinals(BlockID.WALL_SIGN, 2, 5, 3, 4);
|
||||||
for (int offset = 0; offset <= 8; offset += 8) {
|
for (int offset = 0; offset <= 8; offset += 8) {
|
||||||
addCardinals(BlockID.LEVER, offset+4, offset+1, offset+3, offset+2);
|
addCardinals(BlockID.LEVER, offset + 4, offset + 1, offset + 3, offset + 2);
|
||||||
dataAttachments.put(attachmentKey(BlockID.LEVER, offset+5), PlayerDirection.DOWN);
|
dataAttachments.put(attachmentKey(BlockID.LEVER, offset + 5), PlayerDirection.DOWN);
|
||||||
dataAttachments.put(attachmentKey(BlockID.LEVER, offset+6), PlayerDirection.DOWN);
|
dataAttachments.put(attachmentKey(BlockID.LEVER, offset + 6), PlayerDirection.DOWN);
|
||||||
}
|
}
|
||||||
nonDataAttachments.put(BlockID.STONE_PRESSURE_PLATE, PlayerDirection.DOWN);
|
nonDataAttachments.put(BlockID.STONE_PRESSURE_PLATE, PlayerDirection.DOWN);
|
||||||
nonDataAttachments.put(BlockID.IRON_DOOR, PlayerDirection.DOWN);
|
nonDataAttachments.put(BlockID.IRON_DOOR, PlayerDirection.DOWN);
|
||||||
nonDataAttachments.put(BlockID.WOODEN_PRESSURE_PLATE, PlayerDirection.DOWN);
|
nonDataAttachments.put(BlockID.WOODEN_PRESSURE_PLATE, PlayerDirection.DOWN);
|
||||||
// redstone torches: see torches
|
// redstone torches: see torches
|
||||||
for (int offset = 0; offset <= 8; offset += 8) {
|
for (int offset = 0; offset <= 8; offset += 8) {
|
||||||
addCardinals(BlockID.STONE_BUTTON, offset+4, offset+1, offset+3, offset+2);
|
addCardinals(BlockID.STONE_BUTTON, offset + 4, offset + 1, offset + 3, offset + 2);
|
||||||
}
|
}
|
||||||
nonDataAttachments.put(BlockID.CACTUS, PlayerDirection.DOWN);
|
nonDataAttachments.put(BlockID.CACTUS, PlayerDirection.DOWN);
|
||||||
nonDataAttachments.put(BlockID.REED, PlayerDirection.DOWN);
|
nonDataAttachments.put(BlockID.REED, PlayerDirection.DOWN);
|
||||||
@ -917,7 +920,7 @@ public enum BlockType {
|
|||||||
nonDataAttachments.put(BlockID.REDSTONE_REPEATER_OFF, PlayerDirection.DOWN);
|
nonDataAttachments.put(BlockID.REDSTONE_REPEATER_OFF, PlayerDirection.DOWN);
|
||||||
nonDataAttachments.put(BlockID.REDSTONE_REPEATER_ON, PlayerDirection.DOWN);
|
nonDataAttachments.put(BlockID.REDSTONE_REPEATER_ON, PlayerDirection.DOWN);
|
||||||
for (int offset = 0; offset <= 4; offset += 4) {
|
for (int offset = 0; offset <= 4; offset += 4) {
|
||||||
addCardinals(BlockID.TRAP_DOOR, offset+0, offset+3, offset+1, offset+2);
|
addCardinals(BlockID.TRAP_DOOR, offset + 0, offset + 3, offset + 1, offset + 2);
|
||||||
}
|
}
|
||||||
nonDataAttachments.put(BlockID.PUMPKIN_STEM, PlayerDirection.DOWN);
|
nonDataAttachments.put(BlockID.PUMPKIN_STEM, PlayerDirection.DOWN);
|
||||||
nonDataAttachments.put(BlockID.MELON_STEM, PlayerDirection.DOWN);
|
nonDataAttachments.put(BlockID.MELON_STEM, PlayerDirection.DOWN);
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
package com.sk89q.worldedit.tools;
|
package com.sk89q.worldedit.tools;
|
||||||
|
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
import com.sk89q.worldedit.blocks.BlockData;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A mode that cycles the data values of supported blocks.
|
* A mode that cycles the data values of supported blocks.
|
||||||
@ -49,12 +49,13 @@ public class BlockDataCyler implements DoubleActionBlockTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int increment = forward ? 1 : -1;
|
int increment = forward ? 1 : -1;
|
||||||
data = BlockData.cycle(type, data, increment);
|
data = (new BaseBlock(type, data)).cycleData(increment);
|
||||||
|
|
||||||
if (data < 0) {
|
if (data < 0) {
|
||||||
player.printError("That block's data cannot be cycled!");
|
player.printError("That block's data cannot be cycled!");
|
||||||
return true;
|
} else {
|
||||||
|
world.setBlockData(clicked, data);
|
||||||
}
|
}
|
||||||
world.setBlockData(clicked, data);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user