Skip to content

Commit

Permalink
Merge branch 'mc-1.13.x' into mc-1.14-fabric
Browse files Browse the repository at this point in the history
  • Loading branch information
SquidDev committed Apr 24, 2019
2 parents c1e08fc + 4a25e7a commit 26b73c2
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 51 deletions.
13 changes: 6 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ dependencies {
modCompile "net.fabricmc:fabric-loader:0.4.0+build.121"
modCompile "net.fabricmc:fabric:0.2.7+build.122"

// compileOnly "mezz.jei:jei-1.13.2:5.0.0.8:api"
// deobfProvided "pl.asie:Charset-Lib:0.5.4.6"
// deobfProvided "MCMultiPart2:MCMultiPart:2.5.3"

// deobf "mezz.jei:jei-1.13.2:5.0.0.8"

implementation 'com.google.code.findbugs:jsr305:3.0.2'

shade 'org.squiddev:Cobalt:0.5.0-SNAPSHOT'
Expand Down Expand Up @@ -304,7 +298,7 @@ githubRelease {
token project.hasProperty('githubApiKey') ? project.githubApiKey : ''
owner 'SquidDev-CC'
repo 'CC-Tweaked'
targetCommitish (mc_version == "1.12.2" ? "master" : mc_version)
targetCommitish "mc-1.13.x" // TODO: Pull from GrGit

tagName "v${mc_version}-${mod_version}"
releaseName "[${mc_version}] ${mod_version}"
Expand All @@ -314,6 +308,11 @@ githubRelease {
releaseAssets.from(jar.archivePath)
}

task uploadAll(dependsOn: [uploadArchives, "curseforge", "githubRelease"]) {
group "upload"
description "Uploads to all repositories (Maven, Curse, GitHub release)"
}

test {
useJUnitPlatform()
testLogging {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Mod properties
mod_version=1.82.1
mod_version=1.82.3

# Minecraft properties
mc_version=1.14 Pre-Release 2
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ pluginManagement {
}
}

rootProject.name = "cc-tweaked-${mc_version}"
rootProject.name = "cc-tweaked-${mc_version}-fabric"
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public JarMount( File jarFile, String subPath ) throws IOException
// Cleanup any old mounts. It's unlikely that there will be any, but it's best to be safe.
cleanup();

if( !jarFile.exists() || jarFile.isDirectory() ) throw new FileNotFoundException();
if( !jarFile.exists() || jarFile.isDirectory() ) throw new FileNotFoundException( "Cannot find " + jarFile );

// Open the zip file
try
Expand All @@ -85,7 +85,7 @@ public JarMount( File jarFile, String subPath ) throws IOException
if( zip.getEntry( subPath ) == null )
{
zip.close();
throw new IOException( "Zip does not contain path" );
throw new FileNotFoundException( "Zip does not contain path" );
}

// We now create a weak reference to this mount. This is automatically added to the appropriate queue.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public Varargs invoke( final LuaState state, Varargs args ) throws LuaError
}
catch( InterruptedException e )
{
throw new OrphanedThread();
throw new InterruptedError( e );
}
catch( LuaException e )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public int getStrongRedstonePower( BlockState state, BlockView world, BlockPos p
if( computer == null ) return 0;

ComputerSide localSide = computerEntity.remapToLocalSide( incomingSide.getOpposite() );
return computerEntity.isRedstoneBlockedOnSide( localSide ) ? 0 : computer.getRedstoneOutput( localSide );
return computer.getRedstoneOutput( localSide );
}

@Nonnull
Expand All @@ -91,11 +91,7 @@ public int getWeakRedstonePower( BlockState state, BlockView world, BlockPos pos
@Override
public boolean getBundledRedstoneConnectivity( World world, BlockPos pos, Direction side )
{
BlockEntity entity = world.getBlockEntity( pos );
if( !(entity instanceof TileComputerBase) ) return false;

TileComputerBase computerEntity = (TileComputerBase) entity;
return !computerEntity.isRedstoneBlockedOnSide( computerEntity.remapToLocalSide( side ) );
return true;
}

@Override
Expand All @@ -109,7 +105,7 @@ public int getBundledRedstoneOutput( World world, BlockPos pos, Direction side )
if( computer == null ) return 0;

ComputerSide localSide = computerEntity.remapToLocalSide( side );
return computerEntity.isRedstoneBlockedOnSide( localSide ) ? 0 : computer.getBundledRedstoneOutput( localSide );
return computer.getBundledRedstoneOutput( localSide );
}

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import dan200.computercraft.shared.util.DirectionUtil;
import dan200.computercraft.shared.util.RedstoneUtil;
import joptsimple.internal.Strings;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.RedstoneWireBlock;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
Expand All @@ -33,6 +36,7 @@
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -207,11 +211,6 @@ protected boolean isPeripheralBlockedOnSide( ComputerSide localSide )
return false;
}

protected boolean isRedstoneBlockedOnSide( ComputerSide localSide )
{
return false;
}

protected abstract Direction getDirection();

protected ComputerSide remapToLocalSide( Direction globalSide )
Expand All @@ -228,17 +227,35 @@ private void updateSideInput( ServerComputer computer, Direction dir, BlockPos o
{
Direction offsetSide = dir.getOpposite();
ComputerSide localDir = remapToLocalSide( dir );
if( !isRedstoneBlockedOnSide( localDir ) )
{
computer.setRedstoneInput( localDir, getWorld().getEmittedRedstonePower( offset, dir ) );
computer.setBundledRedstoneInput( localDir, BundledRedstone.getOutput( getWorld(), offset, offsetSide ) );
}

computer.setRedstoneInput( localDir, getRedstoneInput( world, offset, dir ) );
computer.setBundledRedstoneInput( localDir, BundledRedstone.getOutput( getWorld(), offset, offsetSide ) );
if( !isPeripheralBlockedOnSide( localDir ) )
{
computer.setPeripheral( localDir, Peripherals.getPeripheral( getWorld(), offset, offsetSide ) );
}
}

/**
* Gets the redstone input for an adjacent block
*
* @param world The world we exist in
* @param pos The position of the neighbour
* @param side The side we are reading from
* @return The effective redstone power
* @see net.minecraft.block.RedstoneBlock#method_9991(World, BlockPos, BlockState)
*/
protected static int getRedstoneInput( World world, BlockPos pos, Direction side )
{
int power = world.getEmittedRedstonePower( pos, side );
if( power >= 15 ) return power;

BlockState neighbour = world.getBlockState( pos );
return neighbour.getBlock() == Blocks.REDSTONE_WIRE
? Math.max( power, neighbour.get( RedstoneWireBlock.POWER ) )
: power;
}

public void updateInput()
{
if( getWorld() == null || getWorld().isClient ) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
import dan200.computercraft.api.ComputerCraftAPI;
import dan200.computercraft.api.peripheral.IPeripheral;
import dan200.computercraft.api.peripheral.IPeripheralTile;
import dan200.computercraft.shared.peripheral.common.TilePeripheralBase;
import dan200.computercraft.shared.peripheral.modem.wireless.TileAdvancedModem;
import dan200.computercraft.shared.peripheral.modem.wireless.TileWirelessModem;
import dan200.computercraft.shared.peripheral.monitor.TileMonitor;
import mcmultipart.api.addon.IMCMPAddon;
import mcmultipart.api.addon.MCMPAddon;
import mcmultipart.api.container.IMultipartContainer;
Expand Down Expand Up @@ -52,7 +54,7 @@ private static void register( IMultipartRegistry registry, Block block, IMultipa
public void registerParts( IMultipartRegistry registry )
{
// Setup all parts
register( registry, ComputerCraft.Blocks.peripheral, new PartNormalModem() );
register( registry, ComputerCraft.Blocks.peripheral, new PartPeripheral() );
register( registry, ComputerCraft.Blocks.advancedModem, new PartAdvancedModem() );

// Subscribe to capability events
Expand Down Expand Up @@ -83,8 +85,11 @@ public void registerParts( IMultipartRegistry registry )
public static void attach( AttachCapabilitiesEvent<TileEntity> event )
{
TileEntity tile = event.getObject();
if( tile instanceof TileAdvancedModem || tile instanceof TileWirelessModem )
if( tile instanceof TileAdvancedModem || tile instanceof TileWirelessModem
|| tile instanceof TilePeripheralBase || tile instanceof TileMonitor )
{
// We need to attach to modems (obviously), but also any other tile created by BlockPeripheral. Otherwise
// IMultipart.convertToMultipartTile will error.
event.addCapability( CAPABILITY_KEY, new BasicMultipart( tile ) );
}
}
Expand All @@ -94,7 +99,10 @@ private static final class BasicMultipart implements ICapabilityProvider
private final TileEntity tile;
private IMultipartTile wrapped;

private BasicMultipart( TileEntity tile ) {this.tile = tile;}
private BasicMultipart( TileEntity tile )
{
this.tile = tile;
}

@Override
public boolean hasCapability( @Nonnull Capability<?> capability, @Nullable Direction facing )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import dan200.computercraft.shared.peripheral.common.BlockPeripheral;
import dan200.computercraft.shared.peripheral.common.BlockPeripheralVariant;
import mcmultipart.api.multipart.IMultipart;
import mcmultipart.api.slot.EnumCenterSlot;
import mcmultipart.api.slot.EnumFaceSlot;
import mcmultipart.api.slot.IPartSlot;
import net.minecraft.block.Block;
Expand All @@ -20,34 +21,41 @@
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

public class PartNormalModem implements IMultipart
import javax.annotation.Nonnull;

public class PartPeripheral implements IMultipart
{
@Override
public IPartSlot getSlotForPlacement( World world, BlockPos pos, IBlockState state, Direction facing, float hitX, float hitY, float hitZ, EntityLivingBase placer )
{
return EnumFaceSlot.fromFace( getFacing( state ) );
return getSlot( state );
}

@Override
public IPartSlot getSlotFromWorld( IBlockAccess world, BlockPos pos, IBlockState state )
{
return EnumFaceSlot.fromFace( getFacing( state ) );
return getSlot( state );
}

private Direction getFacing( IBlockState state )
@Nonnull
private static IPartSlot getSlot( IBlockState state )
{
BlockPeripheralVariant type = state.getValue( BlockPeripheral.VARIANT );
if( type == BlockPeripheralVariant.WirelessModemUpOn || type == BlockPeripheralVariant.WirelessModemUpOff )
{
return Direction.UP;
return EnumFaceSlot.UP;
}
else if( type == BlockPeripheralVariant.WirelessModemDownOn || type == BlockPeripheralVariant.WirelessModemDownOff )
{
return Direction.UP;
return EnumFaceSlot.DOWN;
}
else if( type == BlockPeripheralVariant.WirelessModemOff || type == BlockPeripheralVariant.WirelessModemOn )
{
return EnumFaceSlot.fromFace( state.getValue( BlockPeripheral.FACING ) );
}
else
{
return state.getValue( BlockPeripheral.FACING );
return EnumCenterSlot.CENTER;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,8 @@ public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull O
case 31:
{
// refuel
int count = parseCount( args, 0 );
int count = optInt( args, 0, Integer.MAX_VALUE );
if( count < 0 ) throw new LuaException( "Refuel count " + count + " out of range" );
return tryCommand( context, new TurtleRefuelCommand( count ) );
}
case 32:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,6 @@ protected boolean isPeripheralBlockedOnSide( ComputerSide localSide )
return hasPeripheralUpgradeOnSide( localSide );
}

@Override
protected boolean isRedstoneBlockedOnSide( ComputerSide localSide )
{
return false;
}

// IDirectionalTile

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,27 @@ if #tArgs > 1 then
return
elseif #tArgs > 0 then
if tArgs[1] == "all" then
nLimit = 64 * 16
nLimit = nil
else
nLimit = tonumber( tArgs[1] )
if not nLimit then
print("Invalid limit, expected a number or \"all\"")
return
end
end
end

if turtle.getFuelLevel() ~= "unlimited" then
for n=1,16 do
for n = 1, 16 do
-- Stop if we've reached the limit, or are fully refuelled.
if (nLimit and nLimit <= 0) or turtle.getFuelLevel() >= turtle.getFuelLimit() then
break
end

local nCount = turtle.getItemCount(n)
if nLimit > 0 and nCount > 0 and turtle.getFuelLevel() < turtle.getFuelLimit() then
local nBurn = math.min( nLimit, nCount )
if nCount > 0 then
turtle.select( n )
if turtle.refuel( nBurn ) then
if turtle.refuel( nLimit ) and nLimit then
local nNewCount = turtle.getItemCount(n)
nLimit = nLimit - (nCount - nNewCount)
end
Expand Down

0 comments on commit 26b73c2

Please sign in to comment.