Skip to content
This repository has been archived by the owner on Mar 9, 2024. It is now read-only.

Commit

Permalink
Update for Minecraft 1.12
Browse files Browse the repository at this point in the history
  • Loading branch information
renevo committed Mar 26, 2018
1 parent 0a777cf commit eefa98e
Show file tree
Hide file tree
Showing 16 changed files with 74 additions and 63 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ eclipse/
# gradle
.gradle/
run

# vs code
.vscode
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ buildscript {
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
}
}

Expand Down Expand Up @@ -56,6 +56,7 @@ minecraft {
useDepAts = true
}

sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
compileJava {
sourceCompatibility = 1.8
targetCompatibility = 1.8
Expand Down
8 changes: 4 additions & 4 deletions build.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mod_version=1.5.1
minecraft_version=1.11.2
forge_version=13.20.0.2255
mappings=snapshot_20161220
minecraft_version=1.12.2
forge_version=14.23.2.2635
mappings=snapshot_20171003

jei_version=4.2.+
jei_version=4.8.+
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx3G
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon May 09 14:58:23 PDT 2016
#Mon Sep 14 12:28:28 PDT 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.7-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-bin.zip
6 changes: 5 additions & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ case "`uname`" in
;;
esac

# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi

# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
Expand Down Expand Up @@ -109,7 +114,6 @@ fi
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`

# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/renevo/pcb/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public class ClientProxy extends CommonProxy {

@Override
public void initialization() {
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ItemPortableCraftBench.portableCraftBench, 0, new ModelResourceLocation(PortableCraftBenchMod.MODID + ":" + "portable_craft_bench", "inventory"));
super.initialization();

Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ItemPortableCraftBench.item, 0, new ModelResourceLocation(PortableCraftBenchMod.MODID + ":" + "portable_craft_bench", "inventory"));
}
}
18 changes: 16 additions & 2 deletions src/main/java/com/renevo/pcb/CommonProxy.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
package com.renevo.pcb;
import net.minecraft.item.Item;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.network.NetworkRegistry;

@Mod.EventBusSubscriber
public class CommonProxy {
public void preInitialization() {

}

public void initialization() {
NetworkRegistry.INSTANCE.registerGuiHandler(PortableCraftBenchMod.instance, new PortableCraftBenchGuiHandler());
}

public void postInitialization() {

}

public void initialization() {

@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event) {
event.getRegistry().register(new ItemPortableCraftBench());
}
}
4 changes: 2 additions & 2 deletions src/main/java/com/renevo/pcb/GuiPortableCraftBench.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public GuiPortableCraftBench(InventoryPlayer playerInventory, World world, Block

@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
this.fontRendererObj.drawString(I18n.translateToLocal(ItemPortableCraftBench.portableCraftBench.getUnlocalizedName() + ".name"), 8, 6, 4210752);
this.fontRendererObj.drawString(I18n.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
this.fontRenderer.drawString(I18n.translateToLocal(ItemPortableCraftBench.item.getUnlocalizedName() + ".name"), 8, 6, 4210752);
this.fontRenderer.drawString(I18n.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
}

@Override
Expand Down
24 changes: 5 additions & 19 deletions src/main/java/com/renevo/pcb/ItemPortableCraftBench.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,23 @@
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.*;
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.fml.common.registry.*;

public class ItemPortableCraftBench extends Item {

public static Item portableCraftBench;

public static void create() {
portableCraftBench = new ItemPortableCraftBench();
portableCraftBench.setRegistryName("portable_craft_bench");
GameRegistry.register(portableCraftBench);
GameRegistry.addShapelessRecipe(
new ItemStack(portableCraftBench),
Blocks.CRAFTING_TABLE,
Items.STRING);

// adds the pcb as a workbench in the Ore Dictionary
OreDictionary.registerOre("workbench", portableCraftBench);
}
@GameRegistry.ObjectHolder("pcb:portable_craft_bench")
public static ItemPortableCraftBench item;

public ItemPortableCraftBench() {
super();

super.setMaxStackSize(1);
super.setUnlocalizedName("portable_craft_bench");
super.setRegistryName("portable_craft_bench");
super.setUnlocalizedName(PortableCraftBenchMod.MODID+".portable_craft_bench");
super.setCreativeTab(CreativeTabs.TOOLS);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ public class PortableCraftBenchGuiHandler implements IGuiHandler {

@Override
public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
if (id == PortableCraftBenchMod.GUI_PORTABLE_CRAFT_BENCH_ID && player.getHeldItemMainhand().getItem() == ItemPortableCraftBench.portableCraftBench)
if (id == PortableCraftBenchMod.GUI_PORTABLE_CRAFT_BENCH_ID && player.getHeldItemMainhand().getItem() == ItemPortableCraftBench.item)
return new GuiPortableCraftBench(player.inventory, world, new BlockPos(x, y, z));

if (id == PortableCraftBenchMod.GUI_PORTABLE_CRAFT_BENCH_ID && player.getHeldItemOffhand().getItem() == ItemPortableCraftBench.portableCraftBench)
if (id == PortableCraftBenchMod.GUI_PORTABLE_CRAFT_BENCH_ID && player.getHeldItemOffhand().getItem() == ItemPortableCraftBench.item)
return new GuiPortableCraftBench(player.inventory, world, new BlockPos(x, y, z));

return null;
}

@Override
public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
if (id == PortableCraftBenchMod.GUI_PORTABLE_CRAFT_BENCH_ID && player.getHeldItemMainhand().getItem() == ItemPortableCraftBench.portableCraftBench)
if (id == PortableCraftBenchMod.GUI_PORTABLE_CRAFT_BENCH_ID && player.getHeldItemMainhand().getItem() == ItemPortableCraftBench.item)
return new ContainerPortableCraftBench(player.inventory, world, new BlockPos(x, y, z));

if (id == PortableCraftBenchMod.GUI_PORTABLE_CRAFT_BENCH_ID && player.getHeldItemOffhand().getItem() == ItemPortableCraftBench.portableCraftBench)
if (id == PortableCraftBenchMod.GUI_PORTABLE_CRAFT_BENCH_ID && player.getHeldItemOffhand().getItem() == ItemPortableCraftBench.item)
return new ContainerPortableCraftBench(player.inventory, world, new BlockPos(x, y, z));

return null;
Expand Down
34 changes: 9 additions & 25 deletions src/main/java/com/renevo/pcb/PortableCraftBenchMod.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
package com.renevo.pcb;

import net.minecraft.stats.*;
import net.minecraftforge.common.*;
import net.minecraftforge.fml.common.*;
import net.minecraftforge.fml.common.Mod.*;
import net.minecraftforge.fml.common.event.*;
import net.minecraftforge.fml.common.eventhandler.*;
import net.minecraftforge.fml.common.gameevent.*;
import net.minecraftforge.fml.common.network.*;
import org.apache.logging.log4j.Logger;

@Mod(modid = PortableCraftBenchMod.MODID, version = PortableCraftBenchMod.VERSION)
public class PortableCraftBenchMod {

public static final String MODID = "pcb";
public static final String VERSION = "1.5.0";

public static Achievement achievementPcb = null;

public static final int GUI_PORTABLE_CRAFT_BENCH_ID = 1;

@Instance(PortableCraftBenchMod.MODID)
Expand All @@ -25,30 +18,21 @@ public class PortableCraftBenchMod {
@SidedProxy(clientSide = "com.renevo.pcb.ClientProxy", serverSide = "com.renevo.pcb.CommonProxy")
public static CommonProxy proxy;

@EventHandler
public void init(FMLInitializationEvent event) {
ItemPortableCraftBench.create();

NetworkRegistry.INSTANCE.registerGuiHandler(instance, new PortableCraftBenchGuiHandler());

MinecraftForge.EVENT_BUS.register(this);
public static Logger logger;

// 6 left, 0 up/down - since we are just adding a new achievement, we don't need an achievement page, this somehow just works...
achievementPcb = new Achievement("achievement.pcb", "pcb", 5, -4, ItemPortableCraftBench.portableCraftBench, AchievementList.BUILD_WORK_BENCH);
achievementPcb.registerStat();
@EventHandler
public void preinit(FMLPreInitializationEvent event) {
logger = event.getModLog();
proxy.preInitialization();
}

@EventHandler
public void init(FMLInitializationEvent event) {
proxy.initialization();
}

@EventHandler
public void postInit(FMLPostInitializationEvent event) {
proxy.postInitialization();
}

@SubscribeEvent
public void onCraftItem(PlayerEvent.ItemCraftedEvent event) {
if (event.crafting.getItem() == ItemPortableCraftBench.portableCraftBench) {
event.player.addStat(achievementPcb, 1);
}
}
}
2 changes: 1 addition & 1 deletion src/main/resources/assets/pcb/lang/en_US.lang
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
item.portable_craft_bench.name=Portable Crafting Bench
item.pcb.portable_craft_bench.name=Portable Crafting Bench

achievement.pcb=Take it with you!
achievement.pcb.desc=Craft a portable crafting bench with string and a workbench.
2 changes: 1 addition & 1 deletion src/main/resources/assets/pcb/lang/ru_RU.lang
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
item.portable_craft_bench.name=Карманный верстак
item.pcb.portable_craft_bench.name=Карманный верстак

achievement.pcb=Возьми его с собой!
achievement.pcb.desc=Собери карманный верстак из обычного верстака и нитки
14 changes: 14 additions & 0 deletions src/main/resources/assets/pcb/recipes/portable_craft_bench.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"type": "minecraft:crafting_shapeless",
"ingredients": [
{
"item": "minecraft:string"
},
{
"item": "minecraft:crafting_table"
}
],
"result": {
"item": "pcb:portable_craft_bench"
}
}

0 comments on commit eefa98e

Please sign in to comment.