Skip to content

Commit

Permalink
Brewing stand, cauldron, hopper, end portal frame.
Browse files Browse the repository at this point in the history
  • Loading branch information
asofold committed Aug 26, 2018
1 parent a142df0 commit b422d07
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 27 deletions.
Expand Up @@ -20,7 +20,6 @@

import org.bukkit.Material;

import fr.neatmonster.nocheatplus.compat.BridgeMaterial;
import fr.neatmonster.nocheatplus.compat.blocks.BlockPropertiesSetup;
import fr.neatmonster.nocheatplus.config.WorldConfigProvider;
import fr.neatmonster.nocheatplus.logging.StaticLog;
Expand Down Expand Up @@ -56,16 +55,6 @@ else if (guessItchyBlock(mat)) {
itchyBlocks.add(mat);
}
}
// Blocks that are reported to be full and solid, but which are not.
final long flags = BlockProperties.F_IGN_PASSABLE | BlockProperties.F_GROUND_HEIGHT;
for (final Material mat : new Material[]{
BridgeMaterial.END_PORTAL_FRAME,
}) {
if (!processedBlocks.contains(mat)) {
BlockProperties.setBlockFlags(mat, BlockProperties.getBlockFlags(mat) | flags);
itchyBlocks.add(mat);
}
}
if (!itchyBlocks.isEmpty()) {
StaticLog.logDebug("The following blocks can not be modeled correctly: " + StringUtil.join(itchyBlocks, ", "));
}
Expand Down
Expand Up @@ -23,6 +23,7 @@
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.BukkitEndPortalFrame;
import fr.neatmonster.nocheatplus.compat.bukkit.model.BukkitFence;
import fr.neatmonster.nocheatplus.compat.bukkit.model.BukkitGate;
import fr.neatmonster.nocheatplus.compat.bukkit.model.BukkitShapeModel;
Expand All @@ -48,6 +49,8 @@ public class MCAccessBukkitModern extends MCAccessBukkit {
0.375, 1.5);
private static final BukkitShapeModel MODEL_SHULKER_BOX = new BukkitShulkerBox();

// Blocks with different heights based on whatever.
private static final BukkitShapeModel MODEL_END_PORTAL_FRAME = new BukkitEndPortalFrame();

// Blocks that have a different shape, based on how they have been placed.
private static final BukkitShapeModel MODEL_SLAB = new BukkitSlab();
Expand Down Expand Up @@ -88,15 +91,18 @@ public class MCAccessBukkitModern extends MCAccessBukkit {
0.5625);
private static final BukkitShapeModel MODEL_XZ100_HEIGHT4_3 = new BukkitStatic(
0.75);
private static final BukkitShapeModel MODEL_XZ100_HEIGHT8_7 = new BukkitStatic(
0.875);
private static final BukkitShapeModel MODEL_XZ100_HEIGHT16_15 = new BukkitStatic(
0.9375);

/*
* TODO:
* BREWING_STAND, CAULDRON, CONDUIT, HOPPER, END_PORTAL_FRAME,
* LADDER,
* CONDUIT,
* CHORUS_FLOWER, CHORUS_PLANT, COCOA,
* TURTLE_EGG, SEA_PICKLE,
* VINE, LADDER,
* VINE,
* CAKE,
*/
// TODO: anvils, dead coral fans
Expand Down Expand Up @@ -129,18 +135,28 @@ public void setupBlockProperties(final WorldConfigProvider<?> worldConfigProvide

// TODO: Also consider removing flags (passable_x4 etc).

// Adjust flags for individual blocks.
BlockProperties.setBlockFlags(Material.CAULDRON,
BlockFlags.SOLID_GROUND | BlockProperties.F_GROUND_HEIGHT
| BlockProperties.F_MIN_HEIGHT4_1);

// Directly keep blocks as is.
for (final Material mat : new Material[] {
Material.CAULDRON,
BridgeMaterial.COBWEB,
Material.HOPPER,
BridgeMaterial.MOVING_PISTON,
Material.SNOW,
BridgeMaterial.COBWEB
Material.SNOW
}) {
processedBlocks.add(mat);
}

// Lily pad
addModel(BridgeMaterial.LILY_PAD, MODEL_LILY_PAD);

// End portal frame.
addModel(BridgeMaterial.END_PORTAL_FRAME, MODEL_END_PORTAL_FRAME);

// End rod.
addModel(Material.END_ROD, MODEL_END_ROD);

Expand Down Expand Up @@ -174,6 +190,13 @@ public void setupBlockProperties(final WorldConfigProvider<?> worldConfigProvide
addModel(mat, MODEL_XZ100_HEIGHT4_3);
}

// 7/8 height.
for (Material mat : new Material[] {
Material.BREWING_STAND // TODO: base is 1/8, center 0.875 - needs multi-cuboid.
}) {
addModel(mat, MODEL_XZ100_HEIGHT8_7);
}

// 16/15 height, full xz bounds.
for (Material mat : new Material[] {
Material.GRASS_PATH, BridgeMaterial.FARMLAND
Expand Down
@@ -0,0 +1,43 @@
package fr.neatmonster.nocheatplus.compat.bukkit.model;

import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.type.EndPortalFrame;

import fr.neatmonster.nocheatplus.utilities.map.BlockCache;

public class BukkitEndPortalFrame implements BukkitShapeModel {

@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();
if (blockData instanceof EndPortalFrame) {
return ((EndPortalFrame) blockData).hasEye()
? new double[] {0.0, 0.0, 0.0, 1.0, 1.0, 1.0}
: new double[] {0.0, 0.0, 0.0, 1.0, 0.8125, 1.0};
}
else {
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) {
final Block block = world.getBlockAt(x, y, z);
final BlockState state = block.getState();
final BlockData blockData = state.getBlockData();
if (blockData instanceof EndPortalFrame) {
return ((EndPortalFrame) blockData).hasEye() ? 0x4 : 0;
}
else {
return 0;
}
}

}
Expand Up @@ -91,8 +91,8 @@ public void setupBlockProperties(WorldConfigProvider<?> worldConfigProvider) {

// 154 Hopper
BlockInit.setAs("HOPPER", Material.COAL_ORE);
// TODO: Needs workaround. [workaround-flag + different purpose flag sets ?]
BlockFlags.addFlags("HOPPER", BlockProperties.F_IGN_PASSABLE | BlockProperties.F_GROUND_HEIGHT);
BlockFlags.addFlags("HOPPER", BlockProperties.F_GROUND_HEIGHT
| BlockProperties.F_MIN_HEIGHT16_11);

// 155 Block of Quartz
BlockInit.setAs("QUARTZ_BLOCK", Material.SANDSTONE);
Expand Down
Expand Up @@ -778,11 +778,34 @@ private static long f_flag() {
*/
public static final long F_MIN_HEIGHT16_15 = f_flag();

/**
* Minimum height 13/16 (8125). <br>
* Only applies with F_GROUND_HEIGHT set.
*/
public static final long F_MIN_HEIGHT16_13 = f_flag();

/**
* Minimum height 11/16 (0.6875). <br>
* Only applies with F_GROUND_HEIGHT set.
*/
public static final long F_MIN_HEIGHT16_11 = f_flag();

/**
* Minimum height 5/16 (0.3125). <br>
* Only applies with F_GROUND_HEIGHT set.
*/
public static final long F_MIN_HEIGHT16_5 = f_flag();

/**
* Minimum height 1/4 (0.25). <br>
* Only applies with F_GROUND_HEIGHT set.
*/
public static final long F_MIN_HEIGHT4_1 = f_flag();

/**
* Minimum height 1/16 (0.0625). <br>
* Only applies with F_GROUND_HEIGHT set.
*/
// TODO: Lily pad min height of MC versions?
public static final long F_MIN_HEIGHT16_1 = f_flag();

/** CARPET. **/
Expand Down Expand Up @@ -1189,6 +1212,7 @@ else if (mcAccess.isBlockSolid(mat).decide()) {
}) {
setFlag(mat, F_GROUND_HEIGHT);
}
setFlag(BridgeMaterial.END_PORTAL_FRAME, F_MIN_HEIGHT16_13);
// Issues standing on with F_PASSABLE_X4. Note getGroundMinHeight.
for (Material mat : MaterialUtil.WOODEN_TRAP_DOORS) {
setFlag(mat, F_GROUND_HEIGHT);
Expand Down Expand Up @@ -1357,6 +1381,8 @@ else if (mcAccess.isBlockSolid(mat).decide()) {
setBlock(mat, brickType);
}
}
setBlockFlags(Material.CAULDRON, BlockFlags.SOLID_GROUND
| F_GROUND_HEIGHT | F_MIN_HEIGHT16_5); // LEGACY
setBlock(BridgeMaterial.CRAFTING_TABLE, chestType);
setBlock(Material.CHEST, chestType);
for (Material mat : MaterialUtil.WOODEN_DOORS) {
Expand Down Expand Up @@ -3068,7 +3094,8 @@ else if (id == BridgeMaterial.CAKE) {
}
}
else if (id == Material.CAULDRON) {
if (Math.min(fy, fy + dY * dT) >= 0.3125) {
if (Math.min(fy, fy + dY * dT) >= getGroundMinHeight(
access, bx, by, bz, node, flags)) {
// Check for moving through walls or floor.
// TODO: Maybe this is too exact...
return isInsideCenter(fx, fz, dX, dZ, dT, 0.125);
Expand Down Expand Up @@ -3272,20 +3299,12 @@ else if (id == Material.SOUL_SAND) {
// else if (id == BridgeMaterial.CAKE.getId()) {
// return 0.4375;
// }
else if (id == Material.CAULDRON) {
// TODO: slightly over 0.
return 0.3125;
}
else if (id == Material.CACTUS) {
return 0.9375;
}
else if (id == BridgeMaterial.PISTON_HEAD) {
return 0.625;
}
else if (id == BridgeMaterial.END_PORTAL_FRAME) {
// Allow moving as if no eye was inserted.
return 0.8125;
}
else if (bounds == null) {
return 0.0;
}
Expand All @@ -3295,6 +3314,22 @@ else if ((flags & F_GROUND_HEIGHT) != 0) {
// 1/16
return 0.0625;
}
if ((flags & F_MIN_HEIGHT4_1) != 0) {
// 1/4
return 0.25;
}
if ((flags & F_MIN_HEIGHT16_5) != 0) {
// 5/16
return 0.3125;
}
if ((flags & F_MIN_HEIGHT16_11) != 0) {
// 11/16
return 0.6875;
}
if ((flags & F_MIN_HEIGHT16_13) != 0) {
// 13/16
return 0.8125;
}
if ((flags & F_MIN_HEIGHT16_15) != 0) {
// 15/16
return 0.9375;
Expand Down

0 comments on commit b422d07

Please sign in to comment.