net.minecraft.world.WorldView Java Examples

The following examples show how to use net.minecraft.world.WorldView. 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: RestlessCactusBlock.java    From the-hallow with MIT License 6 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
	Iterator<Direction> iterator = Direction.Type.HORIZONTAL.iterator();
	
	Direction direction;
	Material material;
	do {
		if (!iterator.hasNext()) {
			Block block = world.getBlockState(pos.down()).getBlock();
			return (block == HallowedBlocks.RESTLESS_CACTUS || block == HallowedBlocks.TAINTED_SAND) && !world.getBlockState(pos.up()).getMaterial().isLiquid();
		}
		
		direction = iterator.next();
		BlockState state2 = world.getBlockState(pos.offset(direction));
		material = state2.getMaterial();
	} while (!material.isSolid() && !world.getFluidState(pos.offset(direction)).matches(FluidTags.LAVA));
	
	return false;
}
 
Example #2
Source File: BasicSolarPanelBlock.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
@Override
public boolean canPlaceAt(BlockState blockState_1, WorldView WorldView_1, BlockPos blockPos_1) {
    for (BlockPos otherPart : getOtherParts(blockState_1, blockPos_1)) {
        if (!WorldView_1.getBlockState(otherPart).getMaterial().isReplaceable()) {
            return false;
        }
    }
    return super.canPlaceAt(blockState_1, WorldView_1, blockPos_1);
}
 
Example #3
Source File: AbstractPressurePlateBlock_variableWoodMixin.java    From carpet-extra with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Redirect(method = "updatePlateState", at = @At(
        value = "INVOKE",
        target ="Lnet/minecraft/block/AbstractPressurePlateBlock;getTickRate(Lnet/minecraft/world/WorldView;)I"
))
private int getCustomTickRate(AbstractPressurePlateBlock abstractPressurePlateBlock, WorldView viewableWorld_1,
                              World world_1, BlockPos blockPos_1, BlockState blockState_1, int int_1)
{
    if (!CarpetExtraSettings.variableWoodDelays)
    {
        return abstractPressurePlateBlock.getTickRate(viewableWorld_1);
    }
    return WoodDelayMultipliers.getForDelay(blockState_1.getBlock(), abstractPressurePlateBlock.getTickRate(viewableWorld_1));
}
 
Example #4
Source File: AbstractButtonBlock_variableWoodMixin.java    From carpet-extra with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Redirect(method = "method_21845", at = @At(
        value = "INVOKE",
        target = "Lnet/minecraft/block/AbstractButtonBlock;getTickRate(Lnet/minecraft/world/WorldView;)I"
))
private int getCustomTickRate(AbstractButtonBlock abstractButtonBlock, WorldView viewableWorld_1,
                              BlockState blockState_1, World world_1, BlockPos blockPos_1)
{
    if (!CarpetExtraSettings.variableWoodDelays)
    {
        return abstractButtonBlock.getTickRate(viewableWorld_1);
    }
    return WoodDelayMultipliers.getForDelay(blockState_1.getBlock(), abstractButtonBlock.getTickRate(viewableWorld_1));
}
 
Example #5
Source File: HallowedMushroomPlantBlock.java    From the-hallow with MIT License 5 votes vote down vote up
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
	if (super.canPlaceAt(state, world, pos)) return true;
	BlockPos downPos = pos.down();
	BlockState downState = world.getBlockState(downPos);
	Block downBlock = downState.getBlock();
	return (downBlock == HallowedBlocks.DECEASED_GRASS_BLOCK || downBlock == HallowedBlocks.DECEASED_DIRT || downBlock == HallowedBlocks.DECEASED_MOSS);
}
 
Example #6
Source File: EatBreadcrumbsGoal.java    From the-hallow with MIT License 5 votes vote down vote up
@Override
protected boolean isTargetPos(WorldView world, BlockPos pos) {
	Chunk chunk1 = world.getChunk(pos.getX() >> 4, pos.getZ() >> 4, ChunkStatus.FULL, false);
	if (chunk1 == null) {
		return false;
	} else {
		return chunk1.getBlockState(pos).getBlock() == this.targetBlock && chunk1.getBlockState(pos.up()).isAir() && chunk1.getBlockState(pos.up(2)).isAir();
	}
}
 
Example #7
Source File: CavernousVineBlock.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
@Override
public boolean canPlaceAt(BlockState state, WorldView WorldView, BlockPos pos) {
    BlockPos pos2 = pos;
    BlockPos pos3 = pos;
    pos2 = pos2.add(0, -1, 0);
    pos3 = pos3.add(0, 1, 0);
    //If it isn't on the ground and it is below a block
    return (!WorldView.getBlockState(pos3).getBlock().equals(Blocks.AIR))
            && (WorldView.getBlockState(pos2).getBlock().equals(Blocks.AIR)
            || WorldView.getBlockState(pos2).getBlock().equals(GalacticraftBlocks.CAVERNOUS_VINE)
            || WorldView.getBlockState(pos2).getBlock().equals(GalacticraftBlocks.POISONOUS_CAVERNOUS_VINE));
}
 
Example #8
Source File: WitchWaterBubbleColumnBlock.java    From the-hallow with MIT License 4 votes vote down vote up
@Override
public int getTickRate(WorldView world) {
	return 5;
}
 
Example #9
Source File: MixinBaseFluid.java    From Sandbox with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Shadow
protected abstract FluidState getUpdatedState(WorldView viewableWorld_1, BlockPos blockPos_1, BlockState blockState_1);
 
Example #10
Source File: FluidWrapper.java    From Sandbox with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public int getTickRate(WorldView var1) {
    return fluid.getTickRate((WorldReader) var1);
}
 
Example #11
Source File: FluidWrapper.java    From Sandbox with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
protected int getLevelDecreasePerBlock(WorldView var1) {
    return 1;
}
 
Example #12
Source File: FluidWrapper.java    From Sandbox with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
protected int method_15733(WorldView var1) {
    return 4;
}
 
Example #13
Source File: CrudeOilFluid.java    From Galacticraft-Rewoven with MIT License 4 votes vote down vote up
@Override
public int getTickRate(WorldView WorldView) {
    return 7;
}
 
Example #14
Source File: DeceasedGrassBlock.java    From the-hallow with MIT License 4 votes vote down vote up
private static boolean canSpread(BlockState blockState, WorldView viewableWorld, BlockPos blockPos) {
	BlockPos upPos = blockPos.up();
	return canSurvive(blockState, viewableWorld, blockPos) && !viewableWorld.getFluidState(upPos).matches(FluidTags.WATER);
}
 
Example #15
Source File: DeceasedGrassBlock.java    From the-hallow with MIT License 4 votes vote down vote up
private static boolean canSurvive(BlockState blockState, WorldView viewableWorld, BlockPos blockPos) {
	BlockPos upPos = blockPos.up();
	BlockState upBlockState = viewableWorld.getBlockState(upPos);
	int lightLevel = ChunkLightProvider.getRealisticOpacity(viewableWorld, blockState, blockPos, upBlockState, upPos, Direction.UP, upBlockState.getOpacity(viewableWorld, upPos));
	return lightLevel < viewableWorld.getMaxLightLevel();
}
 
Example #16
Source File: TombstoneBlock.java    From the-hallow with MIT License 4 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
	BlockPos down = pos.down();
	return Block.isFaceFullSquare(world.getBlockState(down).getCollisionShape(world, down), Direction.UP);
}
 
Example #17
Source File: CrudeOilFluid.java    From Galacticraft-Rewoven with MIT License 4 votes vote down vote up
@Override
protected int getFlowSpeed(WorldView world) {
    return 4;
}
 
Example #18
Source File: CoarseTaintedSandBlock.java    From the-hallow with MIT License 4 votes vote down vote up
@Override
public int getTickRate(WorldView viewableworld) {
	return 2;
}
 
Example #19
Source File: BreadCrumbsBlock.java    From the-hallow with MIT License 4 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
	BlockPos down = pos.down();
	return Block.isFaceFullSquare(world.getBlockState(down).getCollisionShape(world, down), Direction.UP);
}
 
Example #20
Source File: WitchWaterBubbleColumnBlock.java    From the-hallow with MIT License 4 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
	Block block = world.getBlockState(pos.down()).getBlock();
	return block == HallowedBlocks.WITCH_WATER_BUBBLE_COLUMN || block == HallowedBlocks.BLEEDING_BLOCK || block == HallowedBlocks.COARSE_TAINTED_SAND;
}
 
Example #21
Source File: FuelFluid.java    From Galacticraft-Rewoven with MIT License 4 votes vote down vote up
@Override
public int getFlowSpeed(WorldView WorldView) {
    return 4;
}
 
Example #22
Source File: BleedingBlock.java    From the-hallow with MIT License 4 votes vote down vote up
@Override
public int getTickRate(WorldView viewableworld) {
	return 20;
}
 
Example #23
Source File: PumpkinPieBlock.java    From the-hallow with MIT License 4 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
	return world.getBlockState(pos.down()).getMaterial().isSolid();
}
 
Example #24
Source File: CrudeOilFluid.java    From Galacticraft-Rewoven with MIT License 4 votes vote down vote up
@Override
public int getLevelDecreasePerBlock(WorldView WorldView) {
    return 1;
}
 
Example #25
Source File: BloodFluid.java    From the-hallow with MIT License 4 votes vote down vote up
@Override
public int getLevelDecreasePerBlock(WorldView viewableWorld) {
	return 1;
}
 
Example #26
Source File: BloodFluid.java    From the-hallow with MIT License 4 votes vote down vote up
@Override
public int method_15733(WorldView viewableWorld) {
	return 4;
}
 
Example #27
Source File: BloodFluid.java    From the-hallow with MIT License 4 votes vote down vote up
@Override
public int getTickRate(WorldView viewableWorld) {
	return 10;
}
 
Example #28
Source File: WitchWaterFluid.java    From the-hallow with MIT License 4 votes vote down vote up
@Override
public int getLevelDecreasePerBlock(WorldView viewableWorld) {
	return 1;
}
 
Example #29
Source File: WitchWaterFluid.java    From the-hallow with MIT License 4 votes vote down vote up
@Override
public int method_15733(WorldView viewableWorld) {
	return 4;
}
 
Example #30
Source File: WitchWaterFluid.java    From the-hallow with MIT License 4 votes vote down vote up
@Override
public int getTickRate(WorldView viewableWorld) {
	return 5;
}