mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-11-12 03:13:00 +00:00
Update CC: Tweaked to 1.13
Look, I originally had this split into several commits, but lots of
other cleanups got mixed in. I then backported some of the cleanups to
1.12, did other tidy ups there, and eventually the web of merges was
unreadable.
Yes, this is a horrible mess, but it's still nicer than it was. Anyway,
changes:
- Flatten everything. For instance, there are now three instances of
BlockComputer, two BlockTurtle, ItemPocketComputer. There's also no
more BlockPeripheral (thank heavens) - there's separate block classes
for each peripheral type.
- Remove pretty much all legacy code. As we're breaking world
compatibility anyway, we can remove all the code to load worlds from
1.4 days.
- The command system is largely rewriten to take advantage of 1.13's
new system. It's very fancy!
- WidgetTerminal now uses Minecraft's "GUI listener" system.
- BREAKING CHANGE: All the codes in keys.lua are different, due to the
move to LWJGL 3. Hopefully this won't have too much of an impact.
I don't want to map to the old key codes on the Java side, as there
always ends up being small but slight inconsistencies. IMO it's
better to make a clean break - people should be using keys rather
than hard coding the constants anyway.
- commands.list now allows fetching sub-commands. The ROM has already
been updated to allow fancy usage such as commands.time.set("noon").
- Turtles, modems and cables can be waterlogged.
This commit is contained in:
@@ -8,42 +8,46 @@ package dan200.computercraft.shared.common;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Random;
|
||||
|
||||
public abstract class BlockGeneric extends Block implements ITileEntityProvider
|
||||
{
|
||||
protected BlockGeneric( Material material )
|
||||
private final TileEntityType<? extends TileGeneric> type;
|
||||
|
||||
public BlockGeneric( Properties settings, TileEntityType<? extends TileGeneric> type )
|
||||
{
|
||||
super( material );
|
||||
hasTileEntity = true;
|
||||
super( settings );
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
protected abstract TileGeneric createTile( IBlockState state );
|
||||
|
||||
protected abstract TileGeneric createTile( int damage );
|
||||
|
||||
@Override
|
||||
public final void breakBlock( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState newState )
|
||||
@Deprecated
|
||||
public final void onReplaced( @Nonnull IBlockState block, @Nonnull World world, @Nonnull BlockPos pos, IBlockState replace, boolean bool )
|
||||
{
|
||||
if( block.getBlock() == replace.getBlock() ) return;
|
||||
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
super.breakBlock( world, pos, newState );
|
||||
super.onReplaced( block, world, pos, replace, bool );
|
||||
world.removeTileEntity( pos );
|
||||
if( tile instanceof TileGeneric ) ((TileGeneric) tile).destroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean onBlockActivated( World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ )
|
||||
@Deprecated
|
||||
public final boolean onBlockActivated( IBlockState state, World world, BlockPos pos, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
return tile instanceof TileGeneric && ((TileGeneric) tile).onActivate( player, hand, side, hitX, hitY, hitZ );
|
||||
@@ -59,80 +63,24 @@ public abstract class BlockGeneric extends Block implements ITileEntityProvider
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onNeighborChange( IBlockAccess world, BlockPos pos, BlockPos neighbour )
|
||||
public final void onNeighborChange( IBlockState state, IWorldReader world, BlockPos pos, BlockPos neighbour )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile instanceof TileGeneric ) ((TileGeneric) tile).onNeighbourTileEntityChange( neighbour );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTick( World world, BlockPos pos, IBlockState state, Random rand )
|
||||
@Deprecated
|
||||
public void tick( IBlockState state, World world, BlockPos pos, Random rand )
|
||||
{
|
||||
TileEntity te = world.getTileEntity( pos );
|
||||
if( te instanceof TileGeneric ) ((TileGeneric) te).updateTick();
|
||||
if( te instanceof TileGeneric ) ((TileGeneric) te).blockTick();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@Deprecated
|
||||
public final boolean canProvidePower( IBlockState state )
|
||||
public TileEntity createNewTileEntity( @Nonnull IBlockReader world )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean canConnectRedstone( IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
return tile instanceof TileGeneric && ((TileGeneric) tile).getRedstoneConnectivity( side );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public final int getStrongPower( IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing oppositeSide )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
return tile instanceof TileGeneric && tile.hasWorld() ? ((TileGeneric) tile).getRedstoneOutput( oppositeSide.getOpposite() ) : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public final int getWeakPower( IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing oppositeSide )
|
||||
{
|
||||
return getStrongPower( state, world, pos, oppositeSide );
|
||||
}
|
||||
|
||||
public boolean getBundledRedstoneConnectivity( World world, BlockPos pos, EnumFacing side )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
return tile instanceof TileGeneric && ((TileGeneric) tile).getBundledRedstoneConnectivity( side );
|
||||
}
|
||||
|
||||
public int getBundledRedstoneOutput( World world, BlockPos pos, EnumFacing side )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
return tile instanceof TileGeneric && tile.hasWorld() ? ((TileGeneric) tile).getBundledRedstoneOutput( side ) : 0;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public final TileEntity createTileEntity( @Nonnull World world, @Nonnull IBlockState state )
|
||||
{
|
||||
return createTile( state );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public final TileEntity createNewTileEntity( @Nonnull World world, int damage )
|
||||
{
|
||||
return createTile( damage );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean isSideSolid( IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, EnumFacing side )
|
||||
{
|
||||
// We need to override this as the default implementation uses isNormalCube, which returns false if
|
||||
// it can provide power.
|
||||
return isFullCube( state );
|
||||
return type.create();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user