From 0c383f7175bbb90d99f8b7f00cb178f3d3f5597a Mon Sep 17 00:00:00 2001 From: jss2a98aj Date: Tue, 28 Apr 2020 00:53:36 -0400 Subject: [PATCH] Remove ring item and unused code --- src/main/java/baubles/common/Baubles.java | 18 --- src/main/java/baubles/common/Config.java | 50 -------- .../common/event/EventHandlerEntity.java | 65 +--------- .../java/baubles/common/items/ItemRing.java | 120 ------------------ .../common/lib/CreativeTabBaubles.java | 27 ---- .../assets/baubles/textures/items/ring.png | Bin 394 -> 0 bytes 6 files changed, 5 insertions(+), 275 deletions(-) delete mode 100644 src/main/java/baubles/common/Config.java delete mode 100644 src/main/java/baubles/common/items/ItemRing.java delete mode 100644 src/main/java/baubles/common/lib/CreativeTabBaubles.java delete mode 100644 src/main/resources/assets/baubles/textures/items/ring.png diff --git a/src/main/java/baubles/common/Baubles.java b/src/main/java/baubles/common/Baubles.java index ccc6fdb..4267d5d 100644 --- a/src/main/java/baubles/common/Baubles.java +++ b/src/main/java/baubles/common/Baubles.java @@ -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(); - - } } diff --git a/src/main/java/baubles/common/Config.java b/src/main/java/baubles/common/Config.java deleted file mode 100644 index cfd3466..0000000 --- a/src/main/java/baubles/common/Config.java +++ /dev/null @@ -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; - } -} diff --git a/src/main/java/baubles/common/event/EventHandlerEntity.java b/src/main/java/baubles/common/event/EventHandlerEntity.java index 4bd5255..615c850 100644 --- a/src/main/java/baubles/common/event/EventHandlerEntity.java +++ b/src/main/java/baubles/common/event/EventHandlerEntity.java @@ -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 playerModes = new HashMap(); - @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())); } } diff --git a/src/main/java/baubles/common/items/ItemRing.java b/src/main/java/baubles/common/items/ItemRing.java deleted file mode 100644 index ccfc0c9..0000000 --- a/src/main/java/baubles/common/items/ItemRing.java +++ /dev/null @@ -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; - } - -} diff --git a/src/main/java/baubles/common/lib/CreativeTabBaubles.java b/src/main/java/baubles/common/lib/CreativeTabBaubles.java deleted file mode 100644 index 61920d3..0000000 --- a/src/main/java/baubles/common/lib/CreativeTabBaubles.java +++ /dev/null @@ -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; - } - -} diff --git a/src/main/resources/assets/baubles/textures/items/ring.png b/src/main/resources/assets/baubles/textures/items/ring.png deleted file mode 100644 index 57e85d773d3eccb3f679663fa00bd885e3e6e1be..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 394 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Iwh_VCC){ui6xo&c?uz!xv31k zK!&lQf^TAxf{}rtiGqQJm64^DiK&9NfsuiMV(k6ZKz-~bp1!W^_n76`?0v(btiIVPik{pF~z5|DmUgV@SoVs}t99wK#~hp64^G zUv=_Dute^@h6It-30tB?1e^U89~I9ys*+?p>xjl3)=2Xon_nNZEqr#y{QDi|KYQim z-@WMj&gBp&()hgc#HOBo?;rmDxAH%aL*}fcNU@SwcF#!*URy28Y|5Ne`^nJMKpDaCp>n~1ApTjHDECzWzjQ!5!Z*g6WZtXNg0pxw3U*sa$LD_%?W zJwC8$&05Z)SaF%-3sgTe~DWM4f2AY-~