Made plant creation consistent with BehaviourBuilders
This commit is contained in:
parent
c340d575c5
commit
f259496ba0
56 changed files with 363 additions and 396 deletions
|
@ -1,6 +1,5 @@
|
|||
package org.betterx.betterend.blocks.basis;
|
||||
|
||||
import org.betterx.bclib.behaviours.interfaces.BehaviourPlant;
|
||||
import org.betterx.bclib.blocks.BasePlantBlock;
|
||||
import org.betterx.betterend.interfaces.PottablePlant;
|
||||
import org.betterx.worlds.together.tag.v3.CommonBlockTags;
|
||||
|
@ -8,25 +7,13 @@ import org.betterx.worlds.together.tag.v3.CommonBlockTags;
|
|||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class EndPlantBlock extends BasePlantBlock implements PottablePlant, BehaviourPlant {
|
||||
protected EndPlantBlock() {
|
||||
super();
|
||||
}
|
||||
|
||||
protected EndPlantBlock(boolean replaceable) {
|
||||
super(replaceable);
|
||||
}
|
||||
|
||||
protected EndPlantBlock(int light) {
|
||||
super(light);
|
||||
}
|
||||
|
||||
public abstract class EndPlantBlock extends BasePlantBlock implements PottablePlant {
|
||||
protected EndPlantBlock(Properties props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isTerrain(BlockState state) {
|
||||
public boolean isTerrain(BlockState state) {
|
||||
return state.is(CommonBlockTags.END_STONES);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,22 +1,18 @@
|
|||
package org.betterx.betterend.blocks.basis;
|
||||
|
||||
import org.betterx.bclib.behaviours.interfaces.BehaviourPlant;
|
||||
import org.betterx.bclib.blocks.BasePlantWithAgeBlock;
|
||||
import org.betterx.worlds.together.tag.v3.CommonBlockTags;
|
||||
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public abstract class EndPlantWithAgeBlock extends BasePlantWithAgeBlock implements BehaviourPlant {
|
||||
protected EndPlantWithAgeBlock() {
|
||||
super();
|
||||
}
|
||||
public abstract class EndPlantWithAgeBlock extends BasePlantWithAgeBlock {
|
||||
|
||||
public EndPlantWithAgeBlock(Properties settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isTerrain(BlockState state) {
|
||||
public boolean isTerrain(BlockState state) {
|
||||
return state.is(CommonBlockTags.END_STONES);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,10 +6,6 @@ import org.betterx.worlds.together.tag.v3.CommonBlockTags;
|
|||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class EndUnderwaterPlantBlock extends UnderwaterPlantBlock {
|
||||
|
||||
public EndUnderwaterPlantBlock() {
|
||||
}
|
||||
|
||||
public EndUnderwaterPlantBlock(Properties settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
|
|
@ -1,17 +1,21 @@
|
|||
package org.betterx.betterend.blocks.basis;
|
||||
|
||||
import org.betterx.bclib.behaviours.BehaviourBuilders;
|
||||
import org.betterx.bclib.blocks.BaseUnderwaterWallPlantBlock;
|
||||
import org.betterx.worlds.together.tag.v3.CommonBlockTags;
|
||||
import org.betterx.betterend.interfaces.survives.SurvivesOnEndStone;
|
||||
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
|
||||
public class EndUnderwaterWallPlantBlock extends BaseUnderwaterWallPlantBlock {
|
||||
public class EndUnderwaterWallPlantBlock extends BaseUnderwaterWallPlantBlock implements SurvivesOnEndStone {
|
||||
|
||||
public EndUnderwaterWallPlantBlock() {
|
||||
public EndUnderwaterWallPlantBlock(MapColor color) {
|
||||
super(BehaviourBuilders.createWaterPlant(color));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean isTerrain(BlockState state) {
|
||||
return state.is(CommonBlockTags.END_STONES);
|
||||
public boolean isTerrain(BlockState state) {
|
||||
return SurvivesOnEndStone.super.isTerrain(state);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,21 +1,24 @@
|
|||
package org.betterx.betterend.blocks.basis;
|
||||
|
||||
import org.betterx.bclib.behaviours.BehaviourBuilders;
|
||||
import org.betterx.bclib.behaviours.interfaces.BehaviourPlant;
|
||||
import org.betterx.bclib.blocks.BaseWallPlantBlock;
|
||||
import org.betterx.worlds.together.tag.v3.CommonBlockTags;
|
||||
import org.betterx.betterend.interfaces.survives.SurvivesOnEndStone;
|
||||
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
|
||||
public class EndWallPlantBlock extends BaseWallPlantBlock implements BehaviourPlant {
|
||||
public EndWallPlantBlock() {
|
||||
public class EndWallPlantBlock extends BaseWallPlantBlock implements BehaviourPlant, SurvivesOnEndStone {
|
||||
public EndWallPlantBlock(MapColor color) {
|
||||
super(BehaviourBuilders.createPlant(color));
|
||||
}
|
||||
|
||||
public EndWallPlantBlock(int light) {
|
||||
super(light);
|
||||
public EndWallPlantBlock(MapColor color, int light) {
|
||||
super(BehaviourBuilders.createPlant(color).lightLevel((bs) -> light));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isTerrain(BlockState state) {
|
||||
return state.is(CommonBlockTags.END_STONES);
|
||||
public boolean isTerrain(BlockState state) {
|
||||
return SurvivesOnEndStone.super.isTerrain(state);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,20 +5,24 @@ import org.betterx.bclib.behaviours.interfaces.BehaviourShearablePlant;
|
|||
import org.betterx.bclib.blocks.BaseAttachedBlock;
|
||||
import org.betterx.bclib.client.render.BCLRenderLayer;
|
||||
import org.betterx.bclib.interfaces.RenderLayerProvider;
|
||||
import org.betterx.bclib.interfaces.TagProvider;
|
||||
import org.betterx.bclib.items.tool.BaseShearsItem;
|
||||
import org.betterx.bclib.util.MHelper;
|
||||
import org.betterx.worlds.together.tag.v3.TagManager;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
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.MapColor;
|
||||
import net.minecraft.world.level.storage.loot.LootParams;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
|
@ -31,28 +35,26 @@ import com.google.common.collect.Maps;
|
|||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
|
||||
public class FurBlock extends BaseAttachedBlock implements RenderLayerProvider, BehaviourShearablePlant {
|
||||
public class FurBlock extends BaseAttachedBlock implements RenderLayerProvider, BehaviourShearablePlant, TagProvider {
|
||||
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
|
||||
private final ItemLike drop;
|
||||
private final int dropChance;
|
||||
|
||||
public FurBlock(ItemLike drop, int light, int dropChance, boolean wet) {
|
||||
super(BehaviourBuilders.createReplaceablePlant()
|
||||
.lightLevel(bs -> light)
|
||||
.sound(wet ? SoundType.WET_GRASS : SoundType.GRASS)
|
||||
public FurBlock(MapColor color, ItemLike drop, int light, int dropChance, boolean wet) {
|
||||
super(BehaviourBuilders
|
||||
.createPlant(color)
|
||||
.replaceable()
|
||||
.lightLevel(bs -> light)
|
||||
.ignitedByLava()
|
||||
.sound(wet ? SoundType.WET_GRASS : SoundType.GRASS)
|
||||
);
|
||||
|
||||
this.drop = drop;
|
||||
this.dropChance = dropChance;
|
||||
TagManager.BLOCKS.add(BlockTags.LEAVES, this);
|
||||
}
|
||||
|
||||
public FurBlock(ItemLike drop, int dropChance) {
|
||||
super(BehaviourBuilders.createReplaceablePlant()
|
||||
.sound(SoundType.GRASS)
|
||||
);
|
||||
this.drop = drop;
|
||||
this.dropChance = dropChance;
|
||||
TagManager.BLOCKS.add(BlockTags.LEAVES, this);
|
||||
public FurBlock(MapColor color, ItemLike drop, int dropChance) {
|
||||
this(color, drop, 0, dropChance, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -89,4 +91,9 @@ public class FurBlock extends BaseAttachedBlock implements RenderLayerProvider,
|
|||
BOUNDING_SHAPES.put(Direction.WEST, Shapes.box(0.5, 0.0, 0.0, 1.0, 1.0, 1.0));
|
||||
BOUNDING_SHAPES.put(Direction.EAST, Shapes.box(0.0, 0.0, 0.0, 0.5, 1.0, 1.0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTags(List<TagKey<Block>> blockTags, List<TagKey<Item>> itemTags) {
|
||||
blockTags.add(BlockTags.LEAVES);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,31 +2,34 @@ package org.betterx.betterend.blocks.basis;
|
|||
|
||||
import org.betterx.bclib.behaviours.interfaces.BehaviourSeed;
|
||||
import org.betterx.bclib.blocks.BaseCropBlock;
|
||||
import org.betterx.bclib.interfaces.SurvivesOnBlocks;
|
||||
import org.betterx.betterend.interfaces.PottablePlant;
|
||||
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
public class PottableCropBlock extends BaseCropBlock implements PottablePlant, BehaviourSeed {
|
||||
private final Block[] terrain;
|
||||
import java.util.List;
|
||||
|
||||
public class PottableCropBlock extends BaseCropBlock implements PottablePlant, BehaviourSeed, SurvivesOnBlocks {
|
||||
private final List<Block> terrain;
|
||||
|
||||
public PottableCropBlock(Item drop, Block... terrain) {
|
||||
super(drop, terrain);
|
||||
this.terrain = terrain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlantOn(Block block) {
|
||||
for (Block ter : terrain) {
|
||||
if (block == ter) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
this.terrain = List.of(terrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPottedState() {
|
||||
return "age=3";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Block> getSurvivableBlocks() {
|
||||
return terrain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlantOn(Block block) {
|
||||
return isSurvivable(block.defaultBlockState());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,12 +2,14 @@ package org.betterx.betterend.blocks.basis;
|
|||
|
||||
import org.betterx.bclib.behaviours.interfaces.BehaviourSapling;
|
||||
import org.betterx.bclib.blocks.FeatureSaplingBlock;
|
||||
import org.betterx.bclib.interfaces.SurvivesOn;
|
||||
import org.betterx.betterend.interfaces.PottablePlant;
|
||||
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.levelgen.feature.Feature;
|
||||
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
|
||||
|
||||
public abstract class PottableFeatureSapling<F extends Feature<FC>, FC extends FeatureConfiguration> extends FeatureSaplingBlock<F, FC> implements PottablePlant, BehaviourSapling {
|
||||
public abstract class PottableFeatureSapling<F extends Feature<FC>, FC extends FeatureConfiguration> extends FeatureSaplingBlock<F, FC> implements PottablePlant, BehaviourSapling, SurvivesOn {
|
||||
|
||||
public PottableFeatureSapling(FeatureSupplier<F, FC> featureSupplier) {
|
||||
super(featureSupplier);
|
||||
|
@ -16,4 +18,9 @@ public abstract class PottableFeatureSapling<F extends Feature<FC>, FC extends F
|
|||
public PottableFeatureSapling(int light, FeatureSupplier<F, FC> featureSupplier) {
|
||||
super(light, featureSupplier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlantOn(Block block) {
|
||||
return isSurvivable(block.defaultBlockState());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
package org.betterx.betterend.blocks.basis;
|
||||
|
||||
import org.betterx.bclib.blocks.BaseLeavesBlock;
|
||||
import org.betterx.bclib.interfaces.SurvivesOnBlocks;
|
||||
import org.betterx.betterend.interfaces.PottablePlant;
|
||||
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
|
||||
public class PottableLeavesBlock extends BaseLeavesBlock implements PottablePlant {
|
||||
import java.util.List;
|
||||
|
||||
public class PottableLeavesBlock extends BaseLeavesBlock implements PottablePlant, SurvivesOnBlocks {
|
||||
|
||||
public PottableLeavesBlock(Block sapling, MapColor color) {
|
||||
super(sapling, color);
|
||||
|
@ -23,4 +26,17 @@ public class PottableLeavesBlock extends BaseLeavesBlock implements PottablePlan
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Block> getSurvivableBlocks() {
|
||||
if (sapling instanceof SurvivesOnBlocks pp) {
|
||||
return pp.getSurvivableBlocks();
|
||||
}
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String prefixComponent() {
|
||||
return "tooltip.bclib.pottable_on";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue