Skip to content

Commit

Permalink
MCAccess: Get rid of Block_i method.
Browse files Browse the repository at this point in the history
  • Loading branch information
asofold committed Jul 9, 2013
1 parent e69741f commit e1babee
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 91 deletions.
Expand Up @@ -89,12 +89,6 @@ public AlmostBoolean isBlockLiquid(final int id) {
}
}

@Override
public boolean Block_i(final int id) {
// TODO: This is inaccurate (would be something like "can suffocate"), however it is used for piling upwards and might about do.
return BlockProperties.isGround(id) || BlockProperties.isSolid(id);
}

@Override
public double getWidth(final Entity entity) {
// TODO
Expand Down
Expand Up @@ -78,17 +78,6 @@ public AlmostBoolean isBlockLiquid(final int id) {
else return AlmostBoolean.match(block.material.isLiquid());
}

@Override
public boolean Block_i(final int id) {
try{
return Block.i(id);
}
catch(Throwable t){
// Minecraft default value.
return true;
}
}

@Override
public double getWidth(final Entity entity) {
return ((CraftEntity) entity).getHandle().width;
Expand Down
Expand Up @@ -76,17 +76,6 @@ public AlmostBoolean isBlockLiquid(final int id) {
else return AlmostBoolean.match(block.material.isLiquid());
}

@Override
public boolean Block_i(final int id) {
try{
return Block.i(id);
}
catch(Throwable t){
// Minecraft default value.
return true;
}
}

@Override
public double getWidth(final Entity entity) {
return ((CraftEntity) entity).getHandle().width;
Expand Down
Expand Up @@ -76,17 +76,6 @@ public AlmostBoolean isBlockLiquid(final int id) {
else return AlmostBoolean.match(block.material.isLiquid());
}

@Override
public boolean Block_i(final int id) {
try{
return Block.i(id);
}
catch(Throwable t){
// Minecraft default value.
return true;
}
}

@Override
public double getWidth(final Entity entity) {
return ((CraftEntity) entity).getHandle().width;
Expand Down
Expand Up @@ -77,17 +77,6 @@ public AlmostBoolean isBlockLiquid(final int id) {
else return AlmostBoolean.match(block.material.isLiquid());
}

@Override
public boolean Block_i(final int id) {
try{
return Block.i(id);
}
catch(Throwable t){
// Minecraft default value.
return true;
}
}

@Override
public double getWidth(final Entity entity) {
return ((CraftEntity) entity).getHandle().width;
Expand Down
Expand Up @@ -21,7 +21,6 @@
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
import fr.neatmonster.nocheatplus.compat.MCAccess;
import fr.neatmonster.nocheatplus.utilities.BlockCache;
import fr.neatmonster.nocheatplus.utilities.BlockProperties;
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;

public class MCAccessCB2645 implements MCAccess{
Expand Down Expand Up @@ -78,12 +77,6 @@ public AlmostBoolean isBlockLiquid(final int id) {
else return AlmostBoolean.match(block.material.isLiquid());
}

@Override
public boolean Block_i(final int id) {
// TODO: This is inaccurate (would be something like "can suffocate"), however it is used for piling upwards and might about do.
return BlockProperties.isGround(id) || BlockProperties.isSolid(id);
}

@Override
public double getWidth(final Entity entity) {
return ((CraftEntity) entity).getHandle().width;
Expand Down
Expand Up @@ -21,7 +21,6 @@
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
import fr.neatmonster.nocheatplus.compat.MCAccess;
import fr.neatmonster.nocheatplus.utilities.BlockCache;
import fr.neatmonster.nocheatplus.utilities.BlockProperties;
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;

public class MCAccessCB2691 implements MCAccess{
Expand Down Expand Up @@ -78,12 +77,6 @@ public AlmostBoolean isBlockLiquid(final int id) {
else return AlmostBoolean.match(block.material.isLiquid());
}

@Override
public boolean Block_i(final int id) {
// TODO: This is inaccurate (would be something like "can suffocate"), however it is used for piling upwards and might about do.
return BlockProperties.isGround(id) || BlockProperties.isSolid(id);
}

@Override
public double getWidth(final Entity entity) {
return ((CraftEntity) entity).getHandle().width;
Expand Down
Expand Up @@ -21,7 +21,6 @@
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
import fr.neatmonster.nocheatplus.compat.MCAccess;
import fr.neatmonster.nocheatplus.utilities.BlockCache;
import fr.neatmonster.nocheatplus.utilities.BlockProperties;
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;

public class MCAccessCB2763 implements MCAccess{
Expand Down Expand Up @@ -78,12 +77,6 @@ public AlmostBoolean isBlockLiquid(final int id) {
else return AlmostBoolean.match(block.material.isLiquid());
}

@Override
public boolean Block_i(final int id) {
// TODO: This is inaccurate (would be something like "can suffocate"), however it is used for piling upwards and might about do.
return BlockProperties.isGround(id) || BlockProperties.isSolid(id);
}

@Override
public double getWidth(final Entity entity) {
return ((CraftEntity) entity).getHandle().width;
Expand Down
Expand Up @@ -21,7 +21,6 @@
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
import fr.neatmonster.nocheatplus.compat.MCAccess;
import fr.neatmonster.nocheatplus.utilities.BlockCache;
import fr.neatmonster.nocheatplus.utilities.BlockProperties;
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;

public class MCAccessCBDev implements MCAccess{
Expand Down Expand Up @@ -78,12 +77,6 @@ public AlmostBoolean isBlockLiquid(final int id) {
else return AlmostBoolean.match(block.material.isLiquid());
}

@Override
public boolean Block_i(final int id) {
// TODO: This is inaccurate (would be something like "can suffocate"), however it is used for piling upwards and might about do.
return BlockProperties.isGround(id) || BlockProperties.isSolid(id);
}

@Override
public double getWidth(final Entity entity) {
return ((CraftEntity) entity).getHandle().width;
Expand Down
Expand Up @@ -214,7 +214,6 @@ public MovingListener() {
* @param event
* the event
*/
@SuppressWarnings("deprecation")
@EventHandler(
ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onBlockPlace(final BlockPlaceEvent event) {
Expand Down Expand Up @@ -246,14 +245,24 @@ public void onBlockPlace(final BlockPlaceEvent event) {
if (Math.abs(loc.getX() - 0.5 - block.getX()) <= 1D
&& Math.abs(loc.getZ() - 0.5 - block.getZ()) <= 1D
&& loc.getY() - blockY > 0D && loc.getY() - blockY < 2D
&& (mcAccess.Block_i(mat.getId()) || BlockProperties.isLiquid(mat.getId()))) {
&& (canJumpOffTop(mat.getId()) || BlockProperties.isLiquid(mat.getId()))) {
// The creative fly and/or survival fly check is enabled, the
// block was placed below the player and is
// solid, so do what we have to do.
data.setSetBackY(blockY + 1D);
data.sfJumpPhase = 0;
}
}

/**
* Used for a workaround that resets the set-back for the case of jumping on just placed blocks.
* @param id
* @return
*/
private final boolean canJumpOffTop(final int id){
// TODO: Test if this can be removed!
return BlockProperties.isGround(id) || BlockProperties.isSolid(id);
}

/**
* We listen to this event to prevent player from flying by sending bed leaving packets.
Expand Down
Expand Up @@ -71,17 +71,6 @@ public interface MCAccess {
* @return
*/
public AlmostBoolean isBlockLiquid(int id);

/**
* Hiding the API access here.<br>
* // TODO: Replace by independent method.
* TODO: Find description of this and use block properties from here, as well as a speaking method name.<br>
* Assumption: This is something like "can stand on this type of block".
* @deprecated Will be replaced by direct calls to BlockProperties soon.
* @param id
* @return
*/
public boolean Block_i(int id);

/**
* Does only check y bounds, returns false if dead. this is half a check as auxiliary means for PlayerLocation.isIllegal.
Expand Down

0 comments on commit e1babee

Please sign in to comment.