Merge pull request #1900 from LordGrimmauld/horizontal-water-wheels-V2

Horizontal water wheels v2
This commit is contained in:
simibubi 2021-07-06 12:58:26 +02:00 committed by GitHub
commit e3d497e527
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 34 additions and 18 deletions

View file

@ -388,7 +388,7 @@ a8094531617e27a545c4815ab2062bf0ffca3633 assets/create/blockstates/turntable.jso
c4db76b9d36cfb098df0d158cb6f8b82768ebe14 assets/create/blockstates/vertical_framed_glass_pane.json
3a5da54d9763e9512cfaa47b25226b79738b25f3 assets/create/blockstates/warped_window.json
19ef7a16c82f07d304fb60d121845185d189aecf assets/create/blockstates/warped_window_pane.json
d995547bcd71603ba7378d8998098e462030bfd0 assets/create/blockstates/water_wheel.json
d31fce8315c8715521d66b5dcc166c84e949dd1d assets/create/blockstates/water_wheel.json
f182669f7547964f9f2ef67916568556870def7b assets/create/blockstates/weathered_limestone.json
27e6740834c0f673acc3531371512daa6dcab025 assets/create/blockstates/weathered_limestone_bricks.json
abb74e4f4c2b9851670cb6ad794281b0f7be0f5a assets/create/blockstates/weathered_limestone_bricks_slab.json
@ -1668,7 +1668,7 @@ d080b1b25e5bc8baf5aee68691b08c7f12ece3b0 assets/create/models/item/windmill_bear
a80fb25a0b655e76be986b5b49fcb0f03461a1ab assets/create/models/item/zinc_nugget.json
b1689617190c05ef34bd18456b0c7ae09bb3210f assets/create/models/item/zinc_ore.json
bbe7fc4aef29420319f59d02d4cd376a78244e70 assets/create/sounds.json
0f1b4b980afba9bf2caf583b88e261bba8b10313 data/create/advancements/aesthetics.json
5d0cc4c0255dc241e61c173b31ddca70c88d08e4 data/create/advancements/aesthetics.json
187921fa131b06721bfaf63f2623a28c141aae9a data/create/advancements/andesite_alloy.json
0ea2db7173b5be28b289ea7c9a6a0cf5805c60c7 data/create/advancements/andesite_casing.json
83c046bd200623933545c9e4326f782fb02c87fa data/create/advancements/arm_blaze_burner.json

View file

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

View file

@ -28,8 +28,8 @@
"trigger": "create:bracket_apply",
"conditions": {
"accepted_entries": [
"create:cogwheel",
"create:large_cogwheel"
"create:large_cogwheel",
"create:cogwheel"
]
}
},

View file

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

View file

@ -5,7 +5,7 @@ import javax.annotation.ParametersAreNonnullByDefault;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllFluids;
import com.simibubi.create.AllTileEntities;
import com.simibubi.create.content.contraptions.base.HorizontalKineticBlock;
import com.simibubi.create.content.contraptions.base.DirectionalKineticBlock;
import com.simibubi.create.foundation.advancement.AllTriggers;
import com.simibubi.create.foundation.block.ITE;
import com.simibubi.create.foundation.config.AllConfigs;
@ -33,7 +33,7 @@ import net.minecraft.world.World;
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public class WaterWheelBlock extends HorizontalKineticBlock implements ITE<WaterWheelTileEntity> {
public class WaterWheelBlock extends DirectionalKineticBlock implements ITE<WaterWheelTileEntity> {
public WaterWheelBlock(Properties properties) {
super(properties);
@ -56,10 +56,10 @@ public class WaterWheelBlock extends HorizontalKineticBlock implements ITE<Water
BlockState neighbourState = worldIn.getBlockState(neighbourPos);
if (!AllBlocks.WATER_WHEEL.has(neighbourState))
continue;
if (neighbourState.get(HORIZONTAL_FACING)
.getAxis() != state.get(HORIZONTAL_FACING)
if (neighbourState.get(FACING)
.getAxis() != state.get(FACING)
.getAxis()
|| state.get(HORIZONTAL_FACING)
|| state.get(FACING)
.getAxis() != direction.getAxis())
return false;
}
@ -88,13 +88,14 @@ public class WaterWheelBlock extends HorizontalKineticBlock implements ITE<Water
updateWheelSpeed(worldIn, pos);
}
private void updateFlowAt(BlockState state, IWorld world, BlockPos pos, Direction side) {
if (side.getAxis() == state.get(HORIZONTAL_FACING)
if (side.getAxis() == state.get(FACING)
.getAxis())
return;
FluidState fluid = world.getFluidState(pos.offset(side));
Direction wf = state.get(HORIZONTAL_FACING);
Direction wf = state.get(FACING);
boolean clockwise = wf.getAxisDirection() == AxisDirection.POSITIVE;
int clockwiseMultiplier = 2;
@ -128,6 +129,14 @@ public class WaterWheelBlock extends HorizontalKineticBlock implements ITE<Water
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()) {
AllTriggers.triggerForNearbyPlayers(AllTriggers.WATER_WHEEL, world, pos, 5);
if (FluidHelper.isLava(fluid.getFluid()))
@ -152,23 +161,23 @@ public class WaterWheelBlock extends HorizontalKineticBlock implements ITE<Water
.getBlockState(context.getPos()
.offset(facing.getOpposite()));
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()
.isHorizontal())
return getDefaultState().with(HORIZONTAL_FACING, context.getPlayer() != null && context.getPlayer()
return getDefaultState().with(FACING, context.getPlayer() != null && context.getPlayer()
.isSneaking() ? facing.getOpposite() : facing);
return super.getStateForPlacement(context);
}
@Override
public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) {
return state.get(HORIZONTAL_FACING)
return state.get(FACING)
.getAxis() == face.getAxis();
}
@Override
public Axis getRotationAxis(BlockState state) {
return state.get(HORIZONTAL_FACING)
return state.get(FACING)
.getAxis();
}

View file

@ -595,7 +595,7 @@ public class KineticsScenes {
scene.idle(10);
scene.world.rotateSection(wheelElement, 0, 180, 0, 5);
scene.idle(10);
scene.world.modifyBlock(wheel, s -> s.with(WaterWheelBlock.HORIZONTAL_FACING, Direction.WEST), false);
scene.world.modifyBlock(wheel, s -> s.with(WaterWheelBlock.FACING, Direction.WEST), false);
scene.world.rotateSection(wheelElement, 0, -180, 0, 0);
scene.idle(1);
scene.world.moveSection(water, util.vector.of(0, -2, 2), 10);
@ -618,7 +618,7 @@ public class KineticsScenes {
scene.rotateCameraY(30);
scene.world.rotateSection(wheelElement, 0, 180, 0, 5);
scene.idle(10);
scene.world.modifyBlock(wheel, s -> s.with(WaterWheelBlock.HORIZONTAL_FACING, Direction.EAST), false);
scene.world.modifyBlock(wheel, s -> s.with(WaterWheelBlock.FACING, Direction.EAST), false);
scene.world.rotateSection(wheelElement, 0, -180, 0, 0);
scene.idle(1);
scene.world.moveSection(water, util.vector.of(0, -2, 2), 10);