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

View file

@ -20,7 +20,7 @@ import net.minecraft.world.phys.shapes.VoxelShape;
public class CavePumpkinVineBlock extends EndPlantWithAgeBlock { public class CavePumpkinVineBlock extends EndPlantWithAgeBlock {
public CavePumpkinVineBlock() { 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); 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.LevelReader;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks; 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.BlockState;
import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.EnumProperty; import net.minecraft.world.level.block.state.properties.EnumProperty;
import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids; 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.LootContext;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.CollisionContext; 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.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import com.google.common.collect.Lists; 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); private static final VoxelShape SHAPE_TOP = Block.box(2, 0, 2, 14, 6, 14);
public EndLilyBlock() { public EndLilyBlock() {
super(FabricBlockSettings.of(Material.WATER_PLANT) super(baseUnderwaterPlantSettings()
.sound(SoundType.WET_GRASS) .lightLevel((state) -> state.getValue(SHAPE) == TripleShape.TOP ? 13 : 0)
.lightLevel((state) -> state.getValue(SHAPE) == TripleShape.TOP ? 13 : 0) );
.noCollission());
} }
@Override @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.Block;
import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState; 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.LootContext;
import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShape;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
@ -29,11 +27,7 @@ public class EndLotusFlowerBlock extends EndPlantBlock {
public EndLotusFlowerBlock() { public EndLotusFlowerBlock() {
//TODO: 1.19 Test if we can remove dynamic shape and offsetType //TODO: 1.19 Test if we can remove dynamic shape and offsetType
super(FabricBlockSettings.of(Material.PLANT) super(basePlantSettings(15).offsetType(BlockBehaviour.OffsetType.NONE));
.luminance(15)
.noOcclusion()
.dynamicShape()
.offsetType(BlockBehaviour.OffsetType.NONE));
} }
@Override @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.SoundType;
import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState; 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.LootContext;
import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShape;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings; import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import com.google.common.collect.Lists; 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); private static final VoxelShape SHAPE = Block.box(0, 0, 0, 16, 1, 16);
public FlamaeaBlock() { public FlamaeaBlock() {
//TODO: 1.19 Test if we can remove dynamic shape and offsetType super(basePlantSettings()
super(FabricBlockSettings.of(Material.PLANT) .sound(SoundType.WET_GRASS)
.sound(SoundType.WET_GRASS) .offsetType(BlockBehaviour.OffsetType.NONE)
.dynamicShape() );
.offsetType(BlockBehaviour.OffsetType.NONE));
} }
@Override @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); private static final VoxelShape SHAPE = Block.box(2, 0, 2, 14, 14, 14);
public FlammalixBlock() { public FlammalixBlock() {
super(false, 12, p -> p.offsetType(OffsetType.NONE)); super(basePlantSettings(12).offsetType(OffsetType.NONE));
} }
@Override @Override

View file

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

View file

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

View file

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

View file

@ -17,7 +17,7 @@ import java.util.Optional;
public class LumecornSeedBlock extends EndPlantWithAgeBlock { public class LumecornSeedBlock extends EndPlantWithAgeBlock {
public LumecornSeedBlock() { public LumecornSeedBlock() {
super(p -> p.offsetType(OffsetType.NONE)); super(basePlantSettings().offsetType(OffsetType.NONE));
} }
@Override @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.Block;
import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState; 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.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShape;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
public class PondAnemoneBlock extends EndUnderwaterPlantBlock implements AddMineableShears { public class PondAnemoneBlock extends EndUnderwaterPlantBlock implements AddMineableShears {
private static final VoxelShape SHAPE = Block.box(2, 0, 2, 14, 14, 14); private static final VoxelShape SHAPE = Block.box(2, 0, 2, 14, 14, 14);
public PondAnemoneBlock() { public PondAnemoneBlock() {
super(FabricBlockSettings.of(Material.WATER_PLANT) super(baseUnderwaterPlantSettings(13).sound(SoundType.CORAL_BLOCK)
.offsetType(OffsetType.NONE)
.luminance(13) );
.sound(SoundType.CORAL_BLOCK)
.noCollission()
.offsetType(OffsetType.NONE));
} }
@Environment(EnvType.CLIENT) @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.Block;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import java.util.function.Function;
public class EndPlantBlock extends BasePlantBlock implements PottablePlant { public class EndPlantBlock extends BasePlantBlock implements PottablePlant {
public EndPlantBlock() { protected EndPlantBlock() {
this(false, p -> p); super();
} }
public EndPlantBlock(int light) { protected EndPlantBlock(boolean replaceable) {
this(light, p -> p);
}
public EndPlantBlock(int light, Function<Properties, Properties> propMod) {
this(false, light, propMod);
}
public EndPlantBlock(boolean replaceable) {
super(replaceable); super(replaceable);
} }
public EndPlantBlock(boolean replaceable, Function<Properties, Properties> propMod) { protected EndPlantBlock(int light) {
super(replaceable, propMod); super(light);
} }
public EndPlantBlock(boolean replaceable, int light) { protected EndPlantBlock(Properties props) {
this(replaceable, light, p -> p); super(props);
}
public EndPlantBlock(boolean replaceable, int light, Function<Properties, Properties> propMod) {
super(replaceable, light, propMod);
}
public EndPlantBlock(Properties settings) {
super(settings);
} }
@Override @Override

View file

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

View file

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

View file

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