Skip to content

Commit

Permalink
Merge pull request #4 from Keriils/AddTwoRing
Browse files Browse the repository at this point in the history
add two ring
  • Loading branch information
Keriils authored Aug 13, 2024
2 parents d335aed + 1c3cabb commit 6b9725a
Show file tree
Hide file tree
Showing 12 changed files with 206 additions and 3 deletions.
3 changes: 2 additions & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
* For more details, see https://docs.gradle.org/8.0.1/userguide/java_library_plugin.html#sec:java_library_configurations_graph
*/
dependencies {
api("com.github.GTNewHorizons:GT5-Unofficial:5.09.48.66:dev")
// api("com.github.GTNewHorizons:GT5-Unofficial:5.09.48.66:dev")
compileOnly ('org.jetbrains:annotations:24.1.0')
api("com.github.GTNewHorizons:Draconic-Evolution:1.3.5-GTNH:dev")
implementation('com.github.GTNewHorizons:Baubles:1.0.4:dev')
implementation("com.github.GTNewHorizons:ae2stuff:0.8.2-GTNH:dev")
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ usesMixins = true
separateMixinSourceSet =

# Adds some debug arguments like verbose output and class export.
usesMixinDebug = false
usesMixinDebug = true

# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
mixinPlugin = mixinPlugin.MixinPlugin
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/com/xir/NHUtilities/common/CommonProxy.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
package com.xir.NHUtilities.common;

import net.minecraftforge.common.MinecraftForge;

import com.xir.NHUtilities.common.nhutilies.events.GluttonyRingEvent;
import com.xir.NHUtilities.loader.ItemLoader;

import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;

public class CommonProxy {

public void preInit(FMLPreInitializationEvent event) {}
public void preInit(FMLPreInitializationEvent event) {
ItemLoader.registerNHUtilitiesItems();
MinecraftForge.EVENT_BUS.register(new GluttonyRingEvent());
}

public void init(FMLInitializationEvent event) {}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.xir.NHUtilities.common.nhutilies.events;

import java.util.Optional;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.entity.player.PlayerUseItemEvent;

import com.brandon3055.draconicevolution.common.utills.InventoryUtils;
import com.xir.NHUtilities.common.nhutilies.items.GluttonyRing;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;

public class GluttonyRingEvent {

@SubscribeEvent
public void onGluttonyRingEating(PlayerUseItemEvent.Start event) {
EntityPlayer entityPlayer = event.entityPlayer;
if (entityPlayer.getHeldItem() == null) return;
Optional<ItemStack> baublesItem = InventoryUtils
.getItemInPlayerBaublesInventory(entityPlayer, GluttonyRing.class);
if (baublesItem.isPresent() && (event.item.getItemUseAction() == EnumAction.eat)
&& entityPlayer.getFoodStats()
.getFoodLevel() < 20) {
event.duration = 2;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.xir.NHUtilities.common.nhutilies.items;

import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;

import baubles.api.BaubleType;
import baubles.api.IBauble;

public class GluttonyRing extends ItemBasic implements IBauble {

public GluttonyRing() {
setMaxStackSize(1);
setUnlocalizedName("GluttonyRing");
setTextureName("GluttonyRing");

}

@Override
public BaubleType getBaubleType(ItemStack itemstack) {
return BaubleType.RING;
}

@Override
public void onWornTick(ItemStack itemstack, EntityLivingBase player) {

}

@Override
public void onEquipped(ItemStack itemstack, EntityLivingBase player) {

}

@Override
public void onUnequipped(ItemStack itemstack, EntityLivingBase player) {

}

@Override
public boolean canEquip(ItemStack itemstack, EntityLivingBase player) {
return true;
}

@Override
public boolean canUnequip(ItemStack itemstack, EntityLivingBase player) {
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.xir.NHUtilities.common.nhutilies.items;

import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.FoodStats;

import baubles.api.BaubleType;
import baubles.api.IBauble;

public class HungerRing extends ItemBasic implements IBauble {

public HungerRing() {
setMaxStackSize(1);
setUnlocalizedName("HungerRing");
setTextureName("HungerRing");

}

@Override
public BaubleType getBaubleType(ItemStack itemstack) {
return BaubleType.RING;
}

@Override
public void onWornTick(ItemStack itemstack, EntityLivingBase player) {
FoodStats foodStats = ((EntityPlayer) player).getFoodStats();
if (foodStats.getFoodLevel() >= 1) {
foodStats.setFoodLevel(0);
}
}

@Override
public void onEquipped(ItemStack itemstack, EntityLivingBase player) {

}

@Override
public void onUnequipped(ItemStack itemstack, EntityLivingBase player) {

}

@Override
public boolean canEquip(ItemStack itemstack, EntityLivingBase player) {
return true;
}

@Override
public boolean canUnequip(ItemStack itemstack, EntityLivingBase player) {
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.xir.NHUtilities.common.nhutilies.items;

import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

import com.xir.NHUtilities.main.NHUtilities;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

/**
* The aim is to simplify some writing as well as others
*/
public class ItemBasic extends Item {

private static final String MODID = String.format("item.%s:", NHUtilities.MODID);
private String unlocalizedName;

@Override
public Item setTextureName(String TextureName) {
this.iconString = NHUtilities.MODID + ":" + TextureName;
return this;
}

@Override
@SideOnly(Side.CLIENT)
protected String getIconString() {
return this.iconString == null
? "MISSING_ICON_ITEM_" + itemRegistry.getIDForObject(this) + "_" + this.unlocalizedName
: this.iconString;
}

@Override
public Item setUnlocalizedName(String unlocalizedName) {
this.unlocalizedName = unlocalizedName;
return this;
}

@Override
public String getUnlocalizedName() {
return MODID + this.unlocalizedName;
}

@Override
public String getUnlocalizedName(ItemStack stack) {
return getUnlocalizedName();
}
}
14 changes: 14 additions & 0 deletions src/main/java/com/xir/NHUtilities/loader/ItemLoader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.xir.NHUtilities.loader;

import com.xir.NHUtilities.common.nhutilies.items.GluttonyRing;
import com.xir.NHUtilities.common.nhutilies.items.HungerRing;

import cpw.mods.fml.common.registry.GameRegistry;

public class ItemLoader {

public static void registerNHUtilitiesItems() {
GameRegistry.registerItem(new GluttonyRing(), "GluttonyRing");
GameRegistry.registerItem(new HungerRing(), "HungerRing");
}
}
2 changes: 2 additions & 0 deletions src/main/resources/assets/NHUtilities/lang/en_US.lang
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
key.toggleTeleporterMKII=Toggle Enhanced Charm of Dislocation GUI
info.teleporterInfBaubles.txt=Support putting in-any-baubles
info.teleporterInfBaublesButton.txt=Support the use of - button - to open the baubles
item.NHUtilities:GluttonyRing.name=GluttonyRing
item.NHUtilities:HungerRing.name=HungerRing
2 changes: 2 additions & 0 deletions src/main/resources/assets/NHUtilities/lang/zh_CN.lang
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
key.toggleTeleporterMKII=开关高级传送器GUI
info.teleporterInfBaubles.txt=支持放入-任意-饰品栏目
info.teleporterInfBaublesButton.txt=支持使用-按键-打开饰品
item.NHUtilities:GluttonyRing.name=暴食指环
item.NHUtilities:HungerRing.name=饥饿指环
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6b9725a

Please sign in to comment.