-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Jungle Lily Pad edits and a new sea message
- Loading branch information
1 parent
70c4a0c
commit ec27420
Showing
7 changed files
with
91 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/generated/resources/data/hybrid-aquatic/hybrid-aquatic/sea_message/yashaa.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"author": "Yashaa", | ||
"has_title": true, | ||
"infinite": false, | ||
"translation_key": "hybrid-aquatic.sea_message.yashaa" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 75 additions & 17 deletions
92
src/main/kotlin/dev/hybridlabs/aquatic/block/JungleLilyPadBlock.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,100 @@ | ||
package dev.hybridlabs.aquatic.block | ||
|
||
import net.minecraft.block.BlockState | ||
import net.minecraft.block.IceBlock | ||
import net.minecraft.block.PlantBlock | ||
import net.minecraft.block.ShapeContext | ||
import net.minecraft.block.* | ||
import net.minecraft.entity.Entity | ||
import net.minecraft.entity.vehicle.BoatEntity | ||
import net.minecraft.fluid.FluidState | ||
import net.minecraft.fluid.Fluids | ||
import net.minecraft.item.ItemPlacementContext | ||
import net.minecraft.server.world.ServerWorld | ||
import net.minecraft.state.StateManager | ||
import net.minecraft.state.property.Properties | ||
import net.minecraft.util.math.BlockPos | ||
import net.minecraft.util.math.Direction | ||
import net.minecraft.util.math.Vec3d | ||
import net.minecraft.util.shape.VoxelShape | ||
import net.minecraft.world.BlockView | ||
import net.minecraft.world.World | ||
import net.minecraft.world.WorldAccess | ||
import net.minecraft.world.WorldView | ||
|
||
open class JungleLilyPadBlock(settings: Settings?) : PlantBlock(settings) { | ||
override fun onEntityCollision(state: BlockState, world: World, pos: BlockPos, entity: Entity) { | ||
super.onEntityCollision(state, world, pos, entity) | ||
if (world is ServerWorld && entity is BoatEntity) { | ||
world.breakBlock(BlockPos(pos), true, entity) | ||
@Suppress("OVERRIDE_DEPRECATION", "DEPRECATION") | ||
class JungleLilyPadBlock(settings: Settings?) : PlantBlock(settings) { | ||
init { | ||
defaultState = defaultState.with(Properties.WATERLOGGED, true) | ||
} | ||
|
||
override fun canPlaceAt(state: BlockState, world: WorldView, pos: BlockPos): Boolean { | ||
val fluidStateAbove = world.getFluidState(pos.up()) | ||
if (fluidStateAbove.fluid != Fluids.EMPTY) { | ||
return false | ||
} | ||
|
||
val stateBelow = world.getBlockState(pos.down()) | ||
if (stateBelow.block == this) { | ||
return false | ||
} | ||
|
||
val fluidState = world.getFluidState(pos) | ||
return fluidState.fluid == Fluids.WATER || sideCoversSmallSquare(world, pos.down(), Direction.UP) | ||
} | ||
|
||
override fun getOutlineShape( | ||
override fun getPlacementState(context: ItemPlacementContext): BlockState? { | ||
val world = context.world | ||
val pos = context.blockPos | ||
val fluidState = world.getFluidState(pos) | ||
return if (fluidState.fluid == Fluids.WATER) { | ||
super.getPlacementState(context)?.with(Properties.WATERLOGGED, true) | ||
} else { | ||
null | ||
} | ||
} | ||
|
||
override fun getStateForNeighborUpdate( | ||
state: BlockState, | ||
world: BlockView, | ||
direction: Direction, | ||
neighborState: BlockState, | ||
world: WorldAccess, | ||
pos: BlockPos, | ||
context: ShapeContext | ||
neighborPos: BlockPos | ||
): BlockState { | ||
if (state.get(Properties.WATERLOGGED)) { | ||
world.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)) | ||
} | ||
|
||
if (!canPlaceAt(state, world, pos)) { | ||
return Blocks.AIR.defaultState | ||
} | ||
|
||
return super.getStateForNeighborUpdate(state, direction, neighborState, world, pos, neighborPos) | ||
} | ||
|
||
override fun getOutlineShape( | ||
state: BlockState?, | ||
world: BlockView?, | ||
pos: BlockPos?, | ||
context: ShapeContext? | ||
): VoxelShape { | ||
return SHAPE | ||
} | ||
|
||
override fun canPlantOnTop(floor: BlockState, world: BlockView, pos: BlockPos): Boolean { | ||
val fluidState = world.getFluidState(pos) | ||
val fluidState2 = world.getFluidState(pos.up()) | ||
return (fluidState.fluid === Fluids.WATER || floor.block is IceBlock) && fluidState2.fluid === Fluids.EMPTY | ||
override fun getFluidState(state: BlockState): FluidState { | ||
return if (state.get(Properties.WATERLOGGED)) Fluids.WATER.getStill(false) else super.getFluidState(state) | ||
} | ||
|
||
override fun appendProperties(builder: StateManager.Builder<Block, BlockState>) { | ||
builder.add(Properties.WATERLOGGED) | ||
} | ||
|
||
override fun onEntityCollision(state: BlockState, world: World, pos: BlockPos, entity: Entity) { | ||
super.onEntityCollision(state, world, pos, entity) | ||
if (world is ServerWorld && entity is BoatEntity) { | ||
entity.slowMovement(state, Vec3d(0.66, 0.66, 0.66)) | ||
world.breakBlock(BlockPos(pos), false, entity) | ||
} | ||
} | ||
|
||
companion object { | ||
protected val SHAPE: VoxelShape = createCuboidShape(1.0, 0.0, 1.0, 15.0, 1.5, 15.0) | ||
private val SHAPE: VoxelShape = createCuboidShape(1.0, 15.0, 1.0, 15.0, 16.0, 15.0) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+622 Bytes
src/main/resources/assets/hybrid-aquatic/textures/item/john_dory.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.