本文整理汇总了Java中net.minecraft.block.BlockRailBase.isRailBlock方法的典型用法代码示例。如果您正苦于以下问题:Java BlockRailBase.isRailBlock方法的具体用法?Java BlockRailBase.isRailBlock怎么用?Java BlockRailBase.isRailBlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.block.BlockRailBase
的用法示例。
在下文中一共展示了BlockRailBase.isRailBlock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onItemUse
import net.minecraft.block.BlockRailBase; //导入方法依赖的package包/类
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
IBlockState iblockstate = worldIn.getBlockState(pos);
if (!BlockRailBase.isRailBlock(iblockstate)) {
return EnumActionResult.FAIL;
}
else {
ItemStack itemstack = player.getHeldItem(hand);
if (!worldIn.isRemote) {
BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = iblockstate.getBlock() instanceof BlockRailBase ? ((BlockRailBase) iblockstate.getBlock()).getRailDirection(worldIn, pos, iblockstate, null) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;
double d0 = 0.0D;
if (blockrailbase$enumraildirection.isAscending()) {
d0 = 0.5D;
}
EntityMinecart entityminecart = summonMinecart(worldIn);//new EntityMinecartTurret(worldIn, (double) pos.getX() + 0.5D, (double) pos.getY() + 0.0625D + d0, (double) pos.getZ() + 0.5D);
entityminecart.setPosition((double) pos.getX() + 0.5D, (double) pos.getY() + 0.0625D + d0, (double) pos.getZ() + 0.5D);
if (itemstack.hasDisplayName()) {
entityminecart.setCustomNameTag(itemstack.getDisplayName());
}
worldIn.spawnEntity(entityminecart);
}
itemstack.shrink(1);
return EnumActionResult.SUCCESS;
}
}
示例2: onItemUse
import net.minecraft.block.BlockRailBase; //导入方法依赖的package包/类
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
if (BlockRailBase.isRailBlock(world.getBlockId(x, y, z))) {
if (!world.isRemote) {
EntityMinecart cart = getMinecart(stack, player, world);
cart.setPosition(x + 0.5D, y + 0.5D, z + 0.5D);
if (stack.hasDisplayName()) {
cart.func_96094_a(stack.getDisplayName());
}
world.spawnEntityInWorld(cart);
stack.stackSize--;
}
return true;
}
return false;
}
示例3: onItemUse
import net.minecraft.block.BlockRailBase; //导入方法依赖的package包/类
/**
* Called when a Block is right-clicked with this Item
*/
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
IBlockState iblockstate = worldIn.getBlockState(pos);
if (!BlockRailBase.isRailBlock(iblockstate))
{
return EnumActionResult.FAIL;
}
else
{
if (!worldIn.isRemote)
{
BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = iblockstate.getBlock() instanceof BlockRailBase ? (BlockRailBase.EnumRailDirection)iblockstate.getValue(((BlockRailBase)iblockstate.getBlock()).getShapeProperty()) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;
double d0 = 0.0D;
if (blockrailbase$enumraildirection.isAscending())
{
d0 = 0.5D;
}
EntityMinecart entityminecart = EntityMinecart.create(worldIn, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.0625D + d0, (double)pos.getZ() + 0.5D, this.minecartType);
if (stack.hasDisplayName())
{
entityminecart.setCustomNameTag(stack.getDisplayName());
}
worldIn.spawnEntityInWorld(entityminecart);
}
--stack.stackSize;
return EnumActionResult.SUCCESS;
}
}
示例4: onItemUse
import net.minecraft.block.BlockRailBase; //导入方法依赖的package包/类
/**
* Called when a Block is right-clicked with this Item
*/
public EnumActionResult onItemUse(EntityPlayer stack, World playerIn, BlockPos worldIn, EnumHand pos, EnumFacing hand, float facing, float hitX, float hitY)
{
IBlockState iblockstate = playerIn.getBlockState(worldIn);
if (!BlockRailBase.isRailBlock(iblockstate))
{
return EnumActionResult.FAIL;
}
else
{
ItemStack itemstack = stack.getHeldItem(pos);
if (!playerIn.isRemote)
{
BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = iblockstate.getBlock() instanceof BlockRailBase ? (BlockRailBase.EnumRailDirection)iblockstate.getValue(((BlockRailBase)iblockstate.getBlock()).getShapeProperty()) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;
double d0 = 0.0D;
if (blockrailbase$enumraildirection.isAscending())
{
d0 = 0.5D;
}
EntityMinecart entityminecart = EntityMinecart.create(playerIn, (double)worldIn.getX() + 0.5D, (double)worldIn.getY() + 0.0625D + d0, (double)worldIn.getZ() + 0.5D, this.minecartType);
if (itemstack.hasDisplayName())
{
entityminecart.setCustomNameTag(itemstack.getDisplayName());
}
playerIn.spawnEntityInWorld(entityminecart);
}
itemstack.func_190918_g(1);
return EnumActionResult.SUCCESS;
}
}
示例5: onItemUse
import net.minecraft.block.BlockRailBase; //导入方法依赖的package包/类
/**
* Called when a Block is right-clicked with this Item
*/
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
IBlockState iblockstate = worldIn.getBlockState(pos);
if (BlockRailBase.isRailBlock(iblockstate))
{
if (!worldIn.isRemote)
{
BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = iblockstate.getBlock() instanceof BlockRailBase ? (BlockRailBase.EnumRailDirection)iblockstate.getValue(((BlockRailBase)iblockstate.getBlock()).getShapeProperty()) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;
double d0 = 0.0D;
if (blockrailbase$enumraildirection.isAscending())
{
d0 = 0.5D;
}
EntityMinecart entityminecart = EntityMinecart.func_180458_a(worldIn, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.0625D + d0, (double)pos.getZ() + 0.5D, this.minecartType);
if (stack.hasDisplayName())
{
entityminecart.setCustomNameTag(stack.getDisplayName());
}
worldIn.spawnEntityInWorld(entityminecart);
}
--stack.stackSize;
return true;
}
else
{
return false;
}
}
示例6: getCurrentRailPosition
import net.minecraft.block.BlockRailBase; //导入方法依赖的package包/类
private BlockPos getCurrentRailPosition()
{
int x = MathHelper.floor_double(this.posX);
int y = MathHelper.floor_double(this.posY);
int z = MathHelper.floor_double(this.posZ);
if (BlockRailBase.isRailBlock(this.worldObj, new BlockPos(x, y - 1, z))) y--;
return new BlockPos(x, y, z);
}
示例7: countAdjacentRails
import net.minecraft.block.BlockRailBase; //导入方法依赖的package包/类
protected int countAdjacentRails(World world, BlockPos pos)
{
int i = 0;
for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
{
BlockPos pos2 = pos.offset(enumfacing);
if(BlockRailBase.isRailBlock(world, pos2) || BlockRailBase.isRailBlock(world, pos2.up()) || BlockRailBase.isRailBlock(world, pos2.down()))
{
++i;
}
}
return i;
}
示例8: onItemUse
import net.minecraft.block.BlockRailBase; //导入方法依赖的package包/类
/**
* Called when a Block is right-clicked with this Item
*/
@Override
public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
ItemStack stack = playerIn.getHeldItem(hand);
IBlockState iblockstate = worldIn.getBlockState(pos);
if (!BlockRailBase.isRailBlock(iblockstate))
{
return EnumActionResult.FAIL;
}
else
{
if (!worldIn.isRemote)
{
BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = iblockstate.getBlock() instanceof BlockRailBase ? (BlockRailBase.EnumRailDirection)iblockstate.getValue(((BlockRailBase)iblockstate.getBlock()).getShapeProperty()) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;
double d0 = 0.0D;
if (blockrailbase$enumraildirection.isAscending())
{
d0 = 0.5D;
}
EntityWirelessChestMinecart entityminecart = new EntityWirelessChestMinecart(worldIn, pos.getX() + 0.5D, pos.getY() + 0.0625D + d0, pos.getZ() + 0.5D);
entityminecart.setCode(ItemNBTHelper.getInteger(stack, WirelessChestHelper.NBT_CODE, 0));
String owner = ItemNBTHelper.getString(stack, WirelessChestHelper.NBT_OWNER, "");
if(UUIDUtils.isUUID(owner))entityminecart.setOwner(UUIDUtils.fromString(owner));
if (stack.hasDisplayName())
{
entityminecart.setCustomNameTag(stack.getDisplayName());
}
worldIn.spawnEntity(entityminecart);
}
ItemStackTools.incStackSize(stack, -1);
return EnumActionResult.SUCCESS;
}
}
示例9: onItemUse
import net.minecraft.block.BlockRailBase; //导入方法依赖的package包/类
/**
* Called when a Block is right-clicked with this Item
*/
@Override
public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
ItemStack stack = playerIn.getHeldItem(hand);
IBlockState iblockstate = worldIn.getBlockState(pos);
if (!BlockRailBase.isRailBlock(iblockstate))
{
return EnumActionResult.FAIL;
}
else
{
if (!worldIn.isRemote)
{
BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = iblockstate.getBlock() instanceof BlockRailBase ? (BlockRailBase.EnumRailDirection)iblockstate.getValue(((BlockRailBase)iblockstate.getBlock()).getShapeProperty()) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;
double d0 = 0.0D;
if (blockrailbase$enumraildirection.isAscending())
{
d0 = 0.5D;
}
CrystalChestType type = CrystalChestType.values()[CrystalChestType.validateMeta(stack.getMetadata())];
EntityMinecart entityminecart = EntityCrystalChestMinecartBase.makeMinecart(worldIn, pos.getX() + 0.5D, pos.getY() + 0.0625D + d0, pos.getZ() + 0.5D, type);
if (stack.hasDisplayName())
{
entityminecart.setCustomNameTag(stack.getDisplayName());
}
worldIn.spawnEntity(entityminecart);
}
ItemStackTools.incStackSize(stack, -1);
return EnumActionResult.SUCCESS;
}
}
示例10: onItemUse
import net.minecraft.block.BlockRailBase; //导入方法依赖的package包/类
/**
* Called when a Block is right-clicked with this Item
*/
@Override
public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
ItemStack stack = playerIn.getHeldItem(hand);
IBlockState iblockstate = worldIn.getBlockState(pos);
if (!BlockRailBase.isRailBlock(iblockstate))
{
return EnumActionResult.FAIL;
}
else
{
if (!worldIn.isRemote)
{
BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = iblockstate.getBlock() instanceof BlockRailBase ? (BlockRailBase.EnumRailDirection)iblockstate.getValue(((BlockRailBase)iblockstate.getBlock()).getShapeProperty()) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;
double d0 = 0.0D;
if (blockrailbase$enumraildirection.isAscending())
{
d0 = 0.5D;
}
EntityEnderChestMinecart entityminecart = new EntityEnderChestMinecart(worldIn, pos.getX() + 0.5D, pos.getY() + 0.0625D + d0, pos.getZ() + 0.5D);
if (stack.hasDisplayName())
{
entityminecart.setCustomNameTag(stack.getDisplayName());
}
worldIn.spawnEntity(entityminecart);
}
ItemStackTools.incStackSize(stack, -1);
return EnumActionResult.SUCCESS;
}
}
示例11: dispenseStack
import net.minecraft.block.BlockRailBase; //导入方法依赖的package包/类
public ItemStack dispenseStack(IBlockSource at, ItemStack is) {
World world = at.getWorld();
IBlockState dispenserState = world.getBlockState(at.getBlockPos());
EnumFacing enumfacing = dispenserState.getValue(BlockDispenser.FACING);
double x = at.getX() + (double) ((float) enumfacing.getFrontOffsetX() * 1.125F);
double y = at.getY() + (double) ((float) enumfacing.getFrontOffsetY() * 1.125F);
double z = at.getZ() + (double) ((float) enumfacing.getFrontOffsetZ() * 1.125F);
BlockPos target = at.getBlockPos().offset(enumfacing);
IBlockState bs = world.getBlockState(target);
Block block = bs.getBlock();
double yOffset;
if (BlockRailBase.isRailBlock(bs)) {
yOffset = 0.0D;
} else {
if (block.getMaterial() != Material.air || !BlockRailBase.isRailBlock(world.getBlockState(target.down()))) {
return this.behaviourDefaultDispenseItem.dispense(at, is);
}
yOffset = -1.0D;
}
EntityMinecart entityminecart = Core.registry.barrelCart.placeCart(null, is, at.getWorld(), new BlockPos((int) x, (int) y, (int) z));
if (is.hasDisplayName()) {
entityminecart.setCustomNameTag(is.getDisplayName());
}
return is;
}
示例12: onItemUse
import net.minecraft.block.BlockRailBase; //导入方法依赖的package包/类
@Override
public boolean onItemUse(ItemStack is, EntityPlayer player, World w, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
if (w.isRemote) return true;
if (!BlockRailBase.isRailBlock(w.getBlockState(pos))) {
return true;
}
placeCart(null, is, w, pos);
return true;
}
示例13: onItemUse
import net.minecraft.block.BlockRailBase; //导入方法依赖的package包/类
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
IBlockState iblockstate = worldIn.getBlockState(pos);
if (BlockRailBase.isRailBlock(iblockstate)) {
if (!worldIn.isRemote)
{
BlockRailBase.EnumRailDirection enumraildirection = iblockstate.getBlock() instanceof BlockRailBase ? (BlockRailBase.EnumRailDirection)iblockstate.getValue(((BlockRailBase)iblockstate.getBlock()).getShapeProperty()) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;
double d0 = 0.0D;
if (enumraildirection.isAscending()) {
d0 = 0.5D;
}
EntityMinecart entityminecart;
if (type == EnumMinecartType.FURNACE) {
entityminecart = new EntityCoalPoweredMinecartVC(worldIn, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.0625D + d0, (double)pos.getZ() + 0.5D);
} else {
entityminecart = new EntityEmptyMinecartVC(worldIn, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.0625D + d0, (double)pos.getZ() + 0.5D);
}
if (stack.hasDisplayName()) {
entityminecart.setCustomNameTag(stack.getDisplayName());
}
worldIn.spawnEntityInWorld(entityminecart);
}
--stack.stackSize;
return true;
}
else {
return false;
}
}
示例14: getMaxSpeed
import net.minecraft.block.BlockRailBase; //导入方法依赖的package包/类
protected double getMaxSpeed()
{
if (!canUseRail()) return getMaximumSpeed();
BlockPos pos = this.getCurrentRailPosition();
IBlockState state = this.worldObj.getBlockState(pos);
if (!BlockRailBase.isRailBlock(state)) return getMaximumSpeed();
float railMaxSpeed = ((BlockRailBase)state.getBlock()).getRailMaxSpeed(worldObj, this, pos);
return Math.min(railMaxSpeed, getCurrentCartSpeedCapOnRail());
}
示例15: dispenseStack
import net.minecraft.block.BlockRailBase; //导入方法依赖的package包/类
/**
* Dispense the specified stack, play the dispense sound and spawn particles.
*/
public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack)
{
EnumFacing enumfacing = BlockDispenser.getFacing(par1IBlockSource.getBlockMetadata());
World world = par1IBlockSource.getWorld();
double d0 = par1IBlockSource.getX() + (double)((float)enumfacing.getFrontOffsetX() * 1.125F);
double d1 = par1IBlockSource.getY() + (double)((float)enumfacing.getFrontOffsetY() * 1.125F);
double d2 = par1IBlockSource.getZ() + (double)((float)enumfacing.getFrontOffsetZ() * 1.125F);
int i = par1IBlockSource.getXInt() + enumfacing.getFrontOffsetX();
int j = par1IBlockSource.getYInt() + enumfacing.getFrontOffsetY();
int k = par1IBlockSource.getZInt() + enumfacing.getFrontOffsetZ();
int l = world.getBlockId(i, j, k);
double d3;
if (BlockRailBase.isRailBlock(l))
{
d3 = 0.0D;
}
else
{
if (l != 0 || !BlockRailBase.isRailBlock(world.getBlockId(i, j - 1, k)))
{
return this.behaviourDefaultDispenseItem.dispense(par1IBlockSource, par2ItemStack);
}
d3 = -1.0D;
}
EntityMinecart entityminecart = EntityMinecart.createMinecart(world, d0, d1 + d3, d2, ((ItemMinecart)par2ItemStack.getItem()).minecartType);
if (par2ItemStack.hasDisplayName())
{
entityminecart.setMinecartName(par2ItemStack.getDisplayName());
}
world.spawnEntityInWorld(entityminecart);
par2ItemStack.splitStack(1);
return par2ItemStack;
}