From 2e56ad67147b58255dc391c7dd7c553e939e77f5 Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Wed, 8 Dec 2021 16:57:23 +0100 Subject: [PATCH 1/2] Pillar of Jank - Added connectivity restrictions to pillar blocks - Fixed reversed uvs on z-axis pillars - Fluid Pipes now require twice the amount of Copper --- src/generated/resources/.cache/cache | 4 +- .../recipes/crafting/kinetics/fluid_pipe.json | 2 +- .../palettes/ConnectedPillarBlock.java | 192 ++++++++++++++++++ .../content/palettes/PaletteBlockPattern.java | 5 +- .../connected/RotatedPillarCTBehaviour.java | 30 ++- .../data/recipe/StandardRecipeGen.java | 2 +- 6 files changed, 226 insertions(+), 9 deletions(-) create mode 100644 src/main/java/com/simibubi/create/content/palettes/ConnectedPillarBlock.java diff --git a/src/generated/resources/.cache/cache b/src/generated/resources/.cache/cache index e341666ad..8a359e80c 100644 --- a/src/generated/resources/.cache/cache +++ b/src/generated/resources/.cache/cache @@ -2125,7 +2125,7 @@ d080b1b25e5bc8baf5aee68691b08c7f12ece3b0 assets/create/models/item/windmill_bear a80fb25a0b655e76be986b5b49fcb0f03461a1ab assets/create/models/item/zinc_nugget.json b1689617190c05ef34bd18456b0c7ae09bb3210f assets/create/models/item/zinc_ore.json 5049f72c327a88f175f6f9425909e098fc711100 assets/create/sounds.json -0f1b4b980afba9bf2caf583b88e261bba8b10313 data/create/advancements/aesthetics.json +5d0cc4c0255dc241e61c173b31ddca70c88d08e4 data/create/advancements/aesthetics.json 613e64b44bed959da899fdd54c1cacb227fb33f2 data/create/advancements/andesite_alloy.json 81885c6bfb85792c88aaa7c9b70f58832945d31f data/create/advancements/andesite_casing.json 83c046bd200623933545c9e4326f782fb02c87fa data/create/advancements/arm_blaze_burner.json @@ -3930,7 +3930,7 @@ ad1c3ce1e98b8483512bdd754f2e5930c7b3ae85 data/create/recipes/crafting/kinetics/d 73cd487885be8d5190f24319b4a927b8e34c21cd data/create/recipes/crafting/kinetics/encased_chain_drive.json b07496e4ba5bc56a2c5a395b612c68ba21328867 data/create/recipes/crafting/kinetics/encased_fan.json 0dd0cc11eaa6789fc612af3231ed247893852178 data/create/recipes/crafting/kinetics/filter.json -371a80e2a93d9fb68b892db5685aaeea55f34a11 data/create/recipes/crafting/kinetics/fluid_pipe.json +9df7da02bcae5ae7c3b441ff0299f75394133145 data/create/recipes/crafting/kinetics/fluid_pipe.json 284e8554d7285989a1684a5e14c72063d152cc9e data/create/recipes/crafting/kinetics/fluid_tank.json 3dad2a849796df268cd3a06ed37376f2cc529957 data/create/recipes/crafting/kinetics/fluid_valve.json 84153bd478c0e63a04c77579d6595043f604b7ab data/create/recipes/crafting/kinetics/furnace_minecart_from_contraption_cart.json diff --git a/src/generated/resources/data/create/recipes/crafting/kinetics/fluid_pipe.json b/src/generated/resources/data/create/recipes/crafting/kinetics/fluid_pipe.json index 1424a0d14..c72baad85 100644 --- a/src/generated/resources/data/create/recipes/crafting/kinetics/fluid_pipe.json +++ b/src/generated/resources/data/create/recipes/crafting/kinetics/fluid_pipe.json @@ -13,6 +13,6 @@ }, "result": { "item": "create:fluid_pipe", - "count": 8 + "count": 4 } } \ No newline at end of file diff --git a/src/main/java/com/simibubi/create/content/palettes/ConnectedPillarBlock.java b/src/main/java/com/simibubi/create/content/palettes/ConnectedPillarBlock.java new file mode 100644 index 000000000..5d0f1aa16 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/palettes/ConnectedPillarBlock.java @@ -0,0 +1,192 @@ +package com.simibubi.create.content.palettes; + +import java.util.Random; + +import com.simibubi.create.foundation.utility.Iterate; + +import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos.MutableBlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.Axis; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.TickList; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition.Builder; +import net.minecraft.world.level.block.state.properties.BooleanProperty; + +public class ConnectedPillarBlock extends LayeredBlock { + + public static final BooleanProperty NORTH = BooleanProperty.create("north"); + public static final BooleanProperty SOUTH = BooleanProperty.create("south"); + public static final BooleanProperty EAST = BooleanProperty.create("east"); + public static final BooleanProperty WEST = BooleanProperty.create("west"); + + public ConnectedPillarBlock(Properties p_55926_) { + super(p_55926_); + registerDefaultState(defaultBlockState().setValue(NORTH, false) + .setValue(WEST, false) + .setValue(EAST, false) + .setValue(SOUTH, false)); + } + + @Override + protected void createBlockStateDefinition(Builder pBuilder) { + super.createBlockStateDefinition(pBuilder.add(NORTH, SOUTH, EAST, WEST)); + } + + @Override + public BlockState getStateForPlacement(BlockPlaceContext pContext) { + BlockState state = super.getStateForPlacement(pContext); + return updateColumn(pContext.getLevel(), pContext.getClickedPos(), state, true); + } + + private BlockState updateColumn(Level level, BlockPos pos, BlockState state, boolean present) { + MutableBlockPos currentPos = new MutableBlockPos(); + Axis axis = state.getValue(AXIS); + for (Direction connection : Iterate.directions) { + if (connection.getAxis() == axis) + continue; + + boolean connect = true; + Move: for (Direction movement : Iterate.directionsInAxis(axis)) { + currentPos.set(pos); + for (int i = 0; i < 1000; i++) { + if (!level.isAreaLoaded(currentPos, 1)) + break; + + BlockState other1 = currentPos.equals(pos) ? state : level.getBlockState(currentPos); + BlockState other2 = level.getBlockState(currentPos.relative(connection)); + boolean col1 = canConnect(state, other1); + boolean col2 = canConnect(state, other2); + currentPos.move(movement); + + if (!col1 && !col2) + break; + if (col1 && col2) + continue; + + connect = false; + break Move; + } + } + state = setConnection(state, connection, connect); + } + return state; + } + + @Override + public void onPlace(BlockState pState, Level pLevel, BlockPos pPos, BlockState pOldState, boolean pIsMoving) { + if (pOldState.getBlock() == this) + return; + TickList blockTicks = pLevel.getBlockTicks(); + if (!blockTicks.hasScheduledTick(pPos, this)) + blockTicks.scheduleTick(pPos, this, 1); + } + + @Override + public void tick(BlockState pState, ServerLevel pLevel, BlockPos pPos, Random pRandom) { + if (pState.getBlock() != this) + return; + BlockPos belowPos = pPos.relative(Direction.fromAxisAndDirection(pState.getValue(AXIS), AxisDirection.NEGATIVE)); + BlockState belowState = pLevel.getBlockState(belowPos); + if (!canConnect(pState, belowState)) + pLevel.setBlock(pPos, updateColumn(pLevel, pPos, pState, true), 3); + } + + @Override + public BlockState updateShape(BlockState state, Direction pDirection, BlockState pNeighborState, + LevelAccessor pLevel, BlockPos pCurrentPos, BlockPos pNeighborPos) { + if (!canConnect(state, pNeighborState)) + return setConnection(state, pDirection, false); + if (pDirection.getAxis() == state.getValue(AXIS)) + return withPropertiesOf(pNeighborState); + + return setConnection(state, pDirection, getConnection(pNeighborState, pDirection.getOpposite())); + } + + protected boolean canConnect(BlockState state, BlockState other) { + return other.getBlock() == this && state.getValue(AXIS) == other.getValue(AXIS); + } + + @Override + public void onRemove(BlockState pState, Level pLevel, BlockPos pPos, BlockState pNewState, boolean pIsMoving) { + if (pIsMoving || pNewState.getBlock() == this) + return; + for (Direction d : Iterate.directionsInAxis(pState.getValue(AXIS))) { + BlockPos relative = pPos.relative(d); + BlockState adjacent = pLevel.getBlockState(relative); + if (canConnect(pState, adjacent)) + pLevel.setBlock(relative, updateColumn(pLevel, relative, adjacent, false), 3); + } + } + + public static boolean getConnection(BlockState state, Direction side) { + BooleanProperty property = connection(state.getValue(AXIS), side); + return property != null && state.getValue(property); + } + + public static BlockState setConnection(BlockState state, Direction side, boolean connect) { + BooleanProperty property = connection(state.getValue(AXIS), side); + if (property != null) + state = state.setValue(property, connect); + return state; + } + + public static BooleanProperty connection(Axis axis, Direction side) { + if (side.getAxis() == axis) + return null; + + if (axis == Axis.X) { + switch (side) { + case UP: + return EAST; + case NORTH: + return NORTH; + case SOUTH: + return SOUTH; + case DOWN: + return WEST; + default: + return null; + } + } + + if (axis == Axis.Y) { + switch (side) { + case EAST: + return EAST; + case NORTH: + return NORTH; + case SOUTH: + return SOUTH; + case WEST: + return WEST; + default: + return null; + } + } + + if (axis == Axis.Z) { + switch (side) { + case UP: + return WEST; + case WEST: + return SOUTH; + case EAST: + return NORTH; + case DOWN: + return EAST; + default: + return null; + } + } + + return null; + } + +} diff --git a/src/main/java/com/simibubi/create/content/palettes/PaletteBlockPattern.java b/src/main/java/com/simibubi/create/content/palettes/PaletteBlockPattern.java index 58804c2dc..9c1ce95ea 100644 --- a/src/main/java/com/simibubi/create/content/palettes/PaletteBlockPattern.java +++ b/src/main/java/com/simibubi/create/content/palettes/PaletteBlockPattern.java @@ -54,7 +54,7 @@ public class PaletteBlockPattern { .connectedTextures(v -> new HorizontalCTBehaviour(ct(v, CTs.LAYERED), ct(v, CTs.CAP))), PILLAR = create("pillar", SUFFIX).blockStateFactory(p -> p::pillar) - .block(LayeredBlock::new) + .block(ConnectedPillarBlock::new) .textures("pillar", "cap") .connectedTextures(v -> new RotatedPillarCTBehaviour(ct(v, CTs.PILLAR), ct(v, CTs.CAP))) @@ -212,7 +212,8 @@ public class PaletteBlockPattern { .rotationX(90) .rotationY(axis == Axis.X ? 90 : 0) .build(); - }, BlockStateProperties.WATERLOGGED); + }, BlockStateProperties.WATERLOGGED, ConnectedPillarBlock.NORTH, ConnectedPillarBlock.SOUTH, + ConnectedPillarBlock.EAST, ConnectedPillarBlock.WEST); } public IBlockStateProvider cubeColumn(String variant) { diff --git a/src/main/java/com/simibubi/create/foundation/block/connected/RotatedPillarCTBehaviour.java b/src/main/java/com/simibubi/create/foundation/block/connected/RotatedPillarCTBehaviour.java index 4bdd7edf4..bf069d3ce 100644 --- a/src/main/java/com/simibubi/create/foundation/block/connected/RotatedPillarCTBehaviour.java +++ b/src/main/java/com/simibubi/create/foundation/block/connected/RotatedPillarCTBehaviour.java @@ -1,5 +1,6 @@ package com.simibubi.create.foundation.block.connected; +import com.simibubi.create.content.palettes.ConnectedPillarBlock; import com.simibubi.create.content.palettes.LayeredBlock; import net.minecraft.core.BlockPos; @@ -17,8 +18,31 @@ public class RotatedPillarCTBehaviour extends HorizontalCTBehaviour { @Override public boolean connectsTo(BlockState state, BlockState other, BlockAndTintGetter reader, BlockPos pos, - BlockPos otherPos, Direction face) { - return state == other && super.connectsTo(state, other, reader, pos, otherPos, face); + BlockPos otherPos, Direction face, Direction primaryOffset, Direction secondaryOffset) { + if (other.getBlock() != state.getBlock()) + return false; + Axis stateAxis = state.getValue(LayeredBlock.AXIS); + if (other.getValue(LayeredBlock.AXIS) != stateAxis) + return false; + if (isBeingBlocked(state, reader, pos, otherPos, face)) + return false; + if (primaryOffset != null && primaryOffset.getAxis() != stateAxis + && !ConnectedPillarBlock.getConnection(state, primaryOffset)) + return false; + if (secondaryOffset != null && secondaryOffset.getAxis() != stateAxis) { + if (!ConnectedPillarBlock.getConnection(state, secondaryOffset)) + return false; + if (!ConnectedPillarBlock.getConnection(other, secondaryOffset.getOpposite())) + return false; + } + return true; + } + + @Override + protected boolean isBeingBlocked(BlockState state, BlockAndTintGetter reader, BlockPos pos, BlockPos otherPos, + Direction face) { + return state.getValue(LayeredBlock.AXIS) == face.getAxis() + && super.isBeingBlocked(state, reader, pos, otherPos, face); } @Override @@ -42,7 +66,7 @@ public class RotatedPillarCTBehaviour extends HorizontalCTBehaviour { if (axis == Axis.X && face == Direction.NORTH) return false; if (axis == Axis.Z && face == Direction.WEST) - return true; + return false; return super.reverseUVsVertically(state, face); } diff --git a/src/main/java/com/simibubi/create/foundation/data/recipe/StandardRecipeGen.java b/src/main/java/com/simibubi/create/foundation/data/recipe/StandardRecipeGen.java index e0fb811bf..2bba667d5 100644 --- a/src/main/java/com/simibubi/create/foundation/data/recipe/StandardRecipeGen.java +++ b/src/main/java/com/simibubi/create/foundation/data/recipe/StandardRecipeGen.java @@ -496,7 +496,7 @@ public class StandardRecipeGen extends CreateRecipeProvider { .pattern("SSS") .pattern("PCP")), - FLUID_PIPE = create(AllBlocks.FLUID_PIPE).returns(8) + FLUID_PIPE = create(AllBlocks.FLUID_PIPE).returns(4) .unlockedBy(I::copper) .viaShaped(b -> b.define('S', I.copperSheet()) .define('C', I.copper()) From 8eea60ddee11f0d4967bc6f4ca89f5e3689ff007 Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Wed, 8 Dec 2021 22:44:00 +0100 Subject: [PATCH 2/2] Tuff on the Eyes - Slightly reduced the amount of block types represented in one batch of ore layers --- .../foundation/worldgen/AllLayerPatterns.java | 37 +++++++++++-------- .../foundation/worldgen/LayerPattern.java | 6 ++- .../worldgen/LayeredOreFeature.java | 7 ---- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/simibubi/create/foundation/worldgen/AllLayerPatterns.java b/src/main/java/com/simibubi/create/foundation/worldgen/AllLayerPatterns.java index b97432db5..4908780fe 100644 --- a/src/main/java/com/simibubi/create/foundation/worldgen/AllLayerPatterns.java +++ b/src/main/java/com/simibubi/create/foundation/worldgen/AllLayerPatterns.java @@ -15,10 +15,12 @@ public class AllLayerPatterns { .layer(l -> l.weight(2) .block(AllPaletteStoneTypes.CRIMSITE.getBaseBlock()) .size(1, 3)) - .layer(l -> l.weight(2) + .layer(l -> l.weight(1) .block(Blocks.TUFF) - .block(Blocks.GRANITE) - .size(1, 2)) + .block(Blocks.DEEPSLATE) + .size(2, 2)) + .layer(l -> l.weight(1) + .blocks(Blocks.DEEPSLATE, Blocks.TUFF)) .layer(l -> l.weight(1) .block(AllPaletteStoneTypes.LIMESTONE.getBaseBlock())) .build(); @@ -29,46 +31,47 @@ public class AllLayerPatterns { .layer(l -> l.weight(2) .block(AllPaletteStoneTypes.ASURINE.getBaseBlock()) .size(1, 3)) - .layer(l -> l.weight(2) + .layer(l -> l.weight(1) .block(Blocks.TUFF) - .block(Blocks.SMOOTH_BASALT) + .block(Blocks.DEEPSLATE) .size(1, 2)) .layer(l -> l.weight(1) - .block(Blocks.DIORITE) + .blocks(Blocks.DEEPSLATE, Blocks.TUFF)) + .layer(l -> l.weight(1) .block(Blocks.CALCITE)) .build(); public static NonNullSupplier OCHRESTONE = () -> LayerPattern.builder() .layer(l -> l.weight(1) - .block(Blocks.ANDESITE) .passiveBlock()) .layer(l -> l.weight(2) .block(AllPaletteStoneTypes.OCHRUM.getBaseBlock()) .size(1, 3)) .layer(l -> l.weight(2) .block(Blocks.TUFF) - .block(Blocks.SMOOTH_BASALT) + .block(Blocks.DEEPSLATE) .size(1, 2)) .layer(l -> l.weight(2) .block(Blocks.DRIPSTONE_BLOCK) - .block(Blocks.GRANITE) .size(1, 2)) .build(); public static NonNullSupplier MALACHITE = () -> LayerPattern.builder() - .layer(l -> l.weight(1) - .passiveBlock()) .layer(l -> l.weight(2) + .passiveBlock()) + .layer(l -> l.weight(4) .block(AllPaletteStoneTypes.VERIDIUM.getBaseBlock()) .size(1, 3)) .layer(l -> l.weight(2) .block(Blocks.TUFF) .block(Blocks.ANDESITE) .size(1, 2)) - .layer(l -> l.weight(1) + .layer(l -> l.weight(2) + .blocks(Blocks.TUFF, Blocks.ANDESITE)) + .layer(l -> l.weight(3) .block(Blocks.SMOOTH_BASALT)) .build(); - + public static NonNullSupplier SCORIA = () -> LayerPattern.builder() .layer(l -> l.weight(1) .passiveBlock()) @@ -79,6 +82,8 @@ public class AllLayerPatterns { .block(Blocks.TUFF) .block(Blocks.ANDESITE) .size(1, 2)) + .layer(l -> l.weight(1) + .blocks(Blocks.TUFF, Blocks.ANDESITE)) .layer(l -> l.weight(1) .block(Blocks.DIORITE)) .build(); @@ -88,9 +93,11 @@ public class AllLayerPatterns { .passiveBlock()) .layer(l -> l.weight(2) .block(Blocks.CALCITE)) + .layer(l -> l.weight(1) + .block(Blocks.DIORITE)) .layer(l -> l.weight(2) .block(AllPaletteStoneTypes.LIMESTONE.getBaseBlock()) - .size(1, 5)) + .size(1, 4)) .build(); public static NonNullSupplier SCORIA_NETHER = () -> LayerPattern.builder() @@ -107,7 +114,7 @@ public class AllLayerPatterns { .block(Blocks.BASALT) .block(Blocks.SMOOTH_BASALT)) .build(); - + public static NonNullSupplier SCORCHIA_NETHER = () -> LayerPattern.builder() .inNether() .layer(l -> l.weight(2) diff --git a/src/main/java/com/simibubi/create/foundation/worldgen/LayerPattern.java b/src/main/java/com/simibubi/create/foundation/worldgen/LayerPattern.java index 5fa7ef7f8..56169577b 100644 --- a/src/main/java/com/simibubi/create/foundation/worldgen/LayerPattern.java +++ b/src/main/java/com/simibubi/create/foundation/worldgen/LayerPattern.java @@ -105,7 +105,7 @@ public class LayerPattern { } public LayerBuilder passiveBlock() { - return block(Blocks.AIR); + return blocks(Blocks.STONE.defaultBlockState(), Blocks.DEEPSLATE.defaultBlockState()); } public LayerBuilder block(Block block) { @@ -116,6 +116,10 @@ public class LayerPattern { } return blocks(block.defaultBlockState(), block.defaultBlockState()); } + + public LayerBuilder blocks(Block block, Block deepblock) { + return blocks(block.defaultBlockState(), deepblock.defaultBlockState()); + } public LayerBuilder blocks(Couple> blocksByDepth) { return blocks(blocksByDepth.getFirst() diff --git a/src/main/java/com/simibubi/create/foundation/worldgen/LayeredOreFeature.java b/src/main/java/com/simibubi/create/foundation/worldgen/LayeredOreFeature.java index 5fb46b8fd..e3799a12b 100644 --- a/src/main/java/com/simibubi/create/foundation/worldgen/LayeredOreFeature.java +++ b/src/main/java/com/simibubi/create/foundation/worldgen/LayeredOreFeature.java @@ -1,7 +1,6 @@ package com.simibubi.create.foundation.worldgen; import java.util.ArrayList; -import java.util.BitSet; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -64,7 +63,6 @@ public class LayeredOreFeature extends OreFeatureBase { List resolvedLayers = new ArrayList<>(); List layerDiameterOffsets = new ArrayList<>(); - BitSet bitset = new BitSet(size * size * size); MutableBlockPos mutablePos = new MutableBlockPos(); BulkSectionAccess bulksectionaccess = new BulkSectionAccess(worldgenlevel); int layerCoordinate = random.nextInt(4); @@ -106,11 +104,6 @@ public class LayeredOreFeature extends OreFeatureBase { if (dx * dx + dy * dy + dz * dz > 1 * layerDiameterOffsets.get(layerIndex)) continue; - int index = x * length * height + y * length + z; - if (bitset.get(index)) - continue; - bitset.set(index); - LayerPattern.Layer layer = resolvedLayers.get(layerIndex); List state = layer.rollBlock(random);