[Change] Added BehaviourBuilders
to replace the deprecated Block-Material
System
This commit is contained in:
parent
e656bce991
commit
4a74a44422
20 changed files with 144 additions and 95 deletions
|
@ -233,7 +233,7 @@ public class StructureWorldNBT extends StructureNBT {
|
|||
POS.setY(y);
|
||||
for (int z = start.getZ(); z <= end.getZ(); z++) {
|
||||
POS.setZ(z);
|
||||
if (world.getBlockState(POS).getMaterial().isReplaceable())
|
||||
if (world.getBlockState(POS).canBeReplaced())
|
||||
airCount++;
|
||||
count++;
|
||||
}
|
||||
|
@ -263,7 +263,7 @@ public class StructureWorldNBT extends StructureNBT {
|
|||
POS.setY(y);
|
||||
for (int z = start.getZ(); z <= end.getZ(); z++) {
|
||||
POS.setZ(z);
|
||||
if (world.getBlockState(POS).getMaterial().isReplaceable())
|
||||
if (world.getBlockState(POS).canBeReplaced())
|
||||
airCount++;
|
||||
count++;
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ public abstract class TemplateStructure extends Structure {
|
|||
}
|
||||
|
||||
protected boolean isFloorPlaceable(BlockState state, BlockState before) {
|
||||
return (state == null || state.is(Blocks.AIR)) && before.getMaterial().isSolid();
|
||||
return (state == null || state.is(Blocks.AIR)) && before.isSolid();
|
||||
}
|
||||
|
||||
protected int erosion(RandomSource rnd) {
|
||||
|
@ -219,7 +219,7 @@ public abstract class TemplateStructure extends Structure {
|
|||
int airCount = 0;
|
||||
for (int i = y; i < y + height && i > y - height; i += searchStep) {
|
||||
BlockState state = column.getBlock(i);
|
||||
if (state.isAir() || state.getMaterial().isReplaceable()) {
|
||||
if (state.isAir() || state.canBeReplaced()) {
|
||||
airCount++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ import net.minecraft.world.level.levelgen.blockpredicates.BlockPredicate;
|
|||
import net.minecraft.world.level.levelgen.feature.Feature;
|
||||
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
|
||||
import net.minecraft.world.level.levelgen.placement.*;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
@ -278,7 +277,7 @@ abstract class CommonPlacedFeatureBuilder<F extends Feature<FC>, FC extends Feat
|
|||
|
||||
/**
|
||||
* Cast a ray with max {@code distance} length to find the next solid Block. The ray will travel through replaceable
|
||||
* Blocks (see {@link Material#isReplaceable()}) and will be accepted if it hits a block with the
|
||||
* Blocks and will be accepted if it hits a block with the
|
||||
* {@link CommonBlockTags#TERRAIN}-tag
|
||||
*
|
||||
* @param dir The direction the ray is cast
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.betterx.bclib.blocks;
|
||||
|
||||
import org.betterx.bclib.client.render.BCLRenderLayer;
|
||||
import org.betterx.bclib.complexmaterials.BehaviourBuilders;
|
||||
import org.betterx.bclib.interfaces.RenderLayerProvider;
|
||||
import org.betterx.bclib.items.tool.BaseShearsItem;
|
||||
import org.betterx.bclib.util.BlocksHelper;
|
||||
|
@ -27,7 +28,6 @@ import net.minecraft.world.level.block.state.BlockState;
|
|||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||
import net.minecraft.world.level.block.state.properties.IntegerProperty;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
@ -45,19 +45,19 @@ public abstract class BaseDoublePlantBlock extends BaseBlockNotFull implements R
|
|||
|
||||
public BaseDoublePlantBlock() {
|
||||
this(
|
||||
Properties.of(Material.PLANT)
|
||||
BehaviourBuilders
|
||||
.createPlant()
|
||||
.sound(SoundType.GRASS)
|
||||
.noCollission()
|
||||
.offsetType(BlockBehaviour.OffsetType.NONE)
|
||||
);
|
||||
}
|
||||
|
||||
public BaseDoublePlantBlock(int light) {
|
||||
this(
|
||||
Properties.of(Material.PLANT)
|
||||
BehaviourBuilders
|
||||
.createPlant()
|
||||
.sound(SoundType.GRASS)
|
||||
.lightLevel((state) -> state.getValue(TOP) ? light : 0)
|
||||
.noCollission()
|
||||
.offsetType(BlockBehaviour.OffsetType.NONE)
|
||||
);
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ public abstract class BaseDoublePlantBlock extends BaseBlockNotFull implements R
|
|||
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
|
||||
BlockState down = world.getBlockState(pos.below());
|
||||
BlockState up = world.getBlockState(pos.above());
|
||||
return state.getValue(TOP) ? down.getBlock() == this : isTerrain(down) && (up.getMaterial().isReplaceable());
|
||||
return state.getValue(TOP) ? down.getBlock() == this : isTerrain(down) && (up.canBeReplaced());
|
||||
}
|
||||
|
||||
public boolean canStayAt(BlockState state, LevelReader world, BlockPos pos) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.betterx.bclib.blocks;
|
||||
|
||||
import org.betterx.bclib.complexmaterials.BehaviourBuilders;
|
||||
import org.betterx.bclib.interfaces.BlockModelProvider;
|
||||
import org.betterx.bclib.interfaces.TagProvider;
|
||||
import org.betterx.bclib.util.LootUtil;
|
||||
|
@ -25,7 +26,6 @@ import net.minecraft.world.level.block.DropExperienceBlock;
|
|||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
|
||||
|
@ -45,8 +45,8 @@ public class BaseOreBlock extends DropExperienceBlock implements BlockModelProvi
|
|||
|
||||
public BaseOreBlock(Supplier<Item> drop, int minCount, int maxCount, int experience, int miningLevel) {
|
||||
this(
|
||||
Properties
|
||||
.of(Material.STONE, MapColor.SAND)
|
||||
BehaviourBuilders
|
||||
.createStone(MapColor.SAND)
|
||||
.requiresCorrectToolForDrops()
|
||||
.destroyTime(3F)
|
||||
.explosionResistance(9F)
|
||||
|
|
|
@ -4,6 +4,7 @@ import org.betterx.bclib.client.models.BasePatterns;
|
|||
import org.betterx.bclib.client.models.ModelsHelper;
|
||||
import org.betterx.bclib.client.models.PatternsHelper;
|
||||
import org.betterx.bclib.client.render.BCLRenderLayer;
|
||||
import org.betterx.bclib.complexmaterials.BehaviourBuilders;
|
||||
import org.betterx.bclib.interfaces.RenderLayerProvider;
|
||||
import org.betterx.bclib.interfaces.SettingsExtender;
|
||||
import org.betterx.bclib.items.tool.BaseShearsItem;
|
||||
|
@ -27,7 +28,6 @@ import net.minecraft.world.level.block.BonemealableBlock;
|
|||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
@ -57,12 +57,13 @@ public abstract class BasePlantBlock extends BaseBlockNotFull implements RenderL
|
|||
}
|
||||
|
||||
public static Properties basePlantSettings(boolean replaceable, int light) {
|
||||
return basePlantSettings(replaceable ? Material.REPLACEABLE_PLANT : Material.PLANT, light);
|
||||
return basePlantSettings(replaceable
|
||||
? BehaviourBuilders.createReplaceablePlant()
|
||||
: BehaviourBuilders.createPlant(), light);
|
||||
}
|
||||
|
||||
public static Properties basePlantSettings(Material mat, int light) {
|
||||
Properties props = Properties
|
||||
.of(mat)
|
||||
public static Properties basePlantSettings(BlockBehaviour.Properties props, int light) {
|
||||
props
|
||||
.sound(SoundType.GRASS)
|
||||
.noCollission()
|
||||
.offsetType(BlockBehaviour.OffsetType.XZ);
|
||||
|
@ -102,11 +103,13 @@ public abstract class BasePlantBlock extends BaseBlockNotFull implements RenderL
|
|||
@Deprecated(forRemoval = true)
|
||||
public BasePlantBlock(boolean replaceable, int light, SettingsExtender propMod) {
|
||||
this(
|
||||
propMod.amend(Properties
|
||||
.of(replaceable ? Material.REPLACEABLE_PLANT : Material.PLANT)
|
||||
propMod.amend(
|
||||
(replaceable
|
||||
? BehaviourBuilders.createReplaceablePlant()
|
||||
: BehaviourBuilders.createPlant()
|
||||
)
|
||||
.lightLevel((state) -> light)
|
||||
.sound(SoundType.GRASS)
|
||||
.noCollission()
|
||||
.offsetType(BlockBehaviour.OffsetType.XZ)
|
||||
)
|
||||
);
|
||||
|
|
|
@ -122,9 +122,9 @@ public class BaseSignBlock extends SignBlock implements BlockModelProvider, Cust
|
|||
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
|
||||
if (!state.getValue(FLOOR)) {
|
||||
int index = (((state.getValue(ROTATION) >> 2) + 2)) & 3;
|
||||
return world.getBlockState(pos.relative(BlocksHelper.HORIZONTAL[index])).getMaterial().isSolid();
|
||||
return world.getBlockState(pos.relative(BlocksHelper.HORIZONTAL[index])).isSolid();
|
||||
} else {
|
||||
return world.getBlockState(pos.below()).getMaterial().isSolid();
|
||||
return world.getBlockState(pos.below()).isSolid();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.betterx.bclib.blocks;
|
|||
|
||||
import org.betterx.bclib.blocks.BlockProperties.TripleShape;
|
||||
import org.betterx.bclib.client.render.BCLRenderLayer;
|
||||
import org.betterx.bclib.complexmaterials.BehaviourBuilders;
|
||||
import org.betterx.bclib.interfaces.RenderLayerProvider;
|
||||
import org.betterx.bclib.items.tool.BaseShearsItem;
|
||||
import org.betterx.bclib.util.BlocksHelper;
|
||||
|
@ -26,7 +27,6 @@ import net.minecraft.world.level.block.state.BlockBehaviour;
|
|||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.EnumProperty;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
@ -57,13 +57,14 @@ public class BaseVineBlock extends BaseBlockNotFull implements RenderLayerProvid
|
|||
|
||||
public BaseVineBlock(int light, boolean bottomOnly, Function<Properties, Properties> propMod) {
|
||||
this(
|
||||
propMod.apply(Properties
|
||||
.of(Material.PLANT)
|
||||
propMod.apply(BehaviourBuilders
|
||||
.createPlant()
|
||||
.sound(SoundType.GRASS)
|
||||
.lightLevel((state) -> bottomOnly ? state.getValue(SHAPE) == TripleShape.BOTTOM
|
||||
.lightLevel((state) -> bottomOnly
|
||||
? state.getValue(SHAPE) == TripleShape.BOTTOM
|
||||
? light
|
||||
: 0 : light)
|
||||
.noCollission()
|
||||
: 0
|
||||
: light)
|
||||
.offsetType(BlockBehaviour.OffsetType.XZ))
|
||||
);
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ public abstract class BaseWallPlantBlock extends BasePlantBlock {
|
|||
}
|
||||
|
||||
public boolean isSupport(LevelReader world, BlockPos pos, BlockState blockState, Direction direction) {
|
||||
return blockState.getMaterial().isSolid() && blockState.isFaceSturdy(world, pos, direction);
|
||||
return blockState.isSolid() && blockState.isFaceSturdy(world, pos, direction);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -5,6 +5,7 @@ import org.betterx.bclib.client.models.BasePatterns;
|
|||
import org.betterx.bclib.client.models.ModelsHelper;
|
||||
import org.betterx.bclib.client.models.PatternsHelper;
|
||||
import org.betterx.bclib.client.render.BCLRenderLayer;
|
||||
import org.betterx.bclib.complexmaterials.BehaviourBuilders;
|
||||
import org.betterx.bclib.interfaces.BlockModelProvider;
|
||||
import org.betterx.bclib.interfaces.RenderLayerProvider;
|
||||
|
||||
|
@ -26,7 +27,6 @@ import net.minecraft.world.level.block.state.BlockBehaviour;
|
|||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.levelgen.feature.Feature;
|
||||
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
@ -51,23 +51,17 @@ public class FeatureSaplingBlock<F extends Feature<FC>, FC extends FeatureConfig
|
|||
|
||||
public FeatureSaplingBlock(FeatureSupplier<F, FC> featureSupplier) {
|
||||
this(
|
||||
BlockBehaviour.Properties.of(Material.PLANT)
|
||||
.noCollission()
|
||||
.instabreak()
|
||||
.sound(SoundType.GRASS)
|
||||
.randomTicks(),
|
||||
BehaviourBuilders.createTickingPlant()
|
||||
.sound(SoundType.GRASS),
|
||||
featureSupplier
|
||||
);
|
||||
}
|
||||
|
||||
public FeatureSaplingBlock(int light, FeatureSupplier<F, FC> featureSupplier) {
|
||||
this(
|
||||
BlockBehaviour.Properties.of(Material.PLANT)
|
||||
.noCollission()
|
||||
BehaviourBuilders.createTickingPlant()
|
||||
.lightLevel(state -> light)
|
||||
.instabreak()
|
||||
.sound(SoundType.GRASS)
|
||||
.randomTicks(),
|
||||
.sound(SoundType.GRASS),
|
||||
featureSupplier
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.betterx.bclib.blocks;
|
||||
|
||||
import org.betterx.bclib.client.render.BCLRenderLayer;
|
||||
import org.betterx.bclib.complexmaterials.BehaviourBuilders;
|
||||
import org.betterx.bclib.interfaces.RenderLayerProvider;
|
||||
import org.betterx.bclib.interfaces.TagProvider;
|
||||
import org.betterx.bclib.interfaces.tools.AddMineableHoe;
|
||||
|
@ -14,37 +15,24 @@ import net.minecraft.world.level.block.Block;
|
|||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SimpleLeavesBlock extends BaseBlockNotFull implements RenderLayerProvider, TagProvider, AddMineableShears, AddMineableHoe {
|
||||
public SimpleLeavesBlock(MapColor color) {
|
||||
this(
|
||||
Properties
|
||||
.of(Material.LEAVES)
|
||||
.strength(0.2F)
|
||||
.color(color)
|
||||
BehaviourBuilders
|
||||
.createLeaves(color)
|
||||
.sound(SoundType.GRASS)
|
||||
.noOcclusion()
|
||||
.isValidSpawn((state, world, pos, type) -> false)
|
||||
.isSuffocating((state, world, pos) -> false)
|
||||
.isViewBlocking((state, world, pos) -> false)
|
||||
);
|
||||
}
|
||||
|
||||
public SimpleLeavesBlock(MapColor color, int light) {
|
||||
this(
|
||||
Properties
|
||||
.of(Material.LEAVES)
|
||||
BehaviourBuilders
|
||||
.createLeaves(color)
|
||||
.lightLevel(ignored -> light)
|
||||
.color(color)
|
||||
.strength(0.2F)
|
||||
.sound(SoundType.GRASS)
|
||||
.noOcclusion()
|
||||
.isValidSpawn((state, world, pos, type) -> false)
|
||||
.isSuffocating((state, world, pos) -> false)
|
||||
.isViewBlocking((state, world, pos) -> false)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.betterx.bclib.blocks;
|
||||
|
||||
import org.betterx.bclib.client.render.BCLRenderLayer;
|
||||
import org.betterx.bclib.complexmaterials.BehaviourBuilders;
|
||||
import org.betterx.bclib.interfaces.RenderLayerProvider;
|
||||
import org.betterx.bclib.items.tool.BaseShearsItem;
|
||||
|
||||
|
@ -25,15 +26,12 @@ import net.minecraft.world.level.block.state.BlockState;
|
|||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -54,14 +52,13 @@ public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements R
|
|||
|
||||
public static Properties baseUnderwaterPlantSettings(boolean replaceable, int light) {
|
||||
return baseUnderwaterPlantSettings(
|
||||
replaceable ? Material.REPLACEABLE_WATER_PLANT : Material.WATER_PLANT,
|
||||
replaceable ? BehaviourBuilders.createReplaceableWaterPlant() : BehaviourBuilders.createWaterPlant(),
|
||||
light
|
||||
);
|
||||
}
|
||||
|
||||
public static Properties baseUnderwaterPlantSettings(Material mat, int light) {
|
||||
Properties props = FabricBlockSettings
|
||||
.of(mat)
|
||||
public static Properties baseUnderwaterPlantSettings(BlockBehaviour.Properties props, int light) {
|
||||
props
|
||||
.sound(SoundType.WET_GRASS)
|
||||
.noCollission()
|
||||
.offsetType(BlockBehaviour.OffsetType.XZ);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.betterx.bclib.blocks;
|
||||
|
||||
import org.betterx.bclib.client.render.BCLRenderLayer;
|
||||
import org.betterx.bclib.complexmaterials.BehaviourBuilders;
|
||||
import org.betterx.bclib.interfaces.RenderLayerProvider;
|
||||
import org.betterx.bclib.interfaces.tools.AddMineableHoe;
|
||||
import org.betterx.bclib.interfaces.tools.AddMineableShears;
|
||||
|
@ -21,13 +22,11 @@ import net.minecraft.world.level.block.SoundType;
|
|||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -36,10 +35,9 @@ public abstract class UpDownPlantBlock extends BaseBlockNotFull implements Rende
|
|||
private static final VoxelShape SHAPE = box(4, 0, 4, 12, 16, 12);
|
||||
|
||||
public UpDownPlantBlock() {
|
||||
this(Properties
|
||||
.of(Material.PLANT)
|
||||
this(BehaviourBuilders
|
||||
.createPlant()
|
||||
.sound(SoundType.GRASS)
|
||||
.noCollission()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,6 @@ public abstract class WallMushroomBlock extends BaseWallPlantBlock {
|
|||
|
||||
@Override
|
||||
public boolean isSupport(LevelReader world, BlockPos pos, BlockState blockState, Direction direction) {
|
||||
return blockState.getMaterial().isSolid() && blockState.isFaceSturdy(world, pos, direction);
|
||||
return blockState.isSolid() && blockState.isFaceSturdy(world, pos, direction);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
package org.betterx.bclib.complexmaterials;
|
||||
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraft.world.level.material.PushReaction;
|
||||
|
||||
public class BehaviourBuilders {
|
||||
public static BlockBehaviour.Properties createPlant() {
|
||||
return BlockBehaviour.Properties.of()
|
||||
.mapColor(MapColor.PLANT)
|
||||
.noCollission()
|
||||
.instabreak()
|
||||
.pushReaction(PushReaction.DESTROY);
|
||||
}
|
||||
|
||||
public static BlockBehaviour.Properties createTickingPlant() {
|
||||
return createPlant().randomTicks();
|
||||
}
|
||||
|
||||
public static BlockBehaviour.Properties createReplaceablePlant() {
|
||||
return createPlant().replaceable();
|
||||
}
|
||||
|
||||
public static BlockBehaviour.Properties createWaterPlant() {
|
||||
return BlockBehaviour.Properties.of()
|
||||
.mapColor(MapColor.WATER)
|
||||
.noCollission()
|
||||
.instabreak()
|
||||
.pushReaction(PushReaction.DESTROY);
|
||||
}
|
||||
|
||||
public static BlockBehaviour.Properties createReplaceableWaterPlant() {
|
||||
return createWaterPlant().replaceable();
|
||||
}
|
||||
|
||||
public static BlockBehaviour.Properties createLeaves() {
|
||||
return createLeaves(MapColor.PLANT);
|
||||
}
|
||||
|
||||
public static BlockBehaviour.Properties createLeaves(MapColor color) {
|
||||
return BlockBehaviour.Properties.of()
|
||||
.mapColor(color)
|
||||
.strength(0.2f)
|
||||
.randomTicks()
|
||||
.noOcclusion()
|
||||
.isValidSpawn(Blocks::ocelotOrParrot)
|
||||
.isSuffocating(Blocks::never)
|
||||
.isViewBlocking(Blocks::never)
|
||||
.ignitedByLava()
|
||||
.pushReaction(PushReaction.DESTROY)
|
||||
.isRedstoneConductor(Blocks::never);
|
||||
}
|
||||
|
||||
public static BlockBehaviour.Properties createStone() {
|
||||
return createStone(MapColor.STONE);
|
||||
}
|
||||
|
||||
public static BlockBehaviour.Properties createStone(MapColor color) {
|
||||
return BlockBehaviour.Properties.of()
|
||||
.mapColor(color)
|
||||
.instrument(NoteBlockInstrument.BASEDRUM);
|
||||
}
|
||||
}
|
|
@ -43,7 +43,7 @@ public class BlockRegistry extends BaseRegistry<Block> {
|
|||
|
||||
}
|
||||
registerBlockItem(id, item);
|
||||
if (block.defaultBlockState().getMaterial().isFlammable()
|
||||
if (block.defaultBlockState().ignitedByLava()
|
||||
&& FlammableBlockRegistry.getDefaultInstance()
|
||||
.get(block)
|
||||
.getBurnChance() == 0) {
|
||||
|
|
|
@ -20,7 +20,7 @@ import java.util.function.Function;
|
|||
public abstract class SDF {
|
||||
private final List<Function<PosInfo, BlockState>> postProcesses = Lists.newArrayList();
|
||||
private Function<BlockState, Boolean> canReplace = (state) -> {
|
||||
return state.getMaterial().isReplaceable();
|
||||
return state.canBeReplaced();
|
||||
};
|
||||
|
||||
public abstract float getDistance(float x, float y, float z);
|
||||
|
|
|
@ -85,7 +85,7 @@ public class BlocksHelper {
|
|||
public static int downRayRep(LevelAccessor world, BlockPos pos, int maxDist) {
|
||||
final MutableBlockPos POS = TL_POS.get();
|
||||
POS.set(pos);
|
||||
for (int j = 1; j < maxDist && (world.getBlockState(POS)).getMaterial().isReplaceable(); j++) {
|
||||
for (int j = 1; j < maxDist && (world.getBlockState(POS)).canBeReplaced(); j++) {
|
||||
POS.setY(POS.getY() - 1);
|
||||
}
|
||||
return pos.getY() - POS.getY();
|
||||
|
@ -94,7 +94,7 @@ public class BlocksHelper {
|
|||
public static int raycastSqr(LevelAccessor world, BlockPos pos, int dx, int dy, int dz, int maxDist) {
|
||||
final MutableBlockPos POS = TL_POS.get();
|
||||
POS.set(pos);
|
||||
for (int j = 1; j < maxDist && (world.getBlockState(POS)).getMaterial().isReplaceable(); j++) {
|
||||
for (int j = 1; j < maxDist && (world.getBlockState(POS)).canBeReplaced(); j++) {
|
||||
POS.move(dx, dy, dz);
|
||||
}
|
||||
return (int) pos.distSqr(POS);
|
||||
|
@ -326,7 +326,7 @@ public class BlocksHelper {
|
|||
}
|
||||
|
||||
public static boolean isFluid(BlockState state) {
|
||||
return state.getMaterial().isLiquid();
|
||||
return state.liquid();
|
||||
}
|
||||
|
||||
public static boolean isFree(BlockState state) {
|
||||
|
@ -334,7 +334,7 @@ public class BlocksHelper {
|
|||
}
|
||||
|
||||
public static boolean isFreeOrReplaceable(BlockState state) {
|
||||
return state.isAir() || state.getMaterial().isReplaceable();
|
||||
return state.isAir() || state.canBeReplaced();
|
||||
}
|
||||
|
||||
public static boolean isFreeOrFluid(BlockState state) {
|
||||
|
|
|
@ -11,8 +11,8 @@ import net.minecraft.util.RandomSource;
|
|||
import net.minecraft.world.level.WorldGenLevel;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
|
||||
import net.minecraft.world.level.levelgen.structure.BoundingBox;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
|
@ -149,7 +149,7 @@ public class StructureErode {
|
|||
int px = MHelper.floor(random.nextGaussian() * 2 + x + 0.5);
|
||||
int pz = MHelper.floor(random.nextGaussian() * 2 + z + 0.5);
|
||||
mut2.set(px, y, pz);
|
||||
while (world.getBlockState(mut2).getMaterial().isReplaceable() && mut2.getY() > minY) {
|
||||
while (world.getBlockState(mut2).canBeReplaced() && mut2.getY() > minY) {
|
||||
mut2.setY(mut2.getY() - 1);
|
||||
}
|
||||
if (!world.getBlockState(mut2).isAir() && state.canSurvive(world, mut2)) {
|
||||
|
@ -225,7 +225,7 @@ public class StructureErode {
|
|||
BlockState state = world.getBlockState(mut);
|
||||
if (!ignore(state, world, mut) && !blocks.contains(mut)) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, Blocks.AIR);
|
||||
while (world.getBlockState(mut).getMaterial().isReplaceable() && mut.getY() > minY) {
|
||||
while (world.getBlockState(mut).canBeReplaced() && mut.getY() > minY) {
|
||||
mut.setY(mut.getY() - 1);
|
||||
}
|
||||
if (mut.getY() > minY) {
|
||||
|
@ -242,7 +242,10 @@ public class StructureErode {
|
|||
if (state.is(CommonBlockTags.GEN_END_STONES) || state.is(BlockTags.NYLIUM)) {
|
||||
return true;
|
||||
}
|
||||
return !state.getMaterial().equals(Material.STONE) || BlocksHelper.isInvulnerable(state, world, pos);
|
||||
|
||||
//NoteBlockInstrument.BASEDRUM this is basically what Material.STONE was previously
|
||||
return !state.instrument().equals(NoteBlockInstrument.BASEDRUM)
|
||||
|| BlocksHelper.isInvulnerable(state, world, pos);
|
||||
}
|
||||
|
||||
private static boolean isTerrainNear(WorldGenLevel world, BlockPos pos) {
|
||||
|
@ -266,8 +269,7 @@ public class StructureErode {
|
|||
mut.setY(y);
|
||||
BlockState state = world.getBlockState(mut);
|
||||
if (state.is(CommonBlockTags.TERRAIN) && !world.getBlockState(mut.above())
|
||||
.getMaterial()
|
||||
.isSolidBlocking()) {
|
||||
.isSolid()) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, top);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,9 @@ accessible method net/minecraft/world/level/levelgen/NoiseRouterData noNewCaves
|
|||
accessible method net/minecraft/world/level/levelgen/NoiseRouterData slideNetherLike (Lnet/minecraft/core/HolderGetter;II)Lnet/minecraft/world/level/levelgen/DensityFunction;
|
||||
accessible method net/minecraft/tags/TagEntry elementOrTag ()Lnet/minecraft/util/ExtraCodecs$TagOrElementLocation;
|
||||
accessible method net/minecraft/data/worldgen/biome/OverworldBiomes calculateSkyColor (F)I
|
||||
accessible method net/minecraft/advancements/Advancement$Builder <init> (Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/advancements/DisplayInfo;Lnet/minecraft/advancements/AdvancementRewards;Ljava/util/Map;[[Ljava/lang/String;)V
|
||||
accessible method net/minecraft/world/level/block/Blocks ocelotOrParrot (Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/entity/EntityType;)Ljava/lang/Boolean;
|
||||
accessible method net/minecraft/world/level/block/Blocks never (Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/entity/EntityType;)Ljava/lang/Boolean;
|
||||
accessible method net/minecraft/world/level/block/Blocks never (Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;)Z
|
||||
|
||||
#Fields
|
||||
accessible field net/minecraft/world/entity/ai/village/poi/PoiTypes TYPE_BY_STATE Ljava/util/Map;
|
Loading…
Add table
Add a link
Reference in a new issue