This repository has been archived on 2023-11-26. You can view files and clone it, but cannot push or open issues or pull requests.
EnergonRelics/src/main/java/com/thebrokenrail/energonrelics/api/block/energy/FacingEnergyBlock.java

45 lines
1.4 KiB
Java
Raw Normal View History

2020-08-04 17:06:11 +00:00
package com.thebrokenrail.energonrelics.api.block.energy;
2020-07-22 18:07:29 +00:00
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.DirectionProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.BlockMirror;
import net.minecraft.util.BlockRotation;
import net.minecraft.util.math.Direction;
2020-08-04 17:06:11 +00:00
/**
* Block That Interacts With Energy That Faces A Direction
*/
2020-07-22 18:07:29 +00:00
@SuppressWarnings("deprecation")
2020-07-26 23:05:59 +00:00
public abstract class FacingEnergyBlock extends EnergyBlock {
2020-07-22 18:07:29 +00:00
public static final DirectionProperty FACING = Properties.FACING;
2020-07-26 23:05:59 +00:00
public FacingEnergyBlock(Settings settings) {
2020-07-22 18:07:29 +00:00
super(settings);
setDefaultState(getDefaultState().with(FACING, Direction.NORTH));
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(FACING);
}
@Override
public BlockState rotate(BlockState state, BlockRotation rotation) {
return state.with(FACING, rotation.rotate(state.get(FACING)));
}
@Override
public BlockState mirror(BlockState state, BlockMirror mirror) {
return state.rotate(mirror.getRotation(state.get(FACING)));
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
return getDefaultState().with(FACING, ctx.getPlayerLookDirection().getOpposite());
}
}