This commit is contained in:
paulevsGitch 2020-10-03 23:28:04 +03:00
parent a968b9bb23
commit 8beabd0f96
18 changed files with 176 additions and 63 deletions

View file

@ -12,7 +12,9 @@ import net.minecraft.state.property.BooleanProperty;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.world.WorldAccess; import net.minecraft.world.WorldAccess;
import net.minecraft.world.WorldView;
import ru.betterend.blocks.basis.BlockBase; import ru.betterend.blocks.basis.BlockBase;
import ru.betterend.registry.BlockRegistry;
public class BlockBlueVineLantern extends BlockBase { public class BlockBlueVineLantern extends BlockBase {
public static final BooleanProperty NATURAL = BooleanProperty.of("natural"); public static final BooleanProperty NATURAL = BooleanProperty.of("natural");
@ -22,9 +24,14 @@ public class BlockBlueVineLantern extends BlockBase {
this.setDefaultState(this.stateManager.getDefaultState().with(NATURAL, false)); this.setDefaultState(this.stateManager.getDefaultState().with(NATURAL, false));
} }
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
return state.get(NATURAL) ? world.getBlockState(pos.down()).getBlock() == BlockRegistry.BLUE_VINE : true;
}
@Override @Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
if (state.get(NATURAL) && world.isAir(pos.down())) { if (!canPlaceAt(state, world, pos)) {
return Blocks.AIR.getDefaultState(); return Blocks.AIR.getDefaultState();
} }
else { else {

View file

@ -2,18 +2,19 @@ package ru.betterend.blocks;
import java.util.Random; import java.util.Random;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.world.StructureWorldAccess;
import ru.betterend.blocks.BlockProperties.TripleShape; import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.BlockPlantWithStages; import ru.betterend.blocks.basis.BlockGlowingFur;
import ru.betterend.blocks.basis.BlockPlantWithAge;
import ru.betterend.registry.BlockRegistry; import ru.betterend.registry.BlockRegistry;
import ru.betterend.util.BlocksHelper; import ru.betterend.util.BlocksHelper;
import ru.betterend.util.MHelper; import ru.betterend.util.MHelper;
public class BlockBlueVineSeed extends BlockPlantWithStages { public class BlockBlueVineSeed extends BlockPlantWithAge {
@Override @Override
public void grow(ServerWorld world, Random random, BlockPos pos) { public void grow(StructureWorldAccess world, Random random, BlockPos pos) {
int height = MHelper.randRange(2, 5, random); int height = MHelper.randRange(2, 5, random);
int h = BlocksHelper.upRay(world, pos, height + 2); int h = BlocksHelper.upRay(world, pos, height + 2);
if (h < height + 1) { if (h < height + 1) {
@ -27,7 +28,7 @@ public class BlockBlueVineSeed extends BlockPlantWithStages {
placeLantern(world, pos.up(height + 1)); placeLantern(world, pos.up(height + 1));
} }
private void placeLantern(ServerWorld world, BlockPos pos) { private void placeLantern(StructureWorldAccess world, BlockPos pos) {
BlocksHelper.setWithoutUpdate(world, pos, BlockRegistry.BLUE_VINE_LANTERN.getDefaultState().with(BlockBlueVineLantern.NATURAL, true)); BlocksHelper.setWithoutUpdate(world, pos, BlockRegistry.BLUE_VINE_LANTERN.getDefaultState().with(BlockBlueVineLantern.NATURAL, true));
for (Direction dir: BlocksHelper.HORIZONTAL) { for (Direction dir: BlocksHelper.HORIZONTAL) {
BlockPos p = pos.offset(dir); BlockPos p = pos.offset(dir);

View file

@ -1,4 +1,4 @@
package ru.betterend.blocks; package ru.betterend.blocks.basis;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.List; import java.util.List;
@ -15,6 +15,7 @@ import net.minecraft.block.Material;
import net.minecraft.block.ShapeContext; import net.minecraft.block.ShapeContext;
import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments; import net.minecraft.enchantment.Enchantments;
import net.minecraft.item.ItemConvertible;
import net.minecraft.item.ItemPlacementContext; import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext; import net.minecraft.loot.context.LootContext;
@ -30,24 +31,24 @@ import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView; import net.minecraft.world.BlockView;
import net.minecraft.world.WorldAccess; import net.minecraft.world.WorldAccess;
import net.minecraft.world.WorldView; import net.minecraft.world.WorldView;
import ru.betterend.blocks.basis.BlockBaseNotFull;
import ru.betterend.client.ERenderLayer; import ru.betterend.client.ERenderLayer;
import ru.betterend.client.IRenderTypeable; import ru.betterend.client.IRenderTypeable;
import ru.betterend.registry.BlockRegistry;
import ru.betterend.util.MHelper; import ru.betterend.util.MHelper;
public class BlockGlowingFur extends BlockBaseNotFull implements IRenderTypeable { public class BlockGlowingFur extends BlockBaseNotFull implements IRenderTypeable {
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class); private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
public static final DirectionProperty FACING = Properties.FACING; public static final DirectionProperty FACING = Properties.FACING;
private final ItemConvertible drop;
private final int dropChance; private final int dropChance;
public BlockGlowingFur(int dropChance) { public BlockGlowingFur(ItemConvertible drop, int dropChance) {
super(FabricBlockSettings.of(Material.REPLACEABLE_PLANT) super(FabricBlockSettings.of(Material.REPLACEABLE_PLANT)
.breakByTool(FabricToolTags.SHEARS) .breakByTool(FabricToolTags.SHEARS)
.sounds(BlockSoundGroup.WET_GRASS) .sounds(BlockSoundGroup.WET_GRASS)
.lightLevel(15) .lightLevel(15)
.breakByHand(true) .breakByHand(true)
.noCollision()); .noCollision());
this.drop = drop;
this.dropChance = dropChance; this.dropChance = dropChance;
} }
@ -102,7 +103,7 @@ public class BlockGlowingFur extends BlockBaseNotFull implements IRenderTypeable
return Lists.newArrayList(new ItemStack(this)); return Lists.newArrayList(new ItemStack(this));
} }
else if (MHelper.RANDOM.nextInt(dropChance) == 0) { else if (MHelper.RANDOM.nextInt(dropChance) == 0) {
return Lists.newArrayList(new ItemStack(BlockRegistry.MOSSY_GLOWSHROOM_SAPLING)); return Lists.newArrayList(new ItemStack(drop));
} }
else { else {
return Lists.newArrayList(); return Lists.newArrayList();

View file

@ -8,8 +8,9 @@ import net.minecraft.server.world.ServerWorld;
import net.minecraft.state.StateManager; import net.minecraft.state.StateManager;
import net.minecraft.state.property.IntProperty; import net.minecraft.state.property.IntProperty;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.StructureWorldAccess;
public abstract class BlockPlantWithStages extends BlockPlant { public abstract class BlockPlantWithAge extends BlockPlant {
public static final IntProperty AGE = IntProperty.of("age", 0, 4); public static final IntProperty AGE = IntProperty.of("age", 0, 4);
@Override @Override
@ -17,7 +18,7 @@ public abstract class BlockPlantWithStages extends BlockPlant {
stateManager.add(AGE); stateManager.add(AGE);
} }
public abstract void grow(ServerWorld world, Random random, BlockPos pos); public abstract void grow(StructureWorldAccess world, Random random, BlockPos pos);
@Override @Override
public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) { public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) {

View file

@ -1,27 +1,29 @@
package ru.betterend.blocks.basis; package ru.betterend.blocks.basis;
import java.util.List; import java.util.List;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.block.Material; import net.minecraft.block.Material;
import net.minecraft.block.ShapeContext; import net.minecraft.block.ShapeContext;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments; import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext; import net.minecraft.loot.context.LootContext;
import net.minecraft.loot.context.LootContextParameters; import net.minecraft.loot.context.LootContextParameters;
import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView; import net.minecraft.world.BlockView;
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 ru.betterend.client.ERenderLayer; import ru.betterend.client.ERenderLayer;
@ -41,25 +43,24 @@ public class BlockUpDownPlant extends BlockBaseNotFull implements IRenderTypeabl
@Override @Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
Vec3d vec3d = state.getModelOffset(view, pos); return SHAPE;
return SHAPE.offset(vec3d.x, vec3d.y, vec3d.z);
}
@Override
public AbstractBlock.OffsetType getOffsetType() {
return AbstractBlock.OffsetType.XZ;
} }
@Override @Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
BlockState down = world.getBlockState(pos.down()); BlockState down = world.getBlockState(pos.down());
return isTerrain(down); BlockState up = world.getBlockState(pos.up());
return (isTerrain(down) || down.getBlock() == this) && (isSupport(up, world, pos) || up.getBlock() == this);
} }
protected boolean isTerrain(BlockState state) { protected boolean isTerrain(BlockState state) {
return state.isIn(BlockTagRegistry.END_GROUND); return state.isIn(BlockTagRegistry.END_GROUND);
} }
protected boolean isSupport(BlockState state, WorldView world, BlockPos pos) {
return sideCoversSmallSquare(world, pos.up(), Direction.UP);
}
@Override @Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
if (!canPlaceAt(state, world, pos)) { if (!canPlaceAt(state, world, pos)) {
@ -85,4 +86,10 @@ public class BlockUpDownPlant extends BlockBaseNotFull implements IRenderTypeabl
public ERenderLayer getRenderLayer() { public ERenderLayer getRenderLayer() {
return ERenderLayer.CUTOUT; return ERenderLayer.CUTOUT;
} }
@Override
public void afterBreak(World world, PlayerEntity player, BlockPos pos, BlockState state, BlockEntity blockEntity, ItemStack stack) {
super.afterBreak(world, player, pos, state, blockEntity, stack);
world.updateNeighbor(pos, Blocks.AIR, pos.down());
}
} }

View file

@ -1,7 +1,6 @@
package ru.betterend.item; package ru.betterend.item;
import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool; import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.minecraft.item.AxeItem; import net.minecraft.item.AxeItem;

View file

@ -8,10 +8,8 @@ import com.google.common.collect.Multimap;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import io.netty.util.internal.ThreadLocalRandom; import io.netty.util.internal.ThreadLocalRandom;
import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool; import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool;
import net.fabricmc.fabric.api.tool.attribute.v1.ToolManager; import net.fabricmc.fabric.api.tool.attribute.v1.ToolManager;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Material; import net.minecraft.block.Material;
import net.minecraft.entity.EquipmentSlot; import net.minecraft.entity.EquipmentSlot;

View file

@ -0,0 +1,17 @@
package ru.betterend.mixin.common;
import org.spongepowered.asm.mixin.Mixin;
import net.minecraft.world.gen.chunk.ChunkGenerator;
@Mixin(ChunkGenerator.class)
public class ChunkGeneratorMixin {
/*@Inject(method = "generateFeatures", at = @At("RETURN"))
private void fixerPass(ChunkRegion region, StructureAccessor accessor, CallbackInfo info) {
int chunkX = region.getCenterChunkX();
int chunkZ = region.getCenterChunkZ();
BlockPos start = new BlockPos(chunkX << 4, 16, chunkZ << 4);
BlockPos end = start.add(15, 64, 15);
BlocksHelper.fixBlocks(region, start, end);
}*/
}

View file

@ -1,13 +0,0 @@
package ru.betterend.mixin.common;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import net.minecraft.tag.Tag;
@Deprecated
@Mixin(targets = "net.minecraft.tag.RequiredTagList$TagWrapper")
public interface TagAccessor<T> {
@Accessor
Tag<T> getDelegate();
}

View file

@ -13,7 +13,6 @@ import ru.betterend.blocks.BlockBlueVineSeed;
import ru.betterend.blocks.BlockEndstoneDust; import ru.betterend.blocks.BlockEndstoneDust;
import ru.betterend.blocks.BlockGlowingMoss; import ru.betterend.blocks.BlockGlowingMoss;
import ru.betterend.blocks.BlockMossyGlowshroomCap; import ru.betterend.blocks.BlockMossyGlowshroomCap;
import ru.betterend.blocks.BlockGlowingFur;
import ru.betterend.blocks.BlockMossyGlowshroomHymenophore; import ru.betterend.blocks.BlockMossyGlowshroomHymenophore;
import ru.betterend.blocks.BlockMossyGlowshroomSapling; import ru.betterend.blocks.BlockMossyGlowshroomSapling;
import ru.betterend.blocks.BlockOre; import ru.betterend.blocks.BlockOre;
@ -24,7 +23,7 @@ import ru.betterend.blocks.BlockUmbrellaMossTall;
import ru.betterend.blocks.EndStoneSmelter; import ru.betterend.blocks.EndStoneSmelter;
import ru.betterend.blocks.EnderBlock; import ru.betterend.blocks.EnderBlock;
import ru.betterend.blocks.TerminiteBlock; import ru.betterend.blocks.TerminiteBlock;
import ru.betterend.blocks.basis.BlockUpDownPlant; import ru.betterend.blocks.basis.BlockGlowingFur;
import ru.betterend.blocks.complex.WoodenMaterial; import ru.betterend.blocks.complex.WoodenMaterial;
import ru.betterend.tab.CreativeTab; import ru.betterend.tab.CreativeTab;
@ -42,7 +41,7 @@ public class BlockRegistry {
public static final Block MOSSY_GLOWSHROOM_SAPLING = registerBlock("mossy_glowshroom_sapling", new BlockMossyGlowshroomSapling()); public static final Block MOSSY_GLOWSHROOM_SAPLING = registerBlock("mossy_glowshroom_sapling", new BlockMossyGlowshroomSapling());
public static final Block MOSSY_GLOWSHROOM_CAP = registerBlock("mossy_glowshroom_cap", new BlockMossyGlowshroomCap()); public static final Block MOSSY_GLOWSHROOM_CAP = registerBlock("mossy_glowshroom_cap", new BlockMossyGlowshroomCap());
public static final Block MOSSY_GLOWSHROOM_HYMENOPHORE = registerBlock("mossy_glowshroom_hymenophore", new BlockMossyGlowshroomHymenophore()); public static final Block MOSSY_GLOWSHROOM_HYMENOPHORE = registerBlock("mossy_glowshroom_hymenophore", new BlockMossyGlowshroomHymenophore());
public static final Block MOSSY_GLOWSHROOM_FUR = registerBlock("mossy_glowshroom_fur", new BlockGlowingFur(16)); public static final Block MOSSY_GLOWSHROOM_FUR = registerBlock("mossy_glowshroom_fur", new BlockGlowingFur(MOSSY_GLOWSHROOM_SAPLING, 16));
public static final WoodenMaterial MOSSY_GLOWSHROOM = new WoodenMaterial("mossy_glowshroom", MaterialColor.GRAY, MaterialColor.WOOD); public static final WoodenMaterial MOSSY_GLOWSHROOM = new WoodenMaterial("mossy_glowshroom", MaterialColor.GRAY, MaterialColor.WOOD);
// Small Plants // // Small Plants //
@ -53,7 +52,7 @@ public class BlockRegistry {
public static final Block BLUE_VINE_SEED = registerBlock("blue_vine_seed", new BlockBlueVineSeed()); public static final Block BLUE_VINE_SEED = registerBlock("blue_vine_seed", new BlockBlueVineSeed());
public static final Block BLUE_VINE = registerBlockNI("blue_vine", new BlockBlueVine()); public static final Block BLUE_VINE = registerBlockNI("blue_vine", new BlockBlueVine());
public static final Block BLUE_VINE_LANTERN = registerBlock("blue_vine_lantern", new BlockBlueVineLantern()); public static final Block BLUE_VINE_LANTERN = registerBlock("blue_vine_lantern", new BlockBlueVineLantern());
public static final Block BLUE_VINE_FUR = registerBlock("blue_vine_fur", new BlockGlowingFur(3)); public static final Block BLUE_VINE_FUR = registerBlock("blue_vine_fur", new BlockGlowingFur(BLUE_VINE_SEED, 3));
// Ores // // Ores //
public static final Block ENDER_ORE = registerBlock("ender_ore", new BlockOre(ItemRegistry.ENDER_DUST, 1, 3)); public static final Block ENDER_ORE = registerBlock("ender_ore", new BlockOre(ItemRegistry.ENDER_DUST, 1, 3));

View file

@ -1,5 +1,6 @@
package ru.betterend.registry; package ru.betterend.registry;
import ru.betterend.world.features.BlueVineFeature;
import ru.betterend.world.features.DoublePlantFeature; import ru.betterend.world.features.DoublePlantFeature;
import ru.betterend.world.features.EndFeature; import ru.betterend.world.features.EndFeature;
import ru.betterend.world.features.EndLakeFeature; import ru.betterend.world.features.EndLakeFeature;
@ -13,6 +14,7 @@ public class FeatureRegistry {
// Plants // // Plants //
public static final EndFeature UMBRELLA_MOSS = new EndFeature("umbrella_moss", new DoublePlantFeature(BlockRegistry.UMBRELLA_MOSS, BlockRegistry.UMBRELLA_MOSS_TALL, 5), 5); public static final EndFeature UMBRELLA_MOSS = new EndFeature("umbrella_moss", new DoublePlantFeature(BlockRegistry.UMBRELLA_MOSS, BlockRegistry.UMBRELLA_MOSS_TALL, 5), 5);
public static final EndFeature CREEPING_MOSS = new EndFeature("creeping_moss", new SinglePlantFeature(BlockRegistry.CREEPING_MOSS, 5), 5); public static final EndFeature CREEPING_MOSS = new EndFeature("creeping_moss", new SinglePlantFeature(BlockRegistry.CREEPING_MOSS, 5), 5);
public static final EndFeature BLUE_VINE = new EndFeature("blue_vine", new BlueVineFeature(), 1);
// Features // // Features //
public static final EndFeature END_LAKE = EndFeature.makeLakeFeature("end_lake", new EndLakeFeature(), 4); public static final EndFeature END_LAKE = EndFeature.makeLakeFeature("end_lake", new EndLakeFeature(), 4);

View file

@ -6,14 +6,18 @@ import java.util.Random;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.server.world.ServerWorld; import net.minecraft.block.Blocks;
import net.minecraft.state.property.Property; import net.minecraft.state.property.Property;
import net.minecraft.util.BlockMirror; import net.minecraft.util.BlockMirror;
import net.minecraft.util.BlockRotation; import net.minecraft.util.BlockRotation;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockPos.Mutable;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3i; import net.minecraft.util.math.Vec3i;
import net.minecraft.world.WorldAccess; import net.minecraft.world.WorldAccess;
import ru.betterend.blocks.BlockBlueVine;
import ru.betterend.blocks.basis.BlockDoublePlant;
import ru.betterend.blocks.basis.BlockGlowingFur;
public class BlocksHelper { public class BlocksHelper {
public static final int FLAG_UPDATE_BLOCK = 1; public static final int FLAG_UPDATE_BLOCK = 1;
@ -25,6 +29,9 @@ public class BlocksHelper {
public static final int SET_SILENT = FLAG_UPDATE_BLOCK | FLAG_IGNORE_OBSERVERS | FLAG_SEND_CLIENT_CHANGES; public static final int SET_SILENT = FLAG_UPDATE_BLOCK | FLAG_IGNORE_OBSERVERS | FLAG_SEND_CLIENT_CHANGES;
public static final Direction[] HORIZONTAL = new Direction[] { Direction.NORTH, Direction.SOUTH, Direction.EAST, Direction.WEST }; public static final Direction[] HORIZONTAL = new Direction[] { Direction.NORTH, Direction.SOUTH, Direction.EAST, Direction.WEST };
private static final Mutable POS = new Mutable();
protected static final BlockState AIR = Blocks.AIR.getDefaultState();
private static final Vec3i[] OFFSETS = new Vec3i[] { private static final Vec3i[] OFFSETS = new Vec3i[] {
new Vec3i(-1, -1, -1), new Vec3i(-1, -1, 0), new Vec3i(-1, -1, 1), new Vec3i(-1, -1, -1), new Vec3i(-1, -1, 0), new Vec3i(-1, -1, 1),
new Vec3i(-1, 0, -1), new Vec3i(-1, 0, 0), new Vec3i(-1, 0, 1), new Vec3i(-1, 0, -1), new Vec3i(-1, 0, 0), new Vec3i(-1, 0, 1),
@ -69,7 +76,7 @@ public class BlocksHelper {
return state.rotate(mirror.getRotation((Direction) state.get(facing))); return state.rotate(mirror.getRotation((Direction) state.get(facing)));
} }
public static int getLengthDown(ServerWorld world, BlockPos pos, Block block) { public static int getLengthDown(WorldAccess world, BlockPos pos, Block block) {
int count = 1; int count = 1;
while (world.getBlockState(pos.down(count)).getBlock() == block) while (world.getBlockState(pos.down(count)).getBlock() == block)
count++; count++;
@ -105,4 +112,47 @@ public class BlocksHelper {
} }
} }
} }
public static void fixBlocks(WorldAccess world, BlockPos start, BlockPos end) {
synchronized (world) {
BlockState state;
for (int x = start.getX(); x <= end.getX(); x++) {
POS.setX(x);
for (int z = start.getZ(); z <= end.getZ(); z++) {
POS.setZ(z);
for (int y = start.getY(); y <= end.getY(); y++) {
POS.setY(y);
state = world.getBlockState(POS);
if (!state.canPlaceAt(world, POS)) {
// Is blue Vine
if (state.getBlock() instanceof BlockBlueVine) {
while (!state.canPlaceAt(world, POS)) {
BlocksHelper.setWithoutUpdate(world, POS, AIR);
for (Direction dir : HORIZONTAL) {
BlockPos p = POS.offset(dir).up();
state = world.getBlockState(p);
if (state.getBlock() instanceof BlockGlowingFur) {
BlocksHelper.setWithoutUpdate(world, p, AIR);
}
}
POS.setY(POS.getY() + 1);
state = world.getBlockState(POS);
}
}
// Double plants
if (state.getBlock() instanceof BlockDoublePlant) {
BlocksHelper.setWithoutUpdate(world, POS, AIR);
POS.setY(POS.getY() + 1);
BlocksHelper.setWithoutUpdate(world, POS, AIR);
}
// Common plants & blocks
else {
BlocksHelper.setWithoutUpdate(world, POS, AIR);
}
}
}
}
}
}
}
} }

View file

@ -16,6 +16,7 @@ public class BiomeFoggyMushroomland extends EndBiome {
.addFeature(FeatureRegistry.ENDER_ORE) .addFeature(FeatureRegistry.ENDER_ORE)
.addFeature(FeatureRegistry.END_LAKE) .addFeature(FeatureRegistry.END_LAKE)
.addFeature(FeatureRegistry.MOSSY_GLOWSHROOM) .addFeature(FeatureRegistry.MOSSY_GLOWSHROOM)
.addFeature(FeatureRegistry.BLUE_VINE)
.addFeature(FeatureRegistry.UMBRELLA_MOSS) .addFeature(FeatureRegistry.UMBRELLA_MOSS)
.addFeature(FeatureRegistry.CREEPING_MOSS)); .addFeature(FeatureRegistry.CREEPING_MOSS));
} }

View file

@ -0,0 +1,36 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.StructureWorldAccess;
import ru.betterend.blocks.basis.BlockPlantWithAge;
import ru.betterend.registry.BlockRegistry;
import ru.betterend.util.BlocksHelper;
import ru.betterend.util.MHelper;
public class BlueVineFeature extends ScatterFeature {
private boolean small;
public BlueVineFeature() {
super(5);
}
@Override
public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius) {
float d = MHelper.length(center.getX() - blockPos.getX(), center.getZ() - blockPos.getZ()) / radius * 0.6F + random.nextFloat() * 0.4F;
small = d > 0.5F;
return BlockRegistry.BLUE_VINE_SEED.canPlaceAt(AIR, world, blockPos);
}
@Override
public void generate(StructureWorldAccess world, Random random, BlockPos blockPos) {
if (small) {
BlocksHelper.setWithoutUpdate(world, blockPos, BlockRegistry.BLUE_VINE_SEED.getDefaultState().with(BlockPlantWithAge.AGE, random.nextInt(4)));
}
else {
BlockPlantWithAge seed = ((BlockPlantWithAge) BlockRegistry.BLUE_VINE_SEED);
seed.grow(world, random, blockPos);
}
}
}

View file

@ -6,6 +6,7 @@ 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.CountConfig;
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;
@ -72,6 +73,11 @@ public class EndFeature {
return newFeature; return newFeature;
} }
public static EndFeature makeChunkFeature(String name, Feature<DefaultFeatureConfig> feature) {
ConfiguredFeature<?, ?> configured = feature.configure(FeatureConfig.DEFAULT).decorate(Decorator.COUNT.configure(new CountConfig(1)));
return new EndFeature(name, feature, GenerationStep.Feature.LOCAL_MODIFICATIONS, configured);
}
public Feature<?> getFeature() { public Feature<?> getFeature() {
return feature; return feature;
} }

View file

@ -4,7 +4,6 @@ import java.util.Random;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.block.Material;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockPos.Mutable; import net.minecraft.util.math.BlockPos.Mutable;
import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.StructureWorldAccess;
@ -50,14 +49,19 @@ public class EndLakeFeature extends DefaultFeature {
waterLevel = MHelper.min(pos.getY(), waterLevel); waterLevel = MHelper.min(pos.getY(), waterLevel);
BlockState state; BlockState state;
int minX = blockPos.getX() - dist2;
int maxX = blockPos.getX() + dist2;
int minZ = blockPos.getZ() - dist2;
int maxZ = blockPos.getZ() + dist2;
for (int y = blockPos.getY(); y <= blockPos.getY() + 10; y++) { for (int y = blockPos.getY(); y <= blockPos.getY() + 10; y++) {
POS.setY(y); POS.setY(y);
int add = y - blockPos.getY(); int add = y - blockPos.getY();
for (int x = blockPos.getX() - dist2; x <= blockPos.getX() + dist2; x++) { for (int x = minX; x <= maxX; x++) {
POS.setX(x); POS.setX(x);
int x2 = x - blockPos.getX(); int x2 = x - blockPos.getX();
x2 *= x2; x2 *= x2;
for (int z = blockPos.getZ() - dist2; z <= blockPos.getZ() + dist2; z++) { for (int z = minZ; z <= maxZ; z++) {
POS.setZ(z); POS.setZ(z);
int z2 = z - blockPos.getZ(); int z2 = z - blockPos.getZ();
z2 *= z2; z2 *= z2;
@ -65,7 +69,7 @@ public class EndLakeFeature extends DefaultFeature {
r *= r; r *= r;
if (x2 + z2 <= r) { if (x2 + z2 <= r) {
state = world.getBlockState(POS); state = world.getBlockState(POS);
if (state.isIn(BlockTagRegistry.END_GROUND) || !state.canPlaceAt(world, POS) || state.getMaterial().equals(Material.PLANT)/* || state.getBlock() == BlockRegistry.ENDSTONE_DUST*/) { if (state.isIn(BlockTagRegistry.END_GROUND)) {
BlocksHelper.setWithoutUpdate(world, POS, AIR); BlocksHelper.setWithoutUpdate(world, POS, AIR);
} }
pos = POS.down(); pos = POS.down();
@ -79,11 +83,6 @@ public class EndLakeFeature extends DefaultFeature {
else else
BlocksHelper.setWithoutUpdate(world, pos, BlockRegistry.ENDSTONE_DUST.getDefaultState()); BlocksHelper.setWithoutUpdate(world, pos, BlockRegistry.ENDSTONE_DUST.getDefaultState());
} }
/*pos = POS.up();
while (world.getBlockState(pos).isIn(BlockTagRegistry.END_GROUND) || !state.canPlaceAt(world, pos) || state.getBlock() == BlockRegistry.ENDSTONE_DUST) {
BlocksHelper.setWithoutUpdate(world, pos, AIR);
pos = pos.up();
}*/
} }
} }
} }
@ -108,7 +107,7 @@ public class EndLakeFeature extends DefaultFeature {
rb *= rb; rb *= rb;
if (y2 + x2 + z2 <= r) { if (y2 + x2 + z2 <= r) {
state = world.getBlockState(POS); state = world.getBlockState(POS);
if (state.isIn(BlockTagRegistry.END_GROUND) || !state.canPlaceAt(world, POS) || state.getBlock() == BlockRegistry.ENDSTONE_DUST) { if (state.isIn(BlockTagRegistry.END_GROUND) || state.getBlock() == BlockRegistry.ENDSTONE_DUST) {
BlocksHelper.setWithoutUpdate(world, POS, y < waterLevel ? WATER : AIR); BlocksHelper.setWithoutUpdate(world, POS, y < waterLevel ? WATER : AIR);
} }
pos = POS.down(); pos = POS.down();
@ -139,6 +138,8 @@ public class EndLakeFeature extends DefaultFeature {
} }
} }
BlocksHelper.fixBlocks(world, new BlockPos(minX - 2, waterLevel - 2, minZ - 2), new BlockPos(maxX + 2, blockPos.getY() + 20, maxZ + 2));
return true; return true;
} }
} }

View file

@ -17,7 +17,7 @@ import net.minecraft.world.StructureWorldAccess;
import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.chunk.ChunkGenerator;
import net.minecraft.world.gen.feature.DefaultFeatureConfig; import net.minecraft.world.gen.feature.DefaultFeatureConfig;
import ru.betterend.blocks.BlockMossyGlowshroomCap; import ru.betterend.blocks.BlockMossyGlowshroomCap;
import ru.betterend.blocks.BlockGlowingFur; import ru.betterend.blocks.basis.BlockGlowingFur;
import ru.betterend.noise.OpenSimplexNoise; import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.BlockRegistry; import ru.betterend.registry.BlockRegistry;
import ru.betterend.registry.BlockTagRegistry; import ru.betterend.registry.BlockTagRegistry;
@ -77,10 +77,6 @@ public class MossyGlowshroomFeature extends DefaultFeature {
return BlockRegistry.MOSSY_GLOWSHROOM.log.getDefaultState(); return BlockRegistry.MOSSY_GLOWSHROOM.log.getDefaultState();
}); });
Vector3f pos = spline.get(spline.size() - 1); Vector3f pos = spline.get(spline.size() - 1);
CENTER.set(blockPos.getX(), 0, blockPos.getZ());
HEAD_POS.setTranslate(pos.getX(), pos.getY(), pos.getZ());
ROOTS_ROT.setAngle(random.nextFloat() * MHelper.PI2);
FUNCTION.setSourceA(sdf);
float scale = MHelper.randRange(0.75F, 1.1F, random); float scale = MHelper.randRange(0.75F, 1.1F, random);
Vector3f vec = spline.get(0); Vector3f vec = spline.get(0);
@ -112,6 +108,11 @@ public class MossyGlowshroomFeature extends DefaultFeature {
} }
BlocksHelper.setWithoutUpdate(world, blockPos, AIR); BlocksHelper.setWithoutUpdate(world, blockPos, AIR);
CENTER.set(blockPos.getX(), 0, blockPos.getZ());
HEAD_POS.setTranslate(pos.getX(), pos.getY(), pos.getZ());
ROOTS_ROT.setAngle(random.nextFloat() * MHelper.PI2);
FUNCTION.setSourceA(sdf);
Set<BlockPos> blocks = new SDFScale() Set<BlockPos> blocks = new SDFScale()
.setScale(scale) .setScale(scale)
.setSource(FUNCTION) .setSource(FUNCTION)
@ -187,7 +188,7 @@ public class MossyGlowshroomFeature extends DefaultFeature {
FUNCTION = new SDFSmoothUnion().setRadius(4).setSourceB(new SDFUnion().setSourceA(HEAD_POS).setSourceB(ROOTS_ROT)); FUNCTION = new SDFSmoothUnion().setRadius(4).setSourceB(new SDFUnion().setSourceA(HEAD_POS).setSourceB(ROOTS_ROT));
REPLACE = (state) -> { REPLACE = (state) -> {
if (state.getBlock() != Blocks.END_STONE && state.isIn(BlockTagRegistry.END_GROUND)) { if (state.isIn(BlockTagRegistry.END_GROUND)) {
return true; return true;
} }
if (state.getMaterial().equals(Material.PLANT)) { if (state.getMaterial().equals(Material.PLANT)) {

View file

@ -11,8 +11,7 @@
"CraftingScreenHandlerMixin", "CraftingScreenHandlerMixin",
"GenerationSettingsMixin", "GenerationSettingsMixin",
"LivingEntityMixin", "LivingEntityMixin",
"BiomeMixin", "BiomeMixin"
"TagAccessor"
], ],
"injectors": { "injectors": {
"defaultRequire": 1 "defaultRequire": 1