net.minecraft.block.Blocks Java Examples

The following examples show how to use net.minecraft.block.Blocks. 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: DispenserBehaviorFireChargeMixin.java    From carpet-extra with GNU Lesser General Public License v3.0 7 votes vote down vote up
@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();
    }
}
 
Example #2
Source File: ClientPlayNetworkHandler_smoothClientAnimationsMixin.java    From fabric-carpet with MIT License 7 votes vote down vote up
@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();
            }
        }
    }
}
 
Example #3
Source File: GameBlockStore.java    From XRay-Mod with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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)));
    }
}
 
Example #4
Source File: LivingEntityMixin.java    From carpet-extra with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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());
    }
}
 
Example #5
Source File: FlowerPotBlockMixin.java    From carpet-extra with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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);
        }
    }
}
 
Example #6
Source File: CarpetDispenserBehaviours.java    From carpet-extra with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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);
}
 
Example #7
Source File: PistonBlockEntity_movableTEMixin.java    From fabric-carpet with MIT License 6 votes vote down vote up
@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);
    }
}
 
Example #8
Source File: SpiderLairFeature.java    From the-hallow with MIT License 6 votes vote down vote up
@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;
	}
}
 
Example #9
Source File: CarpetDispenserBehaviours.java    From carpet-extra with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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);
}
 
Example #10
Source File: DropperBlock_craftingMixin.java    From carpet-extra with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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);
}
 
Example #11
Source File: Protocol_1_11_2.java    From multiconnect with MIT License 6 votes vote down vote up
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);
}
 
Example #12
Source File: Protocol_1_10.java    From multiconnect with MIT License 6 votes vote down vote up
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);
}
 
Example #13
Source File: MoonChunkGenerator.java    From Galacticraft-Rewoven with MIT License 6 votes vote down vote up
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));
}
 
Example #14
Source File: PistonHandler_movableTEMixin.java    From fabric-carpet with MIT License 6 votes vote down vote up
/**
 * 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);
}
 
Example #15
Source File: FarmerVillagerTask_wartFarmMixin.java    From carpet-extra with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Redirect(method = "keepRunning", at = @At(
        value = "INVOKE",
        target = "Lnet/minecraft/server/world/ServerWorld;getBlockState(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/BlockState;",
        ordinal = 0
) )
private BlockState getWartBlockState(ServerWorld serverWorld, BlockPos pos)
{
    BlockState state = serverWorld.getBlockState(pos);
    if (isFarmingCleric && state.getBlock() == Blocks.NETHER_WART && state.get(NetherWartBlock.AGE) == 3)
    {
        return ((CropBlock)Blocks.WHEAT).withAge(((CropBlock)Blocks.WHEAT).getMaxAge());
    }
    return state;
}
 
Example #16
Source File: Protocol_1_14_4.java    From multiconnect with MIT License 5 votes vote down vote up
@Override
public void addExtraBlockTags(TagRegistry<Block> tags) {
    tags.add(BlockTags.TALL_FLOWERS, Blocks.SUNFLOWER, Blocks.LILAC, Blocks.PEONY, Blocks.ROSE_BUSH);
    tags.addTag(BlockTags.FLOWERS, BlockTags.SMALL_FLOWERS);
    tags.addTag(BlockTags.FLOWERS, BlockTags.TALL_FLOWERS);
    tags.add(BlockTags.BEEHIVES);
    tags.add(BlockTags.CROPS, Blocks.BEETROOTS, Blocks.CARROTS, Blocks.POTATOES, Blocks.WHEAT, Blocks.MELON_STEM, Blocks.PUMPKIN_STEM);
    tags.add(BlockTags.BEE_GROWABLES);
    tags.add(BlockTags.SHULKER_BOXES,
            Blocks.SHULKER_BOX,
            Blocks.BLACK_SHULKER_BOX,
            Blocks.BLUE_SHULKER_BOX,
            Blocks.BROWN_SHULKER_BOX,
            Blocks.CYAN_SHULKER_BOX,
            Blocks.GRAY_SHULKER_BOX,
            Blocks.GREEN_SHULKER_BOX,
            Blocks.LIGHT_BLUE_SHULKER_BOX,
            Blocks.LIGHT_GRAY_SHULKER_BOX,
            Blocks.LIME_SHULKER_BOX,
            Blocks.MAGENTA_SHULKER_BOX,
            Blocks.ORANGE_SHULKER_BOX,
            Blocks.PINK_SHULKER_BOX,
            Blocks.PURPLE_SHULKER_BOX,
            Blocks.RED_SHULKER_BOX,
            Blocks.WHITE_SHULKER_BOX,
            Blocks.YELLOW_SHULKER_BOX);
    tags.add(BlockTags.PORTALS, Blocks.NETHER_PORTAL, Blocks.END_PORTAL, Blocks.END_GATEWAY);
    super.addExtraBlockTags(tags);
}
 
Example #17
Source File: SaplingBlockMixin.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Inject(method = "generate", at = @At(value = "INVOKE", shift = At.Shift.BEFORE,
        target = "Lnet/minecraft/block/sapling/SaplingGenerator;generate(Lnet/minecraft/world/IWorld;Lnet/minecraft/world/gen/chunk/ChunkGenerator;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Ljava/util/Random;)Z"),
        cancellable = true)
private void onGenerate(ServerWorld serverWorld_1, BlockPos blockPos_1, BlockState blockState_1, Random random_1, CallbackInfo ci)
{
    if(CarpetSettings.desertShrubs && serverWorld_1.getBiome(blockPos_1) == Biomes.DESERT && !BlockSaplingHelper.hasWater(serverWorld_1, blockPos_1))
    {
        serverWorld_1.setBlockState(blockPos_1, Blocks.DEAD_BUSH.getDefaultState(), 3);
        ci.cancel();
    }
}
 
Example #18
Source File: IForgeBlock.java    From patchwork-api with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Currently only called by fire when it is on top of this block.
 * Returning true will prevent the fire from naturally dying during updating.
 * Also prevents firing from dying from rain.
 *
 * @param state The current state
 * @param world The current world
 * @param pos   Block position in world
 * @param side  The face that the fire is coming from
 * @return True if this block sustains fire, meaning it will never go out.
 */
default boolean isFireSource(BlockState state, BlockView world, BlockPos pos, Direction side) {
	if (side != Direction.UP) {
		return false;
	}

	if (getBlock() == Blocks.NETHERRACK || getBlock() == Blocks.MAGMA_BLOCK) {
		return true;
	}

	return world instanceof CollisionView && ((CollisionView) world).getDimension() instanceof TheEndDimension && getBlock() == Blocks.BEDROCK;
}
 
Example #19
Source File: IPlantable.java    From patchwork-api with GNU Lesser General Public License v2.1 5 votes vote down vote up
default PlantType getPlantType(BlockView world, BlockPos pos) {
	if (this instanceof CropBlock) return PlantType.Crop;
	if (this instanceof SaplingBlock) return PlantType.Plains;
	if (this instanceof FlowerBlock) return PlantType.Plains;
	if (this == Blocks.CACTUS) return PlantType.Desert;
	if (this == Blocks.LILY_PAD) return PlantType.Water;
	if (this == Blocks.RED_MUSHROOM) return PlantType.Cave;
	if (this == Blocks.BROWN_MUSHROOM) return PlantType.Cave;
	if (this == Blocks.NETHER_WART) return PlantType.Nether;
	if (this == Blocks.TALL_GRASS) return PlantType.Plains;
	return net.minecraftforge.common.PlantType.Plains;
}
 
Example #20
Source File: MixinStemBlock.java    From patchwork-api with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Redirect(method = "onScheduledTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;getBlock()Lnet/minecraft/block/Block;"))
private Block redirectSoilCheck(BlockState blockState) {
	if (((IForgeBlockState) blockState).canSustainPlant(currentWorld.get(), currentBlockPos.get().down(), Direction.UP, (IPlantable) this)) {
		return Blocks.DIRT;
	}

	return blockState.getBlock();
}
 
Example #21
Source File: Notebot.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
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;
}
 
Example #22
Source File: NoSlow.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
public void onTick(EventTick event) {
	if (!isToggled()) return;
		
	/* Slowness */
	if (getSettings().get(0).toToggle().state && (mc.player.getStatusEffect(StatusEffects.SLOWNESS) != null || mc.player.getStatusEffect(StatusEffects.BLINDNESS) != null)) {
		if (mc.options.keyForward.isPressed() 
				&& mc.player.getVelocity().x > -0.15 && mc.player.getVelocity().x < 0.15
				&& mc.player.getVelocity().z > -0.15 && mc.player.getVelocity().z < 0.15) {
			mc.player.setVelocity(mc.player.getVelocity().add(addVelocity));
			addVelocity = addVelocity.add(new Vec3d(0, 0, 0.05).rotateY(-(float)Math.toRadians(mc.player.yaw)));
		} else addVelocity = addVelocity.multiply(0.75, 0.75, 0.75);
	}
	
	/* Soul Sand */
	if (getSettings().get(1).toToggle().state && WorldUtils.doesBoxTouchBlock(mc.player.getBoundingBox(), Blocks.SOUL_SAND)) {
		Vec3d m = new Vec3d(0, 0, 0.125).rotateY(-(float) Math.toRadians(mc.player.yaw));
		if (!mc.player.abilities.flying && mc.options.keyForward.isPressed()) {
			mc.player.setVelocity(mc.player.getVelocity().add(m));
		}
	}
	
	/* Slime Block */
	if (getSettings().get(2).toToggle().state && WorldUtils.doesBoxTouchBlock(mc.player.getBoundingBox().offset(0,-0.02,0), Blocks.SLIME_BLOCK)) {
		Vec3d m1 = new Vec3d(0, 0, 0.1).rotateY(-(float) Math.toRadians(mc.player.yaw));
		if (!mc.player.abilities.flying && mc.options.keyForward.isPressed()) {
			mc.player.setVelocity(mc.player.getVelocity().add(m1));
		}
	}
	
	/* Web */
	if (getSettings().get(3).toToggle().state && WorldUtils.doesBoxTouchBlock(mc.player.getBoundingBox(), Blocks.COBWEB)) {
		Vec3d m2 = new Vec3d(0, -1, 0.9).rotateY(-(float) Math.toRadians(mc.player.yaw));
		if (!mc.player.abilities.flying && mc.options.keyForward.isPressed()) {
			mc.player.setVelocity(mc.player.getVelocity().add(m2));
		}
	}
}
 
Example #23
Source File: ExplosionMixin.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Redirect(method = "collectBlocksAndDamageEntities", require = 0, at = @At(value = "INVOKE",
        target ="Lnet/minecraft/world/World;getBlockState(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/BlockState;"))
private BlockState noBlockCalcsWithNoBLockDamage(World world, BlockPos pos)
{
    if (CarpetSettings.explosionNoBlockDamage) return Blocks.BEDROCK.getDefaultState();
    return world.getBlockState(pos);
}
 
Example #24
Source File: FarmerVillagerTask_wartFarmMixin.java    From carpet-extra with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Inject(method = "isSuitableTarget", at = @At("HEAD"), cancellable = true)
private void isValidSoulSand(BlockPos blockPos, ServerWorld serverWorld, CallbackInfoReturnable<Boolean> cir)
{
    if (isFarmingCleric)
    {
        BlockState blockState = serverWorld.getBlockState(blockPos);
        Block block = blockState.getBlock();
        Block block2 = serverWorld.getBlockState(blockPos.down()).getBlock(); // down()
        cir.setReturnValue(
                block == Blocks.NETHER_WART && blockState.get(NetherWartBlock.AGE)== 3 && ableToPickUpSeed ||
                        blockState.isAir() && block2 == Blocks.SOUL_SAND && ableToPlant);

    }
}
 
Example #25
Source File: MixinFlowerPotBlock.java    From multiconnect with MIT License 5 votes vote down vote up
@Inject(method = "onUse", at = @At(value = "FIELD", target = "Lnet/minecraft/block/FlowerPotBlock;content:Lnet/minecraft/block/Block;", ordinal = 0), cancellable = true)
private void cancelEmptyingFlowerPot(CallbackInfoReturnable<ActionResult> ci) {
    // TODO: this doesn't fully work, WTF?!
    if (ConnectionInfo.protocolVersion <= Protocols.V1_10 && content != Blocks.AIR) {
        ci.setReturnValue(ActionResult.CONSUME);
    }
}
 
Example #26
Source File: CoralBlockMixin.java    From fabric-carpet with MIT License 5 votes vote down vote up
public void grow(ServerWorld worldIn, Random random, BlockPos pos, BlockState blockUnder)
{

    CoralFeature coral;
    int variant = random.nextInt(3);
    if (variant == 0)
        coral = new CoralClawFeature(DefaultFeatureConfig::deserialize);
    else if (variant == 1)
        coral = new CoralTreeFeature(DefaultFeatureConfig::deserialize);
    else
        coral = new CoralMushroomFeature(DefaultFeatureConfig::deserialize);

    MaterialColor color = blockUnder.getTopMaterialColor(worldIn, pos);
    BlockState proper_block = blockUnder;
    for (Block block: BlockTags.CORAL_BLOCKS.values())
    {
        proper_block = block.getDefaultState();
        if (proper_block.getTopMaterialColor(worldIn,pos) == color)
        {
            break;
        }
    }
    worldIn.setBlockState(pos, Blocks.WATER.getDefaultState(), 4);

    if (!((CoralFeatureInterface)coral).growSpecific(worldIn, random, pos, proper_block))
    {
        worldIn.setBlockState(pos, blockUnder, 3);
    }
    else
    {
        if (worldIn.random.nextInt(10)==0)
        {
            BlockPos randomPos = pos.add(worldIn.random.nextInt(16)-8,worldIn.random.nextInt(8),worldIn.random.nextInt(16)-8  );
            if (BlockTags.CORAL_BLOCKS.contains(worldIn.getBlockState(randomPos).getBlock()))
            {
                worldIn.setBlockState(randomPos, Blocks.WET_SPONGE.getDefaultState(), 3);
            }
        }
    }
}
 
Example #27
Source File: MoonFloraBlockStateProvider.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
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();
    }
}
 
Example #28
Source File: ObsidianBlock.java    From carpet-extra with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void scheduledTick(BlockState blockState_1, ServerWorld serverWorld_1, BlockPos blockPos_1, Random random_1)
{
    for (Direction dir : Direction.values())
    {
        FluidState neighbor = serverWorld_1.getFluidState(blockPos_1.offset(dir));
        if (neighbor.getFluid() != Fluids.LAVA || !neighbor.isStill())
            return;
    }
    if (random_1.nextInt(10) == 0)
    {
        serverWorld_1.setBlockState(blockPos_1, Blocks.LAVA.getDefaultState());
    }
}
 
Example #29
Source File: Protocol_1_14_4.java    From multiconnect with MIT License 5 votes vote down vote up
@Override
public boolean acceptBlockState(BlockState state) {
    if (state.getBlock() == Blocks.BELL && state.get(BellBlock.POWERED)) // powered
        return false;

    return super.acceptBlockState(state);
}
 
Example #30
Source File: NoSlow.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
public void onTick(EventTick event) {
	if (!isToggled()) return;
		
	/* Slowness */
	if (getSettings().get(0).toToggle().state && (mc.player.getStatusEffect(StatusEffects.SLOWNESS) != null || mc.player.getStatusEffect(StatusEffects.BLINDNESS) != null)) {
		if (mc.options.keyForward.isPressed() 
				&& mc.player.getVelocity().x > -0.15 && mc.player.getVelocity().x < 0.15
				&& mc.player.getVelocity().z > -0.15 && mc.player.getVelocity().z < 0.15) {
			mc.player.setVelocity(mc.player.getVelocity().add(addVelocity));
			addVelocity = addVelocity.add(new Vec3d(0, 0, 0.05).rotateY(-(float)Math.toRadians(mc.player.yaw)));
		} else addVelocity = addVelocity.multiply(0.75, 0.75, 0.75);
	}
	
	/* Soul Sand */
	if (getSettings().get(1).toToggle().state && WorldUtils.doesBoxTouchBlock(mc.player.getBoundingBox(), Blocks.SOUL_SAND)) {
		Vec3d m = new Vec3d(0, 0, 0.125).rotateY(-(float) Math.toRadians(mc.player.yaw));
		if (!mc.player.abilities.flying && mc.options.keyForward.isPressed()) {
			mc.player.setVelocity(mc.player.getVelocity().add(m));
		}
	}
	
	/* Slime Block */
	if (getSettings().get(2).toToggle().state && WorldUtils.doesBoxTouchBlock(mc.player.getBoundingBox().offset(0,-0.02,0), Blocks.SLIME_BLOCK)) {
		Vec3d m1 = new Vec3d(0, 0, 0.1).rotateY(-(float) Math.toRadians(mc.player.yaw));
		if (!mc.player.abilities.flying && mc.options.keyForward.isPressed()) {
			mc.player.setVelocity(mc.player.getVelocity().add(m1));
		}
	}
	
	/* Web */
	if (getSettings().get(3).toToggle().state && WorldUtils.doesBoxTouchBlock(mc.player.getBoundingBox(), Blocks.COBWEB)) {
		Vec3d m2 = new Vec3d(0, -1, 0.9).rotateY(-(float) Math.toRadians(mc.player.yaw));
		if (!mc.player.abilities.flying && mc.options.keyForward.isPressed()) {
			mc.player.setVelocity(mc.player.getVelocity().add(m2));
		}
	}
}