Navigation Menu

Skip to content

Commit

Permalink
Starting 1.12 port. Game compiles, made registry changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
WesCook committed Aug 1, 2017
1 parent cd95d7b commit 6524b8c
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 24 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Expand Up @@ -4,7 +4,7 @@ buildscript {
maven { url = "http://files.minecraftforge.net/maven" }
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
}
}
apply plugin: 'net.minecraftforge.gradle.forge'
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
@@ -1,8 +1,8 @@
# Versions
minecraft_version=1.11.2
forge_version=13.20.1.2386
mappings=snapshot_nodoc_20161220
mod_version=1.6.0
minecraft_version=1.12
forge_version=14.21.1.2387
mappings=snapshot_nodoc_20170624
mod_version=2.0.0

# Gradle Properties
-org.gradle.jvmargs=-Xmx3G
15 changes: 15 additions & 0 deletions src/main/java/ca/wescook/nutrition/events/EventRegistry.java
@@ -0,0 +1,15 @@
package ca.wescook.nutrition.events;

import ca.wescook.nutrition.potions.ModPotions;
import net.minecraft.potion.Potion;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

public class EventRegistry {
@SubscribeEvent
public void registerPotions(RegistryEvent.Register<Potion> event) {
event.getRegistry().register(ModPotions.toughness);
event.getRegistry().register(ModPotions.nourished);
event.getRegistry().register(ModPotions.malnourished);
}
}
8 changes: 4 additions & 4 deletions src/main/java/ca/wescook/nutrition/gui/GuiButtonIcon.java
Expand Up @@ -15,9 +15,9 @@ public GuiButtonIcon(int buttonId, int x, int y, int widthIn, int heightIn, Item

// This exists to draw an icon over the button
@Override
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
drawHorizontalLine(xPosition, xPosition + width - 1, yPosition + height, 0xff000000); // Draw line on bottom
super.drawButton(mc, mouseX, mouseY); // Draw regular button
mc.getRenderItem().renderItemIntoGUI(icon, xPosition + (width / 2) - 8, yPosition + (height / 2) - 7); // Draw our icon centered
public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks) {
drawHorizontalLine(x, x + width - 1, y + height, 0xff000000); // Draw line on bottom
super.drawButton(mc, mouseX, mouseY, partialTicks); // Draw regular button
mc.getRenderItem().renderItemIntoGUI(icon, x + (width / 2) - 8, y + (height / 2) - 7); // Draw our icon centered
}
}
Expand Up @@ -86,7 +86,7 @@ private void drawBackground() {
public void drawLabels(int mouseX, int mouseY) {
// Labels
for (GuiButton aButtonList : this.buttonList)
aButtonList.drawButton(this.mc, mouseX, mouseY);
aButtonList.drawButton(this.mc, mouseX, mouseY, 0);

// Buttons
for (GuiLabel aLabelList : this.labelList)
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/ca/wescook/nutrition/gui/NutritionGui.java
Expand Up @@ -118,18 +118,18 @@ public void redrawLabels() {

// Draw title
String nutritionTitle = I18n.format("gui." + Nutrition.MODID + ":nutrition_title");
labelList.add(label = new GuiLabel(fontRendererObj, 0, (width / 2) - (fontRendererObj.getStringWidth(nutritionTitle) / 2), top + TITLE_VERTICAL_OFFSET, 0, 0, 0xffffffff));
labelList.add(label = new GuiLabel(fontRenderer, 0, (width / 2) - (fontRenderer.getStringWidth(nutritionTitle) / 2), top + TITLE_VERTICAL_OFFSET, 0, 0, 0xffffffff));
label.addLine(nutritionTitle);

// Nutrients names and values
int i = 0;
for (Nutrient nutrient : NutrientList.get()) {
// Create labels for each nutrient type name
labelList.add(label = new GuiLabel(fontRendererObj, 0, left + LABEL_NAME_HORIZONTAL_OFFSET, top + LABEL_VERTICAL_OFFSET + (i * NUTRITION_DISTANCE), 0, 0, 0xffffffff));
labelList.add(label = new GuiLabel(fontRenderer, 0, left + LABEL_NAME_HORIZONTAL_OFFSET, top + LABEL_VERTICAL_OFFSET + (i * NUTRITION_DISTANCE), 0, 0, 0xffffffff));
label.addLine(I18n.format("nutrient." + Nutrition.MODID + ":" + nutrient.name)); // Add name from localization file

// Create percent value labels for each nutrient value
labelList.add(label = new GuiLabel(fontRendererObj, 0, left + LABEL_VALUE_HORIZONTAL_OFFSET, top + LABEL_VERTICAL_OFFSET + (i * NUTRITION_DISTANCE), 0, 0, 0xffffffff));
labelList.add(label = new GuiLabel(fontRenderer, 0, left + LABEL_VALUE_HORIZONTAL_OFFSET, top + LABEL_VERTICAL_OFFSET + (i * NUTRITION_DISTANCE), 0, 0, 0xffffffff));
if (ClientProxy.nutrientData != null && ClientProxy.nutrientData.get(nutrient) != null) // Ensure local nutrition data exists
label.addLine(Math.round(ClientProxy.nutrientData.get(nutrient)) + "%%");
else
Expand Down
Expand Up @@ -28,7 +28,7 @@ public static class Handler implements IMessageHandler<Message, IMessage> {
public IMessage onMessage(final Message message, final MessageContext context) {
FMLCommonHandler.instance().getWorldThread(context.netHandler).addScheduledTask(() -> {
// Return message
EntityPlayer player = context.getServerHandler().playerEntity; // Get Player on server
EntityPlayer player = context.getServerHandler().player; // Get Player on server
ModPacketHandler.NETWORK_CHANNEL.sendTo(new PacketNutritionResponse.Message(player), (EntityPlayerMP) player);
});

Expand Down
6 changes: 1 addition & 5 deletions src/main/java/ca/wescook/nutrition/potions/ModPotions.java
Expand Up @@ -2,7 +2,6 @@

import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.registry.GameRegistry;

import java.util.UUID;

Expand All @@ -18,7 +17,7 @@ public class ModPotions {
static final UUID NOURISHMENT_HEALTH = UUID.fromString("bdafe0c7-5881-4505-802e-e18f6c419554");
static final UUID MALNOURISHMENT_HEALTH = UUID.fromString("ea9cebf7-7c7a-4a89-a04f-221dab8ffdf7");

public static void registerPotions() {
public static void createPotions() {
// Toughness
toughness = new PotionToughness(true, new ResourceLocation("nutrition", "textures/potions/toughness.png"));
toughness.setPotionName("Toughness");
Expand All @@ -27,20 +26,17 @@ public static void registerPotions() {
toughness.registerPotionAttributeModifier(SharedMonsterAttributes.MAX_HEALTH, TOUGHNESS_HEALTH.toString(), 0D, 0);
toughness.registerPotionAttributeModifier(SharedMonsterAttributes.ARMOR_TOUGHNESS, TOUGHNESS_ARMOR.toString(), 0D, 0);
toughness.registerPotionAttributeModifier(SharedMonsterAttributes.ATTACK_SPEED, TOUGHNESS_ATTACK_SPEED.toString(), 0D, 0);
GameRegistry.register(toughness);

// Nourished
nourished = new PotionNourished(true, new ResourceLocation("nutrition", "textures/potions/nourished.png"));
nourished.setPotionName("Nourished");
nourished.setRegistryName("nourished");
nourished.registerPotionAttributeModifier(SharedMonsterAttributes.MAX_HEALTH, NOURISHMENT_HEALTH.toString(), 0D, 0);
GameRegistry.register(nourished);

// Malnourished
malnourished = new PotionMalnourished(true, new ResourceLocation("nutrition", "textures/potions/malnourished.png"));
malnourished.setPotionName("Malnourished");
malnourished.setRegistryName("malnourished");
malnourished.registerPotionAttributeModifier(SharedMonsterAttributes.MAX_HEALTH, MALNOURISHMENT_HEALTH.toString(), 0D, 0);
GameRegistry.register(malnourished);
}
}
8 changes: 3 additions & 5 deletions src/main/java/ca/wescook/nutrition/proxy/CommonProxy.java
Expand Up @@ -5,10 +5,7 @@
import ca.wescook.nutrition.capabilities.CapInterface;
import ca.wescook.nutrition.capabilities.CapStorage;
import ca.wescook.nutrition.effects.EffectsList;
import ca.wescook.nutrition.events.EventEatFood;
import ca.wescook.nutrition.events.EventPlayerAttachCapability;
import ca.wescook.nutrition.events.EventPlayerClone;
import ca.wescook.nutrition.events.EventPlayerUpdate;
import ca.wescook.nutrition.events.*;
import ca.wescook.nutrition.gui.ModGuiHandler;
import ca.wescook.nutrition.network.ModPacketHandler;
import ca.wescook.nutrition.nutrients.NutrientList;
Expand All @@ -26,8 +23,9 @@ public void preInit(FMLPreInitializationEvent event) {
Config.registerConfigs(event.getModConfigurationDirectory()); // Create config files
ModPacketHandler.registerMessages(); // Register network messages
CapabilityManager.INSTANCE.register(CapInterface.class, new CapStorage(), CapImplementation.class); // Register capability
ModPotions.registerPotions(); // Register custom potions

ModPotions.createPotions(); // Register custom potions
MinecraftForge.EVENT_BUS.register(new EventRegistry()); // Register custom potions
MinecraftForge.EVENT_BUS.register(new EventPlayerAttachCapability()); // Attach capability to player
MinecraftForge.EVENT_BUS.register(new EventPlayerClone()); // Player death and warping
MinecraftForge.EVENT_BUS.register(new EventEatFood()); // Register use item event
Expand Down

0 comments on commit 6524b8c

Please sign in to comment.