net.minecraft.util.DefaultedList#net.minecraft.block.Blocks源码实例Demo

下面列出了net.minecraft.util.DefaultedList#net.minecraft.block.Blocks 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@SuppressWarnings("UnresolvedMixinReference")
@Inject(method = "dispenseSilently(Lnet/minecraft/util/math/BlockPointer;Lnet/minecraft/item/ItemStack;)Lnet/minecraft/item/ItemStack;", at = @At("HEAD"), cancellable = true)
private void convertNetherrack(BlockPointer pointer, ItemStack stack, CallbackInfoReturnable<ItemStack> cir)
{
    if (!CarpetExtraSettings.fireChargeConvertsToNetherrack)
        return;
    World world = pointer.getWorld();
    Direction direction = pointer.getBlockState().get(DispenserBlock.FACING);
    BlockPos front = pointer.getBlockPos().offset(direction);
    BlockState state = world.getBlockState(front);
    if (state.getBlock() == Blocks.COBBLESTONE)
    {
        world.setBlockState(front, Blocks.NETHERRACK.getDefaultState());
        stack.decrement(1);
        cir.setReturnValue(stack);
        cir.cancel();
    }
}
 
源代码2 项目: Galacticraft-Rewoven   文件: MoonChunkGenerator.java
public MoonChunkGenerator(MoonBiomeSource biomeSource, long seed) {
    super(biomeSource, biomeSource, new StructuresConfig(false), seed);
    this.seed = seed;
    this.chunkGeneratorType = new ChunkGeneratorType(new StructuresConfig(false), new NoiseConfig(256, new NoiseSamplingConfig(0.9999999814507745D, 0.9999999814507745D, 80.0D, 160.0D), new SlideConfig(-10, 3, 0), new SlideConfig(-30, 0, 0), 1, 2, 1.0D, -0.46875D, true, true, false, false), Blocks.STONE.getDefaultState(), Blocks.WATER.getDefaultState(), -10, 0, 63, false);
    NoiseConfig noiseConfig = chunkGeneratorType.method_28559();
    this.field_24779 = noiseConfig.getHeight();
    this.verticalNoiseResolution = noiseConfig.getSizeVertical() * 4;
    this.horizontalNoiseResolution = noiseConfig.getSizeHorizontal() * 4;
    this.defaultBlock = chunkGeneratorType.getDefaultBlock();
    this.defaultFluid = chunkGeneratorType.getDefaultFluid();
    this.noiseSizeX = 16 / this.horizontalNoiseResolution;
    this.noiseSizeY = noiseConfig.getHeight() / this.verticalNoiseResolution;
    this.noiseSizeZ = 16 / this.horizontalNoiseResolution;
    this.random = new ChunkRandom(seed);
    this.lowerInterpolatedNoise = new OctavePerlinNoiseSampler(this.random, IntStream.rangeClosed(-15, 0));
    this.upperInterpolatedNoise = new OctavePerlinNoiseSampler(this.random, IntStream.rangeClosed(-15, 0));
    this.interpolationNoise = new OctavePerlinNoiseSampler(this.random, IntStream.rangeClosed(-7, 0));
    this.surfaceDepthNoise = new OctaveSimplexNoiseSampler(this.random, IntStream.rangeClosed(-3, 0));
    this.random.consume(2620);
    this.field_24776 = new OctavePerlinNoiseSampler(this.random, IntStream.rangeClosed(-15, 0));
}
 
@Inject( method = "onChunkData", locals = LocalCapture.CAPTURE_FAILHARD, require = 0, at = @At(
        value = "INVOKE",
        target = "Lnet/minecraft/client/world/ClientWorld;getBlockEntity(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/entity/BlockEntity;",
        shift = At.Shift.AFTER
))
private void recreateMovingPistons(ChunkDataS2CPacket packet, CallbackInfo ci,
                                   Iterator var5, CompoundTag tag, BlockPos blockPos)
{
    if (CarpetSettings.smoothClientAnimations)
    {
        BlockEntity blockEntity = world.getBlockEntity(blockPos);
        if (blockEntity == null && "minecraft:piston".equals(tag.getString("id")))
        {
            BlockState blockState = world.getBlockState(blockPos);
            if (blockState.getBlock() == Blocks.MOVING_PISTON) {
                tag.putFloat("progress", Math.min(tag.getFloat("progress") + 0.5F, 1.0F));
                blockEntity = new PistonBlockEntity();
                blockEntity.fromTag(tag);
                world.setBlockEntity(blockPos, blockEntity);
                blockEntity.resetBlock();
            }
        }
    }
}
 
源代码4 项目: the-hallow   文件: SpiderLairFeature.java
@Override
public boolean generate(IWorld iWorld, ChunkGenerator<? extends ChunkGeneratorConfig> chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig defaultFeatureConfig) {
	if (iWorld.getBlockState(pos.down()).getBlock() == HallowedBlocks.DECEASED_GRASS_BLOCK) {
		setSpawner(iWorld, pos, EntityType.SPIDER);
		
		for (int i = 0; i < 64; ++i) {
			BlockPos pos_2 = pos.add(random.nextInt(6) - random.nextInt(6), random.nextInt(3) - random.nextInt(3), random.nextInt(6) - random.nextInt(6));
			if (iWorld.isAir(pos_2) || iWorld.getBlockState(pos_2).getBlock() == HallowedBlocks.DECEASED_GRASS_BLOCK) {
				iWorld.setBlockState(pos_2, Blocks.COBWEB.getDefaultState(), 2);
			}
		}
		
		BlockPos chestPos = pos.add(random.nextInt(4) - random.nextInt(4), 0, random.nextInt(4) - random.nextInt(4));
		iWorld.setBlockState(chestPos, StructurePiece.method_14916(iWorld, chestPos, Blocks.CHEST.getDefaultState()), 2);
		LootableContainerBlockEntity.setLootTable(iWorld, random, chestPos, TheHallow.id("chests/spider_lair"));
		
		return true;
	} else {
		return false;
	}
}
 
@Inject(method = "finish", at = @At(value = "RETURN"))
private void finishHandleBroken(CallbackInfo cir)
{
    //Handle TNT Explosions or other ways the moving Block is broken
    //Also /setblock will cause this to be called, and drop e.g. a moving chest's contents.
    // This is MC-40380 (BlockEntities that aren't Inventories drop stuff when setblock is called )
    if (CarpetSettings.movableBlockEntities && this.carriedBlockEntity != null && !this.world.isClient && this.world.getBlockState(this.pos).getBlock() == Blocks.AIR)
    {
        BlockState blockState_2;
        if (this.source)
            blockState_2 = Blocks.AIR.getDefaultState();
        else
            blockState_2 = Block.getRenderingState(this.pushedBlock, this.world, this.pos);
        ((WorldInterface) (this.world)).setBlockStateWithBlockEntity(this.pos, blockState_2, this.carriedBlockEntity, 3);
        this.world.breakBlock(this.pos, false, null);
    }
}
 
源代码6 项目: bleachhack-1.14   文件: Nofall.java
@Subscribe
public void onTick(EventTick event) {
	if (mc.player.fallDistance > 2f && getSettings().get(0).toMode().mode == 0) {
		if (mc.player.isFallFlying()) return;
		mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket(true));
	}
	
	if (mc.player.fallDistance > 2f && getSettings().get(0).toMode().mode == 1 &&
			mc.world.getBlockState(mc.player.getBlockPos().add(
					0,-1.5+(mc.player.getVelocity().y*0.1),0)).getBlock() != Blocks.AIR) {
		mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket(false));
		mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.PositionOnly(
				mc.player.getX(), mc.player.getY() - 420.69, mc.player.getZ(), true));
		mc.player.fallDistance = 0;
	}
}
 
/**
 * Handles blocks besides the slimeblock that are sticky. Currently only supports blocks that are sticky on one side.
 * Currently the only additional sticky block is the double chest, which sticks to its other chest half.
 * @param blockPos_1 location of a block that moves and needs to stick other blocks to it
 * @author 2No2Name
 */
private boolean stickToStickySide(BlockPos blockPos_1){
    if(!CarpetSettings.movableBlockEntities)
        return true;

    BlockState blockState_1 = this.world.getBlockState(blockPos_1);
    Block block = blockState_1.getBlock();
    Direction stickyDirection  = null;
    if(block == Blocks.CHEST || block == Blocks.TRAPPED_CHEST) {
        stickyDirection = getDirectionToOtherChestHalf(blockState_1);
    }

    //example how you could make sticky pistons have a sticky side:
    //else if(block == Blocks.STICKY_PISTON){
    //    stickyDirection = blockState_1.get(FacingBlock.FACING);
    //}

    return stickyDirection == null || this.tryMove(blockPos_1.offset(stickyDirection), stickyDirection);
}
 
源代码8 项目: XRay-Mod   文件: GameBlockStore.java
/**
 * This method is used to fill the store as we do not intend to update this after
 * it has been populated, it's a singleton by nature but we still need some
 * amount of control over when it is populated.
 */
public void populate()
{
    // Avoid doing the logic again unless repopulate is called
    if( this.store.size() != 0 )
        return;

    for ( Item item : ForgeRegistries.ITEMS ) {
        if( !(item instanceof net.minecraft.item.BlockItem) )
            continue;

        Block block = Block.getBlockFromItem(item);
        if ( item == Items.AIR || block == Blocks.AIR || Controller.blackList.contains(block) )
            continue; // avoids troubles

        store.add(new BlockWithItemStack(block, new ItemStack(item)));
    }
}
 
源代码9 项目: multiconnect   文件: Protocol_1_10.java
private void mutateBlockRegistry(ISimpleRegistry<Block> registry) {
    registry.purge(Blocks.OBSERVER);
    registry.purge(Blocks.WHITE_SHULKER_BOX);
    registry.purge(Blocks.ORANGE_SHULKER_BOX);
    registry.purge(Blocks.MAGENTA_SHULKER_BOX);
    registry.purge(Blocks.LIGHT_BLUE_SHULKER_BOX);
    registry.purge(Blocks.YELLOW_SHULKER_BOX);
    registry.purge(Blocks.LIME_SHULKER_BOX);
    registry.purge(Blocks.PINK_SHULKER_BOX);
    registry.purge(Blocks.GRAY_SHULKER_BOX);
    registry.purge(Blocks.LIGHT_GRAY_SHULKER_BOX);
    registry.purge(Blocks.CYAN_SHULKER_BOX);
    registry.purge(Blocks.PURPLE_SHULKER_BOX);
    registry.purge(Blocks.BLUE_SHULKER_BOX);
    registry.purge(Blocks.BROWN_SHULKER_BOX);
    registry.purge(Blocks.GREEN_SHULKER_BOX);
    registry.purge(Blocks.RED_SHULKER_BOX);
    registry.purge(Blocks.BLACK_SHULKER_BOX);
}
 
源代码10 项目: multiconnect   文件: Protocol_1_11_2.java
private void mutateBlockRegistry(ISimpleRegistry<Block> registry) {
    registry.purge(Blocks.WHITE_GLAZED_TERRACOTTA);
    registry.purge(Blocks.ORANGE_GLAZED_TERRACOTTA);
    registry.purge(Blocks.MAGENTA_GLAZED_TERRACOTTA);
    registry.purge(Blocks.LIGHT_BLUE_GLAZED_TERRACOTTA);
    registry.purge(Blocks.YELLOW_GLAZED_TERRACOTTA);
    registry.purge(Blocks.LIME_GLAZED_TERRACOTTA);
    registry.purge(Blocks.PINK_GLAZED_TERRACOTTA);
    registry.purge(Blocks.GRAY_GLAZED_TERRACOTTA);
    registry.purge(Blocks.LIGHT_GRAY_GLAZED_TERRACOTTA);
    registry.purge(Blocks.CYAN_GLAZED_TERRACOTTA);
    registry.purge(Blocks.PURPLE_GLAZED_TERRACOTTA);
    registry.purge(Blocks.BLUE_GLAZED_TERRACOTTA);
    registry.purge(Blocks.BROWN_GLAZED_TERRACOTTA);
    registry.purge(Blocks.GREEN_GLAZED_TERRACOTTA);
    registry.purge(Blocks.RED_GLAZED_TERRACOTTA);
    registry.purge(Blocks.BLACK_GLAZED_TERRACOTTA);
    registry.purge(Blocks.WHITE_CONCRETE);
    registry.purge(Blocks.WHITE_CONCRETE_POWDER);
}
 
源代码11 项目: bleachhack-1.14   文件: Nofall.java
@Subscribe
public void onTick(EventTick event) {
	if (mc.player.fallDistance > 2f && getSettings().get(0).toMode().mode == 0) {
		if (mc.player.isFallFlying()) return;
		mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket(true));
	}
	
	if (mc.player.fallDistance > 2f && getSettings().get(0).toMode().mode == 1 &&
			mc.world.getBlockState(mc.player.getBlockPos().add(
					0,-1.5+(mc.player.getVelocity().y*0.1),0)).getBlock() != Blocks.AIR) {
		mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket(false));
		mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.PositionOnly(
				mc.player.getX(), mc.player.getY() - 420.69, mc.player.getZ(), true));
		mc.player.fallDistance = 0;
	}
}
 
源代码12 项目: carpet-extra   文件: CarpetDispenserBehaviours.java
@Override
protected ItemStack dispenseSilently(BlockPointer source, ItemStack stack)
{
    if (!CarpetExtraSettings.dispensersPlayRecords)
        return super.dispenseSilently(source, stack);
    
    Direction direction = source.getBlockState().get(DispenserBlock.FACING);
    BlockPos pos = source.getBlockPos().offset(direction);
    World world = source.getWorld();
    BlockState state = world.getBlockState(pos);
    
    if (state.getBlock() == Blocks.JUKEBOX)
    {
        JukeboxBlockEntity jukebox = (JukeboxBlockEntity) world.getBlockEntity(pos);
        if (jukebox != null)
        {
            ItemStack itemStack = jukebox.getRecord();
            ((JukeboxBlock) state.getBlock()).setRecord(world, pos, state, stack);
            world.playLevelEvent(null, 1010, pos, Item.getRawId(stack.getItem()));
            
            return itemStack;
        }
    }
    
    return super.dispenseSilently(source, stack);
}
 
源代码13 项目: carpet-extra   文件: CarpetDispenserBehaviours.java
@Override
protected ItemStack dispenseSilently(BlockPointer source, ItemStack stack)
{
    if (!CarpetExtraSettings.dragonsBreathConvertsCobbleToEndstone)
        return super.dispenseSilently(source, stack);
    
    World world = source.getWorld();
    Direction direction = source.getBlockState().get(DispenserBlock.FACING);
    BlockPos front = source.getBlockPos().offset(direction);
    BlockState state = world.getBlockState(front);
    
    if (state.getBlock() == Blocks.COBBLESTONE)
    {
        world.setBlockState(front, Blocks.END_STONE.getDefaultState());
        stack.decrement(1);
        return stack;
    }
    return super.dispenseSilently(source, stack);
}
 
源代码14 项目: carpet-extra   文件: LivingEntityMixin.java
@Inject(
        method = "onDeath",
        at = @At(value = "INVOKE",
                target = "Lnet/minecraft/entity/damage/DamageSource;getAttacker()Lnet/minecraft/entity/Entity;",
                shift = At.Shift.BEFORE)
)
private void convertSandToSoulsand(DamageSource damageSource_1, CallbackInfo ci)
{
    if (!CarpetExtraSettings.mobInFireConvertsSandToSoulsand)
        return;
    
    BlockPos pos = new BlockPos(this.getX(), this.getY(), this.getZ());
    BlockState statePos = this.world.getBlockState(pos);
    
    BlockPos below = pos.down(1);
    BlockState stateBelow = this.world.getBlockState(below);
    
    if (statePos.getBlock() == Blocks.FIRE && stateBelow.getBlock().matches(BlockTags.SAND))
    {
        this.world.setBlockState(below, Blocks.SOUL_SAND.getDefaultState());
    }
}
 
源代码15 项目: carpet-extra   文件: FlowerPotBlockMixin.java
@Inject(method = "onUse", at = @At("HEAD"))
private void onActivate(BlockState blockState_1, World world_1, BlockPos blockPos_1, PlayerEntity playerEntity_1, Hand hand_1, BlockHitResult blockHitResult_1, CallbackInfoReturnable<Boolean> cir)
{
    if (CarpetExtraSettings.flowerPotChunkLoading && world_1.getServer() != null && !world_1.isClient)
    {
        ItemStack stack = playerEntity_1.getStackInHand(hand_1);
        Item item = stack.getItem();
        Block block = item instanceof BlockItem ? (Block) CONTENT_TO_POTTED.getOrDefault(((BlockItem) item).getBlock(), Blocks.AIR) : Blocks.AIR;
        boolean boolean_1 = block == Blocks.AIR;
        boolean boolean_2 = this.content == Blocks.AIR;
        ServerWorld serverWorld = world_1.getServer().getWorld(world_1.getDimension().getType());

        if (boolean_1 != boolean_2 && (block == Blocks.POTTED_WITHER_ROSE || this.content == Blocks.WITHER_ROSE))
        {
            // System.out.println("Chunk load status = " + boolean_2);
            serverWorld.setChunkForced(blockPos_1.getX() >> 4, blockPos_1.getZ() >> 4, boolean_2);
        }
    }
}
 
源代码16 项目: carpet-extra   文件: DropperBlock_craftingMixin.java
@Override
public int getComparatorOutput(BlockState blockState_1, World world_1, BlockPos blockPos_1)
{
    if (CarpetExtraSettings.autoCraftingDropper)
    {
        BlockPos front = blockPos_1.offset(world_1.getBlockState(blockPos_1).get(DispenserBlock.FACING));
        if (world_1.getBlockState(front).getBlock() == Blocks.CRAFTING_TABLE)
        {
            DispenserBlockEntity dispenserBlockEntity_1 = (DispenserBlockEntity) world_1.getBlockEntity(blockPos_1);
            if (dispenserBlockEntity_1 != null)
            {
                int filled = 0;
                for (ItemStack stack : ((DispenserBlockEntityInterface) dispenserBlockEntity_1).getInventory())
                {
                    if (!stack.isEmpty()) filled++;
                }
                return (filled * 15) / 9;
            }
        }
    }
    return super.getComparatorOutput(blockState_1, world_1, blockPos_1);
}
 
public BlockState getBlockState(Random random, BlockPos pos) {
    double d = Biome.FOLIAGE_NOISE.sample((double) pos.getX() / 200.0D, (double) pos.getZ() / 200.0D, false);
    if (d < -0.8D) {
        return (BlockState) Util.getRandom((Object[]) mix1, random);
    } else {
        return random.nextInt(3) > 0 ? (BlockState) Util.getRandom((Object[]) mix2, random) : Blocks.DANDELION.getDefaultState();
    }
}
 
源代码18 项目: fabric-carpet   文件: BlockRotator.java
public static boolean flippinEligibility(Entity entity)
{
    if (CarpetSettings.flippinCactus && (entity instanceof PlayerEntity))
    {
        PlayerEntity player = (PlayerEntity)entity;
        return (!player.getOffHandStack().isEmpty()
                && player.getOffHandStack().getItem() instanceof BlockItem &&
                ((BlockItem) (player.getOffHandStack().getItem())).getBlock() == Blocks.CACTUS);
    }
    return false;
}
 
源代码19 项目: Galacticraft-Rewoven   文件: MoonChunkGenerator.java
public void buildBedrock(Chunk chunk, Random random) {
    BlockPos.Mutable mutable = new BlockPos.Mutable();
    int i = chunk.getPos().getStartX();
    int j = chunk.getPos().getStartZ();
    int k = this.chunkGeneratorType.getBedrockFloorY();
    int l = this.field_24779 - 1 - this.chunkGeneratorType.getBedrockCeilingY();
    boolean bl = l + 4 >= 0 && l < this.field_24779;
    boolean bl2 = k + 4 >= 0 && k < this.field_24779;
    if (bl || bl2) {
        Iterator<BlockPos> var11 = BlockPos.iterate(i, 0, j, i + 15, 0, j + 15).iterator();

        while (true) {
            BlockPos blockPos;
            int o;
            do {
                if (!var11.hasNext()) {
                    return;
                }

                blockPos = var11.next();
                if (bl) {
                    for (o = 0; o < 5; ++o) {
                        if (o <= random.nextInt(5)) {
                            chunk.setBlockState(mutable.set(blockPos.getX(), l - o, blockPos.getZ()), Blocks.BEDROCK.getDefaultState(), false);
                        }
                    }
                }
            } while (!bl2);

            for (o = 4; o >= 0; --o) {
                if (o <= random.nextInt(5)) {
                    chunk.setBlockState(mutable.set(blockPos.getX(), k + o, blockPos.getZ()), Blocks.BEDROCK.getDefaultState(), false);
                }
            }
        }
    }
}
 
源代码20 项目: bleachhack-1.14   文件: NoSlow.java
public void onUpdate() {
	if (this.isToggled()) {
		
		/* Slowness */
		if (getSettings().get(0).toToggle().state && (mc.player.getActivePotionEffect(Effects.SLOWNESS) != null || mc.player.getActivePotionEffect(Effects.BLINDNESS) != null)) {
			if (mc.gameSettings.keyBindForward.isKeyDown() 
					&& mc.player.getMotion().x > -0.15 && mc.player.getMotion().x < 0.15
					&& mc.player.getMotion().z > -0.15 && mc.player.getMotion().z < 0.15) {
				mc.player.setMotion(mc.player.getMotion().add(addMotion));
				addMotion = addMotion.add(new Vec3d(0, 0, 0.05).rotateYaw(-(float)Math.toRadians(mc.player.rotationYaw)));
			} else addMotion = addMotion.scale(0.75);
		}
		
		/* Soul Sand */
		if (getSettings().get(1).toToggle().state && WorldUtils.doesAABBTouchBlock(mc.player.getBoundingBox(), Blocks.SOUL_SAND)) {
			Vec3d m = new Vec3d(0, 0, 0.125).rotateYaw(-(float) Math.toRadians(mc.player.rotationYaw));
			if (!mc.player.abilities.isFlying && mc.gameSettings.keyBindForward.isKeyDown()) {
				mc.player.setMotion(mc.player.getMotion().add(m));
			}
		}
		
		/* Slime Block */
		if (getSettings().get(2).toToggle().state && WorldUtils.doesAABBTouchBlock(mc.player.getBoundingBox().offset(0,-0.02,0), Blocks.SLIME_BLOCK)) {
			Vec3d m1 = new Vec3d(0, 0, 0.1).rotateYaw(-(float) Math.toRadians(mc.player.rotationYaw));
			if (!mc.player.abilities.isFlying && mc.gameSettings.keyBindForward.isKeyDown()) {
				mc.player.setMotion(mc.player.getMotion().add(m1));
			}
		}
		
		/* Web */
		if (getSettings().get(3).toToggle().state && WorldUtils.doesAABBTouchBlock(mc.player.getBoundingBox(), Blocks.COBWEB)) {
			Vec3d m2 = new Vec3d(0, -1, 0.9).rotateYaw(-(float) Math.toRadians(mc.player.rotationYaw));
			if (!mc.player.abilities.isFlying && mc.gameSettings.keyBindForward.isKeyDown()) {
				mc.player.setMotion(mc.player.getMotion().add(m2));
			}
		}
	}
}
 
public DrippingCrudeOilParticle(ClientWorld world, double x, double y, double z, double velX, double velY, double velZ) {
    super(world, x, y, z, velX, velY, velZ);
    setSprite(MinecraftClient.getInstance().getItemRenderer().getModels().getSprite(Blocks.ACACIA_LOG.asItem()));
    this.scale *= 0.25f;
    this.velocityX = 0.0f;
    this.velocityY = -0.6f;
    this.velocityZ = 0.0f;
    this.colorRed = 42f / 255f;
    this.colorGreen = 42f / 255f;
    this.colorBlue = 42f / 255f;
    this.colorAlpha = 229f / 255f;
    this.maxAge = (int) (64.0D / (Math.random() * 0.8D + 0.2D));
}
 
源代码22 项目: Galacticraft-Rewoven   文件: UnlitWallTorchBlock.java
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
    if (player.getStackInHand(hand).getItem() instanceof FlintAndSteelItem) {
        world.setBlockState(pos, Blocks.WALL_TORCH.getDefaultState().with(WallTorchBlock.FACING, state.get(WallTorchBlock.FACING)));
        ItemStack stack = player.getStackInHand(hand).copy();
        stack.damage(1, player, (playerEntity -> {
        }));
        player.setStackInHand(hand, stack);
    }

    return super.onUse(state, world, pos, player, hand, hit);
}
 
@Override
public void onBreak(World world, BlockPos blockPos, BlockState blockState, PlayerEntity playerEntity) {
    super.onBreak(world, blockPos, blockState, playerEntity);
    dropInventory(world, blockPos);

    for (BlockPos otherPart : getOtherParts(blockState, blockPos)) {
        world.setBlockState(otherPart, Blocks.AIR.getDefaultState(), 3);
    }

    super.onBroken(world, blockPos, blockState);
}
 
void onPartDestroyed(World world, BlockState partState, BlockPos partPos, BlockState baseState, BlockPos basePos, boolean dropBase) {
    dropInventory(world, basePos);
    world.breakBlock(basePos, dropBase);

    for (BlockPos otherPart : getOtherParts(baseState, basePos)) {
        if (!world.getBlockState(otherPart).isAir()) {
            world.setBlockState(otherPart, Blocks.AIR.getDefaultState(), 3);
        }
    }
}
 
源代码25 项目: Galacticraft-Rewoven   文件: LivingEntityMixin.java
@Inject(method = "baseTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;tickStatusEffects()V", shift = At.Shift.BEFORE))
private void doOxygenChecks(CallbackInfo ci) {
    LivingEntity entity = (LivingEntity) (Object) this;
    //noinspection ConstantConditions
    if (this.isAlive() && !(entity instanceof PlayerEntity && ((PlayerEntity) entity).abilities.invulnerable)) {
        if (CelestialBodyType.getByDimType(world.getRegistryKey()).isPresent() && !CelestialBodyType.getByDimType(world.getRegistryKey()).get().getAtmosphere().getComposition().containsKey(AtmosphericGas.OXYGEN)) {
            updateAir(this);
        } else {
            if (this.isSubmergedIn(FluidTags.WATER) && this.world.getBlockState(new BlockPos(this.getX(), this.getEyeY(), this.getZ())).getBlock() != Blocks.BUBBLE_COLUMN) {
                if (!this.canBreatheInWater() && !StatusEffectUtil.hasWaterBreathing((LivingEntity) (Object) this) && !isInvulnerableTo(DamageSource.DROWN)) {
                    this.setAir(this.getNextAirUnderwater(this.getAir()));
                }
            }
        }

        if (this.getAir() == -20) {
            this.setAir(0);

            if (this.isSubmergedIn(FluidTags.WATER) && this.world.getBlockState(new BlockPos(this.getX(), this.getEyeY(), this.getZ())).getBlock() != Blocks.BUBBLE_COLUMN) {
                if (!this.canBreatheInWater() && !StatusEffectUtil.hasWaterBreathing((LivingEntity) (Object) this) && !isInvulnerableTo(DamageSource.DROWN)) {
                    Vec3d vec3d = this.getVelocity();

                    for (int i = 0; i < 8; ++i) {
                        float f = this.random.nextFloat() - this.random.nextFloat();
                        float g = this.random.nextFloat() - this.random.nextFloat();
                        float h = this.random.nextFloat() - this.random.nextFloat();
                        this.world.addParticle(ParticleTypes.BUBBLE, this.getX() + (double) f, this.getY() + (double) g, this.getZ() + (double) h, vec3d.x, vec3d.y, vec3d.z);
                    }
                }
            }

            this.damage(GalacticraftDamageSource.SUFFOCATION, 2.0F);
        }
    }
}
 
源代码26 项目: the-hallow   文件: WitchWellFeature.java
public WitchWellFeature(Function<Dynamic<?>, ? extends DefaultFeatureConfig> configDeserializer) {
	super(configDeserializer);
	this.slab = HallowedBlocks.TAINTED_SANDSTONE_SLAB.getDefaultState();
	this.wall = HallowedBlocks.TAINTED_SANDSTONE.getDefaultState();
	this.fluid = HallowedBlocks.WITCH_WATER_BLOCK.getDefaultState();
	this.lantern = Blocks.LANTERN.getDefaultState().with(LanternBlock.HANGING, true);
}
 
源代码27 项目: the-hallow   文件: FeatureUtils.java
default void setSpawner(IWorld world, BlockPos pos, EntityType<?> entity) {
	world.setBlockState(pos, Blocks.SPAWNER.getDefaultState(), 2);
	BlockEntity be = world.getBlockEntity(pos);
	if (be instanceof MobSpawnerBlockEntity) {
		((MobSpawnerBlockEntity) be).getLogic().setEntityId(entity);
	}
}
 
源代码28 项目: bleachhack-1.14   文件: Notebot.java
public boolean isNoteblock(BlockPos pos) {
	/* Checks if this block is a noteblock and the noteblock can be played */
	if (mc.world.getBlockState(pos).getBlock() instanceof NoteBlock) {
           return mc.world.getBlockState(pos.up()).getBlock() == Blocks.AIR;
	}
	return false;
}
 
源代码29 项目: MiningGadgets   文件: RenderBlockTileEntity.java
private void resetBlock() {
    if(world == null)
        return;

    if (!world.isRemote) {
        if (renderBlock != null)
            world.setBlockState(this.pos, renderBlock);
        else
            world.setBlockState(this.pos, Blocks.AIR.getDefaultState());
    }
}
 
/**
 * Returns true if there is a modification making this blockState sticky on the given face. Vanilla stickyness of SLIME_BLOCK is not affected.
 * @param blockState BlockState to determine the stickyness of
 * @param direction Direction in which the stickyness is to be found
 * @return boolean whether block is not SLIME_BLOCK and is sticky in the given direction
 * @author 2No2Name
 */
private boolean isStickyOnSide(BlockState blockState, Direction direction) {
    Block block = blockState.getBlock();
    if(block == Blocks.CHEST || block == Blocks.TRAPPED_CHEST)
        //Make chests be sticky on the side to
        return getDirectionToOtherChestHalf(blockState) == direction;

    //example how you could make sticky pistons have a sticky side:
    //if(block == Blocks.STICKY_PISTON)
    //    return blockState.get(FacingBlock.FACING) == direction.getOpposite();
    return false;
}