1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-06-25 22:53:22 +00:00

[1.16] Make blocks rotatable for structures (#1083)

This commit is contained in:
Sr_endi 2022-05-01 13:09:38 +02:00 committed by GitHub
parent 6239dbe9ca
commit e909e11e05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 115 additions and 2 deletions

View File

@ -4,5 +4,5 @@ mod_version=1.100.5
# Minecraft properties (update mods.toml when changing)
mc_version=1.16.5
mapping_version=2021.08.08
forge_version=36.2.20
forge_version=36.2.34
# NO SERIOUSLY, UPDATE mods.toml WHEN CHANGING

View File

@ -18,6 +18,8 @@
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraft.util.Mirror;
import net.minecraft.util.Rotation;
import net.minecraftforge.fml.RegistryObject;
import javax.annotation.Nonnull;
@ -50,6 +52,20 @@ public BlockState getStateForPlacement( BlockItemUseContext placement )
return defaultBlockState().setValue( FACING, placement.getHorizontalDirection().getOpposite() );
}
@Nonnull
@Override
public BlockState mirror( BlockState state, Mirror mirrorIn )
{
return state.rotate( mirrorIn.getRotation( state.getValue( FACING ) ) );
}
@Nonnull
@Override
public BlockState rotate( BlockState state, Rotation rot )
{
return state.setValue( FACING, rot.rotate( state.getValue( FACING ) ) );
}
@Nonnull
@Override
protected ItemStack getItem( TileComputerBase tile )

View File

@ -21,6 +21,8 @@
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.INameable;
import net.minecraft.util.Mirror;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@ -47,6 +49,20 @@ protected void createBlockStateDefinition( StateContainer.Builder<Block, BlockSt
properties.add( FACING, STATE );
}
@Nonnull
@Override
public BlockState mirror( BlockState state, Mirror mirrorIn )
{
return state.rotate( mirrorIn.getRotation( state.getValue( FACING ) ) );
}
@Nonnull
@Override
public BlockState rotate( BlockState state, Rotation rot )
{
return state.setValue( FACING, rot.rotate( state.getValue( FACING ) ) );
}
@Nullable
@Override
public BlockState getStateForPlacement( BlockItemUseContext placement )

View File

@ -18,6 +18,8 @@
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraft.util.Mirror;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
@ -94,4 +96,18 @@ public BlockState getStateForPlacement( BlockItemUseContext placement )
.setValue( FACING, placement.getClickedFace().getOpposite() )
.setValue( WATERLOGGED, getWaterloggedStateForPlacement( placement ) );
}
@Nonnull
@Override
public BlockState mirror( BlockState state, Mirror mirrorIn )
{
return state.rotate( mirrorIn.getRotation( state.getValue( FACING ) ) );
}
@Nonnull
@Override
public BlockState rotate( BlockState state, Rotation rot )
{
return state.setValue( FACING, rot.rotate( state.getValue( FACING ) ) );
}
}

View File

@ -18,6 +18,8 @@
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraft.util.Mirror;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.util.FakePlayer;
@ -51,6 +53,20 @@ protected void createBlockStateDefinition( StateContainer.Builder<Block, BlockSt
builder.add( ORIENTATION, FACING, STATE );
}
@Nonnull
@Override
public BlockState mirror( BlockState state, Mirror mirrorIn )
{
return state.rotate( mirrorIn.getRotation( state.getValue( FACING ) ) );
}
@Nonnull
@Override
public BlockState rotate( BlockState state, Rotation rot )
{
return state.setValue( FACING, rot.rotate( state.getValue( FACING ) ) );
}
@Override
@Nullable
public BlockState getStateForPlacement( BlockItemUseContext context )

View File

@ -21,6 +21,8 @@
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.INameable;
import net.minecraft.util.Mirror;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@ -48,6 +50,20 @@ protected void createBlockStateDefinition( StateContainer.Builder<Block, BlockSt
properties.add( FACING, TOP, BOTTOM );
}
@Nonnull
@Override
public BlockState mirror( BlockState state, Mirror mirrorIn )
{
return state.rotate( mirrorIn.getRotation( state.getValue( FACING ) ) );
}
@Nonnull
@Override
public BlockState rotate( BlockState state, Rotation rot )
{
return state.setValue( FACING, rot.rotate( state.getValue( FACING ) ) );
}
@Nullable
@Override
public BlockState getStateForPlacement( BlockItemUseContext placement )

View File

@ -14,7 +14,10 @@
import net.minecraft.state.StateContainer;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.util.Direction;
import net.minecraft.util.Mirror;
import net.minecraft.util.Rotation;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class BlockSpeaker extends BlockGeneric
@ -34,6 +37,20 @@ protected void createBlockStateDefinition( StateContainer.Builder<Block, BlockSt
properties.add( FACING );
}
@Nonnull
@Override
public BlockState mirror( BlockState state, Mirror mirrorIn )
{
return state.rotate( mirrorIn.getRotation( state.getValue( FACING ) ) );
}
@Nonnull
@Override
public BlockState rotate( BlockState state, Rotation rot )
{
return state.setValue( FACING, rot.rotate( state.getValue( FACING ) ) );
}
@Nullable
@Override
public BlockState getStateForPlacement( BlockItemUseContext placement )

View File

@ -29,7 +29,9 @@
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraft.util.Mirror;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
@ -71,6 +73,20 @@ protected void createBlockStateDefinition( StateContainer.Builder<Block, BlockSt
builder.add( FACING, WATERLOGGED );
}
@Nonnull
@Override
public BlockState mirror( BlockState state, Mirror mirrorIn )
{
return state.rotate( mirrorIn.getRotation( state.getValue( FACING ) ) );
}
@Nonnull
@Override
public BlockState rotate( BlockState state, Rotation rot )
{
return state.setValue( FACING, rot.rotate( state.getValue( FACING ) ) );
}
@Nonnull
@Override
@Deprecated

View File

@ -20,6 +20,6 @@ CC: Tweaked is a fork of ComputerCraft, adding programmable computers, turtles a
[[dependencies.computercraft]]
modId="forge"
mandatory=true
versionRange="[36.2.20,37)"
versionRange="[36.2.34,37)"
ordering="NONE"
side="BOTH"