[Change] Use Refactored Plant API (#24)

This commit is contained in:
Frank 2022-06-30 17:52:25 +02:00
parent 372d7ddd13
commit ccd4a6f57d
18 changed files with 37 additions and 110 deletions

View file

@ -16,7 +16,7 @@ import net.minecraft.world.level.block.state.BlockState;
public class BlueVineSeedBlock extends EndPlantWithAgeBlock {
public BlueVineSeedBlock() {
super(p -> p.offsetType(BlockBehaviour.OffsetType.NONE));
super(basePlantSettings().offsetType(BlockBehaviour.OffsetType.NONE));
}
@Override

View file

@ -23,7 +23,7 @@ public class BoluxMushroomBlock extends EndPlantBlock {
private static final VoxelShape SHAPE = Block.box(1, 0, 1, 15, 9, 15);
public BoluxMushroomBlock() {
super(10, p -> p.offsetType(BlockBehaviour.OffsetType.NONE));
super(basePlantSettings(10).offsetType(BlockBehaviour.OffsetType.NONE));
}
@Override

View file

@ -12,23 +12,21 @@ 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.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
public class BubbleCoralBlock extends EndUnderwaterPlantBlock implements AddMineableShears {
private static final VoxelShape SHAPE = Block.box(0, 0, 0, 16, 14, 16);
public BubbleCoralBlock() {
super(FabricBlockSettings.of(Material.WATER_PLANT)
super(baseUnderwaterPlantSettings()
.sound(SoundType.CORAL_BLOCK)
.noCollission()
.offsetType(BlockBehaviour.OffsetType.NONE));
.offsetType(BlockBehaviour.OffsetType.NONE)
);
}
@Environment(EnvType.CLIENT)

View file

@ -20,7 +20,7 @@ import net.minecraft.world.phys.shapes.VoxelShape;
public class CavePumpkinVineBlock extends EndPlantWithAgeBlock {
public CavePumpkinVineBlock() {
super(p -> p.offsetType(BlockBehaviour.OffsetType.NONE));
super(basePlantSettings().offsetType(BlockBehaviour.OffsetType.NONE));
}
private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 16, 12);

View file

@ -18,13 +18,11 @@ import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.SoundType;
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.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.phys.Vec3;
import net.minecraft.world.phys.shapes.CollisionContext;
@ -32,7 +30,6 @@ import net.minecraft.world.phys.shapes.VoxelShape;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import com.google.common.collect.Lists;
@ -45,10 +42,9 @@ public class EndLilyBlock extends EndUnderwaterPlantBlock implements AddMineable
private static final VoxelShape SHAPE_TOP = Block.box(2, 0, 2, 14, 6, 14);
public EndLilyBlock() {
super(FabricBlockSettings.of(Material.WATER_PLANT)
.sound(SoundType.WET_GRASS)
super(baseUnderwaterPlantSettings()
.lightLevel((state) -> state.getValue(SHAPE) == TripleShape.TOP ? 13 : 0)
.noCollission());
);
}
@Override

View file

@ -10,14 +10,12 @@ import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
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.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import com.google.common.collect.Lists;
@ -29,11 +27,7 @@ public class EndLotusFlowerBlock extends EndPlantBlock {
public EndLotusFlowerBlock() {
//TODO: 1.19 Test if we can remove dynamic shape and offsetType
super(FabricBlockSettings.of(Material.PLANT)
.luminance(15)
.noOcclusion()
.dynamicShape()
.offsetType(BlockBehaviour.OffsetType.NONE));
super(basePlantSettings(15).offsetType(BlockBehaviour.OffsetType.NONE));
}
@Override

View file

@ -15,13 +15,11 @@ import net.minecraft.world.level.block.Blocks;
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.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import com.google.common.collect.Lists;
@ -31,11 +29,10 @@ public class FlamaeaBlock extends EndPlantBlock implements CustomItemProvider, A
private static final VoxelShape SHAPE = Block.box(0, 0, 0, 16, 1, 16);
public FlamaeaBlock() {
//TODO: 1.19 Test if we can remove dynamic shape and offsetType
super(FabricBlockSettings.of(Material.PLANT)
super(basePlantSettings()
.sound(SoundType.WET_GRASS)
.dynamicShape()
.offsetType(BlockBehaviour.OffsetType.NONE));
.offsetType(BlockBehaviour.OffsetType.NONE)
);
}
@Override

View file

@ -20,7 +20,7 @@ public class FlammalixBlock extends EndPlantBlock {
private static final VoxelShape SHAPE = Block.box(2, 0, 2, 14, 14, 14);
public FlammalixBlock() {
super(false, 12, p -> p.offsetType(OffsetType.NONE));
super(basePlantSettings(12).offsetType(OffsetType.NONE));
}
@Override

View file

@ -15,16 +15,13 @@ import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.SoundType;
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.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import com.google.common.collect.Lists;
@ -36,10 +33,9 @@ public class HydraluxBlock extends UnderwaterPlantBlock implements AddMineableSh
public static final EnumProperty<HydraluxShape> SHAPE = EndBlockProperties.HYDRALUX_SHAPE;
public HydraluxBlock() {
super(FabricBlockSettings.of(Material.WATER_PLANT)
.sound(SoundType.WET_GRASS)
super(baseUnderwaterPlantSettings()
.lightLevel((state) -> state.getValue(SHAPE).hasGlow() ? 15 : 0)
.noCollission());
);
}
@Override

View file

@ -16,7 +16,7 @@ import net.minecraft.world.level.block.state.BlockState;
public class LanceleafSeedBlock extends EndPlantWithAgeBlock {
public LanceleafSeedBlock() {
super(p -> p.offsetType(OffsetType.NONE));
super(basePlantSettings().offsetType(OffsetType.NONE));
}
@Override

View file

@ -12,30 +12,23 @@ import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.SoundType;
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.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
public class LargeAmaranitaBlock extends EndPlantBlock implements AddMineableShears {
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
private static final VoxelShape SHAPE_BOTTOM = Block.box(4, 0, 4, 12, 14, 12);
private static final VoxelShape SHAPE_TOP = Shapes.or(Block.box(1, 3, 1, 15, 16, 15), SHAPE_BOTTOM);
public LargeAmaranitaBlock() {
//TODO: 1.19 Test if we can remove dynamic shape and offsetType
super(FabricBlockSettings.of(Material.PLANT)
.sound(SoundType.GRASS)
super(basePlantSettings()
.lightLevel((state) -> (state.getValue(SHAPE) == TripleShape.TOP) ? 15 : 0)
.dynamicShape()
.offsetType(OffsetType.NONE));
.offsetType(OffsetType.NONE)
);
}
@Override

View file

@ -17,7 +17,7 @@ import java.util.Optional;
public class LumecornSeedBlock extends EndPlantWithAgeBlock {
public LumecornSeedBlock() {
super(p -> p.offsetType(OffsetType.NONE));
super(basePlantSettings().offsetType(OffsetType.NONE));
}
@Override

View file

@ -11,24 +11,19 @@ import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
public class PondAnemoneBlock extends EndUnderwaterPlantBlock implements AddMineableShears {
private static final VoxelShape SHAPE = Block.box(2, 0, 2, 14, 14, 14);
public PondAnemoneBlock() {
super(FabricBlockSettings.of(Material.WATER_PLANT)
.luminance(13)
.sound(SoundType.CORAL_BLOCK)
.noCollission()
.offsetType(OffsetType.NONE));
super(baseUnderwaterPlantSettings(13).sound(SoundType.CORAL_BLOCK)
.offsetType(OffsetType.NONE)
);
}
@Environment(EnvType.CLIENT)

View file

@ -7,39 +7,21 @@ import org.betterx.worlds.together.tag.v3.CommonBlockTags;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import java.util.function.Function;
public class EndPlantBlock extends BasePlantBlock implements PottablePlant {
public EndPlantBlock() {
this(false, p -> p);
protected EndPlantBlock() {
super();
}
public EndPlantBlock(int light) {
this(light, p -> p);
}
public EndPlantBlock(int light, Function<Properties, Properties> propMod) {
this(false, light, propMod);
}
public EndPlantBlock(boolean replaceable) {
protected EndPlantBlock(boolean replaceable) {
super(replaceable);
}
public EndPlantBlock(boolean replaceable, Function<Properties, Properties> propMod) {
super(replaceable, propMod);
protected EndPlantBlock(int light) {
super(light);
}
public EndPlantBlock(boolean replaceable, int light) {
this(replaceable, light, p -> p);
}
public EndPlantBlock(boolean replaceable, int light, Function<Properties, Properties> propMod) {
super(replaceable, light, propMod);
}
public EndPlantBlock(Properties settings) {
super(settings);
protected EndPlantBlock(Properties props) {
super(props);
}
@Override

View file

@ -5,15 +5,9 @@ import org.betterx.worlds.together.tag.v3.CommonBlockTags;
import net.minecraft.world.level.block.state.BlockState;
import java.util.function.Function;
public abstract class EndPlantWithAgeBlock extends BasePlantWithAgeBlock {
public EndPlantWithAgeBlock() {
}
public EndPlantWithAgeBlock(Function<Properties, Properties> propMod) {
super(propMod);
protected EndPlantWithAgeBlock() {
super();
}
public EndPlantWithAgeBlock(Properties settings) {

View file

@ -5,17 +5,11 @@ import org.betterx.worlds.together.tag.v3.CommonBlockTags;
import net.minecraft.world.level.block.state.BlockState;
import java.util.function.Function;
public class EndUnderwaterPlantBlock extends UnderwaterPlantBlock {
public EndUnderwaterPlantBlock() {
}
public EndUnderwaterPlantBlock(int light, Function<Properties, Properties> propMod) {
super(light, propMod);
}
public EndUnderwaterPlantBlock(Properties settings) {
super(settings);
}

View file

@ -10,14 +10,6 @@ public class EndUnderwaterWallPlantBlock extends BaseUnderwaterWallPlantBlock {
public EndUnderwaterWallPlantBlock() {
}
public EndUnderwaterWallPlantBlock(int light) {
super(light);
}
public EndUnderwaterWallPlantBlock(Properties settings) {
super(settings);
}
@Override
protected boolean isTerrain(BlockState state) {
return state.is(CommonBlockTags.END_STONES);

View file

@ -13,10 +13,6 @@ public class EndWallPlantBlock extends BaseWallPlantBlock {
super(light);
}
public EndWallPlantBlock(Properties settings) {
super(settings);
}
@Override
protected boolean isTerrain(BlockState state) {
return state.is(CommonBlockTags.END_STONES);