Turbines- I mean horizontal water wheels

- Make water wheels work and be able to be placed horizontally
This commit is contained in:
_0Steven 2021-02-22 13:09:50 +01:00
parent da09112e3c
commit 33a08a235e
5 changed files with 112 additions and 97 deletions

View File

@ -140,7 +140,7 @@ de8a40b7daf1497d5aecee47a43b3e0b1d030b00 assets/create/blockstates/fancy_scoria_
fc9ac0a7e7191b93516719455a17177fa6524ecc assets/create/blockstates/fancy_weathered_limestone_bricks_slab.json fc9ac0a7e7191b93516719455a17177fa6524ecc assets/create/blockstates/fancy_weathered_limestone_bricks_slab.json
b2a7c321b1795f20e7433f81a55ce4683de081b8 assets/create/blockstates/fancy_weathered_limestone_bricks_stairs.json b2a7c321b1795f20e7433f81a55ce4683de081b8 assets/create/blockstates/fancy_weathered_limestone_bricks_stairs.json
6372fe02ba0065acb0758121c45a15a1a8fdc5de assets/create/blockstates/fancy_weathered_limestone_bricks_wall.json 6372fe02ba0065acb0758121c45a15a1a8fdc5de assets/create/blockstates/fancy_weathered_limestone_bricks_wall.json
48086bf71a824faf14841b698050cc8544b09a9b assets/create/blockstates/fluid_pipe.json cedc68a9c3ab47a94bd8200889316a708c25950a assets/create/blockstates/fluid_pipe.json
f0eaab18e16c4f3f65ebf3b55b08f0dc445720fe assets/create/blockstates/fluid_tank.json f0eaab18e16c4f3f65ebf3b55b08f0dc445720fe assets/create/blockstates/fluid_tank.json
5408d92ab02af86539ac42971d4033545970bb3a assets/create/blockstates/fluid_valve.json 5408d92ab02af86539ac42971d4033545970bb3a assets/create/blockstates/fluid_valve.json
e9da1794b6ece7f9aa8bcb43d42c23a55446133b assets/create/blockstates/flywheel.json e9da1794b6ece7f9aa8bcb43d42c23a55446133b assets/create/blockstates/flywheel.json
@ -379,7 +379,7 @@ a2454400b1cf9889f70aebdc89c52a1be25f543c assets/create/blockstates/tiled_glass_p
a8094531617e27a545c4815ab2062bf0ffca3633 assets/create/blockstates/turntable.json a8094531617e27a545c4815ab2062bf0ffca3633 assets/create/blockstates/turntable.json
69dfe8afaa8eb6105dae9f76ab8b7847bf90b8c6 assets/create/blockstates/vertical_framed_glass.json 69dfe8afaa8eb6105dae9f76ab8b7847bf90b8c6 assets/create/blockstates/vertical_framed_glass.json
c4db76b9d36cfb098df0d158cb6f8b82768ebe14 assets/create/blockstates/vertical_framed_glass_pane.json c4db76b9d36cfb098df0d158cb6f8b82768ebe14 assets/create/blockstates/vertical_framed_glass_pane.json
d995547bcd71603ba7378d8998098e462030bfd0 assets/create/blockstates/water_wheel.json d31fce8315c8715521d66b5dcc166c84e949dd1d assets/create/blockstates/water_wheel.json
f182669f7547964f9f2ef67916568556870def7b assets/create/blockstates/weathered_limestone.json f182669f7547964f9f2ef67916568556870def7b assets/create/blockstates/weathered_limestone.json
27e6740834c0f673acc3531371512daa6dcab025 assets/create/blockstates/weathered_limestone_bricks.json 27e6740834c0f673acc3531371512daa6dcab025 assets/create/blockstates/weathered_limestone_bricks.json
abb74e4f4c2b9851670cb6ad794281b0f7be0f5a assets/create/blockstates/weathered_limestone_bricks_slab.json abb74e4f4c2b9851670cb6ad794281b0f7be0f5a assets/create/blockstates/weathered_limestone_bricks_slab.json

View File

@ -60,10 +60,10 @@
}, },
{ {
"when": { "when": {
"north": "true",
"down": "false", "down": "false",
"up": "true",
"south": "false", "south": "false",
"north": "true" "up": "true"
}, },
"apply": { "apply": {
"model": "create:block/fluid_pipe/lu_x" "model": "create:block/fluid_pipe/lu_x"
@ -71,10 +71,10 @@
}, },
{ {
"when": { "when": {
"north": "false",
"down": "false", "down": "false",
"up": "true",
"south": "true", "south": "true",
"north": "false" "up": "true"
}, },
"apply": { "apply": {
"model": "create:block/fluid_pipe/ru_x" "model": "create:block/fluid_pipe/ru_x"
@ -82,10 +82,10 @@
}, },
{ {
"when": { "when": {
"north": "true",
"down": "true", "down": "true",
"up": "false",
"south": "false", "south": "false",
"north": "true" "up": "false"
}, },
"apply": { "apply": {
"model": "create:block/fluid_pipe/ld_x" "model": "create:block/fluid_pipe/ld_x"
@ -93,10 +93,10 @@
}, },
{ {
"when": { "when": {
"north": "false",
"down": "true", "down": "true",
"up": "false",
"south": "true", "south": "true",
"north": "false" "up": "false"
}, },
"apply": { "apply": {
"model": "create:block/fluid_pipe/rd_x" "model": "create:block/fluid_pipe/rd_x"
@ -104,10 +104,10 @@
}, },
{ {
"when": { "when": {
"north": "false",
"down": "true", "down": "true",
"up": "true",
"south": "false", "south": "false",
"north": "false" "up": "true"
}, },
"apply": { "apply": {
"model": "create:block/fluid_pipe/ud_x" "model": "create:block/fluid_pipe/ud_x"
@ -115,10 +115,10 @@
}, },
{ {
"when": { "when": {
"north": "false",
"down": "false", "down": "false",
"up": "true",
"south": "false", "south": "false",
"north": "false" "up": "true"
}, },
"apply": { "apply": {
"model": "create:block/fluid_pipe/ud_x" "model": "create:block/fluid_pipe/ud_x"
@ -126,10 +126,10 @@
}, },
{ {
"when": { "when": {
"north": "false",
"down": "true", "down": "true",
"up": "false",
"south": "false", "south": "false",
"north": "false" "up": "false"
}, },
"apply": { "apply": {
"model": "create:block/fluid_pipe/ud_x" "model": "create:block/fluid_pipe/ud_x"
@ -137,10 +137,10 @@
}, },
{ {
"when": { "when": {
"north": "true",
"down": "false", "down": "false",
"up": "false",
"south": "true", "south": "true",
"north": "true" "up": "false"
}, },
"apply": { "apply": {
"model": "create:block/fluid_pipe/lr_x" "model": "create:block/fluid_pipe/lr_x"
@ -148,10 +148,10 @@
}, },
{ {
"when": { "when": {
"north": "true",
"down": "false", "down": "false",
"up": "false",
"south": "false", "south": "false",
"north": "true" "up": "false"
}, },
"apply": { "apply": {
"model": "create:block/fluid_pipe/lr_x" "model": "create:block/fluid_pipe/lr_x"
@ -159,10 +159,10 @@
}, },
{ {
"when": { "when": {
"north": "false",
"down": "false", "down": "false",
"up": "false",
"south": "true", "south": "true",
"north": "false" "up": "false"
}, },
"apply": { "apply": {
"model": "create:block/fluid_pipe/lr_x" "model": "create:block/fluid_pipe/lr_x"
@ -170,10 +170,10 @@
}, },
{ {
"when": { "when": {
"north": "false",
"down": "false", "down": "false",
"up": "false",
"south": "false", "south": "false",
"north": "false" "up": "false"
}, },
"apply": { "apply": {
"model": "create:block/fluid_pipe/none_x" "model": "create:block/fluid_pipe/none_x"
@ -181,10 +181,10 @@
}, },
{ {
"when": { "when": {
"south": "true", "east": "false",
"west": "true",
"north": "false", "north": "false",
"east": "false" "south": "true",
"west": "true"
}, },
"apply": { "apply": {
"model": "create:block/fluid_pipe/lu_y" "model": "create:block/fluid_pipe/lu_y"
@ -192,10 +192,10 @@
}, },
{ {
"when": { "when": {
"south": "true", "east": "true",
"west": "false",
"north": "false", "north": "false",
"east": "true" "south": "true",
"west": "false"
}, },
"apply": { "apply": {
"model": "create:block/fluid_pipe/ru_y" "model": "create:block/fluid_pipe/ru_y"
@ -203,10 +203,10 @@
}, },
{ {
"when": { "when": {
"south": "false", "east": "false",
"west": "true",
"north": "true", "north": "true",
"east": "false" "south": "false",
"west": "true"
}, },
"apply": { "apply": {
"model": "create:block/fluid_pipe/ld_y" "model": "create:block/fluid_pipe/ld_y"
@ -214,10 +214,10 @@
}, },
{ {
"when": { "when": {
"south": "false", "east": "true",
"west": "false",
"north": "true", "north": "true",
"east": "true" "south": "false",
"west": "false"
}, },
"apply": { "apply": {
"model": "create:block/fluid_pipe/rd_y" "model": "create:block/fluid_pipe/rd_y"
@ -225,21 +225,10 @@
}, },
{ {
"when": { "when": {
"south": "true", "east": "false",
"west": "false",
"north": "true", "north": "true",
"east": "false"
},
"apply": {
"model": "create:block/fluid_pipe/ud_y"
}
},
{
"when": {
"south": "true", "south": "true",
"west": "false", "west": "false"
"north": "false",
"east": "false"
}, },
"apply": { "apply": {
"model": "create:block/fluid_pipe/ud_y" "model": "create:block/fluid_pipe/ud_y"
@ -247,10 +236,21 @@
}, },
{ {
"when": { "when": {
"south": "false", "east": "false",
"west": "false", "north": "false",
"south": "true",
"west": "false"
},
"apply": {
"model": "create:block/fluid_pipe/ud_y"
}
},
{
"when": {
"east": "false",
"north": "true", "north": "true",
"east": "false" "south": "false",
"west": "false"
}, },
"apply": { "apply": {
"model": "create:block/fluid_pipe/ud_y" "model": "create:block/fluid_pipe/ud_y"
@ -258,10 +258,10 @@
}, },
{ {
"when": { "when": {
"south": "false", "east": "true",
"west": "true",
"north": "false", "north": "false",
"east": "true" "south": "false",
"west": "true"
}, },
"apply": { "apply": {
"model": "create:block/fluid_pipe/lr_y" "model": "create:block/fluid_pipe/lr_y"
@ -269,10 +269,10 @@
}, },
{ {
"when": { "when": {
"south": "false", "east": "false",
"west": "true",
"north": "false", "north": "false",
"east": "false" "south": "false",
"west": "true"
}, },
"apply": { "apply": {
"model": "create:block/fluid_pipe/lr_y" "model": "create:block/fluid_pipe/lr_y"
@ -280,10 +280,10 @@
}, },
{ {
"when": { "when": {
"south": "false", "east": "true",
"west": "false",
"north": "false", "north": "false",
"east": "true" "south": "false",
"west": "false"
}, },
"apply": { "apply": {
"model": "create:block/fluid_pipe/lr_y" "model": "create:block/fluid_pipe/lr_y"
@ -291,10 +291,10 @@
}, },
{ {
"when": { "when": {
"south": "false", "east": "false",
"west": "false",
"north": "false", "north": "false",
"east": "false" "south": "false",
"west": "false"
}, },
"apply": { "apply": {
"model": "create:block/fluid_pipe/none_y" "model": "create:block/fluid_pipe/none_y"
@ -302,10 +302,10 @@
}, },
{ {
"when": { "when": {
"east": "true",
"down": "false", "down": "false",
"up": "true", "up": "true",
"west": "false", "west": "false"
"east": "true"
}, },
"apply": { "apply": {
"model": "create:block/fluid_pipe/lu_z" "model": "create:block/fluid_pipe/lu_z"
@ -313,10 +313,10 @@
}, },
{ {
"when": { "when": {
"east": "false",
"down": "false", "down": "false",
"up": "true", "up": "true",
"west": "true", "west": "true"
"east": "false"
}, },
"apply": { "apply": {
"model": "create:block/fluid_pipe/ru_z" "model": "create:block/fluid_pipe/ru_z"
@ -324,10 +324,10 @@
}, },
{ {
"when": { "when": {
"east": "true",
"down": "true", "down": "true",
"up": "false", "up": "false",
"west": "false", "west": "false"
"east": "true"
}, },
"apply": { "apply": {
"model": "create:block/fluid_pipe/ld_z" "model": "create:block/fluid_pipe/ld_z"
@ -335,10 +335,10 @@
}, },
{ {
"when": { "when": {
"east": "false",
"down": "true", "down": "true",
"up": "false", "up": "false",
"west": "true", "west": "true"
"east": "false"
}, },
"apply": { "apply": {
"model": "create:block/fluid_pipe/rd_z" "model": "create:block/fluid_pipe/rd_z"
@ -346,10 +346,10 @@
}, },
{ {
"when": { "when": {
"east": "false",
"down": "true", "down": "true",
"up": "true", "up": "true",
"west": "false", "west": "false"
"east": "false"
}, },
"apply": { "apply": {
"model": "create:block/fluid_pipe/ud_z" "model": "create:block/fluid_pipe/ud_z"
@ -357,10 +357,10 @@
}, },
{ {
"when": { "when": {
"east": "false",
"down": "false", "down": "false",
"up": "true", "up": "true",
"west": "false", "west": "false"
"east": "false"
}, },
"apply": { "apply": {
"model": "create:block/fluid_pipe/ud_z" "model": "create:block/fluid_pipe/ud_z"
@ -368,10 +368,10 @@
}, },
{ {
"when": { "when": {
"east": "false",
"down": "true", "down": "true",
"up": "false", "up": "false",
"west": "false", "west": "false"
"east": "false"
}, },
"apply": { "apply": {
"model": "create:block/fluid_pipe/ud_z" "model": "create:block/fluid_pipe/ud_z"
@ -379,10 +379,10 @@
}, },
{ {
"when": { "when": {
"east": "true",
"down": "false", "down": "false",
"up": "false", "up": "false",
"west": "true", "west": "true"
"east": "true"
}, },
"apply": { "apply": {
"model": "create:block/fluid_pipe/lr_z" "model": "create:block/fluid_pipe/lr_z"
@ -390,10 +390,10 @@
}, },
{ {
"when": { "when": {
"east": "true",
"down": "false", "down": "false",
"up": "false", "up": "false",
"west": "false", "west": "false"
"east": "true"
}, },
"apply": { "apply": {
"model": "create:block/fluid_pipe/lr_z" "model": "create:block/fluid_pipe/lr_z"
@ -401,10 +401,10 @@
}, },
{ {
"when": { "when": {
"east": "false",
"down": "false", "down": "false",
"up": "false", "up": "false",
"west": "true", "west": "true"
"east": "false"
}, },
"apply": { "apply": {
"model": "create:block/fluid_pipe/lr_z" "model": "create:block/fluid_pipe/lr_z"
@ -412,10 +412,10 @@
}, },
{ {
"when": { "when": {
"east": "false",
"down": "false", "down": "false",
"up": "false", "up": "false",
"west": "false", "west": "false"
"east": "false"
}, },
"apply": { "apply": {
"model": "create:block/fluid_pipe/none_z" "model": "create:block/fluid_pipe/none_z"

View File

@ -1,5 +1,12 @@
{ {
"variants": { "variants": {
"facing=down": {
"model": "create:block/water_wheel",
"x": 180
},
"facing=up": {
"model": "create:block/water_wheel"
},
"facing=north": { "facing=north": {
"model": "create:block/water_wheel", "model": "create:block/water_wheel",
"x": 90 "x": 90

View File

@ -335,7 +335,7 @@ public class AllBlocks {
public static final BlockEntry<WaterWheelBlock> WATER_WHEEL = REGISTRATE.block("water_wheel", WaterWheelBlock::new) public static final BlockEntry<WaterWheelBlock> WATER_WHEEL = REGISTRATE.block("water_wheel", WaterWheelBlock::new)
.initialProperties(SharedProperties::wooden) .initialProperties(SharedProperties::wooden)
.properties(Block.Properties::nonOpaque) .properties(Block.Properties::nonOpaque)
.blockstate(BlockStateGen.horizontalWheelProvider(false)) .blockstate(BlockStateGen.directionalBlockProviderIgnoresWaterlogged(false))
.addLayer(() -> RenderType::getCutoutMipped) .addLayer(() -> RenderType::getCutoutMipped)
.transform(StressConfigDefaults.setCapacity(16.0)) .transform(StressConfigDefaults.setCapacity(16.0))
.simpleItem() .simpleItem()

View File

@ -3,6 +3,7 @@ package com.simibubi.create.content.contraptions.components.waterwheel;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllFluids; import com.simibubi.create.AllFluids;
import com.simibubi.create.AllTileEntities; import com.simibubi.create.AllTileEntities;
import com.simibubi.create.content.contraptions.base.DirectionalKineticBlock;
import com.simibubi.create.content.contraptions.base.HorizontalKineticBlock; import com.simibubi.create.content.contraptions.base.HorizontalKineticBlock;
import com.simibubi.create.foundation.advancement.AllTriggers; import com.simibubi.create.foundation.advancement.AllTriggers;
import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.block.ITE;
@ -28,7 +29,7 @@ import net.minecraft.world.IWorld;
import net.minecraft.world.IWorldReader; import net.minecraft.world.IWorldReader;
import net.minecraft.world.World; import net.minecraft.world.World;
public class WaterWheelBlock extends HorizontalKineticBlock implements ITE<WaterWheelTileEntity> { public class WaterWheelBlock extends DirectionalKineticBlock implements ITE<WaterWheelTileEntity> {
public WaterWheelBlock(Properties properties) { public WaterWheelBlock(Properties properties) {
super(properties); super(properties);
@ -51,10 +52,10 @@ public class WaterWheelBlock extends HorizontalKineticBlock implements ITE<Water
BlockState neighbourState = worldIn.getBlockState(neighbourPos); BlockState neighbourState = worldIn.getBlockState(neighbourPos);
if (!AllBlocks.WATER_WHEEL.has(neighbourState)) if (!AllBlocks.WATER_WHEEL.has(neighbourState))
continue; continue;
if (neighbourState.get(HORIZONTAL_FACING) if (neighbourState.get(FACING)
.getAxis() != state.get(HORIZONTAL_FACING) .getAxis() != state.get(FACING)
.getAxis() .getAxis()
|| state.get(HORIZONTAL_FACING) || state.get(FACING)
.getAxis() != direction.getAxis()) .getAxis() != direction.getAxis())
return false; return false;
} }
@ -85,12 +86,12 @@ public class WaterWheelBlock extends HorizontalKineticBlock implements ITE<Water
} }
private void updateFlowAt(BlockState state, World world, BlockPos pos, Direction side) { private void updateFlowAt(BlockState state, World world, BlockPos pos, Direction side) {
if (side.getAxis() == state.get(HORIZONTAL_FACING) if (side.getAxis() == state.get(FACING)
.getAxis()) .getAxis())
return; return;
IFluidState fluid = world.getFluidState(pos.offset(side)); IFluidState fluid = world.getFluidState(pos.offset(side));
Direction wf = state.get(HORIZONTAL_FACING); Direction wf = state.get(FACING);
boolean clockwise = wf.getAxisDirection() == AxisDirection.POSITIVE; boolean clockwise = wf.getAxisDirection() == AxisDirection.POSITIVE;
int clockwiseMultiplier = 2; int clockwiseMultiplier = 2;
@ -124,6 +125,13 @@ public class WaterWheelBlock extends HorizontalKineticBlock implements ITE<Water
flowStrength = flow.y > 0 ^ !clockwise ? -flow.y * clockwiseMultiplier : -flow.y; flowStrength = flow.y > 0 ^ !clockwise ? -flow.y * clockwiseMultiplier : -flow.y;
} }
if (wf.getAxis() == Axis.Y) {
if (side.getAxis() == Axis.Z)
flowStrength = flow.x < 0 ^ !clockwise ? flow.x * clockwiseMultiplier : flow.x;
if (side.getAxis() == Axis.X)
flowStrength = flow.z > 0 ^ !clockwise ? -flow.z * clockwiseMultiplier : -flow.z;
}
if (te.getSpeed() == 0 && flowStrength != 0 && !world.isRemote) { if (te.getSpeed() == 0 && flowStrength != 0 && !world.isRemote) {
AllTriggers.triggerForNearbyPlayers(AllTriggers.WATER_WHEEL, world, pos, 5); AllTriggers.triggerForNearbyPlayers(AllTriggers.WATER_WHEEL, world, pos, 5);
if (FluidHelper.isLava(fluid.getFluid())) if (FluidHelper.isLava(fluid.getFluid()))
@ -148,23 +156,23 @@ public class WaterWheelBlock extends HorizontalKineticBlock implements ITE<Water
.getBlockState(context.getPos() .getBlockState(context.getPos()
.offset(facing.getOpposite())); .offset(facing.getOpposite()));
if (AllBlocks.WATER_WHEEL.has(placedOn)) if (AllBlocks.WATER_WHEEL.has(placedOn))
return getDefaultState().with(HORIZONTAL_FACING, placedOn.get(HORIZONTAL_FACING)); return getDefaultState().with(FACING, placedOn.get(FACING));
if (facing.getAxis() if (facing.getAxis()
.isHorizontal()) .isHorizontal())
return getDefaultState().with(HORIZONTAL_FACING, context.getPlayer() != null && context.getPlayer() return getDefaultState().with(FACING, context.getPlayer() != null && context.getPlayer()
.isSneaking() ? facing.getOpposite() : facing); .isSneaking() ? facing.getOpposite() : facing);
return super.getStateForPlacement(context); return super.getStateForPlacement(context);
} }
@Override @Override
public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) {
return state.get(HORIZONTAL_FACING) return state.get(FACING)
.getAxis() == face.getAxis(); .getAxis() == face.getAxis();
} }
@Override @Override
public Axis getRotationAxis(BlockState state) { public Axis getRotationAxis(BlockState state) {
return state.get(HORIZONTAL_FACING) return state.get(FACING)
.getAxis(); .getAxis();
} }