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
This commit is contained in:
parent
b6c66868ca
commit
2e56ad6714
6 changed files with 226 additions and 9 deletions
|
@ -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
|
||||
|
|
|
@ -13,6 +13,6 @@
|
|||
},
|
||||
"result": {
|
||||
"item": "create:fluid_pipe",
|
||||
"count": 8
|
||||
"count": 4
|
||||
}
|
||||
}
|
|
@ -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<Block, BlockState> 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<Block> 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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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())
|
||||
|
|
Loading…
Reference in a new issue