Skip to content

Commit

Permalink
compiles
Browse files Browse the repository at this point in the history
  • Loading branch information
Tfarcenim committed Aug 3, 2019
1 parent 6712598 commit f4f6b42
Show file tree
Hide file tree
Showing 20 changed files with 343 additions and 630 deletions.
195 changes: 19 additions & 176 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,152 +1,5 @@
buildscript {
repositories {
maven { url = 'https://files.minecraftforge.net/maven' }
jcenter()
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
}
}
apply plugin: 'net.minecraftforge.gradle'
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
apply plugin: 'eclipse'
apply plugin: 'maven-publish'

version = "${mod_version}"
group = "com.tfar.${modid}" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "${modid}"

sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.

minecraft {
// The mappings can be changed at any time, and must be in the following format.
// snapshot_YYYYMMDD Snapshot are built nightly.
// stable_# Stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not always work.
// Simply re-run your setup task after changing the mappings to update your workspace.
mappings channel: "snapshot", version: "${mapping}-1.14.3"
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.

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

// Default run configurations.
// These can be tweaked, removed, or duplicated as needed.
runs {
client {
workingDirectory project.file('run')

// Recommended logging data for a userdev environment
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'

// Recommended logging level for the console
property 'forge.logging.console.level', 'debug'

mods {
examplemod {
source sourceSets.main
}
}
}

server {
workingDirectory project.file('run')

// Recommended logging data for a userdev environment
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'

// Recommended logging level for the console
property 'forge.logging.console.level', 'debug'

mods {
examplemod {
source sourceSets.main
}
}
}
}
}

repositories{
maven {
// location of the maven that hosts JEI files
name = "Progwml6 maven"
url = "https://dvs1.progwml6.com/files/maven/"
}
maven {
// location of a maven mirror for JEI files, as a fallback
name = "ModMaven"
url = "https://modmaven.k-4u.nl"
}
}

dependencies {
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
// that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}" //21

// compile against the JEI API but do not include it at runtime
compileOnly fg.deobf("mezz.jei:jei-1.14.3:${jei_version}:api")
// at runtime, use the full JEI jar
runtimeOnly fg.deobf("mezz.jei:jei-1.14.3:${jei_version}")

// You may put jars on which you depend on in ./libs or you may define them like so..
// compile "some.group:artifact:version:classifier"
// compile "some.group:artifact:version"

// Real examples
// compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
// compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env

// The 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
// provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'

// These dependencies get remapped to your current MCP mappings
// deobf 'com.mod-buildcraft:buildcraft:6.0.8:dev'

// For more info...
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html

}

// Example for how to get properties into the manifest for reading by the runtime..
jar {
manifest {
attributes([
"Specification-Title": "examplemod",
"Specification-Vendor": "examplemodsareus",
"Specification-Version": "1", // We are version 1 of ourselves
"Implementation-Title": project.name,
"Implementation-Version": "${version}",
"Implementation-Vendor" :"examplemodsareus",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}

// Example configuration to allow publishing using the maven-publish task
// we define a custom artifact that is sourced from the reobfJar output task
// and then declare that to be published
// Note you'll need to add a repository here
def reobfFile = file("$buildDir/reobfJar/output.jar")
def reobfArtifact = artifacts.add('default', reobfFile) {
type 'jar'
builtBy 'reobfJar'
}
publishing {
publications {
mavenJava(MavenPublication) {
artifact reobfArtifact
}
}
repositories {
maven {
url "file:///${project.projectDir}/mcmodsrepo"
}
}
}
=======
jcenter()
maven { url = "https://files.minecraftforge.net/maven" }
}
Expand All @@ -158,19 +11,19 @@ apply plugin: 'net.minecraftforge.gradle.forge'
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.


version = "${mod_version}"
group = "com.tfar.modid" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "modid"
version = "0.1.0"
group = "com.tfar.craftingstation" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "craftingstation"

sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
compileJava {
sourceCompatibility = targetCompatibility = '1.8'
}

minecraft {
version = "1.12.2-14.23.5.2814"
version = "1.12.2-14.23.5.2838"
runDir = "run"

// the mappings can be changed at any time, and must be in the following format.
// snapshot_YYYYMMDD snapshot are built nightly.
// stable_# stables are built at the discretion of the MCP team.
Expand All @@ -179,29 +32,19 @@ minecraft {
mappings = "stable_39"
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
}
repositories {
maven {
url "http://dvs1.progwml6.com/files/maven" // JEI
}

dependencies {
// you may put jars on which you depend on in ./libs
// or you may define them like so..
//compile "some.group:artifact:version:classifier"
//compile "some.group:artifact:version"

// real examples
//compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
//compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env

// the 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
//provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'

// the deobf configurations: 'deobfCompile' and 'deobfProvided' are the same as the normal compile and provided,
// except that these dependencies get remapped to your current MCP mappings
//deobfCompile 'com.mod-buildcraft:buildcraft:6.0.8:dev'
//deobfProvided 'com.mod-buildcraft:buildcraft:6.0.8:dev'

// for more info...
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html
maven {
url "http://maven.tterrag.com/" // The One Probe
}
}

dependencies {
deobfCompile "mezz.jei:jei_1.12.2:4.9.1.169"
deobfCompile "mcjty.theoneprobe:TheOneProbe-1.12:1.12-1.4.23-16"
}

processResources {
Expand All @@ -212,13 +55,13 @@ processResources {
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'

// replace version and mcversion
expand 'version':project.version, 'mcversion':project.minecraft.version
}

// copy everything else except the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.tfar.examplemod;

import net.minecraft.inventory.CraftingInventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.ItemStackHandler;

/** pretends to be an InventoryCrafting while actually just wrapping an IItemHandler */
public class CraftingInventoryPersistant extends CraftingInventory {
public class CraftingInventoryPersistant extends InventoryCrafting {

ItemStackHandler itemHandler;
Container eventHandler;
Expand Down
83 changes: 31 additions & 52 deletions src/main/java/com/tfar/examplemod/CraftingStation.java
Original file line number Diff line number Diff line change
@@ -1,95 +1,74 @@
package com.tfar.examplemod;

import com.tfar.examplemod.client.CraftingStationScreen;
import com.tfar.examplemod.client.CraftingStationTileSpecialRenderer;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.gui.ScreenManager;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.item.BlockItem;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.tileentity.TileEntityType;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraft.item.ItemBlock;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.extensions.IForgeContainerType;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.ObjectHolder;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

// The value here should match an entry in the META-INF/mods.toml file
@Mod(CraftingStation.MODID)
@Mod.EventBusSubscriber
@Mod(modid = CraftingStation.MODID, name = CraftingStation.NAME, version = CraftingStation.VERSION)
public class CraftingStation {
// Directly reference a log4j logger.

public static final String MODID = "craftingstation";
public static final String NAME = "Crafting Station";
public static final String VERSION = "@VERSION@";

private static final Logger LOGGER = LogManager.getLogger();

public CraftingStation() {
// Register the setup method for modloading
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
// Register the doClientStuff method for modloading
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff);
@Mod.Instance
public static CraftingStation INSTANCE;

// Register ourselves for server and other game events we are interested in
public CraftingStation() {
MinecraftForge.EVENT_BUS.register(this);
}

private void setup(final FMLCommonSetupEvent event) {
}

private void doClientStuff(final FMLClientSetupEvent event) {
ScreenManager.registerFactory(Objects.crafting_station_container, CraftingStationScreen::new);
DistExecutor.runWhenOn(Dist.CLIENT,() -> () -> ClientRegistry.bindTileEntitySpecialRenderer(CraftingStationTile.class, new CraftingStationTileSpecialRenderer()));
@Mod.EventHandler
public void preInit(final FMLPreInitializationEvent event) {
NetworkRegistry.INSTANCE.registerGuiHandler(this,new GuiHandler());
}

@SubscribeEvent
public static void doClientStuff(final ModelRegistryEvent event) {
ClientRegistry.bindTileEntitySpecialRenderer(CraftingStationTile.class, new CraftingStationTileSpecialRenderer());
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(Objects.crafting_station),0,new ModelResourceLocation(Item.getItemFromBlock(Objects.crafting_station).getRegistryName(), "inventory"));
}

// You can use EventBusSubscriber to automatically subscribe events on the contained class (this is subscribing to the MOD
// Event bus for receiving Registry Events)
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
@Mod.EventBusSubscriber
public static class RegistryEvents {
@SubscribeEvent
public static void block(final RegistryEvent.Register<Block> event) {
// register a new block here
event.getRegistry().register(new CraftingStationBlock(Block.Properties
.create(Material.WOOD)
.hardnessAndResistance(2,2)).setRegistryName("crafting_station"));
event.getRegistry().register(new CraftingStationBlock(Material.WOOD).setRegistryName("crafting_station"));
}

@SubscribeEvent
public static void item(final RegistryEvent.Register<Item> event) {
// register a new block here
event.getRegistry().register(new BlockItem(Objects.crafting_station, new Item.Properties()
.group(ItemGroup.DECORATIONS)).setRegistryName("crafting_station"));
}

@SubscribeEvent
public static void container(final RegistryEvent.Register<ContainerType<?>> event){
event.getRegistry().register(IForgeContainerType.create((windowId, inv, data) ->
new CraftingStationContainer(windowId, inv, inv.player.world, data.readBlockPos(), inv.player)).setRegistryName("crafting_station_container"));

}

@SubscribeEvent
public static void tile(final RegistryEvent.Register<TileEntityType<?>> event){
event.getRegistry().register(TileEntityType.Builder.create(CraftingStationTile::new, Objects.crafting_station).build(null).setRegistryName("crafting_station_tile"));
event.getRegistry().register(new ItemBlock(Objects.crafting_station).setRegistryName(Objects.crafting_station.getRegistryName()).setCreativeTab(CreativeTabs.DECORATIONS));
GameRegistry.registerTileEntity(CraftingStationTile.class, new ResourceLocation(MODID, "crafting_station_tile"));
}
}
@ObjectHolder(MODID)

@GameRegistry.ObjectHolder(MODID)
public static class Objects {
public static final Block crafting_station = null;
public static final ContainerType<CraftingStationContainer> crafting_station_container = null;
public static final ContainerType<SideContainerInventory> side_container = null;
public static final TileEntityType<CraftingStationTile> crafting_station_tile = null;
}
}
Loading

0 comments on commit f4f6b42

Please sign in to comment.