net.minecraft.block.BlockSlab Java Examples
The following examples show how to use
net.minecraft.block.BlockSlab.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BufferSpeed.java From LiquidBounce with GNU General Public License v3.0 | 6 votes |
private boolean isNearBlock() { final EntityPlayerSP thePlayer = mc.thePlayer; final WorldClient theWorld = mc.theWorld; final List<BlockPos> blocks = new ArrayList<>(); blocks.add(new BlockPos(thePlayer.posX, thePlayer.posY + 1, thePlayer.posZ - 0.7)); blocks.add(new BlockPos(thePlayer.posX + 0.7, thePlayer.posY + 1, thePlayer.posZ)); blocks.add(new BlockPos(thePlayer.posX, thePlayer.posY + 1, thePlayer.posZ + 0.7)); blocks.add(new BlockPos(thePlayer.posX - 0.7, thePlayer.posY + 1, thePlayer.posZ)); for(final BlockPos blockPos : blocks) if((theWorld.getBlockState(blockPos).getBlock().getBlockBoundsMaxY() == theWorld.getBlockState(blockPos).getBlock().getBlockBoundsMinY() + 1 && !theWorld.getBlockState(blockPos).getBlock().isTranslucent() && theWorld.getBlockState(blockPos).getBlock() != Blocks.water && !(theWorld.getBlockState(blockPos).getBlock() instanceof BlockSlab)) || theWorld.getBlockState(blockPos).getBlock() == Blocks.barrier) return true; return false; }
Example #2
Source File: EasyPlaceUtils.java From litematica with GNU Lesser General Public License v3.0 | 6 votes |
private static boolean clientBlockIsSameMaterialSingleSlab(IBlockState stateSchematic, IBlockState stateClient) { Block blockSchematic = stateSchematic.getBlock(); Block blockClient = stateClient.getBlock(); if ((blockSchematic instanceof BlockSlab) && (blockClient instanceof BlockSlab) && ((BlockSlab) blockClient).isDouble() == false) { IProperty<?> propSchematic = ((BlockSlab) blockSchematic).getVariantProperty(); IProperty<?> propClient = ((BlockSlab) blockClient).getVariantProperty(); return propSchematic == propClient && stateSchematic.getValue(propSchematic) == stateClient.getValue(propClient); } return false; }
Example #3
Source File: EasyPlaceUtils.java From litematica with GNU Lesser General Public License v3.0 | 6 votes |
private static boolean canPlaceBlock(BlockPos targetPos, World worldClient, IBlockState stateSchematic, IBlockState stateClient) { boolean isSlab = stateSchematic.getBlock() instanceof BlockSlab; if (isSlab) { if (PlacementUtils.isReplaceable(worldClient, targetPos, true) == false && (((BlockSlab) stateSchematic.getBlock()).isDouble() == false || clientBlockIsSameMaterialSingleSlab(stateSchematic, stateClient) == false)) { return false; } return true; } return PlacementUtils.isReplaceable(worldClient, targetPos, true); }
Example #4
Source File: BlockSlabWithSubtypesTest.java From customstuff4 with GNU General Public License v3.0 | 6 votes |
@Test @SuppressWarnings("unchecked") public void test_getSubtype() { 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)); } } }
Example #5
Source File: MaterialCache.java From litematica with GNU Lesser General Public License v3.0 | 5 votes |
protected void overrideStackSize(IBlockState state, ItemStack stack) { if (state.getBlock() instanceof BlockSlab && ((BlockSlab) state.getBlock()).isDouble()) { stack.setCount(2); } else if (state.getBlock() == Blocks.SNOW_LAYER) { stack.setCount(state.getValue(BlockSnow.LAYERS)); } }
Example #6
Source File: ItemUtils.java From litematica with GNU Lesser General Public License v3.0 | 5 votes |
private static void overrideStackSize(IBlockState state, ItemStack stack) { if (state.getBlock() instanceof BlockSlab && ((BlockSlab) state.getBlock()).isDouble()) { stack.setCount(2); } }
Example #7
Source File: EasyPlaceUtils.java From litematica with GNU Lesser General Public License v3.0 | 5 votes |
@Nullable private static HitPosition getClickPosition(HitPosition targetPosition, IBlockState stateSchematic, IBlockState stateClient, Minecraft mc) { boolean isSlab = stateSchematic.getBlock() instanceof BlockSlab; if (isSlab) { return getClickPositionForSlab(targetPosition, stateSchematic, stateClient, mc); } BlockPos targetBlockPos = targetPosition.getBlockPos(); boolean requireAdjacent = Configs.Generic.EASY_PLACE_CLICK_ADJACENT.getBooleanValue(); return requireAdjacent ? getAdjacentClickPosition(targetBlockPos, mc) : targetPosition; }
Example #8
Source File: EasyPlaceUtils.java From litematica with GNU Lesser General Public License v3.0 | 5 votes |
private static boolean canClickOnAdjacentBlockToPlaceSingleSlabAt(BlockPos targetBlockPos, IBlockState targetState, EnumFacing side, World worldClient) { BlockPos posSide = targetBlockPos.offset(side); IBlockState stateSide = worldClient.getBlockState(posSide); return PlacementUtils.isReplaceable(worldClient, posSide, false) == false && (side.getAxis() != EnumFacing.Axis.Y || clientBlockIsSameMaterialSingleSlab(targetState, stateSide) == false || stateSide.getValue(BlockSlab.HALF) != targetState.getValue(BlockSlab.HALF)); }
Example #9
Source File: BlockMap.java From ToroQuest with GNU General Public License v3.0 | 5 votes |
private PaletteEntry parsePaleteBlock(String blockString) { PaletteEntry entry = new PaletteEntry(); String[] a = blockString.split("\\|"); entry.block = Block.getBlockFromName(a[0]).getDefaultState(); // blockRegistry.getObject(new // ResourceLocation(a[0])).getDefaultState(); if(a[0].equals("minecraft:wooden_slab")){ entry.block = entry.block.withProperty(BlockSlab.HALF, BlockSlab.EnumBlockHalf.TOP); } if (a.length > 0) { for (int i = 1; i < a.length; i++) { String propertyString = a[i]; if (propertyString == null) { continue; } if (propertyString.matches("^\\(\\d+\\)$")) { System.out.println("found pass number [" + propertyString + "]"); parsePaletePassNumber(propertyString, entry); }else{ parsePaleteBlockParameter(a[0], propertyString, entry); } } } return entry; }
Example #10
Source File: MapGenLander.java From AdvancedRocketry with MIT License | 4 votes |
@SubscribeEvent public void populateChunkPostEvent(PopulateChunkEvent.Post event) { World worldIn = event.getWorld(); BlockPos position = new BlockPos(16*event.getChunkX() + 3,0, 16*event.getChunkZ() + 11); if(DimensionManager.getInstance().getDimensionProperties(worldIn.provider.getDimension()).getName().equals("Luna") && position.getX() == 67 && position.getZ() == 2347) { position = worldIn.getHeight(position).down(); worldIn.setBlockState(position.add(0, 0, 3), Blocks.STONE_SLAB.getDefaultState().withProperty(BlockSlab.HALF, EnumBlockHalf.TOP)); worldIn.setBlockState(position.add(0, 0, -3), Blocks.STONE_SLAB.getDefaultState().withProperty(BlockSlab.HALF, EnumBlockHalf.TOP)); worldIn.setBlockState(position.add(3, 0, 0), Blocks.STONE_SLAB.getDefaultState().withProperty(BlockSlab.HALF, EnumBlockHalf.TOP)); worldIn.setBlockState(position.add(-3, 0, 0), Blocks.STONE_SLAB.getDefaultState().withProperty(BlockSlab.HALF, EnumBlockHalf.TOP)); position = position.up(); worldIn.setBlockState(position, AdvancedRocketryBlocks.blockEngine.getDefaultState()); worldIn.setBlockState(position.add(0, 0, 3), Blocks.IRON_BARS.getDefaultState()); worldIn.setBlockState(position.add(0, 0, -3), Blocks.IRON_BARS.getDefaultState()); worldIn.setBlockState(position.add(3, 0, 0), Blocks.IRON_BARS.getDefaultState()); worldIn.setBlockState(position.add(-3, 0, 0), Blocks.IRON_BARS.getDefaultState()); position = position.up(); worldIn.setBlockState(position.add(0, 0, 3), Blocks.IRON_BARS.getDefaultState()); worldIn.setBlockState(position.add(0, 0, -3), Blocks.IRON_BARS.getDefaultState()); worldIn.setBlockState(position.add(3, 0, 0), Blocks.IRON_BARS.getDefaultState()); worldIn.setBlockState(position.add(-3, 0, 0), Blocks.IRON_BARS.getDefaultState()); for(int x = -1; x <= 1; x++ ) { worldIn.setBlockState(position.add(-2, 0, x), Blocks.GOLD_BLOCK.getDefaultState()); worldIn.setBlockState(position.add(2, 0, x), Blocks.GOLD_BLOCK.getDefaultState()); worldIn.setBlockState(position.add(x, 0, -2), Blocks.GOLD_BLOCK.getDefaultState()); worldIn.setBlockState(position.add(x, 0, 2), Blocks.GOLD_BLOCK.getDefaultState()); for(int z = -1; z <= 1; z++) { worldIn.setBlockState(position.add(x, 0, z), Blocks.IRON_BLOCK.getDefaultState()); } } position = position.up(); worldIn.setBlockState(position.add(0, 0, 3), Blocks.IRON_BARS.getDefaultState()); worldIn.setBlockState(position.add(0, 0, -3), Blocks.IRON_BARS.getDefaultState()); worldIn.setBlockState(position.add(3, 0, 0), Blocks.IRON_BARS.getDefaultState()); worldIn.setBlockState(position.add(-3, 0, 0), Blocks.IRON_BARS.getDefaultState()); for(int x = -1; x <= 1; x++ ) { worldIn.setBlockState(position.add(-2, 0, x), Blocks.GOLD_BLOCK.getDefaultState()); worldIn.setBlockState(position.add(2, 0, x), Blocks.GOLD_BLOCK.getDefaultState()); worldIn.setBlockState(position.add(x, 0, -2), Blocks.GOLD_BLOCK.getDefaultState()); worldIn.setBlockState(position.add(x, 0, 2), Blocks.GOLD_BLOCK.getDefaultState()); } worldIn.setBlockState(position.add(0, 0, 1), Blocks.IRON_BLOCK.getDefaultState()); worldIn.setBlockState(position.add(1, 0, 0), Blocks.IRON_BLOCK.getDefaultState()); worldIn.setBlockState(position.add(0, 0, -1), Blocks.IRON_BLOCK.getDefaultState()); worldIn.setBlockState(position.add(-1, 0, 0), Blocks.IRON_BLOCK.getDefaultState()); position = worldIn.getHeight(position.add(10,0,15)); for(int x = 0; x <= 4; x++ ) worldIn.setBlockState(position.add(0,x,0), Blocks.IRON_BARS.getDefaultState()); worldIn.setBlockState(position.add(1,4,0), Blocks.IRON_BARS.getDefaultState()); worldIn.setBlockState(position.add(2,4,0), Blocks.IRON_BARS.getDefaultState()); } }