This commit is contained in:
paulevsGitch 2020-09-30 12:31:40 +03:00
parent 4703d575c5
commit ba4bc366c8
6 changed files with 14 additions and 21 deletions

View file

@ -1,10 +1,16 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import net.minecraft.world.gen.feature.Feature;
import ru.betterend.blocks.basis.BlockFeatureSapling; import ru.betterend.blocks.basis.BlockFeatureSapling;
import ru.betterend.registry.FeatureRegistry; import ru.betterend.registry.FeatureRegistry;
public class BlockMossyGlowshroomSapling extends BlockFeatureSapling { public class BlockMossyGlowshroomSapling extends BlockFeatureSapling {
public BlockMossyGlowshroomSapling() { public BlockMossyGlowshroomSapling() {
super(FeatureRegistry.MOSSY_GLOWSHROOM, 7); super(7);
}
@Override
protected Feature<?> getFeature() {
return FeatureRegistry.MOSSY_GLOWSHROOM.getFeature();
} }
} }

View file

@ -18,29 +18,25 @@ import net.minecraft.world.BlockView;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.WorldAccess; import net.minecraft.world.WorldAccess;
import net.minecraft.world.WorldView; import net.minecraft.world.WorldView;
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
import net.minecraft.world.gen.feature.Feature; import net.minecraft.world.gen.feature.Feature;
import ru.betterend.client.ERenderLayer; import ru.betterend.client.ERenderLayer;
import ru.betterend.client.IRenderTypeable; import ru.betterend.client.IRenderTypeable;
import ru.betterend.registry.BlockTagRegistry; import ru.betterend.registry.BlockTagRegistry;
import ru.betterend.util.BlocksHelper; import ru.betterend.util.BlocksHelper;
import ru.betterend.world.features.EndFeature;
public class BlockFeatureSapling extends BlockBaseNotFull implements Fertilizable, IRenderTypeable { public abstract class BlockFeatureSapling extends BlockBaseNotFull implements Fertilizable, IRenderTypeable {
private static final VoxelShape SHAPE = Block.createCuboidShape(4, 2, 4, 12, 16, 12); private static final VoxelShape SHAPE = Block.createCuboidShape(4, 2, 4, 12, 16, 12);
private final EndFeature feature;
public BlockFeatureSapling(EndFeature feature) { public BlockFeatureSapling() {
super(FabricBlockSettings.of(Material.PLANT) super(FabricBlockSettings.of(Material.PLANT)
.breakByHand(true) .breakByHand(true)
.collidable(false) .collidable(false)
.breakInstantly() .breakInstantly()
.sounds(BlockSoundGroup.GRASS) .sounds(BlockSoundGroup.GRASS)
.ticksRandomly()); .ticksRandomly());
this.feature = feature;
} }
public BlockFeatureSapling(EndFeature feature, int light) { public BlockFeatureSapling(int light) {
super(FabricBlockSettings.of(Material.PLANT) super(FabricBlockSettings.of(Material.PLANT)
.breakByHand(true) .breakByHand(true)
.collidable(false) .collidable(false)
@ -48,9 +44,10 @@ public class BlockFeatureSapling extends BlockBaseNotFull implements Fertilizabl
.sounds(BlockSoundGroup.GRASS) .sounds(BlockSoundGroup.GRASS)
.lightLevel(light) .lightLevel(light)
.ticksRandomly()); .ticksRandomly());
this.feature = feature;
} }
protected abstract Feature<?> getFeature();
@Override @Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
return SHAPE; return SHAPE;
@ -82,9 +79,7 @@ public class BlockFeatureSapling extends BlockBaseNotFull implements Fertilizabl
@Override @Override
public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) { public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) {
BlocksHelper.setWithoutUpdate(world, pos, Blocks.AIR.getDefaultState()); BlocksHelper.setWithoutUpdate(world, pos, Blocks.AIR.getDefaultState());
@SuppressWarnings("unchecked") getFeature().generate(world, world.getChunkManager().getChunkGenerator(), random, pos, null);
Feature<DefaultFeatureConfig> defFeature = (Feature<DefaultFeatureConfig>) feature.getFeature();
defFeature.generate(world, world.getChunkManager().getChunkGenerator(), random, pos, DefaultFeatureConfig.INSTANCE);
} }
@Override @Override

View file

@ -8,7 +8,6 @@ import com.mojang.blaze3d.systems.RenderSystem;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.client.gui.DrawableHelper; import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.recipebook.BlastFurnaceRecipeBookScreen; import net.minecraft.client.gui.screen.recipebook.BlastFurnaceRecipeBookScreen;
@ -19,7 +18,6 @@ import net.minecraft.recipe.Ingredient;
import net.minecraft.recipe.Recipe; import net.minecraft.recipe.Recipe;
import net.minecraft.screen.slot.Slot; import net.minecraft.screen.slot.Slot;
import net.minecraft.util.collection.DefaultedList; import net.minecraft.util.collection.DefaultedList;
import ru.betterend.blocks.entities.EndStoneSmelterBlockEntity; import ru.betterend.blocks.entities.EndStoneSmelterBlockEntity;
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)

View file

@ -3,7 +3,6 @@ package ru.betterend.client.gui;
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.screenhandler.v1.ScreenHandlerRegistry; import net.fabricmc.fabric.api.screenhandler.v1.ScreenHandlerRegistry;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.Inventory; import net.minecraft.inventory.Inventory;
@ -20,7 +19,6 @@ import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.screen.slot.Slot; import net.minecraft.screen.slot.Slot;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.world.World; import net.minecraft.world.World;
import ru.betterend.BetterEnd; import ru.betterend.BetterEnd;
import ru.betterend.blocks.EndStoneSmelter; import ru.betterend.blocks.EndStoneSmelter;
import ru.betterend.blocks.entities.EndStoneSmelterBlockEntity; import ru.betterend.blocks.entities.EndStoneSmelterBlockEntity;

View file

@ -8,9 +8,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.DefaultBiomeCreator; import net.minecraft.world.biome.DefaultBiomeCreator;
import net.minecraft.world.biome.GenerationSettings; import net.minecraft.world.biome.GenerationSettings;
import net.minecraft.world.gen.GenerationStep;
import ru.betterend.registry.FeatureRegistry;
@Mixin(DefaultBiomeCreator.class) @Mixin(DefaultBiomeCreator.class)
public abstract class DefaultBiomeCreatorMixin { public abstract class DefaultBiomeCreatorMixin {

View file

@ -6,7 +6,6 @@ import net.minecraft.structure.rule.BlockMatchRuleTest;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.registry.BuiltinRegistries; import net.minecraft.util.registry.BuiltinRegistries;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import net.minecraft.world.gen.GenerationStep; import net.minecraft.world.gen.GenerationStep;
import net.minecraft.world.gen.decorator.ChanceDecoratorConfig; import net.minecraft.world.gen.decorator.ChanceDecoratorConfig;
import net.minecraft.world.gen.decorator.Decorator; import net.minecraft.world.gen.decorator.Decorator;