Add end rod (1.13).
This commit is contained in:
parent
6e2d611e9b
commit
fbd8f6a02d
|
@ -21,15 +21,16 @@ import org.bukkit.Material;
|
|||
|
||||
import fr.neatmonster.nocheatplus.compat.BridgeMaterial;
|
||||
import fr.neatmonster.nocheatplus.compat.blocks.init.BlockInit;
|
||||
import fr.neatmonster.nocheatplus.compat.bukkit.model.BukkitDirectionalCentered;
|
||||
import fr.neatmonster.nocheatplus.compat.bukkit.model.BukkitDoor;
|
||||
import fr.neatmonster.nocheatplus.compat.bukkit.model.BukkitFence;
|
||||
import fr.neatmonster.nocheatplus.compat.bukkit.model.BukkitGate;
|
||||
import fr.neatmonster.nocheatplus.compat.bukkit.model.BukkitTrapDoor;
|
||||
import fr.neatmonster.nocheatplus.compat.bukkit.model.BukkitShapeModel;
|
||||
import fr.neatmonster.nocheatplus.compat.bukkit.model.BukkitShulkerBox;
|
||||
import fr.neatmonster.nocheatplus.compat.bukkit.model.BukkitSlab;
|
||||
import fr.neatmonster.nocheatplus.compat.bukkit.model.BukkitStairs;
|
||||
import fr.neatmonster.nocheatplus.compat.bukkit.model.BukkitStatic;
|
||||
import fr.neatmonster.nocheatplus.compat.bukkit.model.BukkitTrapDoor;
|
||||
import fr.neatmonster.nocheatplus.config.WorldConfigProvider;
|
||||
import fr.neatmonster.nocheatplus.utilities.map.BlockCache;
|
||||
import fr.neatmonster.nocheatplus.utilities.map.BlockFlags;
|
||||
|
@ -51,6 +52,8 @@ public class MCAccessBukkitModern extends MCAccessBukkit {
|
|||
// Blocks that have a different shape, based on how they have been placed.
|
||||
private static final BukkitShapeModel MODEL_SLAB = new BukkitSlab();
|
||||
private static final BukkitShapeModel MODEL_STAIRS= new BukkitStairs();
|
||||
private static final BukkitShapeModel MODEL_END_ROD = new BukkitDirectionalCentered(
|
||||
0.375, 1.0, false);
|
||||
|
||||
// Blocks that have a different shape with neighbor blocks (bukkit takes care though).
|
||||
private static final BukkitShapeModel MODEL_THIN_FENCE = new BukkitFence(
|
||||
|
@ -94,7 +97,7 @@ public class MCAccessBukkitModern extends MCAccessBukkit {
|
|||
* CAKE,
|
||||
*/
|
||||
// TODO: anvils, dead coral fans
|
||||
// TODO: END_ROD: 0.075 + 0.3, 0.925 - 0.3 / 1.0 -> BukkitCenteredFacing +-
|
||||
// TODO: Liquid (all leveled).
|
||||
|
||||
public MCAccessBukkitModern() {
|
||||
super();
|
||||
|
@ -138,6 +141,9 @@ public class MCAccessBukkitModern extends MCAccessBukkit {
|
|||
// Lily pad
|
||||
addModel(BridgeMaterial.LILY_PAD, MODEL_LILY_PAD);
|
||||
|
||||
// End rod.
|
||||
addModel(Material.END_ROD, MODEL_END_ROD);
|
||||
|
||||
// 1/8 height.
|
||||
for (Material mat : new Material[] {
|
||||
BridgeMaterial.REPEATER,
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package fr.neatmonster.nocheatplus.compat.bukkit.model;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import fr.neatmonster.nocheatplus.utilities.map.BlockCache;
|
||||
|
||||
/**
|
||||
* Somehow attached to a block face, centered cuboid.
|
||||
*
|
||||
* @author asofold
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractBukkitCentered implements BukkitShapeModel {
|
||||
|
||||
private final double minDist;
|
||||
private final double maxDist;
|
||||
private final double length;
|
||||
protected final boolean invertFace;
|
||||
|
||||
public AbstractBukkitCentered(double inset, double length,
|
||||
boolean invertFace) {
|
||||
// TODO: Might add a signature to specify minY and maxY (attach NWSE only).
|
||||
this.minDist = inset;
|
||||
this.maxDist = 1.0 - inset;
|
||||
this.length = length;
|
||||
this.invertFace = invertFace;
|
||||
}
|
||||
|
||||
protected abstract BlockFace getFacing(BlockData blockData);
|
||||
|
||||
@Override
|
||||
public double[] getShape(final BlockCache blockCache,
|
||||
final World world, final int x, final int y, final int z) {
|
||||
final Block block = world.getBlockAt(x, y, z);
|
||||
final BlockState state = block.getState();
|
||||
final BlockData blockData = state.getBlockData();
|
||||
|
||||
final BlockFace facing = invertFace
|
||||
? getFacing(blockData).getOppositeFace()
|
||||
: getFacing(blockData);
|
||||
// TODO: Evaluate if (some) faces need to be inverted.
|
||||
// End rod facing: the direction it points to.
|
||||
switch (facing) {
|
||||
case NORTH:
|
||||
return new double[] {0.0, minDist, minDist,
|
||||
length, maxDist, maxDist};
|
||||
case SOUTH:
|
||||
return new double[] {1.0 - length, minDist, minDist,
|
||||
1.0, maxDist, maxDist};
|
||||
case WEST:
|
||||
return new double[] {minDist, minDist, 0.0,
|
||||
maxDist, maxDist, length};
|
||||
case EAST:
|
||||
return new double[] {minDist, minDist, 1.0 - length,
|
||||
maxDist, maxDist, 1.0};
|
||||
case DOWN:
|
||||
return new double[] {minDist, 1.0 - length, minDist,
|
||||
maxDist, 1.0, maxDist};
|
||||
case UP:
|
||||
return new double[] {minDist, 0.0, minDist,
|
||||
maxDist, length, maxDist};
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return new double[] {0.0, 0.0, 0.0, 1.0, 1.0, 1.0};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFakeData(final BlockCache blockCache,
|
||||
final World world, final int x, final int y, final int z) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package fr.neatmonster.nocheatplus.compat.bukkit.model;
|
||||
|
||||
import org.bukkit.World;
|
||||
|
||||
import fr.neatmonster.nocheatplus.utilities.map.BlockCache;
|
||||
|
||||
/**
|
||||
* Somehow attached to a block face, centered cuboid.
|
||||
*
|
||||
* @author asofold
|
||||
*
|
||||
*/
|
||||
public class BukkitAttachedCentered implements BukkitShapeModel {
|
||||
|
||||
// TODO: Add modifications (shape alteration interface).
|
||||
|
||||
public BukkitAttachedCentered(double inset, double length,
|
||||
boolean invertFace) {
|
||||
// TODO: Might add a signature to specify minY and maxY (attach NWSE only).
|
||||
// TODO: Implement.
|
||||
}
|
||||
|
||||
@Override
|
||||
public double[] getShape(final BlockCache blockCache,
|
||||
final World world, final int x, final int y, final int z) {
|
||||
// TODO: Implement (attached face via ... directional and/or facing etc.).
|
||||
return new double[] {0.0, 0.0, 0.0, 1.0, 1.0, 1.0};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFakeData(final BlockCache blockCache,
|
||||
final World world, final int x, final int y, final int z) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package fr.neatmonster.nocheatplus.compat.bukkit.model;
|
||||
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.Directional;
|
||||
|
||||
public class BukkitDirectionalCentered extends AbstractBukkitCentered {
|
||||
|
||||
public BukkitDirectionalCentered(double inset, double length,
|
||||
boolean invertFace) {
|
||||
super(inset, length, invertFace);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockFace getFacing(final BlockData blockData) {
|
||||
if (blockData instanceof Directional) {
|
||||
return ((Directional) blockData).getFacing();
|
||||
}
|
||||
else {
|
||||
return BlockFace.SELF;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue