mirror of
https://github.com/GTNewHorizons/Baubles-Expanded.git
synced 2026-11-25 06:14:30 +00:00
Refactor bauble methods into abstract class (#3)
* Refactor some bauble methods into an abstract class * This was needed to stop TC4 from deploading the OG version * remove unneeded clientonly * Add note
This commit is contained in:
1 parent
8afc29f5ab
commit
4f4741d21e
4 files changed
+76
-63
No files matched your search
@@ -0,0 +1,59 @@
|
||||
package baubles.common;
|
||||
|
||||
import baubles.api.expanded.BaubleItemHelper;
|
||||
import baubles.api.expanded.IBaubleExpanded;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* To be used to create standalone (i.e can't be used outside a bauble slot) bauble
|
||||
*/
|
||||
public abstract class BaubleItemBase extends Item implements IBaubleExpanded {
|
||||
|
||||
public BaubleItemBase(){
|
||||
super();
|
||||
setCreativeTab(CreativeTabs.tabTools);
|
||||
this.setMaxStackSize(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer player) {
|
||||
return BaubleItemHelper.onBaubleRightClick(itemStackIn, worldIn, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean debug) {
|
||||
BaubleItemHelper.addSlotInformation(tooltip, getBaubleTypes(stack));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasEffect(ItemStack itemStack, int a) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEquip(ItemStack itemstack, EntityLivingBase player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUnequip(ItemStack itemstack, EntityLivingBase player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWornTick(ItemStack itemStack, EntityLivingBase player) {}
|
||||
|
||||
@Override
|
||||
public void onEquipped(ItemStack itemStack, EntityLivingBase player) {}
|
||||
|
||||
@Override
|
||||
public void onUnequipped(ItemStack itemStack, EntityLivingBase player) {}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package baubles.common;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import baubles.Tags;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -25,7 +26,7 @@ public class Baubles {
|
||||
|
||||
public static final String MODID = "Baubles";
|
||||
public static final String MODNAME = "Baubles";
|
||||
public static final String VERSION = "GRADLETOKEN_VERSION";
|
||||
public static final String VERSION = Tags.VERSION;
|
||||
|
||||
@SidedProxy(clientSide = "baubles.client.ClientProxy", serverSide = "baubles.common.CommonProxy")
|
||||
public static CommonProxy proxy;
|
||||
|
||||
@@ -4,31 +4,26 @@ import java.util.List;
|
||||
|
||||
import baubles.api.BaubleType;
|
||||
import baubles.api.expanded.BaubleExpandedSlots;
|
||||
import baubles.api.expanded.BaubleItemHelper;
|
||||
import baubles.api.expanded.IBaubleExpanded;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemDebugger extends Item implements IBaubleExpanded {
|
||||
public class ItemDebugger extends BaubleItemBase {
|
||||
|
||||
private IIcon[] icons;
|
||||
|
||||
public ItemDebugger() {
|
||||
super();
|
||||
this.setMaxStackSize(1);
|
||||
this.setHasSubtypes(true);
|
||||
setCreativeTab(BaublesConfig.hideDebugItem ? null : CreativeTabs.tabTools);
|
||||
if (BaublesConfig.hideDebugItem){
|
||||
setCreativeTab(null);
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon[] icons;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerIcons(IIconRegister ir) {
|
||||
@@ -38,14 +33,12 @@ public class ItemDebugger extends Item implements IBaubleExpanded {
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public IIcon getIconFromDamage(int meta) {
|
||||
return icons[meta >= icons.length ? 0 : meta];
|
||||
}
|
||||
@Override
|
||||
public IIcon getIconFromDamage(int meta) {
|
||||
return icons[meta >= icons.length ? 0 : meta];
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void getSubItems(Item item, CreativeTabs tab, List list) {
|
||||
for(int i = 0; i < icons.length; i++) {
|
||||
@@ -53,11 +46,6 @@ public class ItemDebugger extends Item implements IBaubleExpanded {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer player) {
|
||||
return BaubleItemHelper.onBaubleRightClick(itemStackIn, worldIn, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBaubleTypes(ItemStack itemStack) {
|
||||
String type;
|
||||
@@ -75,41 +63,6 @@ public class ItemDebugger extends Item implements IBaubleExpanded {
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean debug) {
|
||||
BaubleItemHelper.addSlotInformation(tooltip, getBaubleTypes(stack));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWornTick(ItemStack itemStack, EntityLivingBase player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasEffect(ItemStack itemStack, int a) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getBackgroundIconForSlotType(String type) {
|
||||
if(type != null && BaubleExpandedSlots.isTypeRegistered(type)) {
|
||||
return icons[BaubleExpandedSlots.getIndexOfTypeInRegisteredTypes(type)];
|
||||
|
||||
Reference in new issue
Block a user