mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-11-07 08:52:59 +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:
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
|
||||
package dan200.computercraft.shared.common;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class BlockDirectional extends BlockGeneric
|
||||
{
|
||||
protected BlockDirectional( Material material )
|
||||
{
|
||||
super( material );
|
||||
}
|
||||
|
||||
public EnumFacing getDirection( IBlockAccess world, BlockPos pos )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile instanceof IDirectionalTile )
|
||||
{
|
||||
IDirectionalTile directional = (IDirectionalTile) tile;
|
||||
return directional.getDirection();
|
||||
}
|
||||
return EnumFacing.NORTH;
|
||||
}
|
||||
|
||||
public void setDirection( World world, BlockPos pos, EnumFacing dir )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile instanceof IDirectionalTile )
|
||||
{
|
||||
IDirectionalTile directional = (IDirectionalTile) tile;
|
||||
directional.setDirection( dir );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,10 +50,10 @@ public class ClientTerminal implements ITerminal
|
||||
public void readDescription( NBTTagCompound nbt )
|
||||
{
|
||||
m_colour = nbt.getBoolean( "colour" );
|
||||
if( nbt.hasKey( "terminal" ) )
|
||||
if( nbt.contains( "terminal" ) )
|
||||
{
|
||||
NBTTagCompound terminal = nbt.getCompoundTag( "terminal" );
|
||||
resizeTerminal( terminal.getInteger( "term_width" ), terminal.getInteger( "term_height" ) );
|
||||
NBTTagCompound terminal = nbt.getCompound( "terminal" );
|
||||
resizeTerminal( terminal.getInt( "term_width" ), terminal.getInt( "term_height" ) );
|
||||
m_terminal.readFromNBT( terminal );
|
||||
}
|
||||
else
|
||||
|
||||
@@ -6,24 +6,30 @@
|
||||
|
||||
package dan200.computercraft.shared.common;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.shared.util.AbstractRecipe;
|
||||
import dan200.computercraft.shared.util.Colour;
|
||||
import dan200.computercraft.shared.util.ColourTracker;
|
||||
import dan200.computercraft.shared.util.ColourUtils;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||
import net.minecraft.item.crafting.RecipeSerializers;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.crafting.IRecipeFactory;
|
||||
import net.minecraftforge.common.crafting.JsonContext;
|
||||
import net.minecraftforge.registries.IForgeRegistryEntry;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ColourableRecipe extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe
|
||||
public class ColourableRecipe extends AbstractRecipe
|
||||
{
|
||||
public ColourableRecipe( ResourceLocation id )
|
||||
{
|
||||
super( id );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches( @Nonnull InventoryCrafting inv, @Nonnull World worldIn )
|
||||
public boolean matches( @Nonnull IInventory inv, @Nonnull World world )
|
||||
{
|
||||
boolean hasColourable = false;
|
||||
boolean hasDye = false;
|
||||
@@ -37,7 +43,7 @@ public class ColourableRecipe extends IForgeRegistryEntry.Impl<IRecipe> implemen
|
||||
if( hasColourable ) return false;
|
||||
hasColourable = true;
|
||||
}
|
||||
else if( ColourUtils.getStackColour( stack ) >= 0 )
|
||||
else if( ColourUtils.getStackColour( stack ) != null )
|
||||
{
|
||||
hasDye = true;
|
||||
}
|
||||
@@ -52,7 +58,7 @@ public class ColourableRecipe extends IForgeRegistryEntry.Impl<IRecipe> implemen
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getCraftingResult( @Nonnull InventoryCrafting inv )
|
||||
public ItemStack getCraftingResult( @Nonnull IInventory inv )
|
||||
{
|
||||
ItemStack colourable = ItemStack.EMPTY;
|
||||
|
||||
@@ -70,10 +76,10 @@ public class ColourableRecipe extends IForgeRegistryEntry.Impl<IRecipe> implemen
|
||||
}
|
||||
else
|
||||
{
|
||||
int index = ColourUtils.getStackColour( stack );
|
||||
if( index < 0 ) continue;
|
||||
EnumDyeColor dye = ColourUtils.getStackColour( stack );
|
||||
if( dye == null ) continue;
|
||||
|
||||
Colour colour = Colour.values()[index];
|
||||
Colour colour = Colour.fromInt( 15 - dye.getId() );
|
||||
tracker.addColour( colour.getR(), colour.getG(), colour.getB() );
|
||||
}
|
||||
}
|
||||
@@ -89,24 +95,13 @@ public class ColourableRecipe extends IForgeRegistryEntry.Impl<IRecipe> implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDynamic()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getRecipeOutput()
|
||||
public IRecipeSerializer<?> getSerializer()
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
return SERIALIZER;
|
||||
}
|
||||
|
||||
public static class Factory implements IRecipeFactory
|
||||
{
|
||||
@Override
|
||||
public IRecipe parse( JsonContext jsonContext, JsonObject jsonObject )
|
||||
{
|
||||
return new ColourableRecipe();
|
||||
}
|
||||
}
|
||||
public static final IRecipeSerializer<?> SERIALIZER = new RecipeSerializers.SimpleSerializer<>(
|
||||
ComputerCraft.MOD_ID + ":colour", ColourableRecipe::new
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
|
||||
package dan200.computercraft.shared.common;
|
||||
|
||||
import dan200.computercraft.shared.util.InventoryUtil;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumHand;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ContainerHeldItem extends Container
|
||||
{
|
||||
private final ItemStack m_stack;
|
||||
private final EnumHand m_hand;
|
||||
|
||||
public ContainerHeldItem( EntityPlayer player, EnumHand hand )
|
||||
{
|
||||
m_hand = hand;
|
||||
m_stack = InventoryUtil.copyItem( player.getHeldItem( hand ) );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public ItemStack getStack()
|
||||
{
|
||||
return m_stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith( @Nonnull EntityPlayer player )
|
||||
{
|
||||
if( !player.isAlive() ) return false;
|
||||
|
||||
ItemStack stack = player.getHeldItem( m_hand );
|
||||
return stack == m_stack || !stack.isEmpty() && !m_stack.isEmpty() && stack.getItem() == m_stack.getItem();
|
||||
}
|
||||
}
|
||||
@@ -25,9 +25,9 @@ public class DefaultBundledRedstoneProvider implements IBundledRedstoneProvider
|
||||
public static int getDefaultBundledRedstoneOutput( World world, BlockPos pos, EnumFacing side )
|
||||
{
|
||||
Block block = world.getBlockState( pos ).getBlock();
|
||||
if( block instanceof BlockGeneric )
|
||||
if( block instanceof IBundledRedstoneBlock )
|
||||
{
|
||||
BlockGeneric generic = (BlockGeneric) block;
|
||||
IBundledRedstoneBlock generic = (IBundledRedstoneBlock) block;
|
||||
if( generic.getBundledRedstoneConnectivity( world, pos, side ) )
|
||||
{
|
||||
return generic.getBundledRedstoneOutput( world, pos, side );
|
||||
|
||||
@@ -7,10 +7,12 @@
|
||||
package dan200.computercraft.shared.common;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IDirectionalTile
|
||||
public interface IBundledRedstoneBlock
|
||||
{
|
||||
EnumFacing getDirection();
|
||||
boolean getBundledRedstoneConnectivity( World world, BlockPos pos, EnumFacing side );
|
||||
|
||||
void setDirection( EnumFacing dir );
|
||||
int getBundledRedstoneOutput( World world, BlockPos pos, EnumFacing side );
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public interface IColouredItem
|
||||
{
|
||||
String NBT_COLOUR = "colour";
|
||||
String NBT_COLOUR = "Color";
|
||||
|
||||
default int getColour( ItemStack stack )
|
||||
{
|
||||
@@ -27,21 +27,20 @@ public interface IColouredItem
|
||||
|
||||
static int getColourBasic( ItemStack stack )
|
||||
{
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag != null && tag.hasKey( NBT_COLOUR ) ? tag.getInteger( NBT_COLOUR ) : -1;
|
||||
NBTTagCompound tag = stack.getTag();
|
||||
return tag != null && tag.contains( NBT_COLOUR ) ? tag.getInt( NBT_COLOUR ) : -1;
|
||||
}
|
||||
|
||||
static void setColourBasic( ItemStack stack, int colour )
|
||||
{
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
if( colour == -1 )
|
||||
{
|
||||
if( tag != null ) tag.removeTag( NBT_COLOUR );
|
||||
NBTTagCompound tag = stack.getTag();
|
||||
if( tag != null ) tag.remove( NBT_COLOUR );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( tag == null ) stack.setTagCompound( tag = new NBTTagCompound() );
|
||||
tag.setInteger( NBT_COLOUR, colour );
|
||||
stack.getOrCreateTag().putInt( NBT_COLOUR, colour );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,14 +88,14 @@ public class ServerTerminal implements ITerminal
|
||||
|
||||
public void writeDescription( NBTTagCompound nbt )
|
||||
{
|
||||
nbt.setBoolean( "colour", m_colour );
|
||||
nbt.putBoolean( "colour", m_colour );
|
||||
if( m_terminal != null )
|
||||
{
|
||||
NBTTagCompound terminal = new NBTTagCompound();
|
||||
terminal.setInteger( "term_width", m_terminal.getWidth() );
|
||||
terminal.setInteger( "term_height", m_terminal.getHeight() );
|
||||
terminal.putInt( "term_width", m_terminal.getWidth() );
|
||||
terminal.putInt( "term_height", m_terminal.getHeight() );
|
||||
m_terminal.writeToNBT( terminal );
|
||||
nbt.setTag( "terminal", terminal );
|
||||
nbt.put( "terminal", terminal );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,51 +6,37 @@
|
||||
|
||||
package dan200.computercraft.shared.common;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||
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.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public abstract class TileGeneric extends TileEntity
|
||||
{
|
||||
public TileGeneric( TileEntityType<? extends TileGeneric> type )
|
||||
{
|
||||
super( type );
|
||||
}
|
||||
|
||||
public void destroy()
|
||||
{
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public BlockGeneric getBlock()
|
||||
{
|
||||
Block block = getBlockType();
|
||||
return block instanceof BlockGeneric ? (BlockGeneric) block : null;
|
||||
}
|
||||
|
||||
protected final IBlockState getBlockState()
|
||||
{
|
||||
return getWorld().getBlockState( getPos() );
|
||||
}
|
||||
|
||||
public final void updateBlock()
|
||||
{
|
||||
markDirty();
|
||||
BlockPos pos = getPos();
|
||||
IBlockState state = getWorld().getBlockState( pos );
|
||||
IBlockState state = getBlockState();
|
||||
getWorld().markBlockRangeForRenderUpdate( pos, pos );
|
||||
getWorld().notifyBlockUpdate( getPos(), state, state, 3 );
|
||||
}
|
||||
|
||||
protected final void setBlockState( IBlockState newState )
|
||||
{
|
||||
getWorld().setBlockState( getPos(), newState, 3 );
|
||||
getWorld().notifyBlockUpdate( pos, state, state, 3 );
|
||||
}
|
||||
|
||||
public boolean onActivate( EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ )
|
||||
@@ -58,45 +44,18 @@ public abstract class TileGeneric extends TileEntity
|
||||
return false;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void onNeighbourChange()
|
||||
{
|
||||
}
|
||||
|
||||
@SuppressWarnings( "deprecation" )
|
||||
public void onNeighbourChange( @Nonnull BlockPos neighbour )
|
||||
{
|
||||
onNeighbourChange();
|
||||
}
|
||||
|
||||
public void onNeighbourTileEntityChange( @Nonnull BlockPos neighbour )
|
||||
{
|
||||
}
|
||||
|
||||
protected void updateTick()
|
||||
protected void blockTick()
|
||||
{
|
||||
}
|
||||
|
||||
public boolean getRedstoneConnectivity( EnumFacing side )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getRedstoneOutput( EnumFacing side )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean getBundledRedstoneConnectivity( @Nonnull EnumFacing side )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getBundledRedstoneOutput( @Nonnull EnumFacing side )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected double getInteractRange( EntityPlayer player )
|
||||
{
|
||||
return 8.0;
|
||||
@@ -104,7 +63,7 @@ public abstract class TileGeneric extends TileEntity
|
||||
|
||||
public boolean isUsable( EntityPlayer player, boolean ignoreRange )
|
||||
{
|
||||
if( player == null || !player.isEntityAlive() || getWorld().getTileEntity( getPos() ) != this ) return false;
|
||||
if( player == null || !player.isAlive() || getWorld().getTileEntity( getPos() ) != this ) return false;
|
||||
if( ignoreRange ) return true;
|
||||
|
||||
double range = getInteractRange( player );
|
||||
@@ -121,18 +80,13 @@ public abstract class TileGeneric extends TileEntity
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRefresh( World world, BlockPos pos, @Nonnull IBlockState oldState, @Nonnull IBlockState newState )
|
||||
{
|
||||
return newState.getBlock() != oldState.getBlock();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public final SPacketUpdateTileEntity getUpdatePacket()
|
||||
{
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
writeDescription( nbt );
|
||||
return new SPacketUpdateTileEntity( getPos(), 0, nbt );
|
||||
return new SPacketUpdateTileEntity( pos, 0, nbt );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user