[Change] streamlined BehaviourBuilders for Plants

This commit is contained in:
Frank 2023-06-13 16:47:05 +02:00
parent e0622a1c11
commit 941782e4f1

View file

@ -14,58 +14,73 @@ public class BehaviourBuilders {
} }
public static BlockBehaviour.Properties createPlant(MapColor color) { public static BlockBehaviour.Properties createPlant(MapColor color) {
return createPlant(color, false); return createWalkablePlant(color).noCollission();
} }
//TODO: Remove this method, and call noCollision explicitly public static BlockBehaviour.Properties createWalkablePlant() {
public static BlockBehaviour.Properties createPlant(MapColor color, boolean collission) { return createWalkablePlant(MapColor.PLANT);
var p = BlockBehaviour.Properties.of() }
public static BlockBehaviour.Properties createWalkablePlant(MapColor color) {
return BlockBehaviour.Properties
.of()
.mapColor(color) .mapColor(color)
.noOcclusion()
.instabreak() .instabreak()
.pushReaction(PushReaction.DESTROY); .pushReaction(PushReaction.DESTROY);
if (!collission)
p.noCollission();
return p;
} }
public static BlockBehaviour.Properties createGrass(MapColor color, boolean flammable) { public static BlockBehaviour.Properties createVine() {
final BlockBehaviour.Properties p = createPlant(color); return createVine(MapColor.PLANT);
if (flammable)
p.ignitedByLava();
return p;
} }
public static BlockBehaviour.Properties createTickingPlant() { public static BlockBehaviour.Properties createVine(MapColor color) {
return createTickingPlant(MapColor.PLANT); return createPlant(color)
.replaceable()
.noCollission()
.randomTicks()
.strength(0.2f)
.sound(SoundType.VINE);
} }
public static BlockBehaviour.Properties createTickingPlant(MapColor color) { public static BlockBehaviour.Properties createGrass(MapColor color) {
return createPlant(color).randomTicks(); return createPlant(color)
.noCollission()
.noOcclusion()
.offsetType(BlockBehaviour.OffsetType.XZ)
.sound(SoundType.GRASS);
} }
public static BlockBehaviour.Properties createReplaceablePlant() { public static BlockBehaviour.Properties createSeed(MapColor color) {
return createReplaceablePlant(MapColor.PLANT); return createPlant(color)
.noCollission()
.randomTicks()
.sound(SoundType.HARD_CROP)
.offsetType(BlockBehaviour.OffsetType.XZ);
} }
public static BlockBehaviour.Properties createReplaceablePlant(MapColor color) { public static BlockBehaviour.Properties createPlantCover(MapColor color) {
return createPlant(color).replaceable(); return createPlant(color).forceSolidOn()
.noCollission()
.replaceable()
.strength(0.2f)
.sound(SoundType.GLOW_LICHEN);
} }
public static BlockBehaviour.Properties createWaterPlant() { public static BlockBehaviour.Properties createWaterPlant() {
return createWaterPlant(MapColor.WATER, false); return createWaterPlant(MapColor.WATER);
} }
//TODO: Remove this method, and call noCollision explicitly public static BlockBehaviour.Properties createWaterPlant(MapColor color) {
public static BlockBehaviour.Properties createWaterPlant(MapColor color, boolean collission) { return BlockBehaviour.Properties.of()
var p = BlockBehaviour.Properties.of()
.mapColor(color) .mapColor(color)
.instabreak() .instabreak()
.noOcclusion()
.noCollission()
.sound(SoundType.WET_GRASS)
.offsetType(BlockBehaviour.OffsetType.XZ)
.pushReaction(PushReaction.DESTROY); .pushReaction(PushReaction.DESTROY);
if (!collission)
p.noCollission();
return p;
} }
public static BlockBehaviour.Properties createReplaceableWaterPlant() { public static BlockBehaviour.Properties createReplaceableWaterPlant() {
@ -197,32 +212,6 @@ public class BehaviourBuilders {
.isViewBlocking(Blocks::never); .isViewBlocking(Blocks::never);
} }
public static BlockBehaviour.Properties applyBasePlantSettings() {
return applyBasePlantSettings(false, 0);
}
public static BlockBehaviour.Properties applyBasePlantSettings(int light) {
return applyBasePlantSettings(false, light);
}
public static BlockBehaviour.Properties applyBasePlantSettings(boolean replaceable) {
return applyBasePlantSettings(replaceable, 0);
}
public static BlockBehaviour.Properties applyBasePlantSettings(boolean replaceable, int light) {
return applyBasePlantSettings(replaceable
? createReplaceablePlant()
: createPlant(), light);
}
public static BlockBehaviour.Properties applyBasePlantSettings(BlockBehaviour.Properties props, int light) {
props
.sound(SoundType.GRASS)
.offsetType(BlockBehaviour.OffsetType.XZ);
if (light > 0) props.lightLevel(s -> light);
return props;
}
public static BlockBehaviour.Properties createSnow() { public static BlockBehaviour.Properties createSnow() {
return BlockBehaviour.Properties return BlockBehaviour.Properties
.of() .of()