-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
500173d
commit b10f057
Showing
22 changed files
with
329 additions
and
13 deletions.
There are no files selected for viewing
81 changes: 81 additions & 0 deletions
81
src/main/java/com/starfish_studios/seasons_greetings/block/IcingBlock.java
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,81 @@ | ||
package com.starfish_studios.seasons_greetings.block; | ||
|
||
import com.mojang.serialization.MapCodec; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.util.RandomSource; | ||
import net.minecraft.world.item.Items; | ||
import net.minecraft.world.item.context.BlockPlaceContext; | ||
import net.minecraft.world.level.BlockGetter; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.LevelAccessor; | ||
import net.minecraft.world.level.LevelReader; | ||
import net.minecraft.world.level.block.*; | ||
import net.minecraft.world.level.block.state.BlockBehaviour; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.level.block.state.StateDefinition; | ||
import net.minecraft.world.level.block.state.properties.BlockStateProperties; | ||
import net.minecraft.world.level.block.state.properties.BooleanProperty; | ||
import net.minecraft.world.level.material.FluidState; | ||
import net.minecraft.world.level.material.Fluids; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.function.ToIntFunction; | ||
|
||
public class IcingBlock extends MultifaceBlock implements SimpleWaterloggedBlock { | ||
public static final MapCodec<IcingBlock> CODEC = simpleCodec(IcingBlock::new); | ||
private static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; | ||
private final MultifaceSpreader spreader = new MultifaceSpreader(this); | ||
|
||
@Override | ||
public @NotNull MapCodec<IcingBlock> codec() { | ||
return CODEC; | ||
} | ||
|
||
public IcingBlock(BlockBehaviour.Properties properties) { | ||
super(properties); | ||
this.registerDefaultState(this.defaultBlockState().setValue(WATERLOGGED, Boolean.FALSE)); | ||
} | ||
|
||
public static ToIntFunction<BlockState> emission(int i) { | ||
return blockState -> MultifaceBlock.hasAnyFace(blockState) ? i : 0; | ||
} | ||
|
||
@Override | ||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { | ||
super.createBlockStateDefinition(builder); | ||
builder.add(WATERLOGGED); | ||
} | ||
|
||
@Override | ||
protected @NotNull BlockState updateShape( | ||
BlockState blockState, Direction direction, BlockState blockState2, LevelAccessor levelAccessor, BlockPos blockPos, BlockPos blockPos2 | ||
) { | ||
if (blockState.getValue(WATERLOGGED)) { | ||
levelAccessor.scheduleTick(blockPos, Fluids.WATER, Fluids.WATER.getTickDelay(levelAccessor)); | ||
} | ||
|
||
return super.updateShape(blockState, direction, blockState2, levelAccessor, blockPos, blockPos2); | ||
} | ||
|
||
@Override | ||
protected boolean canBeReplaced(BlockState blockState, BlockPlaceContext blockPlaceContext) { | ||
return !blockPlaceContext.getItemInHand().is(this.asItem()) || super.canBeReplaced(blockState, blockPlaceContext); | ||
} | ||
|
||
@Override | ||
protected @NotNull FluidState getFluidState(BlockState blockState) { | ||
return blockState.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(blockState); | ||
} | ||
|
||
@Override | ||
protected boolean propagatesSkylightDown(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos) { | ||
return blockState.getFluidState().isEmpty(); | ||
} | ||
|
||
@Override | ||
public @NotNull MultifaceSpreader getSpreader() { | ||
return this.spreader; | ||
} | ||
} |
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
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
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
124 changes: 124 additions & 0 deletions
124
src/main/resources/assets/seasonsgreetings/blockstates/gingerbread_door.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,124 @@ | ||
{ | ||
"variants": { | ||
"facing=east,half=lower,hinge=left,open=false": { | ||
"model": "seasonsgreetings:block/gingerbread_door_bottom_left" | ||
}, | ||
"facing=east,half=lower,hinge=left,open=true": { | ||
"model": "seasonsgreetings:block/gingerbread_door_bottom_left_open", | ||
"y": 90 | ||
}, | ||
"facing=east,half=lower,hinge=right,open=false": { | ||
"model": "seasonsgreetings:block/gingerbread_door_bottom_right" | ||
}, | ||
"facing=east,half=lower,hinge=right,open=true": { | ||
"model": "seasonsgreetings:block/gingerbread_door_bottom_right_open", | ||
"y": 270 | ||
}, | ||
"facing=east,half=upper,hinge=left,open=false": { | ||
"model": "seasonsgreetings:block/gingerbread_door_top_left" | ||
}, | ||
"facing=east,half=upper,hinge=left,open=true": { | ||
"model": "seasonsgreetings:block/gingerbread_door_top_left_open", | ||
"y": 90 | ||
}, | ||
"facing=east,half=upper,hinge=right,open=false": { | ||
"model": "seasonsgreetings:block/gingerbread_door_top_right" | ||
}, | ||
"facing=east,half=upper,hinge=right,open=true": { | ||
"model": "seasonsgreetings:block/gingerbread_door_top_right_open", | ||
"y": 270 | ||
}, | ||
"facing=north,half=lower,hinge=left,open=false": { | ||
"model": "seasonsgreetings:block/gingerbread_door_bottom_left", | ||
"y": 270 | ||
}, | ||
"facing=north,half=lower,hinge=left,open=true": { | ||
"model": "seasonsgreetings:block/gingerbread_door_bottom_left_open" | ||
}, | ||
"facing=north,half=lower,hinge=right,open=false": { | ||
"model": "seasonsgreetings:block/gingerbread_door_bottom_right", | ||
"y": 270 | ||
}, | ||
"facing=north,half=lower,hinge=right,open=true": { | ||
"model": "seasonsgreetings:block/gingerbread_door_bottom_right_open", | ||
"y": 180 | ||
}, | ||
"facing=north,half=upper,hinge=left,open=false": { | ||
"model": "seasonsgreetings:block/gingerbread_door_top_left", | ||
"y": 270 | ||
}, | ||
"facing=north,half=upper,hinge=left,open=true": { | ||
"model": "seasonsgreetings:block/gingerbread_door_top_left_open" | ||
}, | ||
"facing=north,half=upper,hinge=right,open=false": { | ||
"model": "seasonsgreetings:block/gingerbread_door_top_right", | ||
"y": 270 | ||
}, | ||
"facing=north,half=upper,hinge=right,open=true": { | ||
"model": "seasonsgreetings:block/gingerbread_door_top_right_open", | ||
"y": 180 | ||
}, | ||
"facing=south,half=lower,hinge=left,open=false": { | ||
"model": "seasonsgreetings:block/gingerbread_door_bottom_left", | ||
"y": 90 | ||
}, | ||
"facing=south,half=lower,hinge=left,open=true": { | ||
"model": "seasonsgreetings:block/gingerbread_door_bottom_left_open", | ||
"y": 180 | ||
}, | ||
"facing=south,half=lower,hinge=right,open=false": { | ||
"model": "seasonsgreetings:block/gingerbread_door_bottom_right", | ||
"y": 90 | ||
}, | ||
"facing=south,half=lower,hinge=right,open=true": { | ||
"model": "seasonsgreetings:block/gingerbread_door_bottom_right_open" | ||
}, | ||
"facing=south,half=upper,hinge=left,open=false": { | ||
"model": "seasonsgreetings:block/gingerbread_door_top_left", | ||
"y": 90 | ||
}, | ||
"facing=south,half=upper,hinge=left,open=true": { | ||
"model": "seasonsgreetings:block/gingerbread_door_top_left_open", | ||
"y": 180 | ||
}, | ||
"facing=south,half=upper,hinge=right,open=false": { | ||
"model": "seasonsgreetings:block/gingerbread_door_top_right", | ||
"y": 90 | ||
}, | ||
"facing=south,half=upper,hinge=right,open=true": { | ||
"model": "seasonsgreetings:block/gingerbread_door_top_right_open" | ||
}, | ||
"facing=west,half=lower,hinge=left,open=false": { | ||
"model": "seasonsgreetings:block/gingerbread_door_bottom_left", | ||
"y": 180 | ||
}, | ||
"facing=west,half=lower,hinge=left,open=true": { | ||
"model": "seasonsgreetings:block/gingerbread_door_bottom_left_open", | ||
"y": 270 | ||
}, | ||
"facing=west,half=lower,hinge=right,open=false": { | ||
"model": "seasonsgreetings:block/gingerbread_door_bottom_right", | ||
"y": 180 | ||
}, | ||
"facing=west,half=lower,hinge=right,open=true": { | ||
"model": "seasonsgreetings:block/gingerbread_door_bottom_right_open", | ||
"y": 90 | ||
}, | ||
"facing=west,half=upper,hinge=left,open=false": { | ||
"model": "seasonsgreetings:block/gingerbread_door_top_left", | ||
"y": 180 | ||
}, | ||
"facing=west,half=upper,hinge=left,open=true": { | ||
"model": "seasonsgreetings:block/gingerbread_door_top_left_open", | ||
"y": 270 | ||
}, | ||
"facing=west,half=upper,hinge=right,open=false": { | ||
"model": "seasonsgreetings:block/gingerbread_door_top_right", | ||
"y": 180 | ||
}, | ||
"facing=west,half=upper,hinge=right,open=true": { | ||
"model": "seasonsgreetings:block/gingerbread_door_top_right_open", | ||
"y": 90 | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/resources/assets/seasonsgreetings/models/block/gingerbread_door_bottom_left.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,7 @@ | ||
{ | ||
"parent": "minecraft:block/door_bottom_left", | ||
"textures": { | ||
"bottom": "seasonsgreetings:block/gingerbread_door_bottom", | ||
"top": "seasonsgreetings:block/gingerbread_door_top" | ||
} | ||
} |
Oops, something went wrong.