mirror of
https://github.com/GTNewHorizons/Baubles-Expanded.git
synced 2026-11-25 06:14:30 +00:00
Remove ring item and unused code
This commit is contained in:
1 parent
fea8e96081
commit
0c383f7175
6 files changed
+5
-275
No files matched your search
@@ -46,14 +46,6 @@ public class Baubles {
|
||||
event.getModMetadata().version = Baubles.VERSION;
|
||||
modDir = event.getModConfigurationDirectory();
|
||||
|
||||
try {
|
||||
Config.initialize(event.getSuggestedConfigurationFile());
|
||||
} catch (Exception e) {
|
||||
Baubles.log.error("BAUBLES has a problem loading it's configuration");
|
||||
} finally {
|
||||
if (Config.config!=null) Config.save();
|
||||
}
|
||||
|
||||
PacketHandler.init();
|
||||
|
||||
entityEventHandler = new EventHandlerEntity();
|
||||
@@ -63,10 +55,6 @@ public class Baubles {
|
||||
FMLCommonHandler.instance().bus().register(entityEventNetwork);
|
||||
proxy.registerHandlers();
|
||||
|
||||
/////////////////////
|
||||
|
||||
Config.save();
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -74,11 +62,5 @@ public class Baubles {
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy);
|
||||
proxy.registerKeyBindings();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void postInit(FMLPostInitializationEvent evt) {
|
||||
Config.initRecipe();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
package baubles.common;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import baubles.common.items.ItemRing;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
|
||||
public class Config {
|
||||
|
||||
public static Configuration config;
|
||||
public static Item itemRing;
|
||||
|
||||
// config properties
|
||||
private static boolean splitSurvivalCreative = false;
|
||||
|
||||
public static void initialize(File file)
|
||||
{
|
||||
config = new Configuration(file);
|
||||
config.load();
|
||||
|
||||
itemRing =(new ItemRing()).setUnlocalizedName("Ring");
|
||||
GameRegistry.registerItem(itemRing, "Ring", Baubles.MODID);
|
||||
|
||||
splitSurvivalCreative = config.getBoolean("splitSurvivalCreative", "server", splitSurvivalCreative, "Split Baubles inventory for survival and creative game modes.");
|
||||
|
||||
//save it
|
||||
config.save();
|
||||
}
|
||||
|
||||
|
||||
public static void save()
|
||||
{
|
||||
config.save();
|
||||
}
|
||||
|
||||
public static void initRecipe() {
|
||||
// GameRegistry.addShapedRecipe(
|
||||
// new ItemStack(itemRing), new Object[] {
|
||||
// "PIP", "IPI", "PIP",
|
||||
// Character.valueOf('I'), new ItemStack(Items.iron_ingot),
|
||||
// Character.valueOf('P'), new ItemStack(Items.potionitem,1,8226)});
|
||||
}
|
||||
|
||||
public static boolean isSplitSurvivalCreative() {
|
||||
return splitSurvivalCreative;
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,6 @@ package baubles.common.event;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraftforge.event.entity.player.PlayerDropsEvent;
|
||||
@@ -12,7 +10,6 @@ import baubles.api.IBauble;
|
||||
import baubles.common.Baubles;
|
||||
import baubles.common.container.InventoryBaubles;
|
||||
import baubles.common.lib.PlayerHandler;
|
||||
import baubles.common.Config;
|
||||
|
||||
import com.google.common.io.Files;
|
||||
|
||||
@@ -23,9 +20,6 @@ public class EventHandlerEntity {
|
||||
// player directory
|
||||
private File playerDirectory;
|
||||
|
||||
// hash containing game mode of all players
|
||||
private Map<String,Boolean> playerModes = new HashMap<String,Boolean>();
|
||||
|
||||
@SubscribeEvent
|
||||
public void playerTick(PlayerEvent.LivingUpdateEvent event) {
|
||||
|
||||
@@ -33,25 +27,6 @@ public class EventHandlerEntity {
|
||||
if (event.entity instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) event.entity;
|
||||
|
||||
if (Config.isSplitSurvivalCreative()) {
|
||||
// detect game mode changes
|
||||
if (playerModes.containsKey(player.getCommandSenderName()) && (playerDirectory != null))
|
||||
{
|
||||
Boolean mode = playerModes.get(player.getCommandSenderName());
|
||||
if (mode && !player.capabilities.isCreativeMode)
|
||||
{
|
||||
playerSaveDo(player, playerDirectory, true);
|
||||
playerLoadDo(player, playerDirectory, false);
|
||||
}
|
||||
else if (!mode && player.capabilities.isCreativeMode)
|
||||
{
|
||||
playerSaveDo(player, playerDirectory, false);
|
||||
playerLoadDo(player, playerDirectory, true);
|
||||
}
|
||||
}
|
||||
playerModes.put(player.getCommandSenderName(), player.capabilities.isCreativeMode);
|
||||
}
|
||||
|
||||
InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(player);
|
||||
for (int a = 0; a < baubles.getSizeInventory(); a++) {
|
||||
if (baubles.getStackInSlot(a) != null
|
||||
@@ -88,14 +63,8 @@ public class EventHandlerEntity {
|
||||
|
||||
File file1, file2;
|
||||
String fileName, fileNameBackup;
|
||||
if (gamemode || !Config.isSplitSurvivalCreative()) {
|
||||
fileName = "baub";
|
||||
fileNameBackup = "baubback";
|
||||
}
|
||||
else {
|
||||
fileName = "baubs";
|
||||
fileNameBackup = "baubsback";
|
||||
}
|
||||
fileName = "baub";
|
||||
fileNameBackup = "baubback";
|
||||
|
||||
// look for normal files first
|
||||
file1 = getPlayerFile(fileName, directory, player.getCommandSenderName());
|
||||
@@ -112,14 +81,6 @@ public class EventHandlerEntity {
|
||||
File fb = getPlayerFileUUID(fileNameBackup, directory, player.getGameProfile().getId().toString());
|
||||
if (fb.exists()) fb.delete();
|
||||
} catch (IOException e) {}
|
||||
} else {
|
||||
File filet = getLegacyFileFromPlayer(player);
|
||||
if (filet.exists()) {
|
||||
try {
|
||||
Files.copy(filet, file1);
|
||||
Baubles.log.info("Using pre MC 1.7.10 Baubles savefile for "+player.getCommandSenderName());
|
||||
} catch (IOException e) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,15 +99,6 @@ public class EventHandlerEntity {
|
||||
if ("dat".equals(suffix)) throw new IllegalArgumentException("The suffix 'dat' is reserved");
|
||||
return new File(playerDirectory, playerUUID+"."+suffix);
|
||||
}
|
||||
|
||||
public static File getLegacyFileFromPlayer(EntityPlayer player)
|
||||
{
|
||||
try {
|
||||
File playersDirectory = new File(player.worldObj.getSaveHandler().getWorldDirectory(), "players");
|
||||
return new File(playersDirectory, player.getCommandSenderName() + ".baub");
|
||||
} catch (Exception e) { e.printStackTrace(); }
|
||||
return null;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void playerSave(PlayerEvent.SaveToFile event) {
|
||||
@@ -154,16 +106,9 @@ public class EventHandlerEntity {
|
||||
}
|
||||
|
||||
private void playerSaveDo(EntityPlayer player, File directory, Boolean gamemode) {
|
||||
if (gamemode || !Config.isSplitSurvivalCreative()) {
|
||||
PlayerHandler.savePlayerBaubles(player,
|
||||
getPlayerFile("baub", directory, player.getCommandSenderName()),
|
||||
getPlayerFile("baubback", directory, player.getCommandSenderName()));
|
||||
}
|
||||
else {
|
||||
PlayerHandler.savePlayerBaubles(player,
|
||||
getPlayerFile("baubs", directory, player.getCommandSenderName()),
|
||||
getPlayerFile("baubsback", directory, player.getCommandSenderName()));
|
||||
}
|
||||
PlayerHandler.savePlayerBaubles(player,
|
||||
getPlayerFile("baub", directory, player.getCommandSenderName()),
|
||||
getPlayerFile("baubback", directory, player.getCommandSenderName()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
package baubles.common.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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.EnumRarity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import baubles.api.BaubleType;
|
||||
import baubles.api.IBauble;
|
||||
import baubles.common.container.InventoryBaubles;
|
||||
import baubles.common.lib.PlayerHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemRing extends Item implements IBauble
|
||||
{
|
||||
|
||||
public ItemRing()
|
||||
{
|
||||
super();
|
||||
this.setMaxStackSize(1);
|
||||
this.setHasSubtypes(true);
|
||||
this.setMaxDamage(0);
|
||||
setCreativeTab(CreativeTabs.tabTools);
|
||||
}
|
||||
|
||||
public IIcon icon;
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerIcons(IIconRegister ir) {
|
||||
icon = ir.registerIcon("baubles:ring");
|
||||
}
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public IIcon getIconFromDamage(int meta) {
|
||||
return icon;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void getSubItems(Item par1, CreativeTabs par2CreativeTabs,List par3List) {
|
||||
par3List.add(new ItemStack(this,1,0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaubleType getBaubleType(ItemStack itemstack) {
|
||||
return BaubleType.RING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
|
||||
if(!par2World.isRemote) {
|
||||
InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(par3EntityPlayer);
|
||||
for(int i = 0; i < baubles.getSizeInventory(); i++)
|
||||
if(baubles.getStackInSlot(i) == null && baubles.isItemValidForSlot(i, par1ItemStack)) {
|
||||
baubles.setInventorySlotContents(i, par1ItemStack.copy());
|
||||
if(!par3EntityPlayer.capabilities.isCreativeMode){
|
||||
par3EntityPlayer.inventory.setInventorySlotContents(par3EntityPlayer.inventory.currentItem, null);
|
||||
}
|
||||
onEquipped(par1ItemStack, par3EntityPlayer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWornTick(ItemStack itemstack, EntityLivingBase player) {
|
||||
if (itemstack.getItemDamage()==0 && !player.isPotionActive(Potion.digSpeed)) {
|
||||
player.addPotionEffect(new PotionEffect(Potion.digSpeed.id,40,0,true));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasEffect(ItemStack par1ItemStack, int a) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRarity getRarity(ItemStack par1ItemStack) {
|
||||
return EnumRarity.rare;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack par1ItemStack)
|
||||
{
|
||||
return super.getUnlocalizedName() + "." + par1ItemStack.getItemDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEquipped(ItemStack itemstack, EntityLivingBase player) {
|
||||
if (!player.worldObj.isRemote) {
|
||||
player.worldObj.playSoundAtEntity(player, "random.orb", 0.1F, 1.3f);
|
||||
}
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package baubles.common.lib;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import baubles.common.Config;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public final class CreativeTabBaubles extends CreativeTabs
|
||||
{
|
||||
public CreativeTabBaubles(int par1, String par2Str)
|
||||
{
|
||||
super(par1, par2Str);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
/**
|
||||
* the itemID for the item to be displayed on the tab
|
||||
*/
|
||||
@Override
|
||||
public Item getTabIconItem()
|
||||
{
|
||||
return Config.itemRing;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user