Skip to content

Commit

Permalink
Initial update to Fabric
Browse files Browse the repository at this point in the history
  • Loading branch information
SquidDev committed Apr 3, 2019
1 parent 7afc3e5 commit 55a7ee4
Show file tree
Hide file tree
Showing 297 changed files with 4,957 additions and 5,565 deletions.
65 changes: 17 additions & 48 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
buildscript {
repositories {
jcenter()
mavenCentral()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
}
dependencies {
classpath 'com.google.code.gson:gson:2.8.1'
classpath 'net.minecraftforge.gradle:ForgeGradle:3.0.115'
classpath 'net.sf.proguard:proguard-gradle:6.1.0beta2'
classpath 'org.ajoberstar.grgit:grgit-gradle:3.0.0'
}
}

plugins {
id 'fabric-loom' version '0.2.0-SNAPSHOT'
id 'com.matthewprenger.cursegradle' version '1.2.0'
}

apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'org.ajoberstar.grgit'
apply plugin: 'maven-publish'
apply plugin: 'maven'
Expand All @@ -30,38 +21,10 @@ group = "org.squiddev"
archivesBaseName = "cc-tweaked-${mc_version}"

minecraft {
runs {
client {
workingDirectory project.file('run')
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'

mods {
computercraft {
source sourceSets.main
}
}
}

server {
workingDirectory project.file('run')
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
property 'forge.logging.console.level', 'debug'

mods {
computercraft {
source sourceSets.main
}
}
}
}

mappings channel: 'snapshot', version: "${mappings_version}".toString()

accessTransformer file('src/main/resources/META-INF/accesstransformer.cfg')
}

repositories {
mavenCentral()
maven {
name "JEI"
url "http://dvs1.progwml6.com/files/maven"
Expand All @@ -87,15 +50,21 @@ configurations {
}

dependencies {
minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}"
minecraft "com.mojang:minecraft:${mc_version}"
mappings "net.fabricmc:yarn:${mc_version}.${mappings_version}"
modCompile "net.fabricmc:fabric-loader:0.3.7.109"
modCompile "net.fabricmc:fabric:0.2.6.117"

compileOnly "mezz.jei:jei-1.13.2:5.0.0.8:api"
// 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"
// 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'
shade 'javax.vecmath:vecmath:1.5.2'

testImplementation 'org.junit.jupiter:junit-jupiter-api:5.1.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.1.0'
Expand All @@ -106,8 +75,7 @@ dependencies {
sourceSets {
main {
java {
exclude 'dan200/computercraft/shared/integration/mcmp'
exclude 'dan200/computercraft/shared/integration/charset'
exclude 'dan200/computercraft/shared/integration'
}
}
}
Expand Down Expand Up @@ -212,7 +180,7 @@ processResources {
inputs.property "commithash", hash

from(sourceSets.main.resources.srcDirs) {
include 'META-INF/mods.toml'
include 'fabric.mods.json'
include 'data/computercraft/lua/rom/help/credits.txt'

expand 'version': mod_version,
Expand All @@ -221,7 +189,7 @@ processResources {
}

from(sourceSets.main.resources.srcDirs) {
exclude 'META-INF/mods.toml'
exclude 'fabric.mods.json'
exclude 'data/computercraft/lua/rom/help/credits.txt'
}
}
Expand Down Expand Up @@ -272,7 +240,8 @@ curseforge {
apiKey = project.hasProperty('curseForgeApiKey') ? project.curseForgeApiKey : ''
project {
id = '282001'
releaseType = 'beta'
addGameVersion '1.14-Snapshot'
releaseType = 'alpha'
changelog = "Release notes can be found on the GitHub repository (https://github.com/SquidDev-CC/CC-Tweaked/releases/tag/v${mc_version}-${mod_version})."
}
}
Expand Down Expand Up @@ -338,7 +307,7 @@ test {
}

gradle.projectsEvaluated {
reobfJar.dependsOn proguardMove
remapJar.dependsOn proguardMove

tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint" << "-Xlint:-processing" // Causes Forge build to fail << "-Werror"
Expand Down
5 changes: 2 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
mod_version=1.82.0

# Minecraft properties
mc_version=1.13.2
forge_version=25.0.100
mappings_version=20190327-1.13.2
mc_version=19w14a
mappings_version=3
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
11 changes: 11 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
pluginManagement {
repositories {
jcenter()
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
gradlePluginPortal()
}
}

rootProject.name = "cc-tweaked-${mc_version}"
35 changes: 24 additions & 11 deletions src/main/java/dan200/computercraft/ComputerCraft.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

import dan200.computercraft.api.filesystem.IMount;
import dan200.computercraft.api.turtle.event.TurtleAction;
import dan200.computercraft.client.proxy.ComputerCraftProxyClient;
import dan200.computercraft.core.apis.AddressPredicate;
import dan200.computercraft.core.apis.http.websocket.Websocket;
import dan200.computercraft.core.filesystem.ResourceMount;
import dan200.computercraft.shared.Config;
import dan200.computercraft.shared.computer.blocks.BlockComputer;
import dan200.computercraft.shared.computer.core.ClientComputerRegistry;
import dan200.computercraft.shared.computer.core.ServerComputerRegistry;
Expand All @@ -30,13 +30,14 @@
import dan200.computercraft.shared.pocket.items.ItemPocketComputer;
import dan200.computercraft.shared.pocket.peripherals.PocketModem;
import dan200.computercraft.shared.pocket.peripherals.PocketSpeaker;
import dan200.computercraft.shared.proxy.ComputerCraftProxyCommon;
import dan200.computercraft.shared.turtle.blocks.BlockTurtle;
import dan200.computercraft.shared.turtle.items.ItemTurtle;
import dan200.computercraft.shared.turtle.upgrades.*;
import net.minecraft.resources.IReloadableResourceManager;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.server.ServerLifecycleHooks;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.ModInitializer;
import net.minecraft.resource.ReloadableResourceManager;
import net.minecraft.util.Identifier;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

Expand All @@ -45,8 +46,7 @@
import java.util.EnumSet;
import java.util.concurrent.TimeUnit;

@Mod( ComputerCraft.MOD_ID )
public final class ComputerCraft
public final class ComputerCraft implements ModInitializer
{
public static final String MOD_ID = "computercraft";

Expand Down Expand Up @@ -184,9 +184,22 @@ public static final class PocketUpgrades
// Logging
public static final Logger log = LogManager.getLogger( MOD_ID );

// Implementation
public static ComputerCraft instance;

public ComputerCraft()
{
Config.load();
instance = this;
}

@Override
public void onInitialize()
{
ComputerCraftProxyCommon.setup();
if( net.fabricmc.loader.api.FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT )
{
ComputerCraftProxyClient.setup();
}
}

public static String getVersion()
Expand All @@ -196,17 +209,17 @@ public static String getVersion()

static IMount createResourceMount( String domain, String subPath )
{
IReloadableResourceManager manager = ServerLifecycleHooks.getCurrentServer().getResourceManager();
ReloadableResourceManager manager = ComputerCraftProxyCommon.getServer().getDataManager();
ResourceMount mount = new ResourceMount( domain, subPath, manager );
return mount.exists( "" ) ? mount : null;
}

public static InputStream getResourceFile( String domain, String subPath )
{
IReloadableResourceManager manager = ServerLifecycleHooks.getCurrentServer().getResourceManager();
ReloadableResourceManager manager = ComputerCraftProxyCommon.getServer().getDataManager();
try
{
return manager.getResource( new ResourceLocation( domain, subPath ) ).getInputStream();
return manager.getResource( new Identifier( domain, subPath ) ).getInputStream();
}
catch( IOException ignored )
{
Expand Down
33 changes: 19 additions & 14 deletions src/main/java/dan200/computercraft/ComputerCraftAPIImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@
import dan200.computercraft.core.apis.ApiFactories;
import dan200.computercraft.core.filesystem.FileMount;
import dan200.computercraft.shared.*;
import dan200.computercraft.shared.peripheral.modem.wired.TileCable;
import dan200.computercraft.shared.peripheral.modem.wired.TileWiredModemFull;
import dan200.computercraft.shared.peripheral.modem.wireless.WirelessNetwork;
import dan200.computercraft.shared.util.IDAssigner;
import dan200.computercraft.shared.wired.CapabilityWiredElement;
import dan200.computercraft.shared.wired.WiredNode;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraftforge.common.util.LazyOptional;

import javax.annotation.Nonnull;
import java.io.File;
Expand All @@ -52,15 +52,15 @@ public String getInstalledVersion()
@Override
public int createUniqueNumberedSaveDir( @Nonnull World world, @Nonnull String parentSubPath )
{
return IDAssigner.getNextId( parentSubPath );
return IDAssigner.getNextId( world, parentSubPath );
}

@Override
public IWritableMount createSaveDirMount( @Nonnull World world, @Nonnull String subPath, long capacity )
{
try
{
return new FileMount( new File( IDAssigner.getDir(), subPath ), capacity );
return new FileMount( new File( IDAssigner.getDir( world ), subPath ), capacity );
}
catch( Exception e )
{
Expand Down Expand Up @@ -93,7 +93,7 @@ public void registerBundledRedstoneProvider( @Nonnull IBundledRedstoneProvider p
}

@Override
public int getBundledRedstoneOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing side )
public int getBundledRedstoneOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Direction side )
{
return BundledRedstone.getDefaultOutput( world, pos, side );
}
Expand Down Expand Up @@ -129,12 +129,17 @@ public IWiredNode createWiredNodeForElement( @Nonnull IWiredElement element )
}

@Override
public IWiredElement getWiredElementAt( @Nonnull IBlockReader world, @Nonnull BlockPos pos, @Nonnull EnumFacing side )
public IWiredElement getWiredElementAt( @Nonnull BlockView world, @Nonnull BlockPos pos, @Nonnull Direction side )
{
TileEntity tile = world.getTileEntity( pos );
if( tile == null ) return null;

LazyOptional<IWiredElement> element = tile.getCapability( CapabilityWiredElement.CAPABILITY, side );
return CapabilityWiredElement.unwrap( element );
BlockEntity tile = world.getBlockEntity( pos );
if( tile instanceof TileCable )
{
return ((TileCable) tile).getElement( side );
}
else if( tile instanceof TileWiredModemFull )
{
return ((TileWiredModemFull) tile).getElement();
}
return null;
}
}
20 changes: 10 additions & 10 deletions src/main/java/dan200/computercraft/api/AbstractTurtleUpgrade.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

import dan200.computercraft.api.turtle.ITurtleUpgrade;
import dan200.computercraft.api.turtle.TurtleUpgradeType;
import net.minecraft.item.ItemProvider;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IItemProvider;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Util;
import net.minecraft.util.Identifier;
import net.minecraft.util.SystemUtil;

import javax.annotation.Nonnull;

Expand All @@ -22,37 +22,37 @@
*/
public abstract class AbstractTurtleUpgrade implements ITurtleUpgrade
{
private final ResourceLocation id;
private final Identifier id;
private final TurtleUpgradeType type;
private final String adjective;
private final ItemStack stack;

protected AbstractTurtleUpgrade( ResourceLocation id, TurtleUpgradeType type, String adjective, ItemStack stack )
protected AbstractTurtleUpgrade( Identifier id, TurtleUpgradeType type, String adjective, ItemStack stack )
{
this.id = id;
this.type = type;
this.adjective = adjective;
this.stack = stack;
}

protected AbstractTurtleUpgrade( ResourceLocation id, TurtleUpgradeType type, String adjective, IItemProvider item )
protected AbstractTurtleUpgrade( Identifier id, TurtleUpgradeType type, String adjective, ItemProvider item )
{
this( id, type, adjective, new ItemStack( item ) );
}

protected AbstractTurtleUpgrade( ResourceLocation id, TurtleUpgradeType type, ItemStack stack )
protected AbstractTurtleUpgrade( Identifier id, TurtleUpgradeType type, ItemStack stack )
{
this( id, type, Util.makeTranslationKey( "upgrade", id ) + ".adjective", stack );
this( id, type, SystemUtil.createTranslationKey( "upgrade", id ) + ".adjective", stack );
}

protected AbstractTurtleUpgrade( ResourceLocation id, TurtleUpgradeType type, IItemProvider item )
protected AbstractTurtleUpgrade( Identifier id, TurtleUpgradeType type, ItemProvider item )
{
this( id, type, new ItemStack( item ) );
}

@Nonnull
@Override
public final ResourceLocation getUpgradeID()
public final Identifier getUpgradeID()
{
return id;
}
Expand Down
Loading

0 comments on commit 55a7ee4

Please sign in to comment.