Fixes, tree WIP
This commit is contained in:
parent
f18cf5c073
commit
58124139d5
7 changed files with 90 additions and 17 deletions
|
@ -17,7 +17,7 @@ import ru.betterend.blocks.basis.BlockBase;
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
|
|
||||||
public class BlockBlueVineLantern extends BlockBase {
|
public class BlockBlueVineLantern extends BlockBase {
|
||||||
public static final BooleanProperty NATURAL = BooleanProperty.of("natural");
|
public static final BooleanProperty NATURAL = BlockProperties.NATURAL;
|
||||||
|
|
||||||
public BlockBlueVineLantern() {
|
public BlockBlueVineLantern() {
|
||||||
super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sounds(BlockSoundGroup.WART_BLOCK).luminance(15));
|
super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sounds(BlockSoundGroup.WART_BLOCK).luminance(15));
|
||||||
|
|
|
@ -14,6 +14,7 @@ public class BlockProperties {
|
||||||
public static final BooleanProperty HAS_LIGHT = BooleanProperty.of("has_light");
|
public static final BooleanProperty HAS_LIGHT = BooleanProperty.of("has_light");
|
||||||
public static final BooleanProperty ACTIVE = BooleanProperty.of("active");
|
public static final BooleanProperty ACTIVE = BooleanProperty.of("active");
|
||||||
public static final IntProperty ROTATION = IntProperty.of("rotation", 0, 3);
|
public static final IntProperty ROTATION = IntProperty.of("rotation", 0, 3);
|
||||||
|
public static final BooleanProperty NATURAL = BooleanProperty.of("natural");
|
||||||
|
|
||||||
public static enum TripleShape implements StringIdentifiable {
|
public static enum TripleShape implements StringIdentifiable {
|
||||||
TOP("top"),
|
TOP("top"),
|
||||||
|
|
|
@ -5,12 +5,25 @@ 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.MaterialColor;
|
import net.minecraft.block.MaterialColor;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.Items;
|
||||||
|
import net.minecraft.sound.SoundCategory;
|
||||||
|
import net.minecraft.sound.SoundEvents;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.state.StateManager;
|
||||||
import net.minecraft.state.property.BooleanProperty;
|
import net.minecraft.state.property.BooleanProperty;
|
||||||
|
import net.minecraft.util.ActionResult;
|
||||||
|
import net.minecraft.util.Hand;
|
||||||
|
import net.minecraft.util.hit.BlockHitResult;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
import ru.betterend.blocks.basis.BlockBase;
|
import ru.betterend.blocks.basis.BlockBase;
|
||||||
|
import ru.betterend.registry.EndBlocks;
|
||||||
|
import ru.betterend.registry.EndItems;
|
||||||
|
import ru.betterend.util.BlocksHelper;
|
||||||
|
|
||||||
public class BlockUmbrellaTreeCluster extends BlockBase {
|
public class BlockUmbrellaTreeCluster extends BlockBase {
|
||||||
public static final BooleanProperty NATURAL = BooleanProperty.of("natural");
|
public static final BooleanProperty NATURAL = BlockProperties.NATURAL;
|
||||||
|
|
||||||
public BlockUmbrellaTreeCluster() {
|
public BlockUmbrellaTreeCluster() {
|
||||||
super(FabricBlockSettings.copyOf(Blocks.NETHER_WART_BLOCK)
|
super(FabricBlockSettings.copyOf(Blocks.NETHER_WART_BLOCK)
|
||||||
|
@ -23,4 +36,20 @@ public class BlockUmbrellaTreeCluster extends BlockBase {
|
||||||
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
||||||
stateManager.add(NATURAL);
|
stateManager.add(NATURAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
||||||
|
ItemStack stack = player.getMainHandStack();
|
||||||
|
if (stack.getItem() == Items.GLASS_BOTTLE) {
|
||||||
|
if (!player.isCreative()) {
|
||||||
|
stack.decrement(1);
|
||||||
|
}
|
||||||
|
stack = new ItemStack(EndItems.UMBRELLA_CLUSTER_JUICE);
|
||||||
|
player.giveItemStack(stack);
|
||||||
|
world.playSound(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, SoundEvents.ITEM_BOTTLE_FILL, SoundCategory.BLOCKS, 1, 1, false);
|
||||||
|
BlocksHelper.setWithUpdate(world, pos, EndBlocks.UMBRELLA_TREE_CLUSTER_EMPTY.getDefaultState().with(NATURAL, state.get(NATURAL)));
|
||||||
|
return ActionResult.SUCCESS;
|
||||||
|
}
|
||||||
|
return ActionResult.FAIL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ import ru.betterend.registry.EndBlocks;
|
||||||
import ru.betterend.util.BlocksHelper;
|
import ru.betterend.util.BlocksHelper;
|
||||||
|
|
||||||
public class BlockUmbrellaTreeClusterEmpty extends BlockBase {
|
public class BlockUmbrellaTreeClusterEmpty extends BlockBase {
|
||||||
public static final BooleanProperty NATURAL = BooleanProperty.of("natural");
|
public static final BooleanProperty NATURAL = BlockProperties.NATURAL;
|
||||||
|
|
||||||
public BlockUmbrellaTreeClusterEmpty() {
|
public BlockUmbrellaTreeClusterEmpty() {
|
||||||
super(FabricBlockSettings.copyOf(Blocks.NETHER_WART_BLOCK)
|
super(FabricBlockSettings.copyOf(Blocks.NETHER_WART_BLOCK)
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class EndStoneSmelterBlockEntity extends LockableContainerBlockEntity imp
|
||||||
private static final int[] TOP_SLOTS = new int[] { 0, 1 };
|
private static final int[] TOP_SLOTS = new int[] { 0, 1 };
|
||||||
private static final int[] BOTTOM_SLOTS = new int[] { 2, 3 };
|
private static final int[] BOTTOM_SLOTS = new int[] { 2, 3 };
|
||||||
private static final int[] SIDE_SLOTS = new int[] { 3 };
|
private static final int[] SIDE_SLOTS = new int[] { 3 };
|
||||||
private static final Map<Item, Integer> availableFuels = Maps.newHashMap();
|
private static final Map<Item, Integer> AVAILABLE_FUELS = Maps.newHashMap();
|
||||||
|
|
||||||
private final Object2IntOpenHashMap<Identifier> recipesUsed;
|
private final Object2IntOpenHashMap<Identifier> recipesUsed;
|
||||||
protected DefaultedList<ItemStack> inventory;
|
protected DefaultedList<ItemStack> inventory;
|
||||||
|
@ -404,7 +404,7 @@ public class EndStoneSmelterBlockEntity extends LockableContainerBlockEntity imp
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
Item item = fuel.getItem();
|
Item item = fuel.getItem();
|
||||||
return availableFuels.getOrDefault(item, 0);
|
return AVAILABLE_FUELS.getOrDefault(item, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -454,14 +454,14 @@ public class EndStoneSmelterBlockEntity extends LockableContainerBlockEntity imp
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canUseAsFuel(ItemStack stack) {
|
public static boolean canUseAsFuel(ItemStack stack) {
|
||||||
return availableFuels.containsKey(stack.getItem());
|
return AVAILABLE_FUELS.containsKey(stack.getItem());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerFuel(ItemConvertible fuel, int time) {
|
public static void registerFuel(ItemConvertible fuel, int time) {
|
||||||
if (availableFuels.containsKey(fuel)) {
|
if (AVAILABLE_FUELS.containsKey(fuel)) {
|
||||||
availableFuels.replace(fuel.asItem(), time);
|
AVAILABLE_FUELS.replace(fuel.asItem(), time);
|
||||||
} else {
|
} else {
|
||||||
availableFuels.put(fuel.asItem(), time);
|
AVAILABLE_FUELS.put(fuel.asItem(), time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -471,6 +471,6 @@ public class EndStoneSmelterBlockEntity extends LockableContainerBlockEntity imp
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<Item, Integer> availableFuels() {
|
public static Map<Item, Integer> availableFuels() {
|
||||||
return availableFuels;
|
return AVAILABLE_FUELS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.block.Material;
|
||||||
import net.minecraft.client.util.math.Vector3f;
|
import net.minecraft.client.util.math.Vector3f;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.world.StructureWorldAccess;
|
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;
|
||||||
|
@ -17,6 +18,9 @@ import ru.betterend.registry.EndTags;
|
||||||
import ru.betterend.util.MHelper;
|
import ru.betterend.util.MHelper;
|
||||||
import ru.betterend.util.SplineHelper;
|
import ru.betterend.util.SplineHelper;
|
||||||
import ru.betterend.util.sdf.SDF;
|
import ru.betterend.util.sdf.SDF;
|
||||||
|
import ru.betterend.util.sdf.operator.SDFSmoothUnion;
|
||||||
|
import ru.betterend.util.sdf.operator.SDFTranslate;
|
||||||
|
import ru.betterend.util.sdf.operator.SDFUnion;
|
||||||
import ru.betterend.world.features.DefaultFeature;
|
import ru.betterend.world.features.DefaultFeature;
|
||||||
|
|
||||||
public class BigEtherTreeFeature extends DefaultFeature {
|
public class BigEtherTreeFeature extends DefaultFeature {
|
||||||
|
@ -26,20 +30,55 @@ public class BigEtherTreeFeature extends DefaultFeature {
|
||||||
|
|
||||||
BlockState log = Integrations.BYG.getDefaultState("ether_log");
|
BlockState log = Integrations.BYG.getDefaultState("ether_log");
|
||||||
BlockState wood = Integrations.BYG.getDefaultState("ether_wood");
|
BlockState wood = Integrations.BYG.getDefaultState("ether_wood");
|
||||||
BlockState leaves = Integrations.BYG.getDefaultState("ether_leaves");
|
//BlockState leaves = Integrations.BYG.getDefaultState("ether_leaves");
|
||||||
|
Function<BlockPos, BlockState> splinePlacer = (bpos) -> { return log; };
|
||||||
|
Function<BlockState, Boolean> replace = (state) -> {
|
||||||
|
return state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT) || state.getMaterial().isReplaceable();
|
||||||
|
};
|
||||||
|
|
||||||
int height = MHelper.randRange(20, 30, random);
|
int height = MHelper.randRange(40, 60, random);
|
||||||
List<Vector3f> trunk = SplineHelper.makeSpline(0, 0, 0, 0, height, 0, height / 2);
|
List<Vector3f> trunk = SplineHelper.makeSpline(0, 0, 0, 0, height, 0, height / 4);
|
||||||
SplineHelper.offsetParts(trunk, random, 2F, 0, 2F);
|
SplineHelper.offsetParts(trunk, random, 2F, 0, 2F);
|
||||||
SDF sdf = SplineHelper.buildSDF(trunk, 2.3F, 0.8F, (bpos) -> { return log;});
|
SDF sdf = SplineHelper.buildSDF(trunk, 2.3F, 0.8F, splinePlacer);
|
||||||
|
|
||||||
|
int count = height / 10;
|
||||||
|
for (int i = 1; i < count; i++) {
|
||||||
|
float splinePos = (float) i / count;
|
||||||
|
float startAngle = random.nextFloat() * MHelper.PI2;
|
||||||
|
float length = (1 - splinePos) * height * 0.4F;
|
||||||
|
int points = (int) (length / 3);
|
||||||
|
List<Vector3f> branch = SplineHelper.makeSpline(0, 0, 0, length, 0, 0, points < 2 ? 2 : points);
|
||||||
|
SplineHelper.powerOffset(branch, length * 0.5F, 1.5F);
|
||||||
|
int rotCount = MHelper.randRange(5, 7, random);
|
||||||
|
float startRad = MathHelper.lerp(splinePos, 2.3F, 0.8F) * 0.8F;
|
||||||
|
Vector3f start = SplineHelper.getPos(trunk, splinePos * (trunk.size() - 1));
|
||||||
|
System.out.println(start + " " + startRad + " " + branch.size());
|
||||||
|
for (int j = 0; j < rotCount; j++) {
|
||||||
|
float angle = startAngle + (float) j / rotCount * MHelper.PI2;
|
||||||
|
List<Vector3f> br = SplineHelper.copySpline(branch);
|
||||||
|
SplineHelper.offsetParts(br, random, 0, 1, 1);
|
||||||
|
SplineHelper.rotateSpline(br, angle);
|
||||||
|
//SDF branchSDF = SplineHelper.buildSDF(br, startRad, 0.5F, splinePlacer);
|
||||||
|
//branchSDF = new SDFTranslate().setTranslate(start.getX(), start.getY(), start.getZ()).setSource(branchSDF);
|
||||||
|
//sdf = new SDFSmoothUnion().setRadius(2).setSourceA(sdf).setSourceB(branchSDF);
|
||||||
|
//sdf = new SDFUnion().setSourceA(sdf).setSourceB(branchSDF);
|
||||||
|
SplineHelper.fillSpline(br, world, wood, pos, replace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sdf.setReplaceFunction((state) -> {
|
sdf.setReplaceFunction((state) -> {
|
||||||
return state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT) || state.getMaterial().isReplaceable();
|
return state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT) || state.getMaterial().isReplaceable();
|
||||||
|
}).setPostProcess((info) -> {
|
||||||
|
if (info.getState().equals(log) && (!info.getStateUp().equals(log) || !info.getStateDown().equals(log))) {
|
||||||
|
return wood;
|
||||||
|
}
|
||||||
|
return info.getState();
|
||||||
}).fillRecursive(world, pos);
|
}).fillRecursive(world, pos);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void makeLeavesSphere(StructureWorldAccess world, BlockPos pos, BlockState leaves, Function<BlockState, Boolean> ignore) {
|
//private void makeLeavesSphere(StructureWorldAccess world, BlockPos pos, BlockState leaves, Function<BlockState, Boolean> ignore) {
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
|
@ -253,6 +253,10 @@ public class SplineHelper {
|
||||||
|
|
||||||
public static Vector3f getPos(List<Vector3f> spline, float index) {
|
public static Vector3f getPos(List<Vector3f> spline, float index) {
|
||||||
int i = (int) index;
|
int i = (int) index;
|
||||||
|
int last = spline.size() - 1;
|
||||||
|
if (i >= last) {
|
||||||
|
return spline.get(last);
|
||||||
|
}
|
||||||
float delta = index - i;
|
float delta = index - i;
|
||||||
Vector3f p1 = spline.get(i);
|
Vector3f p1 = spline.get(i);
|
||||||
Vector3f p2 = spline.get(i + 1);
|
Vector3f p2 = spline.get(i + 1);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue