本文整理汇总了Java中net.minecraft.block.BlockSlab.EnumBlockHalf方法的典型用法代码示例。如果您正苦于以下问题:Java BlockSlab.EnumBlockHalf方法的具体用法?Java BlockSlab.EnumBlockHalf怎么用?Java BlockSlab.EnumBlockHalf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.block.BlockSlab
的用法示例。
在下文中一共展示了BlockSlab.EnumBlockHalf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_getSubtype
import net.minecraft.block.BlockSlab; //导入方法依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void test_getSubtype() throws Exception
{
ContentBlockSlab content = new ContentBlockSlab();
content.subtypes = new int[] {0, 1, 2, 3, 4, 5, 6, 7};
content.id = "test_getSubtype";
Block block = content.createBlock();
CSBlock<ContentBlockSlab> csblock = (CSBlock<ContentBlockSlab>) block;
for (int subtype = 0; subtype < 8; subtype++)
{
for (BlockSlab.EnumBlockHalf facing : BlockSlabWithSubtypes.HALF.getAllowedValues())
{
IBlockState state = block.getDefaultState()
.withProperty(BlockSlabWithSubtypes.HALF, facing)
.withProperty(BlockHelper.getSubtypeProperty(content.subtypes), EnumSubtype.values()[subtype]);
assertEquals(subtype, csblock.getSubtype(state));
}
}
}
示例2: mapBlockRender
import net.minecraft.block.BlockSlab; //导入方法依赖的package包/类
@Override
@SideOnly(Side.CLIENT)
public List<IBlockState> mapBlockRender(@Nonnull IBlockStateWrapper state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, BlockRenderLayer blockLayer,
@Nonnull QuadCollector quadCollector) {
for (BlockSlab.EnumBlockHalf half : BlockSlab.EnumBlockHalf.values()) {
if (isDouble() || half == state.getValue(HALF)) {
boolean isTop = half == BlockSlab.EnumBlockHalf.TOP;
IBlockState paintSource = isTop ? getPaintSource2(state, world, pos) : getPaintSource(state, world, pos);
if (blockLayer == null || PaintUtil.canRenderInLayer(paintSource, blockLayer)) {
quadCollector.addFriendlybakedModel(blockLayer, PaintRegistry.getModel(IBakedModel.class, isTop ? "slab_hi" : "slab_lo", paintSource, null),
paintSource, MathHelper.getPositionRandom(pos));
}
}
}
return null;
}
示例3: onItemUse
import net.minecraft.block.BlockSlab; //导入方法依赖的package包/类
@Override
public @Nonnull EnumActionResult onItemUse(@Nonnull EntityPlayer playerIn, @Nonnull World worldIn, @Nonnull BlockPos pos, @Nonnull EnumHand hand,
@Nonnull EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack stack = playerIn.getHeldItem(hand);
if (!playerIn.canPlayerEdit(pos.offset(side), side, stack)) {
return EnumActionResult.FAIL;
} else {
IBlockState iblockstate = worldIn.getBlockState(pos);
if (iblockstate.getBlock() == this.singleSlab) {
BlockSlab.EnumBlockHalf blockslab$enumblockhalf = iblockstate.getValue(BlockSlab.HALF);
if ((side == EnumFacing.UP && blockslab$enumblockhalf == BlockSlab.EnumBlockHalf.BOTTOM
|| side == EnumFacing.DOWN && blockslab$enumblockhalf == BlockSlab.EnumBlockHalf.TOP)) {
tryPlace(stack, worldIn, pos);
return EnumActionResult.SUCCESS;
}
}
return this.tryPlace(stack, worldIn, pos.offset(side)) ? EnumActionResult.SUCCESS : super.onItemUse(playerIn, worldIn, pos, hand, side, hitX, hitY, hitZ);
}
}
示例4: onItemUse
import net.minecraft.block.BlockSlab; //导入方法依赖的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)
{
if (stack.stackSize == 0)
{
return false;
}
else if (!playerIn.canPlayerEdit(pos.offset(side), side, stack))
{
return false;
}
else
{
Object object = this.singleSlab.getVariant(stack);
IBlockState iblockstate = worldIn.getBlockState(pos);
if (iblockstate.getBlock() == this.singleSlab)
{
IProperty iproperty = this.singleSlab.getVariantProperty();
Comparable comparable = iblockstate.getValue(iproperty);
BlockSlab.EnumBlockHalf blockslab$enumblockhalf = (BlockSlab.EnumBlockHalf)iblockstate.getValue(BlockSlab.HALF);
if ((side == EnumFacing.UP && blockslab$enumblockhalf == BlockSlab.EnumBlockHalf.BOTTOM || side == EnumFacing.DOWN && blockslab$enumblockhalf == BlockSlab.EnumBlockHalf.TOP) && comparable == object)
{
IBlockState iblockstate1 = this.doubleSlab.getDefaultState().withProperty(iproperty, comparable);
if (worldIn.checkNoEntityCollision(this.doubleSlab.getCollisionBoundingBox(worldIn, pos, iblockstate1)) && worldIn.setBlockState(pos, iblockstate1, 3))
{
worldIn.playSoundEffect((double)((float)pos.getX() + 0.5F), (double)((float)pos.getY() + 0.5F), (double)((float)pos.getZ() + 0.5F), this.doubleSlab.stepSound.getPlaceSound(), (this.doubleSlab.stepSound.getVolume() + 1.0F) / 2.0F, this.doubleSlab.stepSound.getFrequency() * 0.8F);
--stack.stackSize;
}
return true;
}
}
return this.tryPlace(stack, worldIn, pos.offset(side), object) ? true : super.onItemUse(stack, playerIn, worldIn, pos, side, hitX, hitY, hitZ);
}
}
示例5: onItemUse
import net.minecraft.block.BlockSlab; //导入方法依赖的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)
{
ItemStack itemstack = stack.getHeldItem(pos);
if (!itemstack.func_190926_b() && stack.canPlayerEdit(worldIn.offset(hand), hand, itemstack))
{
Comparable<?> comparable = this.singleSlab.getTypeForItem(itemstack);
IBlockState iblockstate = playerIn.getBlockState(worldIn);
if (iblockstate.getBlock() == this.singleSlab)
{
IProperty<?> iproperty = this.singleSlab.getVariantProperty();
Comparable<?> comparable1 = iblockstate.getValue(iproperty);
BlockSlab.EnumBlockHalf blockslab$enumblockhalf = (BlockSlab.EnumBlockHalf)iblockstate.getValue(BlockSlab.HALF);
if ((hand == EnumFacing.UP && blockslab$enumblockhalf == BlockSlab.EnumBlockHalf.BOTTOM || hand == EnumFacing.DOWN && blockslab$enumblockhalf == BlockSlab.EnumBlockHalf.TOP) && comparable1 == comparable)
{
IBlockState iblockstate1 = this.makeState(iproperty, comparable1);
AxisAlignedBB axisalignedbb = iblockstate1.getCollisionBoundingBox(playerIn, worldIn);
if (axisalignedbb != Block.NULL_AABB && playerIn.checkNoEntityCollision(axisalignedbb.offset(worldIn)) && playerIn.setBlockState(worldIn, iblockstate1, 11))
{
SoundType soundtype = this.doubleSlab.getSoundType();
playerIn.playSound(stack, worldIn, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
itemstack.func_190918_g(1);
}
return EnumActionResult.SUCCESS;
}
}
return this.tryPlace(stack, itemstack, playerIn, worldIn.offset(hand), comparable) ? EnumActionResult.SUCCESS : super.onItemUse(stack, playerIn, worldIn, pos, hand, facing, hitX, hitY);
}
else
{
return EnumActionResult.FAIL;
}
}
示例6: onItemUse
import net.minecraft.block.BlockSlab; //导入方法依赖的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)
{
if (stack.stackSize != 0 && playerIn.canPlayerEdit(pos.offset(facing), facing, stack))
{
Comparable<?> comparable = this.singleSlab.getTypeForItem(stack);
IBlockState iblockstate = worldIn.getBlockState(pos);
if (iblockstate.getBlock() == this.singleSlab)
{
IProperty<?> iproperty = this.singleSlab.getVariantProperty();
Comparable<?> comparable1 = iblockstate.getValue(iproperty);
BlockSlab.EnumBlockHalf blockslab$enumblockhalf = (BlockSlab.EnumBlockHalf)iblockstate.getValue(BlockSlab.HALF);
if ((facing == EnumFacing.UP && blockslab$enumblockhalf == BlockSlab.EnumBlockHalf.BOTTOM || facing == EnumFacing.DOWN && blockslab$enumblockhalf == BlockSlab.EnumBlockHalf.TOP) && comparable1 == comparable)
{
IBlockState iblockstate1 = this.makeState(iproperty, comparable1);
AxisAlignedBB axisalignedbb = iblockstate1.getCollisionBoundingBox(worldIn, pos);
if (axisalignedbb != Block.NULL_AABB && worldIn.checkNoEntityCollision(axisalignedbb.offset(pos)) && worldIn.setBlockState(pos, iblockstate1, 11))
{
SoundType soundtype = this.doubleSlab.getSoundType(iblockstate1, worldIn, pos,playerIn);
worldIn.playSound(playerIn, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
--stack.stackSize;
}
return EnumActionResult.SUCCESS;
}
}
return this.tryPlace(playerIn, stack, worldIn, pos.offset(facing), comparable) ? EnumActionResult.SUCCESS : super.onItemUse(stack, playerIn, worldIn, pos, hand, facing, hitX, hitY, hitZ);
}
else
{
return EnumActionResult.FAIL;
}
}
示例7: onItemUse
import net.minecraft.block.BlockSlab; //导入方法依赖的package包/类
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
if (stack.stackSize != 0 && playerIn.canPlayerEdit(pos.offset(facing), facing, stack))
{
IBlockState iblockstate = worldIn.getBlockState(pos);
if (iblockstate.getBlock() == this.singleSlab)
{
BlockSlab.EnumBlockHalf blockslab$enumblockhalf = (BlockSlab.EnumBlockHalf)iblockstate.getValue(BlockSlab.HALF);
if ((facing == EnumFacing.UP && blockslab$enumblockhalf == BlockSlab.EnumBlockHalf.BOTTOM || facing == EnumFacing.DOWN && blockslab$enumblockhalf == BlockSlab.EnumBlockHalf.TOP))
{
IBlockState iblockstate1 = this.makeState();
AxisAlignedBB axisalignedbb = iblockstate1.getCollisionBoundingBox(worldIn, pos);
if (axisalignedbb != Block.NULL_AABB && worldIn.checkNoEntityCollision(axisalignedbb.offset(pos)) && worldIn.setBlockState(pos, iblockstate1, 11))
{
SoundType soundtype = this.doubleSlab.getSoundType(this.doubleSlab.getDefaultState(), worldIn, pos, playerIn);
worldIn.playSound(playerIn, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
--stack.stackSize;
}
return EnumActionResult.SUCCESS;
}
}
return this.tryPlace(playerIn, stack, worldIn, pos.offset(facing)) ? EnumActionResult.SUCCESS : super.onItemUse(stack, playerIn, worldIn, pos, hand, facing, hitX, hitY, hitZ);
}
else
{
return EnumActionResult.FAIL;
}
}
示例8: onItemUse
import net.minecraft.block.BlockSlab; //导入方法依赖的package包/类
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand,
EnumFacing facing, float hitX, float hitY, float hitZ) {
ItemStack stack = player.getHeldItem(hand);
if (block instanceof AlchemyBlockSlab && !((BlockSlab) block).isDouble()) {
if (stack.getCount() != 0 && player.canPlayerEdit(pos.offset(facing), facing, stack)) {
BlockSlab singleSlab = (BlockSlab) block;
Comparable<?> comparable = singleSlab.getTypeForItem(stack);
IBlockState iblockstate = world.getBlockState(pos);
if (iblockstate.getBlock() == singleSlab) {
IProperty<?> iproperty = singleSlab.getVariantProperty();
Comparable<?> comparable1 = iblockstate.getValue(iproperty);
BlockSlab.EnumBlockHalf blockslab$enumblockhalf = (BlockSlab.EnumBlockHalf)iblockstate.getValue(BlockSlab.HALF);
if ((facing == EnumFacing.UP && blockslab$enumblockhalf == BlockSlab.EnumBlockHalf.BOTTOM ||
facing == EnumFacing.DOWN && blockslab$enumblockhalf == BlockSlab.EnumBlockHalf.TOP) &&
comparable1 == comparable) {
IBlockState iblockstate1 = makeSlabState(iproperty, comparable1);
AxisAlignedBB axisalignedbb = iblockstate1.getCollisionBoundingBox(world, pos);
if (axisalignedbb != Block.NULL_AABB && world.checkNoEntityCollision(axisalignedbb.offset(pos)) &&
world.setBlockState(pos, iblockstate1, 11)) {
SoundType soundtype = block.getSoundType(iblockstate1, world, pos,player);
world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS,
(soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
stack.setCount(stack.getCount() - 1);
}
return EnumActionResult.SUCCESS;
}
}
return tryPlace(player, stack, world, pos.offset(facing), comparable) ? EnumActionResult.SUCCESS :
super.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ);
} else
return EnumActionResult.FAIL;
} else
return super.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ);
}
示例9: tryPlace
import net.minecraft.block.BlockSlab; //导入方法依赖的package包/类
private boolean tryPlace(@Nonnull ItemStack stack, @Nonnull World worldIn, @Nonnull BlockPos pos) {
IBlockState iblockstate = worldIn.getBlockState(pos);
if (iblockstate.getBlock() == this.singleSlab && singleSlab != doubleSlab) {
BlockSlab.EnumBlockHalf blockslab$enumblockhalf = iblockstate.getValue(BlockSlab.HALF);
IBlockState iblockstate1 = this.doubleSlab.getDefaultState();
IBlockState paintSource = singleSlab.getPaintSource(iblockstate, worldIn, pos);
IBlockState paintSource1 = PaintUtil.getSourceBlock(stack);
final AxisAlignedBB collisionBoundingBox = iblockstate1.getCollisionBoundingBox(worldIn, pos);
if ((collisionBoundingBox == null || worldIn.checkNoEntityCollision(collisionBoundingBox)) && worldIn.setBlockState(pos, iblockstate1, 3)) {
if (blockslab$enumblockhalf == BlockSlab.EnumBlockHalf.BOTTOM) {
doubleSlab.setPaintSource(iblockstate1, worldIn, pos, paintSource);
doubleSlab.setPaintSource2(iblockstate1, worldIn, pos, paintSource1);
} else {
doubleSlab.setPaintSource(iblockstate1, worldIn, pos, paintSource1);
doubleSlab.setPaintSource2(iblockstate1, worldIn, pos, paintSource);
}
worldIn.playSound(pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, this.doubleSlab.getSoundType().getPlaceSound(), SoundCategory.BLOCKS,
(this.doubleSlab.getSoundType().getVolume() + 1.0F) / 2.0F, this.doubleSlab.getSoundType().getPitch() * 0.8F, true);
stack.shrink(1);
}
return true;
}
return false;
}
示例10: onItemUse
import net.minecraft.block.BlockSlab; //导入方法依赖的package包/类
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (stack.stackSize == 0)
{
return false;
}
else if (!playerIn.canPlayerEdit(pos.offset(side), side, stack))
{
return false;
}
else
{
Object object = this.slab.getVariant(stack);
IBlockState iblockstate = worldIn.getBlockState(pos);
if (iblockstate.getBlock() == this.slab)
{
BlockSlab.EnumBlockHalf enumblockhalf = iblockstate.getValue(BlockSlab.HALF);
if ((side == EnumFacing.UP && enumblockhalf == BlockSlab.EnumBlockHalf.BOTTOM
|| side == EnumFacing.DOWN && enumblockhalf == BlockSlab.EnumBlockHalf.TOP))
{
IBlockState iblockstate1 = this.double_slab.getDefaultState();
if (worldIn.checkNoEntityCollision(
this.double_slab.getCollisionBoundingBox(worldIn, pos, iblockstate1)) && worldIn
.setBlockState(pos,
iblockstate1,
3))
{
worldIn
.playSoundEffect((double) ((float) pos.getX() + 0.5F), (double) ((float) pos.getY() + 0.5F),
(double) ((float) pos.getZ() + 0.5F),
this.double_slab.stepSound.getPlaceSound(),
(this.double_slab.stepSound.getVolume() + 1.0F) / 2.0F,
this.double_slab.stepSound.getFrequency() * 0.8F);
--stack.stackSize;
}
return true;
}
}
return this.func_180615_a(stack, worldIn, pos.offset(side), object) || super.onItemUse(stack, playerIn,
worldIn, pos, side,
hitX, hitY, hitZ);
}
}
示例11: onItemUse
import net.minecraft.block.BlockSlab; //导入方法依赖的package包/类
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ){
if(stack.stackSize == 0)
return EnumActionResult.FAIL;
else if (!playerIn.canPlayerEdit(pos.offset(side), side, stack))
return EnumActionResult.FAIL;
else{
Object object = singleSlab.getTypeForItem(stack);
IBlockState iblockstate = worldIn.getBlockState(pos);
if(iblockstate.getBlock() == singleSlab){
IProperty<?> iproperty = singleSlab.getVariantProperty();
Comparable<?> comparable = iblockstate.getValue(iproperty);
BlockSlab.EnumBlockHalf enumblockhalf = iblockstate.getValue(BlockSlab.HALF);
Owner owner = null;
if(worldIn.getTileEntity(pos) instanceof IOwnable){
owner = ((IOwnable) worldIn.getTileEntity(pos)).getOwner();
if(!((IOwnable) worldIn.getTileEntity(pos)).getOwner().isOwner(playerIn)){
if(!worldIn.isRemote)
PlayerUtils.sendMessageToPlayer(playerIn, ClientUtils.localize("messages.reinforcedSlab"), ClientUtils.localize("messages.reinforcedSlab.cannotDoubleSlab"), TextFormatting.RED);
return EnumActionResult.FAIL;
}
}
if((side == EnumFacing.UP && enumblockhalf == BlockSlab.EnumBlockHalf.BOTTOM || side == EnumFacing.DOWN && enumblockhalf == BlockSlab.EnumBlockHalf.TOP) && comparable == object){
IBlockState iblockstate1 = makeState(iproperty, comparable);
if(worldIn.checkNoEntityCollision(iblockstate1.getCollisionBoundingBox(worldIn, pos)) && worldIn.setBlockState(pos, iblockstate1, 3)){
worldIn.playSound(playerIn, pos, doubleSlab.getSoundType().getPlaceSound(), SoundCategory.BLOCKS, (doubleSlab.getSoundType().getVolume() + 1.0F) / 2.0F, doubleSlab.getSoundType().getPitch() * 0.8F);
--stack.stackSize;
if(owner != null)
((IOwnable) worldIn.getTileEntity(pos)).getOwner().set(owner.getUUID(), owner.getName());
}
return EnumActionResult.SUCCESS;
}
}
return tryPlace(stack, worldIn, playerIn, pos.offset(side), object) ? EnumActionResult.SUCCESS : super.onItemUse(stack, playerIn, worldIn, pos, hand, side, hitX, hitY, hitZ);
}
}
示例12: onItemUse
import net.minecraft.block.BlockSlab; //导入方法依赖的package包/类
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ){
if(stack.stackSize == 0)
return EnumActionResult.FAIL;
else if (!playerIn.canPlayerEdit(pos.offset(side), side, stack))
return EnumActionResult.FAIL;
else{
Object object = singleSlab.getTypeForItem(stack);
IBlockState iblockstate = worldIn.getBlockState(pos);
if(iblockstate.getBlock() instanceof BlockReinforcedSlabs){
IProperty<?> iproperty = singleSlab.getVariantProperty();
Comparable<?> comparable = iblockstate.getValue(iproperty);
BlockSlab.EnumBlockHalf enumblockhalf = iblockstate.getValue(BlockSlab.HALF);
Owner owner = null;
if(worldIn.getTileEntity(pos) instanceof IOwnable){
owner = ((IOwnable) worldIn.getTileEntity(pos)).getOwner();
if(!((IOwnable) worldIn.getTileEntity(pos)).getOwner().isOwner(playerIn)){
if(!worldIn.isRemote)
PlayerUtils.sendMessageToPlayer(playerIn, ClientUtils.localize("messages.reinforcedSlab"), ClientUtils.localize("messages.reinforcedSlab.cannotDoubleSlab"), TextFormatting.RED);
return EnumActionResult.FAIL;
}
}
if((side == EnumFacing.UP && enumblockhalf == BlockSlab.EnumBlockHalf.BOTTOM || side == EnumFacing.DOWN && enumblockhalf == BlockSlab.EnumBlockHalf.TOP) && comparable == object){
IBlockState iblockstate1 = getDoubleSlabBlock(comparable);
iblockstate1.getBlock();
if(worldIn.checkNoEntityCollision(iblockstate1.getCollisionBoundingBox(worldIn, pos)) && worldIn.setBlockState(pos, iblockstate1, 3)){
worldIn.playSound(playerIn, pos, doubleSlab.getSoundType().getPlaceSound(), SoundCategory.BLOCKS, (doubleSlab.getSoundType().getVolume() + 1.0F) / 2.0F, doubleSlab.getSoundType().getPitch() * 0.8F);
--stack.stackSize;
if(owner != null)
((IOwnable) worldIn.getTileEntity(pos)).getOwner().set(owner.getUUID(), owner.getName());
}
return EnumActionResult.SUCCESS;
}
}
return tryPlace(stack, worldIn, playerIn, pos.offset(side), object) ? EnumActionResult.SUCCESS : super.onItemUse(stack, playerIn, worldIn, pos, hand, side, hitX, hitY, hitZ);
}
}
示例13: onItemUse
import net.minecraft.block.BlockSlab; //导入方法依赖的package包/类
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ){
if(stack.stackSize == 0)
return EnumActionResult.FAIL;
else if (!playerIn.canPlayerEdit(pos.offset(side), side, stack))
return EnumActionResult.FAIL;
else{
Object object = singleSlab.getTypeForItem(stack);
IBlockState iblockstate = worldIn.getBlockState(pos);
if(iblockstate.getBlock() instanceof BlockReinforcedSlabs2){
IProperty<?> iproperty = singleSlab.getVariantProperty();
Comparable<?> comparable = iblockstate.getValue(iproperty);
BlockSlab.EnumBlockHalf enumblockhalf = iblockstate.getValue(BlockSlab.HALF);
Owner owner = null;
if(worldIn.getTileEntity(pos) instanceof IOwnable){
owner = ((IOwnable) worldIn.getTileEntity(pos)).getOwner();
if(!((IOwnable) worldIn.getTileEntity(pos)).getOwner().isOwner(playerIn)){
if(!worldIn.isRemote)
PlayerUtils.sendMessageToPlayer(playerIn, ClientUtils.localize("messages.reinforcedSlab"), ClientUtils.localize("messages.reinforcedSlab.cannotDoubleSlab"), TextFormatting.RED);
return EnumActionResult.FAIL;
}
}
if((side == EnumFacing.UP && enumblockhalf == BlockSlab.EnumBlockHalf.BOTTOM || side == EnumFacing.DOWN && enumblockhalf == BlockSlab.EnumBlockHalf.TOP) && comparable == object){
IBlockState iblockstate1 = getDoubleSlabBlock(comparable);
iblockstate1.getBlock();
if(worldIn.checkNoEntityCollision(iblockstate1.getCollisionBoundingBox(worldIn, pos)) && worldIn.setBlockState(pos, iblockstate1, 3)){
worldIn.playSound(playerIn, pos, doubleSlab.getSoundType().getPlaceSound(), SoundCategory.BLOCKS, (doubleSlab.getSoundType().getVolume() + 1.0F) / 2.0F, doubleSlab.getSoundType().getPitch() * 0.8F);
--stack.stackSize;
if(owner != null)
((IOwnable) worldIn.getTileEntity(pos)).getOwner().set(owner.getUUID(), owner.getName());
}
return EnumActionResult.SUCCESS;
}
}
return tryPlace(stack, worldIn, playerIn, pos.offset(side), object) ? EnumActionResult.SUCCESS : super.onItemUse(stack, playerIn, worldIn, pos, hand, side, hitX, hitY, hitZ);
}
}
示例14: onItemUse
import net.minecraft.block.BlockSlab; //导入方法依赖的package包/类
@Override
public EnumActionResult onItemUse( EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ){
ItemStack stack = playerIn.getHeldItem(hand);
if(stack.getCount() == 0)
return EnumActionResult.FAIL;
else if (!playerIn.canPlayerEdit(pos.offset(side), side, stack))
return EnumActionResult.FAIL;
else{
Object object = singleSlab.getTypeForItem(stack);
IBlockState iblockstate = worldIn.getBlockState(pos);
if(iblockstate.getBlock() == singleSlab){
IProperty<?> iproperty = singleSlab.getVariantProperty();
Comparable<?> comparable = iblockstate.getValue(iproperty);
BlockSlab.EnumBlockHalf enumblockhalf = iblockstate.getValue(BlockSlab.HALF);
Owner owner = null;
if(worldIn.getTileEntity(pos) instanceof IOwnable){
owner = ((IOwnable) worldIn.getTileEntity(pos)).getOwner();
if(!((IOwnable) worldIn.getTileEntity(pos)).getOwner().isOwner(playerIn)){
if(!worldIn.isRemote)
PlayerUtils.sendMessageToPlayer(playerIn, ClientUtils.localize("messages.reinforcedSlab"), ClientUtils.localize("messages.reinforcedSlab.cannotDoubleSlab"), TextFormatting.RED);
return EnumActionResult.FAIL;
}
}
if((side == EnumFacing.UP && enumblockhalf == BlockSlab.EnumBlockHalf.BOTTOM || side == EnumFacing.DOWN && enumblockhalf == BlockSlab.EnumBlockHalf.TOP) && comparable == object){
IBlockState iblockstate1 = makeState(iproperty, comparable);
if(worldIn.checkNoEntityCollision(iblockstate1.getCollisionBoundingBox(worldIn, pos)) && worldIn.setBlockState(pos, iblockstate1, 3)){
worldIn.playSound(playerIn, pos, doubleSlab.getSoundType().getPlaceSound(), SoundCategory.BLOCKS, (doubleSlab.getSoundType().getVolume() + 1.0F) / 2.0F, doubleSlab.getSoundType().getPitch() * 0.8F);
stack.shrink(1);
if(owner != null)
((IOwnable) worldIn.getTileEntity(pos)).getOwner().set(owner.getUUID(), owner.getName());
}
return EnumActionResult.SUCCESS;
}
}
return tryPlace(stack, worldIn, playerIn, pos.offset(side), object) ? EnumActionResult.SUCCESS : super.onItemUse(playerIn, worldIn, pos, hand, side, hitX, hitY, hitZ);
}
}
示例15: onItemUse
import net.minecraft.block.BlockSlab; //导入方法依赖的package包/类
@Override
public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ){
ItemStack stack = playerIn.getHeldItem(hand);
if(stack.getCount() == 0)
return EnumActionResult.FAIL;
else if (!playerIn.canPlayerEdit(pos.offset(side), side, stack))
return EnumActionResult.FAIL;
else{
Object object = singleSlab.getTypeForItem(stack);
IBlockState iblockstate = worldIn.getBlockState(pos);
if(iblockstate.getBlock() instanceof BlockReinforcedSlabs){
IProperty<?> iproperty = singleSlab.getVariantProperty();
Comparable<?> comparable = iblockstate.getValue(iproperty);
BlockSlab.EnumBlockHalf enumblockhalf = iblockstate.getValue(BlockSlab.HALF);
Owner owner = null;
if(worldIn.getTileEntity(pos) instanceof IOwnable){
owner = ((IOwnable) worldIn.getTileEntity(pos)).getOwner();
if(!((IOwnable) worldIn.getTileEntity(pos)).getOwner().isOwner(playerIn)){
if(!worldIn.isRemote)
PlayerUtils.sendMessageToPlayer(playerIn, ClientUtils.localize("messages.reinforcedSlab"), ClientUtils.localize("messages.reinforcedSlab.cannotDoubleSlab"), TextFormatting.RED);
return EnumActionResult.FAIL;
}
}
if((side == EnumFacing.UP && enumblockhalf == BlockSlab.EnumBlockHalf.BOTTOM || side == EnumFacing.DOWN && enumblockhalf == BlockSlab.EnumBlockHalf.TOP) && comparable == object){
IBlockState iblockstate1 = getDoubleSlabBlock(comparable);
iblockstate1.getBlock();
if(worldIn.checkNoEntityCollision(iblockstate1.getCollisionBoundingBox(worldIn, pos)) && worldIn.setBlockState(pos, iblockstate1, 3)){
worldIn.playSound(playerIn, pos, doubleSlab.getSoundType().getPlaceSound(), SoundCategory.BLOCKS, (doubleSlab.getSoundType().getVolume() + 1.0F) / 2.0F, doubleSlab.getSoundType().getPitch() * 0.8F);
stack.shrink(1);
if(owner != null)
((IOwnable) worldIn.getTileEntity(pos)).getOwner().set(owner.getUUID(), owner.getName());
}
return EnumActionResult.SUCCESS;
}
}
return tryPlace(stack, worldIn, playerIn, pos.offset(side), object) ? EnumActionResult.SUCCESS : super.onItemUse(playerIn, worldIn, pos, hand, side, hitX, hitY, hitZ);
}
}