1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-09-29 15:30:48 +00:00

Replace WorldUtil methods with builtin alternatives

- Replace most 0 <= y < world.getHeight() checks with
  world.isBlockValid.
 - Remove several "in bounds" checks, as they'll be handled by later
   calls.
This commit is contained in:
SquidDev 2018-12-26 10:28:32 +00:00
parent a1c4a9fb58
commit 4d5c52bc63
14 changed files with 121 additions and 206 deletions

View File

@ -61,7 +61,6 @@ import dan200.computercraft.shared.turtle.upgrades.*;
import dan200.computercraft.shared.util.CreativeTabMain; import dan200.computercraft.shared.util.CreativeTabMain;
import dan200.computercraft.shared.util.IDAssigner; import dan200.computercraft.shared.util.IDAssigner;
import dan200.computercraft.shared.util.InventoryUtil; import dan200.computercraft.shared.util.InventoryUtil;
import dan200.computercraft.shared.util.WorldUtil;
import dan200.computercraft.shared.wired.CapabilityWiredElement; import dan200.computercraft.shared.wired.CapabilityWiredElement;
import dan200.computercraft.shared.wired.WiredNode; import dan200.computercraft.shared.wired.WiredNode;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
@ -778,20 +777,12 @@ public class ComputerCraft
public static int getDefaultBundledRedstoneOutput( World world, BlockPos pos, EnumFacing side ) public static int getDefaultBundledRedstoneOutput( World world, BlockPos pos, EnumFacing side )
{ {
if( WorldUtil.isBlockInWorld( world, pos ) ) return world.isValid( pos ) ? DefaultBundledRedstoneProvider.getDefaultBundledRedstoneOutput( world, pos, side ) : -1;
{
return DefaultBundledRedstoneProvider.getDefaultBundledRedstoneOutput( world, pos, side );
}
return -1;
} }
public static int getBundledRedstoneOutput( World world, BlockPos pos, EnumFacing side ) public static int getBundledRedstoneOutput( World world, BlockPos pos, EnumFacing side )
{ {
int y = pos.getY(); if( !world.isValid( pos ) ) return -1;
if( y < 0 || y >= world.getHeight() )
{
return -1;
}
// Try the handlers in order: // Try the handlers in order:
int combinedSignal = -1; int combinedSignal = -1;

View File

@ -12,7 +12,6 @@ import dan200.computercraft.api.lua.ILuaAPI;
import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException; import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.shared.computer.blocks.TileCommandComputer; import dan200.computercraft.shared.computer.blocks.TileCommandComputer;
import dan200.computercraft.shared.util.WorldUtil;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
@ -215,7 +214,7 @@ public class CommandAPI implements ILuaAPI
Math.max( miny, maxy ), Math.max( miny, maxy ),
Math.max( minz, maxz ) Math.max( minz, maxz )
); );
if( !WorldUtil.isBlockInWorld( world, min ) || !WorldUtil.isBlockInWorld( world, max ) ) if( !world.isValid( min ) || !world.isValid( max ) )
{ {
throw new LuaException( "Co-ordinates out or range" ); throw new LuaException( "Co-ordinates out or range" );
} }
@ -250,7 +249,7 @@ public class CommandAPI implements ILuaAPI
// Get the details of the block // Get the details of the block
World world = m_computer.getWorld(); World world = m_computer.getWorld();
BlockPos position = new BlockPos( x, y, z ); BlockPos position = new BlockPos( x, y, z );
if( WorldUtil.isBlockInWorld( world, position ) ) if( world.isValid( position ) )
{ {
return new Object[] { getBlockInfo( world, position ) }; return new Object[] { getBlockInfo( world, position ) };
} }

View File

@ -326,7 +326,7 @@ public abstract class TileComputerBase extends TileGeneric
int localDir = remapLocalSide( DirectionUtil.toLocal( this, dir ) ); int localDir = remapLocalSide( DirectionUtil.toLocal( this, dir ) );
if( !isRedstoneBlockedOnSide( localDir ) ) if( !isRedstoneBlockedOnSide( localDir ) )
{ {
computer.setRedstoneInput( localDir, RedstoneUtil.getRedstoneOutput( getWorld(), offset, offsetSide ) ); computer.setRedstoneInput( localDir, getWorld().getRedstonePower( offset, offsetSide ) );
computer.setBundledRedstoneInput( localDir, RedstoneUtil.getBundledRedstoneOutput( getWorld(), offset, offsetSide ) ); computer.setBundledRedstoneInput( localDir, RedstoneUtil.getBundledRedstoneOutput( getWorld(), offset, offsetSide ) );
} }
if( !isPeripheralBlockedOnSide( localDir ) ) if( !isPeripheralBlockedOnSide( localDir ) )

View File

@ -420,16 +420,10 @@ public class TileMonitor extends TilePeripheralBase
private TileMonitor getSimilarMonitorAt( BlockPos pos ) private TileMonitor getSimilarMonitorAt( BlockPos pos )
{ {
if( pos.equals( getPos() ) ) if( pos.equals( getPos() ) ) return this;
{
return this;
}
int y = pos.getY();
World world = getWorld(); World world = getWorld();
if( world != null && y >= 0 && y < world.getHeight() ) if( world != null && world.isBlockLoaded( pos ) )
{
if( world.isBlockLoaded( pos ) )
{ {
TileEntity tile = world.getTileEntity( pos ); TileEntity tile = world.getTileEntity( pos );
if( tile != null && tile instanceof TileMonitor ) if( tile != null && tile instanceof TileMonitor )
@ -442,8 +436,6 @@ public class TileMonitor extends TilePeripheralBase
} }
} }
} }
}
return null; return null;
} }

View File

@ -9,7 +9,6 @@ package dan200.computercraft.shared.turtle.core;
import dan200.computercraft.api.turtle.ITurtleAccess; import dan200.computercraft.api.turtle.ITurtleAccess;
import dan200.computercraft.api.turtle.ITurtleCommand; import dan200.computercraft.api.turtle.ITurtleCommand;
import dan200.computercraft.api.turtle.TurtleCommandResult; import dan200.computercraft.api.turtle.TurtleCommandResult;
import dan200.computercraft.shared.util.WorldUtil;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.item.Item; import net.minecraft.item.Item;
@ -48,8 +47,6 @@ public class TurtleCompareCommand implements ITurtleCommand
BlockPos newPosition = oldPosition.offset( direction ); BlockPos newPosition = oldPosition.offset( direction );
ItemStack lookAtStack = ItemStack.EMPTY; ItemStack lookAtStack = ItemStack.EMPTY;
if( WorldUtil.isBlockInWorld( world, newPosition ) )
{
if( !world.isAirBlock( newPosition ) ) if( !world.isAirBlock( newPosition ) )
{ {
IBlockState lookAtState = world.getBlockState( newPosition ); IBlockState lookAtState = world.getBlockState( newPosition );
@ -107,7 +104,6 @@ public class TurtleCompareCommand implements ITurtleCommand
} }
} }
} }
}
// Compare them // Compare them
if( selectedStack.isEmpty() && lookAtStack.isEmpty() ) if( selectedStack.isEmpty() && lookAtStack.isEmpty() )

View File

@ -37,14 +37,10 @@ public class TurtleDetectCommand implements ITurtleCommand
BlockPos oldPosition = turtle.getPosition(); BlockPos oldPosition = turtle.getPosition();
BlockPos newPosition = oldPosition.offset( direction ); BlockPos newPosition = oldPosition.offset( direction );
if( WorldUtil.isBlockInWorld( world, newPosition ) ) if( !WorldUtil.isLiquidBlock( world, newPosition ) && !world.isAirBlock( newPosition ) )
{
if( !WorldUtil.isLiquidBlock( world, newPosition ) &&
!world.isAirBlock( newPosition ) )
{ {
return TurtleCommandResult.success(); return TurtleCommandResult.success();
} }
}
return TurtleCommandResult.failure(); return TurtleCommandResult.failure();
} }

View File

@ -11,7 +11,6 @@ import dan200.computercraft.api.turtle.ITurtleAccess;
import dan200.computercraft.api.turtle.ITurtleCommand; import dan200.computercraft.api.turtle.ITurtleCommand;
import dan200.computercraft.api.turtle.TurtleCommandResult; import dan200.computercraft.api.turtle.TurtleCommandResult;
import dan200.computercraft.api.turtle.event.TurtleBlockEvent; import dan200.computercraft.api.turtle.event.TurtleBlockEvent;
import dan200.computercraft.shared.util.WorldUtil;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
@ -26,7 +25,6 @@ import java.util.Map;
public class TurtleInspectCommand implements ITurtleCommand public class TurtleInspectCommand implements ITurtleCommand
{ {
private static final boolean FAIL_ON_AIR = true;
private final InteractDirection m_direction; private final InteractDirection m_direction;
public TurtleInspectCommand( InteractDirection direction ) public TurtleInspectCommand( InteractDirection direction )
@ -44,13 +42,14 @@ public class TurtleInspectCommand implements ITurtleCommand
// Check if thing in front is air or not // Check if thing in front is air or not
World world = turtle.getWorld(); World world = turtle.getWorld();
BlockPos oldPosition = turtle.getPosition(); BlockPos oldPosition = turtle.getPosition();
BlockPos newPosition = WorldUtil.moveCoords( oldPosition, direction ); BlockPos newPosition = oldPosition.offset( direction );
if( WorldUtil.isBlockInWorld( world, newPosition ) )
{
IBlockState state = world.getBlockState( newPosition ); IBlockState state = world.getBlockState( newPosition );
if( !FAIL_ON_AIR || !state.getBlock().isAir( state, world, newPosition ) ) if( state.getBlock().isAir( state, world, newPosition ) )
{ {
return TurtleCommandResult.failure( "No block to inspect" );
}
Block block = state.getBlock(); Block block = state.getBlock();
String name = Block.REGISTRY.getNameForObject( block ).toString(); String name = Block.REGISTRY.getNameForObject( block ).toString();
int metadata = block.getMetaFromState( state ); int metadata = block.getMetaFromState( state );
@ -78,23 +77,9 @@ public class TurtleInspectCommand implements ITurtleCommand
// Fire the event, exiting if it is cancelled // Fire the event, exiting if it is cancelled
TurtlePlayer turtlePlayer = TurtlePlaceCommand.createPlayer( turtle, oldPosition, direction ); TurtlePlayer turtlePlayer = TurtlePlaceCommand.createPlayer( turtle, oldPosition, direction );
TurtleBlockEvent.Inspect event = new TurtleBlockEvent.Inspect( turtle, turtlePlayer, world, newPosition, state, table ); TurtleBlockEvent.Inspect event = new TurtleBlockEvent.Inspect( turtle, turtlePlayer, world, newPosition, state, table );
if( MinecraftForge.EVENT_BUS.post( event ) ) if( MinecraftForge.EVENT_BUS.post( event ) ) return TurtleCommandResult.failure( event.getFailureMessage() );
{
return TurtleCommandResult.failure( event.getFailureMessage() );
}
return TurtleCommandResult.success( new Object[] { table } ); return TurtleCommandResult.success( new Object[] { table } );
}
}
if( !FAIL_ON_AIR )
{
Map<Object, Object> table = new HashMap<>();
table.put( "name", "minecraft:air" );
table.put( "metadata", 0 );
table.put( "state", new HashMap<>() );
return TurtleCommandResult.success( new Object[] { table } );
}
return TurtleCommandResult.failure( "No block to inspect" );
} }
} }

View File

@ -43,7 +43,7 @@ public class TurtleMoveCommand implements ITurtleCommand
// Check if we can move // Check if we can move
World oldWorld = turtle.getWorld(); World oldWorld = turtle.getWorld();
BlockPos oldPosition = turtle.getPosition(); BlockPos oldPosition = turtle.getPosition();
BlockPos newPosition = WorldUtil.moveCoords( oldPosition, direction ); BlockPos newPosition = oldPosition.offset( direction );
TurtlePlayer turtlePlayer = TurtlePlaceCommand.createPlayer( turtle, oldPosition, direction ); TurtlePlayer turtlePlayer = TurtlePlaceCommand.createPlayer( turtle, oldPosition, direction );
TurtleCommandResult canEnterResult = canEnter( turtlePlayer, oldWorld, newPosition ); TurtleCommandResult canEnterResult = canEnter( turtlePlayer, oldWorld, newPosition );
@ -158,14 +158,15 @@ public class TurtleMoveCommand implements ITurtleCommand
private TurtleCommandResult canEnter( TurtlePlayer turtlePlayer, World world, BlockPos position ) private TurtleCommandResult canEnter( TurtlePlayer turtlePlayer, World world, BlockPos position )
{ {
if( position.getY() < 0 ) if( world.isOutsideBuildHeight( position ) )
{ {
return TurtleCommandResult.failure( "Too low to move" ); return TurtleCommandResult.failure( position.getY() < 0 ? "Too low to move" : "Too high to move" );
} }
else if( position.getY() > world.getHeight() - 1 ) else if( !world.isValid( position ) )
{ {
return TurtleCommandResult.failure( "Too high to move" ); return TurtleCommandResult.failure( "Cannot leave the world" );
} }
if( ComputerCraft.turtlesObeyBlockProtection ) if( ComputerCraft.turtlesObeyBlockProtection )
{ {
// Check spawn protection // Check spawn protection

View File

@ -64,10 +64,10 @@ public class TurtlePlaceCommand implements ITurtleCommand
// Remember old block // Remember old block
EnumFacing direction = m_direction.toWorldDir( turtle ); EnumFacing direction = m_direction.toWorldDir( turtle );
World world = turtle.getWorld(); World world = turtle.getWorld();
BlockPos coordinates = WorldUtil.moveCoords( turtle.getPosition(), direction ); BlockPos coordinates = turtle.getPosition().offset( direction );
// Create a fake player, and orient it appropriately // Create a fake player, and orient it appropriately
BlockPos playerPosition = WorldUtil.moveCoords( turtle.getPosition(), direction ); BlockPos playerPosition = turtle.getPosition().offset( direction );
TurtlePlayer turtlePlayer = createPlayer( turtle, playerPosition, direction ); TurtlePlayer turtlePlayer = createPlayer( turtle, playerPosition, direction );
TurtleBlockEvent.Place place = new TurtleBlockEvent.Place( turtle, turtlePlayer, turtle.getWorld(), coordinates, stack ); TurtleBlockEvent.Place place = new TurtleBlockEvent.Place( turtle, turtlePlayer, turtle.getWorld(), coordinates, stack );
@ -76,16 +76,6 @@ public class TurtlePlaceCommand implements ITurtleCommand
return TurtleCommandResult.failure( place.getFailureMessage() ); return TurtleCommandResult.failure( place.getFailureMessage() );
} }
IBlockState previousState;
if( WorldUtil.isBlockInWorld( world, coordinates ) )
{
previousState = world.getBlockState( coordinates );
}
else
{
previousState = null;
}
// Do the deploying // Do the deploying
String[] errorMessage = new String[1]; String[] errorMessage = new String[1];
ItemStack remainder = deploy( stack, turtle, turtlePlayer, direction, m_extraArguments, errorMessage ); ItemStack remainder = deploy( stack, turtle, turtlePlayer, direction, m_extraArguments, errorMessage );
@ -119,7 +109,7 @@ public class TurtlePlaceCommand implements ITurtleCommand
public static ItemStack deploy( @Nonnull ItemStack stack, ITurtleAccess turtle, EnumFacing direction, Object[] extraArguments, String[] o_errorMessage ) public static ItemStack deploy( @Nonnull ItemStack stack, ITurtleAccess turtle, EnumFacing direction, Object[] extraArguments, String[] o_errorMessage )
{ {
// Create a fake player, and orient it appropriately // Create a fake player, and orient it appropriately
BlockPos playerPosition = WorldUtil.moveCoords( turtle.getPosition(), direction ); BlockPos playerPosition = turtle.getPosition().offset( direction );
TurtlePlayer turtlePlayer = createPlayer( turtle, playerPosition, direction ); TurtlePlayer turtlePlayer = createPlayer( turtle, playerPosition, direction );
return deploy( stack, turtle, turtlePlayer, direction, extraArguments, o_errorMessage ); return deploy( stack, turtle, turtlePlayer, direction, extraArguments, o_errorMessage );
@ -136,7 +126,7 @@ public class TurtlePlaceCommand implements ITurtleCommand
// Deploy on the block immediately in front // Deploy on the block immediately in front
BlockPos position = turtle.getPosition(); BlockPos position = turtle.getPosition();
BlockPos newPosition = WorldUtil.moveCoords( position, direction ); BlockPos newPosition = position.offset( direction );
remainder = deployOnBlock( stack, turtle, turtlePlayer, newPosition, direction.getOpposite(), extraArguments, true, o_errorMessage ); remainder = deployOnBlock( stack, turtle, turtlePlayer, newPosition, direction.getOpposite(), extraArguments, true, o_errorMessage );
if( remainder != stack ) if( remainder != stack )
{ {
@ -144,7 +134,7 @@ public class TurtlePlaceCommand implements ITurtleCommand
} }
// Deploy on the block one block away // Deploy on the block one block away
remainder = deployOnBlock( stack, turtle, turtlePlayer, WorldUtil.moveCoords( newPosition, direction ), direction.getOpposite(), extraArguments, false, o_errorMessage ); remainder = deployOnBlock( stack, turtle, turtlePlayer, newPosition.offset( direction ), direction.getOpposite(), extraArguments, false, o_errorMessage );
if( remainder != stack ) if( remainder != stack )
{ {
return remainder; return remainder;
@ -299,7 +289,7 @@ public class TurtlePlaceCommand implements ITurtleCommand
private static boolean canDeployOnBlock( @Nonnull ItemStack stack, ITurtleAccess turtle, TurtlePlayer player, BlockPos position, EnumFacing side, boolean allowReplaceable, String[] o_errorMessage ) private static boolean canDeployOnBlock( @Nonnull ItemStack stack, ITurtleAccess turtle, TurtlePlayer player, BlockPos position, EnumFacing side, boolean allowReplaceable, String[] o_errorMessage )
{ {
World world = turtle.getWorld(); World world = turtle.getWorld();
if( WorldUtil.isBlockInWorld( world, position ) && if( world.isValid( position ) &&
!world.isAirBlock( position ) && !world.isAirBlock( position ) &&
!(stack.getItem() instanceof ItemBlock && WorldUtil.isLiquidBlock( world, position )) ) !(stack.getItem() instanceof ItemBlock && WorldUtil.isLiquidBlock( world, position )) )
{ {
@ -312,19 +302,9 @@ public class TurtlePlaceCommand implements ITurtleCommand
if( ComputerCraft.turtlesObeyBlockProtection ) if( ComputerCraft.turtlesObeyBlockProtection )
{ {
// Check spawn protection // Check spawn protection
boolean editable = true; boolean editable = replaceable
if( replaceable ) ? ComputerCraft.isBlockEditable( world, position, player )
{ : ComputerCraft.isBlockEditable( world, position.offset( side ), player );
editable = ComputerCraft.isBlockEditable( world, position, player );
}
else
{
BlockPos shiftedPos = WorldUtil.moveCoords( position, side );
if( WorldUtil.isBlockInWorld( world, shiftedPos ) )
{
editable = ComputerCraft.isBlockEditable( world, shiftedPos, player );
}
}
if( !editable ) if( !editable )
{ {
if( o_errorMessage != null ) if( o_errorMessage != null )
@ -356,7 +336,7 @@ public class TurtlePlaceCommand implements ITurtleCommand
// Re-orient the fake player // Re-orient the fake player
EnumFacing playerDir = side.getOpposite(); EnumFacing playerDir = side.getOpposite();
BlockPos playerPosition = WorldUtil.moveCoords( position, side ); BlockPos playerPosition = position.offset( side );
orientPlayer( turtle, turtlePlayer, playerPosition, playerDir ); orientPlayer( turtle, turtlePlayer, playerPosition, playerDir );
// Calculate where the turtle would hit the block // Calculate where the turtle would hit the block
@ -421,7 +401,7 @@ public class TurtlePlaceCommand implements ITurtleCommand
TileEntity tile = world.getTileEntity( position ); TileEntity tile = world.getTileEntity( position );
if( tile == null || tile == existingTile ) if( tile == null || tile == existingTile )
{ {
tile = world.getTileEntity( WorldUtil.moveCoords( position, side ) ); tile = world.getTileEntity( position.offset( side ) );
} }
if( tile instanceof TileEntitySign ) if( tile instanceof TileEntitySign )
{ {

View File

@ -12,7 +12,6 @@ import dan200.computercraft.api.turtle.TurtleAnimation;
import dan200.computercraft.api.turtle.TurtleCommandResult; import dan200.computercraft.api.turtle.TurtleCommandResult;
import dan200.computercraft.api.turtle.event.TurtleInventoryEvent; import dan200.computercraft.api.turtle.event.TurtleInventoryEvent;
import dan200.computercraft.shared.util.InventoryUtil; import dan200.computercraft.shared.util.InventoryUtil;
import dan200.computercraft.shared.util.WorldUtil;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -54,7 +53,7 @@ public class TurtleSuckCommand implements ITurtleCommand
// Get inventory for thing in front // Get inventory for thing in front
World world = turtle.getWorld(); World world = turtle.getWorld();
BlockPos oldPosition = turtle.getPosition(); BlockPos oldPosition = turtle.getPosition();
BlockPos newPosition = WorldUtil.moveCoords( oldPosition, direction ); BlockPos newPosition = oldPosition.offset( direction );
EnumFacing side = direction.getOpposite(); EnumFacing side = direction.getOpposite();
IItemHandler inventory = InventoryUtil.getInventory( world, newPosition, side ); IItemHandler inventory = InventoryUtil.getInventory( world, newPosition, side );

View File

@ -49,9 +49,6 @@ public class InventoryUtil
public static IItemHandler getInventory( World world, BlockPos pos, EnumFacing side ) public static IItemHandler getInventory( World world, BlockPos pos, EnumFacing side )
{ {
// Look for tile with inventory // Look for tile with inventory
int y = pos.getY();
if( y >= 0 && y < world.getHeight() )
{
TileEntity tileEntity = world.getTileEntity( pos ); TileEntity tileEntity = world.getTileEntity( pos );
if( tileEntity != null ) if( tileEntity != null )
{ {
@ -69,7 +66,6 @@ public class InventoryUtil
return new InvWrapper( (IInventory) tileEntity ); return new InvWrapper( (IInventory) tileEntity );
} }
} }
}
// Look for entity with inventory // Look for entity with inventory
Vec3d vecStart = new Vec3d( Vec3d vecStart = new Vec3d(

View File

@ -10,11 +10,6 @@ public class PeripheralUtil
{ {
public static IPeripheral getPeripheral( World world, BlockPos pos, EnumFacing side ) public static IPeripheral getPeripheral( World world, BlockPos pos, EnumFacing side )
{ {
int y = pos.getY(); return world.isValid( pos ) && !world.isRemote ? ComputerCraft.getPeripheralAt( world, pos, side ) : null;
if( y >= 0 && y < world.getHeight() && !world.isRemote )
{
return ComputerCraft.getPeripheralAt( world, pos, side );
}
return null;
} }
} }

View File

@ -15,11 +15,6 @@ import net.minecraft.world.World;
public class RedstoneUtil public class RedstoneUtil
{ {
public static int getRedstoneOutput( World world, BlockPos pos, EnumFacing side )
{
return world.getRedstonePower( pos, side );
}
public static int getBundledRedstoneOutput( World world, BlockPos pos, EnumFacing side ) public static int getBundledRedstoneOutput( World world, BlockPos pos, EnumFacing side )
{ {
int signal = ComputerCraft.getBundledRedstoneOutput( world, pos, side ); int signal = ComputerCraft.getBundledRedstoneOutput( world, pos, side );

View File

@ -24,19 +24,9 @@ import java.util.List;
public class WorldUtil public class WorldUtil
{ {
public static boolean isBlockInWorld( World world, BlockPos pos )
{
return pos.getY() >= 0 && pos.getY() < world.getHeight();
}
public static boolean isLiquidBlock( World world, BlockPos pos ) public static boolean isLiquidBlock( World world, BlockPos pos )
{ {
return isBlockInWorld( world, pos ) && world.getBlockState( pos ).getMaterial().isLiquid(); return world.getBlockState( pos ).getMaterial().isLiquid();
}
public static BlockPos moveCoords( BlockPos pos, EnumFacing dir )
{
return pos.offset( dir );
} }
public static Pair<Entity, Vec3d> rayTraceEntities( World world, Vec3d vecStart, Vec3d vecDir, double distance ) public static Pair<Entity, Vec3d> rayTraceEntities( World world, Vec3d vecStart, Vec3d vecDir, double distance )