-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- moved to mojmap - fixed all known recipe and tag related bugs - better tags datagen implementation - fixed rain passing through some blocks - did a little bit of refactoring
- Loading branch information
1 parent
73ee588
commit de46935
Showing
69 changed files
with
3,425 additions
and
4,131 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
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
842 changes: 407 additions & 435 deletions
842
common/src/main/java/jdlenl/thaumon/block/ThaumonBlocks.java
Large diffs are not rendered by default.
Oops, something went wrong.
131 changes: 70 additions & 61 deletions
131
common/src/main/java/jdlenl/thaumon/block/blocks/CrystalLampBlock.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 |
---|---|---|
@@ -1,100 +1,109 @@ | ||
package jdlenl.thaumon.block.blocks; | ||
|
||
import net.minecraft.block.*; | ||
import net.minecraft.client.item.TooltipContext; | ||
import net.minecraft.fluid.FluidState; | ||
import net.minecraft.fluid.Fluids; | ||
import net.minecraft.item.ItemPlacementContext; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.state.StateManager; | ||
import net.minecraft.state.property.BooleanProperty; | ||
import net.minecraft.state.property.DirectionProperty; | ||
import net.minecraft.state.property.Properties; | ||
import net.minecraft.text.Text; | ||
import net.minecraft.util.BlockMirror; | ||
import net.minecraft.util.BlockRotation; | ||
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.util.shape.VoxelShapes; | ||
import net.minecraft.world.BlockView; | ||
import net.minecraft.world.WorldAccess; | ||
|
||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.sounds.SoundEvent; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.TooltipFlag; | ||
import net.minecraft.world.item.context.BlockPlaceContext; | ||
import net.minecraft.world.level.BlockGetter; | ||
import net.minecraft.world.level.LevelAccessor; | ||
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.block.state.properties.DirectionProperty; | ||
import net.minecraft.world.level.material.FluidState; | ||
import net.minecraft.world.level.material.Fluids; | ||
import net.minecraft.world.phys.Vec3; | ||
import net.minecraft.world.phys.shapes.CollisionContext; | ||
import net.minecraft.world.phys.shapes.Shapes; | ||
import net.minecraft.world.phys.shapes.VoxelShape; | ||
import java.util.List; | ||
|
||
public class CrystalLampBlock extends Block implements Waterloggable { | ||
public class CrystalLampBlock extends Block implements SimpleWaterloggedBlock { | ||
public static final DirectionProperty FACING; | ||
public static final BooleanProperty WATERLOGGED; | ||
|
||
public CrystalLampBlock(AbstractBlock.Settings settings) { | ||
public CrystalLampBlock(BlockBehaviour.Properties settings) { | ||
super(settings); | ||
this.setDefaultState(this.getStateManager().getDefaultState().with(FACING, Direction.NORTH).with(WATERLOGGED, false)); | ||
this.registerDefaultState(this.getStateDefinition().any().setValue(FACING, Direction.NORTH).setValue(WATERLOGGED, false)); | ||
} | ||
|
||
public void appendTooltip(ItemStack itemstack, BlockView world, List<Text> list, TooltipContext flag) { | ||
list.add(Text.translatable("tooltip.thaumon.canbeplaced")); | ||
public void appendHoverText(ItemStack itemstack, BlockGetter world, List<Component> list, TooltipFlag flag) { | ||
list.add(Component.translatable("tooltip.thaumon.canbeplaced")); | ||
} | ||
|
||
public boolean isTransparent(BlockState state, BlockView reader, BlockPos pos) { | ||
public boolean propagatesSkylightDown(BlockState state, BlockGetter reader, BlockPos pos) { | ||
return state.getFluidState().isEmpty(); | ||
} | ||
|
||
public int getOpacity(BlockState state, BlockView worldIn, BlockPos pos) { | ||
public int getLightBlock(BlockState state, BlockGetter worldIn, BlockPos pos) { | ||
return 0; | ||
} | ||
|
||
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { | ||
Vec3d offset = state.getModelOffset(world, pos); | ||
VoxelShape shape; | ||
switch (state.get(FACING)) { | ||
case NORTH: | ||
shape = VoxelShapes.union(createCuboidShape(7.0, 1.0, 7.0, 9.0, 4.0, 9.0), new VoxelShape[]{createCuboidShape(8.0, 4.0, 7.0, 9.0, 5.0, 9.0), createCuboidShape(6.5, 0.0, 6.5, 9.5, 1.0, 9.5), createCuboidShape(7.0, 4.0, 8.0, 8.0, 5.0, 9.0), createCuboidShape(8.0, 5.0, 8.0, 9.0, 6.0, 9.0)}); | ||
break; | ||
case EAST: | ||
shape = VoxelShapes.union(createCuboidShape(7.0, 1.0, 7.0, 9.0, 4.0, 9.0), new VoxelShape[]{createCuboidShape(7.0, 4.0, 8.0, 9.0, 5.0, 9.0), createCuboidShape(6.5, 0.0, 6.5, 9.5, 1.0, 9.5), createCuboidShape(7.0, 4.0, 7.0, 8.0, 5.0, 8.0), createCuboidShape(7.0, 5.0, 8.0, 8.0, 6.0, 9.0)}); | ||
break; | ||
case WEST: | ||
shape = VoxelShapes.union(createCuboidShape(7.0, 1.0, 7.0, 9.0, 4.0, 9.0), new VoxelShape[]{createCuboidShape(7.0, 4.0, 7.0, 9.0, 5.0, 8.0), createCuboidShape(6.5, 0.0, 6.5, 9.5, 1.0, 9.5), createCuboidShape(8.0, 4.0, 8.0, 9.0, 5.0, 9.0), createCuboidShape(8.0, 5.0, 7.0, 9.0, 6.0, 8.0)}); | ||
break; | ||
default: | ||
shape = VoxelShapes.union(createCuboidShape(7.0, 1.0, 7.0, 9.0, 4.0, 9.0), new VoxelShape[]{createCuboidShape(7.0, 4.0, 7.0, 8.0, 5.0, 9.0), createCuboidShape(6.5, 0.0, 6.5, 9.5, 1.0, 9.5), createCuboidShape(8.0, 4.0, 7.0, 9.0, 5.0, 8.0), createCuboidShape(7.0, 5.0, 7.0, 8.0, 6.0, 8.0)}); | ||
} | ||
|
||
return shape.offset(offset.x, offset.y, offset.z); | ||
public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { | ||
Vec3 offset = state.getOffset(world, pos); | ||
VoxelShape shape = switch (state.getValue(FACING)) { | ||
case NORTH -> | ||
Shapes.or(box(7.0, 1.0, 7.0, 9.0, 4.0, 9.0), box(8.0, 4.0, 7.0, 9.0, 5.0, 9.0), box(6.5, 0.0, 6.5, 9.5, 1.0, 9.5), box(7.0, 4.0, 8.0, 8.0, 5.0, 9.0), box(8.0, 5.0, 8.0, 9.0, 6.0, 9.0)); | ||
case EAST -> | ||
Shapes.or(box(7.0, 1.0, 7.0, 9.0, 4.0, 9.0), box(7.0, 4.0, 8.0, 9.0, 5.0, 9.0), box(6.5, 0.0, 6.5, 9.5, 1.0, 9.5), box(7.0, 4.0, 7.0, 8.0, 5.0, 8.0), box(7.0, 5.0, 8.0, 8.0, 6.0, 9.0)); | ||
case WEST -> | ||
Shapes.or(box(7.0, 1.0, 7.0, 9.0, 4.0, 9.0), box(7.0, 4.0, 7.0, 9.0, 5.0, 8.0), box(6.5, 0.0, 6.5, 9.5, 1.0, 9.5), box(8.0, 4.0, 8.0, 9.0, 5.0, 9.0), box(8.0, 5.0, 7.0, 9.0, 6.0, 8.0)); | ||
default -> | ||
Shapes.or(box(7.0, 1.0, 7.0, 9.0, 4.0, 9.0), box(7.0, 4.0, 7.0, 8.0, 5.0, 9.0), box(6.5, 0.0, 6.5, 9.5, 1.0, 9.5), box(8.0, 4.0, 7.0, 9.0, 5.0, 8.0), box(7.0, 5.0, 7.0, 8.0, 6.0, 8.0)); | ||
}; | ||
|
||
return shape.move(offset.x, offset.y, offset.z); | ||
} | ||
|
||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) { | ||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { | ||
builder.add(FACING, WATERLOGGED); | ||
} | ||
|
||
public BlockState getPlacementState(ItemPlacementContext context) { | ||
boolean isWater = context.getWorld().getFluidState(context.getBlockPos()).getFluid() == Fluids.WATER; | ||
return this.getDefaultState().with(FACING, context.getHorizontalPlayerFacing().getOpposite()).with(WATERLOGGED, isWater); | ||
public BlockState getStateForPlacement(BlockPlaceContext context) { | ||
boolean isWater = context.getLevel().getFluidState(context.getClickedPos()).getType() == Fluids.WATER; | ||
return this.defaultBlockState().setValue(FACING, context.getHorizontalDirection().getOpposite()).setValue(WATERLOGGED, isWater); | ||
} | ||
|
||
public BlockState rotate(BlockState state, BlockRotation rot) { | ||
return state.with(FACING, rot.rotate(state.get(FACING))); | ||
public BlockState rotate(BlockState state, Rotation rot) { | ||
return state.setValue(FACING, rot.rotate(state.getValue(FACING))); | ||
} | ||
|
||
public BlockState mirror(BlockState state, BlockMirror mirrorIn) { | ||
return state.rotate(mirrorIn.getRotation(state.get(FACING))); | ||
public BlockState mirror(BlockState state, Mirror mirrorIn) { | ||
return state.rotate(mirrorIn.getRotation(state.getValue(FACING))); | ||
} | ||
|
||
public FluidState getFluidState(BlockState state) { | ||
return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state); | ||
return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state); | ||
} | ||
|
||
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState facingState, WorldAccess world, BlockPos currentPos, BlockPos facingPos) { | ||
if (state.get(WATERLOGGED)) { | ||
world.scheduleFluidTick(currentPos, Fluids.WATER, Fluids.WATER.getTickRate(world)); | ||
public BlockState updateShape(BlockState state, Direction facing, BlockState facingState, LevelAccessor world, BlockPos currentPos, BlockPos facingPos) { | ||
if (state.getValue(WATERLOGGED)) { | ||
world.scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); | ||
} | ||
|
||
return super.getStateForNeighborUpdate(state, facing, facingState, world, currentPos, facingPos); | ||
return super.updateShape(state, facing, facingState, world, currentPos, facingPos); | ||
} | ||
|
||
@Override | ||
public SoundType getSoundType(BlockState state) { | ||
return new SoundType(1.0F, 1.0F, | ||
SoundEvent.createVariableRangeEvent(new ResourceLocation("block.lantern.break")), | ||
SoundEvent.createVariableRangeEvent(new ResourceLocation("block.amethyst_cluster.step")), | ||
SoundEvent.createVariableRangeEvent(new ResourceLocation("block.amethyst_cluster.place")), | ||
SoundEvent.createVariableRangeEvent(new ResourceLocation("block.lantern.hit")), | ||
SoundEvent.createVariableRangeEvent(new ResourceLocation("block.amethyst_cluster.fall")) | ||
); | ||
} | ||
|
||
static { | ||
FACING = HorizontalFacingBlock.FACING; | ||
WATERLOGGED = Properties.WATERLOGGED; | ||
FACING = HorizontalDirectionalBlock.FACING; | ||
WATERLOGGED = BlockStateProperties.WATERLOGGED; | ||
} | ||
} |
Oops, something went wrong.