diff --git a/.gitignore b/.gitignore index 7ae4cc7..6fdd4be 100644 --- a/.gitignore +++ b/.gitignore @@ -1,18 +1,4 @@ -/assets/borderlands -/assets/icecreamcreepers -/assets/testing -/assets/forge -/cpw -/ibxm -/net -/paulscode -*.lzma -*.cfg -fmlversion.properties -forge_logo.png -mcpmod.info -Start.java -*.class -*.jar -ICSCreeperMod.properties -BorderlandsMod.properties \ No newline at end of file +/.gradle +/build +/eclipse +build.gradle \ No newline at end of file diff --git a/assets/fyresmodjam/sound/pillarActivated.wav b/assets/fyresmodjam/sound/pillarActivated.wav deleted file mode 100644 index 61b952d..0000000 Binary files a/assets/fyresmodjam/sound/pillarActivated.wav and /dev/null differ diff --git a/fyresmodjam/ClientProxy.java b/fyresmodjam/ClientProxy.java deleted file mode 100644 index 82c394b..0000000 --- a/fyresmodjam/ClientProxy.java +++ /dev/null @@ -1,127 +0,0 @@ -package fyresmodjam; - -import java.awt.Color; - -import org.lwjgl.input.Keyboard; - - - - - - -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.entity.RenderSnowball; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumMovingObjectType; -import net.minecraft.util.MovingObjectPosition; -import net.minecraft.world.World; -import net.minecraftforge.client.event.RenderGameOverlayEvent; -import net.minecraftforge.client.event.sound.SoundLoadEvent; -import net.minecraftforge.common.Configuration; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.ForgeSubscribe; -import cpw.mods.fml.client.registry.ClientRegistry; -import cpw.mods.fml.client.registry.KeyBindingRegistry; -import cpw.mods.fml.client.registry.RenderingRegistry; -import cpw.mods.fml.common.registry.TickRegistry; -import cpw.mods.fml.relauncher.Side; -import fyresmodjam.entities.EntityMysteryPotion; -import fyresmodjam.entities.renderers.RenderMysteryPotion; -import fyresmodjam.handlers.ClientTickHandler; -import fyresmodjam.handlers.FyresKeyHandler; -import fyresmodjam.misc.EntityStatHelper; -import fyresmodjam.tileentities.TileEntityCrystal; -import fyresmodjam.tileentities.TileEntityCrystalStand; -import fyresmodjam.tileentities.TileEntityPillar; -import fyresmodjam.tileentities.TileEntityTrap; -import fyresmodjam.tileentities.renderers.TileEntityCrystalRenderer; -import fyresmodjam.tileentities.renderers.TileEntityCrystalStandRenderer; -import fyresmodjam.tileentities.renderers.TileEntityPillarRenderer; -import fyresmodjam.tileentities.renderers.TileEntityTrapRenderer; - -public class ClientProxy extends CommonProxy { - - public static String[] sounds = {"pillarActivated"/*, "coin"*/}; - - @ForgeSubscribe - public void onSound(SoundLoadEvent event) { - for(String s : sounds) {event.manager.addSound("fyresmodjam:" + s + ".wav");} - } - - @ForgeSubscribe - public void guiRenderEvent(RenderGameOverlayEvent.Post event) { - if(event.type == RenderGameOverlayEvent.ElementType.HOTBAR) { - MovingObjectPosition mouse = Minecraft.getMinecraft().objectMouseOver; - - World world = Minecraft.getMinecraft().theWorld; - - if(mouse != null && world != null && mouse.typeOfHit == EnumMovingObjectType.TILE) { - TileEntity te = world.getBlockTileEntity(mouse.blockX, mouse.blockY, mouse.blockZ); - int id = world.getBlockId(mouse.blockX, mouse.blockY, mouse.blockZ); - - if(id == ModjamMod.blockPillar.blockID || (id == ModjamMod.blockTrap.blockID && te != null && te instanceof TileEntityTrap && ((TileEntityTrap) te).placedBy != null)) { - String key = Keyboard.getKeyName(FyresKeyHandler.examine.keyCode); - String string = "Press " + key + " to Examine"; - - if(te != null && Minecraft.getMinecraft().thePlayer != null && te instanceof TileEntityTrap && ((TileEntityTrap) te).placedBy.equals(Minecraft.getMinecraft().thePlayer.getEntityName())) { - string = Minecraft.getMinecraft().thePlayer.isSneaking() ? "Use to disarm (Stand to toggle setting)" : "Use to toggle setting (Sneak to disarm)"; - } - - Minecraft.getMinecraft().fontRenderer.drawStringWithShadow(string, (event.resolution.getScaledWidth() / 2) - (Minecraft.getMinecraft().fontRenderer.getStringWidth(string) / 2), event.resolution.getScaledHeight() / 2 + 16, Color.WHITE.getRGB()); - } - } - - if(Minecraft.getMinecraft().thePlayer != null) { - EntityPlayer player = Minecraft.getMinecraft().thePlayer; - String blessing = EntityStatHelper.getStat(player, "Blessing"); - - if(blessing != null) { - if(blessing.equals("Berserker")) { - if(!EntityStatHelper.hasStat(player, "BlessingCounter")) {EntityStatHelper.giveStat(player, "BlessingCounter", 0);} - String string = EntityStatHelper.getStat(player, "BlessingCounter"); - Minecraft.getMinecraft().fontRenderer.drawStringWithShadow(string, (event.resolution.getScaledWidth() / 2) - (Minecraft.getMinecraft().fontRenderer.getStringWidth(string) / 2), event.resolution.getScaledHeight() - 48 + (player.capabilities.isCreativeMode ? 16 : 0), Color.RED.getRGB()); - } - } - } - } - } - - //public static int mushroomRendererID; - - @Override - public void register() { - //TickRegistry.registerTickHandler(new CommonTickHandler(), Side.SERVER); - TickRegistry.registerTickHandler(new ClientTickHandler(), Side.CLIENT); - - KeyBindingRegistry.registerKeyBinding(new FyresKeyHandler()); - - ClientRegistry.bindTileEntitySpecialRenderer(TileEntityPillar.class, new TileEntityPillarRenderer()); - ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTrap.class, new TileEntityTrapRenderer()); - ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCrystal.class, new TileEntityCrystalRenderer()); - ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCrystalStand.class, new TileEntityCrystalStandRenderer()); - - RenderingRegistry.registerEntityRenderingHandler(EntityMysteryPotion.class, new RenderMysteryPotion(ModjamMod.mysteryPotion)); - - //mushroomRendererID = RenderingRegistry.getNextAvailableRenderId(); - //RenderingRegistry.registerBlockHandler(new BlockMysteryMushroomRenderer()); - - MinecraftForge.EVENT_BUS.register(this); - } - - @Override - public void sendPlayerMessage(String message) { - Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(message); - } - - @Override - public void loadFromConfig(Configuration config) { - super.loadFromConfig(config); - - ModjamMod.examineKey = config.get("Keybindings", "examine_key", ModjamMod.examineKey).getInt(ModjamMod.examineKey); - ModjamMod.blessingKey = config.get("Keybindings", "blessing_key", ModjamMod.blessingKey).getInt(ModjamMod.blessingKey); - - FyresKeyHandler.examine.keyCode = ModjamMod.examineKey; - FyresKeyHandler.activateBlessing.keyCode = ModjamMod.blessingKey; - } -} diff --git a/fyresmodjam/CommonProxy.java b/fyresmodjam/CommonProxy.java deleted file mode 100644 index b572bbd..0000000 --- a/fyresmodjam/CommonProxy.java +++ /dev/null @@ -1,40 +0,0 @@ -package fyresmodjam; - -import net.minecraftforge.common.Configuration; -import cpw.mods.fml.common.registry.TickRegistry; -import cpw.mods.fml.relauncher.Side; - -public class CommonProxy { - public void register() { - //TickRegistry.registerTickHandler(new CommonTickHandler(), Side.SERVER); - } - - public void sendPlayerMessage(String message) {} - - public void loadFromConfig(Configuration config) { - ModjamMod.itemID = config.getItem("item_ids", ModjamMod.itemID).getInt(); - ModjamMod.blockID = config.getBlock("block_ids",ModjamMod. blockID).getInt(); - - ModjamMod.pillarGlow = config.get(config.CATEGORY_GENERAL, "pillar_glow", ModjamMod.pillarGlow).getBoolean(ModjamMod.pillarGlow); - - ModjamMod.pillarGenChance = config.get(config.CATEGORY_GENERAL, "pillar_gen_difficulty", ModjamMod.pillarGenChance).getInt(); - ModjamMod.maxPillarsPerChunk = config.get(config.CATEGORY_GENERAL, "max_pillars_per_chunk", ModjamMod.maxPillarsPerChunk).getInt(); - ModjamMod.towerGenChance = config.get(config.CATEGORY_GENERAL, "tower_gen_difficulty", ModjamMod.towerGenChance).getInt(); - ModjamMod.trapGenChance = config.get(config.CATEGORY_GENERAL, "trap_gen_difficulty", ModjamMod.trapGenChance).getInt(); - ModjamMod.mushroomReplaceChance = config.get(config.CATEGORY_GENERAL, "mushroom_replace_difficulty", ModjamMod.mushroomReplaceChance).getInt(); - - ModjamMod.spawnTraps = !(config.get(config.CATEGORY_GENERAL, "disable_traps", !ModjamMod.spawnTraps).getBoolean(!ModjamMod.spawnTraps)); - ModjamMod.spawnTowers = config.get(config.CATEGORY_GENERAL, "spawn_towers", ModjamMod.spawnTowers).getBoolean(ModjamMod.spawnTowers); - ModjamMod.spawnRandomPillars = config.get(config.CATEGORY_GENERAL, "spawn_random_pillars", ModjamMod.spawnRandomPillars).getBoolean(ModjamMod.spawnRandomPillars); - ModjamMod.disableDisadvantages = config.get(config.CATEGORY_GENERAL, "disable_disadvantages", ModjamMod.disableDisadvantages).getBoolean(ModjamMod.disableDisadvantages); - ModjamMod.versionChecking = config.get(config.CATEGORY_GENERAL, "version_checking", ModjamMod.versionChecking).getBoolean(ModjamMod.versionChecking); - - ModjamMod.showAllPillarsInCreative = config.get(config.CATEGORY_GENERAL, "show_all_pillars_in_creative", ModjamMod.showAllPillarsInCreative).getBoolean(ModjamMod.showAllPillarsInCreative); - - ModjamMod.enableMobKillStats = config.get(config.CATEGORY_GENERAL, "enable_mob_kill_stats", ModjamMod.enableMobKillStats).getBoolean(ModjamMod.enableMobKillStats); - ModjamMod.enableWeaponKillStats = config.get(config.CATEGORY_GENERAL, "enable_weapon_kill_stats", ModjamMod.enableWeaponKillStats).getBoolean(ModjamMod.enableWeaponKillStats); - ModjamMod.enableCraftingStats = config.get(config.CATEGORY_GENERAL, "enable_crafting_stats", ModjamMod.enableCraftingStats).getBoolean(ModjamMod.enableCraftingStats); - - ModjamMod.trapsBelowGroundOnly = config.get(config.CATEGORY_GENERAL, "traps_below_ground_only", ModjamMod.trapsBelowGroundOnly).getBoolean(ModjamMod.trapsBelowGroundOnly); - } -} diff --git a/fyresmodjam/ModjamMod.java b/fyresmodjam/ModjamMod.java deleted file mode 100644 index ff4679f..0000000 --- a/fyresmodjam/ModjamMod.java +++ /dev/null @@ -1,596 +0,0 @@ -package fyresmodjam; - -import java.awt.Color; -import java.io.BufferedReader; -import java.io.File; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.lang.reflect.Method; -import java.net.URL; -import java.util.Properties; -import java.util.Random; - -import org.lwjgl.input.Keyboard; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockContainer; -import net.minecraft.block.material.Material; -import net.minecraft.command.CommandHandler; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLiving; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.IRangedAttackMob; -import net.minecraft.entity.SharedMonsterAttributes; -import net.minecraft.entity.monster.EntityCreeper; -import net.minecraft.entity.monster.EntityMob; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.Item; -import net.minecraft.item.ItemArmor; -import net.minecraft.item.ItemAxe; -import net.minecraft.item.ItemBow; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemSword; -import net.minecraft.stats.Achievement; -import net.minecraft.util.WeightedRandomChestContent; -import net.minecraftforge.common.AchievementPage; -import net.minecraftforge.common.ChestGenHooks; -import net.minecraftforge.common.Configuration; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.ForgeSubscribe; -import net.minecraftforge.event.entity.player.PlayerEvent; -import cpw.mods.fml.common.ICraftingHandler; -import cpw.mods.fml.common.IPlayerTracker; -import cpw.mods.fml.common.Mod; -import cpw.mods.fml.common.Mod.EventHandler; -import cpw.mods.fml.common.Mod.Instance; -import cpw.mods.fml.common.SidedProxy; -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; -import cpw.mods.fml.common.network.NetworkMod; -import cpw.mods.fml.common.network.NetworkRegistry; -import cpw.mods.fml.common.network.PacketDispatcher; -import cpw.mods.fml.common.network.Player; -import cpw.mods.fml.common.registry.EntityRegistry; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.common.registry.LanguageRegistry; -import cpw.mods.fml.common.registry.TickRegistry; -import cpw.mods.fml.relauncher.Side; -import fyresmodjam.blocks.BlockCrystal; -import fyresmodjam.blocks.BlockCrystalStand; -import fyresmodjam.blocks.BlockMysteryMushroom; -import fyresmodjam.blocks.BlockPillar; -import fyresmodjam.blocks.BlockTrap; -import fyresmodjam.commands.CommandCraftingStats; -import fyresmodjam.commands.CommandCurrentBlessing; -import fyresmodjam.commands.CommandCurrentDisadvantage; -import fyresmodjam.commands.CommandCurrentWorldTask; -import fyresmodjam.commands.CommandKillStats; -import fyresmodjam.commands.CommandWeaponStats; -import fyresmodjam.entities.EntityMysteryPotion; -import fyresmodjam.handlers.CommonTickHandler; -import fyresmodjam.handlers.GUIHandler; -import fyresmodjam.handlers.PacketHandler; -import fyresmodjam.items.ItemCrystal; -import fyresmodjam.items.ItemMysteryMushroom; -import fyresmodjam.items.ItemMysteryPotion; -import fyresmodjam.items.ItemObsidianSceptre; -import fyresmodjam.items.ItemPillar; -import fyresmodjam.items.ItemScroll; -import fyresmodjam.items.ItemTrap; -import fyresmodjam.misc.CreativeTabModjamMod; -import fyresmodjam.misc.EntityStatHelper; -import fyresmodjam.misc.ItemStatHelper; -import fyresmodjam.misc.EntityStatHelper.EntityStat; -import fyresmodjam.misc.EntityStatHelper.EntityStatTracker; -import fyresmodjam.misc.ItemStatHelper.ItemStat; -import fyresmodjam.misc.ItemStatHelper.ItemStatTracker; -import fyresmodjam.tileentities.TileEntityCrystal; -import fyresmodjam.tileentities.TileEntityCrystalStand; -import fyresmodjam.tileentities.TileEntityPillar; -import fyresmodjam.tileentities.TileEntityTrap; -import fyresmodjam.worldgen.FyresWorldData; -import fyresmodjam.worldgen.PillarGen; -import fyresmodjam.worldgen.WorldGenMoreDungeons; -import fyresmodjam.worldgen.WorldGenTrapsTowersAndMore; - -@Mod(modid = "fyresmodjam", name = "Fyres ModJam Mod", version = "0.0.3d") -@NetworkMod(clientSideRequired = true, serverSideRequired = false, channels = {"FyresModJamMod"}, packetHandler = PacketHandler.class) -public class ModjamMod extends CommandHandler implements IPlayerTracker { - - @SidedProxy(clientSide = "fyresmodjam.ClientProxy", serverSide = "fyresmodjam.CommonProxy") - public static CommonProxy proxy; - - @Instance("fyresmodjam") - public static ModjamMod instance; - - public static Random r = new Random(); - - public static int itemID = 6971, blockID = 2875, achievementID = 2500, examineKey = Keyboard.KEY_X, blessingKey = Keyboard.KEY_K; - public static int pillarGenChance = 75, maxPillarsPerChunk = 3, towerGenChance = 225, trapGenChance = 300, mushroomReplaceChance = 15; - public static boolean pillarGlow = true, spawnTraps = true, spawnTowers = true, spawnRandomPillars = true, disableDisadvantages = false, versionChecking = true, trapsBelowGroundOnly = false, showAllPillarsInCreative = false, enableWeaponKillStats = true, enableMobKillStats = true, enableCraftingStats = true; - - public static CreativeTabs tabModjamMod = new CreativeTabModjamMod(CreativeTabs.getNextID(), "The \"You Will Die\" Mod"); - - public static Block blockPillar; - public static Block blockTrap; - public static Block mysteryMushroomBlock; - - public static Item itemPillar; - public static Item mysteryPotion; - public static Item itemTrap; - public static Item mysteryMushroom; - public static Item sceptre; - - public static Item crystalItem; - public static Item scroll; - - public static Block crystal; - public static Block crystalStand; - - public static Achievement startTheGame; - public static Achievement losingIsFun; - public static Achievement whoops; - - public static Achievement theHunt; - public static Achievement jackOfAllTrades; - - public static AchievementPage page; - - public static String version = "v0.0.3d"; - public static String foundVersion = "v0.0.3d"; - public static boolean newerVersion = false; - - /*public static void loadProperties() { - Properties prop = new Properties(); - - try { - prop.load(ModjamMod.class.getResourceAsStream("/FyresModJamMod.properties")); - } catch (Exception e) {e.printStackTrace();} - - itemID = Integer.parseInt(prop.getProperty("itemID", "" + itemID)); - blockID = Integer.parseInt(prop.getProperty("blockID", "" + blockID)); - //achievementID = Integer.parseInt(prop.getProperty("achievementID", "" + achievementID)); - pillarGlow = Boolean.parseBoolean(prop.getProperty("pillarGlow", "" + pillarGlow)); - - pillarGenChance = Integer.parseInt(prop.getProperty("pillarGenChance", "" + pillarGenChance)); - maxPillarsPerChunk = Integer.parseInt(prop.getProperty("maxPillarsPerChunk", "" + maxPillarsPerChunk)); - towerGenChance = Integer.parseInt(prop.getProperty("towerGenChance", "" + towerGenChance)); - trapGenChance = Integer.parseInt(prop.getProperty("trapGenChance", "" + trapGenChance)); - mushroomReplaceChance = Integer.parseInt(prop.getProperty("mushroomReplaceChance", "" + mushroomReplaceChance)); - - spawnTraps = !Boolean.parseBoolean(prop.getProperty("disableTraps", "" + (!spawnTraps))); - trapsBelowGroundOnly = Boolean.parseBoolean(prop.getProperty("trapsBelowGroundOnly", "" + trapsBelowGroundOnly)); - versionChecking = Boolean.parseBoolean(prop.getProperty("versionChecking", "" + versionChecking)); - - showAllPillarsInCreative = Boolean.parseBoolean(prop.getProperty("showAllPillarsInCreative", "" + showAllPillarsInCreative)); - }*/ - - public static ItemStack losingIsFunStack = new ItemStack(Item.bow, 1); - public static ItemStack whoopsStack = new ItemStack(Item.flintAndSteel, 1, 1); - - public static String configPath = null; - - public static final String versionOrder = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; - - @EventHandler - public void preInit(FMLPreInitializationEvent event) { - //loadProperties(); - - File old = new File(event.getSuggestedConfigurationFile().getAbsolutePath().replace("fyresmodjam", "YouWillDieMod")); - if(old.exists()) {old.delete(); System.out.println(true);} - - configPath = event.getSuggestedConfigurationFile().getAbsolutePath().replace("fyresmodjam", "TheYouWillDieMod"); - - Configuration config = new Configuration(new File(configPath)); - - config.load(); - - proxy.loadFromConfig(config); - - config.save(); - - if(versionChecking) { - InputStream in = null; - BufferedReader reader = null; - - try { - in = new URL("https://dl.dropboxusercontent.com/s/n30va53f6uh2mki/versions.txt?token_hash=AAE89oZXZUV7Khx4mAbLhJS1Q4UuMZW2CXAO52yW1Ef9fw").openStream(); - reader = new BufferedReader(new InputStreamReader(in)); - - String inputLine; - while((inputLine = reader.readLine()) != null && !inputLine.startsWith("YWDMod")) {} - if(inputLine != null) {foundVersion = inputLine.split("=")[1];} - } catch (Exception e) { - e.printStackTrace(); - } finally { - try { - if(reader != null) {reader.close();} - - if(in != null) {in.close();} - } catch (Exception e) {e.printStackTrace();} - } - - String[] versionSplit = version.replace("v", "").split("\\."), foundSplit = foundVersion.replace("v", "").split("\\."); - - if(!version.equals(foundVersion) && (Integer.parseInt(versionSplit[0]) < Integer.parseInt(foundSplit[0]) ? (Integer.parseInt(versionSplit[1]) < Integer.parseInt(foundSplit[1]) ? (Integer.parseInt("" + versionSplit[2].charAt(0)) < Integer.parseInt("" + foundSplit[2].charAt(0)) ? (versionOrder.indexOf(versionSplit[2].charAt(1)) < versionOrder.indexOf(foundSplit[2].charAt(1))) : false) : false) : false)) { - System.out.println("A newer version of the \"You Will Die\" Mod has been found (" + foundVersion + ")."); - newerVersion = true; - } else { - System.out.println("No newer version of the \"You Will Die\" Mod has been found."); - } - } else {System.out.println("\"You Will\" Die Mod version checking disabled.");} - - startTheGame = getNewAchievement(achievementID, 0, 0, new ItemStack(Item.swordIron, 1), "startTheGame", "You Will Die", "Join a world with this mod installed", null, true); - losingIsFun = getNewAchievement(achievementID + 1, -2, 0, losingIsFunStack, "losingIsFun", "Losing Is Fun", "Experience \"fun\"", startTheGame, false); - whoops = getNewAchievement(achievementID + 2, 2, 0, whoopsStack, "whoops", "Whoops", "Fail to disarm a trap", startTheGame, false); - - theHunt = getNewAchievement(achievementID + 3, 0, -2, new ItemStack(Item.bow, 1), "theHunt", "The Hunt", "Become a competent slayer of 5 or more different creatures", startTheGame, false); - jackOfAllTrades = getNewAchievement(achievementID + 4, 0, 2, new ItemStack(Block.workbench, 1), "jackOfAllTrades", "Jack of All Trades", "Become a novice user of at least 10 different weapons", startTheGame, false); - - page = new AchievementPage("The \"You Will Die\" Mod", startTheGame, losingIsFun, whoops, theHunt, jackOfAllTrades); - - AchievementPage.registerAchievementPage(page); - } - - @EventHandler - public void init(FMLInitializationEvent event) { - - //Registering - - TickRegistry.registerTickHandler(new CommonTickHandler(), Side.SERVER); - - MinecraftForge.EVENT_BUS.register(this); - GameRegistry.registerPlayerTracker(this); - - new ItemStatHelper().register(); - new EntityStatHelper().register(); - - NetworkRegistry.instance().registerGuiHandler(this, new GUIHandler()); - - GameRegistry.registerWorldGenerator(new PillarGen()); - - //if(spawnTraps) { - GameRegistry.registerWorldGenerator(new WorldGenTrapsTowersAndMore()); - //} - - for(int i = 0; i < 3; i++) {GameRegistry.registerWorldGenerator(new WorldGenMoreDungeons());} - - EntityRegistry.registerGlobalEntityID(EntityMysteryPotion.class, "MysteryPotion", EntityRegistry.findGlobalUniqueEntityId()); - EntityRegistry.registerModEntity(EntityMysteryPotion.class, "MysteryPotion", 0, instance, 128, 1, true); - LanguageRegistry.instance().addStringLocalization("entity.MysteryPotion.name", "en_US", "Mystery Potion"); - - //Item and Block loading - - blockPillar = new BlockPillar(blockID).setBlockUnbreakable().setResistance(6000000.0F); - blockTrap = new BlockTrap(blockID + 1).setBlockUnbreakable().setResistance(6000000.0F); - mysteryMushroomBlock = new BlockMysteryMushroom(blockID + 2).setHardness(0.0F).setStepSound(Block.soundGrassFootstep).setLightValue(0.125F); - - crystal = new BlockCrystal(blockID + 3); - GameRegistry.registerBlock(crystal, "crystal"); - GameRegistry.registerTileEntity(TileEntityCrystal.class, "Crystal Tile Entity"); - LanguageRegistry.addName(crystal, "Crystal"); - - crystalStand = new BlockCrystalStand(blockID + 4).setCreativeTab(CreativeTabs.tabDecorations); - GameRegistry.registerBlock(crystalStand, "crystalStand"); - GameRegistry.registerTileEntity(TileEntityCrystalStand.class, "Crystal Stand Tile Entity"); - LanguageRegistry.addName(crystalStand, "Crystal Stand"); - - itemPillar = new ItemPillar(itemID).setUnlocalizedName("blockPillar"); - mysteryPotion = new ItemMysteryPotion(itemID + 1).setUnlocalizedName("mysteryPotion").setCreativeTab(CreativeTabs.tabBrewing); - itemTrap = new ItemTrap(itemID + 2).setUnlocalizedName("itemTrap").setCreativeTab(CreativeTabs.tabBlock); - mysteryMushroom = new ItemMysteryMushroom(itemID + 3).setUnlocalizedName("mysteryMushroom").setCreativeTab(CreativeTabs.tabBrewing); - sceptre = new ItemObsidianSceptre(itemID + 4).setUnlocalizedName("sceptre").setCreativeTab(CreativeTabs.tabTools).setFull3D(); - - crystalItem = new ItemCrystal(crystal.blockID - 256); - - scroll = new ItemScroll(itemID + 5).setUnlocalizedName("scroll").setCreativeTab(CreativeTabs.tabMisc); - LanguageRegistry.addName(scroll, "Scroll"); - - GameRegistry.registerBlock(blockPillar, "blockPillar"); - GameRegistry.registerTileEntity(TileEntityPillar.class, "Pillar Tile Entity"); - - GameRegistry.registerBlock(blockTrap, "blockTrap"); - GameRegistry.registerTileEntity(TileEntityTrap.class, "Trap Entity"); - - //LanguageRegistry.addName(blockPillar, "Pillar Block"); - //LanguageRegistry.addName(blockTrap, "Trap"); - //LanguageRegistry.addName(mysteryMushroomBlock, "Mystery Mushroom"); - - LanguageRegistry.addName(itemPillar, "Pillar"); - LanguageRegistry.addName(mysteryPotion, "Mystery Potion"); - LanguageRegistry.addName(itemTrap, "Trap"); - LanguageRegistry.addName(mysteryMushroom, "Mystery Mushroom"); - LanguageRegistry.addName(sceptre, "Obsidian Sceptre"); - - LanguageRegistry.instance().addStringLocalization("commands.currentBlessing.usage", "/currentBlessing - used to check your current blessing"); - LanguageRegistry.instance().addStringLocalization("commands.currentDisadvantage.usage", "/currentDisadvantage - used to check your current world disadvantage"); - LanguageRegistry.instance().addStringLocalization("commands.currentGoal.usage", "/currentGoal - used to check your current world goal"); - LanguageRegistry.instance().addStringLocalization("commands.creatureKnowledge.usage", "/creatureKnowledge [page] - used to check your current creature knowledge stats"); - LanguageRegistry.instance().addStringLocalization("commands.weaponKnowledge.usage", "/weaponKnowledge [page] - used to check your current weapon knowledge stats"); - LanguageRegistry.instance().addStringLocalization("commands.craftingKnowledge.usage", "/craftingKnowledge [page] - used to check your current crafting knowledge stats"); - LanguageRegistry.instance().addStringLocalization("fyresmodjam.newVersion", "\u00A7bA newer version of the \"You Will Die\" Mod has been found (" + foundVersion + ")."); - - GameRegistry.addShapelessRecipe(new ItemStack(itemTrap, 1, 0), new Object[] {Block.pressurePlateIron, Block.cactus}); - GameRegistry.addShapelessRecipe(new ItemStack(itemTrap, 1, 1), new Object[] {Block.pressurePlateIron, Block.torchWood}); - GameRegistry.addShapelessRecipe(new ItemStack(itemTrap, 1, 2), new Object[] {Block.pressurePlateIron, new ItemStack(Item.dyePowder, 1, 0)}); - - for(int i = 0; i < 13; i++) { - GameRegistry.addShapelessRecipe(new ItemStack(mysteryPotion, 1, i + 13), new Object[] {new ItemStack(mysteryPotion, 1, i), Item.gunpowder}); - GameRegistry.addShapelessRecipe(new ItemStack(mysteryPotion, 1, i), new Object[] {new ItemStack(Item.potion, 1, 0), Item.leather, new ItemStack(mysteryMushroom, 1, i)}); - } - - GameRegistry.addRecipe(new ItemStack(sceptre, 1, 0), "X", "Y", "X", 'X', Block.obsidian, 'Y', Block.whiteStone); - GameRegistry.addShapelessRecipe(new ItemStack(sceptre, 1, 1), new Object[] {new ItemStack(sceptre, 1, 0), Item.enderPearl, Item.book}); - - proxy.register(); - - //Entity Trackers - - EntityStatTracker playerTracker = new EntityStatTracker(EntityPlayer.class, true); - - playerTracker.addStat(new EntityStat("BlessingCooldown", "" + 0)); - playerTracker.addStat(new EntityStat("BlessingCounter", "" + 0)); - - EntityStatTracker mobTracker = new EntityStatTracker(EntityMob.class, true); - - mobTracker.addStat(new EntityStat("Level", "") { - public Object getNewValue(Random r) { - int i = 1; - for(; i < 5; i++) {if(ModjamMod.r.nextInt(5) < 3) {break;}} - return i; - } - - public String getAlteredEntityName(EntityLiving entity) { - int level = 1; - - try { - level = Integer.parseInt(entity.getEntityData().getString(name)); - } catch (Exception e) {e.printStackTrace();} - - return (level == 5 ? "\u00A7c" : "") + entity.getEntityName() + ", Level " + level; - } - - public void modifyEntity(Entity entity) { - int level = 1; - - try { - level = Integer.parseInt(entity.getEntityData().getString(name)); - } catch (Exception e) {e.printStackTrace();} - - int healthGain = (int) ((level - 1) * (((EntityLivingBase) entity).getMaxHealth()/4) + (level == 5 ? ((EntityLivingBase) entity).getMaxHealth()/4 : 0)); - - if(healthGain != 0) { - ((EntityLivingBase) entity).getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(((EntityLivingBase) entity).getMaxHealth() + healthGain); - ((EntityLivingBase) entity).setHealth(((EntityLivingBase) entity).getMaxHealth() + healthGain); - } - - if(level == 5) { - switch(r.nextInt(4)) { - - case 0: - if(entity instanceof IRangedAttackMob) {entity.getEntityData().setString("Blessing", "Hunter");} - else {entity.getEntityData().setString("Blessing", "Warrior");} - break; - - case 1: entity.getEntityData().setString("Blessing", "Swamp"); break; - case 2: entity.getEntityData().setString("Blessing", "Guardian"); break; - case 3: entity.getEntityData().setString("Blessing", "Vampire"); break; - - default: break; - - } - - if(entity instanceof EntityCreeper) { - ((EntityCreeper) entity).getDataWatcher().updateObject(17, (byte) 1); - ((EntityCreeper) entity).getEntityData().setBoolean("powered", true); - } - } - } - }); - - EntityStatHelper.addStatTracker(mobTracker); - - //Item Trackers - - ItemStatTracker weaponTracker = new ItemStatTracker(new Class[] {ItemSword.class, ItemAxe.class, ItemBow.class}, null, true); - - weaponTracker.addStat(new ItemStat("Rank", "") { - - public String[][] prefixesByRank = { - {"Old", "Dull", "Broken", "Worn"}, - {"Average", "Decent", "Modest", "Ordinary"}, - {"Strong", "Sharp", "Polished", "Refined"}, - {"Powerful", "Ruthless", "Elite", "Astonishing"}, - {"Godly", "Divine", "Fabled", "Legendary"} - }; - - public Object getNewValue(ItemStack stack, Random r) { - int i = 1; - for(; i < 5; i++) {if(ModjamMod.r.nextInt(10) < 7) {break;}} - return i; - } - - public void modifyStack(ItemStack stack, Random r) { - int rank = Integer.parseInt(stack.getTagCompound().getString(name)); - float bonusDamage = ((float) rank - 1)/2 + (r.nextInt(rank + 1) * r.nextFloat()); - - //ItemStatHelper.giveStat(stack, "BonusDamage", bonusDamage); - //ItemStatHelper.addLore(stack, bonusDamage != 0 ? "\u00A77\u00A7o " + (bonusDamage > 0 ? "+" : "") + bonusDamage + " bonus damage" : null); - - ItemStatHelper.giveStat(stack, "BonusDamage", String.format("%.2f", bonusDamage)); - ItemStatHelper.addLore(stack, !String.format("%.2f", bonusDamage).equals("0.00") ? "\u00A77\u00A7o " + (bonusDamage > 0 ? "+" : "") + String.format("%.2f", bonusDamage) + " bonus damage" : null); - - ItemStatHelper.addLore(stack, "\u00A7eRank: "+ rank); - } - - public String getAlteredStackName(ItemStack stack, Random r) { - String[] list = prefixesByRank[Integer.parseInt(stack.getTagCompound().getString(name)) - 1]; - String prefix = list[r.nextInt(list.length)]; - - if(prefix.equals("Sharp") && stack.getItem() instanceof ItemBow) {prefix = "Long";} - - return "\u00A7f" + prefix + " " + stack.getDisplayName(); - } - - }); - - ItemStatHelper.addStatTracker(weaponTracker); - - ItemStatTracker armorTracker = new ItemStatTracker(new Class[] {ItemArmor.class}, null, true); - - armorTracker.addStat(new ItemStat("Rank", "") { - - public String[][] prefixesByRank = { - {"Old", "Broken", "Worn", "Weak"}, - {"Average", "Decent", "Modest", "Ordinary"}, - {"Polished", "Tough", "Hardened", "Durable"}, - {"Elite", "Astonishing", "Reinforced", "Resilient"}, - {"Godly", "Divine", "Fabled", "Legendary"} - }; - - public Object getNewValue(ItemStack stack, Random r) { - int i = 1; - for(; i < 5; i++) {if(ModjamMod.r.nextInt(10) < 7) {break;}} - return i; - } - - public void modifyStack(ItemStack stack, Random r) { - int rank = Integer.parseInt(stack.getTagCompound().getString(name)); - float damageReduction = (rank - 1) + r.nextFloat() * 0.5F; - - ItemStatHelper.giveStat(stack, "DamageReduction", String.format("%.2f", damageReduction)); - ItemStatHelper.addLore(stack, !String.format("%.2f", damageReduction).equals("0.00") ? "\u00A77\u00A7o " + (damageReduction > 0 ? "+" : "") + String.format("%.2f", damageReduction) + "% damage reduction" : null); - - ItemStatHelper.addLore(stack, "\u00A7eRank: "+ rank); - } - - public String getAlteredStackName(ItemStack stack, Random r) { - String[] list = prefixesByRank[Integer.parseInt(stack.getTagCompound().getString(name)) - 1]; - String prefix = list[r.nextInt(list.length)]; - - if(prefix.equals("Sharp") && stack.getItem() instanceof ItemBow) {prefix = "Long";} - - return "\u00A7f" + prefix + " " + stack.getDisplayName(); - } - - }); - - ItemStatHelper.addStatTracker(armorTracker); - - //ItemStatTracker foodTracker = new ItemStatTracker(ItemFood.class, -1); - //foodTracker.addStat(new ItemStat("Spoiled", false)); - //ItemStatHelper.addStatTracker(foodTracker); - - //Other - - losingIsFunStack.itemID = itemTrap.itemID; - whoopsStack.itemID = itemTrap.itemID; - - for(int i = 0; i < 13; i++) { - ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST).addItem(new WeightedRandomChestContent(mysteryPotion.itemID, i, 1, 3, 2)); - WorldGenTrapsTowersAndMore.chestGenInfo.addItem(new WeightedRandomChestContent(mysteryPotion.itemID, i, 1, 3, 2)); - } - } - - @EventHandler - public void postInit(FMLPostInitializationEvent event) { - - } - - @Override - public void onPlayerLogin(EntityPlayer player) { - if(!player.worldObj.isRemote) { - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.UPDATE_WORLD_DATA, new Object[] {CommonTickHandler.worldData.potionValues, CommonTickHandler.worldData.potionDurations, CommonTickHandler.worldData.getDisadvantage(), CommonTickHandler.worldData.currentTask, CommonTickHandler.worldData.currentTaskID, CommonTickHandler.worldData.currentTaskAmount, CommonTickHandler.worldData.progress, CommonTickHandler.worldData.tasksCompleted, CommonTickHandler.worldData.enderDragonKilled, ModjamMod.spawnTraps, CommonTickHandler.worldData.rewardLevels, CommonTickHandler.worldData.mushroomColors}), (Player) player); - - String name = CommonTickHandler.worldData.currentTask.equals("Kill") ? FyresWorldData.validMobNames[CommonTickHandler.worldData.currentTaskID] : new ItemStack(Item.itemsList[CommonTickHandler.worldData.currentTaskID], 1).getDisplayName(); - - if(CommonTickHandler.worldData.currentTaskAmount > 1) { - if(name.contains("Block")) {name = name.replace("Block", "Blocks").replace("block", "blocks");} - else {name += "s";} - } - - int index = -1; - for(int i = 0; i < CommonTickHandler.worldData.validDisadvantages.length; i++) {if(CommonTickHandler.worldData.validDisadvantages[i].equals(CommonTickHandler.worldData.getDisadvantage())) {index = i; break;}} - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7eWorld disadvantage: " + CommonTickHandler.worldData.getDisadvantage() + (index == -1 ? "" : " (" + CommonTickHandler.worldData.disadvantageDescriptions[index] + ")")}), (Player) player); - - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7eWorld goal: " + CommonTickHandler.worldData.currentTask + " " + CommonTickHandler.worldData.currentTaskAmount + " " + name + ". (" + CommonTickHandler.worldData.progress + " " + CommonTickHandler.worldData.currentTask + "ed)"}), (Player) player); - //PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7eReward: " + CommonTickHandler.worldData.rewardLevels + " levels"}), (Player) player); - //PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7eGoals completed: " + CommonTickHandler.worldData.tasksCompleted}), (Player) player); - - if(!player.getEntityData().hasKey("Blessing")) { - player.getEntityData().setString("Blessing", TileEntityPillar.validBlessings[ModjamMod.r.nextInt(TileEntityPillar.validBlessings.length)]); - while(player.getEntityData().getString("Blessing").equals("Inferno")) {player.getEntityData().setString("Blessing", TileEntityPillar.validBlessings[ModjamMod.r.nextInt(TileEntityPillar.validBlessings.length)]);} - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A72You've been granted the Blessing of the " + player.getEntityData().getString("Blessing") + ". (Use /currentBlessing to check effect)"}), (Player) player); - } - - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.UPDATE_BLESSING, new Object[] {player.getEntityData().getString("Blessing")}), (Player) player); - - if(!player.getEntityData().hasKey("PotionKnowledge")) {player.getEntityData().setIntArray("PotionKnowledge", new int[] {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1});} - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.UPDATE_POTION_KNOWLEDGE, new Object[] {player.getEntityData().getIntArray("PotionKnowledge")}), (Player) player); - } - - if(versionChecking && newerVersion) {player.addChatMessage("fyresmodjam.newVersion");} - - //player.triggerAchievement(startTheGame); - } - - @Override - public void onPlayerLogout(EntityPlayer player) { - - } - - @Override - public void onPlayerChangedDimension(EntityPlayer player) { - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.UPDATE_WORLD_DATA, new Object[] {CommonTickHandler.worldData.potionValues, CommonTickHandler.worldData.potionDurations, CommonTickHandler.worldData.getDisadvantage(), CommonTickHandler.worldData.currentTask, CommonTickHandler.worldData.currentTaskID, CommonTickHandler.worldData.currentTaskAmount, CommonTickHandler.worldData.progress, CommonTickHandler.worldData.tasksCompleted, CommonTickHandler.worldData.enderDragonKilled, ModjamMod.spawnTraps, CommonTickHandler.worldData.rewardLevels, CommonTickHandler.worldData.mushroomColors}), (Player) player); - - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.UPDATE_BLESSING, new Object[] {player.getEntityData().getString("Blessing")}), (Player) player); - - if(!player.getEntityData().hasKey("PotionKnowledge")) {player.getEntityData().setIntArray("PotionKnowledge", new int[] {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1});} - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.UPDATE_POTION_KNOWLEDGE, new Object[] {player.getEntityData().getIntArray("PotionKnowledge")}), (Player) player); - } - - @Override - public void onPlayerRespawn(EntityPlayer player) { - - } - - @ForgeSubscribe - public void checkBreakSpeed(PlayerEvent.BreakSpeed event) { - if(event.entityPlayer != null && event.entityPlayer.getEntityData().hasKey("Blessing")) { - String blessing = event.entityPlayer.getEntityData().getString("Blessing"); - - if(blessing.equals("Miner")) { - if(event.block.blockMaterial == Material.rock || event.block.blockMaterial == Material.iron) {event.newSpeed = event.originalSpeed * 1.25F;} - } else if(blessing.equals("Lumberjack")) { - if(event.block.blockMaterial == Material.wood) {event.newSpeed = event.originalSpeed * 1.25F;} - } - } - } - - @EventHandler - public void serverStarting(FMLServerStartingEvent event) { - this.initCommands(event); - } - - public void initCommands(FMLServerStartingEvent event) { - event.registerServerCommand(new CommandCurrentBlessing()); - event.registerServerCommand(new CommandCurrentDisadvantage()); - event.registerServerCommand(new CommandCurrentWorldTask()); - event.registerServerCommand(new CommandKillStats()); - event.registerServerCommand(new CommandWeaponStats()); - event.registerServerCommand(new CommandCraftingStats()); - } - - public static Achievement getNewAchievement(int id, int x, int y, ItemStack stack, String name, String displayName, String desc, Achievement prereq, boolean independent) { - Achievement achievement = new Achievement(id, name, x, y, stack, prereq); - if(independent) {achievement = achievement.setIndependent();} - LanguageRegistry.instance().addStringLocalization("achievement." + name, "en_US", displayName); - LanguageRegistry.instance().addStringLocalization("achievement." + name + ".desc", "en_US", desc); - achievement.registerAchievement(); - return achievement; - } -} diff --git a/fyresmodjam/blocks/BlockMysteryMushroom.java b/fyresmodjam/blocks/BlockMysteryMushroom.java deleted file mode 100644 index 1a1b1d3..0000000 --- a/fyresmodjam/blocks/BlockMysteryMushroom.java +++ /dev/null @@ -1,208 +0,0 @@ -package fyresmodjam.blocks; - -import java.util.List; -import java.util.Random; - - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import fyresmodjam.ModjamMod; -import fyresmodjam.handlers.PacketHandler; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockFlower; -import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Icon; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import net.minecraft.world.gen.feature.WorldGenBigMushroom; - -import net.minecraftforge.common.EnumPlantType; -import net.minecraftforge.common.ForgeDirection; -import net.minecraftforge.common.IPlantable; - -public class BlockMysteryMushroom extends BlockFlower -{ - - public Icon icon; - public Icon overlay; - - public BlockMysteryMushroom(int par1) { - super(par1); - float f = 0.2F; - this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 2.0F, 0.5F + f); - this.setTickRandomly(true); - } - - @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) { - icon = par1IconRegister.registerIcon("fyresmodjam:mushroomBlock"); - overlay = par1IconRegister.registerIcon("fyresmodjam:mushroomBlock_overlay"); - this.blockIcon = icon; - } - - @SideOnly(Side.CLIENT) - public Icon getIcon(int par1, int par2) { - return renderPass == 0 ? icon : overlay; - } - - public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) { - if (par5Random.nextInt(25) == 0) { - byte b0 = 4; - int l = 5; - int i1; - int j1; - int k1; - - for (i1 = par2 - b0; i1 <= par2 + b0; ++i1) - { - for (j1 = par4 - b0; j1 <= par4 + b0; ++j1) - { - for (k1 = par3 - 1; k1 <= par3 + 1; ++k1) - { - if (par1World.getBlockId(i1, k1, j1) == this.blockID) - { - --l; - - if (l <= 0) - { - return; - } - } - } - } - } - - i1 = par2 + par5Random.nextInt(3) - 1; - j1 = par3 + par5Random.nextInt(2) - par5Random.nextInt(2); - k1 = par4 + par5Random.nextInt(3) - 1; - - for (int l1 = 0; l1 < 4; ++l1) - { - if (par1World.isAirBlock(i1, j1, k1) && this.canBlockStay(par1World, i1, j1, k1)) - { - par2 = i1; - par3 = j1; - par4 = k1; - } - - i1 = par2 + par5Random.nextInt(3) - 1; - j1 = par3 + par5Random.nextInt(2) - par5Random.nextInt(2); - k1 = par4 + par5Random.nextInt(3) - 1; - } - - if (par1World.isAirBlock(i1, j1, k1) && this.canBlockStay(par1World, i1, j1, k1)) - { - par1World.setBlock(i1, j1, k1, this.blockID, par1World.getBlockMetadata(par2, par3, par4), 2); - } - } - } - - /** - * Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z - */ - public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4) - { - return super.canPlaceBlockAt(par1World, par2, par3, par4) && this.canBlockStay(par1World, par2, par3, par4); - } - - /** - * Gets passed in the blockID of the block below and supposed to return true if its allowed to grow on the type of - * blockID passed in. Args: blockID - */ - protected boolean canThisPlantGrowOnThisBlockID(int par1) - { - return Block.opaqueCubeLookup[par1]; - } - - /** - * Can this block stay at this position. Similar to canPlaceBlockAt except gets checked often with plants. - */ - public boolean canBlockStay(World par1World, int par2, int par3, int par4) - { - if (par3 >= 0 && par3 < 256) - { - int l = par1World.getBlockId(par2, par3 - 1, par4); - Block soil = Block.blocksList[l]; - return /*(l == Block.mycelium.blockID || par1World.getFullBlockLightValue(par2, par3, par4) < 13) &&*/ - (soil != null && soil.canSustainPlant(par1World, par2, par3 - 1, par4, ForgeDirection.UP, this)); - } - else - { - return false; - } - } - - @SideOnly(Side.CLIENT) - public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List) { - for(int i = 0; i < 13; i++) {par3List.add(new ItemStack(par1, 1, i));} - } - - public int damageDropped(int par1) { - return par1 % 13; - } - - /*public boolean fertilizeMushroom(World par1World, int par2, int par3, int par4, Random par5Random) - { - int l = par1World.getBlockMetadata(par2, par3, par4); - par1World.setBlockToAir(par2, par3, par4); - WorldGenBigMushroom worldgenbigmushroom = null; - - if (this.blockID == Block.mushroomBrown.blockID) - { - worldgenbigmushroom = new WorldGenBigMushroom(0); - } - else if (this.blockID == Block.mushroomRed.blockID) - { - worldgenbigmushroom = new WorldGenBigMushroom(1); - } - - if (worldgenbigmushroom != null && worldgenbigmushroom.generate(par1World, par5Random, par2, par3, par4)) - { - return true; - } - else - { - par1World.setBlock(par2, par3, par4, this.blockID, l, 3); - return false; - } - }*/ - - /*public static int lastMeta = 0; - - @SideOnly(Side.CLIENT) - public int getRenderColor(int par1) { - return PacketHandler.mushroomColors[lastMeta][par1]; - }*/ - - @SideOnly(Side.CLIENT) - public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) { - //lastMeta = par1IBlockAccess.getBlockMetadata(par2, par3, par4); - return PacketHandler.mushroomColors[par1IBlockAccess.getBlockMetadata(par2, par3, par4)][renderPass]; - } - - public static int renderPass; - public boolean canRenderInPass(int pass) { - this.renderPass = pass; - return true; - } - - public int idPicked(World par1World, int par2, int par3, int par4) { - return ModjamMod.mysteryMushroom.itemID; - } - - public int idDropped(int par1, Random par2Random, int par3) { - return ModjamMod.mysteryMushroom.itemID; - } - - @Override - public int getRenderBlockPass() { - return 1; - } - - //public int getRenderType() {return ClientProxy.mushroomRendererID;} -} diff --git a/fyresmodjam/blocks/BlockPillar.java b/fyresmodjam/blocks/BlockPillar.java deleted file mode 100644 index 4f0016a..0000000 --- a/fyresmodjam/blocks/BlockPillar.java +++ /dev/null @@ -1,220 +0,0 @@ -package fyresmodjam.blocks; - -import java.util.Random; - - -import net.minecraft.block.Block; -import net.minecraft.block.BlockContainer; -import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.monster.EntityMob; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import cpw.mods.fml.common.network.PacketDispatcher; -import cpw.mods.fml.common.network.Player; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import fyresmodjam.ModjamMod; -import fyresmodjam.handlers.PacketHandler; -import fyresmodjam.misc.EntityStatHelper; -import fyresmodjam.tileentities.TileEntityPillar; -import fyresmodjam.worldgen.WorldGenTrapsTowersAndMore; - -public class BlockPillar extends BlockContainer -{ - public BlockPillar(int par1) { - super(par1, Material.rock); - this.setLightOpacity(0); - //this.setTickRandomly(true); - //this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 2.0F, 1.0F); - } - - @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) { - this.blockIcon = par1IconRegister.registerIcon("fyresmodjam:pillar"); - } - - public int idDropped(int par1, Random par2Random, int par3) { - return 0; - } - - public int getDamageValue(World par1World, int par2, int par3, int par4) { - int damage = 0; - - if(ModjamMod.showAllPillarsInCreative) { - int meta = par1World.getBlockMetadata(par2, par3, par4); - TileEntity te = par1World.getBlockTileEntity(par2, par3 - (meta == 1 ? 1 : 0), par4); - - if(te != null && te instanceof TileEntityPillar) { - for(int i = 0; i < TileEntityPillar.validBlessings.length; i++) { - if(TileEntityPillar.validBlessings[i].equals(((TileEntityPillar) te).blessing)) {damage = i + 1; break;} - } - } - } - - return damage; - } - - public int idPicked(World par1World, int par2, int par3, int par4) { - return ModjamMod.itemPillar.itemID; - } - - public boolean canHarvestBlock(EntityPlayer par1EntityPlayer, int par2) { - return false; - } - - public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { - if(par1World.getBlockMetadata(par2, par3, par4) % 2 == 1) {par3--;} - - TileEntity te = par1World.getBlockTileEntity(par2, par3, par4); - - if(par5EntityPlayer.getHeldItem() == null || par5EntityPlayer.getHeldItem().getItem() == null || par5EntityPlayer.getHeldItem().getItemDamage() != 1 || par5EntityPlayer.getHeldItem().getItem().itemID != ModjamMod.sceptre.itemID) { - if(te != null && te instanceof TileEntityPillar && (!par5EntityPlayer.getEntityData().hasKey("Blessing") || !par5EntityPlayer.getEntityData().getString("Blessing").equals(((TileEntityPillar) te).blessing))) { - - boolean skip = false; - - for(int i = 0; i < par1World.loadedEntityList.size(); i++) { - Entity e = (Entity) par1World.loadedEntityList.get(i); - - if(e instanceof EntityMob) { - double xDiff = par2 - e.posX; - double yDiff = par3 - e.posY; - double zDiff = par4 - e.posZ; - - if(Math.abs(yDiff) > 4) {continue;} - - double dist = Math.sqrt(xDiff * xDiff + yDiff * yDiff + zDiff * zDiff); - - if(dist <= 14) {skip = true;} - } - } - - if(!skip) { - if(((TileEntityPillar) te).blessing != null) { - EntityStatHelper.giveStat(par5EntityPlayer, "Blessing", ((TileEntityPillar) te).blessing); - EntityStatHelper.giveStat(par5EntityPlayer, "BlessingActive", false); - EntityStatHelper.giveStat(par5EntityPlayer, "BlessingCounter", 0); - EntityStatHelper.giveStat(par5EntityPlayer, "BlessingCooldown", 0); - - if(par1World.isRemote) { - //Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage("Activated blessing of the " + ((TileEntityPillar) te).blessing + "."); - } else { - par1World.playSoundAtEntity(par5EntityPlayer, "fyresmodjam:pillarActivated", 1.0F, 1.0F); - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"Activated blessing of the " + ((TileEntityPillar) te).blessing + "."}), (Player) par5EntityPlayer); - } - } - } else { - if(!par1World.isRemote) { - //Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage("\u00A7cCannot activate pillar with monsters nearby!"); - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7cCannot activate pillar with monsters nearby!"}), (Player) par5EntityPlayer); - } - } - } - } else if(!par1World.isRemote) { - int damage = 0; - - if(te != null && te instanceof TileEntityPillar) { - for(int i = 0; i < TileEntityPillar.validBlessings.length; i++) { - if(TileEntityPillar.validBlessings[i].equals(((TileEntityPillar) te).blessing)) {damage = i + 1; break;} - } - } - - if(!par5EntityPlayer.capabilities.isCreativeMode) {par5EntityPlayer.getHeldItem().stackSize--;} - par1World.spawnEntityInWorld(new EntityItem(par1World, par2 + 0.5F, par3 + 0.5F, par4 + 0.5F, new ItemStack(ModjamMod.itemPillar, 1, damage))); - par1World.setBlockToAir(par2, par3, par4); - - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7e\u00A7oThe pillar deconstructs before you."}), (Player) par5EntityPlayer); - } - - return true; - } - - public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) { - super.onNeighborBlockChange(par1World, par2, par3, par4, par5); - - if (!par1World.isRemote && !WorldGenTrapsTowersAndMore.genning) { - int i1 = par1World.getBlockMetadata(par2, par3, par4); - - if (i1 % 2 == 0) { - if (par1World.isAirBlock(par2, par3 + 1, par4) || par1World.getBlockId(par2, par3 + 1, par4) != par1World.getBlockId(par2, par3, par4)) { - //this.dropBlockAsItem(par1World, par2, par3, par4, i1, 0); - par1World.setBlockToAir(par2, par3, par4); - } - } else { - if (par1World.isAirBlock(par2, par3 - 1, par4) || par1World.getBlockId(par2, par3 - 1, par4) != par1World.getBlockId(par2, par3, par4)) { - par1World.setBlockToAir(par2, par3, par4); - } - } - } - } - - @Override - public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4) { - return par3 >= 255 ? false : (super.canPlaceBlockAt(par1World, par2, par3, par4) && super.canPlaceBlockAt(par1World, par2, par3 + 1, par4)); - } - - public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) { - int l = par1IBlockAccess.getBlockMetadata(par2, par3, par4); - - if (l % 2 == 0) { - this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 2.0F, 1.0F); - } else { - this.setBlockBounds(0.0F, -1.0F, 0.0F, 1.0F, 1.0F, 1.0F); - } - } - - @SideOnly(Side.CLIENT) - public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) { - return false; - } - - public boolean isOpaqueCube() { - return false; - } - - public boolean hasTileEntity(int metadata) { - return metadata % 2 == 0; - } - - @Override - public TileEntity createNewTileEntity(World world) { - return new TileEntityPillar(); - } - - public int getMobilityFlag() { - return 2; - } - - public void onBlockHarvested(World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer) { - if (par6EntityPlayer.capabilities.isCreativeMode && par5 >= 2 && par1World.getBlockId(par2, par3 - 1, par4) == this.blockID) { - par1World.setBlockToAir(par2, par3 - 1, par4); - } else { - super.onBlockHarvested(par1World, par2, par3, par4, par5, par6EntityPlayer); - } - } - - @SideOnly(Side.CLIENT) - public int getLightValue(IBlockAccess world, int x, int y, int z) { - Block block = blocksList[world.getBlockId(x, y, z)]; - TileEntity te = world.getBlockTileEntity(x, y, z); - - if(block != null && block != this) { - return block.getLightValue(world, x, y, z); - } - - if(ModjamMod.pillarGlow && net.minecraft.client.Minecraft.getMinecraft().theWorld != null && net.minecraft.client.Minecraft.getMinecraft().theWorld.isRemote) { - EntityPlayer player = net.minecraft.client.Minecraft.getMinecraft().thePlayer; - - if(player != null && te != null && te instanceof TileEntityPillar && ((TileEntityPillar) te).blessing != null && ((TileEntityPillar) te).blessing.equals(player.getEntityData().getString("Blessing"))) { - return 4; - } - } - - return 0; - } -} diff --git a/fyresmodjam/blocks/BlockTrap.java b/fyresmodjam/blocks/BlockTrap.java deleted file mode 100644 index d2eb982..0000000 --- a/fyresmodjam/blocks/BlockTrap.java +++ /dev/null @@ -1,277 +0,0 @@ -package fyresmodjam.blocks; - -import static net.minecraftforge.common.ForgeDirection.SOUTH; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - - -import net.minecraft.block.Block; -import net.minecraft.block.BlockContainer; -import net.minecraft.block.material.Material; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.client.renderer.tileentity.TileEntityRenderer; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.monster.EntityMob; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; -import net.minecraft.server.MinecraftServer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.DamageSource; -import net.minecraft.util.Icon; -import net.minecraft.util.MovingObjectPosition; -import net.minecraft.util.Vec3; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import net.minecraft.world.WorldServer; -import net.minecraftforge.common.ForgeDirection; -import net.minecraftforge.common.ForgeHooks; -import net.minecraftforge.common.IShearable; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.network.PacketDispatcher; -import cpw.mods.fml.common.network.Player; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import fyresmodjam.ModjamMod; -import fyresmodjam.handlers.CommonTickHandler; -import fyresmodjam.handlers.PacketHandler; -import fyresmodjam.items.ItemTrap; -import fyresmodjam.tileentities.TileEntityTrap; - -public class BlockTrap extends BlockContainer implements IShearable { - - public static int trapTypes = 3; - - public BlockTrap(int par1) { - super(par1, Material.circuits); - this.setLightOpacity(0); - } - - @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) { - this.blockIcon = par1IconRegister.registerIcon("fyresmodjam:spikes2"); - } - - public int idDropped(int par1, Random par2Random, int par3) { - return 0; - } - - public int idPicked(World par1World, int par2, int par3, int par4) { - return ModjamMod.blockTrap.blockID; - } - - public boolean canHarvestBlock(EntityPlayer par1EntityPlayer, int par2) { - return false; - } - - public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { - if(par5EntityPlayer.getHeldItem() == null) { - TileEntity te = par1World.getBlockTileEntity(par2, par3, par4); - - if(!par5EntityPlayer.isSneaking() && te != null && te instanceof TileEntityTrap && ((TileEntityTrap) te).placedBy != null && ((TileEntityTrap) te).placedBy.equals(par5EntityPlayer.getEntityName())) { - if(!par1World.isRemote) { - ((TileEntityTrap) te).setting++; if(((TileEntityTrap) te).setting >= TileEntityTrap.settings.length) {((TileEntityTrap) te).setting = 0;} - PacketDispatcher.sendPacketToAllPlayers(te.getDescriptionPacket()); - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7e\u00A7oSet to: " + TileEntityTrap.settings[((TileEntityTrap) te).setting] + "."}), (Player) par5EntityPlayer); - } - } else { - if(par1World.isRemote) { - PacketDispatcher.sendPacketToServer(PacketHandler.newPacket(PacketHandler.DISARM_TRAP, new Object[] {par2, par3, par4, par5EntityPlayer.getEntityData().hasKey("Blessing") && par5EntityPlayer.getEntityData().getString("Blessing").equals("Mechanic")})); - } - } - } - - return true; - } - - @SideOnly(Side.CLIENT) - public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) { - return false; - } - - public boolean isOpaqueCube() { - return false; - } - - public boolean hasTileEntity(int metadata) { - return true; - } - - @Override - public TileEntity createNewTileEntity(World world) { - return new TileEntityTrap(); - } - - public int getMobilityFlag() { - return 2; - } - - public void addCollisionBoxesToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity) {} - - /*@SideOnly(Side.CLIENT) - public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) { - EntityPlayer player = Minecraft.getMinecraft().thePlayer; - TileEntity te = par1World.getBlockTileEntity(par2, par3, par4); - return (player != null && te instanceof TileEntityTrap && player.getEntityName().equals(((TileEntityTrap) te).placedBy)) ? super.getCollisionBoundingBoxFromPool(par1World, par2, par3, par4) : null; - }*/ - - public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) { - return super.getCollisionBoundingBoxFromPool(par1World, par2, par3, par4); - } - - @SideOnly(Side.CLIENT) - public MovingObjectPosition collisionRayTrace(World par1World, int par2, int par3, int par4, Vec3 par5Vec3, Vec3 par6Vec3) { - EntityPlayer player = Minecraft.getMinecraft().thePlayer; - TileEntity te = par1World.getBlockTileEntity(par2, par3, par4); - return (player != null && te instanceof TileEntityTrap && (((TileEntityTrap) te).placedBy != null || !PacketHandler.trapsDisabled) && (player.getEntityName().equals(((TileEntityTrap) te).placedBy) || player.isSneaking() || (player.getEntityData().hasKey("Blessing") && player.getEntityData().getString("Blessing").equals("Scout")))) ? super.collisionRayTrace(par1World, par2, par3, par4, par5Vec3, par6Vec3) : null; - } - - public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity) { - TileEntity te = par1World.getBlockTileEntity(par2, par3, par4); - - boolean b1 = (((TileEntityTrap) te).placedBy == null || !par5Entity.getEntityName().equals(((TileEntityTrap) te).placedBy)); - boolean b2 = ((TileEntityTrap) te).setting != 3 && (!(par5Entity instanceof EntityPlayer) || ((TileEntityTrap) te).setting < 2); - boolean b3 = (ModjamMod.spawnTraps || ((TileEntityTrap) te).placedBy != null); - boolean b4 = ((par5Entity instanceof EntityPlayer && !((EntityPlayer) par5Entity).capabilities.isCreativeMode) || par5Entity instanceof EntityMob); - - //System.out.println(b1 + ", " + b2 + ", " + b3 + ", " + b4 + ", " + ((TileEntityTrap) te).setting); - - if(!par1World.isRemote && par5Entity.ridingEntity == null && te != null && te instanceof TileEntityTrap && b1 && b2 && b3 && b4) { - - int type = par1World.getBlockMetadata(par2, par3, par4); - - String blessing = null; - if(par5Entity.getEntityData().hasKey("Blessing")) {blessing = par5Entity.getEntityData().getString("Blessing");} - boolean scout = blessing != null && blessing.equals("Scout"); - - if(par5Entity instanceof EntityPlayer) { - if(type % trapTypes == 0) { - par5Entity.attackEntityFrom(DamageSource.cactus, 8.0F + (scout ? 2.0F : 0.0F)); - if(ModjamMod.r.nextInt(8 - (scout ? 2 : 0)) == 0) {((EntityLivingBase) par5Entity).addPotionEffect(new PotionEffect(Potion.poison.id, 100 + (scout ? 25 : 0), 1));} - } else if(type % trapTypes == 1) { - if(!par5Entity.isBurning()) {par5Entity.setFire(10 + (scout ? 2 : 0));} - } else if(type % trapTypes == 2) { - ((EntityLivingBase) par5Entity).addPotionEffect(new PotionEffect(Potion.blindness.id, 200 + (scout ? 50 : 0), 1)); - ((EntityLivingBase) par5Entity).addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 200 + (scout ? 50 : 0), 1)); - } - - if(CommonTickHandler.worldData.getDisadvantage().equals("Explosive Traps")) {par5Entity.worldObj.setBlockToAir(par2, par3, par4); par5Entity.worldObj.createExplosion(null, par2 + 0.5F, par3 + 0.5F, par4 + 0.5F, 1.33F, true);} - - par1World.setBlockToAir(par2, par3, par4); - - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7c\u00A7oYou triggered a " + ItemTrap.names[type % trapTypes].toLowerCase() + "!"}), (Player) par5Entity); - } else { - if(type % trapTypes == 0) { - par5Entity.attackEntityFrom(DamageSource.cactus, 2.0F); - if(ModjamMod.r.nextInt(32) == 0) {((EntityLivingBase) par5Entity).addPotionEffect(new PotionEffect(Potion.poison.id, 100, 1));} - } else if(type % trapTypes == 1) { - if(!par5Entity.isBurning()) {par5Entity.setFire(5);} - } else if(type % trapTypes == 2) { - ((EntityLivingBase) par5Entity).addPotionEffect(new PotionEffect(Potion.blindness.id, 100, 1)); - ((EntityLivingBase) par5Entity).addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 100, 1)); - } - } - - } - } - - public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) { - super.onNeighborBlockChange(par1World, par2, par3, par4, par5); - - if(!par1World.isRemote && !par1World.isBlockSolidOnSide(par2, par3 - 1, par4, ForgeDirection.SOUTH, true)) { - par1World.setBlockToAir(par2, par3, par4); - TileEntity te = par1World.getBlockTileEntity(par2, par3, par4); - if((ModjamMod.spawnTraps || (te != null && te instanceof TileEntityTrap && ((TileEntityTrap) te).placedBy != null)) && CommonTickHandler.worldData != null && CommonTickHandler.worldData.getDisadvantage().equals("Explosive Traps")) {par1World.createExplosion(null, par2 + 0.5F, par3 + 0.5F, par4 + 0.5F, 1.33F, true);} - } - } - - @Override - public boolean isBlockReplaceable(World world, int x, int y, int z) { - TileEntity te = world.getBlockTileEntity(x, y, z); - return super.isBlockReplaceable(world, x, y, z) || ((world.isRemote ? PacketHandler.trapsDisabled : !ModjamMod.spawnTraps) && (te == null || !(te instanceof TileEntityTrap) || ((TileEntityTrap) te).placedBy == null)); - } - - @SideOnly(Side.CLIENT) - public boolean isCollidable() {return super.isCollidable();}//!PacketHandler.trapsDisabled;} //&& getPlayerSneaking();} - - @Override - public boolean canPlaceBlockAt(World world, int x, int y, int z) { - return super.canPlaceBlockAt(world, x, y, z) && (y == 0 || world.getBlockId(x, y - 1, z) != ModjamMod.blockTrap.blockID); - } - - /*@SideOnly(Side.CLIENT) - public boolean getPlayerSneaking() { - EntityPlayer player = Minecraft.getMinecraft().thePlayer; - return (player == null ? false : (player.isSneaking() || (player.getEntityData().hasKey("Blessing") && player.getEntityData().getString("Blessing").equals("Scout")))); - }*/ - - public int damageDropped(int par1) { - return par1 % trapTypes; - } - - @SideOnly(Side.CLIENT) - public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List) { - for(int i = 0; i < trapTypes; i++) {par3List.add(new ItemStack(par1, 1, i));} - } - - public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { - super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack); - - par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage(), 0); - - if(par5EntityLivingBase != null && par5EntityLivingBase instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) par5EntityLivingBase; - - if(!player.capabilities.isCreativeMode || PacketHandler.trapsDisabled) { - TileEntity te = par1World.getBlockTileEntity(par2, par3, par4); - if(te != null && te instanceof TileEntityTrap) {((TileEntityTrap) te).placedBy = player.getEntityName();} - } - } - } - - @Override - public boolean isShearable(ItemStack item, World world, int x, int y, int z) {return true;} - - @Override - public ArrayList onSheared(ItemStack item, World world, int x, int y, int z, int fortune) { - world.setBlockToAir(x, y, z); - - if(!world.isRemote) { - MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); - - for(int i = 0; i < server.worldServers.length; i++) { - WorldServer s = FMLCommonHandler.instance().getMinecraftServerInstance().worldServers[i]; - - if(s == null) {continue;} - - for(Object o : s.playerEntities) { - if(o == null || !(o instanceof EntityPlayer)) {continue;} - - EntityPlayer player = (EntityPlayer) o; - - if(item.equals(player.getHeldItem())) { - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7e\u00A7oYou disarmed the trap."}), (Player) player); - } - } - } - } - - item.attemptDamageItem(119, ModjamMod.r); - - return new ArrayList(); - } - - - @Override - public float getPlayerRelativeBlockHardness(EntityPlayer par1EntityPlayer, World par2World, int par3, int par4, int par5) { - return (par1EntityPlayer.getHeldItem() != null && par1EntityPlayer.getHeldItem().getItem().itemID == Item.shears.itemID) ? 1.0F : this.getBlockHardness(par2World, par3, par4, par5); - } -} diff --git a/fyresmodjam/commands/CommandWeaponStats.java b/fyresmodjam/commands/CommandWeaponStats.java deleted file mode 100644 index 0c00061..0000000 --- a/fyresmodjam/commands/CommandWeaponStats.java +++ /dev/null @@ -1,97 +0,0 @@ -package fyresmodjam.commands; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - - -import cpw.mods.fml.common.network.PacketDispatcher; -import cpw.mods.fml.common.network.Player; -import fyresmodjam.ModjamMod; -import fyresmodjam.handlers.PacketHandler; -import fyresmodjam.misc.EntityStatHelper; - -import net.minecraft.command.ICommand; -import net.minecraft.command.ICommandSender; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.nbt.NBTBase; -import net.minecraft.nbt.NBTTagCompound; - -public class CommandWeaponStats implements ICommand { - - public int compareTo(Object arg0) {return 0;} - - public String getCommandName() {return "weaponKnowledge";} - - public String getCommandUsage(ICommandSender icommandsender) {return "commands.weaponKnowledge.usage";} - - public List getCommandAliases() {return null;} - - public void processCommand(ICommandSender icommandsender, String[] astring) { - int page = astring.length > 0 ? Integer.parseInt(astring[0]) - 1 : 0, maxPage = 0; - if(icommandsender instanceof EntityPlayer) { - EntityPlayer entityplayer = (EntityPlayer) icommandsender; - - String message = "\u00A7c\u00A7oWeapon kill stats not enabled."; - - if(ModjamMod.enableWeaponKillStats) { - message = "@Weapon Knowledge:"; //\u00A7e\u00A7o - - if(entityplayer.getEntityData().hasKey("WeaponStats")) { - NBTTagCompound killStats = entityplayer.getEntityData().getCompoundTag("WeaponStats"); - - ArrayList objects = new ArrayList(); - objects.addAll(killStats.getTags()); - - Collections.sort(objects, new Comparator() { - public int compare(Object o1, Object o2) { - int i = 0; - if(o1 instanceof NBTBase && o2 instanceof NBTBase) {i = ((NBTBase) o1).getName().replace("Kills", "").compareTo(((NBTBase) o2).getName().replace("Kills", ""));} - return i; - } - }); - - maxPage = Math.max(0, (killStats.getTags().size())/4); - if(page > maxPage) {page = maxPage;} - if(page < 0) {page = 0;} - - message = "@Weapon Knowledge (page " + (page + 1) + "/" + (maxPage + 1) + "):"; - - int count = 0, skip = 0; - for(Object o : objects) { - if(skip < page * 4) {skip++; continue;} - if(o instanceof NBTBase) { - String mob = ((NBTBase) o).getName().replace("Kills", ""); - int kills = killStats.getInteger(((NBTBase) o).getName()); - - int last = 0; - for(int i = 0; i < EntityStatHelper.killCount.length; i++) { - if(kills >= EntityStatHelper.killCount[i] * 2) {last = i; continue;} else {break;} - } - - message += "@\u00A7b " + EntityStatHelper.knowledge[last] + " " + mob.toLowerCase() + " user\u00A73 " + (last > 0 ? "+" + EntityStatHelper.damageBonusString[last] + "% damage bonus (" : "(") + kills + " kill(s)" + (last < EntityStatHelper.knowledge.length - 1 ? ", " + (EntityStatHelper.killCount[last + 1] * 2 - kills + " kill(s) to next rank)") : ")"); - count++; - - if(count >= 4) {break;} - } - } - } else { - message += "@ You've yet to learn anything."; - } - } - - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {message}), (Player) entityplayer); - } - } - - public boolean canCommandSenderUseCommand(ICommandSender icommandsender) {return true;} - - public List addTabCompletionOptions(ICommandSender icommandsender, String[] astring) {return null;} - - public boolean isUsernameIndex(String[] astring, int i) {return false;} - - public int getRequiredPermissionLevel() {return 0;} - -} diff --git a/fyresmodjam/entities/EntityMysteryPotion.java b/fyresmodjam/entities/EntityMysteryPotion.java deleted file mode 100644 index 1200887..0000000 --- a/fyresmodjam/entities/EntityMysteryPotion.java +++ /dev/null @@ -1,178 +0,0 @@ -package fyresmodjam.entities; - -import cpw.mods.fml.common.network.PacketDispatcher; -import cpw.mods.fml.common.network.Player; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import java.util.Iterator; -import java.util.List; - -import fyresmodjam.ModjamMod; -import fyresmodjam.handlers.CommonTickHandler; -import fyresmodjam.handlers.PacketHandler; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.projectile.EntityThrowable; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.MovingObjectPosition; -import net.minecraft.util.StatCollector; -import net.minecraft.world.World; - -public class EntityMysteryPotion extends EntityThrowable { - - public EntityMysteryPotion(World par1World) - { - super(par1World); - } - - public EntityMysteryPotion(World par1World, EntityLivingBase par2EntityLivingBase, int par3) - { - this(par1World, par2EntityLivingBase, null); - } - - public EntityMysteryPotion(World par1World, EntityLivingBase par2EntityLivingBase, ItemStack par4ItemStack) - { - super(par1World, par2EntityLivingBase); - - if(par4ItemStack != null) { - int damage = par4ItemStack.getItemDamage(); - this.dataWatcher.updateObject(24, damage); - if(damage % 13 < 12) {this.dataWatcher.updateObject(25, CommonTickHandler.worldData.potionDurations[damage % 13]);} - } - } - - public void entityInit() { - super.entityInit(); - - this.dataWatcher.addObject(24, 0); - this.dataWatcher.addObject(25, 0); - } - - @SideOnly(Side.CLIENT) - public EntityMysteryPotion(World par1World, double par2, double par4, double par6, int par8) - { - this(par1World, par2, par4, par6, new ItemStack(Item.potion, 1, par8)); - } - - public EntityMysteryPotion(World par1World, double par2, double par4, double par6, ItemStack par4ItemStack) - { - super(par1World, par2, par4, par6); - - if(par4ItemStack != null) { - int damage = par4ItemStack.getItemDamage(); - this.dataWatcher.updateObject(24, damage); - this.dataWatcher.updateObject(25, CommonTickHandler.worldData.potionDurations[damage % 13]); - } - } - - /** - * Gets the amount of gravity to apply to the thrown entity with each tick. - */ - protected float getGravityVelocity() - { - return 0.05F; - } - - protected float func_70182_d() - { - return 0.5F; - } - - protected float func_70183_g() - { - return -20.0F; - } - - /** - * Called when this EntityThrowable hits a block or entity. - */ - protected void onImpact(MovingObjectPosition par1MovingObjectPosition) - { - if (!this.worldObj.isRemote) { - AxisAlignedBB axisalignedbb = this.boundingBox.expand(4.0D, 2.0D, 4.0D); - List list1 = this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb); - - if(list1 != null && !list1.isEmpty()) { - int type = getDataWatcher().getWatchableObjectInt(24) % 13; - int j = type >= 12 ? (5 + ModjamMod.r.nextInt(26)) : getDataWatcher().getWatchableObjectInt(25); - - int damage = 0; - - if(type >= 12 || (getThrower().getEntityData().hasKey("Blessing") && getThrower().getEntityData().getString("Blessing").equals("Alchemist"))) { - damage = ModjamMod.r.nextInt(Potion.potionTypes.length); - while(Potion.potionTypes[damage] == null) {damage = ModjamMod.r.nextInt(Potion.potionTypes.length);} - } else { - damage = CommonTickHandler.worldData.potionValues[type]; - } - - Iterator iterator = list1.iterator(); - - while(iterator.hasNext()) { - EntityLivingBase entitylivingbase = (EntityLivingBase)iterator.next(); - double d0 = this.getDistanceSqToEntity(entitylivingbase); - - if(d0 < 16.0D) { - if(Potion.potionTypes[damage].isInstant()) { - Potion.potionTypes[damage].affectEntity(getThrower(), entitylivingbase, 1, 1); - } else { - entitylivingbase.addPotionEffect(new PotionEffect(damage, j * 20, 1, false)); - } - } - } - - if(getThrower() instanceof EntityPlayer) { - EntityPlayer par3EntityPlayer = (EntityPlayer) getThrower(); - - if(type < 12 && (!getThrower().getEntityData().hasKey("Blessing") || !getThrower().getEntityData().getString("Blessing").equals("Alchemist"))) { - if(!par3EntityPlayer.getEntityData().hasKey("PotionKnowledge")) {par3EntityPlayer.getEntityData().setIntArray("PotionKnowledge", new int[] {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1});} - - if(par3EntityPlayer.getEntityData().getIntArray("PotionKnowledge")[type] == -1) { - par3EntityPlayer.getEntityData().getIntArray("PotionKnowledge")[type] = 1; - - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.UPDATE_POTION_KNOWLEDGE, new Object[] {par3EntityPlayer.getEntityData().getIntArray("PotionKnowledge")}), (Player) par3EntityPlayer); - - Potion potion = Potion.potionTypes[CommonTickHandler.worldData.potionValues[type]]; - String name = StatCollector.translateToLocal(potion.getName()) + " Potion"; - - if(!potion.isInstant()) { - int time = CommonTickHandler.worldData.potionDurations[type]; - name += " (" + time + " seconds)"; - } - - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7oYou learnt Mystery Potion #" + (type + 1) + " was a " + name + "!"}), (Player) par3EntityPlayer); - } - } else { - Potion potion = Potion.potionTypes[damage]; - String name = StatCollector.translateToLocal(potion.getName()) + " Potion"; - if(!potion.isInstant()) {name += " (" + j + " seconds)";} - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7oYou threw a " + name + "."}), (Player) par3EntityPlayer); - } - } - } - - this.worldObj.playAuxSFX(2002, (int)Math.round(this.posX), (int)Math.round(this.posY), (int)Math.round(this.posZ), 1); - this.setDead(); - } - } - - /** - * (abstract) Protected helper method to read subclass entity data from NBT. - */ - public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) - { - super.readEntityFromNBT(par1NBTTagCompound); - } - - /** - * (abstract) Protected helper method to write subclass entity data to NBT. - */ - public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) - { - super.writeEntityToNBT(par1NBTTagCompound); - } -} diff --git a/fyresmodjam/entities/renderers/RenderMysteryPotion.java b/fyresmodjam/entities/renderers/RenderMysteryPotion.java deleted file mode 100644 index 444e2f1..0000000 --- a/fyresmodjam/entities/renderers/RenderMysteryPotion.java +++ /dev/null @@ -1,91 +0,0 @@ -package fyresmodjam.entities.renderers; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.entity.Render; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.entity.Entity; -import net.minecraft.entity.projectile.EntityPotion; -import net.minecraft.item.Item; -import net.minecraft.item.ItemPotion; -import net.minecraft.potion.PotionHelper; -import net.minecraft.util.Icon; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL12; - -import fyresmodjam.entities.EntityMysteryPotion; - -@SideOnly(Side.CLIENT) -public class RenderMysteryPotion extends Render -{ - private Item field_94151_a; - - public RenderMysteryPotion(Item par1Item) { - this.field_94151_a = par1Item; - } - - /** - * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then - * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic - * (Render> 16 & 255) / 255.0F; - float f3 = (float)(i >> 8 & 255) / 255.0F; - float f4 = (float)(i & 255) / 255.0F; - GL11.glColor3f(f2, f3, f4); - GL11.glPushMatrix(); - this.func_77026_a(tessellator, ItemPotion.func_94589_d("overlay")); - GL11.glPopMatrix(); - GL11.glColor3f(1.0F, 1.0F, 1.0F); - } - - this.func_77026_a(tessellator, icon); - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - GL11.glPopMatrix(); - } - } - - protected ResourceLocation getEntityTexture(Entity par1Entity) - { - return TextureMap.locationItemsTexture; - } - - private void func_77026_a(Tessellator par1Tessellator, Icon par2Icon) - { - float f = par2Icon.getMinU(); - float f1 = par2Icon.getMaxU(); - float f2 = par2Icon.getMinV(); - float f3 = par2Icon.getMaxV(); - float f4 = 1.0F; - float f5 = 0.5F; - float f6 = 0.25F; - GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F); - par1Tessellator.startDrawingQuads(); - par1Tessellator.setNormal(0.0F, 1.0F, 0.0F); - par1Tessellator.addVertexWithUV((double)(0.0F - f5), (double)(0.0F - f6), 0.0D, (double)f, (double)f3); - par1Tessellator.addVertexWithUV((double)(f4 - f5), (double)(0.0F - f6), 0.0D, (double)f1, (double)f3); - par1Tessellator.addVertexWithUV((double)(f4 - f5), (double)(f4 - f6), 0.0D, (double)f1, (double)f2); - par1Tessellator.addVertexWithUV((double)(0.0F - f5), (double)(f4 - f6), 0.0D, (double)f, (double)f2); - par1Tessellator.draw(); - } -} diff --git a/fyresmodjam/handlers/ClientTickHandler.java b/fyresmodjam/handlers/ClientTickHandler.java deleted file mode 100644 index cc161c7..0000000 --- a/fyresmodjam/handlers/ClientTickHandler.java +++ /dev/null @@ -1,128 +0,0 @@ -package fyresmodjam.handlers; - -import java.awt.Color; -import java.io.File; -import java.util.EnumSet; - -import org.lwjgl.input.Keyboard; - - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumMovingObjectType; -import net.minecraft.util.MovingObjectPosition; -import net.minecraftforge.common.Configuration; - -import cpw.mods.fml.client.FMLClientHandler; -import cpw.mods.fml.common.ITickHandler; -import cpw.mods.fml.common.TickType; -import cpw.mods.fml.common.network.PacketDispatcher; -import fyresmodjam.ModjamMod; - -public class ClientTickHandler implements ITickHandler { - - @Override - public void tickStart(EnumSet type, Object... tickData) { - - } - - @Override - public void tickEnd(EnumSet type, Object... tickData) { - if (type.equals(EnumSet.of(TickType.CLIENT))) { - GuiScreen guiscreen = Minecraft.getMinecraft().currentScreen; - - if (guiscreen != null) { - onTickInGUI(guiscreen); - } else { - onTickInGame(); - } - - onClientTick(); - } else if (type.equals(EnumSet.of(TickType.RENDER))) {onRenderTick();} - } - - private void onRenderTick() { - /*MovingObjectPosition mouse = Minecraft.getMinecraft().objectMouseOver; - - if(mouse != null && Minecraft.getMinecraft().inGameHasFocus && Minecraft.getMinecraft().isGuiEnabled() && Minecraft.getMinecraft().theWorld != null && mouse.typeOfHit == EnumMovingObjectType.TILE && Minecraft.getMinecraft().theWorld.getBlockId(mouse.blockX, mouse.blockY, mouse.blockZ) == ModjamMod.blockPillar.blockID) { - ScaledResolution scaledRes = new ScaledResolution(Minecraft.getMinecraft().gameSettings, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight); - int screenWidth = scaledRes.getScaledWidth(); - int screenHeight = scaledRes.getScaledHeight(); - - String key = Keyboard.getKeyName(FyresKeyHandler.examine.keyCode); - - String string = "Press " + key + " to Examine"; - Minecraft.getMinecraft().fontRenderer.drawStringWithShadow(string, (screenWidth / 2) - (Minecraft.getMinecraft().fontRenderer.getStringWidth(string) / 2), screenHeight / 2 + 16, Color.WHITE.getRGB()); - }*/ - } - - private void onClientTick() { - EntityPlayer player = Minecraft.getMinecraft().thePlayer; - - if(player != null) { - if(player.openContainer != null) { - boolean sendPacket = false; - - for(Object object : player.inventory.mainInventory) { - if(object == null || !(object instanceof ItemStack)) {continue;} - - ItemStack stack = (ItemStack) object; - if(stack.getTagCompound() == null || !stack.getTagCompound().hasKey("processed") || stack.getTagCompound().getString("processed").equals("false")) { - sendPacket = true; - } - } - - if(sendPacket) {PacketDispatcher.sendPacketToServer(PacketHandler.newPacket(PacketHandler.UPDATE_PLAYER_ITEMS));} - } - - /*for(Object o : player.worldObj.loadedEntityList) { - if(o == null) {continue;} - - if(EntityStatHelper.hasStat((Entity) o, "Blessing") && EntityStatHelper.hasStat((Entity) o, "BlessingActive")) { - Entity entity = (Entity) o; - - if(EntityStatHelper.getStat(entity, "Blessing").equals("Berserker") && EntityStatHelper.getStat(entity, "BlessingActive").equals("true")) { - for(int i = 0; i < 2; i++) {player.worldObj.spawnParticle("reddust", player.posX - 0.5D + ModjamMod.r.nextDouble(), player.posY - player.height + ModjamMod.r.nextDouble() * player.height, player.posZ - 0.5D + ModjamMod.r.nextDouble(), 0.0D, 0.0D, 0.0D);} - } - } - }*/ - - player.triggerAchievement(ModjamMod.startTheGame); - } - - if(FyresKeyHandler.examine.keyCode != ModjamMod.examineKey || FyresKeyHandler.activateBlessing.keyCode != ModjamMod.blessingKey) { - ModjamMod.examineKey = FyresKeyHandler.examine.keyCode; - ModjamMod.blessingKey = FyresKeyHandler.activateBlessing.keyCode; - - Configuration config = new Configuration(new File(ModjamMod.configPath)); - config.load(); - config.get("Keybindings", "examine_key", ModjamMod.examineKey).set(ModjamMod.examineKey); - config.get("Keybindings", "blessing_key", ModjamMod.blessingKey).set(ModjamMod.blessingKey); - config.save(); - } - } - - private void onTickInGame() { - - } - - private void onTickInGUI(GuiScreen guiscreen) { - - } - - @Override - public EnumSet ticks() { - return EnumSet.of(TickType.RENDER, TickType.CLIENT); - } - - @Override - public String getLabel() { - return "FyresModJamClientTicker"; - } - -} diff --git a/fyresmodjam/handlers/FyresKeyHandler.java b/fyresmodjam/handlers/FyresKeyHandler.java deleted file mode 100644 index de0a86a..0000000 --- a/fyresmodjam/handlers/FyresKeyHandler.java +++ /dev/null @@ -1,117 +0,0 @@ -package fyresmodjam.handlers; - -import java.util.EnumSet; - -import org.lwjgl.input.Keyboard; - - -import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.client.settings.KeyBinding; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumMovingObjectType; -import net.minecraft.util.MovingObjectPosition; -import net.minecraft.util.StatCollector; -import cpw.mods.fml.client.registry.KeyBindingRegistry.KeyHandler; -import cpw.mods.fml.common.TickType; -import cpw.mods.fml.common.network.PacketDispatcher; -import fyresmodjam.ModjamMod; -import fyresmodjam.blocks.BlockTrap; -import fyresmodjam.items.ItemTrap; -import fyresmodjam.tileentities.TileEntityPillar; -import fyresmodjam.tileentities.TileEntityTrap; - -public class FyresKeyHandler extends KeyHandler { - - public static KeyBinding examine = new KeyBinding("Examine", Keyboard.KEY_X); - public static KeyBinding activateBlessing = new KeyBinding("Activate Blessing", Keyboard.KEY_K); - - public static KeyBinding[] keyBindings = new KeyBinding[] {examine, activateBlessing}; - public static boolean[] repeat = new boolean[] {false, false}; - - public FyresKeyHandler() { - super(keyBindings, repeat); - } - - @Override - public String getLabel() { - return "KeyHandler for FyresModJamMod"; - } - - @Override - public void keyDown(EnumSet types, KeyBinding kb, boolean tickEnd, boolean isRepeat) { - - } - - @Override - public void keyUp(EnumSet types, KeyBinding kb, boolean tickEnd) { - if(tickEnd && Minecraft.getMinecraft().inGameHasFocus) { - Minecraft minecraft = Minecraft.getMinecraft(); - EntityPlayer player = minecraft.thePlayer; - - if(player != null) { - if(kb.equals(examine)) { - if(minecraft.objectMouseOver != null) { - - MovingObjectPosition o = minecraft.objectMouseOver; - - if(o.typeOfHit == EnumMovingObjectType.TILE) { - int x = minecraft.objectMouseOver.blockX; - int y = minecraft.objectMouseOver.blockY; - int z = minecraft.objectMouseOver.blockZ; - - if(minecraft.theWorld.getBlockId(x, y, z) == ModjamMod.blockPillar.blockID && (minecraft.theWorld.getBlockMetadata(x, y, z) % 2) == 1) {y--;} - - TileEntity te = minecraft.theWorld.getBlockTileEntity(x, y, z); - - if(te != null && te instanceof TileEntityPillar) { - int index = 0; - for(int i = 0; i < TileEntityPillar.validBlessings.length; i++) {if(TileEntityPillar.validBlessings[i].equals(((TileEntityPillar) te).blessing)) {index = i; break;}} - - String s = "@\u00A7eBlessing of the " + ((TileEntityPillar) te).blessing + ": " + TileEntityPillar.blessingDescriptions[index] + "."; - - for(String s2 : s.split("@")) { - Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(s2); - } - - } else if(te != null && te instanceof TileEntityTrap) { - String placedBy = ((TileEntityTrap) te).placedBy; - - String s = (placedBy != null ? "\u00A7eThis " + ItemTrap.names[te.getBlockMetadata() % BlockTrap.trapTypes].toLowerCase() + " was placed by " + (placedBy.equals(player.getEntityName()) ? "you": placedBy) + "." : "\u00A7eThis " + ItemTrap.names[te.getBlockMetadata() % BlockTrap.trapTypes].toLowerCase() + " doesn't seem to have been placed by anyone."); - s += " Trap is set to " + TileEntityTrap.settings[((TileEntityTrap) te).setting] + "."; - Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(s); - } else { - ItemStack stack = new ItemStack(minecraft.theWorld.getBlockId(x, y, z), 1, minecraft.theWorld.getBlockMetadata(x, y, z)); - - if(stack.getItem() != null) { - String name = stack.getDisplayName().toLowerCase(); //stack.hasDisplayName() ? stack.getDisplayName().toLowerCase() : stack.getUnlocalizedName(); - Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage("\u00A7eIt's a " + name + (!name.contains("block") ? " block." : ".")); - } - } - } else if(o.typeOfHit == EnumMovingObjectType.ENTITY && o.entityHit != null) { - PacketDispatcher.sendPacketToServer(PacketHandler.newPacket(PacketHandler.EXAMINE_MOB, new Object[] {o.entityHit.dimension, o.entityHit.entityId})); - } - } - } else if(kb.equals(activateBlessing)) { - String blessing = player.getEntityData().getString("Blessing"); - Object[] params = null; - - if(blessing != null && blessing.equals("Mechanic") && minecraft.objectMouseOver != null) { - MovingObjectPosition o = minecraft.objectMouseOver; - if(o.typeOfHit == EnumMovingObjectType.TILE) {params = new Object[] {minecraft.objectMouseOver.blockX, minecraft.objectMouseOver.blockY, minecraft.objectMouseOver.blockZ};} - } - - PacketDispatcher.sendPacketToServer(PacketHandler.newPacket(PacketHandler.ACTIVATE_BLESSING, params)); - } - } - } - } - - @Override - public EnumSet ticks() { - return EnumSet.of(TickType.CLIENT); - } - -} diff --git a/fyresmodjam/handlers/PacketHandler.java b/fyresmodjam/handlers/PacketHandler.java deleted file mode 100644 index 687ed51..0000000 --- a/fyresmodjam/handlers/PacketHandler.java +++ /dev/null @@ -1,317 +0,0 @@ -package fyresmodjam.handlers; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.DataInputStream; -import java.io.DataOutputStream; - - -import net.minecraft.client.Minecraft; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.item.ItemStack; -import net.minecraft.network.INetworkManager; -import net.minecraft.network.packet.Packet; -import net.minecraft.network.packet.Packet250CustomPayload; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; -import net.minecraft.server.MinecraftServer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.DamageSource; -import net.minecraft.world.WorldServer; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.network.IPacketHandler; -import cpw.mods.fml.common.network.PacketDispatcher; -import cpw.mods.fml.common.network.Player; -import cpw.mods.fml.relauncher.Side; -import fyresmodjam.ModjamMod; -import fyresmodjam.blocks.BlockTrap; -import fyresmodjam.misc.EntityStatHelper; -import fyresmodjam.misc.ItemStatHelper; -import fyresmodjam.tileentities.TileEntityTrap; - -public class PacketHandler implements IPacketHandler { - - //Packet types - public static final byte UPDATE_BLESSING = 1, PLAY_SOUND = 2, UPDATE_POTION_KNOWLEDGE = 3, SEND_MESSAGE = 4, UPDATE_WORLD_DATA = 5, UPDATE_PLAYER_ITEMS = 6, DISARM_TRAP = 7, EXAMINE_MOB = 8, LEVEL_UP = 9, ACTIVATE_BLESSING = 10, UPDATE_STATS = 11; - - public static int[] potionValues = null; - public static int[] potionDurations = null; - - public static int[][] mushroomColors = null; - - public static String currentDisadvantage = null; - - public static String currentTask = null; - public static int currentTaskID = -1; - public static int currentTaskAmount = 0; - public static int progress = 0; - public static int tasksCompleted = 0; - public static int rewardLevels = 0; - - public static boolean enderDragonKilled = false; - public static boolean trapsDisabled = false; - - public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player playerEntity) { - Side side = FMLCommonHandler.instance().getEffectiveSide(); - - DataInputStream inputStream = null; - byte type = 0; - - try { - - inputStream = new DataInputStream(new ByteArrayInputStream(packet.data)); - - if(inputStream != null) { - type = inputStream.readByte(); - - if (side == Side.SERVER) { - EntityPlayerMP player = (EntityPlayerMP) playerEntity; - - switch(type) { - case PLAY_SOUND: - - String sound = inputStream.readUTF(); - - int x = inputStream.readInt(); - int y = inputStream.readInt(); - int z = inputStream.readInt(); - - Minecraft.getMinecraft().theWorld.playSound(x, y, z, "fyresmodjam:" + sound, 1.0F, 1.0F, false); - return; - - case UPDATE_PLAYER_ITEMS: - - //if(player.openContainer != null) { - for(Object stack : player.inventory.mainInventory) { - if(stack == null || !(stack instanceof ItemStack)) {continue;} - ItemStatHelper.processItemStack((ItemStack) stack, ModjamMod.r); - } - - //player.openContainer.detectAndSendChanges(); - //((EntityPlayerMP) player).sendContainerAndContentsToPlayer(player.openContainer, player.openContainer.getInventory()); - //} - - return; - - case ACTIVATE_BLESSING: - - String blessing = EntityStatHelper.getStat(player, "Blessing"); - boolean blessingActive = EntityStatHelper.hasStat(player, "BlessingActive") ? Boolean.parseBoolean(EntityStatHelper.getStat(player, "BlessingActive")) : false; - - if(!EntityStatHelper.hasStat(player, "BlessingCooldown")) {EntityStatHelper.giveStat(player, "BlessingCooldown", 0);} - - if(EntityStatHelper.getStat(player, "BlessingCooldown").equals("0") || Integer.parseInt(EntityStatHelper.getStat(player, "BlessingCooldown")) <= player.worldObj.getWorldTime()) { - if(!blessingActive) { - if(blessing != null) { - if(blessing.equals("Berserker")) { - if(EntityStatHelper.hasStat(player, "BlessingCounter") && Integer.parseInt(EntityStatHelper.getStat(player, "BlessingCounter")) > 0) { - blessingActive = true; - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7cYou enter berserk mode."}), (Player) player); - } else { - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7cYou have no berserk counters."}), (Player) player); - } - } else if(blessing.equals("Mechanic")) { - x = inputStream.readInt(); - y = inputStream.readInt(); - z = inputStream.readInt(); - - TileEntity te = player.worldObj.getBlockTileEntity(x, y, z); - - if(te != null && te instanceof TileEntityTrap) { - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7e\u00A7oYou disarm and salvage the trap."}), (Player) player); - player.worldObj.spawnEntityInWorld(new EntityItem(player.worldObj, x + 0.5F, y, z + 0.5F, new ItemStack(ModjamMod.itemTrap.itemID, 1, player.worldObj.getBlockMetadata(x, y, z) % BlockTrap.trapTypes))); - player.worldObj.setBlockToAir(x, y, z); - - EntityStatHelper.giveStat(player, "BlessingCooldown", (int) ((player.worldObj.getWorldTime() / 24000) + 24000)); - } else { - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7e\u00A7oNo selected trap."}), (Player) player); - } - } - } - } else { - blessingActive = false; - - if(blessing != null) { - if(blessing.equals("Berserker")) { - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7cYou calm down."}), (Player) player); - EntityStatHelper.giveStat(player, "BlessingCooldown", (int) (player.worldObj.getWorldTime() + 1200)); - } - } - - EntityStatHelper.giveStat(player, "BlessingTimer", 0); - } - } else { - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7cBlessing is on cooldown. (" + (Integer.parseInt(EntityStatHelper.getStat(player, "BlessingCooldown")) - player.worldObj.getWorldTime())/20 + "s)"}), (Player) player); - } - - EntityStatHelper.giveStat(player, "BlessingActive", blessingActive); - - return; - - case DISARM_TRAP: - - int blockX = inputStream.readInt(); - int blockY = inputStream.readInt(); - int blockZ = inputStream.readInt(); - - boolean mechanic = inputStream.readBoolean(); - - blessing = null; - if(player.getEntityData().hasKey("Blessing")) {blessing = player.getEntityData().getString("Blessing");} - boolean scout = blessing != null && blessing.equals("Scout"); - - TileEntity te = player.worldObj.getBlockTileEntity(blockX, blockY, blockZ); - - boolean yours = (te == null || !(te instanceof TileEntityTrap)) ? false : player.getEntityName().equals(((TileEntityTrap) te).placedBy); - - if(yours || (mechanic ? ModjamMod.r.nextInt(4) != 0 : ModjamMod.r.nextInt(4) == 0)) { - boolean salvage = yours || (mechanic ? ModjamMod.r.nextBoolean() : (ModjamMod.r.nextInt(4) == 0)); - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7e\u00A7o" + (!salvage ? "You disarmed the trap." : "You disarm and salvage the trap.")}), (Player) player); - if(salvage) {player.worldObj.spawnEntityInWorld(new EntityItem(player.worldObj, blockX + 0.5F, blockY, blockZ + 0.5F, new ItemStack(ModjamMod.itemTrap.itemID, 1, player.worldObj.getBlockMetadata(blockX, blockY, blockZ) % BlockTrap.trapTypes)));} - player.worldObj.setBlockToAir(blockX, blockY, blockZ); - } else { - int trapType = player.worldObj.getBlockMetadata(blockX, blockY, blockZ); - - if(trapType % BlockTrap.trapTypes == 0) { - player.attackEntityFrom(DamageSource.cactus, 4.0F + (scout ? 1 : 0)); - if(ModjamMod.r.nextInt(16 - (scout ? 4 : 0)) == 0) {((EntityLivingBase) player).addPotionEffect(new PotionEffect(Potion.poison.id, 100 + (scout ? 25 : 0), 1));} - } else if(trapType % BlockTrap.trapTypes == 1) { - if(!player.isBurning()) {player.setFire(5 + (scout ? 1 : 0));} - } else if(trapType % BlockTrap.trapTypes == 2) { - player.addPotionEffect(new PotionEffect(Potion.blindness.id, 100 + (scout ? 25 : 0), 1)); - player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 100 + (scout ? 25 : 0), 1)); - } - - player.worldObj.setBlockToAir(blockX, blockY, blockZ); - - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7c\u00A7oYou failed to disarm the trap."}), (Player) player); - if(CommonTickHandler.worldData.getDisadvantage().equals("Explosive Traps")) {player.worldObj.setBlockToAir(blockX, blockY, blockZ); player.worldObj.createExplosion(null, blockX + 0.5F, blockY + 0.5F, blockZ + 0.5F, 1.33F, true);} - player.triggerAchievement(ModjamMod.whoops); - } - - return; - - case EXAMINE_MOB: - - int dimension = inputStream.readInt(); - int entityID = inputStream.readInt(); - - WorldServer server = null; - - for(WorldServer s : MinecraftServer.getServer().worldServers) {if(s.provider.dimensionId == dimension) {server = s; break;}} - - if(server != null) { - Entity entity = server.getEntityByID(entityID); - - if(entity != null) { - String blessing2 = entity.getEntityData().hasKey("Blessing") ? entity.getEntityData().getString("Blessing") : null; - - if(blessing2 != null) { - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7eYou notice " + entity.getTranslatedEntityName() + "\u00A7e is using Blessing of the " + blessing2 + "."}), (Player) player); - } else { - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7eThere doesn't seem to be anything special about " + (entity instanceof EntityPlayer ? "" : "this ") + entity.getTranslatedEntityName() + "\u00A7e."}), (Player) player); - } - } - } - - return; - - default: return; - } - } else if (side == Side.CLIENT) { - EntityPlayer player = (EntityPlayer) playerEntity; - - if(potionValues == null) {potionValues = new int[12];} - if(potionDurations == null) {potionDurations = new int[12];} - if(mushroomColors == null) {mushroomColors = new int[13][2];} - - switch(type) { - case UPDATE_BLESSING: player.getEntityData().setString("Blessing", inputStream.readUTF()); return; - case UPDATE_POTION_KNOWLEDGE: int[] potionKnowledge = new int[12]; for(int i = 0; i < 12; i++) {potionKnowledge[i] = inputStream.readInt();} player.getEntityData().setIntArray("PotionKnowledge", potionKnowledge); return; - - case SEND_MESSAGE: - for(String s : inputStream.readUTF().split("@")) {Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(s);} - return; - - case LEVEL_UP: player.addExperienceLevel(inputStream.readInt()); return; - - case UPDATE_STATS: - int num = inputStream.readInt(); - - for(int i = 0; i < num; i++) { - EntityStatHelper.giveStat(player, inputStream.readUTF(), inputStream.readUTF()); - } - return; - - case UPDATE_WORLD_DATA: - - for(int i = 0; i < 12; i++) {potionValues[i] = inputStream.readInt();} - for(int i = 0; i < 12; i++) {potionDurations[i] = inputStream.readInt();} - currentDisadvantage = inputStream.readUTF(); - currentTask = inputStream.readUTF(); - currentTaskID = inputStream.readInt(); - currentTaskAmount = inputStream.readInt(); - progress = inputStream.readInt(); - tasksCompleted = inputStream.readInt(); - enderDragonKilled = inputStream.readBoolean(); - trapsDisabled = !inputStream.readBoolean(); - rewardLevels = inputStream.readInt(); - - for(int i = 0; i < 13; i++) { - for(int i2 = 0; i2 < 2; i2++) {mushroomColors[i][i2] = inputStream.readInt();} - } - - return; - - default: return; - } - } - } - - } catch (Exception e) {e.printStackTrace();} - } - - public static Packet250CustomPayload newPacket(byte type, Object[] data) { - ByteArrayOutputStream bos = new ByteArrayOutputStream(8); - DataOutputStream outputStream = new DataOutputStream(bos); - - try { - outputStream.writeByte(type); - - if(data != null) { - for(int i = 0; i < data.length; i++) { - if(data[i] instanceof Integer) {outputStream.writeInt((Integer) data[i]);} - else if(data[i] instanceof int[]) { - for(int i2 = 0; i2 < ((int[]) data[i]).length; i2++) {outputStream.writeInt(((int[]) data[i])[i2]);} - } else if(data[i] instanceof int[][]) { - int[][] values = (int[][]) data[i]; - - for(int i2 = 0; i2 < values.length; i2++) { - for(int i3 = 0; i3 < values[i2].length; i3++) { - outputStream.writeInt(values[i2][i3]); - } - } - } else if(data[i] instanceof Boolean) {outputStream.writeBoolean((Boolean) data[i]);} - else if(data[i] instanceof String) {outputStream.writeUTF((String) data[i]);} - else if(data[i] instanceof Byte) {outputStream.writeByte((Byte) data[i]);} - else if(data[i] instanceof Float) {outputStream.writeDouble((Double) data[i]);} - else if(data[i] instanceof Double) {outputStream.writeFloat((Float) data[i]);} - else if(data[i] instanceof Character) {outputStream.writeChar((Character) data[i]);} - } - } - } catch (Exception ex) {ex.printStackTrace();} - - Packet250CustomPayload packet = new Packet250CustomPayload(); - packet.channel = "FyresModJamMod"; - packet.data = bos.toByteArray(); - packet.length = bos.size(); - return packet; - } - - public static Packet250CustomPayload newPacket(byte type) {return newPacket(type, null);} - -} diff --git a/fyresmodjam/items/ItemMysteryMushroom.java b/fyresmodjam/items/ItemMysteryMushroom.java deleted file mode 100644 index 784dd31..0000000 --- a/fyresmodjam/items/ItemMysteryMushroom.java +++ /dev/null @@ -1,146 +0,0 @@ -package fyresmodjam.items; - -import java.awt.Color; -import java.util.List; - - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import fyresmodjam.ModjamMod; -import fyresmodjam.handlers.PacketHandler; - -import net.minecraft.block.Block; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.EntityEggInfo; -import net.minecraft.entity.EntityList; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Icon; -import net.minecraft.world.World; - -public class ItemMysteryMushroom extends Item { - - public Icon overlay, icon; - - public ItemMysteryMushroom(int par1) { - super(par1); - this.setHasSubtypes(true); - } - - @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) { - icon = par1IconRegister.registerIcon("fyresmodjam:mushroom"); - overlay = par1IconRegister.registerIcon("fyresmodjam:mushroom_overlay"); - this.itemIcon = icon; - } - - public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List) { - for(int i = 0; i < 13; i++) {par3List.add(new ItemStack(par1, 1, i));} - } - - @SideOnly(Side.CLIENT) - public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { - return PacketHandler.mushroomColors[par1ItemStack.getItemDamage() % 13][par2 % 2]; - } - - @SideOnly(Side.CLIENT) - public boolean requiresMultipleRenderPasses() { - return true; - } - - @SideOnly(Side.CLIENT) - public Icon getIconFromDamageForRenderPass(int par1, int par2) { - return par2 > 0 ? overlay : icon; - } - - @Override - public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) - { - int i1 = par3World.getBlockId(par4, par5, par6); - - if (i1 == Block.snow.blockID && (par3World.getBlockMetadata(par4, par5, par6) & 7) < 1) - { - par7 = 1; - } - else if (i1 != Block.vine.blockID && i1 != Block.tallGrass.blockID && i1 != Block.deadBush.blockID - && (Block.blocksList[i1] == null || !Block.blocksList[i1].isBlockReplaceable(par3World, par4, par5, par6))) - { - if (par7 == 0) - { - --par5; - } - - if (par7 == 1) - { - ++par5; - } - - if (par7 == 2) - { - --par6; - } - - if (par7 == 3) - { - ++par6; - } - - if (par7 == 4) - { - --par4; - } - - if (par7 == 5) - { - ++par4; - } - } - - if (par1ItemStack.stackSize == 0) - { - return false; - } - else if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) - { - return false; - } - else if (par5 == 255 && Block.blocksList[ModjamMod.mysteryMushroomBlock.blockID].blockMaterial.isSolid()) - { - return false; - } - else if (par3World.canPlaceEntityOnSide(ModjamMod.mysteryMushroomBlock.blockID, par4, par5, par6, false, par7, par2EntityPlayer, par1ItemStack)) - { - - Block block = Block.blocksList[ModjamMod.mysteryMushroomBlock.blockID]; - int j1 = par1ItemStack.getItemDamage(); - int k1 = Block.blocksList[ModjamMod.mysteryMushroomBlock.blockID].onBlockPlaced(par3World, par4, par5, par6, par7, par8, par9, par10, j1); - - if(placeBlockAt(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10, k1)) { - par3World.playSoundEffect((double)((float)par4 + 0.5F), (double)((float)par5 + 0.5F), (double)((float)par6 + 0.5F), block.stepSound.getPlaceSound(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F); - --par1ItemStack.stackSize; - } - - return true; - } else { - return false; - } - } - - public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) - { - if (!world.setBlock(x, y, z, ModjamMod.mysteryMushroomBlock.blockID, metadata, 3)) - { - return false; - } - - if (world.getBlockId(x, y, z) == ModjamMod.mysteryMushroomBlock.blockID) - { - Block.blocksList[ModjamMod.mysteryMushroomBlock.blockID].onBlockPlacedBy(world, x, y, z, player, stack); - Block.blocksList[ModjamMod.mysteryMushroomBlock.blockID].onPostBlockPlaced(world, x, y, z, metadata); - } - - return true; - } -} diff --git a/fyresmodjam/items/ItemMysteryPotion.java b/fyresmodjam/items/ItemMysteryPotion.java deleted file mode 100644 index b01030d..0000000 --- a/fyresmodjam/items/ItemMysteryPotion.java +++ /dev/null @@ -1,192 +0,0 @@ -package fyresmodjam.items; - -import java.util.List; - - -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.network.PacketDispatcher; -import cpw.mods.fml.common.network.Player; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import fyresmodjam.ModjamMod; -import fyresmodjam.entities.EntityMysteryPotion; -import fyresmodjam.handlers.CommonTickHandler; -import fyresmodjam.handlers.PacketHandler; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.projectile.EntityPotion; -import net.minecraft.item.EnumAction; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; -import net.minecraft.util.Icon; -import net.minecraft.util.StatCollector; -import net.minecraft.world.World; - -public class ItemMysteryPotion extends Item { - - public Icon[] icons = null; - - public ItemMysteryPotion(int par1) { - super(par1); - this.setHasSubtypes(true); - } - - @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) { - icons = new Icon[26]; - - for(int i = 0; i < 13; i++) { - icons[i] = par1IconRegister.registerIcon("fyresmodjam:mysteryPotion_" + (i + 1)); - icons[i + 13] = par1IconRegister.registerIcon("fyresmodjam:mysteryPotionThrowable_" + (i + 1)); - } - - this.itemIcon = icons[0]; - } - - @SideOnly(Side.CLIENT) - public Icon getIconFromDamage(int par1) { - return icons[par1 % 26]; - } - - public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List) { - for(int i = 0; i < 13; i++) {par3List.add(new ItemStack(par1, 1, i));} - for(int i = 0; i < 13; i++) {par3List.add(new ItemStack(par1, 1, i + 13));} - } - - @SideOnly(Side.CLIENT) - public String getItemDisplayName(ItemStack par1ItemStack) { - int damage = par1ItemStack.getItemDamage() % 13; - String name = "Mystery Potion #" + (damage + 1); - - String blessing = null; - - if(FMLCommonHandler.instance().getSide() == Side.CLIENT) {blessing = getBlessing();} - - if(damage < 12) { - if(Minecraft.getMinecraft().thePlayer != null && Minecraft.getMinecraft().thePlayer.getEntityData().hasKey("PotionKnowledge")) { - if(Minecraft.getMinecraft().thePlayer.getEntityData().getIntArray("PotionKnowledge")[damage] != -1) { - Potion potion = Potion.potionTypes[PacketHandler.potionValues[damage]]; - name = StatCollector.translateToLocal(potion.getName()) + " Potion"; - - if(!potion.isInstant()) { - int time = PacketHandler.potionDurations[damage]; - name += " (" + time + " seconds)"; - } - } - } - } else if(damage >= 12) { - name = "Wildcard Potion"; - } - - //if(par1ItemStack.getItemDamage() >= 13) {name += " (Splash)";} - - if((blessing != null && blessing.equals("Alchemist")) /*|| FyresWorldData.currentDisadvantage.equals("Illiterate")*/) {name = "\u00A7k" + name;} - - return name; - } - - public EnumAction getItemUseAction(ItemStack par1ItemStack) { - return par1ItemStack.getItemDamage() < 13 ? EnumAction.drink : super.getItemUseAction(par1ItemStack); - } - - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if(par1ItemStack.getItemDamage() < 13) { - par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); - } else { - if(!par3EntityPlayer.capabilities.isCreativeMode) {par1ItemStack.stackSize--;} - par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); - - if(!par2World.isRemote) { - int value = 0; - - if(par1ItemStack.getItemDamage() % 13 >= 12) { - value = ModjamMod.r.nextInt(Potion.potionTypes.length); - while(Potion.potionTypes[value] == null) {value = ModjamMod.r.nextInt(Potion.potionTypes.length);} - } else { - value = CommonTickHandler.worldData.potionValues[par1ItemStack.getItemDamage() % 13]; - } - - par2World.spawnEntityInWorld(new EntityMysteryPotion(par2World, par3EntityPlayer, par1ItemStack)); - } - } - - return par1ItemStack; - } - - public int getMaxItemUseDuration(ItemStack par1ItemStack) { - return par1ItemStack.getItemDamage() < 13 ? 32 : super.getMaxItemUseDuration(par1ItemStack); - } - - public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if(!par3EntityPlayer.capabilities.isCreativeMode) {--par1ItemStack.stackSize;} - - String blessing = (par3EntityPlayer != null && par3EntityPlayer.getEntityData().hasKey("Blessing")) ? par3EntityPlayer.getEntityData().getString("Blessing") : null; - - int damage = par1ItemStack.getItemDamage() % 13; - - if((blessing == null || !blessing.equals("Alchemist")) && damage < 12) { - if(!par2World.isRemote) { - - int value = CommonTickHandler.worldData.potionValues[damage]; - - if(!Potion.potionTypes[value].isInstant()) { - par3EntityPlayer.addPotionEffect(new PotionEffect(value, CommonTickHandler.worldData.potionDurations[damage] * 20, 1, false)); - } else { - Potion.potionTypes[value].affectEntity(par3EntityPlayer, par3EntityPlayer, 1, 1); - } - - if(!par3EntityPlayer.getEntityData().hasKey("PotionKnowledge")) {par3EntityPlayer.getEntityData().setIntArray("PotionKnowledge", new int[] {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1});} - - if(par3EntityPlayer.getEntityData().getIntArray("PotionKnowledge")[damage] == -1) { - par3EntityPlayer.getEntityData().getIntArray("PotionKnowledge")[damage] = 1; - - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.UPDATE_POTION_KNOWLEDGE, new Object[] {par3EntityPlayer.getEntityData().getIntArray("PotionKnowledge")}), (Player) par3EntityPlayer); - - Potion potion = Potion.potionTypes[CommonTickHandler.worldData.potionValues[damage]]; - String name = StatCollector.translateToLocal(potion.getName()) + " Potion"; - - if(!potion.isInstant()) { - int time = CommonTickHandler.worldData.potionDurations[damage]; - name += " (" + time + " seconds)"; - } - - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7oYou learnt Mystery Potion #" + (damage + 1) + " was a " + name + "!"}), (Player) par3EntityPlayer); - } - } - - } else if(!par2World.isRemote) { - int value = ModjamMod.r.nextInt(Potion.potionTypes.length); - while(Potion.potionTypes[value] == null) {value = ModjamMod.r.nextInt(Potion.potionTypes.length);} - int time = 5 + ModjamMod.r.nextInt(26); - - if(!Potion.potionTypes[value].isInstant()) { - par3EntityPlayer.addPotionEffect(new PotionEffect(value, time * 20, 1, false)); - } else { - Potion.potionTypes[value].affectEntity(par3EntityPlayer, par3EntityPlayer, 1, 1); - } - - Potion potion = Potion.potionTypes[value]; - String name = StatCollector.translateToLocal(potion.getName()) + " Potion"; - - if(!potion.isInstant()) {name += " (" + time + " seconds)";} - - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7oYou drank a " + name + "."}), (Player) par3EntityPlayer); - } - - return par1ItemStack; - } - - @SideOnly(Side.CLIENT) - public String getBlessing() { - return (Minecraft.getMinecraft().thePlayer != null && Minecraft.getMinecraft().thePlayer.getEntityData().hasKey("Blessing")) ? Minecraft.getMinecraft().thePlayer.getEntityData().getString("Blessing") : null; - } - - public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { - return false; - } - -} diff --git a/fyresmodjam/items/ItemObsidianSceptre.java b/fyresmodjam/items/ItemObsidianSceptre.java deleted file mode 100644 index 33f3cdf..0000000 --- a/fyresmodjam/items/ItemObsidianSceptre.java +++ /dev/null @@ -1,47 +0,0 @@ -package fyresmodjam.items; - -import java.util.List; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Icon; - -public class ItemObsidianSceptre extends Item { - - public Icon icon, icon2; - - public ItemObsidianSceptre(int par1) { - super(par1); - this.hasSubtypes = true; - } - - @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) { - icon = par1IconRegister.registerIcon("fyresmodjam:unenchantedSceptre"); - icon2 = par1IconRegister.registerIcon("fyresmodjam:enchantedSceptre"); - this.itemIcon = icon; - } - - public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List) { - for(int i = 0; i < 2; i++) {par3List.add(new ItemStack(par1, 1, i));} - } - - @SideOnly(Side.CLIENT) - public String getItemDisplayName(ItemStack par1ItemStack) { - return (par1ItemStack.getItemDamage() == 0 ? "" : "Infused ") + super.getItemDisplayName(par1ItemStack); - } - - @SideOnly(Side.CLIENT) - public Icon getIconFromDamage(int par1) { - return par1 == 0 ? icon : icon2; - } - - @SideOnly(Side.CLIENT) - public boolean hasEffect(ItemStack par1ItemStack) { - return par1ItemStack.getItemDamage() > 0; - } -} diff --git a/fyresmodjam/items/ItemPillar.java b/fyresmodjam/items/ItemPillar.java deleted file mode 100644 index 87394f7..0000000 --- a/fyresmodjam/items/ItemPillar.java +++ /dev/null @@ -1,72 +0,0 @@ -package fyresmodjam.items; - -import java.util.List; - - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import fyresmodjam.ModjamMod; -import fyresmodjam.tileentities.TileEntityPillar; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.MathHelper; -import net.minecraft.world.World; - -public class ItemPillar extends Item -{ - public ItemPillar(int par1) { - super(par1); - this.maxStackSize = 1; - this.setCreativeTab(CreativeTabs.tabBlock); - this.hasSubtypes = true; - } - - public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List) { - if(ModjamMod.showAllPillarsInCreative) { - for(int i = 0; i < TileEntityPillar.validBlessings.length + 1; i++) {par3List.add(new ItemStack(par1, 1, i));} - } else {super.getSubItems(par1, par2CreativeTabs, par3List);} - } - - @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) { - this.itemIcon = par1IconRegister.registerIcon("fyresmodjam:itemPillar"); - } - - @SideOnly(Side.CLIENT) - public String getItemDisplayName(ItemStack par1ItemStack) { - return super.getItemDisplayName(par1ItemStack) + (par1ItemStack.getItemDamage() == 0 ? "" : " (Blessing of the " + TileEntityPillar.validBlessings[(par1ItemStack.getItemDamage() - 1) % TileEntityPillar.validBlessings.length] + ")"); - } - - public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) - { - Block block = ModjamMod.blockPillar; - - if(par7 == 0) {par5 -= 2;} - if(par7 == 1 && !Block.blocksList[par3World.getBlockId(par4, par5, par6)].isBlockReplaceable(par3World, par4, par5, par6)) {++par5;} - if(par7 == 2) {--par6;} - if(par7 == 3) {++par6;} - if(par7 == 4) {--par4;} - if(par7 == 5) {++par4;} - - if(!block.canPlaceBlockAt(par3World, par4, par5, par6)) { - return false; - } else { - par3World.setBlock(par4, par5, par6, block.blockID); - par3World.setBlockMetadataWithNotify(par4, par5, par6, 0, 0); - - par3World.setBlock(par4, par5 + 1, par6, block.blockID); - par3World.setBlockMetadataWithNotify(par4, par5 + 1, par6, 1, 0); - - if(par1ItemStack.getItemDamage() != 0) {((TileEntityPillar) par3World.getBlockTileEntity(par4, par5, par6)).blessing = TileEntityPillar.validBlessings[par1ItemStack.getItemDamage() - 1];} - - --par1ItemStack.stackSize; - - return true; - } - } -} diff --git a/fyresmodjam/items/ItemScroll.java b/fyresmodjam/items/ItemScroll.java deleted file mode 100644 index 5c2bfa6..0000000 --- a/fyresmodjam/items/ItemScroll.java +++ /dev/null @@ -1,92 +0,0 @@ -package fyresmodjam.items; - -import java.util.List; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemEditableBook; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.nbt.NBTTagString; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.Icon; -import net.minecraft.util.StatCollector; -import net.minecraft.world.World; - -public class ItemScroll extends Item { - - public static String[][] scrollText = new String[][] { - {"Unkown Adventurer", "Codex #1: Adventurer's Log", "This morning I fell out of the sky. I am unsure of where I am, or for what purpose, but I've begun construction of a small shelter for the time being.", "I've now spent days scouting the nearby area with no luck. Still alone, I'm made my decision to set out further.", "I've discovered an ancient stronghold. Writtings of end times cover the walls. What could it mean? Who built this place? Why was it here? And I have an unsettling feeling that I'm being watched..."}, - {"Village Elder", "Codex #2: An Elders Warning", "For thousands of years, we have lived peacefully. As stories of the distant past began to fade in time, the elders became tasked with remembering. I now join their ranks, but still I see there are those who choose to forget.", "The lines between worlds begin to blur once again. In the deepest caverns, we can see in to their world, and theirs in to ours. The end returns, yet no other will listen. It's clear I must find the crystal alone."}, - {"Pigman Warrior", "Codex #3: The Warriors Spirit", "We fight through the fires of this realm, thinking as one. It is the only way to survive this wretched landscape. Hurt one and the horde will know.", "Strangers enter our realm through even stranger portals. They seek the crystal which bonds our world. We refuse, we fight, but many die. Our numbers begin dwindle, but the crystal will stay ours.", "We can see the void seeping through the cracks of our realm, reanimating the dead. Empty husks of our fallen push back the intruders. But they too are affected by the void's forces."}, - {"Enderman Urchin", "Codex #4: From the Shadows", "The darkness shall consume all, below each of the worlds it boils. We now wait for our time to return, watching through the cracks of space and time. Us children of the Ender will reclaim what was once ours."}/*, - {"Author", "Codex #5", "Words"}*/ - }; - - // TODO get text from text file to allow for user editting - - public Icon texture; - - public ItemScroll(int par1) { - super(par1); - this.hasSubtypes = true; - this.maxStackSize = 1; - } - - @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister iconRegister) { - texture = iconRegister.registerIcon("fyresmodjam:scroll"); - this.itemIcon = texture; - } - - public void onUpdate(ItemStack stack, World world, Entity entity, int par1, boolean b) { - if(!world.isRemote) { - if(!stack.hasTagCompound()) {stack.stackTagCompound = new NBTTagCompound();} - - if(!stack.getTagCompound().hasKey("initialized") || !stack.getTagCompound().getBoolean("initialized")) { - stack.getTagCompound().setBoolean("initialized", true); - - ItemStack book = new ItemStack(Item.writtenBook, 1, 0); - - NBTTagList pages = new NBTTagList("pages"); - - for(int i = 2; i < scrollText[stack.getItemDamage() % scrollText.length].length; i++) { - pages.appendTag(new NBTTagString("" + (i - 1), scrollText[stack.getItemDamage() % scrollText.length][i])); - } - - book.setTagInfo("pages", pages); - book.setTagInfo("author", new NBTTagString("author", scrollText[stack.getItemDamage() % scrollText.length][0])); - book.setTagInfo("title", new NBTTagString("title", scrollText[stack.getItemDamage() % scrollText.length][1])); - - NBTTagCompound bookTag = new NBTTagCompound(); - book.writeToNBT(bookTag); - stack.setTagInfo("book", bookTag); - } - } - } - - public void getSubItems(int id, CreativeTabs creativeTab, List list) { - for(int i = 0; i < scrollText.length; i++) {list.add(new ItemStack(id, 1, i));} - } - - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - NBTTagCompound bookTag = par1ItemStack.getTagCompound().getCompoundTag("book"); - if(bookTag != null) {par3EntityPlayer.displayGUIBook(ItemStack.loadItemStackFromNBT(bookTag));} - return par1ItemStack; - } - - public String getItemDisplayName(ItemStack par1ItemStack) { - return scrollText[par1ItemStack.getItemDamage() % scrollText.length][1]; - } - - @SideOnly(Side.CLIENT) - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(EnumChatFormatting.GRAY + scrollText[par1ItemStack.getItemDamage() % scrollText.length][0]); - } -} diff --git a/fyresmodjam/items/ItemTrap.java b/fyresmodjam/items/ItemTrap.java deleted file mode 100644 index 31befa5..0000000 --- a/fyresmodjam/items/ItemTrap.java +++ /dev/null @@ -1,201 +0,0 @@ -package fyresmodjam.items; - -import java.util.List; - - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import fyresmodjam.ModjamMod; -import fyresmodjam.blocks.BlockTrap; -import fyresmodjam.misc.BehaviorDispenseTrap; -import net.minecraft.block.Block; -import net.minecraft.block.BlockDispenser; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.dispenser.IBehaviorDispenseItem; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Icon; -import net.minecraft.world.World; - -public class ItemTrap extends Item { - - private static final IBehaviorDispenseItem dispenseTrap = new BehaviorDispenseTrap(); - - public Icon[] icons; - public static String[] iconLocations = new String[] {"fyresmodjam:itemTrap", "fyresmodjam:trap2", "fyresmodjam:trap3"}; - - public ItemTrap(int par1) { - super(par1); - this.setHasSubtypes(true); - BlockDispenser.dispenseBehaviorRegistry.putObject(this, dispenseTrap); - } - - @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) { - icons = new Icon[iconLocations.length]; - for(int i = 0; i < iconLocations.length; i++) {icons[i] = par1IconRegister.registerIcon(iconLocations[i]);} - - this.itemIcon = icons[0]; - } - - public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List) { - for(int i = 0; i < BlockTrap.trapTypes; i++) {par3List.add(new ItemStack(par1, 1, i));} - } - - public static String[] names = {"Spike Trap", "Flame Trap", "Smoke Trap"}; - - @SideOnly(Side.CLIENT) - public String getItemDisplayName(ItemStack par1ItemStack) { - return names[par1ItemStack.getItemDamage() % BlockTrap.trapTypes]; - } - - @SideOnly(Side.CLIENT) - public Icon getIconFromDamage(int par1) { - return icons[par1 % BlockTrap.trapTypes]; - } - - //Below snipped and editted from ItemBlock, avoided using ItemBlock because blockID was private - - public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) - { - int i1 = par3World.getBlockId(par4, par5, par6); - - if (i1 == Block.snow.blockID && (par3World.getBlockMetadata(par4, par5, par6) & 7) < 1) - { - par7 = 1; - } - else if (i1 != Block.vine.blockID && i1 != Block.tallGrass.blockID && i1 != Block.deadBush.blockID - && (Block.blocksList[i1] == null || !Block.blocksList[i1].isBlockReplaceable(par3World, par4, par5, par6))) - { - if (par7 == 0) - { - --par5; - } - - if (par7 == 1) - { - ++par5; - } - - if (par7 == 2) - { - --par6; - } - - if (par7 == 3) - { - ++par6; - } - - if (par7 == 4) - { - --par4; - } - - if (par7 == 5) - { - ++par4; - } - } - - if (par1ItemStack.stackSize == 0) - { - return false; - } - else if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) - { - return false; - } - else if (par5 == 255 && Block.blocksList[ModjamMod.blockTrap.blockID].blockMaterial.isSolid()) - { - return false; - } - else if (par3World.canPlaceEntityOnSide(ModjamMod.blockTrap.blockID, par4, par5, par6, false, par7, par2EntityPlayer, par1ItemStack)) - { - Block block = Block.blocksList[ModjamMod.blockTrap.blockID]; - int j1 = this.getMetadata(par1ItemStack.getItemDamage()); - int k1 = Block.blocksList[ModjamMod.blockTrap.blockID].onBlockPlaced(par3World, par4, par5, par6, par7, par8, par9, par10, j1); - - if (placeBlockAt(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10, k1)) - { - par3World.playSoundEffect((double)((float)par4 + 0.5F), (double)((float)par5 + 0.5F), (double)((float)par6 + 0.5F), block.stepSound.getPlaceSound(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F); - --par1ItemStack.stackSize; - } - - return true; - } - else - { - return false; - } - } - - @SideOnly(Side.CLIENT) - - /** - * Returns true if the given ItemBlock can be placed on the given side of the given block position. - */ - public boolean canPlaceItemBlockOnSide(World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer, ItemStack par7ItemStack) - { - int i1 = par1World.getBlockId(par2, par3, par4); - - if (i1 == Block.snow.blockID) - { - par5 = 1; - } - else if (i1 != Block.vine.blockID && i1 != Block.tallGrass.blockID && i1 != Block.deadBush.blockID - && (Block.blocksList[i1] == null || !Block.blocksList[i1].isBlockReplaceable(par1World, par2, par3, par4))) - { - if (par5 == 0) - { - --par3; - } - - if (par5 == 1) - { - ++par3; - } - - if (par5 == 2) - { - --par4; - } - - if (par5 == 3) - { - ++par4; - } - - if (par5 == 4) - { - --par2; - } - - if (par5 == 5) - { - ++par2; - } - } - - return par1World.canPlaceEntityOnSide(ModjamMod.blockTrap.blockID, par2, par3, par4, false, par5, (Entity)null, par7ItemStack); - } - - public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) - { - if (!world.setBlock(x, y, z, ModjamMod.blockTrap.blockID, metadata, 3)) - { - return false; - } - - if (world.getBlockId(x, y, z) == ModjamMod.blockTrap.blockID) - { - Block.blocksList[ModjamMod.blockTrap.blockID].onBlockPlacedBy(world, x, y, z, player, stack); - Block.blocksList[ModjamMod.blockTrap.blockID].onPostBlockPlaced(world, x, y, z, metadata); - } - - return true; - } -} diff --git a/fyresmodjam/misc/BehaviorDispenseTrap.java b/fyresmodjam/misc/BehaviorDispenseTrap.java deleted file mode 100644 index 5c11144..0000000 --- a/fyresmodjam/misc/BehaviorDispenseTrap.java +++ /dev/null @@ -1,52 +0,0 @@ -package fyresmodjam.misc; - -import cpw.mods.fml.common.network.PacketDispatcher; -import fyresmodjam.ModjamMod; -import net.minecraft.block.Block; -import net.minecraft.block.BlockDispenser; -import net.minecraft.block.BlockRailBase; -import net.minecraft.dispenser.BehaviorDefaultDispenseItem; -import net.minecraft.dispenser.IBlockSource; -import net.minecraft.entity.item.EntityMinecart; -import net.minecraft.item.ItemMinecart; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraft.world.World; - -public class BehaviorDispenseTrap extends BehaviorDefaultDispenseItem { - - private final BehaviorDefaultDispenseItem field_96465_b = new BehaviorDefaultDispenseItem(); - - public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) { - - EnumFacing enumfacing = BlockDispenser.getFacing(par1IBlockSource.getBlockMetadata()); - - World world = par1IBlockSource.getWorld(); - - double d0 = par1IBlockSource.getX() + (double)((float)enumfacing.getFrontOffsetX() * 1.125F); - double d1 = par1IBlockSource.getY() + (double)((float)enumfacing.getFrontOffsetY() * 1.125F); - double d2 = par1IBlockSource.getZ() + (double)((float)enumfacing.getFrontOffsetZ() * 1.125F); - - int i = par1IBlockSource.getXInt() + enumfacing.getFrontOffsetX(); - int j = par1IBlockSource.getYInt() + enumfacing.getFrontOffsetY(); - int k = par1IBlockSource.getZInt() + enumfacing.getFrontOffsetZ(); - - int l = world.getBlockId(i, j, k); - - if(!Block.blocksList[ModjamMod.blockTrap.blockID].canPlaceBlockAt(world, i, j, k)){ - return this.field_96465_b.dispense(par1IBlockSource, par2ItemStack); - } - - world.setBlock(i, j, k, ModjamMod.blockTrap.blockID, par2ItemStack.getItemDamage(), 0); - world.markBlockForUpdate(i, j, k); - - //TileEntity te = world.getBlockTileEntity(i, j, k); - //if(te != null && !world.isRemote) {PacketDispatcher.sendPacketToAllPlayers(te.getDescriptionPacket());} - - par2ItemStack.splitStack(1); - - return par2ItemStack; - - } -} diff --git a/fyresmodjam/misc/ItemStatHelper.java b/fyresmodjam/misc/ItemStatHelper.java deleted file mode 100644 index 3db049a..0000000 --- a/fyresmodjam/misc/ItemStatHelper.java +++ /dev/null @@ -1,505 +0,0 @@ -package fyresmodjam.misc; - -import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Random; -import java.util.Stack; - -import cpw.mods.fml.common.ICraftingHandler; -import cpw.mods.fml.common.network.PacketDispatcher; -import cpw.mods.fml.common.network.Player; -import cpw.mods.fml.common.registry.GameRegistry; -import fyresmodjam.ModjamMod; -import fyresmodjam.handlers.CommonTickHandler; -import fyresmodjam.handlers.PacketHandler; -import fyresmodjam.misc.EntityStatHelper.EntityStat; -import fyresmodjam.misc.EntityStatHelper.EntityStatTracker; -import fyresmodjam.misc.ItemStatHelper.ItemStat; - - -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLiving; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.monster.EntityMob; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.Item; -import net.minecraft.item.ItemAxe; -import net.minecraft.item.ItemBow; -import net.minecraft.item.ItemPickaxe; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemSword; -import net.minecraft.nbt.NBTBase; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.nbt.NBTTagString; -import net.minecraft.network.packet.Packet; -import net.minecraft.network.packet.Packet250CustomPayload; -import net.minecraft.network.packet.Packet5PlayerInventory; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; -import net.minecraft.util.DamageSource; -import net.minecraft.util.StatCollector; -import net.minecraft.world.WorldServer; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.ForgeSubscribe; -import net.minecraftforge.event.entity.EntityJoinWorldEvent; -import net.minecraftforge.event.entity.item.ItemTossEvent; -import net.minecraftforge.event.entity.living.LivingHurtEvent; -import net.minecraftforge.event.entity.player.EntityItemPickupEvent; -import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent; -import net.minecraftforge.event.entity.player.PlayerDropsEvent; - -public class ItemStatHelper implements ICraftingHandler { - - //There's probably a better way of doing all of this. :P Oh well. - - public static class ItemStatTracker { - public Class[] classes; - public int[] ids; - - public boolean instanceAllowed = false; - - public ItemStatTracker(Class[] classes, int[] ids, boolean instanceAllowed) { - this.classes = classes; - this.ids = ids; - this.instanceAllowed = instanceAllowed; - } - - public ItemStatTracker(Class c, int id, boolean instanceAllowed) {this(new Class[] {c}, new int[] {id}, instanceAllowed);} - - //public HashMap stats = new HashMap(); - public ArrayList stats = new ArrayList(); - //public StatTracker giveStat(String name, String value) {stats.put(name, value); return this;} - - public void addStat(ItemStat stat) { - if(!stats.contains(stat)) {stats.add(stat);} - } - } - - public static class ItemStat { - public String name; - public String value; - - public ItemStat(String name, Object value) { - this.name = name; - this.value = value.toString(); - } - - public Object getNewValue(ItemStack stack, Random r) {return value;} - public String getLore(ItemStack stack) {return null;} - public String getAlteredStackName(ItemStack stack, Random r) {return stack.getDisplayName();} - public void modifyStack(ItemStack stack, Random r) {} - } - - public static HashMap statTrackersByClass = new HashMap(); - public static HashMap statTrackersByID = new HashMap(); - - public static ArrayList genericTrackers = new ArrayList(); - - public static void addStatTracker(ItemStatTracker statTracker) { - if(statTracker.classes != null) {for(Class c : statTracker.classes) {statTrackersByClass.put(c, statTracker);}} - if(statTracker.ids != null) {for(int i : statTracker.ids) {if(i < 0) {continue;} statTrackersByID.put(i, statTracker);}} - if(statTracker.instanceAllowed) {genericTrackers.add(statTracker);} - } - - public static ItemStack giveStat(ItemStack stack, String name, Object value) { - if(!stack.hasTagCompound()) {stack.setTagCompound(new NBTTagCompound());} - NBTTagCompound data = stack.stackTagCompound; - data.setString(name, value.toString()); - return stack; - } - - public static ItemStack setName(ItemStack stack, String name) { - if(!stack.hasTagCompound()) {stack.setTagCompound(new NBTTagCompound());} - if(!stack.getTagCompound().hasKey("display")) {stack.getTagCompound().setTag("display", new NBTTagCompound());} - stack.getTagCompound().getCompoundTag("display").setString("Name", name); - - //if(getName(stack).equals(StatCollector.translateToLocal(stack.getItemName()))) {stack.getTagCompound().getCompoundTag("display").removeTag("Name");} - - return stack; - } - - public static ItemStack addLore(ItemStack stack, String lore) { - if(!stack.hasTagCompound()) {stack.setTagCompound(new NBTTagCompound());} - if(!stack.getTagCompound().hasKey("display")) {stack.getTagCompound().setTag("display", new NBTTagCompound());} - if(!stack.getTagCompound().getCompoundTag("display").hasKey("Lore")) {stack.getTagCompound().getCompoundTag("display").setTag("Lore", new NBTTagList());} - if(lore != null) {stack.getTagCompound().getCompoundTag("display").getTagList("Lore").appendTag(new NBTTagString("", lore));} - return stack; - } - - public static String getName(ItemStack stack) { - if(stack.getTagCompound() != null && stack.getTagCompound().hasKey("display") && stack.getTagCompound().getCompoundTag("display").hasKey("Name")) { - return stack.getTagCompound().getCompoundTag("display").getString("Name"); - } - - return null; - } - - public static String getStat(ItemStack stack, String name) { - String s = null; - if(stack.getTagCompound() != null && stack.getTagCompound().hasKey(name)) {s = stack.getTagCompound().getString(name);} - return s; - } - - public static boolean hasStat(ItemStack stack, String name) { - if(stack.getTagCompound() != null && stack.getTagCompound().hasKey(name)) {return true;} - return false; - } - - /*@ForgeSubscribe - public void entityJoinWorld(EntityJoinWorldEvent event) { - if(!event.world.isRemote && event.entity instanceof EntityItem) { - EntityItem item = (EntityItem) event.entity; - processItemStack(item.getDataWatcher().getWatchableObjectItemStack(10), ModjamMod.r); - } - }*/ - - /*@ForgeSubscribe - public void playerToss(ItemTossEvent event) { - if(!event.entity.worldObj.isRemote) { - ItemStack stack = event.entityItem.getDataWatcher().getWatchableObjectItemStack(10); - - if(CommonTickHandler.worldData.currentTask.equals("Collect") && stack.getItem().itemID == CommonTickHandler.worldData.currentTaskID) { - CommonTickHandler.worldData.progress -= stack.stackSize; - - PacketDispatcher.sendPacketToAllPlayers(PacketHandler.newPacket(PacketHandler.UPDATE_WORLD_DATA, new Object[] {CommonTickHandler.worldData.potionValues, CommonTickHandler.worldData.potionDurations, CommonTickHandler.worldData.currentDisadvantage, CommonTickHandler.worldData.currentTask, CommonTickHandler.worldData.currentTaskID, CommonTickHandler.worldData.currentTaskAmount, CommonTickHandler.worldData.progress, CommonTickHandler.worldData.tasksCompleted, CommonTickHandler.worldData.enderDragonKilled, ModjamMod.spawnTraps})); - - CommonTickHandler.worldData.setDirty(true); - } - } - } - - @ForgeSubscribe - public void playerDestroyItem(PlayerDestroyItemEvent event) { - if(!event.entity.worldObj.isRemote) { - ItemStack stack = event.original; - - if(CommonTickHandler.worldData.currentTask.equals("Collect") && stack.getItem().itemID == CommonTickHandler.worldData.currentTaskID) { - CommonTickHandler.worldData.progress -= stack.stackSize; - - PacketDispatcher.sendPacketToAllPlayers(PacketHandler.newPacket(PacketHandler.UPDATE_WORLD_DATA, new Object[] {CommonTickHandler.worldData.potionValues, CommonTickHandler.worldData.potionDurations, CommonTickHandler.worldData.currentDisadvantage, CommonTickHandler.worldData.currentTask, CommonTickHandler.worldData.currentTaskID, CommonTickHandler.worldData.currentTaskAmount, CommonTickHandler.worldData.progress, CommonTickHandler.worldData.tasksCompleted, CommonTickHandler.worldData.enderDragonKilled, ModjamMod.spawnTraps})); - - CommonTickHandler.worldData.setDirty(true); - } - } - }*/ - - @ForgeSubscribe - public void playerDrops(PlayerDropsEvent event) { - if(!event.entity.worldObj.isRemote) { - if(CommonTickHandler.worldData.getDisadvantage().equals("Permadeath")) { - for(EntityItem i : event.drops) {i.setDead();} - } - } - } - - /*@ForgeSubscribe - public void itemPickUp(EntityItemPickupEvent event) { - if(!event.entityPlayer.worldObj.isRemote) { - //processItemStack(event.item.getDataWatcher().getWatchableObjectItemStack(10), ModjamMod.r); - - ItemStack stack = event.item.getDataWatcher().getWatchableObjectItemStack(10); - - if(CommonTickHandler.worldData.currentTask.equals("Collect") && stack.getItem().itemID == CommonTickHandler.worldData.currentTaskID) { - CommonTickHandler.worldData.progress += stack.stackSize; - - if(CommonTickHandler.worldData.progress >= CommonTickHandler.worldData.currentTaskAmount) { - CommonTickHandler.worldData.progress = 0; - CommonTickHandler.worldData.tasksCompleted++; - - CommonTickHandler.worldData.giveNewTask(); - - PacketDispatcher.sendPacketToAllPlayers(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7eA world goal has been completed!" + (!CommonTickHandler.worldData.currentDisadvantage.equals("None") ? " World disadvantage has been lifted!": "")})); - PacketDispatcher.sendPacketToAllPlayers(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7eA new world goal has been set: " + (CommonTickHandler.worldData.currentTask + " " + CommonTickHandler.worldData.currentTaskAmount + " " + (CommonTickHandler.worldData.currentTask.equals("Kill") ? FyresWorldData.validMobNames[CommonTickHandler.worldData.currentTaskID] : new ItemStack(Item.itemsList[CommonTickHandler.worldData.currentTaskID], 1).getDisplayName()) + "s. (" + CommonTickHandler.worldData.progress + " " + CommonTickHandler.worldData.currentTask + "ed)")})); - - CommonTickHandler.worldData.currentDisadvantage = "None"; - } - - PacketDispatcher.sendPacketToAllPlayers(PacketHandler.newPacket(PacketHandler.UPDATE_WORLD_DATA, new Object[] {CommonTickHandler.worldData.potionValues, CommonTickHandler.worldData.potionDurations, CommonTickHandler.worldData.currentDisadvantage, CommonTickHandler.worldData.currentTask, CommonTickHandler.worldData.currentTaskID, CommonTickHandler.worldData.currentTaskAmount, CommonTickHandler.worldData.progress, CommonTickHandler.worldData.tasksCompleted, CommonTickHandler.worldData.enderDragonKilled, ModjamMod.spawnTraps})); - - CommonTickHandler.worldData.setDirty(true); - } - } - }*/ - - @ForgeSubscribe - public void livingHurt(LivingHurtEvent event) { - if(!event.entity.worldObj.isRemote) { - float damageMultiplier = 1.0F; - - boolean skip = false; - - if((CommonTickHandler.worldData.getDisadvantage().equals("Weak") && event.source.getDamageType().equals("player")) || (CommonTickHandler.worldData.getDisadvantage().equals("Tougher Mobs") && event.entity instanceof EntityMob)) { - damageMultiplier -= 0.25F; - } - - if(event.entity.getEntityData().hasKey("Blessing")) { - String blessing = event.entity.getEntityData().getString("Blessing"); - - if(blessing.equals("Guardian")) { - damageMultiplier -= 0.20F; - } else if(blessing.equals("Inferno") && (event.source.isFireDamage() || event.source.getDamageType().equals("inFire") || event.source.getDamageType().equals("onFire") || event.source.getDamageType().equals("lava"))) { - skip = true; - damageMultiplier = 0; - } else if(blessing.equals("Paratrooper") && event.source.getDamageType().equals("fall")) { - skip = true; - damageMultiplier = 0; - } else if(blessing.equals("Vampire")) { - if(event.entity.getBrightness(1.0F) > 0.5F && event.entity.worldObj.canBlockSeeTheSky((int) (event.entity.posX), (int) (event.entity.posY), (int) (event.entity.posZ))) { - damageMultiplier += 0.2F; - } - } else if(blessing.equals("Porcupine") && event.source.getEntity() != null && event.source.getEntity() instanceof EntityLivingBase && !event.source.isProjectile() && (event.source.damageType.equals("mob") || event.source.getDamageType().equals("player"))) { - DamageSource damage = DamageSource.causeThornsDamage(event.entity); - ((EntityLivingBase) event.source.getEntity()).attackEntityFrom(damage, event.ammount * 0.07F); - } - } - - if(!skip && event.entity instanceof EntityLivingBase) { - EntityLivingBase entity = (EntityLivingBase) event.entity; - - for(int i = 0; i < 4; i++) { - ItemStack stack = entity.getCurrentItemOrArmor(i + 1); - if(stack == null || stack.getTagCompound() == null || !stack.getTagCompound().hasKey("DamageReduction")) {continue;} - damageMultiplier -= Float.parseFloat(stack.getTagCompound().getString("DamageReduction").trim().replace(",", ".")) * 0.01F; - } - } - - if(!skip && event.source != null && event.source.getEntity() != null) { - if(event.source.getEntity() instanceof EntityLivingBase) { - EntityLivingBase entity = (EntityLivingBase) event.source.getEntity(); - - ItemStack held = entity.getCurrentItemOrArmor(0); - - if(held != null && ((event.source.getDamageType().equals("player") || event.source.getDamageType().equals("mob") || (held.getItem().itemID == Item.bow.itemID && event.source.isProjectile())))) { - String s = getStat(held, "BonusDamage"); - if(s != null) {event.ammount += Float.parseFloat(s.trim().replace(",", "."));} - } - } - - String mob = EntityStatHelper.getUnalteredName(event.entity); - if(ModjamMod.enableMobKillStats && event.source.getEntity() instanceof EntityPlayer && event.source.getEntity().getEntityData().hasKey("KillStats") && event.source.getEntity().getEntityData().getCompoundTag("KillStats").hasKey(mob + "Kills")) { - int kills = event.source.getEntity().getEntityData().getCompoundTag("KillStats").getInteger(mob + "Kills"); - - int last = 0; - for(int i = 0; i < EntityStatHelper.killCount.length; i++) { - if(kills >= EntityStatHelper.killCount[i]) {last = i; continue;} else {break;} - } - - damageMultiplier += EntityStatHelper.damageBonus[last]; - } - - String weapon = "misc"; - if(ModjamMod.enableWeaponKillStats && event.source.getEntity() instanceof EntityPlayer && event.source.getEntity().getEntityData().hasKey("WeaponStats") && event.source.getEntity().getEntityData().getCompoundTag("WeaponStats").hasKey(weapon + "Kills")) { - EntityPlayer player = (EntityPlayer) event.source.getEntity(); - - if(player.getHeldItem() == null) { - weapon = "fist"; - } else if(player.getHeldItem().getItem() != null && player.getHeldItem().getItem() instanceof ItemSword || player.getHeldItem().getItem() instanceof ItemBow || player.getHeldItem().getItem() instanceof ItemAxe) { - weapon = EntityStatHelper.getUnalteredItemName(player.getHeldItem().getItem()); - } - - int kills = event.source.getEntity().getEntityData().getCompoundTag("WeaponStats").getInteger(weapon + "Kills"); - - int last = 0; - for(int i = 0; i < EntityStatHelper.killCount.length; i++) { - if(kills >= EntityStatHelper.killCount[i] * 2) {last = i; continue;} else {break;} - } - - damageMultiplier += EntityStatHelper.damageBonus[last]; - } - - if(event.source.getEntity().getEntityData().hasKey("Blessing")) { - String blessing = event.source.getEntity().getEntityData().getString("Blessing"); - - ItemStack held = null; - if(event.source.getEntity() instanceof EntityLivingBase) {held = ((EntityLivingBase) event.source.getEntity()).getHeldItem();} - - if(blessing.equals("Warrior") && (event.source.getDamageType().equals("player") || event.source.getDamageType().equals("mob"))) { - damageMultiplier += 0.2F; - } else if(blessing.equals("Hunter") && event.source.isProjectile()) { - damageMultiplier += 0.2F; - } else if(blessing.equals("Miner") && held != null && held.getItem() instanceof ItemPickaxe) { - damageMultiplier += 0.2F; - } else if(blessing.equals("Lumberjack") && held != null && held.getItem() instanceof ItemAxe) { - damageMultiplier += 0.15F; - } else if(event.entityLiving != null && blessing.equals("Ninja") && event.source.getEntity().isSneaking() && event.entityLiving.getHealth() == event.entityLiving.getMaxHealth()) { - damageMultiplier += 1.0F; - } else if(blessing.equals("Swamp") && event.entityLiving != null) { - event.entityLiving.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 100, 1, false)); - } else if(blessing.equals("Vampire") && event.source.getEntity() instanceof EntityLivingBase) { - ((EntityLivingBase) event.source.getEntity()).heal(event.ammount * damageMultiplier * 0.07F); - - if(event.source.getEntity().getBrightness(1.0F) > 0.5F && event.source.getEntity().worldObj.canBlockSeeTheSky((int) (event.source.getEntity().posX), (int) (event.source.getEntity().posY), (int) (event.source.getEntity().posZ))) { - damageMultiplier -= 0.2F; - } - } else if(blessing.equals("Inferno") && event.source.getEntity().isBurning()) { - damageMultiplier += 0.35F; - } else if(blessing.equals("Berserker") && EntityStatHelper.hasStat(event.source.getEntity(), "BlessingActive") ? Boolean.parseBoolean(EntityStatHelper.getStat(event.source.getEntity(), "BlessingActive")) : false) { - damageMultiplier += 0.3F; - } else if(event.source.getEntity() instanceof EntityLivingBase && blessing.equals("Loner")) { - damageMultiplier += 0.35F * (1.0F - (((EntityLivingBase) event.source.getEntity()).getHealth() / ((EntityLivingBase) event.source.getEntity()).getMaxHealth())); - } - } - } - - event.ammount *= damageMultiplier; - - //System.out.println(event.ammount); - } - } - - public static ArrayList temp = new ArrayList(); - - public static void processItemStack(ItemStack stack, Random r) { - if(stack == null) {return;} - - temp.clear(); - - if(statTrackersByClass.containsKey(stack.getItem().getClass())) {temp.add(statTrackersByClass.get(stack.getItem().getClass()));} - if(statTrackersByID.containsKey(stack.getItem().itemID)) {temp.add(statTrackersByID.get(stack.getItem().itemID));} - - for(ItemStatTracker e : genericTrackers) { - if(!temp.contains(e)) { - for(Class c : e.classes) {if(c.isAssignableFrom(stack.getItem().getClass())) {temp.add(e); break;}} - } - } - - if(!temp.isEmpty()) { - if(!stack.hasTagCompound()) {stack.setTagCompound(new NBTTagCompound());} - - String processed = ItemStatHelper.getStat(stack, "processed"); - - if(processed == null || processed.equals("false")) { - stack.getTagCompound().setTag("Lore", new NBTTagList()); - - ItemStatHelper.giveStat(stack, "processed", "true"); - - for(ItemStatTracker statTracker : temp) { - for(ItemStat s : statTracker.stats) { - giveStat(stack, s.name, s.getNewValue(stack, r).toString()); - - String lore = s.getLore(stack); - if(lore != null) {addLore(stack, lore);} - - setName(stack, s.getAlteredStackName(stack, r)); - - s.modifyStack(stack, r); - } - } - } - } - - /*String stackName = getName(stack); - if(FyresWorldData.currentDisadvantage.equals("Illiterate")) { - if((stackName == null || !stackName.startsWith("\u00A7k"))) { - setName(stack, "\u00A7k" + (stackName == null ? stack.getDisplayName() : stackName)); - } - } else if(stackName != null && stackName.startsWith("\u00A7k")) { - setName(stack, stackName.replace("\u00A7k", "")); - }*/ - } - - @Override - public void onCrafting(EntityPlayer player, ItemStack item, IInventory craftMatrix) { - - if(!player.worldObj.isRemote) { - String itemName = null; - - if(item.getItem() != null && item.getItem() instanceof ItemSword || item.getItem() instanceof ItemBow || item.getItem() instanceof ItemAxe) {itemName = EntityStatHelper.getUnalteredItemName(item.getItem());} - - if(ModjamMod.enableCraftingStats && itemName != null) { - if(!player.getEntityData().hasKey("CraftingStats")) {player.getEntityData().setCompoundTag("CraftingStats", new NBTTagCompound());} - NBTTagCompound craftingStats = player.getEntityData().getCompoundTag("CraftingStats"); - if(!craftingStats.hasKey(itemName)) {craftingStats.setInteger(itemName, 0);} - craftingStats.setInteger(itemName, craftingStats.getInteger(itemName) + 1); - - for(int i = 0; i < EntityStatHelper.knowledge.length; i++) { - if(EntityStatHelper.killCount[i] == craftingStats.getInteger(itemName)) {PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7o\u00A73You've become a " + EntityStatHelper.knowledge[i].toLowerCase() + " " + itemName.toLowerCase() + " smith! (" + (i < EntityStatHelper.knowledge.length - 1 ? (EntityStatHelper.killCount[i + 1] * 2 - EntityStatHelper.killCount[i] * 2) + " " + itemName.toLowerCase() + " crafts to next rank." : "")}), (Player) player); break;} - } - - /*int count = 0; - - for(Object object : craftingStats.getTags()) { - if(object == null || !(object instanceof NBTBase)) {continue;} - if(craftingStats.getInteger(((NBTBase) object).getName()) >= EntityStatHelper.killCount[1]) {count++;} - } - - if(count >= 10) {player.triggerAchievement(ModjamMod.);}*/ - } - } - - /*if(player != null && !player.worldObj.isRemote) { - for(int i = 0; i < craftMatrix.getSizeInventory(); i++) { - ItemStack stack = craftMatrix.getStackInSlot(i); - - if(stack == null) {continue;} - - if(CommonTickHandler.worldData.currentTask.equals("Collect") && stack.getItem().itemID == CommonTickHandler.worldData.currentTaskID) { - CommonTickHandler.worldData.progress -= stack.stackSize; - - PacketDispatcher.sendPacketToAllPlayers(PacketHandler.newPacket(PacketHandler.UPDATE_WORLD_DATA, new Object[] {CommonTickHandler.worldData.potionValues, CommonTickHandler.worldData.potionDurations, CommonTickHandler.worldData.currentDisadvantage, CommonTickHandler.worldData.currentTask, CommonTickHandler.worldData.currentTaskID, CommonTickHandler.worldData.currentTaskAmount, CommonTickHandler.worldData.progress, CommonTickHandler.worldData.tasksCompleted, CommonTickHandler.worldData.enderDragonKilled, ModjamMod.spawnTraps})); - - CommonTickHandler.worldData.setDirty(true); - } - } - - if(CommonTickHandler.worldData.currentTask.equals("Collect") && item.getItem().itemID == CommonTickHandler.worldData.currentTaskID) { - CommonTickHandler.worldData.progress += item.stackSize; - - if(CommonTickHandler.worldData.progress >= CommonTickHandler.worldData.currentTaskAmount) { - CommonTickHandler.worldData.progress = 0; - CommonTickHandler.worldData.tasksCompleted++; - - CommonTickHandler.worldData.giveNewTask(); - - PacketDispatcher.sendPacketToAllPlayers(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7eA world goal has been completed!" + (!CommonTickHandler.worldData.currentDisadvantage.equals("None") ? " World disadvantage has been lifted!": "")})); - PacketDispatcher.sendPacketToAllPlayers(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7eA new world goal has been set: " + (CommonTickHandler.worldData.currentTask + " " + CommonTickHandler.worldData.currentTaskAmount + " " + (CommonTickHandler.worldData.currentTask.equals("Kill") ? FyresWorldData.validMobNames[CommonTickHandler.worldData.currentTaskID] : new ItemStack(Item.itemsList[CommonTickHandler.worldData.currentTaskID], 1).getDisplayName()) + (CommonTickHandler.worldData.currentTaskAmount > 1 ? "s. (" : ". (") + CommonTickHandler.worldData.progress + " " + CommonTickHandler.worldData.currentTask + "ed)")})); - - CommonTickHandler.worldData.currentDisadvantage = "None"; - } - - PacketDispatcher.sendPacketToAllPlayers(PacketHandler.newPacket(PacketHandler.UPDATE_WORLD_DATA, new Object[] {CommonTickHandler.worldData.potionValues, CommonTickHandler.worldData.potionDurations, CommonTickHandler.worldData.currentDisadvantage, CommonTickHandler.worldData.currentTask, CommonTickHandler.worldData.currentTaskID, CommonTickHandler.worldData.currentTaskAmount, CommonTickHandler.worldData.progress, CommonTickHandler.worldData.tasksCompleted, CommonTickHandler.worldData.enderDragonKilled, ModjamMod.spawnTraps})); - - CommonTickHandler.worldData.setDirty(true); - } - }*/ - } - - /*@Override - public void onSmelting(EntityPlayer player, ItemStack item) { - if(player != null && !player.worldObj.isRemote) { - if(CommonTickHandler.worldData.currentTask.equals("Collect") && item.getItem().itemID == CommonTickHandler.worldData.currentTaskID) { - CommonTickHandler.worldData.progress += item.stackSize; - - if(CommonTickHandler.worldData.progress >= CommonTickHandler.worldData.currentTaskAmount) { - CommonTickHandler.worldData.progress = 0; - CommonTickHandler.worldData.tasksCompleted++; - - CommonTickHandler.worldData.giveNewTask(); - - PacketDispatcher.sendPacketToAllPlayers(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7eA world goal has been completed!" + (!CommonTickHandler.worldData.currentDisadvantage.equals("None") ? " World disadvantage has been lifted!": "")})); - PacketDispatcher.sendPacketToAllPlayers(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7eA new world goal has been set: " + (CommonTickHandler.worldData.currentTask + " " + CommonTickHandler.worldData.currentTaskAmount + " " + (CommonTickHandler.worldData.currentTask.equals("Kill") ? FyresWorldData.validMobNames[CommonTickHandler.worldData.currentTaskID] : new ItemStack(Item.itemsList[CommonTickHandler.worldData.currentTaskID], 1).getDisplayName()) + "s. (" + CommonTickHandler.worldData.progress + " " + CommonTickHandler.worldData.currentTask + "ed)")})); - - CommonTickHandler.worldData.currentDisadvantage = "None"; - } - - PacketDispatcher.sendPacketToAllPlayers(PacketHandler.newPacket(PacketHandler.UPDATE_WORLD_DATA, new Object[] {CommonTickHandler.worldData.potionValues, CommonTickHandler.worldData.potionDurations, CommonTickHandler.worldData.currentDisadvantage, CommonTickHandler.worldData.currentTask, CommonTickHandler.worldData.currentTaskID, CommonTickHandler.worldData.currentTaskAmount, CommonTickHandler.worldData.progress, CommonTickHandler.worldData.tasksCompleted, CommonTickHandler.worldData.enderDragonKilled, ModjamMod.spawnTraps})); - - CommonTickHandler.worldData.setDirty(true); - } - } - }*/ - - public void register() { - MinecraftForge.EVENT_BUS.register(this); - GameRegistry.registerCraftingHandler(this); - } - - public void onSmelting(EntityPlayer player, ItemStack item) {} -} diff --git a/fyresmodjam/models/ModelCrystal.java b/fyresmodjam/models/ModelCrystal.java deleted file mode 100644 index 772455b..0000000 --- a/fyresmodjam/models/ModelCrystal.java +++ /dev/null @@ -1,81 +0,0 @@ -// Date: 12/13/2013 12:25:37 AM -// Template version 1.1 -// Java generated by Techne -// Keep in mind that you still need to fill in some blanks -// - ZeuX - -package fyresmodjam.models; - -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; -import net.minecraft.entity.Entity; - -public class ModelCrystal extends ModelBase -{ - //fields - ModelRenderer CrystalMain; - ModelRenderer CrystalEdge1; - ModelRenderer CrystalEdge2; - ModelRenderer CrystalTop1; - ModelRenderer CrystalTop2; - - public ModelCrystal() { - textureWidth = 64; - textureHeight = 32; - - CrystalMain = new ModelRenderer(this, 0, 0); - CrystalMain.addBox(0F, 0F, 0F, 5, 7, 5); - CrystalMain.setRotationPoint(-3F, 10F, -3F); - CrystalMain.setTextureSize(64, 32); - CrystalMain.mirror = true; - setRotation(CrystalMain, 0F, 0F, 0F); - CrystalEdge1 = new ModelRenderer(this, 0, 14); - CrystalEdge1.addBox(0F, 0F, 0F, 3, 1, 3); - CrystalEdge1.setRotationPoint(-2F, 9F, -2F); - CrystalEdge1.setTextureSize(64, 32); - CrystalEdge1.mirror = true; - setRotation(CrystalEdge1, 0F, 0F, 0F); - CrystalEdge2 = new ModelRenderer(this, 0, 14); - CrystalEdge2.addBox(0F, 0F, 0F, 3, 1, 3); - CrystalEdge2.setRotationPoint(-2F, 17F, -2F); - CrystalEdge2.setTextureSize(64, 32); - CrystalEdge2.mirror = true; - setRotation(CrystalEdge2, 0F, 0F, 0F); - CrystalTop1 = new ModelRenderer(this, 0, 12); - CrystalTop1.addBox(0F, 8F, 0F, 1, 1, 1); - CrystalTop1.setRotationPoint(-1F, 0F, -1F); - CrystalTop1.setTextureSize(64, 32); - CrystalTop1.mirror = true; - setRotation(CrystalTop1, 0F, 0F, 0F); - CrystalTop2 = new ModelRenderer(this, 0, 12); - CrystalTop2.addBox(-1F, 18F, -1F, 1, 1, 1); - CrystalTop2.setRotationPoint(0F, 0F, 0F); - CrystalTop2.setTextureSize(64, 32); - CrystalTop2.mirror = true; - setRotation(CrystalTop2, 0F, 0F, 0F); - } - - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - super.render(entity, f, f1, f2, f3, f4, f5); - setRotationAngles(f, f1, f2, f3, f4, f5, entity); - CrystalMain.render(f5); - CrystalEdge1.render(f5); - CrystalEdge2.render(f5); - CrystalTop1.render(f5); - CrystalTop2.render(f5); - - // TODO floating animation thing - } - - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } - - public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { - super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); - } - -} diff --git a/fyresmodjam/models/ModelCrystalStand.java b/fyresmodjam/models/ModelCrystalStand.java deleted file mode 100644 index 716a782..0000000 --- a/fyresmodjam/models/ModelCrystalStand.java +++ /dev/null @@ -1,58 +0,0 @@ -// Date: 12/13/2013 3:43:20 PM -// Template version 1.1 -// Java generated by Techne -// Keep in mind that you still need to fill in some blanks -// - ZeuX - -package fyresmodjam.models; - -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; -import net.minecraft.entity.Entity; - -public class ModelCrystalStand extends ModelBase -{ - //fields - ModelRenderer Shape1; - ModelRenderer Shape2; - - public ModelCrystalStand() - { - textureWidth = 64; - textureHeight = 64; - - Shape1 = new ModelRenderer(this, 0, 0); - Shape1.addBox(0F, 0F, 0F, 16, 4, 16); - Shape1.setRotationPoint(-8F, 20F, -8F); - Shape1.setTextureSize(64, 64); - Shape1.mirror = true; - setRotation(Shape1, 0F, 0F, 0F); - Shape2 = new ModelRenderer(this, 0, 20); - Shape2.addBox(0F, 0F, 0F, 10, 4, 10); - Shape2.setRotationPoint(-5F, 16F, -5F); - Shape2.setTextureSize(64, 64); - Shape2.mirror = true; - setRotation(Shape2, 0F, 0F, 0F); - } - - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) - { - super.render(entity, f, f1, f2, f3, f4, f5); - setRotationAngles(f, f1, f2, f3, f4, f5, entity); - Shape1.render(f5); - Shape2.render(f5); - } - - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } - - public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) - { - super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); - } - -} diff --git a/fyresmodjam/models/ModelPillar.java b/fyresmodjam/models/ModelPillar.java deleted file mode 100644 index a04227b..0000000 --- a/fyresmodjam/models/ModelPillar.java +++ /dev/null @@ -1,66 +0,0 @@ -// Date: 8/2/2013 9:09:39 AM -// Template version 1.1 -// Java generated by Techne -// Keep in mind that you still need to fill in some blanks -// - ZeuX - -package fyresmodjam.models; - -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; -import net.minecraft.entity.Entity; - -public class ModelPillar extends ModelBase -{ - //fields - ModelRenderer Shape1; - ModelRenderer Shape2; - ModelRenderer Shape3; - - public ModelPillar() - { - textureWidth = 64; - textureHeight = 64; - - Shape1 = new ModelRenderer(this, 0, 0); - Shape1.addBox(0F, 0F, 0F, 12, 26, 12); - Shape1.setRotationPoint(-6F, -2F, -6F); - Shape1.setTextureSize(64, 64); - Shape1.mirror = true; - setRotation(Shape1, 0F, 0F, 0F); - Shape2 = new ModelRenderer(this, 0, 38); - Shape2.addBox(0F, 0F, 0F, 10, 2, 10); - Shape2.setRotationPoint(-5F, -4F, -5F); - Shape2.setTextureSize(64, 64); - Shape2.mirror = true; - setRotation(Shape2, 0F, 0F, 0F); - Shape3 = new ModelRenderer(this, 0, 50); - Shape3.addBox(0F, 0F, 0F, 8, 2, 8); - Shape3.setRotationPoint(-4F, -6F, -4F); - Shape3.setTextureSize(64, 64); - Shape3.mirror = true; - setRotation(Shape3, 0F, 0F, 0F); - } - - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) - { - super.render(entity, f, f1, f2, f3, f4, f5); - setRotationAngles(f, f1, f2, f3, f4, f5, entity); - Shape1.render(f5); - Shape2.render(f5); - Shape3.render(f5); - } - - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } - - public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) - { - super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); - } - -} diff --git a/fyresmodjam/models/ModelSpikes.java b/fyresmodjam/models/ModelSpikes.java deleted file mode 100644 index 367733d..0000000 --- a/fyresmodjam/models/ModelSpikes.java +++ /dev/null @@ -1,305 +0,0 @@ -// Date: 8/3/2013 3:14:02 PM -// Template version 1.1 -// Java generated by Techne -// Keep in mind that you still need to fill in some blanks -// - ZeuX - -package fyresmodjam.models; - -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; -import net.minecraft.entity.Entity; - -public class ModelSpikes extends ModelBase { - //fields - ModelRenderer Shape1; - ModelRenderer Shape2; - ModelRenderer Shape3; - ModelRenderer Shape4; - ModelRenderer Shape5; - ModelRenderer Shape6; - ModelRenderer Shape7; - ModelRenderer Shape8; - ModelRenderer Shape9; - ModelRenderer Shape10; - ModelRenderer Shape12; - ModelRenderer Shape13; - ModelRenderer Shape11; - ModelRenderer Shape14; - ModelRenderer Shape15; - ModelRenderer Shape16; - ModelRenderer Shape17; - ModelRenderer Shape18; - ModelRenderer Shape19; - ModelRenderer Shape20; - ModelRenderer Shape21; - ModelRenderer Shape22; - ModelRenderer Shape23; - ModelRenderer Shape24; - ModelRenderer Shape25; - ModelRenderer Shape26; - ModelRenderer Shape27; - ModelRenderer Shape28; - ModelRenderer Shape29; - ModelRenderer Shape30; - ModelRenderer Shape31; - ModelRenderer Shape32; - ModelRenderer Shape33; - - public ModelSpikes() - { - textureWidth = 64; - textureHeight = 32; - - Shape1 = new ModelRenderer(this, 0, 5); - Shape1.addBox(0F, 0F, 0F, 14, 1, 13); - Shape1.setRotationPoint(-7F, 23F, -6.5F); - Shape1.setTextureSize(64, 32); - Shape1.mirror = true; - setRotation(Shape1, 0F, 0F, 0F); - Shape2 = new ModelRenderer(this, 0, 0); - Shape2.addBox(0F, 0F, 0F, 2, 3, 2); - Shape2.setRotationPoint(4F, 20F, 3.5F); - Shape2.setTextureSize(64, 32); - Shape2.mirror = true; - setRotation(Shape2, 0F, 0F, 0F); - Shape3 = new ModelRenderer(this, 0, 0); - Shape3.addBox(0F, 0F, 0F, 1, 3, 1); - Shape3.setRotationPoint(4.5F, 17F, 4F); - Shape3.setTextureSize(64, 32); - Shape3.mirror = true; - setRotation(Shape3, 0F, 0F, 0F); - Shape4 = new ModelRenderer(this, 0, 0); - Shape4.addBox(0F, 0F, 0F, 1, 3, 1); - Shape4.setRotationPoint(-5.5F, 17F, 4F); - Shape4.setTextureSize(64, 32); - Shape4.mirror = true; - setRotation(Shape4, 0F, 0F, 0F); - Shape5 = new ModelRenderer(this, 0, 0); - Shape5.addBox(0F, 0F, 0F, 2, 3, 2); - Shape5.setRotationPoint(-6F, 20F, 3.5F); - Shape5.setTextureSize(64, 32); - Shape5.mirror = true; - setRotation(Shape5, 0F, 0F, 0F); - Shape6 = new ModelRenderer(this, 0, 0); - Shape6.addBox(0F, 0F, 0F, 1, 3, 1); - Shape6.setRotationPoint(-2.5F, 17F, 4F); - Shape6.setTextureSize(64, 32); - Shape6.mirror = true; - setRotation(Shape6, 0F, 0F, 0F); - Shape7 = new ModelRenderer(this, 0, 0); - Shape7.addBox(0F, 0F, 0F, 2, 3, 2); - Shape7.setRotationPoint(-3F, 20F, 3.5F); - Shape7.setTextureSize(64, 32); - Shape7.mirror = true; - setRotation(Shape7, 0F, 0F, 0F); - Shape8 = new ModelRenderer(this, 0, 0); - Shape8.addBox(0F, 0F, 0F, 2, 3, 2); - Shape8.setRotationPoint(0.4666667F, 20F, 3.5F); - Shape8.setTextureSize(64, 32); - Shape8.mirror = true; - setRotation(Shape8, 0F, 0F, 0F); - Shape9 = new ModelRenderer(this, 0, 0); - Shape9.addBox(0F, 0F, 0F, 1, 3, 1); - Shape9.setRotationPoint(1F, 17F, 4F); - Shape9.setTextureSize(64, 32); - Shape9.mirror = true; - setRotation(Shape9, 0F, 0F, 0F); - Shape10 = new ModelRenderer(this, 0, 0); - Shape10.addBox(0F, 0F, 0F, 2, 3, 2); - Shape10.setRotationPoint(-3F, 20F, -5.5F); - Shape10.setTextureSize(64, 32); - Shape10.mirror = true; - setRotation(Shape10, 0F, 0F, 0F); - Shape12 = new ModelRenderer(this, 0, 0); - Shape12.addBox(0F, 0F, 0F, 2, 3, 2); - Shape12.setRotationPoint(-6F, 20F, -5.5F); - Shape12.setTextureSize(64, 32); - Shape12.mirror = true; - setRotation(Shape12, 0F, 0F, 0F); - Shape13 = new ModelRenderer(this, 0, 0); - Shape13.addBox(0F, 0F, 0F, 1, 3, 1); - Shape13.setRotationPoint(-5.5F, 17F, -5F); - Shape13.setTextureSize(64, 32); - Shape13.mirror = true; - setRotation(Shape13, 0F, 0F, 0F); - Shape11 = new ModelRenderer(this, 0, 0); - Shape11.addBox(0F, 0F, 0F, 1, 3, 1); - Shape11.setRotationPoint(-2.5F, 17F, -5F); - Shape11.setTextureSize(64, 32); - Shape11.mirror = true; - setRotation(Shape11, 0F, 0F, 0F); - Shape14 = new ModelRenderer(this, 0, 0); - Shape14.addBox(0F, 0F, 0F, 2, 3, 2); - Shape14.setRotationPoint(0.4666667F, 20F, -5.5F); - Shape14.setTextureSize(64, 32); - Shape14.mirror = true; - setRotation(Shape14, 0F, 0F, 0F); - Shape15 = new ModelRenderer(this, 0, 0); - Shape15.addBox(0F, 0F, 0F, 1, 3, 1); - Shape15.setRotationPoint(1F, 17F, -5F); - Shape15.setTextureSize(64, 32); - Shape15.mirror = true; - setRotation(Shape15, 0F, 0F, 0F); - Shape16 = new ModelRenderer(this, 0, 0); - Shape16.addBox(0F, 0F, 0F, 2, 3, 2); - Shape16.setRotationPoint(4F, 20F, -5.5F); - Shape16.setTextureSize(64, 32); - Shape16.mirror = true; - setRotation(Shape16, 0F, 0F, 0F); - Shape17 = new ModelRenderer(this, 0, 0); - Shape17.addBox(0F, 0F, 0F, 1, 3, 1); - Shape17.setRotationPoint(4.5F, 17F, -5F); - Shape17.setTextureSize(64, 32); - Shape17.mirror = true; - setRotation(Shape17, 0F, 0F, 0F); - Shape18 = new ModelRenderer(this, 0, 0); - Shape18.addBox(0F, 0F, 0F, 2, 3, 2); - Shape18.setRotationPoint(-3F, 20F, -2.5F); - Shape18.setTextureSize(64, 32); - Shape18.mirror = true; - setRotation(Shape18, 0F, 0F, 0F); - Shape19 = new ModelRenderer(this, 0, 0); - Shape19.addBox(0F, 0F, 0F, 2, 3, 2); - Shape19.setRotationPoint(-6F, 20F, -2.5F); - Shape19.setTextureSize(64, 32); - Shape19.mirror = true; - setRotation(Shape19, 0F, 0F, 0F); - Shape20 = new ModelRenderer(this, 0, 0); - Shape20.addBox(0F, 0F, 0F, 1, 3, 1); - Shape20.setRotationPoint(-5.5F, 17F, -2F); - Shape20.setTextureSize(64, 32); - Shape20.mirror = true; - setRotation(Shape20, 0F, 0F, 0F); - Shape21 = new ModelRenderer(this, 0, 0); - Shape21.addBox(0F, 0F, 0F, 1, 3, 1); - Shape21.setRotationPoint(-2.5F, 17F, -2F); - Shape21.setTextureSize(64, 32); - Shape21.mirror = true; - setRotation(Shape21, 0F, 0F, 0F); - Shape22 = new ModelRenderer(this, 0, 0); - Shape22.addBox(0F, 0F, 0F, 2, 3, 2); - Shape22.setRotationPoint(0.4666667F, 20F, -2.5F); - Shape22.setTextureSize(64, 32); - Shape22.mirror = true; - setRotation(Shape22, 0F, 0F, 0F); - Shape23 = new ModelRenderer(this, 0, 0); - Shape23.addBox(0F, 0F, 0F, 1, 3, 1); - Shape23.setRotationPoint(1F, 17F, -2F); - Shape23.setTextureSize(64, 32); - Shape23.mirror = true; - setRotation(Shape23, 0F, 0F, 0F); - Shape24 = new ModelRenderer(this, 0, 0); - Shape24.addBox(0F, 0F, 0F, 2, 3, 2); - Shape24.setRotationPoint(4F, 20F, -2.5F); - Shape24.setTextureSize(64, 32); - Shape24.mirror = true; - setRotation(Shape24, 0F, 0F, 0F); - Shape25 = new ModelRenderer(this, 0, 0); - Shape25.addBox(0F, 0F, 0F, 1, 3, 1); - Shape25.setRotationPoint(4.5F, 17F, -2F); - Shape25.setTextureSize(64, 32); - Shape25.mirror = true; - setRotation(Shape25, 0F, 0F, 0F); - Shape26 = new ModelRenderer(this, 0, 0); - Shape26.addBox(0F, 0F, 0F, 2, 3, 2); - Shape26.setRotationPoint(-3F, 20F, 0.5F); - Shape26.setTextureSize(64, 32); - Shape26.mirror = true; - setRotation(Shape26, 0F, 0F, 0F); - Shape27 = new ModelRenderer(this, 0, 0); - Shape27.addBox(0F, 0F, 0F, 2, 3, 2); - Shape27.setRotationPoint(-6F, 20F, 0.5F); - Shape27.setTextureSize(64, 32); - Shape27.mirror = true; - setRotation(Shape27, 0F, 0F, 0F); - Shape28 = new ModelRenderer(this, 0, 0); - Shape28.addBox(0F, 0F, 0F, 1, 3, 1); - Shape28.setRotationPoint(-5.5F, 17F, 1F); - Shape28.setTextureSize(64, 32); - Shape28.mirror = true; - setRotation(Shape28, 0F, 0F, 0F); - Shape29 = new ModelRenderer(this, 0, 0); - Shape29.addBox(0F, 0F, 0F, 1, 3, 1); - Shape29.setRotationPoint(-2.5F, 17F, 1F); - Shape29.setTextureSize(64, 32); - Shape29.mirror = true; - setRotation(Shape29, 0F, 0F, 0F); - Shape30 = new ModelRenderer(this, 0, 0); - Shape30.addBox(0F, 0F, 0F, 2, 3, 2); - Shape30.setRotationPoint(0.4666667F, 20F, 0.5F); - Shape30.setTextureSize(64, 32); - Shape30.mirror = true; - setRotation(Shape30, 0F, 0F, 0F); - Shape31 = new ModelRenderer(this, 0, 0); - Shape31.addBox(0F, 0F, 0F, 1, 3, 1); - Shape31.setRotationPoint(1F, 17F, 1F); - Shape31.setTextureSize(64, 32); - Shape31.mirror = true; - setRotation(Shape31, 0F, 0F, 0F); - Shape32 = new ModelRenderer(this, 0, 0); - Shape32.addBox(0F, 0F, 0F, 2, 3, 2); - Shape32.setRotationPoint(4F, 20F, 0.5F); - Shape32.setTextureSize(64, 32); - Shape32.mirror = true; - setRotation(Shape32, 0F, 0F, 0F); - Shape33 = new ModelRenderer(this, 0, 0); - Shape33.addBox(0F, 0F, 0F, 1, 3, 1); - Shape33.setRotationPoint(4.5F, 17F, 1F); - Shape33.setTextureSize(64, 32); - Shape33.mirror = true; - setRotation(Shape33, 0F, 0F, 0F); - } - - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) - { - super.render(entity, f, f1, f2, f3, f4, f5); - setRotationAngles(f, f1, f2, f3, f4, f5, entity); - Shape1.render(f5); - Shape2.render(f5); - Shape3.render(f5); - Shape4.render(f5); - Shape5.render(f5); - Shape6.render(f5); - Shape7.render(f5); - Shape8.render(f5); - Shape9.render(f5); - Shape10.render(f5); - Shape12.render(f5); - Shape13.render(f5); - Shape11.render(f5); - Shape14.render(f5); - Shape15.render(f5); - Shape16.render(f5); - Shape17.render(f5); - Shape18.render(f5); - Shape19.render(f5); - Shape20.render(f5); - Shape21.render(f5); - Shape22.render(f5); - Shape23.render(f5); - Shape24.render(f5); - Shape25.render(f5); - Shape26.render(f5); - Shape27.render(f5); - Shape28.render(f5); - Shape29.render(f5); - Shape30.render(f5); - Shape31.render(f5); - Shape32.render(f5); - Shape33.render(f5); - } - - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } - - public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) - { - super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); - } - -} diff --git a/fyresmodjam/models/ModelTrap2.java b/fyresmodjam/models/ModelTrap2.java deleted file mode 100644 index b4bda64..0000000 --- a/fyresmodjam/models/ModelTrap2.java +++ /dev/null @@ -1,82 +0,0 @@ -// Date: 8/4/2013 9:26:07 AM -// Template version 1.1 -// Java generated by Techne -// Keep in mind that you still need to fill in some blanks -// - ZeuX - -package fyresmodjam.models; - -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; -import net.minecraft.entity.Entity; - -public class ModelTrap2 extends ModelBase -{ - //fields - ModelRenderer Shape1; - ModelRenderer Shape22; - ModelRenderer Shape26; - ModelRenderer Shape30; - ModelRenderer Shape27; - - public ModelTrap2() - { - textureWidth = 64; - textureHeight = 32; - - Shape1 = new ModelRenderer(this, 0, 6); - Shape1.addBox(0F, 0F, 0F, 14, 1, 14); - Shape1.setRotationPoint(-7F, 23F, -7F); - Shape1.setTextureSize(64, 32); - Shape1.mirror = true; - setRotation(Shape1, 0F, 0F, 0F); - Shape22 = new ModelRenderer(this, 0, 0); - Shape22.addBox(0F, 0F, 0F, 3, 2, 1); - Shape22.setRotationPoint(-2.033333F, 21F, -2F); - Shape22.setTextureSize(64, 32); - Shape22.mirror = true; - setRotation(Shape22, 0F, 0F, 0F); - Shape26 = new ModelRenderer(this, 0, 0); - Shape26.addBox(0F, 0F, 0F, 1, 2, 4); - Shape26.setRotationPoint(1F, 21F, -2F); - Shape26.setTextureSize(64, 32); - Shape26.mirror = true; - setRotation(Shape26, 0F, 0F, 0F); - Shape30 = new ModelRenderer(this, 0, 0); - Shape30.addBox(0F, 0F, 0F, 3, 2, 1); - Shape30.setRotationPoint(-2.033333F, 21F, 1F); - Shape30.setTextureSize(64, 32); - Shape30.mirror = true; - setRotation(Shape30, 0F, 0F, 0F); - Shape27 = new ModelRenderer(this, 0, 0); - Shape27.addBox(0F, 0F, 0F, 1, 2, 2); - Shape27.setRotationPoint(-2F, 21F, -1F); - Shape27.setTextureSize(64, 32); - Shape27.mirror = true; - setRotation(Shape27, 0F, 0F, 0F); - } - - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) - { - super.render(entity, f, f1, f2, f3, f4, f5); - setRotationAngles(f, f1, f2, f3, f4, f5, entity); - Shape1.render(f5); - Shape22.render(f5); - Shape26.render(f5); - Shape30.render(f5); - Shape27.render(f5); - } - - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } - - public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) - { - super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); - } - -} diff --git a/fyresmodjam/tileentities/TileEntityPillar.java b/fyresmodjam/tileentities/TileEntityPillar.java deleted file mode 100644 index 85f59e1..0000000 --- a/fyresmodjam/tileentities/TileEntityPillar.java +++ /dev/null @@ -1,74 +0,0 @@ -package fyresmodjam.tileentities; - -import net.minecraft.client.Minecraft; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.INetworkManager; -import net.minecraft.network.packet.Packet; -import net.minecraft.network.packet.Packet132TileEntityData; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.AxisAlignedBB; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import fyresmodjam.ModjamMod; - -public class TileEntityPillar extends TileEntity { - - public static String[] validBlessings = {"Miner", "Lumberjack", "Warrior", "Hunter", "Swamp", "Thief", "Ninja", "Mechanic", "Alchemist", "Scout", "Guardian"/*, "Healer"*/, "Vampire", "Inferno", "Diver", "Berserker", "Loner", "Paratrooper", "Porcupine"}; - public static String[] blessingDescriptions = {"+25% breaking speed on stone and iron blocks, and +20% damage with pickaxes", "+25% breaking speed on wooden blocks, and +15% damage with axes", "+20% melee damage", "+20% projectile damage", "Attacks will slow enemies", "Enemies have a chance to drop gold nuggets", "While sneaking you are invisble and attacks on enemies with full health do double damage", "@@\u00A7ePASSIVE - \u00A7oYou disarm traps 3x as often and have 2x the chance to salvage disarmed traps.@@\u00A7eACTIVE - \u00A7oOnce per day, you may disarm and salvage target trap for free.", "All potions act like wildcard potions", "You can see traps without sneaking, but take 25% more damage from traps", "Take 20% less damage from all sources"/*, "2x healing rate"*/, "Heal 7% of damage dealt to enemies and, in direct sunlight, you take 20% more damage and deal 20% less damage", "You don't take fire damage, do +35% damage while on fire, and take damage when wet", "You can breathe underwater", "@@\u00A7ePASSIVE - \u00A7oKills are added to berserk counter. (10 max)@@\u00A7eACTIVE - \u00A7oTurn on/off berserk mode. While berserk mode is active, you do 30% more damage, and berserk counter ticks down every 2 seconds", "The lower your health, the higher your damage, to a maximum of +35%", "You don't take fall damage", "Melee attackers take receive damage"}; - - public String blessing = null; - - public TileEntityPillar() {} - - public void updateEntity() { - super.updateEntity(); - - if(worldObj.isRemote) { - /*EntityPlayer player = ; - - if(player != null && player.getEntityData().hasKey("Blessing") && player.getEntityData().getString("Blessing").equals(blessing)) { - for(int i = 0; i < 2; i++) {this.worldObj.spawnParticle("portal", this.xCoord + ModjamMod.r.nextDouble(), this.yCoord + ModjamMod.r.nextDouble() * 2, this.zCoord + ModjamMod.r.nextDouble(), (ModjamMod.r.nextDouble() - 0.5D) * 2.0D, -ModjamMod.r.nextDouble(), (ModjamMod.r.nextDouble() - 0.5D) * 2.0D);} - }*/ - - spawnParticles(); - - if(ModjamMod.pillarGlow) {this.worldObj.updateAllLightTypes(this.xCoord, this.yCoord, this.zCoord);} - } - } - - @SideOnly(Side.CLIENT) - public void spawnParticles() { - EntityPlayer player = Minecraft.getMinecraft().thePlayer; - - if(player != null && player.getEntityData().hasKey("Blessing") && player.getEntityData().getString("Blessing").equals(blessing)) { - for(int i = 0; i < 2; i++) {this.worldObj.spawnParticle("portal", this.xCoord + ModjamMod.r.nextDouble(), this.yCoord + ModjamMod.r.nextDouble() * 2, this.zCoord + ModjamMod.r.nextDouble(), (ModjamMod.r.nextDouble() - 0.5D) * 2.0D, -ModjamMod.r.nextDouble(), (ModjamMod.r.nextDouble() - 0.5D) * 2.0D);} - } - } - - public void writeToNBT(NBTTagCompound par1NBTTagCompound) { - super.writeToNBT(par1NBTTagCompound); - if(blessing == null) {this.blessing = validBlessings[ModjamMod.r.nextInt(validBlessings.length)];} - par1NBTTagCompound.setString("Blessing", blessing); - } - - public void readFromNBT(NBTTagCompound par1NBTTagCompound) { - super.readFromNBT(par1NBTTagCompound); - blessing = par1NBTTagCompound.hasKey("Blessing") ? par1NBTTagCompound.getString("Blessing") : validBlessings[ModjamMod.r.nextInt(validBlessings.length)]; - } - - public Packet getDescriptionPacket() { - NBTTagCompound tag = new NBTTagCompound(); - this.writeToNBT(tag); - return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 1, tag); - } - - public void onDataPacket(INetworkManager net, Packet132TileEntityData packet) {this.readFromNBT(packet.data);} - - @SideOnly(Side.CLIENT) - public AxisAlignedBB getRenderBoundingBox() { - //fixes rendering bug, but on downside, always renders, even off screen - return INFINITE_EXTENT_AABB; - } -} \ No newline at end of file diff --git a/fyresmodjam/tileentities/TileEntityTrap.java b/fyresmodjam/tileentities/TileEntityTrap.java deleted file mode 100644 index f65547d..0000000 --- a/fyresmodjam/tileentities/TileEntityTrap.java +++ /dev/null @@ -1,91 +0,0 @@ -package fyresmodjam.tileentities; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.tileentity.TileEntityRenderer; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.INetworkManager; -import net.minecraft.network.packet.Packet; -import net.minecraft.network.packet.Packet132TileEntityData; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.AxisAlignedBB; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import fyresmodjam.ModjamMod; -import fyresmodjam.handlers.PacketHandler; - -public class TileEntityTrap extends TileEntity { - - public static String[] settings = {"invisible to and damages all but player", "visible to all and damages all but player", "visible to all and only damages mobs", "decorative"}; - - //public int type = -1; - public String placedBy = null; - public int setting = 0; - - public TileEntityTrap() {} - - /*public void updateEntity() { - super.updateEntity(); - }*/ - - public void updateEntity() { - super.updateEntity(); - - if(worldObj.isRemote) {spawnParticles();} - } - - public void writeToNBT(NBTTagCompound par1NBTTagCompound) { - super.writeToNBT(par1NBTTagCompound); - - //if(type == -1) {type = ModjamMod.r.nextInt(4);} - //par1NBTTagCompound.setInteger("TrapType", type); - - if(placedBy != null) {par1NBTTagCompound.setString("PlacedBy", placedBy);} - par1NBTTagCompound.setInteger("Setting", setting % settings.length); - } - - public void readFromNBT(NBTTagCompound par1NBTTagCompound) { - super.readFromNBT(par1NBTTagCompound); - //type = par1NBTTagCompound.getInteger("TrapType"); - - if(par1NBTTagCompound.hasKey("PlacedBy")) {placedBy = par1NBTTagCompound.getString("PlacedBy");} else {placedBy = null;} - if(par1NBTTagCompound.hasKey("Setting")) {setting = par1NBTTagCompound.getInteger("Setting") % settings.length;} - } - - public Packet getDescriptionPacket() { - NBTTagCompound tag = new NBTTagCompound(); - this.writeToNBT(tag); - return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 1, tag); - } - - public void onDataPacket(INetworkManager net, Packet132TileEntityData packet) {this.readFromNBT(packet.data);} - - @SideOnly(Side.CLIENT) - public AxisAlignedBB getRenderBoundingBox() { - //fixes rendering bug, but on downside, always renders, even off screen - return INFINITE_EXTENT_AABB; - } - - @SideOnly(Side.CLIENT) - public double getMaxRenderDistanceSquared() { - EntityPlayer player = Minecraft.getMinecraft().thePlayer; - //EntityPlayer player = Minecraft.getMinecraft().thePlayer; - return (player != null && (player.getEntityName().equals(placedBy) || setting != 0)) ? 4096.0F: 36.0F; //(player != null && player.getEntityData().hasKey("Blessing") && player.getEntityData().getString("Blessing").equals("Scout")) ? 16.0D : 36.0D; - } - - @SideOnly(Side.CLIENT) - public void spawnParticles() { - EntityPlayer player = Minecraft.getMinecraft().thePlayer; - int type = this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord); - - if(player != null && (!PacketHandler.trapsDisabled || placedBy != null) && (player.getEntityName().equals(placedBy) || player.isSneaking() || setting != 0 || (player.getEntityData().hasKey("Blessing") && player.getEntityData().getString("Blessing").equals("Scout"))) && this.getDistanceFrom(TileEntityRenderer.staticPlayerX, TileEntityRenderer.staticPlayerY, TileEntityRenderer.staticPlayerZ) < (player.getEntityName().equals(placedBy) ? 4096 : 36.0F)) { - if(type == 1) { - if(ModjamMod.r.nextInt(5) == 0) {this.worldObj.spawnParticle("smoke", this.xCoord + 0.5F, this.yCoord + 0.175F, this.zCoord + 0.5F, (ModjamMod.r.nextFloat() - 0.5F)/16, ModjamMod.r.nextFloat()/16, (ModjamMod.r.nextFloat() - 0.5F)/16);} - this.worldObj.spawnParticle("flame", this.xCoord + 0.5F, this.yCoord + 0.175F, this.zCoord + 0.5F, 0.0F, 0.0F, 0.0F); - } else if(type == 2) { - for(int i = 0; i < 3; i++) {this.worldObj.spawnParticle("smoke", this.xCoord + 0.5F, this.yCoord + 0.175F, this.zCoord + 0.5F, (ModjamMod.r.nextFloat() - 0.5F)/16, ModjamMod.r.nextFloat()/16, (ModjamMod.r.nextFloat() - 0.5F)/16);} - } - } - } -} \ No newline at end of file diff --git a/fyresmodjam/tileentities/renderers/TileEntityPillarRenderer.java b/fyresmodjam/tileentities/renderers/TileEntityPillarRenderer.java deleted file mode 100644 index e6f4d8c..0000000 --- a/fyresmodjam/tileentities/renderers/TileEntityPillarRenderer.java +++ /dev/null @@ -1,62 +0,0 @@ -package fyresmodjam.tileentities.renderers; - -import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.client.model.ModelSign; -import net.minecraft.client.renderer.OpenGlHelper; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import org.lwjgl.opengl.GL11; - -import fyresmodjam.ModjamMod; -import fyresmodjam.models.ModelPillar; -import fyresmodjam.tileentities.TileEntityPillar; - - -public class TileEntityPillarRenderer extends TileEntitySpecialRenderer -{ - private ModelPillar modelPillar = new ModelPillar(); - - public static ResourceLocation[] textures = { - new ResourceLocation("fyresmodjam", "textures/blocks/pillar.png"), - new ResourceLocation("fyresmodjam", "textures/blocks/pillarActive.png") - }; - - public void renderTileEntityAt(TileEntity tileEntity, double d, double d1, double d2, float f) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)d, (float)d1, (float)d2); - TileEntityPillar tileEntityYour = (TileEntityPillar) tileEntity; - renderBlockYour(tileEntityYour, tileEntity.worldObj, tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, ModjamMod.blockPillar); - GL11.glPopMatrix(); - } - - public void renderBlockYour(TileEntityPillar tl, World world, int i, int j, int k, Block block) - { - Tessellator tessellator = Tessellator.instance; - float f = block.getBlockBrightness(world, i, j, k); - int l = world.getLightBrightnessForSkyBlocks(i, j, k, 0); - int l1 = l % 65536; - int l2 = l / 65536; - tessellator.setColorOpaque_F(f, f, f); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)l1, (float)l2); - - EntityPlayer player = Minecraft.getMinecraft().thePlayer; - boolean active = player != null && player.getEntityData().hasKey("Blessing") && player.getEntityData().getString("Blessing").equals(tl.blessing); - - GL11.glPushMatrix(); - - GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F); - GL11.glTranslatef(0.5F, -1.5F, -0.5F); - - this.tileEntityRenderer.renderEngine.bindTexture(!active ? textures[0] : textures[1]); - this.modelPillar.render((Entity) null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F); - GL11.glPopMatrix(); - } -} \ No newline at end of file diff --git a/fyresmodjam/tileentities/renderers/TileEntityTrapRenderer.java b/fyresmodjam/tileentities/renderers/TileEntityTrapRenderer.java deleted file mode 100644 index 4b30ce6..0000000 --- a/fyresmodjam/tileentities/renderers/TileEntityTrapRenderer.java +++ /dev/null @@ -1,72 +0,0 @@ -package fyresmodjam.tileentities.renderers; - -import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelSign; -import net.minecraft.client.renderer.OpenGlHelper; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import org.lwjgl.opengl.GL11; - -import fyresmodjam.ModjamMod; -import fyresmodjam.blocks.BlockTrap; -import fyresmodjam.handlers.PacketHandler; -import fyresmodjam.models.ModelSpikes; -import fyresmodjam.models.ModelTrap2; -import fyresmodjam.tileentities.TileEntityTrap; - - -public class TileEntityTrapRenderer extends TileEntitySpecialRenderer { - - private ModelBase[] models = {new ModelSpikes(), new ModelTrap2(), new ModelTrap2()}; - - public static ResourceLocation[] textures = {new ResourceLocation("fyresmodjam", "textures/blocks/spikes.png"), new ResourceLocation("fyresmodjam", "textures/blocks/trap2.png"), new ResourceLocation("fyresmodjam", "textures/blocks/trap3.png")}; - - public void renderTileEntityAt(TileEntity tileEntity, double d, double d1, double d2, float f) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)d, (float)d1, (float)d2); - TileEntityTrap tileEntityYour = (TileEntityTrap) tileEntity; - renderBlockYour(tileEntityYour, tileEntity.worldObj, tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, ModjamMod.blockTrap); - GL11.glPopMatrix(); - } - - public void renderBlockYour(TileEntityTrap tl, World world, int i, int j, int k, Block block) { - Tessellator tessellator = Tessellator.instance; - float f = block.getBlockBrightness(world, i, j, k); - int l = world.getLightBrightnessForSkyBlocks(i, j, k, 0); - int l1 = l % 65536; - int l2 = l / 65536; - tessellator.setColorOpaque_F(f, f, f); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)l1, (float)l2); - - EntityPlayer player = Minecraft.getMinecraft().thePlayer; - boolean active = player != null && (!PacketHandler.trapsDisabled || tl.placedBy != null) && (player.getEntityName().equals(tl.placedBy) || tl.setting != 0 || player.isSneaking() || (player.getEntityData().hasKey("Blessing") && player.getEntityData().getString("Blessing").equals("Scout"))); - - int type = world.getBlockMetadata(i, j, k); - - if(active) { - GL11.glPushMatrix(); - - //GL11.glEnable(GL11.GL_BLEND); - //GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - - GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F); - GL11.glTranslatef(0.5F, -1.5F, -0.5F); - - this.tileEntityRenderer.renderEngine.bindTexture(textures[type % BlockTrap.trapTypes]); - this.models[type % BlockTrap.trapTypes].render((Entity) null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F); - - //GL11.glDisable(GL11.GL_BLEND); - - GL11.glPopMatrix(); - } - } -} \ No newline at end of file diff --git a/fyresmodjam/worldgen/PillarGen.java b/fyresmodjam/worldgen/PillarGen.java deleted file mode 100644 index 3376d26..0000000 --- a/fyresmodjam/worldgen/PillarGen.java +++ /dev/null @@ -1,47 +0,0 @@ -package fyresmodjam.worldgen; - -import java.util.Random; - - -import net.minecraft.block.Block; -import net.minecraft.world.World; -import net.minecraft.world.chunk.IChunkProvider; -import net.minecraft.world.gen.feature.WorldGenMinable; -import cpw.mods.fml.common.IWorldGenerator; -import fyresmodjam.ModjamMod; - -public class PillarGen implements IWorldGenerator { - @Override - public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { - if(ModjamMod.spawnRandomPillars && world.provider.dimensionId == 0 && random.nextInt(ModjamMod.pillarGenChance) == 0) { - boolean placed = false; - - int max = random.nextInt(ModjamMod.maxPillarsPerChunk) + 1; - - for(int y = 127, added = 0; y > 30 && !placed && added < max; y--) { - for(int x = chunkX * 16; x < chunkX * 16 + 16 && !placed && added < max; x++) { - for(int z = chunkZ * 16; z < chunkZ * 16 + 16 && !placed && added < max; z++) { - if(random.nextInt(15) != 0 || world.isAirBlock(x, y, z) || Block.blocksList[world.getBlockId(x, y, z)].isBlockReplaceable(world, x, y, z) || world.getBlockId(x, y, z) == ModjamMod.blockTrap.blockID || world.getBlockId(x, y, z) == Block.leaves.blockID) {continue;} - - Block block = ModjamMod.blockPillar; - - if(block.canPlaceBlockAt(world, x, y + 1, z)) { - world.setBlock(x, y + 1, z, block.blockID); - world.setBlockMetadataWithNotify(x, y + 1, z, 0, 0); - - world.setBlock(x, y + 2, z, block.blockID); - world.setBlockMetadataWithNotify(x, y + 2, z, 1, 0); - - placed = random.nextBoolean(); - - y -= 10; - added++; - - //System.out.println(x + ", " + y + ", " + z); - } - } - } - } - } - } -} diff --git a/fyresmodjam/worldgen/WorldGenTrapsTowersAndMore.java b/fyresmodjam/worldgen/WorldGenTrapsTowersAndMore.java deleted file mode 100644 index 6fd31f8..0000000 --- a/fyresmodjam/worldgen/WorldGenTrapsTowersAndMore.java +++ /dev/null @@ -1,159 +0,0 @@ -package fyresmodjam.worldgen; - -import java.util.Random; - - -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import net.minecraft.tileentity.TileEntityChest; -import net.minecraft.tileentity.TileEntityMobSpawner; -import net.minecraft.util.WeightedRandomChestContent; -import net.minecraft.world.World; -import net.minecraft.world.chunk.IChunkProvider; -import net.minecraftforge.common.ChestGenHooks; -import net.minecraftforge.common.DungeonHooks; -import cpw.mods.fml.common.IWorldGenerator; -import fyresmodjam.ModjamMod; -import fyresmodjam.blocks.BlockTrap; - -public class WorldGenTrapsTowersAndMore implements IWorldGenerator { - - public static final WeightedRandomChestContent[] field_111189_a = new WeightedRandomChestContent[] { - new WeightedRandomChestContent(Item.ingotIron.itemID, 0, 1, 4, 10), - new WeightedRandomChestContent(Item.bread.itemID, 0, 1, 1, 10), - new WeightedRandomChestContent(Item.wheat.itemID, 0, 1, 4, 10), - new WeightedRandomChestContent(Item.gunpowder.itemID, 0, 1, 4, 10), - new WeightedRandomChestContent(Item.silk.itemID, 0, 1, 4, 10), - new WeightedRandomChestContent(Item.bucketEmpty.itemID, 0, 1, 1, 10), - new WeightedRandomChestContent(Item.redstone.itemID, 0, 1, 4, 10), - new WeightedRandomChestContent(Item.nameTag.itemID, 0, 1, 1, 10), - }; - - public static boolean genning = false; - - public static final String TOWER_CHESTS = "towerChests"; - - public static ChestGenHooks chestGenInfo = new ChestGenHooks(TOWER_CHESTS, field_111189_a, 8, 8); - - @Override - public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { - - genning = true; - - boolean addedDungeon = !ModjamMod.spawnTowers || random.nextInt(ModjamMod.towerGenChance) != 0; - - for(int y = 1; y < 127; y++) { - for(int x = chunkX * 16; x < chunkX * 16 + 16; x++) { - for(int z = chunkZ * 16; z < chunkZ * 16 + 16; z++) { - if((world.isAirBlock(x, y, z) || (Block.blocksList[world.getBlockId(x, y, z)].isBlockReplaceable(world, x, y, z) && world.getBlockId(x, y, z) != Block.waterStill.blockID && world.getBlockId(x, y, z) != Block.waterMoving.blockID && world.getBlockId(x, y, z) != Block.lavaStill.blockID && world.getBlockId(x, y, z) != Block.lavaMoving.blockID)) && (!world.isAirBlock(x, y - 1, z) && world.getBlockId(x, y - 1, z) != ModjamMod.blockTrap.blockID && !Block.blocksList[world.getBlockId(x, y - 1, z)].isBlockReplaceable(world, x, y - 1, z)) && random.nextInt(ModjamMod.trapGenChance) == 0) { - boolean skip = ModjamMod.trapsBelowGroundOnly && (world.getBlockId(x, y - 1, z) == Block.grass.blockID || world.getBlockId(x, y - 1, z) == Block.sand.blockID || world.getBlockId(x, y - 1, z) == Block.wood.blockID || world.canBlockSeeTheSky(x, y, z)); - if(!skip && ModjamMod.blockTrap.canPlaceBlockAt(world, x, y, z)) {world.setBlock(x, y, z, ModjamMod.blockTrap.blockID, random.nextInt(BlockTrap.trapTypes), 0);} - } - - if((world.getBlockId(x, y, z) == Block.mushroomBrown.blockID || world.getBlockId(x, y, z) == Block.mushroomRed.blockID) && random.nextInt(ModjamMod.mushroomReplaceChance) == 0) { - world.setBlock(x, y, z, ModjamMod.mysteryMushroomBlock.blockID, random.nextInt(13), 0); - } - - if(!addedDungeon && ((world.getBlockId(x, y, z) == Block.grass.blockID || ((world.getBlockId(x, y, z) == Block.sand.blockID || world.getBlockId(x, y, z) == Block.netherrack.blockID || world.getBlockId(x, y, z) == Block.slowSand.blockID || world.getBlockId(x, y, z) == Block.gravel.blockID) && world.isAirBlock(x, y + 1, z)))) && world.getBlockId(x, y + 1, z) != Block.waterStill.blockID && world.getBlockId(x, y + 1, z) != Block.waterMoving.blockID && world.getBlockId(x, y + 1, z) != Block.lavaStill.blockID && world.getBlockId(x, y + 1, z) != Block.lavaMoving.blockID && ModjamMod.r.nextInt(100) == 0) { - - boolean obsidian = !world.provider.isHellWorld && ModjamMod.r.nextInt(100) == 0; - - y--; - - int floors = 3 + random.nextInt(6); - - for(int y2 = 0; y2 <= floors * 6; y2++) { - for(int x2 = -5; x2 <= 5; x2++) { - for(int z2 = -5; z2 <= 5; z2++) { - - if(((y2/6) % 2 == 0 ^ y2 % 6 < 2) && x2 == -2 && z2 == -5 && y2 > 1 && y2 <= floors * 6 - 5) { - world.setBlock(x + x2, y + y2, z + z2 + 2, Block.ladder.blockID, 3, 0); - } - - if(((y2/6) % 2 == 1 ^ y2 % 6 < 2) && x2 == 2 && z2 == 5 && y2 > 1 && y2 <= floors * 6 - 5) { - world.setBlock(x + x2, y + y2, z + z2 - 2, Block.ladder.blockID, 2, 0); - } - - if((x2 * x2 + z2 * z2 <= 25) && ((y2 % 6 == 0 || y2 % 6 == 1) || z2 > 3 + (y2 < 6 ? 1 : 0) || z2 < -3 || Math.abs(x2) > 3 + (y2 < 5 ? 1 : 0))) { - if(world.getBlockId(x + x2, y + y2, z + z2) != Block.ladder.blockID && world.getBlockId(x + x2, y + y2, z + z2) != Block.obsidian.blockID) { - //if(y2 >= 5 && (y2 % 5 == 2 || y2 % 5 == 3) && (Math.abs(x2) == 2 || Math.abs(z2) == 2)) { - // world.setBlock(x + x2, y + y2, z + z2, Block.fenceIron.blockID); - //} else { - if(!obsidian && Math.abs(x2) <= 1 && Math.abs(z2) <= 1 && y2 != floors * 6 && y2 != 1 && y2 % 6 == 1) { - world.setBlock(x + x2, y + y2, z + z2, Block.obsidian.blockID); - } else { - world.setBlock(x + x2, y + y2, z + z2, !world.provider.isHellWorld ? (!obsidian ? (random.nextBoolean() ? Block.cobblestoneMossy.blockID : Block.cobblestone.blockID) : Block.obsidian.blockID) : Block.netherBrick.blockID); - } - //} - } - } else if(y2 % 6 == 2 && x2 == 0 && z2 == ((y2/6) % 2 == 1 ? 3 : -3) && (y2/6 >= floors - 1 || random.nextInt(3) == 0) && y2 >= 5) { - world.setBlock(x + x2, y + y2, z + z2, Block.chest.blockID, 0, 2); - - boolean b = (y2/6) % 2 == 1; - - TileEntityChest tileentitychest = (TileEntityChest) world.getBlockTileEntity(x + x2, y + y2, z + z2); - - if(tileentitychest != null) { - //ChestGenHooks info = ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST); - WeightedRandomChestContent.generateChestContents(random, ((y2/6 >= floors - 1 || obsidian) ? ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST) : chestGenInfo).getItems(random), tileentitychest, chestGenInfo.getCount(random)); - } - - if(!obsidian) { - world.setBlock(x + x2, y + y2 - 1, z + z2, Block.obsidian.blockID); - world.setBlock(x + x2, y + y2 + 2, z + z2, Block.obsidian.blockID); - world.setBlock(x + x2, y + y2, z + z2 + (b ? 1 : -1), Block.obsidian.blockID); - world.setBlock(x + x2, y + y2 + 1, z + z2 + (b ? 1 : -1), Block.obsidian.blockID); - world.setBlock(x + x2 + 1, y + y2, z + z2, Block.obsidian.blockID); - world.setBlock(x + x2 - 1, y + y2, z + z2, Block.obsidian.blockID); - world.setBlock(x + x2 + 1, y + y2 + 1, z + z2, Block.obsidian.blockID); - world.setBlock(x + x2 - 1, y + y2 + 1, z + z2, Block.obsidian.blockID); - } - } else if(y2 % 6 == 2 && x2 == 0 && z2 == 0) { - if(y2 != 2) { - world.setBlock(x + x2, y + y2, z + z2, Block.mobSpawner.blockID, 0, 2); - TileEntityMobSpawner tileentitymobspawner = (TileEntityMobSpawner)world.getBlockTileEntity(x + x2, y + y2, z + z2); - - if(tileentitymobspawner != null) { - tileentitymobspawner.getSpawnerLogic().setMobID(DungeonHooks.getRandomDungeonMob(random)); - } - } else { - world.setBlock(x + x2, y + y2, z + z2, ModjamMod.blockPillar.blockID); - world.setBlockMetadataWithNotify(x + x2, y + y2, z + z2, 0, 0); - - world.setBlock(x + x2, y + y2 + 1, z + z2, ModjamMod.blockPillar.blockID); - world.setBlockMetadataWithNotify(x + x2, y + y2 + 1, z + z2, 1, 0); - } - } else if((x2 * x2 + z2 * z2 <= 25) && world.getBlockId(x + x2, y + y2, z + z2) != ModjamMod.blockPillar.blockID && world.getBlockId(x + x2, y + y2, z + z2) != Block.mobSpawner.blockID && world.getBlockId(x + x2, y + y2, z + z2) != Block.ladder.blockID && world.getBlockId(x + x2, y + y2, z + z2) != Block.chest.blockID && world.getBlockId(x + x2, y + y2, z + z2) != Block.obsidian.blockID) { - world.setBlockToAir(x + x2, y + y2, z + z2); - } - - } - } - } - - int changes = 0, y2 = -1; - - do { - changes = 0; - - for(int x2 = -5; x2 <= 5; x2++) { - for(int z2 = -5; z2 <= 5; z2++) { - if(x2 * x2 + z2 * z2 <= 25 && world.isAirBlock(x + x2, y + y2, z + z2)) {world.setBlock(x + x2, y + y2, z + z2, !obsidian ? (random.nextBoolean() ? Block.cobblestoneMossy.blockID : Block.cobblestone.blockID) : Block.obsidian.blockID); changes++;} - } - } - - y2--; - } while(changes != 0 && y + y2 >= 0); - - addedDungeon = true; - - y++; - } - } - } - } - - genning = false; - } - -} diff --git a/java/fyresmodjam/ClientProxy.java b/java/fyresmodjam/ClientProxy.java new file mode 100644 index 0000000..c300e45 --- /dev/null +++ b/java/fyresmodjam/ClientProxy.java @@ -0,0 +1,112 @@ +package fyresmodjam; + +import java.awt.Color; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.MovingObjectPosition.MovingObjectType; +import net.minecraft.world.World; +import net.minecraftforge.client.event.RenderGameOverlayEvent; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.config.Configuration; + +import org.lwjgl.input.Keyboard; + +import cpw.mods.fml.client.registry.ClientRegistry; +import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import fyresmodjam.entities.EntityMysteryPotion; +import fyresmodjam.entities.renderers.RenderMysteryPotion; +import fyresmodjam.handlers.ClientTickHandler; +import fyresmodjam.handlers.FyresKeyHandler; +import fyresmodjam.handlers.NewPacketHandler; +import fyresmodjam.misc.EntityStatHelper; +import fyresmodjam.tileentities.TileEntityCrystal; +import fyresmodjam.tileentities.TileEntityCrystalStand; +import fyresmodjam.tileentities.TileEntityPillar; +import fyresmodjam.tileentities.TileEntityTrap; +import fyresmodjam.tileentities.renderers.TileEntityCrystalRenderer; +import fyresmodjam.tileentities.renderers.TileEntityCrystalStandRenderer; +import fyresmodjam.tileentities.renderers.TileEntityPillarRenderer; +import fyresmodjam.tileentities.renderers.TileEntityTrapRenderer; + +public class ClientProxy extends CommonProxy { + + @SubscribeEvent + public void guiRenderEvent(RenderGameOverlayEvent.Post event) { + if(event.type == RenderGameOverlayEvent.ElementType.HOTBAR) { + MovingObjectPosition mouse = Minecraft.getMinecraft().objectMouseOver; + + World world = Minecraft.getMinecraft().theWorld; + + if(mouse != null && world != null && mouse.typeOfHit == MovingObjectType.BLOCK) { + TileEntity te = world.getTileEntity(mouse.blockX, mouse.blockY, mouse.blockZ); + Block id = world.getBlock(mouse.blockX, mouse.blockY, mouse.blockZ); + + if(id == ModjamMod.blockPillar || (id == ModjamMod.blockTrap && te != null && te instanceof TileEntityTrap && ((TileEntityTrap) te).placedBy != null)) { + String key = Keyboard.getKeyName(FyresKeyHandler.examine.getKeyCode()); + String string = "Press " + key + " to Examine"; + + if(te != null && Minecraft.getMinecraft().thePlayer != null && te instanceof TileEntityTrap && ((TileEntityTrap) te).placedBy.equals(Minecraft.getMinecraft().thePlayer.getCommandSenderName())) { + string = Minecraft.getMinecraft().thePlayer.isSneaking() ? "Use to disarm (Stand to toggle setting)" : "Use to toggle setting (Sneak to disarm)"; + } + + Minecraft.getMinecraft().fontRenderer.drawStringWithShadow(string, (event.resolution.getScaledWidth() / 2) - (Minecraft.getMinecraft().fontRenderer.getStringWidth(string) / 2), event.resolution.getScaledHeight() / 2 + 16, Color.WHITE.getRGB()); + } + } + + if(Minecraft.getMinecraft().thePlayer != null) { + EntityPlayer player = Minecraft.getMinecraft().thePlayer; + String blessing = EntityStatHelper.getStat(player, "Blessing"); + + if(blessing != null) { + if(blessing.equals("Berserker")) { + if(!EntityStatHelper.hasStat(player, "BlessingCounter")) {EntityStatHelper.giveStat(player, "BlessingCounter", 0);} + String string = EntityStatHelper.getStat(player, "BlessingCounter"); + Minecraft.getMinecraft().fontRenderer.drawStringWithShadow(string, (event.resolution.getScaledWidth() / 2) - (Minecraft.getMinecraft().fontRenderer.getStringWidth(string) / 2), event.resolution.getScaledHeight() - 48 + (player.capabilities.isCreativeMode ? 16 : 0), Color.RED.getRGB()); + } + } + } + } + } + + @Override + public void register() { + ClientTickHandler clientHandler = new ClientTickHandler(); + FMLCommonHandler.instance().bus().register(clientHandler); + + FMLCommonHandler.instance().bus().register(new FyresKeyHandler()); + + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityPillar.class, new TileEntityPillarRenderer()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTrap.class, new TileEntityTrapRenderer()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCrystal.class, new TileEntityCrystalRenderer()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCrystalStand.class, new TileEntityCrystalStandRenderer()); + + RenderingRegistry.registerEntityRenderingHandler(EntityMysteryPotion.class, new RenderMysteryPotion(ModjamMod.mysteryPotion)); + + MinecraftForge.EVENT_BUS.register(this); + } + + @Override + public void sendPlayerMessage(String message) { + //Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new ChatComponentText(message)); + + NewPacketHandler.SEND_MESSAGE.data = new Object[] {message}; + NewPacketHandler.SEND_MESSAGE.executeClient(Minecraft.getMinecraft().thePlayer); + } + + @Override + public void loadFromConfig(Configuration config) { + super.loadFromConfig(config); + + ModjamMod.examineKey = config.get("Keybindings", "examine_key", ModjamMod.examineKey).getInt(ModjamMod.examineKey); + ModjamMod.blessingKey = config.get("Keybindings", "blessing_key", ModjamMod.blessingKey).getInt(ModjamMod.blessingKey); + + FyresKeyHandler.examine.setKeyCode(ModjamMod.examineKey); + FyresKeyHandler.activateBlessing.setKeyCode(ModjamMod.blessingKey); + } +} diff --git a/java/fyresmodjam/CommonProxy.java b/java/fyresmodjam/CommonProxy.java new file mode 100644 index 0000000..c70934b --- /dev/null +++ b/java/fyresmodjam/CommonProxy.java @@ -0,0 +1,33 @@ +package fyresmodjam; + +import net.minecraftforge.common.config.Configuration; + +public class CommonProxy { + public void register() {} + + public void sendPlayerMessage(String message) {} + + public void loadFromConfig(Configuration config) { + ModjamMod.pillarGlow = config.get(Configuration.CATEGORY_GENERAL, "pillar_glow", ModjamMod.pillarGlow).getBoolean(ModjamMod.pillarGlow); + + ModjamMod.pillarGenChance = config.get(Configuration.CATEGORY_GENERAL, "pillar_gen_difficulty", ModjamMod.pillarGenChance).getInt(); + ModjamMod.maxPillarsPerChunk = config.get(Configuration.CATEGORY_GENERAL, "max_pillars_per_chunk", ModjamMod.maxPillarsPerChunk).getInt(); + ModjamMod.towerGenChance = config.get(Configuration.CATEGORY_GENERAL, "tower_gen_difficulty", ModjamMod.towerGenChance).getInt(); + ModjamMod.trapGenChance = config.get(Configuration.CATEGORY_GENERAL, "trap_gen_difficulty", ModjamMod.trapGenChance).getInt(); + ModjamMod.mushroomReplaceChance = config.get(Configuration.CATEGORY_GENERAL, "mushroom_replace_difficulty", ModjamMod.mushroomReplaceChance).getInt(); + + ModjamMod.spawnTraps = !(config.get(Configuration.CATEGORY_GENERAL, "disable_traps", !ModjamMod.spawnTraps).getBoolean(!ModjamMod.spawnTraps)); + ModjamMod.spawnTowers = config.get(Configuration.CATEGORY_GENERAL, "spawn_towers", ModjamMod.spawnTowers).getBoolean(ModjamMod.spawnTowers); + ModjamMod.spawnRandomPillars = config.get(Configuration.CATEGORY_GENERAL, "spawn_random_pillars", ModjamMod.spawnRandomPillars).getBoolean(ModjamMod.spawnRandomPillars); + ModjamMod.disableDisadvantages = config.get(Configuration.CATEGORY_GENERAL, "disable_disadvantages", ModjamMod.disableDisadvantages).getBoolean(ModjamMod.disableDisadvantages); + ModjamMod.versionChecking = config.get(Configuration.CATEGORY_GENERAL, "version_checking", ModjamMod.versionChecking).getBoolean(ModjamMod.versionChecking); + + ModjamMod.showAllPillarsInCreative = config.get(Configuration.CATEGORY_GENERAL, "show_all_pillars_in_creative", ModjamMod.showAllPillarsInCreative).getBoolean(ModjamMod.showAllPillarsInCreative); + + ModjamMod.enableMobKillStats = config.get(Configuration.CATEGORY_GENERAL, "enable_mob_kill_stats", ModjamMod.enableMobKillStats).getBoolean(ModjamMod.enableMobKillStats); + ModjamMod.enableWeaponKillStats = config.get(Configuration.CATEGORY_GENERAL, "enable_weapon_kill_stats", ModjamMod.enableWeaponKillStats).getBoolean(ModjamMod.enableWeaponKillStats); + ModjamMod.enableCraftingStats = config.get(Configuration.CATEGORY_GENERAL, "enable_crafting_stats", ModjamMod.enableCraftingStats).getBoolean(ModjamMod.enableCraftingStats); + + ModjamMod.trapsBelowGroundOnly = config.get(Configuration.CATEGORY_GENERAL, "traps_below_ground_only", ModjamMod.trapsBelowGroundOnly).getBoolean(ModjamMod.trapsBelowGroundOnly); + } +} diff --git a/java/fyresmodjam/ModjamMod.java b/java/fyresmodjam/ModjamMod.java new file mode 100644 index 0000000..812da18 --- /dev/null +++ b/java/fyresmodjam/ModjamMod.java @@ -0,0 +1,551 @@ +package fyresmodjam; + +import java.io.BufferedReader; +import java.io.File; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.util.EnumMap; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.command.CommandHandler; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IRangedAttackMob; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.monster.EntityCreeper; +import net.minecraft.entity.monster.EntityMob; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemAxe; +import net.minecraft.item.ItemBow; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemSword; +import net.minecraft.stats.Achievement; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.WeightedRandomChestContent; +import net.minecraftforge.common.AchievementPage; +import net.minecraftforge.common.ChestGenHooks; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.event.entity.player.PlayerEvent; + +import org.lwjgl.input.Keyboard; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.Mod.EventHandler; +import cpw.mods.fml.common.Mod.Instance; +import cpw.mods.fml.common.SidedProxy; +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; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerChangedDimensionEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent; +import cpw.mods.fml.common.network.FMLEmbeddedChannel; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.registry.EntityRegistry; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.relauncher.Side; +import fyresmodjam.blocks.BlockMysteryMushroom; +import fyresmodjam.blocks.BlockPillar; +import fyresmodjam.blocks.BlockTrap; +import fyresmodjam.commands.CommandCraftingStats; +import fyresmodjam.commands.CommandCurrentBlessing; +import fyresmodjam.commands.CommandCurrentDisadvantage; +import fyresmodjam.commands.CommandCurrentWorldTask; +import fyresmodjam.commands.CommandKillStats; +import fyresmodjam.commands.CommandWeaponStats; +import fyresmodjam.entities.EntityMysteryPotion; +import fyresmodjam.handlers.CommonTickHandler; +import fyresmodjam.handlers.GUIHandler; +import fyresmodjam.handlers.NewPacketHandler; +import fyresmodjam.handlers.NewPacketHandler.ChannelHandler; +import fyresmodjam.items.ItemMysteryMushroom; +import fyresmodjam.items.ItemMysteryPotion; +import fyresmodjam.items.ItemObsidianSceptre; +import fyresmodjam.items.ItemPillar; +import fyresmodjam.items.ItemTrap; +import fyresmodjam.misc.CreativeTabModjamMod; +import fyresmodjam.misc.EntityStatHelper; +import fyresmodjam.misc.EntityStatHelper.EntityStat; +import fyresmodjam.misc.EntityStatHelper.EntityStatTracker; +import fyresmodjam.misc.ItemStatHelper; +import fyresmodjam.misc.ItemStatHelper.ItemStat; +import fyresmodjam.misc.ItemStatHelper.ItemStatTracker; +import fyresmodjam.tileentities.TileEntityPillar; +import fyresmodjam.tileentities.TileEntityTrap; +import fyresmodjam.worldgen.FyresWorldData; +import fyresmodjam.worldgen.PillarGen; +import fyresmodjam.worldgen.WorldGenMoreDungeons; +import fyresmodjam.worldgen.WorldGenTrapsTowersAndMore; + +@Mod(modid = "fyresmodjam", name = "Fyres ModJam Mod", version = "0.0.3d") +public class ModjamMod extends CommandHandler { + + @SidedProxy(clientSide = "fyresmodjam.ClientProxy", serverSide = "fyresmodjam.CommonProxy") + public static CommonProxy proxy; + + @Instance("fyresmodjam") + public static ModjamMod instance; + + public static EnumMap channels = NetworkRegistry.INSTANCE.newChannel("YWDMod", new ChannelHandler()); + + public static Random r = new Random(); + + public static int achievementID = 2500, examineKey = Keyboard.KEY_X, blessingKey = Keyboard.KEY_K; + public static int pillarGenChance = 75, maxPillarsPerChunk = 3, towerGenChance = 225, trapGenChance = 300, mushroomReplaceChance = 15; + public static boolean pillarGlow = true, spawnTraps = true, spawnTowers = true, spawnRandomPillars = true, disableDisadvantages = false, versionChecking = true, trapsBelowGroundOnly = false, showAllPillarsInCreative = false, enableWeaponKillStats = true, enableMobKillStats = true, enableCraftingStats = true; + + public static CreativeTabs tabModjamMod = new CreativeTabModjamMod(CreativeTabs.getNextID(), "The \"You Will Die\" Mod"); + + public static Block blockPillar; + public static Block blockTrap; + public static Block mysteryMushroomBlock; + + public static Item itemPillar; + public static Item mysteryPotion; + public static Item itemTrap; + public static Item mysteryMushroom; + public static Item sceptre; + + public static Item crystalItem; + public static Item scroll; + + public static Block crystal; + public static Block crystalStand; + + public static Achievement startTheGame; + public static Achievement losingIsFun; + public static Achievement whoops; + + public static Achievement theHunt; + public static Achievement jackOfAllTrades; + + public static AchievementPage page; + + public static String version = "v0.0.3e"; + public static String foundVersion = "v0.0.3e"; + public static boolean newerVersion = false; + + public static String configPath = null; + + public static final String versionOrder = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; + + @EventHandler + public void preInit(FMLPreInitializationEvent event) { + File old = new File(event.getSuggestedConfigurationFile().getAbsolutePath().replace("fyresmodjam", "YouWillDieMod")); + if(old.exists()) {old.delete(); System.out.println(true);} + + configPath = event.getSuggestedConfigurationFile().getAbsolutePath().replace("fyresmodjam", "TheYouWillDieMod"); + + Configuration config = new Configuration(new File(configPath)); + + config.load(); + + proxy.loadFromConfig(config); + + config.save(); + + if(versionChecking) { + InputStream in = null; + BufferedReader reader = null; + + try { + in = new URL("https://dl.dropboxusercontent.com/s/n30va53f6uh2mki/versions.txt?token_hash=AAE89oZXZUV7Khx4mAbLhJS1Q4UuMZW2CXAO52yW1Ef9fw").openStream(); + reader = new BufferedReader(new InputStreamReader(in)); + + String inputLine; + while((inputLine = reader.readLine()) != null && !inputLine.startsWith("YWDMod")) {} + if(inputLine != null) {foundVersion = inputLine.split("=")[1];} + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + if(reader != null) {reader.close();} + + if(in != null) {in.close();} + } catch (Exception e) {e.printStackTrace();} + } + + String[] versionSplit = version.replace("v", "").split("\\."), foundSplit = foundVersion.replace("v", "").split("\\."); + + if(!version.equals(foundVersion) && (Integer.parseInt(versionSplit[0]) < Integer.parseInt(foundSplit[0]) ? (Integer.parseInt(versionSplit[1]) < Integer.parseInt(foundSplit[1]) ? (Integer.parseInt("" + versionSplit[2].charAt(0)) < Integer.parseInt("" + foundSplit[2].charAt(0)) ? (versionOrder.indexOf(versionSplit[2].charAt(1)) < versionOrder.indexOf(foundSplit[2].charAt(1))) : false) : false) : false)) { + System.out.println("A newer version of the \"You Will Die\" Mod has been found (" + foundVersion + ")."); + newerVersion = true; + } else { + System.out.println("No newer version of the \"You Will Die\" Mod has been found."); + } + } else {System.out.println("\"You Will\" Die Mod version checking disabled.");} + + //Item and Block loading + + blockPillar = new BlockPillar().setBlockUnbreakable().setResistance(6000000.0F); + blockTrap = new BlockTrap().setBlockUnbreakable().setResistance(6000000.0F); + mysteryMushroomBlock = new BlockMysteryMushroom().setHardness(0.0F).setStepSound(Block.soundTypeGrass).setLightLevel(0.125F).setBlockName("mysteryMushroomBlock"); + + /*crystal = new BlockCrystal(blockID + 3); + GameRegistry.registerBlock(crystal, "crystal"); + GameRegistry.registerTileEntity(TileEntityCrystal.class, "Crystal Tile Entity"); + LanguageRegistry.addName(crystal, "Crystal"); + + crystalStand = new BlockCrystalStand(blockID + 4).setCreativeTab(CreativeTabs.tabDecorations); + GameRegistry.registerBlock(crystalStand, "crystalStand"); + GameRegistry.registerTileEntity(TileEntityCrystalStand.class, "Crystal Stand Tile Entity"); + LanguageRegistry.addName(crystalStand, "Crystal Stand");*/ + + itemPillar = new ItemPillar().setUnlocalizedName("blockPillar"); + GameRegistry.registerItem(itemPillar, "itemPillar"); + + mysteryPotion = new ItemMysteryPotion().setUnlocalizedName("mysteryPotion").setCreativeTab(CreativeTabs.tabBrewing); + GameRegistry.registerItem(mysteryPotion, "mysteryPotion"); + + itemTrap = new ItemTrap().setUnlocalizedName("itemTrap").setCreativeTab(CreativeTabs.tabBlock); + GameRegistry.registerItem(itemTrap, "itemTrap"); + + mysteryMushroom = new ItemMysteryMushroom().setUnlocalizedName("mysteryMushroom").setCreativeTab(CreativeTabs.tabBrewing); + GameRegistry.registerItem(mysteryMushroom, "mysteryMushroom"); + + sceptre = new ItemObsidianSceptre().setUnlocalizedName("sceptre").setCreativeTab(CreativeTabs.tabTools).setFull3D(); + GameRegistry.registerItem(sceptre, "sceptre"); + + //crystalItem = new ItemCrystal(crystal.blockID - 256); + + //scroll = new ItemScroll(itemID + 5).setUnlocalizedName("scroll").setCreativeTab(CreativeTabs.tabMisc); + //LanguageRegistry.addName(scroll, "Scroll"); + + GameRegistry.registerBlock(blockPillar, "blockPillar"); + GameRegistry.registerTileEntity(TileEntityPillar.class, "Pillar Tile Entity"); + + GameRegistry.registerBlock(blockTrap, "blockTrap"); + GameRegistry.registerTileEntity(TileEntityTrap.class, "Trap Entity"); + + GameRegistry.registerBlock(mysteryMushroomBlock, "mysteryMushroomBlock"); + + startTheGame = getNewAchievement(achievementID, 0, 0, new ItemStack(Items.iron_sword, 1), "startTheGame", "You Will Die", "Join a world with this mod installed", null, true); + losingIsFun = getNewAchievement(achievementID + 1, -2, 0, new ItemStack(itemTrap, 1), "losingIsFun", "Losing Is Fun", "Experience \"fun\"", startTheGame, false); + whoops = getNewAchievement(achievementID + 2, 2, 0, new ItemStack(itemTrap, 1, 1), "whoops", "Whoops", "Fail to disarm a trap", startTheGame, false); + + theHunt = getNewAchievement(achievementID + 3, 0, -2, new ItemStack(Items.bow, 1), "theHunt", "The Hunt", "Become a competent slayer of 5 or more different creatures", startTheGame, false); + jackOfAllTrades = getNewAchievement(achievementID + 4, 0, 2, new ItemStack(Blocks.crafting_table, 1), "jackOfAllTrades", "Jack of All Trades", "Become a novice user of at least 10 different weapons", startTheGame, false); + + page = new AchievementPage("The \"You Will Die\" Mod", startTheGame, losingIsFun, whoops, theHunt, jackOfAllTrades); + + AchievementPage.registerAchievementPage(page); + } + + @EventHandler + public void init(FMLInitializationEvent event) { + + //Registering + + CommonTickHandler commonHandler = new CommonTickHandler(); + FMLCommonHandler.instance().bus().register(commonHandler); + + MinecraftForge.EVENT_BUS.register(this); + FMLCommonHandler.instance().bus().register(this); + + new ItemStatHelper().register(); + new EntityStatHelper().register(); + + NetworkRegistry.INSTANCE.registerGuiHandler(this, new GUIHandler()); + + GameRegistry.registerWorldGenerator(new PillarGen(), 0); + + GameRegistry.registerWorldGenerator(new WorldGenTrapsTowersAndMore(), 0); + + for(int i = 0; i < 3; i++) {GameRegistry.registerWorldGenerator(new WorldGenMoreDungeons(), 0);} + + EntityRegistry.registerGlobalEntityID(EntityMysteryPotion.class, "MysteryPotion", EntityRegistry.findGlobalUniqueEntityId()); + EntityRegistry.registerModEntity(EntityMysteryPotion.class, "MysteryPotion", 0, instance, 128, 1, true); + + GameRegistry.addShapelessRecipe(new ItemStack(itemTrap, 1, 0), new Object[] {Blocks.heavy_weighted_pressure_plate, Blocks.cactus}); + GameRegistry.addShapelessRecipe(new ItemStack(itemTrap, 1, 1), new Object[] {Blocks.heavy_weighted_pressure_plate, Blocks.torch}); + GameRegistry.addShapelessRecipe(new ItemStack(itemTrap, 1, 2), new Object[] {Blocks.heavy_weighted_pressure_plate, new ItemStack(Items.dye, 1, 0)}); + + for(int i = 0; i < 13; i++) { + GameRegistry.addShapelessRecipe(new ItemStack(mysteryPotion, 1, i + 13), new Object[] {new ItemStack(mysteryPotion, 1, i), Items.gunpowder}); + GameRegistry.addShapelessRecipe(new ItemStack(mysteryPotion, 1, i), new Object[] {new ItemStack(Items.potionitem, 1, 0), Items.leather, new ItemStack(mysteryMushroom, 1, i)}); + } + + GameRegistry.addRecipe(new ItemStack(sceptre, 1, 0), "X", "Y", "X", 'X', Blocks.obsidian, 'Y', Blocks.end_stone); + GameRegistry.addShapelessRecipe(new ItemStack(sceptre, 1, 1), new Object[] {new ItemStack(sceptre, 1, 0), Items.ender_pearl, Items.book}); + + proxy.register(); + + //Entity Trackers + + EntityStatTracker playerTracker = new EntityStatTracker(EntityPlayer.class, true); + + playerTracker.addStat(new EntityStat("BlessingCooldown", "" + 0)); + playerTracker.addStat(new EntityStat("BlessingCounter", "" + 0)); + + EntityStatTracker mobTracker = new EntityStatTracker(EntityMob.class, true); + + mobTracker.addStat(new EntityStat("Level", "") { + @Override + public Object getNewValue(Random r) { + int i = 1; + for(; i < 5; i++) {if(ModjamMod.r.nextInt(5) < 3) {break;}} + return i; + } + + @Override + public String getAlteredEntityName(EntityLiving entity) { + int level = 1; + + try { + level = Integer.parseInt(entity.getEntityData().getString(name)); + } catch (Exception e) {e.printStackTrace();} + + return (level == 5 ? "\u00A7c" : "") + entity.getCommandSenderName() + ", Level " + level; + } + + @Override + public void modifyEntity(Entity entity) { + int level = 1; + + try { + level = Integer.parseInt(entity.getEntityData().getString(name)); + } catch (Exception e) {e.printStackTrace();} + + int healthGain = (int) ((level - 1) * (((EntityLivingBase) entity).getMaxHealth()/4) + (level == 5 ? ((EntityLivingBase) entity).getMaxHealth()/4 : 0)); + + if(healthGain != 0) { + ((EntityLivingBase) entity).getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(((EntityLivingBase) entity).getMaxHealth() + healthGain); + ((EntityLivingBase) entity).setHealth(((EntityLivingBase) entity).getMaxHealth() + healthGain); + } + + if(level == 5) { + switch(r.nextInt(4)) { + + case 0: + if(entity instanceof IRangedAttackMob) {entity.getEntityData().setString("Blessing", "Hunter");} + else {entity.getEntityData().setString("Blessing", "Warrior");} + break; + + case 1: entity.getEntityData().setString("Blessing", "Swamp"); break; + case 2: entity.getEntityData().setString("Blessing", "Guardian"); break; + case 3: entity.getEntityData().setString("Blessing", "Vampire"); break; + + default: break; + + } + + if(entity instanceof EntityCreeper) { + ((EntityCreeper) entity).getDataWatcher().updateObject(17, (byte) 1); + ((EntityCreeper) entity).getEntityData().setBoolean("powered", true); + } + } + } + }); + + EntityStatHelper.addStatTracker(mobTracker); + + //Item Trackers + + ItemStatTracker weaponTracker = new ItemStatTracker(new Class[] {ItemSword.class, ItemAxe.class, ItemBow.class}, true); + + weaponTracker.addStat(new ItemStat("Rank", "") { + + public String[][] prefixesByRank = { + {"Old", "Dull", "Broken", "Worn"}, + {"Average", "Decent", "Modest", "Ordinary"}, + {"Strong", "Sharp", "Polished", "Refined"}, + {"Powerful", "Ruthless", "Elite", "Astonishing"}, + {"Godly", "Divine", "Fabled", "Legendary"} + }; + + @Override + public Object getNewValue(ItemStack stack, Random r) { + int i = 1; + for(; i < 5; i++) {if(ModjamMod.r.nextInt(10) < 7) {break;}} + return i; + } + + @Override + public void modifyStack(ItemStack stack, Random r) { + int rank = Integer.parseInt(stack.getTagCompound().getString(name)); + float bonusDamage = ((float) rank - 1)/2 + (r.nextInt(rank + 1) * r.nextFloat()); + + ItemStatHelper.giveStat(stack, "BonusDamage", String.format("%.2f", bonusDamage)); + ItemStatHelper.addLore(stack, !String.format("%.2f", bonusDamage).equals("0.00") ? "\u00A77\u00A7o " + (bonusDamage > 0 ? "+" : "") + String.format("%.2f", bonusDamage) + " bonus damage" : null); + + ItemStatHelper.addLore(stack, "\u00A7eRank: "+ rank); + } + + @Override + public String getAlteredStackName(ItemStack stack, Random r) { + String[] list = prefixesByRank[Integer.parseInt(stack.getTagCompound().getString(name)) - 1]; + String prefix = list[r.nextInt(list.length)]; + + if(prefix.equals("Sharp") && stack.getItem() instanceof ItemBow) {prefix = "Long";} + + return "\u00A7f" + prefix + " " + stack.getDisplayName(); + } + + }); + + ItemStatHelper.addStatTracker(weaponTracker); + + ItemStatTracker armorTracker = new ItemStatTracker(new Class[] {ItemArmor.class}, true); + + armorTracker.addStat(new ItemStat("Rank", "") { + + public String[][] prefixesByRank = { + {"Old", "Broken", "Worn", "Weak"}, + {"Average", "Decent", "Modest", "Ordinary"}, + {"Polished", "Tough", "Hardened", "Durable"}, + {"Elite", "Astonishing", "Reinforced", "Resilient"}, + {"Godly", "Divine", "Fabled", "Legendary"} + }; + + @Override + public Object getNewValue(ItemStack stack, Random r) { + int i = 1; + for(; i < 5; i++) {if(ModjamMod.r.nextInt(10) < 7) {break;}} + return i; + } + + @Override + public void modifyStack(ItemStack stack, Random r) { + int rank = Integer.parseInt(stack.getTagCompound().getString(name)); + float damageReduction = (rank - 1) + r.nextFloat() * 0.5F; + + ItemStatHelper.giveStat(stack, "DamageReduction", String.format("%.2f", damageReduction)); + ItemStatHelper.addLore(stack, !String.format("%.2f", damageReduction).equals("0.00") ? "\u00A77\u00A7o " + (damageReduction > 0 ? "+" : "") + String.format("%.2f", damageReduction) + "% damage reduction" : null); + + ItemStatHelper.addLore(stack, "\u00A7eRank: "+ rank); + } + + @Override + public String getAlteredStackName(ItemStack stack, Random r) { + String[] list = prefixesByRank[Integer.parseInt(stack.getTagCompound().getString(name)) - 1]; + String prefix = list[r.nextInt(list.length)]; + + if(prefix.equals("Sharp") && stack.getItem() instanceof ItemBow) {prefix = "Long";} + + return "\u00A7f" + prefix + " " + stack.getDisplayName(); + } + + }); + + ItemStatHelper.addStatTracker(armorTracker); + + //Other + + for(int i = 0; i < 13; i++) { + ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST).addItem(new WeightedRandomChestContent(mysteryPotion, i, 1, 3, 2)); + WorldGenTrapsTowersAndMore.chestGenInfo.addItem(new WeightedRandomChestContent(mysteryPotion, i, 1, 3, 2)); + } + } + + @EventHandler + public void postInit(FMLPostInitializationEvent event) { + + } + + @SubscribeEvent + public void onPlayerLogin(PlayerLoggedInEvent event) { + EntityPlayer player = event.player; + + if(!player.worldObj.isRemote) { + NewPacketHandler.UPDATE_WORLD_DATA.sendToPlayer(player, CommonTickHandler.worldData.potionValues, CommonTickHandler.worldData.potionDurations, CommonTickHandler.worldData.getDisadvantage(), CommonTickHandler.worldData.currentTask, CommonTickHandler.worldData.currentTaskID, CommonTickHandler.worldData.currentTaskAmount, CommonTickHandler.worldData.progress, CommonTickHandler.worldData.tasksCompleted, CommonTickHandler.worldData.enderDragonKilled, ModjamMod.spawnTraps, CommonTickHandler.worldData.rewardLevels, CommonTickHandler.worldData.mushroomColors); + + String name = CommonTickHandler.worldData.currentTask.equals("Kill") ? FyresWorldData.validMobNames[CommonTickHandler.worldData.currentTaskID] : FyresWorldData.validItems[CommonTickHandler.worldData.currentTaskID].getDisplayName(); + + if(CommonTickHandler.worldData.currentTaskAmount > 1) { + if(name.contains("Block")) {name = name.replace("Block", "Blocks").replace("block", "blocks");} + else {name += "s";} + } + + int index = -1; + for(int i = 0; i < FyresWorldData.validDisadvantages.length; i++) {if(FyresWorldData.validDisadvantages[i].equals(CommonTickHandler.worldData.getDisadvantage())) {index = i; break;}} + + NewPacketHandler.SEND_MESSAGE.sendToPlayer(player, "\u00A7eWorld disadvantage: " + CommonTickHandler.worldData.getDisadvantage() + (index == -1 ? "" : " (" + FyresWorldData.disadvantageDescriptions[index] + ")")); + + NewPacketHandler.SEND_MESSAGE.sendToPlayer(player, "\u00A7eWorld goal: " + CommonTickHandler.worldData.currentTask + " " + CommonTickHandler.worldData.currentTaskAmount + " " + name + ". (" + CommonTickHandler.worldData.progress + " " + CommonTickHandler.worldData.currentTask + "ed)"); + + if(!player.getEntityData().hasKey("Blessing")) { + player.getEntityData().setString("Blessing", TileEntityPillar.validBlessings[ModjamMod.r.nextInt(TileEntityPillar.validBlessings.length)]); + while(player.getEntityData().getString("Blessing").equals("Inferno")) {player.getEntityData().setString("Blessing", TileEntityPillar.validBlessings[ModjamMod.r.nextInt(TileEntityPillar.validBlessings.length)]);} + + NewPacketHandler.SEND_MESSAGE.sendToPlayer(player, "\u00A72You've been granted the Blessing of the " + player.getEntityData().getString("Blessing") + ". (Use /currentBlessing to check effect)"); + } + + NewPacketHandler.UPDATE_BLESSING.sendToPlayer(player, player.getEntityData().getString("Blessing")); + + if(EntityStatHelper.hasStat(player, "BlessingCounter")) {NewPacketHandler.UPDATE_STAT.sendToPlayer(player, "BlessingCounter", EntityStatHelper.getStat(player, "BlessingCounter"));} + + if(!player.getEntityData().hasKey("PotionKnowledge")) {player.getEntityData().setIntArray("PotionKnowledge", new int[] {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1});} + + NewPacketHandler.UPDATE_POTION_KNOWLEDGE.sendToPlayer(player, player.getEntityData().getIntArray("PotionKnowledge")); + } + + if(versionChecking && newerVersion) {player.addChatComponentMessage(new ChatComponentTranslation("fyresmodjam.newVersion"));} + + player.triggerAchievement(startTheGame); + } + + @SubscribeEvent + public void onPlayerChangedDimension(PlayerChangedDimensionEvent event) { + EntityPlayer player = event.player; + + NewPacketHandler.UPDATE_WORLD_DATA.sendToPlayer(player, CommonTickHandler.worldData.potionValues, CommonTickHandler.worldData.potionDurations, CommonTickHandler.worldData.getDisadvantage(), CommonTickHandler.worldData.currentTask, CommonTickHandler.worldData.currentTaskID, CommonTickHandler.worldData.currentTaskAmount, CommonTickHandler.worldData.progress, CommonTickHandler.worldData.tasksCompleted, CommonTickHandler.worldData.enderDragonKilled, ModjamMod.spawnTraps, CommonTickHandler.worldData.rewardLevels, CommonTickHandler.worldData.mushroomColors); + + NewPacketHandler.UPDATE_BLESSING.sendToPlayer(player, player.getEntityData().getString("Blessing")); + + if(EntityStatHelper.hasStat(player, "BlessingCounter")) {NewPacketHandler.UPDATE_STAT.sendToPlayer(player, "BlessingCounter", EntityStatHelper.getStat(player, "BlessingCounter"));} + + if(!player.getEntityData().hasKey("PotionKnowledge")) {player.getEntityData().setIntArray("PotionKnowledge", new int[] {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1});} + + NewPacketHandler.UPDATE_POTION_KNOWLEDGE.sendToPlayer(player, player.getEntityData().getIntArray("PotionKnowledge")); + } + + @SubscribeEvent + public void checkBreakSpeed(PlayerEvent.BreakSpeed event) { + if(event.entityPlayer != null && event.entityPlayer.getEntityData().hasKey("Blessing")) { + String blessing = event.entityPlayer.getEntityData().getString("Blessing"); + + if(blessing.equals("Miner")) { + if(event.block.getMaterial() == Material.rock || event.block.getMaterial() == Material.iron) {event.newSpeed = event.originalSpeed * 1.25F;} + } else if(blessing.equals("Lumberjack")) { + if(event.block.getMaterial() == Material.wood) {event.newSpeed = event.originalSpeed * 1.25F;} + } + } + } + + @EventHandler + public void serverStarting(FMLServerStartingEvent event) { + initCommands(event); + } + + public void initCommands(FMLServerStartingEvent event) { + event.registerServerCommand(new CommandCurrentBlessing()); + event.registerServerCommand(new CommandCurrentDisadvantage()); + event.registerServerCommand(new CommandCurrentWorldTask()); + event.registerServerCommand(new CommandKillStats()); + event.registerServerCommand(new CommandWeaponStats()); + event.registerServerCommand(new CommandCraftingStats()); + } + + @SuppressWarnings("deprecation") + public static Achievement getNewAchievement(int id, int x, int y, ItemStack stack, String name, String displayName, String desc, Achievement prereq, boolean independent) { + Achievement achievement = new Achievement("YWD-" + id, name, x, y, stack, prereq); + if(independent) {achievement = achievement.initIndependentStat();} + LanguageRegistry.instance().addStringLocalization("achievement." + name, "en_US", displayName); + LanguageRegistry.instance().addStringLocalization("achievement." + name + ".desc", "en_US", desc); + achievement.registerStat(); + return achievement; + } +} diff --git a/fyresmodjam/blocks/BlockCrystal.java b/java/fyresmodjam/blocks/BlockCrystal.java similarity index 54% rename from fyresmodjam/blocks/BlockCrystal.java rename to java/fyresmodjam/blocks/BlockCrystal.java index 8f5b569..b17fe10 100644 --- a/fyresmodjam/blocks/BlockCrystal.java +++ b/java/fyresmodjam/blocks/BlockCrystal.java @@ -1,75 +1,69 @@ package fyresmodjam.blocks; -import java.awt.Color; -import java.util.List; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import fyresmodjam.ModjamMod; -import fyresmodjam.items.ItemCrystal; -import fyresmodjam.tileentities.TileEntityCrystal; -import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.StatCollector; +import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import fyresmodjam.ModjamMod; +import fyresmodjam.items.ItemCrystal; +import fyresmodjam.tileentities.TileEntityCrystal; public class BlockCrystal extends BlockContainer { - //need to add subtype information - - public BlockCrystal(int par1) { - super(par1, Material.glass); - this.setBlockBounds(0.25F, 0.1F, 0.25F, 0.75F, 0.9F, 0.75F); - // TODO set block bounds + public BlockCrystal() { + super(Material.glass); + setBlockBounds(0.25F, 0.1F, 0.25F, 0.75F, 0.9F, 0.75F); } - + + @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister iconRegister) { - this.blockIcon = ((ItemCrystal) ModjamMod.crystalItem).texture; + public void registerBlockIcons(IIconRegister par1IconRegister) { + blockIcon = ((ItemCrystal) ModjamMod.crystalItem).texture; } - public boolean canHarvestBlock(EntityPlayer player, int i) { - return false; //player will get it through activating - } - @Override - public TileEntity createNewTileEntity(World world) {return new TileEntityCrystal();} + public boolean canHarvestBlock(EntityPlayer player, int i) {return false;} + @Override + public TileEntity createNewTileEntity(World world, int i) {return new TileEntityCrystal();} + + @Override public boolean hasTileEntity(int meta) {return true;} + @Override public boolean isOpaqueCube() {return false;} + @Override @SideOnly(Side.CLIENT) public boolean shouldSideBeRendered(IBlockAccess blockAccess, int i, int i2, int i3, int i4) { return false; } - - public int idPicked(World world, int i, int i2, int i3) { - return ModjamMod.crystalItem.itemID; + + @Override + public ItemStack getPickBlock(MovingObjectPosition object, World par1World, int par2, int par3, int par4) { + return new ItemStack(ModjamMod.crystalItem); } - + + @Override public int getDamageValue(World world, int i, int i2, int i3) { return world.getBlockMetadata(i, i2, i3); } - + + @Override public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage(), 0); } - + + @Override public int getLightValue(IBlockAccess world, int x, int y, int z) { return 10; } - - /*@SideOnly(Side.CLIENT) - public void getSubBlocks(int id, CreativeTabs creativeTab, List list) { - for(int i = 0; i < names.length; i++) {list.add(new ItemStack(id, 1, i));} - }*/ } diff --git a/fyresmodjam/blocks/BlockCrystalStand.java b/java/fyresmodjam/blocks/BlockCrystalStand.java similarity index 64% rename from fyresmodjam/blocks/BlockCrystalStand.java rename to java/fyresmodjam/blocks/BlockCrystalStand.java index 603dfda..d0d373c 100644 --- a/fyresmodjam/blocks/BlockCrystalStand.java +++ b/java/fyresmodjam/blocks/BlockCrystalStand.java @@ -1,43 +1,41 @@ package fyresmodjam.blocks; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import fyresmodjam.tileentities.TileEntityCrystalStand; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import fyresmodjam.tileentities.TileEntityCrystalStand; public class BlockCrystalStand extends BlockContainer { - public BlockCrystalStand(int par1) { - super(par1, Material.rock); - this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); + public BlockCrystalStand() { + super(Material.rock); + setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); } - + + @Override public boolean canHarvestBlock(EntityPlayer player, int i) { return false; } @Override - public TileEntity createNewTileEntity(World world) { + public TileEntity createNewTileEntity(World world, int i) { return new TileEntityCrystalStand(); } + @Override public boolean hasTileEntity(int meta) {return true;} + @Override public boolean isOpaqueCube() {return false;} + @Override @SideOnly(Side.CLIENT) public boolean shouldSideBeRendered(IBlockAccess blockAccess, int i, int i2, int i3, int i4) { return false; } - - /*@SideOnly(Side.CLIENT) - public void registerIcons(IconRegister iconRegister) { - this.blockIcon = iconRegister.registerIcon("fyresmodjam:crystal_stand_item"); // TODO fix rendering later - }*/ } diff --git a/java/fyresmodjam/blocks/BlockMysteryMushroom.java b/java/fyresmodjam/blocks/BlockMysteryMushroom.java new file mode 100644 index 0000000..70326c2 --- /dev/null +++ b/java/fyresmodjam/blocks/BlockMysteryMushroom.java @@ -0,0 +1,155 @@ +package fyresmodjam.blocks; + +import java.util.List; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockFlower; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import fyresmodjam.ModjamMod; +import fyresmodjam.handlers.NewPacketHandler; + +public class BlockMysteryMushroom extends BlockFlower { + + public IIcon icon; + public IIcon overlay; + + public BlockMysteryMushroom() { + super(0); + float f = 0.2F; + setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 2.0F, 0.5F + f); + setTickRandomly(true); + setCreativeTab(null); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + icon = par1IconRegister.registerIcon("fyresmodjam:mushroomBlock"); + overlay = par1IconRegister.registerIcon("fyresmodjam:mushroomBlock_overlay"); + blockIcon = icon; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int par1, int par2) { + return renderPass == 0 ? icon : overlay; + } + + @Override + public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) { + if (par5Random.nextInt(25) == 0) { + byte b0 = 4; + int l = 5; + int i1; + int j1; + int k1; + + for (i1 = par2 - b0; i1 <= par2 + b0; ++i1) + { + for (j1 = par4 - b0; j1 <= par4 + b0; ++j1) + { + for (k1 = par3 - 1; k1 <= par3 + 1; ++k1) + { + if (par1World.getBlock(i1, k1, j1) == this) + { + --l; + + if (l <= 0) + { + return; + } + } + } + } + } + + i1 = par2 + par5Random.nextInt(3) - 1; + j1 = par3 + par5Random.nextInt(2) - par5Random.nextInt(2); + k1 = par4 + par5Random.nextInt(3) - 1; + + for (int l1 = 0; l1 < 4; ++l1) { + if (par1World.isAirBlock(i1, j1, k1) && canBlockStay(par1World, i1, j1, k1)) { + par2 = i1; + par3 = j1; + par4 = k1; + } + + i1 = par2 + par5Random.nextInt(3) - 1; + j1 = par3 + par5Random.nextInt(2) - par5Random.nextInt(2); + k1 = par4 + par5Random.nextInt(3) - 1; + } + + if (par1World.isAirBlock(i1, j1, k1) && canBlockStay(par1World, i1, j1, k1)) + { + par1World.setBlock(i1, j1, k1, this, par1World.getBlockMetadata(par2, par3, par4), 2); + } + } + } + + @Override + public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4) { + return super.canPlaceBlockAt(par1World, par2, par3, par4) && canBlockStay(par1World, par2, par3, par4); + } + + @Override + public boolean canBlockStay(World par1World, int par2, int par3, int par4) { + if (par3 >= 0 && par3 < 256) { + Block soil = par1World.getBlock(par2, par3 - 1, par4); + return (soil != null && soil.canSustainPlant(par1World, par2, par3 - 1, par4, ForgeDirection.UP, this)); + } else { + return false; + } + } + + @Override + @SuppressWarnings({ "unchecked", "rawtypes" }) + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for(int i = 0; i < 13; i++) {par3List.add(new ItemStack(par1, 1, i));} + } + + @Override + public int damageDropped(int par1) { + return par1 % 13; + } + + @Override + @SideOnly(Side.CLIENT) + public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) { + return NewPacketHandler.mushroomColors[par1IBlockAccess.getBlockMetadata(par2, par3, par4)][renderPass]; + } + + public static int renderPass; + @Override + public boolean canRenderInPass(int pass) { + renderPass = pass; + return true; + } + + @Override + public ItemStack getPickBlock(MovingObjectPosition object, World par1World, int par2, int par3, int par4) { + return new ItemStack(ModjamMod.mysteryMushroom); + } + + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return ModjamMod.mysteryMushroom; + } + + @Override + public int getRenderBlockPass() { + return 1; + } +} diff --git a/java/fyresmodjam/blocks/BlockPillar.java b/java/fyresmodjam/blocks/BlockPillar.java new file mode 100644 index 0000000..2254e68 --- /dev/null +++ b/java/fyresmodjam/blocks/BlockPillar.java @@ -0,0 +1,221 @@ +package fyresmodjam.blocks; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.monster.EntityMob; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import fyresmodjam.ModjamMod; +import fyresmodjam.handlers.NewPacketHandler; +import fyresmodjam.misc.EntityStatHelper; +import fyresmodjam.tileentities.TileEntityPillar; +import fyresmodjam.worldgen.WorldGenTrapsTowersAndMore; + +public class BlockPillar extends BlockContainer { + + public BlockPillar() { + super(Material.rock); + setLightOpacity(0); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + blockIcon = par1IconRegister.registerIcon("fyresmodjam:pillar"); + } + + public int idDropped(int par1, Random par2Random, int par3) { + return 0; + } + + @Override + public int getDamageValue(World par1World, int par2, int par3, int par4) { + int damage = 0; + + if(ModjamMod.showAllPillarsInCreative) { + int meta = par1World.getBlockMetadata(par2, par3, par4); + TileEntity te = par1World.getTileEntity(par2, par3 - (meta == 1 ? 1 : 0), par4); + + if(te != null && te instanceof TileEntityPillar) { + for(int i = 0; i < TileEntityPillar.validBlessings.length; i++) { + if(TileEntityPillar.validBlessings[i].equals(((TileEntityPillar) te).blessing)) {damage = i + 1; break;} + } + } + } + + return damage; + } + + @Override + public ItemStack getPickBlock(MovingObjectPosition object, World par1World, int par2, int par3, int par4) { + return new ItemStack(ModjamMod.itemPillar); + } + + @Override + public boolean canHarvestBlock(EntityPlayer par1EntityPlayer, int par2) { + return false; + } + + @Override + public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { + if(par1World.getBlockMetadata(par2, par3, par4) % 2 == 1) {par3--;} + + TileEntity te = par1World.getTileEntity(par2, par3, par4); + + if(par5EntityPlayer.getHeldItem() == null || par5EntityPlayer.getHeldItem().getItem() == null || par5EntityPlayer.getHeldItem().getItemDamage() != 1 || par5EntityPlayer.getHeldItem().getItem() != ModjamMod.sceptre) { + if(te != null && te instanceof TileEntityPillar && (!par5EntityPlayer.getEntityData().hasKey("Blessing") || !par5EntityPlayer.getEntityData().getString("Blessing").equals(((TileEntityPillar) te).blessing))) { + + boolean skip = false; + + for(int i = 0; i < par1World.loadedEntityList.size(); i++) { + Entity e = (Entity) par1World.loadedEntityList.get(i); + + if(e instanceof EntityMob) { + double xDiff = par2 - e.posX; + double yDiff = par3 - e.posY; + double zDiff = par4 - e.posZ; + + if(Math.abs(yDiff) > 4) {continue;} + + double dist = Math.sqrt(xDiff * xDiff + yDiff * yDiff + zDiff * zDiff); + + if(dist <= 14) {skip = true;} + } + } + + if(!skip) { + if(((TileEntityPillar) te).blessing != null) { + EntityStatHelper.giveStat(par5EntityPlayer, "Blessing", ((TileEntityPillar) te).blessing); + EntityStatHelper.giveStat(par5EntityPlayer, "BlessingActive", false); + EntityStatHelper.giveStat(par5EntityPlayer, "BlessingCounter", 0); + EntityStatHelper.giveStat(par5EntityPlayer, "BlessingCooldown", 0); + + if(!par1World.isRemote) { + par1World.playSoundAtEntity(par5EntityPlayer, "fyresmodjam:pillarActivated", 1.0F, 1.0F); + NewPacketHandler.SEND_MESSAGE.sendToPlayer(par5EntityPlayer, "Activated blessing of the " + ((TileEntityPillar) te).blessing + "."); + } + } + } else if(!par1World.isRemote) { + NewPacketHandler.SEND_MESSAGE.sendToPlayer(par5EntityPlayer, "\u00A7cCannot activate pillar with monsters nearby!"); + } + } + } else if(!par1World.isRemote) { + int damage = 0; + + if(te != null && te instanceof TileEntityPillar) { + for(int i = 0; i < TileEntityPillar.validBlessings.length; i++) { + if(TileEntityPillar.validBlessings[i].equals(((TileEntityPillar) te).blessing)) {damage = i + 1; break;} + } + } + + if(!par5EntityPlayer.capabilities.isCreativeMode) {par5EntityPlayer.getHeldItem().stackSize--;} + par1World.spawnEntityInWorld(new EntityItem(par1World, par2 + 0.5F, par3 + 0.5F, par4 + 0.5F, new ItemStack(ModjamMod.itemPillar, 1, damage))); + par1World.setBlockToAir(par2, par3, par4); + + NewPacketHandler.SEND_MESSAGE.sendToPlayer(par5EntityPlayer, "\u00A7e\u00A7oThe pillar deconstructs before you."); + } + + return true; + } + + @Override + public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, Block par5) { + super.onNeighborBlockChange(par1World, par2, par3, par4, par5); + + if (!par1World.isRemote && !WorldGenTrapsTowersAndMore.genning) { + int i1 = par1World.getBlockMetadata(par2, par3, par4); + + if (i1 % 2 == 0) { + if (par1World.isAirBlock(par2, par3 + 1, par4) || par1World.getBlock(par2, par3 + 1, par4) != par1World.getBlock(par2, par3, par4)) { + par1World.setBlockToAir(par2, par3, par4); + } + } else if (par1World.isAirBlock(par2, par3 - 1, par4) || par1World.getBlock(par2, par3 - 1, par4) != par1World.getBlock(par2, par3, par4)) { + par1World.setBlockToAir(par2, par3, par4); + } + } + } + + @Override + public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4) { + return par3 >= 255 ? false : (super.canPlaceBlockAt(par1World, par2, par3, par4) && super.canPlaceBlockAt(par1World, par2, par3 + 1, par4)); + } + + @Override + public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) { + int l = par1IBlockAccess.getBlockMetadata(par2, par3, par4); + + if (l % 2 == 0) { + setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 2.0F, 1.0F); + } else { + setBlockBounds(0.0F, -1.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + } + + @Override + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) { + return false; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean hasTileEntity(int metadata) { + return metadata % 2 == 0; + } + + @Override + public TileEntity createNewTileEntity(World world, int i) { + return new TileEntityPillar(); + } + + @Override + public int getMobilityFlag() { + return 2; + } + + @Override + public void onBlockHarvested(World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer) { + if (par6EntityPlayer.capabilities.isCreativeMode && par5 >= 2 && par1World.getBlock(par2, par3 - 1, par4) == this) { + par1World.setBlockToAir(par2, par3 - 1, par4); + } else { + super.onBlockHarvested(par1World, par2, par3, par4, par5, par6EntityPlayer); + } + } + + @Override + @SideOnly(Side.CLIENT) + public int getLightValue(IBlockAccess world, int x, int y, int z) { + Block block = world.getBlock(x, y, z); + TileEntity te = world.getTileEntity(x, y, z); + + if(block != null && block != this) { + return block.getLightValue(world, x, y, z); + } + + if(ModjamMod.pillarGlow && net.minecraft.client.Minecraft.getMinecraft().theWorld != null && net.minecraft.client.Minecraft.getMinecraft().theWorld.isRemote) { + EntityPlayer player = net.minecraft.client.Minecraft.getMinecraft().thePlayer; + + if(player != null && te != null && te instanceof TileEntityPillar && ((TileEntityPillar) te).blessing != null && ((TileEntityPillar) te).blessing.equals(player.getEntityData().getString("Blessing"))) { + return 4; + } + } + + return 0; + } +} diff --git a/java/fyresmodjam/blocks/BlockTrap.java b/java/fyresmodjam/blocks/BlockTrap.java new file mode 100644 index 0000000..d45ccfc --- /dev/null +++ b/java/fyresmodjam/blocks/BlockTrap.java @@ -0,0 +1,278 @@ +package fyresmodjam.blocks; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntityMob; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.server.MinecraftServer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Vec3; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraft.world.WorldServer; +import net.minecraftforge.common.IShearable; +import net.minecraftforge.common.util.ForgeDirection; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import fyresmodjam.ModjamMod; +import fyresmodjam.handlers.CommonTickHandler; +import fyresmodjam.handlers.NewPacketHandler; +import fyresmodjam.items.ItemTrap; +import fyresmodjam.tileentities.TileEntityTrap; + +public class BlockTrap extends BlockContainer implements IShearable { + + public static int trapTypes = 3; + + public BlockTrap() { + super(Material.circuits); + setLightOpacity(0); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + blockIcon = par1IconRegister.registerIcon("fyresmodjam:spikes2"); + } + + public int idDropped(int par1, Random par2Random, int par3) { + return 0; + } + + @Override + public ItemStack getPickBlock(MovingObjectPosition object, World par1World, int par2, int par3, int par4) { + return new ItemStack(ModjamMod.blockTrap); + } + + @Override + public boolean canHarvestBlock(EntityPlayer par1EntityPlayer, int par2) { + return false; + } + + @Override + public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { + if(par5EntityPlayer.getHeldItem() == null) { + TileEntity te = par1World.getTileEntity(par2, par3, par4); + + if(!par5EntityPlayer.isSneaking() && te != null && te instanceof TileEntityTrap && ((TileEntityTrap) te).placedBy != null && ((TileEntityTrap) te).placedBy.equals(par5EntityPlayer.getCommandSenderName())) { + if(!par1World.isRemote) { + ((TileEntityTrap) te).setting++; if(((TileEntityTrap) te).setting >= TileEntityTrap.settings.length) {((TileEntityTrap) te).setting = 0;} + + te.markDirty(); + + NewPacketHandler.SEND_MESSAGE.sendToPlayer(par5EntityPlayer, "\u00A7e\u00A7oSet to: " + TileEntityTrap.settings[((TileEntityTrap) te).setting] + "."); + } + } else if(par1World.isRemote) { + NewPacketHandler.DISARM_TRAP.sendToServer(par2, par3, par4, par5EntityPlayer.getEntityData().hasKey("Blessing") && par5EntityPlayer.getEntityData().getString("Blessing").equals("Mechanic")); + } + } + + return true; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) { + return false; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean hasTileEntity(int metadata) { + return true; + } + + @Override + public TileEntity createNewTileEntity(World world, int i) { + return new TileEntityTrap(); + } + + @Override + public int getMobilityFlag() { + return 2; + } + + @Override + @SuppressWarnings("rawtypes") + public void addCollisionBoxesToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity) {} + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) { + return super.getCollisionBoundingBoxFromPool(par1World, par2, par3, par4); + } + + @Override + @SideOnly(Side.CLIENT) + public MovingObjectPosition collisionRayTrace(World par1World, int par2, int par3, int par4, Vec3 par5Vec3, Vec3 par6Vec3) { + EntityPlayer player = Minecraft.getMinecraft().thePlayer; + TileEntity te = par1World.getTileEntity(par2, par3, par4); + return (player != null && te instanceof TileEntityTrap && (((TileEntityTrap) te).placedBy != null || !NewPacketHandler.trapsDisabled) && (player.getCommandSenderName().equals(((TileEntityTrap) te).placedBy) || player.isSneaking() || (player.getEntityData().hasKey("Blessing") && player.getEntityData().getString("Blessing").equals("Scout")))) ? super.collisionRayTrace(par1World, par2, par3, par4, par5Vec3, par6Vec3) : null; + } + + @Override + public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity) { + TileEntity te = par1World.getTileEntity(par2, par3, par4); + + boolean b1 = (((TileEntityTrap) te).placedBy == null || !par5Entity.getCommandSenderName().equals(((TileEntityTrap) te).placedBy)); + boolean b2 = ((TileEntityTrap) te).setting != 3 && (!(par5Entity instanceof EntityPlayer) || ((TileEntityTrap) te).setting < 2); + boolean b3 = (ModjamMod.spawnTraps || ((TileEntityTrap) te).placedBy != null); + boolean b4 = ((par5Entity instanceof EntityPlayer && !((EntityPlayer) par5Entity).capabilities.isCreativeMode) || par5Entity instanceof EntityMob); + + if(!par1World.isRemote && par5Entity.ridingEntity == null && te != null && te instanceof TileEntityTrap && b1 && b2 && b3 && b4) { + + int type = par1World.getBlockMetadata(par2, par3, par4); + + String blessing = null; + if(par5Entity.getEntityData().hasKey("Blessing")) {blessing = par5Entity.getEntityData().getString("Blessing");} + boolean scout = blessing != null && blessing.equals("Scout"); + + if(par5Entity instanceof EntityPlayer) { + if(type % trapTypes == 0) { + par5Entity.attackEntityFrom(DamageSource.cactus, 8.0F + (scout ? 2.0F : 0.0F)); + if(ModjamMod.r.nextInt(8 - (scout ? 2 : 0)) == 0) {((EntityLivingBase) par5Entity).addPotionEffect(new PotionEffect(Potion.poison.id, 100 + (scout ? 25 : 0), 1));} + } else if(type % trapTypes == 1) { + if(!par5Entity.isBurning()) {par5Entity.setFire(10 + (scout ? 2 : 0));} + } else if(type % trapTypes == 2) { + ((EntityLivingBase) par5Entity).addPotionEffect(new PotionEffect(Potion.blindness.id, 200 + (scout ? 50 : 0), 1)); + ((EntityLivingBase) par5Entity).addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 200 + (scout ? 50 : 0), 1)); + } + + if(CommonTickHandler.worldData.getDisadvantage().equals("Explosive Traps")) {par5Entity.worldObj.setBlockToAir(par2, par3, par4); par5Entity.worldObj.createExplosion(null, par2 + 0.5F, par3 + 0.5F, par4 + 0.5F, 1.33F, true);} + + par1World.setBlockToAir(par2, par3, par4); + + NewPacketHandler.SEND_MESSAGE.sendToPlayer((EntityPlayer) par5Entity, "\u00A7c\u00A7oYou triggered a " + ItemTrap.names[type % trapTypes].toLowerCase() + "!"); + } else { + if(type % trapTypes == 0) { + par5Entity.attackEntityFrom(DamageSource.cactus, 2.0F); + if(ModjamMod.r.nextInt(32) == 0) {((EntityLivingBase) par5Entity).addPotionEffect(new PotionEffect(Potion.poison.id, 100, 1));} + } else if(type % trapTypes == 1) { + if(!par5Entity.isBurning()) {par5Entity.setFire(5);} + } else if(type % trapTypes == 2) { + ((EntityLivingBase) par5Entity).addPotionEffect(new PotionEffect(Potion.blindness.id, 100, 1)); + ((EntityLivingBase) par5Entity).addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 100, 1)); + } + } + + } + } + + @Override + public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, Block par5) { + super.onNeighborBlockChange(par1World, par2, par3, par4, par5); + + if(!par1World.isRemote && !par1World.isSideSolid(par2, par3 - 1, par4, ForgeDirection.SOUTH, true)) { + par1World.setBlockToAir(par2, par3, par4); + TileEntity te = par1World.getTileEntity(par2, par3, par4); + if((ModjamMod.spawnTraps || (te != null && te instanceof TileEntityTrap && ((TileEntityTrap) te).placedBy != null)) && CommonTickHandler.worldData != null && CommonTickHandler.worldData.getDisadvantage().equals("Explosive Traps")) {par1World.createExplosion(null, par2 + 0.5F, par3 + 0.5F, par4 + 0.5F, 1.33F, true);} + } + } + + @Override + public boolean isReplaceable(IBlockAccess world, int x, int y, int z) { + TileEntity te = world.getTileEntity(x, y, z); + return super.isReplaceable(world, x, y, z) || (((world instanceof World && ((World) world).isRemote) ? NewPacketHandler.trapsDisabled : !ModjamMod.spawnTraps) && (te == null || !(te instanceof TileEntityTrap) || ((TileEntityTrap) te).placedBy == null)); + } + + @Override + @SideOnly(Side.CLIENT) + public boolean isCollidable() {return super.isCollidable();} + + @Override + public boolean canPlaceBlockAt(World world, int x, int y, int z) { + return super.canPlaceBlockAt(world, x, y, z) && (y == 0 || world.getBlock(x, y - 1, z) != ModjamMod.blockTrap); + } + + @Override + public int damageDropped(int par1) { + return par1 % trapTypes; + } + + @Override + @SuppressWarnings({ "unchecked", "rawtypes" }) + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for(int i = 0; i < trapTypes; i++) {par3List.add(new ItemStack(par1, 1, i));} + } + + @Override + public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { + super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack); + + par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage(), 0); + + if(par5EntityLivingBase != null && par5EntityLivingBase instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) par5EntityLivingBase; + + if(!player.capabilities.isCreativeMode || NewPacketHandler.trapsDisabled) { + TileEntity te = par1World.getTileEntity(par2, par3, par4); + if(te != null && te instanceof TileEntityTrap) {((TileEntityTrap) te).placedBy = player.getCommandSenderName();} + } + } + } + + @Override + public boolean isShearable(ItemStack item, IBlockAccess blockAccess, int x, int y, int z) {return true;} + + @Override + public ArrayList onSheared(ItemStack item, IBlockAccess blockAccess, int x, int y, int z, int fortune) { + if(blockAccess instanceof World) { + World world = (World) blockAccess; + + world.setBlockToAir(x, y, z); + + if(!world.isRemote) { + MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); + + for(int i = 0; i < server.worldServers.length; i++) { + WorldServer s = FMLCommonHandler.instance().getMinecraftServerInstance().worldServers[i]; + + if(s == null) {continue;} + + for(Object o : s.playerEntities) { + if(o == null || !(o instanceof EntityPlayer)) {continue;} + + EntityPlayer player = (EntityPlayer) o; + + if(item.equals(player.getHeldItem())) { + NewPacketHandler.SEND_MESSAGE.sendToPlayer(player, "\u00A7e\u00A7oYou disarmed the trap."); + } + } + } + } + + item.attemptDamageItem(119, ModjamMod.r); + } + + return new ArrayList(); + } + + + @Override + public float getPlayerRelativeBlockHardness(EntityPlayer par1EntityPlayer, World par2World, int par3, int par4, int par5) { + return (par1EntityPlayer.getHeldItem() != null && par1EntityPlayer.getHeldItem().getItem() == Items.shears) ? 1.0F : getBlockHardness(par2World, par3, par4, par5); + } +} diff --git a/fyresmodjam/commands/CommandCraftingStats.java b/java/fyresmodjam/commands/CommandCraftingStats.java similarity index 51% rename from fyresmodjam/commands/CommandCraftingStats.java rename to java/fyresmodjam/commands/CommandCraftingStats.java index e06fa3b..ec899f7 100644 --- a/fyresmodjam/commands/CommandCraftingStats.java +++ b/java/fyresmodjam/commands/CommandCraftingStats.java @@ -1,79 +1,69 @@ package fyresmodjam.commands; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; import java.util.List; - -import cpw.mods.fml.common.network.PacketDispatcher; -import cpw.mods.fml.common.network.Player; -import fyresmodjam.ModjamMod; -import fyresmodjam.handlers.PacketHandler; -import fyresmodjam.misc.EntityStatHelper; - import net.minecraft.command.ICommand; import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; +import fyresmodjam.ModjamMod; +import fyresmodjam.handlers.NewPacketHandler; +import fyresmodjam.misc.EntityStatHelper; public class CommandCraftingStats implements ICommand { + @Override public int compareTo(Object arg0) {return 0;} + @Override public String getCommandName() {return "craftingKnowledge";} + @Override public String getCommandUsage(ICommandSender icommandsender) {return "commands.craftingKnowledge.usage";} + @Override + @SuppressWarnings("rawtypes") public List getCommandAliases() {return null;} + @Override public void processCommand(ICommandSender icommandsender, String[] astring) { int page = astring.length > 0 ? Integer.parseInt(astring[0]) - 1 : 0, maxPage = 0; if(icommandsender instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer) icommandsender; String message = "\u00A7c\u00A7oCrafting stats not enabled."; - + if(ModjamMod.enableCraftingStats) { - message = "@Crafting Knowledge:"; //\u00A7e\u00A7o - + message = "@Crafting Knowledge:"; + if(entityplayer.getEntityData().hasKey("CraftingStats")) { NBTTagCompound craftingStats = entityplayer.getEntityData().getCompoundTag("CraftingStats"); - - ArrayList objects = new ArrayList(); - objects.addAll(craftingStats.getTags()); - - Collections.sort(objects, new Comparator() { - public int compare(Object o1, Object o2) { - int i = 0; - if(o1 instanceof NBTBase && o2 instanceof NBTBase) {i = ((NBTBase) o1).getName().compareTo(((NBTBase) o2).getName());} - return i; - } - }); - - maxPage = Math.max(0, (craftingStats.getTags().size())/4); - if(page > maxPage) {page = maxPage;} - if(page < 0) {page = 0;} - - message = "@Crafting Knowledge (page " + (page + 1) + "/" + (maxPage + 1) + "):"; - - int count = 0, skip = 0; - for(Object o : objects) { - if(skip < page * 4) {skip++; continue;} - if(o instanceof NBTBase) { - String mob = ((NBTBase) o).getName().replace("Kills", ""); - int kills = craftingStats.getInteger(((NBTBase) o).getName()); - + + String trackedItems = craftingStats.hasKey("TrackedItemList") ? craftingStats.getString("TrackedItemList") : ""; + + if(trackedItems != null && trackedItems.length() > 0) { + String[] trackedItemList = trackedItems.split(";"); + + maxPage = Math.max(0, (craftingStats.func_150296_c().size() - 1)/4); + if(page > maxPage) {page = maxPage;} + if(page < 0) {page = 0;} + + message = "@Crafting Knowledge (page " + (page + 1) + "/" + (maxPage + 1) + "):"; + + int count = 0, skip = 0; + for(String item : trackedItemList) { + if(skip < page * 4) {skip++; continue;} + + int kills = craftingStats.getInteger(item); + int last = 0; for(int i = 0; i < EntityStatHelper.killCount.length; i++) { if(kills >= EntityStatHelper.killCount[i] * 2) {last = i; continue;} else {break;} } - - message += "@\u00A7b " + EntityStatHelper.knowledge[last] + " " + mob.toLowerCase() + " smith\u00A73 (" + kills + " craft(s)" + (last < EntityStatHelper.knowledge.length - 1 ? ", " + (EntityStatHelper.killCount[last + 1] * 2 - kills + " craft(s) to next rank)") : ")"); + + message += "@\u00A7b " + EntityStatHelper.knowledge[last] + " " + item.toLowerCase() + " smith\u00A73 (" + kills + " craft(s)" + (last < EntityStatHelper.knowledge.length - 1 ? ", " + (EntityStatHelper.killCount[last + 1] * 2 - kills + " craft(s) to next rank)") : ")"); count++; - + if(count >= 4) {break;} } } @@ -81,17 +71,21 @@ public int compare(Object o1, Object o2) { message += "@ You've yet to learn anything."; } } - - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {message}), (Player) entityplayer); + + NewPacketHandler.SEND_MESSAGE.sendToPlayer(entityplayer, message); } } + @Override public boolean canCommandSenderUseCommand(ICommandSender icommandsender) {return true;} + @Override + @SuppressWarnings("rawtypes") public List addTabCompletionOptions(ICommandSender icommandsender, String[] astring) {return null;} + @Override public boolean isUsernameIndex(String[] astring, int i) {return false;} - + public int getRequiredPermissionLevel() {return 0;} - + } diff --git a/fyresmodjam/commands/CommandCurrentBlessing.java b/java/fyresmodjam/commands/CommandCurrentBlessing.java similarity index 71% rename from fyresmodjam/commands/CommandCurrentBlessing.java rename to java/fyresmodjam/commands/CommandCurrentBlessing.java index b9e64be..c1c3157 100644 --- a/fyresmodjam/commands/CommandCurrentBlessing.java +++ b/java/fyresmodjam/commands/CommandCurrentBlessing.java @@ -2,45 +2,50 @@ import java.util.List; - -import cpw.mods.fml.common.network.PacketDispatcher; -import cpw.mods.fml.common.network.Player; -import fyresmodjam.handlers.PacketHandler; -import fyresmodjam.tileentities.TileEntityPillar; - import net.minecraft.command.ICommand; import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; +import fyresmodjam.handlers.NewPacketHandler; +import fyresmodjam.tileentities.TileEntityPillar; public class CommandCurrentBlessing implements ICommand { + @Override public int compareTo(Object arg0) {return 0;} + @Override public String getCommandName() {return "currentBlessing";} + @Override public String getCommandUsage(ICommandSender icommandsender) {return "commands.currentBlessing.usage";} + @Override + @SuppressWarnings("rawtypes") public List getCommandAliases() {return null;} + @Override public void processCommand(ICommandSender icommandsender, String[] astring) { if(icommandsender instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer) icommandsender; - + String blessing = entityplayer.getEntityData().hasKey("Blessing") ? entityplayer.getEntityData().getString("Blessing") : null; int index = 0; for(int i = 0; i < TileEntityPillar.validBlessings.length; i++) {if(TileEntityPillar.validBlessings[i].equals(blessing)) {index = i; break;}} - - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {blessing != null ? "\u00A7eCurrent Blessing - \u00A7oBlessing of the " + blessing + ": " + TileEntityPillar.blessingDescriptions[index] : "You don't currently have a blessing."}), (Player) entityplayer); + + NewPacketHandler.SEND_MESSAGE.sendToPlayer(entityplayer, blessing != null ? "\u00A7eCurrent Blessing - \u00A7oBlessing of the " + blessing + ": " + TileEntityPillar.blessingDescriptions[index] : "You don't currently have a blessing."); } } + @Override public boolean canCommandSenderUseCommand(ICommandSender icommandsender) {return true;} + @Override + @SuppressWarnings("rawtypes") public List addTabCompletionOptions(ICommandSender icommandsender, String[] astring) {return null;} + @Override public boolean isUsernameIndex(String[] astring, int i) {return false;} - + public int getRequiredPermissionLevel() {return 0;} - + } diff --git a/fyresmodjam/commands/CommandCurrentDisadvantage.java b/java/fyresmodjam/commands/CommandCurrentDisadvantage.java similarity index 71% rename from fyresmodjam/commands/CommandCurrentDisadvantage.java rename to java/fyresmodjam/commands/CommandCurrentDisadvantage.java index 399b8a4..0a9e690 100644 --- a/fyresmodjam/commands/CommandCurrentDisadvantage.java +++ b/java/fyresmodjam/commands/CommandCurrentDisadvantage.java @@ -2,44 +2,49 @@ import java.util.List; - -import cpw.mods.fml.common.network.PacketDispatcher; -import cpw.mods.fml.common.network.Player; -import fyresmodjam.handlers.CommonTickHandler; -import fyresmodjam.handlers.PacketHandler; -import fyresmodjam.worldgen.FyresWorldData; - import net.minecraft.command.ICommand; import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; +import fyresmodjam.handlers.CommonTickHandler; +import fyresmodjam.handlers.NewPacketHandler; +import fyresmodjam.worldgen.FyresWorldData; public class CommandCurrentDisadvantage implements ICommand { + @Override public int compareTo(Object arg0) {return 0;} + @Override public String getCommandName() {return "currentDisadvantage";} + @Override public String getCommandUsage(ICommandSender icommandsender) {return "commands.currentDisadvantage.usage";} + @Override + @SuppressWarnings("rawtypes") public List getCommandAliases() {return null;} + @Override public void processCommand(ICommandSender icommandsender, String[] astring) { if(icommandsender instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer) icommandsender; - + int index = -1; for(int i = 0; i < FyresWorldData.validDisadvantages.length; i++) {if(FyresWorldData.validDisadvantages[i].equals(CommonTickHandler.worldData.getDisadvantage())) {index = i; break;}} - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7eWorld disadvantage: " + CommonTickHandler.worldData.getDisadvantage() + (index == -1 ? "" : " (" + FyresWorldData.disadvantageDescriptions[index] + ")")}), (Player) entityplayer); + NewPacketHandler.SEND_MESSAGE.sendToPlayer(entityplayer, "\u00A7eWorld disadvantage: " + CommonTickHandler.worldData.getDisadvantage() + (index == -1 ? "" : " (" + FyresWorldData.disadvantageDescriptions[index] + ")")); } } + @Override public boolean canCommandSenderUseCommand(ICommandSender icommandsender) {return true;} + @Override + @SuppressWarnings("rawtypes") public List addTabCompletionOptions(ICommandSender icommandsender, String[] astring) {return null;} + @Override public boolean isUsernameIndex(String[] astring, int i) {return false;} - + public int getRequiredPermissionLevel() {return 0;} - + } diff --git a/fyresmodjam/commands/CommandCurrentWorldTask.java b/java/fyresmodjam/commands/CommandCurrentWorldTask.java similarity index 54% rename from fyresmodjam/commands/CommandCurrentWorldTask.java rename to java/fyresmodjam/commands/CommandCurrentWorldTask.java index 54b88fd..e0ea79a 100644 --- a/fyresmodjam/commands/CommandCurrentWorldTask.java +++ b/java/fyresmodjam/commands/CommandCurrentWorldTask.java @@ -2,53 +2,58 @@ import java.util.List; - -import cpw.mods.fml.common.network.PacketDispatcher; -import cpw.mods.fml.common.network.Player; -import fyresmodjam.handlers.CommonTickHandler; -import fyresmodjam.handlers.PacketHandler; -import fyresmodjam.worldgen.FyresWorldData; - import net.minecraft.command.ICommand; import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; +import fyresmodjam.handlers.CommonTickHandler; +import fyresmodjam.handlers.NewPacketHandler; +import fyresmodjam.worldgen.FyresWorldData; public class CommandCurrentWorldTask implements ICommand { + @Override public int compareTo(Object arg0) {return 0;} + @Override public String getCommandName() {return "currentGoal";} + @Override public String getCommandUsage(ICommandSender icommandsender) {return "commands.currentGoal.usage";} + @Override + @SuppressWarnings("rawtypes") public List getCommandAliases() {return null;} + @Override public void processCommand(ICommandSender icommandsender, String[] astring) { if(icommandsender instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer) icommandsender; - - String name = CommonTickHandler.worldData.currentTask.equals("Kill") ? FyresWorldData.validMobNames[CommonTickHandler.worldData.currentTaskID] : new ItemStack(Item.itemsList[CommonTickHandler.worldData.currentTaskID], 1).getDisplayName(); - + + String name = CommonTickHandler.worldData.currentTask.equals("Kill") ? FyresWorldData.validMobNames[CommonTickHandler.worldData.currentTaskID] : FyresWorldData.validItems[CommonTickHandler.worldData.currentTaskID].getDisplayName(); + if(CommonTickHandler.worldData.currentTaskAmount > 1) { if(name.contains("Block")) {if(name.contains("Block")) {name = name.replace("Block", "Blocks").replace("block", "blocks");}} else {name += "s";} } - - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7eWorld goal: " + CommonTickHandler.worldData.currentTask + " " + CommonTickHandler.worldData.currentTaskAmount + " " + name + ". (" + CommonTickHandler.worldData.progress + " " + CommonTickHandler.worldData.currentTask + "ed)"}), (Player) entityplayer); - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7f Reward: " + CommonTickHandler.worldData.rewardLevels + " Experience Levels"}), (Player) entityplayer); - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7eGoals completed: " + CommonTickHandler.worldData.tasksCompleted}), (Player) entityplayer); + + NewPacketHandler.SEND_MESSAGE.sendToPlayer(entityplayer, "\u00A7eWorld goal: " + CommonTickHandler.worldData.currentTask + " " + CommonTickHandler.worldData.currentTaskAmount + " " + name + ". (" + CommonTickHandler.worldData.progress + " " + CommonTickHandler.worldData.currentTask + "ed)"); + + NewPacketHandler.SEND_MESSAGE.sendToPlayer(entityplayer, "\u00A7f Reward: " + CommonTickHandler.worldData.rewardLevels + " Experience Levels"); + + NewPacketHandler.SEND_MESSAGE.sendToPlayer(entityplayer, "\u00A7eGoals completed: " + CommonTickHandler.worldData.tasksCompleted); } } + @Override public boolean canCommandSenderUseCommand(ICommandSender icommandsender) {return true;} + @Override + @SuppressWarnings("rawtypes") public List addTabCompletionOptions(ICommandSender icommandsender, String[] astring) {return null;} + @Override public boolean isUsernameIndex(String[] astring, int i) {return false;} - + public int getRequiredPermissionLevel() {return 0;} - + } diff --git a/fyresmodjam/commands/CommandKillStats.java b/java/fyresmodjam/commands/CommandKillStats.java similarity index 57% rename from fyresmodjam/commands/CommandKillStats.java rename to java/fyresmodjam/commands/CommandKillStats.java index d583c95..44c6559 100644 --- a/fyresmodjam/commands/CommandKillStats.java +++ b/java/fyresmodjam/commands/CommandKillStats.java @@ -1,80 +1,70 @@ package fyresmodjam.commands; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; import java.util.List; - -import cpw.mods.fml.common.network.PacketDispatcher; -import cpw.mods.fml.common.network.Player; -import fyresmodjam.ModjamMod; -import fyresmodjam.handlers.PacketHandler; -import fyresmodjam.misc.EntityStatHelper; - import net.minecraft.command.ICommand; import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; +import fyresmodjam.ModjamMod; +import fyresmodjam.handlers.NewPacketHandler; +import fyresmodjam.misc.EntityStatHelper; public class CommandKillStats implements ICommand { + @Override public int compareTo(Object arg0) {return 0;} + @Override public String getCommandName() {return "creatureKnowledge";} + @Override public String getCommandUsage(ICommandSender icommandsender) {return "commands.creatureKnowledge.usage";} + @Override + @SuppressWarnings("rawtypes") public List getCommandAliases() {return null;} + @Override public void processCommand(ICommandSender icommandsender, String[] astring) { int page = astring.length > 0 ? Integer.parseInt(astring[0]) - 1 : 0, maxPage = 0; - + if(icommandsender instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer) icommandsender; - + String message = "\u00A7c\u00A7oMob kill stats not enabled."; - + if(ModjamMod.enableMobKillStats) { - message = "@Creature Knowledge:"; //\u00A7e\u00A7o - + message = "@Creature Knowledge:"; + if(entityplayer.getEntityData().hasKey("KillStats")) { NBTTagCompound killStats = entityplayer.getEntityData().getCompoundTag("KillStats"); - - ArrayList objects = new ArrayList(); - objects.addAll(killStats.getTags()); - - Collections.sort(objects, new Comparator() { - public int compare(Object o1, Object o2) { - int i = 0; - if(o1 instanceof NBTBase && o2 instanceof NBTBase) {i = ((NBTBase) o1).getName().replace("Kills", "").compareTo(((NBTBase) o2).getName().replace("Kills", ""));} - return i; - } - }); - - maxPage = Math.max(0, (killStats.getTags().size())/4); - if(page > maxPage) {page = maxPage;} - if(page < 0) {page = 0;} - - message = "@Creature Knowledge (page " + (page + 1) + "/" + (maxPage + 1) + "):"; - - int count = 0, skip = 0; - for(Object o : objects) { - if(skip < page * 4) {skip++; continue;} - if(o instanceof NBTBase) { - String mob = ((NBTBase) o).getName().replace("Kills", ""); - int kills = killStats.getInteger(((NBTBase) o).getName()); + + String trackedMobs = killStats.hasKey("TrackedMobList") ? killStats.getString("TrackedMobList") : ""; + + if(trackedMobs != null && trackedMobs.length() > 0) { + String[] trackedMobList = trackedMobs.split(";"); + + maxPage = Math.max(0, (killStats.func_150296_c().size() - 1)/4); + if(page > maxPage) {page = maxPage;} + if(page < 0) {page = 0;} + + message = "@Creature Knowledge (page " + (page + 1) + "/" + (maxPage + 1) + "):"; + + int count = 0, skip = 0; + for(String mob : trackedMobList) { + if(skip < page * 4) {skip++; continue;} + int kills = killStats.getInteger(mob); + int last = 0; for(int i = 0; i < EntityStatHelper.killCount.length; i++) { if(kills >= EntityStatHelper.killCount[i]) {last = i; continue;} else {break;} } - + message += "@\u00A7b " + EntityStatHelper.knowledge[last] + " " + mob.toLowerCase() + " slayer\u00A73 " + (last > 0 ? "+" + EntityStatHelper.damageBonusString[last] + "% damage bonus (" : "(") + kills + " kill(s)" + (last < EntityStatHelper.knowledge.length - 1 ? ", " + (EntityStatHelper.killCount[last + 1] - kills + " kill(s) to next rank)") : ")"); count++; - + if(count >= 4) {break;} } } @@ -82,17 +72,21 @@ public int compare(Object o1, Object o2) { message += "@ You've yet to learn anything."; } } - - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {message}), (Player) entityplayer); + + NewPacketHandler.SEND_MESSAGE.sendToPlayer(entityplayer, message); } } + @Override public boolean canCommandSenderUseCommand(ICommandSender icommandsender) {return true;} + @Override + @SuppressWarnings("rawtypes") public List addTabCompletionOptions(ICommandSender icommandsender, String[] astring) {return null;} + @Override public boolean isUsernameIndex(String[] astring, int i) {return false;} - + public int getRequiredPermissionLevel() {return 0;} - + } diff --git a/java/fyresmodjam/commands/CommandWeaponStats.java b/java/fyresmodjam/commands/CommandWeaponStats.java new file mode 100644 index 0000000..57917b6 --- /dev/null +++ b/java/fyresmodjam/commands/CommandWeaponStats.java @@ -0,0 +1,91 @@ +package fyresmodjam.commands; + +import java.util.List; + +import net.minecraft.command.ICommand; +import net.minecraft.command.ICommandSender; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import fyresmodjam.ModjamMod; +import fyresmodjam.handlers.NewPacketHandler; +import fyresmodjam.misc.EntityStatHelper; + +public class CommandWeaponStats implements ICommand { + + @Override + public int compareTo(Object arg0) {return 0;} + + @Override + public String getCommandName() {return "weaponKnowledge";} + + @Override + public String getCommandUsage(ICommandSender icommandsender) {return "commands.weaponKnowledge.usage";} + + @Override + @SuppressWarnings("rawtypes") + public List getCommandAliases() {return null;} + + @Override + public void processCommand(ICommandSender icommandsender, String[] astring) { + int page = astring.length > 0 ? Integer.parseInt(astring[0]) - 1 : 0, maxPage = 0; + if(icommandsender instanceof EntityPlayer) { + EntityPlayer entityplayer = (EntityPlayer) icommandsender; + + String message = "\u00A7c\u00A7oWeapon kill stats not enabled."; + + if(ModjamMod.enableWeaponKillStats) { + message = "@Weapon Knowledge:"; + + if(entityplayer.getEntityData().hasKey("WeaponStats")) { + NBTTagCompound itemStats = entityplayer.getEntityData().getCompoundTag("WeaponStats"); + + String trackedItems = itemStats.hasKey("TrackedItemList") ? itemStats.getString("TrackedItemList") : ""; + + if(trackedItems != null && trackedItems.length() > 0) { + String[] trackedItemList = trackedItems.split(";"); + + maxPage = Math.max(0, (itemStats.func_150296_c().size())/4); + if(page > maxPage) {page = maxPage;} + if(page < 0) {page = 0;} + + message = "@Weapon Knowledge (page " + (page + 1) + "/" + (maxPage + 1) + "):"; + + int count = 0, skip = 0; + for(String item : trackedItemList) { + if(skip < page * 4) {skip++; continue;} + + int kills = itemStats.getInteger(item); + + int last = 0; + for(int i = 0; i < EntityStatHelper.killCount.length; i++) { + if(kills >= EntityStatHelper.killCount[i] * 2) {last = i; continue;} else {break;} + } + + message += "@\u00A7b " + EntityStatHelper.knowledge[last] + " " + item.toLowerCase() + " user\u00A73 " + (last > 0 ? "+" + EntityStatHelper.damageBonusString[last] + "% damage bonus (" : "(") + kills + " kill(s)" + (last < EntityStatHelper.knowledge.length - 1 ? ", " + (EntityStatHelper.killCount[last + 1] * 2 - kills + " kill(s) to next rank)") : ")"); + count++; + + if(count >= 4) {break;} + } + } + } else { + message += "@ You've yet to learn anything."; + } + } + + NewPacketHandler.SEND_MESSAGE.sendToPlayer(entityplayer, message); + } + } + + @Override + public boolean canCommandSenderUseCommand(ICommandSender icommandsender) {return true;} + + @Override + @SuppressWarnings("rawtypes") + public List addTabCompletionOptions(ICommandSender icommandsender, String[] astring) {return null;} + + @Override + public boolean isUsernameIndex(String[] astring, int i) {return false;} + + public int getRequiredPermissionLevel() {return 0;} + +} diff --git a/java/fyresmodjam/entities/EntityMysteryPotion.java b/java/fyresmodjam/entities/EntityMysteryPotion.java new file mode 100644 index 0000000..c5eeda6 --- /dev/null +++ b/java/fyresmodjam/entities/EntityMysteryPotion.java @@ -0,0 +1,173 @@ +package fyresmodjam.entities; + +import java.util.Iterator; +import java.util.List; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityThrowable; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import fyresmodjam.ModjamMod; +import fyresmodjam.handlers.CommonTickHandler; +import fyresmodjam.handlers.NewPacketHandler; + +public class EntityMysteryPotion extends EntityThrowable { + + public EntityMysteryPotion(World par1World) + { + super(par1World); + } + + public EntityMysteryPotion(World par1World, EntityLivingBase par2EntityLivingBase, int par3) + { + this(par1World, par2EntityLivingBase, null); + } + + public EntityMysteryPotion(World par1World, EntityLivingBase par2EntityLivingBase, ItemStack par4ItemStack) + { + super(par1World, par2EntityLivingBase); + + if(par4ItemStack != null) { + int damage = par4ItemStack.getItemDamage(); + dataWatcher.updateObject(24, damage); + if(damage % 13 < 12) {dataWatcher.updateObject(25, CommonTickHandler.worldData.potionDurations[damage % 13]);} + } + } + + @Override + public void entityInit() { + super.entityInit(); + + dataWatcher.addObject(24, 0); + dataWatcher.addObject(25, 0); + } + + @SideOnly(Side.CLIENT) + public EntityMysteryPotion(World par1World, double par2, double par4, double par6, int par8) + { + this(par1World, par2, par4, par6, new ItemStack(Items.potionitem, 1, par8)); + } + + public EntityMysteryPotion(World par1World, double par2, double par4, double par6, ItemStack par4ItemStack) + { + super(par1World, par2, par4, par6); + + if(par4ItemStack != null) { + int damage = par4ItemStack.getItemDamage(); + dataWatcher.updateObject(24, damage); + dataWatcher.updateObject(25, CommonTickHandler.worldData.potionDurations[damage % 13]); + } + } + + @Override + protected float getGravityVelocity() + { + return 0.05F; + } + + @Override + protected float func_70182_d() + { + return 0.5F; + } + + @Override + protected float func_70183_g() + { + return -20.0F; + } + + @Override + @SuppressWarnings("rawtypes") + protected void onImpact(MovingObjectPosition par1MovingObjectPosition) + { + if (!worldObj.isRemote) { + AxisAlignedBB axisalignedbb = boundingBox.expand(4.0D, 2.0D, 4.0D); + List list1 = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb); + + if(list1 != null && !list1.isEmpty()) { + int type = getDataWatcher().getWatchableObjectInt(24) % 13; + int j = type >= 12 ? (5 + ModjamMod.r.nextInt(26)) : getDataWatcher().getWatchableObjectInt(25); + + int damage = 0; + + if(type >= 12 || (getThrower().getEntityData().hasKey("Blessing") && getThrower().getEntityData().getString("Blessing").equals("Alchemist"))) { + damage = ModjamMod.r.nextInt(Potion.potionTypes.length); + while(Potion.potionTypes[damage] == null) {damage = ModjamMod.r.nextInt(Potion.potionTypes.length);} + } else { + damage = CommonTickHandler.worldData.potionValues[type]; + } + + Iterator iterator = list1.iterator(); + + while(iterator.hasNext()) { + EntityLivingBase entitylivingbase = (EntityLivingBase)iterator.next(); + double d0 = getDistanceSqToEntity(entitylivingbase); + + if(d0 < 16.0D) { + if(Potion.potionTypes[damage].isInstant()) { + Potion.potionTypes[damage].affectEntity(getThrower(), entitylivingbase, 1, 1); + } else { + entitylivingbase.addPotionEffect(new PotionEffect(damage, j * 20, 1, false)); + } + } + } + + if(getThrower() instanceof EntityPlayer) { + EntityPlayer par3EntityPlayer = (EntityPlayer) getThrower(); + + if(type < 12 && (!getThrower().getEntityData().hasKey("Blessing") || !getThrower().getEntityData().getString("Blessing").equals("Alchemist"))) { + if(!par3EntityPlayer.getEntityData().hasKey("PotionKnowledge")) {par3EntityPlayer.getEntityData().setIntArray("PotionKnowledge", new int[] {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1});} + + if(par3EntityPlayer.getEntityData().getIntArray("PotionKnowledge")[type] == -1) { + par3EntityPlayer.getEntityData().getIntArray("PotionKnowledge")[type] = 1; + + NewPacketHandler.UPDATE_POTION_KNOWLEDGE.sendToPlayer(par3EntityPlayer, par3EntityPlayer.getEntityData().getIntArray("PotionKnowledge")); + + Potion potion = Potion.potionTypes[CommonTickHandler.worldData.potionValues[type]]; + String name = StatCollector.translateToLocal(potion.getName()) + " Potion"; + + if(!potion.isInstant()) { + int time = CommonTickHandler.worldData.potionDurations[type]; + name += " (" + time + " seconds)"; + } + + NewPacketHandler.SEND_MESSAGE.sendToPlayer(par3EntityPlayer, "\u00A7oYou learnt Mystery Potion #" + (type + 1) + " was a " + name + "!"); + } + } else { + Potion potion = Potion.potionTypes[damage]; + String name = StatCollector.translateToLocal(potion.getName()) + " Potion"; + if(!potion.isInstant()) {name += " (" + j + " seconds)";} + + NewPacketHandler.SEND_MESSAGE.sendToPlayer(par3EntityPlayer, "\u00A7oYou threw a " + name + "."); + } + } + } + + worldObj.playAuxSFX(2002, (int)Math.round(posX), (int)Math.round(posY), (int)Math.round(posZ), 1); + setDead(); + } + } + + @Override + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readEntityFromNBT(par1NBTTagCompound); + } + + @Override + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeEntityToNBT(par1NBTTagCompound); + } +} diff --git a/java/fyresmodjam/entities/renderers/RenderMysteryPotion.java b/java/fyresmodjam/entities/renderers/RenderMysteryPotion.java new file mode 100644 index 0000000..479d34d --- /dev/null +++ b/java/fyresmodjam/entities/renderers/RenderMysteryPotion.java @@ -0,0 +1,88 @@ +package fyresmodjam.entities.renderers; + +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.entity.Entity; +import net.minecraft.entity.projectile.EntityPotion; +import net.minecraft.item.Item; +import net.minecraft.item.ItemPotion; +import net.minecraft.potion.PotionHelper; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import fyresmodjam.entities.EntityMysteryPotion; + +@SideOnly(Side.CLIENT) +public class RenderMysteryPotion extends Render +{ + private Item field_94151_a; + + public RenderMysteryPotion(Item par1Item) { + field_94151_a = par1Item; + } + + @Override + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + IIcon icon = (par1Entity instanceof EntityMysteryPotion) ? field_94151_a.getIconFromDamage(par1Entity.getDataWatcher().getWatchableObjectInt(24)) : field_94151_a.getIconFromDamage(0); + + if (icon != null) + { + GL11.glPushMatrix(); + GL11.glTranslatef((float)par2, (float)par4, (float)par6); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glScalef(0.5F, 0.5F, 0.5F); + bindEntityTexture(par1Entity); + Tessellator tessellator = Tessellator.instance; + + if (icon == ItemPotion.func_94589_d("bottle_splash")) + { + int i = PotionHelper.func_77915_a(((EntityPotion)par1Entity).getPotionDamage(), false); + float f2 = (i >> 16 & 255) / 255.0F; + float f3 = (i >> 8 & 255) / 255.0F; + float f4 = (i & 255) / 255.0F; + GL11.glColor3f(f2, f3, f4); + GL11.glPushMatrix(); + func_77026_a(tessellator, ItemPotion.func_94589_d("overlay")); + GL11.glPopMatrix(); + GL11.glColor3f(1.0F, 1.0F, 1.0F); + } + + func_77026_a(tessellator, icon); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } + } + + @Override + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return TextureMap.locationItemsTexture; + } + + private void func_77026_a(Tessellator par1Tessellator, IIcon par2Icon) + { + float f = par2Icon.getMinU(); + float f1 = par2Icon.getMaxU(); + float f2 = par2Icon.getMinV(); + float f3 = par2Icon.getMaxV(); + float f4 = 1.0F; + float f5 = 0.5F; + float f6 = 0.25F; + GL11.glRotatef(180.0F - renderManager.playerViewY, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-renderManager.playerViewX, 1.0F, 0.0F, 0.0F); + par1Tessellator.startDrawingQuads(); + par1Tessellator.setNormal(0.0F, 1.0F, 0.0F); + par1Tessellator.addVertexWithUV(0.0F - f5, 0.0F - f6, 0.0D, f, f3); + par1Tessellator.addVertexWithUV(f4 - f5, 0.0F - f6, 0.0D, f1, f3); + par1Tessellator.addVertexWithUV(f4 - f5, f4 - f6, 0.0D, f1, f2); + par1Tessellator.addVertexWithUV(0.0F - f5, f4 - f6, 0.0D, f, f2); + par1Tessellator.draw(); + } +} diff --git a/java/fyresmodjam/handlers/ClientTickHandler.java b/java/fyresmodjam/handlers/ClientTickHandler.java new file mode 100644 index 0000000..c816c10 --- /dev/null +++ b/java/fyresmodjam/handlers/ClientTickHandler.java @@ -0,0 +1,57 @@ +package fyresmodjam.handlers; + +import java.io.File; + +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.config.Configuration; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent; +import fyresmodjam.ModjamMod; +import fyresmodjam.misc.ItemStatHelper; + +public class ClientTickHandler { + + public static long time = System.currentTimeMillis(); + + @SubscribeEvent + public void clientTick(ClientTickEvent event) { + EntityPlayer player = Minecraft.getMinecraft().thePlayer; + + if(System.currentTimeMillis() - time > 200 && player != null) { + if(player.openContainer != null) { + boolean sendPacket = false; + + for(Object object : player.inventory.mainInventory) { + if(object == null || !(object instanceof ItemStack)) {continue;} + + ItemStack stack = (ItemStack) object; + + if(stack.getItem() != null && !ItemStatHelper.skip.contains(stack.getItem().getClass()) && (stack.getTagCompound() == null || !stack.getTagCompound().hasKey("processed") || stack.getTagCompound().getString("processed").equals("false"))) { + sendPacket = true; + } + } + + if(sendPacket) { + NewPacketHandler.UPDATE_PLAYER_ITEMS.sendToServer((Object) null); + time = System.currentTimeMillis(); + } + } + + player.triggerAchievement(ModjamMod.startTheGame); + } + + if(FyresKeyHandler.examine.getKeyCode() != ModjamMod.examineKey || FyresKeyHandler.activateBlessing.getKeyCode() != ModjamMod.blessingKey) { + ModjamMod.examineKey = FyresKeyHandler.examine.getKeyCode(); + ModjamMod.blessingKey = FyresKeyHandler.activateBlessing.getKeyCode(); + + Configuration config = new Configuration(new File(ModjamMod.configPath)); + config.load(); + config.get("Keybindings", "examine_key", ModjamMod.examineKey).set(ModjamMod.examineKey); + config.get("Keybindings", "blessing_key", ModjamMod.blessingKey).set(ModjamMod.blessingKey); + config.save(); + } + } + +} diff --git a/fyresmodjam/handlers/CommonTickHandler.java b/java/fyresmodjam/handlers/CommonTickHandler.java similarity index 52% rename from fyresmodjam/handlers/CommonTickHandler.java rename to java/fyresmodjam/handlers/CommonTickHandler.java index 93b4f57..a31926c 100644 --- a/fyresmodjam/handlers/CommonTickHandler.java +++ b/java/fyresmodjam/handlers/CommonTickHandler.java @@ -1,92 +1,83 @@ package fyresmodjam.handlers; import java.util.ArrayList; -import java.util.EnumSet; - import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.server.MinecraftServer; import net.minecraft.util.DamageSource; -import net.minecraft.world.World; import net.minecraft.world.WorldServer; - import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.ITickHandler; -import cpw.mods.fml.common.TickType; -import cpw.mods.fml.common.network.PacketDispatcher; -import cpw.mods.fml.common.network.Player; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent; +import cpw.mods.fml.common.gameevent.TickEvent.ServerTickEvent; +import cpw.mods.fml.common.gameevent.TickEvent.WorldTickEvent; import fyresmodjam.ModjamMod; import fyresmodjam.misc.EntityStatHelper; import fyresmodjam.worldgen.FyresWorldData; -public class CommonTickHandler implements ITickHandler { +public class CommonTickHandler { public static FyresWorldData worldData = null; - + public static ArrayList addLater = new ArrayList(); - @Override - public void tickStart(EnumSet type, Object... tickData) { - if(type.equals(EnumSet.of(TickType.WORLDLOAD))){ - for(int i = 0; i < tickData.length; i++) { - if(tickData[i] instanceof World && ((World) tickData[i]).provider.dimensionId == 0) { - worldData = FyresWorldData.forWorld((World) tickData[i]); - worldData.markDirty(); - } + @SubscribeEvent + public void worldTick(WorldTickEvent event) { + if(event.phase == TickEvent.Phase.START) { + if(event.world != null && event.world.provider.dimensionId == 0) { + worldData = FyresWorldData.forWorld(event.world); + worldData.markDirty(); } - } else if(type.equals(EnumSet.of(TickType.SERVER))) { - serverTick(); } - } - - public void serverTick() { + + @SubscribeEvent + public void serverTick(ServerTickEvent event) { MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); - + for(int i = 0; i < server.worldServers.length; i++) { WorldServer s = FMLCommonHandler.instance().getMinecraftServerInstance().worldServers[i]; - + if(s == null) {continue;} - + for(Object o : s.playerEntities) { if(o == null || !(o instanceof EntityPlayer)) {continue;} - + EntityPlayer player = (EntityPlayer) o; - + String blessing = player.getEntityData().hasKey("Blessing") ? player.getEntityData().getString("Blessing") : null; int coolDown = 0, counter = 0, timer = 0; boolean blessingActive = EntityStatHelper.hasStat(player, "BlessingActive") ? Boolean.parseBoolean(EntityStatHelper.getStat(player, "BlessingActive")) : false; - - /*if(EntityStatHelper.hasStat(player, "BlessingCooldown")) { + + if(EntityStatHelper.hasStat(player, "BlessingCooldown")) { coolDown = Integer.parseInt(EntityStatHelper.getStat(player, "BlessingCooldown")); if(coolDown > 0) {coolDown--;} - }*/ - + } + if(EntityStatHelper.hasStat(player, "BlessingTimer")) { timer = Integer.parseInt(EntityStatHelper.getStat(player, "BlessingTimer")); if(blessingActive) {timer++;} else {timer = 0;} } - + if(EntityStatHelper.hasStat(player, "BlessingCounter")) { counter = Integer.parseInt(EntityStatHelper.getStat(player, "BlessingCounter")); - + if(blessing != null) { if(blessingActive && blessing.equals("Berserker") && timer % 40 == 0) { counter = Math.max(0, counter - 1); - + if(counter == 0) { - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7cYou calm down."}), (Player) player); - coolDown = (int) (player.worldObj.getWorldTime() + 1200); timer = 0; blessingActive = false; + NewPacketHandler.SEND_MESSAGE.sendToPlayer(player, "\u00A7cYou calm down."); + coolDown = 1200; timer = 0; blessingActive = false; } } } } - + if(blessing != null) { if(player.isSneaking() && blessing.equals("Ninja")) { PotionEffect e = player.getActivePotionEffect(Potion.invisibility); @@ -95,21 +86,16 @@ public void serverTick() { player.setAir(0); } else if(blessing.equals("Inferno") && player.isWet() && player.ticksExisted % 10 == 0) { player.attackEntityFrom(DamageSource.drown, 1.0F); - }/* else if(blessing.equals("Healer")) { - if(player.worldObj.getGameRules().getGameRuleBooleanValue("naturalRegeneration") && ((player.worldObj.difficultySetting == 0 && player.func_110143_aJ() < player.func_110138_aP() && player.ticksExisted % 20 * 12 == 0) || (player.getFoodStats().getFoodLevel() >= 18 && player.getEntityData().getInteger("foodTickTimer") >= 80 && player.shouldHeal()))) { - player.heal(1.0F); - System.out.println(true); - } - }*/ + } } + + if(EntityStatHelper.hasStat(player, "BlessingCounter") && Integer.parseInt(EntityStatHelper.getStat(player, "BlessingCounter")) != counter) {NewPacketHandler.UPDATE_STAT.sendToPlayer(player, "BlessingCounter", "" + counter);} EntityStatHelper.giveStat(player, "BlessingActive", blessingActive); - if(coolDown != 0) {EntityStatHelper.giveStat(player, "BlessingCooldown", coolDown);} + EntityStatHelper.giveStat(player, "BlessingCooldown", coolDown); EntityStatHelper.giveStat(player, "BlessingCounter", counter); EntityStatHelper.giveStat(player, "BlessingTimer", timer); - - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.UPDATE_STATS, new Object[] {1, "BlessingCounter", "" + counter}), (Player) player); - //PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.UPDATE_STATS, new Object[] {2, "BlessingCounter", "" + counter, "BlessingActive", "" + blessingActive}), (Player) player); + } for(Object o : s.loadedEntityList) { @@ -117,60 +103,60 @@ public void serverTick() { if(o instanceof EntityItem) { EntityItem item = (EntityItem) o; - + if(((EntityItem) o).isBurning()) { ItemStack stack = item.getDataWatcher().getWatchableObjectItemStack(10); - - if(worldData.currentTask.equals("Burn") && stack.getItem().itemID == worldData.currentTaskID) { + + if(worldData.currentTask.equals("Burn") && (stack.getItem() == FyresWorldData.validItems[worldData.currentTaskID].getItem() && stack.getItemDamage() == FyresWorldData.validItems[worldData.currentTaskID].getItemDamage())) { worldData.progress += stack.stackSize; ((EntityItem) o).isDead = true; - - String name1 = CommonTickHandler.worldData.currentTask.equals("Kill") ? FyresWorldData.validMobNames[CommonTickHandler.worldData.currentTaskID] : new ItemStack(Item.itemsList[CommonTickHandler.worldData.currentTaskID], 1).getDisplayName(); - + + String name1 = CommonTickHandler.worldData.currentTask.equals("Kill") ? FyresWorldData.validMobNames[CommonTickHandler.worldData.currentTaskID] : FyresWorldData.validItems[CommonTickHandler.worldData.currentTaskID].getDisplayName(); + if(name1.contains("Block")) {if(name1.contains("Block")) {name1 = name1.replace("Block", "Blocks").replace("block", "blocks");}} else {name1 += "s";} - - PacketDispatcher.sendPacketToAllPlayers(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7fCurrent Goal Progress: " + worldData.progress + "/" + worldData.currentTaskAmount + " " + name1 + " "+ worldData.currentTask + "ed."})); - + + NewPacketHandler.SEND_MESSAGE.sendToAllPlayers("\u00A7fCurrent Goal Progress: " + worldData.progress + "/" + worldData.currentTaskAmount + " " + name1 + " "+ worldData.currentTask + "ed."); + if(worldData.progress >= worldData.currentTaskAmount) { worldData.progress = 0; worldData.tasksCompleted++; - - PacketDispatcher.sendPacketToAllPlayers(PacketHandler.newPacket(PacketHandler.LEVEL_UP, new Object[] {worldData.rewardLevels})); - + + NewPacketHandler.LEVEL_UP.sendToAllPlayers(worldData.rewardLevels); + worldData.giveNewTask(); - - - String name = worldData.currentTask.equals("Kill") ? FyresWorldData.validMobNames[worldData.currentTaskID] : new ItemStack(Item.itemsList[worldData.currentTaskID], 1).getDisplayName(); - + + + String name = worldData.currentTask.equals("Kill") ? FyresWorldData.validMobNames[worldData.currentTaskID] : FyresWorldData.validItems[worldData.currentTaskID].getDisplayName(); + if(worldData.currentTaskAmount > 1) { if(name.contains("Block")) {if(name.contains("Block")) {name = name.replace("Block", "Blocks").replace("block", "blocks");}} else {name += "s";} } - - PacketDispatcher.sendPacketToAllPlayers(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7eA world goal has been completed!" + (!worldData.getDisadvantage().equals("None") ? " World disadvantage has been lifted!": "")})); - PacketDispatcher.sendPacketToAllPlayers(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7eA new world goal has been set: " + (worldData.currentTask + " " + worldData.currentTaskAmount + " " + name + ". (" + worldData.progress + " " + worldData.currentTask + "ed)")})); - //PacketDispatcher.sendPacketToAllPlayers(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7eGoal Reward: " + worldData.rewardLevels + " experience levels"})); - + + NewPacketHandler.SEND_MESSAGE.sendToAllPlayers("\u00A7eA world goal has been completed!" + (!worldData.getDisadvantage().equals("None") ? " World disadvantage has been lifted!": "")); + + NewPacketHandler.SEND_MESSAGE.sendToAllPlayers("\u00A7eA new world goal has been set: " + (worldData.currentTask + " " + worldData.currentTaskAmount + " " + name + ". (" + worldData.progress + " " + worldData.currentTask + "ed)")); + worldData.currentDisadvantage = "None"; } - - PacketDispatcher.sendPacketToAllPlayers(PacketHandler.newPacket(PacketHandler.UPDATE_WORLD_DATA, new Object[] {worldData.potionValues, worldData.potionDurations, worldData.getDisadvantage(), worldData.currentTask, worldData.currentTaskID, worldData.currentTaskAmount, worldData.progress, worldData.tasksCompleted, worldData.enderDragonKilled, ModjamMod.spawnTraps, worldData.rewardLevels, worldData.mushroomColors})); - + + NewPacketHandler.UPDATE_WORLD_DATA.sendToAllPlayers(worldData.potionValues, worldData.potionDurations, worldData.getDisadvantage(), worldData.currentTask, worldData.currentTaskID, worldData.currentTaskAmount, worldData.progress, worldData.tasksCompleted, worldData.enderDragonKilled, ModjamMod.spawnTraps, worldData.rewardLevels, worldData.mushroomColors); + worldData.setDirty(true); } } } } } - + for(Entity e : addLater) { WorldServer world = null; for(WorldServer s : MinecraftServer.getServer().worldServers) {if(s.provider.dimensionId == e.dimension) {world = s; break;}} if(world != null) {world.spawnEntityInWorld(e);} } addLater.clear(); - + if(worldData != null) { if(worldData.getDisadvantage().equals("Neverending Rain")) { if(!MinecraftServer.getServer().worldServers[0].getWorldInfo().isRaining()) {MinecraftServer.getServer().worldServers[0].getWorldInfo().setRaining(true);} @@ -180,19 +166,4 @@ public void serverTick() { } } } - - @Override - public void tickEnd(EnumSet type, Object... tickData) { - - } - - @Override - public EnumSet ticks() { - return EnumSet.of(TickType.SERVER, TickType.WORLDLOAD); - } - - @Override - public String getLabel() { - return "FyresModJamCommonTicker"; - } } \ No newline at end of file diff --git a/java/fyresmodjam/handlers/FyresKeyHandler.java b/java/fyresmodjam/handlers/FyresKeyHandler.java new file mode 100644 index 0000000..bf6357f --- /dev/null +++ b/java/fyresmodjam/handlers/FyresKeyHandler.java @@ -0,0 +1,110 @@ +package fyresmodjam.handlers; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.settings.KeyBinding; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.MovingObjectPosition.MovingObjectType; + +import org.lwjgl.input.Keyboard; + +import cpw.mods.fml.client.registry.ClientRegistry; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.InputEvent.KeyInputEvent; +import fyresmodjam.ModjamMod; +import fyresmodjam.blocks.BlockTrap; +import fyresmodjam.items.ItemTrap; +import fyresmodjam.tileentities.TileEntityPillar; +import fyresmodjam.tileentities.TileEntityTrap; + +public class FyresKeyHandler { + + public static KeyBinding examine = new KeyBinding("Examine", Keyboard.KEY_X, "YWD"); + public static KeyBinding activateBlessing = new KeyBinding("Activate Blessing", Keyboard.KEY_K, "YWD"); + + public static KeyBinding[] keyBindings = new KeyBinding[] {examine, activateBlessing}; + + public FyresKeyHandler() { + for(KeyBinding k : keyBindings) {ClientRegistry.registerKeyBinding(k);} + } + + @SubscribeEvent + public void keyInput(KeyInputEvent event) { + if(Minecraft.getMinecraft().inGameHasFocus) { + Minecraft minecraft = Minecraft.getMinecraft(); + EntityPlayer player = minecraft.thePlayer; + + if(player != null) { + if(examine.isPressed()) { + if(minecraft.objectMouseOver != null) { + + MovingObjectPosition o = minecraft.objectMouseOver; + + if(o.typeOfHit == MovingObjectType.BLOCK) { + int x = minecraft.objectMouseOver.blockX; + int y = minecraft.objectMouseOver.blockY; + int z = minecraft.objectMouseOver.blockZ; + + if(minecraft.theWorld.getBlock(x, y, z) == ModjamMod.blockPillar && (minecraft.theWorld.getBlockMetadata(x, y, z) % 2) == 1) {y--;} + + TileEntity te = minecraft.theWorld.getTileEntity(x, y, z); + + if(te != null && te instanceof TileEntityPillar) { + int index = 0; + for(int i = 0; i < TileEntityPillar.validBlessings.length; i++) {if(TileEntityPillar.validBlessings[i].equals(((TileEntityPillar) te).blessing)) {index = i; break;}} + + String s = "@\u00A7eBlessing of the " + ((TileEntityPillar) te).blessing + ": " + TileEntityPillar.blessingDescriptions[index] + "."; + + for(String s2 : s.split("@")) { + //Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new ChatComponentText(s2)); + + NewPacketHandler.SEND_MESSAGE.data = new Object[] {s2}; + NewPacketHandler.SEND_MESSAGE.executeClient(Minecraft.getMinecraft().thePlayer); + } + + } else if(te != null && te instanceof TileEntityTrap) { + String placedBy = ((TileEntityTrap) te).placedBy; + + String s = (placedBy != null ? "\u00A7eThis " + ItemTrap.names[te.getBlockMetadata() % BlockTrap.trapTypes].toLowerCase() + " was placed by " + (placedBy.equals(player.getCommandSenderName()) ? "you": placedBy) + "." : "\u00A7eThis " + ItemTrap.names[te.getBlockMetadata() % BlockTrap.trapTypes].toLowerCase() + " doesn't seem to have been placed by anyone."); + s += " \u00A7eTrap is set to " + TileEntityTrap.settings[((TileEntityTrap) te).setting] + "."; + + //Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new ChatComponentText(s)); + + NewPacketHandler.SEND_MESSAGE.data = new Object[] {s}; + NewPacketHandler.SEND_MESSAGE.executeClient(Minecraft.getMinecraft().thePlayer); + } else { + ItemStack stack = new ItemStack(minecraft.theWorld.getBlock(x, y, z), 1, minecraft.theWorld.getBlockMetadata(x, y, z)); + + if(stack.getItem() != null) { + String name = stack.getDisplayName().toLowerCase(); + + //Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new ChatComponentText("\u00A7eIt's a " + name + (!name.contains("block") ? " block." : "."))); + + NewPacketHandler.SEND_MESSAGE.data = new Object[] {"\u00A7eIt's a " + name + (!name.contains("block") ? " block." : ".")}; + NewPacketHandler.SEND_MESSAGE.executeClient(Minecraft.getMinecraft().thePlayer); + } + } + } else if(o.typeOfHit == MovingObjectType.ENTITY && o.entityHit != null) { + NewPacketHandler.EXAMINE_MOB.sendToServer(o.entityHit.dimension, o.entityHit.getEntityId()); + } + } + } + + if(activateBlessing.isPressed()) { + String blessing = player.getEntityData().getString("Blessing"); + + if(blessing != null) { + if(minecraft.objectMouseOver != null) { + MovingObjectPosition o = minecraft.objectMouseOver; + if(o.typeOfHit == MovingObjectType.BLOCK) {NewPacketHandler.ACTIVATE_BLESSING.sendToServer(minecraft.objectMouseOver.blockX, minecraft.objectMouseOver.blockY, minecraft.objectMouseOver.blockZ);} + } else { + NewPacketHandler.ACTIVATE_BLESSING.sendToServer(player.chunkCoordX, player.chunkCoordY, player.chunkCoordZ); + } + } + } + } + } + } +} diff --git a/fyresmodjam/handlers/GUIHandler.java b/java/fyresmodjam/handlers/GUIHandler.java similarity index 100% rename from fyresmodjam/handlers/GUIHandler.java rename to java/fyresmodjam/handlers/GUIHandler.java diff --git a/java/fyresmodjam/handlers/NewPacketHandler.java b/java/fyresmodjam/handlers/NewPacketHandler.java new file mode 100644 index 0000000..56dcc47 --- /dev/null +++ b/java/fyresmodjam/handlers/NewPacketHandler.java @@ -0,0 +1,516 @@ +package fyresmodjam.handlers; + +import fyresmodjam.ModjamMod; +import fyresmodjam.blocks.BlockTrap; +import fyresmodjam.misc.EntityStatHelper; +import fyresmodjam.misc.ItemStatHelper; +import fyresmodjam.tileentities.TileEntityTrap; +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; + +import java.nio.charset.Charset; +import java.util.ArrayList; + +import net.minecraft.client.Minecraft; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.network.INetHandler; +import net.minecraft.network.NetHandlerPlayServer; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.server.MinecraftServer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.DamageSource; +import net.minecraft.world.WorldServer; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec; +import cpw.mods.fml.common.network.FMLOutboundHandler; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SuppressWarnings("rawtypes") +public class NewPacketHandler { + + public static BasicPacket[] packetTypes = new BasicPacket[256]; + + public static int[] potionValues = new int[12]; + public static int[] potionDurations = new int[12]; + + public static int[][] mushroomColors = new int[13][2]; + + public static String currentDisadvantage = null; + + public static String currentTask = null; + public static int currentTaskID = -1; + public static int currentTaskAmount = 0; + public static int progress = 0; + public static int tasksCompleted = 0; + public static int rewardLevels = 0; + + public static boolean enderDragonKilled = false; + public static boolean trapsDisabled = false; + + public static interface IPacket { + public void readBytes(ByteBuf bytes); + public void writeBytes(ByteBuf bytes); + public void executeClient(EntityPlayer player); + public void executeServer(EntityPlayer player); + public void executeBoth(EntityPlayer player); + } + + public static class ChannelHandler extends FMLIndexedMessageToMessageCodec { + + public ChannelHandler() { + addDiscriminator(0, BasicPacket.class); + } + + @Override + public void encodeInto(ChannelHandlerContext ctx, IPacket packet, ByteBuf data) throws Exception { + packet.writeBytes(data); + } + + @Override + public void decodeInto(ChannelHandlerContext ctx, ByteBuf data, IPacket packet) { + packet.readBytes(data); + + if(packet instanceof BasicPacket) {packetTypes[((BasicPacket) packet).type].data = ((BasicPacket) packet).data;} + + EntityPlayer player = null; + + switch (FMLCommonHandler.instance().getEffectiveSide()) { + + case CLIENT: + + player = getClientPlayer(); + + if(player != null) { + packet.executeClient(player); + packet.executeBoth(player); + } + + break; + + case SERVER: + + INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get(); + player = ((NetHandlerPlayServer) netHandler).playerEntity; + + if(player != null) { + packet.executeServer(player); + packet.executeBoth(player); + } + + break; + + default: break; + + } + } + + @SideOnly(Side.CLIENT) + public EntityPlayer getClientPlayer() {return Minecraft.getMinecraft().thePlayer;} + } + + public static class BasicPacket implements IPacket { + public static Class[] validClassArray = {Integer.class, Boolean.class, String.class, Character.class, Byte.class, Float.class, Double.class, int[].class, int[][].class}; + public static ArrayList validClasses = new ArrayList(); + static {for(Class c : validClassArray) {validClasses.add(c);}} + + public Object[] data = null; + public byte type; + + public BasicPacket() {} + + public BasicPacket(int type) { + if(type == 0 || packetTypes[type] != null) {throw new RuntimeException("Packet slot " + type + " already in use.");} + packetTypes[type] = this; + this.type = (byte) type; + } + + public BasicPacket(BasicPacket packet, Object... data) { + if(packet.type > 0 && packet.type < packetTypes.length && packet == packetTypes[packet.type]) {type = packet.type;} else {throw new RuntimeException("Must supply valid packet type.");} + + Class[] classes = getExpectedClasses(); + + if(classes != null) { + for(Class c : classes) { + if(!validClasses.contains(c)) {throw new RuntimeException("Argument class not valid. (" + c + ")");} + } + + if(data == null || data.length != classes.length) { + throw new RuntimeException("Wrong number of arguments provided."); + } else { + for(int i = 0; i < data.length; i++) { + if(data[i].getClass() != classes[i]) {throw new RuntimeException("Wrong argument class provided. (" + data[i].getClass() + ", expected " + classes[i] + ")");} + } + } + } + + this.data = data; + } + + @Override + public void readBytes(ByteBuf bytes) { + type = bytes.readByte(); + + Class[] classes = getExpectedClasses(); + + if(classes != null) { + data = new Object[classes.length]; + + for(int i = 0; i < classes.length; i++) { + if(classes[i] == Integer.class) {data[i] = bytes.readInt();} + if(classes[i] == int[].class) {int[] array = new int[bytes.readInt()]; for(int i2 = 0; i2 < array.length; i2++) {array[i2] = bytes.readInt();} data[i] = array;} + if(classes[i] == int[][].class) { + int[][] array = new int[bytes.readInt()][]; + + for(int i2 = 0; i2 < array.length; i2++) { + array[i2] = new int[bytes.readInt()]; + for(int i3 = 0; i3 < array[i2].length; i3++) {array[i2][i3] = bytes.readInt();} + } + + data[i] = array; + } else if(classes[i] == Boolean.class) {data[i] = bytes.readBoolean();} + else if(classes[i] == String.class) { + int length = bytes.readInt(); + try{ + byte[] stringBytes = new byte[length]; + bytes.readBytes(stringBytes); + data[i] = new String(stringBytes, "UTF-8"); + } catch(Exception e) {e.printStackTrace();} + } else if(classes[i] == Byte.class) {data[i] = bytes.readByte();} + else if(classes[i] == Float.class) {data[i] = bytes.readDouble();} + else if(classes[i] == Double.class) {data[i] = bytes.readFloat();} + else if(classes[i] == Character.class) {data[i] = bytes.readChar();} + } + } + } + + @Override + public void writeBytes(ByteBuf bytes) { + bytes.writeByte(type); + + if(data != null) { + for(int i = 0; i < data.length; i++) { + if(data[i] instanceof Integer) {bytes.writeInt((Integer) data[i]);} + else if(data[i] instanceof int[]) { + bytes.writeInt(((int[]) data[i]).length); + for(int i2 = 0; i2 < ((int[]) data[i]).length; i2++) {bytes.writeInt(((int[]) data[i])[i2]);} + } else if(data[i] instanceof int[][]) { + int[][] values = (int[][]) data[i]; + + bytes.writeInt(values.length); + + for(int i2 = 0; i2 < values.length; i2++) { + bytes.writeInt(values[i2].length); + for(int i3 = 0; i3 < values[i2].length; i3++) {bytes.writeInt(values[i2][i3]);} + } + } else if(data[i] instanceof Boolean) {bytes.writeBoolean((Boolean) data[i]);} + else if(data[i] instanceof String) { + byte[] stringBytes = ((String) data[i]).getBytes(Charset.forName("UTF-8")); + bytes.writeInt(stringBytes.length); + bytes.writeBytes(stringBytes); + } else if(data[i] instanceof Byte) {bytes.writeByte((Byte) data[i]);} + else if(data[i] instanceof Float) {bytes.writeDouble((Double) data[i]);} + else if(data[i] instanceof Double) {bytes.writeFloat((Float) data[i]);} + else if(data[i] instanceof Character) {bytes.writeChar((Character) data[i]);} + } + } + } + + @Override + public void executeClient(EntityPlayer player) { + if(packetTypes[type] != this) {packetTypes[type].executeClient(player);} + } + + @Override + public void executeServer(EntityPlayer player) { + if(packetTypes[type] != this) {packetTypes[type].executeServer(player);} + } + + @Override + public void executeBoth(EntityPlayer player) { + if(packetTypes[type] != this) {packetTypes[type].executeBoth(player);} + } + + public Class[] getExpectedClasses() {if(packetTypes[type] != this) {return packetTypes[type].getExpectedClasses();} else {return null;}} + + public void sendToPlayer(EntityPlayer player, Object... data) { + sendPacketToPlayer(new BasicPacket(this, data), player); + } + + public void sendToAllPlayers(Object... data) { + sendPacketToAllPlayers(new BasicPacket(this, data)); + } + + public void sendToServer(Object... data) { + sendPacketToServer(new BasicPacket(this, data)); + } + } + + public static void sendPacketToPlayer(IPacket packet, EntityPlayer player) { + ModjamMod.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER); + ModjamMod.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(player); + ModjamMod.channels.get(Side.SERVER).writeOutbound(packet); + } + + public static void sendPacketToAllPlayers(IPacket packet) { + ModjamMod.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALL); + ModjamMod.channels.get(Side.SERVER).writeOutbound(packet); + } + + public static void sendPacketToServer(IPacket packet) { + ModjamMod.channels.get(Side.CLIENT).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.TOSERVER); + ModjamMod.channels.get(Side.CLIENT).writeOutbound(packet); + } + + public static final BasicPacket + + UPDATE_BLESSING = new BasicPacket(1) { + @Override + public void executeBoth(EntityPlayer player) {player.getEntityData().setString("Blessing", (String) data[0]);} + @Override + public Class[] getExpectedClasses() {return new Class[] {String.class};} + }, + + PLAY_SOUND = new BasicPacket(2) { + @Override + public void executeServer(EntityPlayer player) { + String sound = (String) data[0]; + int x = (Integer) data[1], y = (Integer) data[2], z = (Integer) data[3]; + player.worldObj.playSound(x, y, z, "fyresmodjam:" + sound, 1.0F, 1.0F, false); + } + + @Override + public Class[] getExpectedClasses() {return new Class[] {String.class, Integer.class, Integer.class, Integer.class};} + }, + + UPDATE_POTION_KNOWLEDGE = new BasicPacket(3) { + @Override + public void executeBoth(EntityPlayer player) {player.getEntityData().setIntArray("PotionKnowledge", (int[]) data[0]);} + @Override + public Class[] getExpectedClasses() {return new Class[] {int[].class};} + }, + + SEND_MESSAGE = new BasicPacket(4) { + @Override + public void executeClient(EntityPlayer player) { + String style = ""; + + for(String s : ((String) data[0]).split("@")) { + String[] words = s.split(" "); + s = ""; + + for(String word : words) { + s += style + word + " "; + + while(word.contains("\u00A7")) { + int firstOccurance = word.indexOf("\u00A7"); + String string = word.substring(firstOccurance, firstOccurance + 2); + + if(style.contains(string)) {style = style.replace(string, "");} + style += string; + if(string.equals("\u00A7r")) {style = "";} + + word = word.replaceFirst(string, ""); + } + } + + player.addChatComponentMessage(new ChatComponentText(s)); + } + } + + @Override + public Class[] getExpectedClasses() {return new Class[] {String.class};} + }, + + UPDATE_WORLD_DATA = new BasicPacket(5) { + @Override + public void executeClient(EntityPlayer player) { + potionValues = (int[]) data[0]; + potionDurations = (int[]) data[1]; + currentDisadvantage = (String) data[2]; + currentTask = (String) data[3]; + currentTaskID = (Integer) data[4]; + currentTaskAmount = (Integer) data[5]; + progress = (Integer) data[6]; + tasksCompleted = (Integer) data[7]; + enderDragonKilled = (Boolean) data[8]; + trapsDisabled = !((Boolean) data[9]); + rewardLevels = (Integer) data[10]; + mushroomColors = (int[][]) data[11]; + } + + @Override + public Class[] getExpectedClasses() {return new Class[] {int[].class, int[].class, String.class, String.class, Integer.class, Integer.class, Integer.class, Integer.class, Boolean.class, Boolean.class, Integer.class, int[][].class};} + }, + + UPDATE_PLAYER_ITEMS = new BasicPacket(6) { + @Override + public void executeServer(EntityPlayer player) { + for(Object stack : player.inventory.mainInventory) { + if(stack == null || !(stack instanceof ItemStack)) {continue;} + ItemStatHelper.processItemStack((ItemStack) stack, ModjamMod.r); + } + } + + @Override + public Class[] getExpectedClasses() {return null;} + }, + + DISARM_TRAP = new BasicPacket(7) { + @Override + public void executeServer(EntityPlayer player) { + int blockX = (Integer) data[0], blockY = (Integer) data[1], blockZ = (Integer) data[2]; + boolean mechanic = (Boolean) data[3]; + + String blessing = null; + if(player.getEntityData().hasKey("Blessing")) {blessing = player.getEntityData().getString("Blessing");} + boolean scout = blessing != null && blessing.equals("Scout"); + + TileEntity te = player.worldObj.getTileEntity(blockX, blockY, blockZ); + + boolean yours = (te == null || !(te instanceof TileEntityTrap)) ? false : player.getCommandSenderName().equals(((TileEntityTrap) te).placedBy); + + if(yours || (mechanic ? ModjamMod.r.nextInt(4) != 0 : ModjamMod.r.nextInt(4) == 0)) { + boolean salvage = yours || (mechanic ? ModjamMod.r.nextBoolean() : (ModjamMod.r.nextInt(4) == 0)); + + SEND_MESSAGE.sendToPlayer(player, "\u00A7e\u00A7o" + (!salvage ? "You disarmed the trap." : "You disarm and salvage the trap.")); + + if(salvage) {player.worldObj.spawnEntityInWorld(new EntityItem(player.worldObj, blockX + 0.5F, blockY, blockZ + 0.5F, new ItemStack(ModjamMod.itemTrap, 1, player.worldObj.getBlockMetadata(blockX, blockY, blockZ) % BlockTrap.trapTypes)));} + player.worldObj.setBlockToAir(blockX, blockY, blockZ); + } else { + int trapType = player.worldObj.getBlockMetadata(blockX, blockY, blockZ); + + if(trapType % BlockTrap.trapTypes == 0) { + player.attackEntityFrom(DamageSource.cactus, 4.0F + (scout ? 1 : 0)); + if(ModjamMod.r.nextInt(16 - (scout ? 4 : 0)) == 0) {((EntityLivingBase) player).addPotionEffect(new PotionEffect(Potion.poison.id, 100 + (scout ? 25 : 0), 1));} + } else if(trapType % BlockTrap.trapTypes == 1) { + if(!player.isBurning()) {player.setFire(5 + (scout ? 1 : 0));} + } else if(trapType % BlockTrap.trapTypes == 2) { + player.addPotionEffect(new PotionEffect(Potion.blindness.id, 100 + (scout ? 25 : 0), 1)); + player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 100 + (scout ? 25 : 0), 1)); + } + + player.worldObj.setBlockToAir(blockX, blockY, blockZ); + + SEND_MESSAGE.sendToPlayer(player, "\u00A7c\u00A7oYou failed to disarm the trap."); + + if(CommonTickHandler.worldData.getDisadvantage().equals("Explosive Traps")) {player.worldObj.setBlockToAir(blockX, blockY, blockZ); player.worldObj.createExplosion(null, blockX + 0.5F, blockY + 0.5F, blockZ + 0.5F, 1.33F, true);} + player.triggerAchievement(ModjamMod.whoops); + } + } + + @Override + public Class[] getExpectedClasses() {return new Class[] {Integer.class, Integer.class, Integer.class, Boolean.class};} + }, + + EXAMINE_MOB = new BasicPacket(8) { + @Override + public void executeServer(EntityPlayer player) { + int dimension = (Integer) data[0]; + int entityID = (Integer) data[1]; + + WorldServer server = null; + + for(WorldServer s : MinecraftServer.getServer().worldServers) {if(s.provider.dimensionId == dimension) {server = s; break;}} + + if(server != null) { + Entity entity = server.getEntityByID(entityID); + + if(entity != null) { + String blessing2 = entity.getEntityData().hasKey("Blessing") ? entity.getEntityData().getString("Blessing") : null; + + if(blessing2 != null) { + SEND_MESSAGE.sendToPlayer(player, "\u00A7eYou notice " + entity.getCommandSenderName() + "\u00A7e is using Blessing of the " + blessing2 + "."); + } else { + SEND_MESSAGE.sendToPlayer(player, "\u00A7eThere doesn't seem to be anything special about " + (entity instanceof EntityPlayer ? "" : "this ") + entity.getCommandSenderName() + "\u00A7e."); + } + } + } + } + + @Override + public Class[] getExpectedClasses() {return new Class[] {Integer.class, Integer.class};} + }, + + LEVEL_UP = new BasicPacket(9) { + @Override + public void executeBoth(EntityPlayer player) {player.addExperienceLevel((Integer) data[0]);} + @Override + public Class[] getExpectedClasses() {return new Class[] {Integer.class};} + }, + + ACTIVATE_BLESSING = new BasicPacket(10) { + @Override + public void executeServer(EntityPlayer player) { + int x = (Integer) data[0], y = (Integer) data[1], z = (Integer) data[2]; + + String blessing = EntityStatHelper.getStat(player, "Blessing"); + boolean blessingActive = EntityStatHelper.hasStat(player, "BlessingActive") ? Boolean.parseBoolean(EntityStatHelper.getStat(player, "BlessingActive")) : false; + + if(!EntityStatHelper.hasStat(player, "BlessingCooldown")) {EntityStatHelper.giveStat(player, "BlessingCooldown", 0);} + + long time = (CommonTickHandler.worldData != null && CommonTickHandler.worldData.getDisadvantage().equals("Neverending Rain")) ? player.worldObj.getTotalWorldTime() : player.worldObj.getWorldTime(); + + if(EntityStatHelper.getStat(player, "BlessingCooldown").equals("0")) { + if(!blessingActive) { + if(blessing != null) { + if(blessing.equals("Berserker")) { + if(EntityStatHelper.hasStat(player, "BlessingCounter") && Integer.parseInt(EntityStatHelper.getStat(player, "BlessingCounter")) > 0) { + blessingActive = true; + SEND_MESSAGE.sendToPlayer(player, "\u00A7cYou enter berserk mode."); + } else { + SEND_MESSAGE.sendToPlayer(player, "\u00A7cYou have no berserk counters."); + } + } else if(blessing.equals("Mechanic")) { + TileEntity te = player.worldObj.getTileEntity(x, y, z); + + if(te != null && te instanceof TileEntityTrap) { + SEND_MESSAGE.sendToPlayer(player, "\u00A7e\u00A7oYou disarm and salvage the trap."); + + player.worldObj.spawnEntityInWorld(new EntityItem(player.worldObj, x + 0.5F, y, z + 0.5F, new ItemStack(ModjamMod.itemTrap, 1, player.worldObj.getBlockMetadata(x, y, z) % BlockTrap.trapTypes))); + player.worldObj.setBlockToAir(x, y, z); + + EntityStatHelper.giveStat(player, "BlessingCooldown", 24000 - (time % 24000)); + } else { + SEND_MESSAGE.sendToPlayer(player, "\u00A7e\u00A7oNo selected trap."); + } + } + } + } else { + blessingActive = false; + + if(blessing != null) { + if(blessing.equals("Berserker")) { + SEND_MESSAGE.sendToPlayer(player, "\u00A7cYou calm down."); + + EntityStatHelper.giveStat(player, "BlessingCooldown", 1200); + } + } + + EntityStatHelper.giveStat(player, "BlessingTimer", 0); + } + } else { + SEND_MESSAGE.sendToPlayer(player, "\u00A7cBlessing is on cooldown. (" + (Integer.parseInt(EntityStatHelper.getStat(player, "BlessingCooldown")))/20 + "s)"); + } + + EntityStatHelper.giveStat(player, "BlessingActive", blessingActive); + } + + @Override + public Class[] getExpectedClasses() {return new Class[] {Integer.class, Integer.class, Integer.class};} + }, + + UPDATE_STAT = new BasicPacket(11) { + @Override + public void executeBoth(EntityPlayer player) {EntityStatHelper.giveStat(player, (String) data[0], data[1]);} + @Override + public Class[] getExpectedClasses() {return new Class[] {String.class, String.class};} + }; +} diff --git a/fyresmodjam/items/ItemCrystal.java b/java/fyresmodjam/items/ItemCrystal.java similarity index 65% rename from fyresmodjam/items/ItemCrystal.java rename to java/fyresmodjam/items/ItemCrystal.java index 4284760..12db43c 100644 --- a/fyresmodjam/items/ItemCrystal.java +++ b/java/fyresmodjam/items/ItemCrystal.java @@ -3,49 +3,50 @@ import java.awt.Color; import java.util.List; -import cpw.mods.fml.common.network.PacketDispatcher; -import cpw.mods.fml.common.network.Player; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import fyresmodjam.ModjamMod; -import fyresmodjam.handlers.PacketHandler; -import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import fyresmodjam.ModjamMod; public class ItemCrystal extends ItemBlock { - public Icon texture; - + public IIcon texture; + public static String[] names = new String[] {"Shining", "Void", "Firey"}; public static String[] particleNames = new String[] {"spell", "portal", "flame"}; public static Color[] colors = new Color[] {new Color(255, 255, 173), new Color(33, 0, 73), new Color(255, 55, 0)}; - - public ItemCrystal(int par1) { - super(par1); - this.hasSubtypes = true; - this.setMaxStackSize(1); + + public ItemCrystal() { + super(ModjamMod.crystal); + hasSubtypes = true; + setMaxStackSize(1); } - - public void getSubItems(int id, CreativeTabs creativeTab, List list) { + + @Override + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void getSubItems(Item id, CreativeTabs creativeTab, List list) { for(int i = 0; i < names.length; i++) {list.add(new ItemStack(id, 1, i));} } - + public String getItemDisplayName(ItemStack itemStack) { return names[itemStack.getItemDamage() % names.length] + " Crystal"; } + @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister iconRegister) { + public void registerIcons(IIconRegister iconRegister) { texture = iconRegister.registerIcon("fyresmodjam:crystal_item"); - this.itemIcon = texture; + itemIcon = texture; } + @Override @SideOnly(Side.CLIENT) public int getColorFromItemStack(ItemStack itemStack, int i) { return colors[itemStack.getItemDamage() % colors.length].getRGB(); @@ -55,36 +56,37 @@ public int getColorFromItemStack(ItemStack itemStack, int i) { return ModjamMod.crystal.blockID; }*/ //Why is this even a thing if it isn't called in the numerous places that use block id? :P + @Override @SideOnly(Side.CLIENT) public int getSpriteNumber() { return 1; } - + + @Override @SideOnly(Side.CLIENT) - public Icon getIconFromDamage(int par1) { - return this.itemIcon; + public IIcon getIconFromDamage(int par1) { + return itemIcon; } - + + @Override public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - int value = (!par3EntityPlayer.getEntityData().hasKey("equippedCrystal") || par3EntityPlayer.getEntityData().getInteger("equippedCrystal") != par1ItemStack.getItemDamage()) ? par1ItemStack.getItemDamage() : -1; - + //int value = (!par3EntityPlayer.getEntityData().hasKey("equippedCrystal") || par3EntityPlayer.getEntityData().getInteger("equippedCrystal") != par1ItemStack.getItemDamage()) ? par1ItemStack.getItemDamage() : -1; + /*if(par2World.isRemote) { PacketDispatcher.sendPacketToServer(PacketHandler.newPacket(PacketHandler.UPDATE_STAT, new Object[] {"equippedCrystal", "int", par1ItemStack.getItemDamage()})); } else { PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.UPDATE_STAT, new Object[] {"equippedCrystal", "int", par1ItemStack.getItemDamage()}), (Player) par3EntityPlayer); }*/ - + /*if(par2World.isRemote) { par3EntityPlayer.openGui(ModjamMod.instance, 1, par2World, (int) par3EntityPlayer.posX, (int) par3EntityPlayer.posY, (int) par3EntityPlayer.posZ); }*/ - + return par1ItemStack; } - + + @Override @SideOnly(Side.CLIENT) - public CreativeTabs getCreativeTab() {return CreativeTabs.tabMaterials;} - - //public String getUnlocalizedName() {return super.getUnlocalizedName();} - //public String getUnlocalizedName(ItemStack stack) {return super.getUnlocalizedName(stack);} + public CreativeTabs getCreativeTab() {return CreativeTabs.tabMaterials;} } diff --git a/java/fyresmodjam/items/ItemMysteryMushroom.java b/java/fyresmodjam/items/ItemMysteryMushroom.java new file mode 100644 index 0000000..13db6e3 --- /dev/null +++ b/java/fyresmodjam/items/ItemMysteryMushroom.java @@ -0,0 +1,148 @@ +package fyresmodjam.items; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import fyresmodjam.ModjamMod; +import fyresmodjam.handlers.NewPacketHandler; + +public class ItemMysteryMushroom extends Item { + + public IIcon overlay, icon; + + public ItemMysteryMushroom() { + super(); + setHasSubtypes(true); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + icon = par1IconRegister.registerIcon("fyresmodjam:mushroom"); + overlay = par1IconRegister.registerIcon("fyresmodjam:mushroom_overlay"); + itemIcon = icon; + } + + @Override + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for(int i = 0; i < 13; i++) {par3List.add(new ItemStack(par1, 1, i));} + } + + @Override + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { + return NewPacketHandler.mushroomColors[par1ItemStack.getItemDamage() % 13][par2 % 2]; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean requiresMultipleRenderPasses() { + return true; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamageForRenderPass(int par1, int par2) { + return par2 > 0 ? overlay : icon; + } + + @Override + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) + { + Block i1 = par3World.getBlock(par4, par5, par6); + + if (i1 == Blocks.snow && (par3World.getBlockMetadata(par4, par5, par6) & 7) < 1) + { + par7 = 1; + } + else if (i1 != Blocks.vine && i1 != Blocks.tallgrass && i1 != Blocks.deadbush + && (i1 == null || !i1.isReplaceable(par3World, par4, par5, par6))) + { + if (par7 == 0) + { + --par5; + } + + if (par7 == 1) + { + ++par5; + } + + if (par7 == 2) + { + --par6; + } + + if (par7 == 3) + { + ++par6; + } + + if (par7 == 4) + { + --par4; + } + + if (par7 == 5) + { + ++par4; + } + } + + if (par1ItemStack.stackSize == 0) + { + return false; + } + else if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) + { + return false; + } + else if (par5 == 255 && ModjamMod.mysteryMushroomBlock.getMaterial().isSolid()) + { + return false; + } + else if (par3World.canPlaceEntityOnSide(ModjamMod.mysteryMushroomBlock, par4, par5, par6, false, par7, par2EntityPlayer, par1ItemStack)) + { + + Block block = ModjamMod.mysteryMushroomBlock; + int j1 = par1ItemStack.getItemDamage(); + int k1 = ModjamMod.mysteryMushroomBlock.onBlockPlaced(par3World, par4, par5, par6, par7, par8, par9, par10, j1); + + if(onItemUseFirst(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10, k1)) { + par3World.playSoundEffect(par4 + 0.5F, par5 + 0.5F, par6 + 0.5F, block.stepSound.func_150496_b(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F); + --par1ItemStack.stackSize; + } + + return true; + } else { + return false; + } + } + + public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) + { + if (!world.setBlock(x, y, z, ModjamMod.mysteryMushroomBlock, metadata, 3)) + { + return false; + } + + if (world.getBlock(x, y, z) == ModjamMod.mysteryMushroomBlock) + { + ModjamMod.mysteryMushroomBlock.onBlockPlacedBy(world, x, y, z, player, stack); + ModjamMod.mysteryMushroomBlock.onPostBlockPlaced(world, x, y, z, metadata); + } + + return true; + } +} diff --git a/java/fyresmodjam/items/ItemMysteryPotion.java b/java/fyresmodjam/items/ItemMysteryPotion.java new file mode 100644 index 0000000..f8bd6d3 --- /dev/null +++ b/java/fyresmodjam/items/ItemMysteryPotion.java @@ -0,0 +1,196 @@ +package fyresmodjam.items; + +import java.util.List; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumAction; +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.util.StatCollector; +import net.minecraft.world.World; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import fyresmodjam.ModjamMod; +import fyresmodjam.entities.EntityMysteryPotion; +import fyresmodjam.handlers.CommonTickHandler; +import fyresmodjam.handlers.NewPacketHandler; + +public class ItemMysteryPotion extends Item { + + public IIcon[] icons = null; + + public ItemMysteryPotion() { + super(); + setHasSubtypes(true); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + icons = new IIcon[26]; + + for(int i = 0; i < 13; i++) { + icons[i] = par1IconRegister.registerIcon("fyresmodjam:mysteryPotion_" + (i + 1)); + icons[i + 13] = par1IconRegister.registerIcon("fyresmodjam:mysteryPotionThrowable_" + (i + 1)); + } + + itemIcon = icons[0]; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) { + return icons[par1 % 26]; + } + + @Override + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for(int i = 0; i < 13; i++) {par3List.add(new ItemStack(par1, 1, i));} + for(int i = 0; i < 13; i++) {par3List.add(new ItemStack(par1, 1, i + 13));} + } + + @Override + @SideOnly(Side.CLIENT) + public String getItemStackDisplayName(ItemStack par1ItemStack) { + int damage = par1ItemStack.getItemDamage() % 13; + String name = "Mystery Potion #" + (damage + 1); + + String blessing = null; + + if(FMLCommonHandler.instance().getSide() == Side.CLIENT) {blessing = getBlessing();} + + if(damage < 12) { + if(Minecraft.getMinecraft().thePlayer != null && Minecraft.getMinecraft().thePlayer.getEntityData().hasKey("PotionKnowledge")) { + if(Minecraft.getMinecraft().thePlayer.getEntityData().getIntArray("PotionKnowledge")[damage] != -1) { + Potion potion = Potion.potionTypes[NewPacketHandler.potionValues[damage]]; + name = StatCollector.translateToLocal(potion.getName()) + " Potion"; + + if(!potion.isInstant()) { + int time = NewPacketHandler.potionDurations[damage]; + name += " (" + time + " seconds)"; + } + } + } + } else if(damage >= 12) { + name = "Wildcard Potion"; + } + + if((blessing != null && blessing.equals("Alchemist"))) {name = "\u00A7k" + name;} + + return name; + } + + @Override + public EnumAction getItemUseAction(ItemStack par1ItemStack) { + return par1ItemStack.getItemDamage() < 13 ? EnumAction.drink : super.getItemUseAction(par1ItemStack); + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + if(par1ItemStack.getItemDamage() < 13) { + par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); + } else { + if(!par3EntityPlayer.capabilities.isCreativeMode) {par1ItemStack.stackSize--;} + par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + + if(!par2World.isRemote) { + int value = 0; + + if(par1ItemStack.getItemDamage() % 13 >= 12) { + value = ModjamMod.r.nextInt(Potion.potionTypes.length); + while(Potion.potionTypes[value] == null) {value = ModjamMod.r.nextInt(Potion.potionTypes.length);} + } else { + value = CommonTickHandler.worldData.potionValues[par1ItemStack.getItemDamage() % 13]; + } + + par2World.spawnEntityInWorld(new EntityMysteryPotion(par2World, par3EntityPlayer, par1ItemStack)); + } + } + + return par1ItemStack; + } + + @Override + public int getMaxItemUseDuration(ItemStack par1ItemStack) { + return par1ItemStack.getItemDamage() < 13 ? 32 : super.getMaxItemUseDuration(par1ItemStack); + } + + @Override + public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + if(!par3EntityPlayer.capabilities.isCreativeMode) {--par1ItemStack.stackSize;} + + String blessing = (par3EntityPlayer != null && par3EntityPlayer.getEntityData().hasKey("Blessing")) ? par3EntityPlayer.getEntityData().getString("Blessing") : null; + + int damage = par1ItemStack.getItemDamage() % 13; + + if((blessing == null || !blessing.equals("Alchemist")) && damage < 12) { + if(!par2World.isRemote) { + + int value = CommonTickHandler.worldData.potionValues[damage]; + + if(!Potion.potionTypes[value].isInstant()) { + par3EntityPlayer.addPotionEffect(new PotionEffect(value, CommonTickHandler.worldData.potionDurations[damage] * 20, 1, false)); + } else { + Potion.potionTypes[value].affectEntity(par3EntityPlayer, par3EntityPlayer, 1, 1); + } + + if(!par3EntityPlayer.getEntityData().hasKey("PotionKnowledge")) {par3EntityPlayer.getEntityData().setIntArray("PotionKnowledge", new int[] {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1});} + + if(par3EntityPlayer.getEntityData().getIntArray("PotionKnowledge")[damage] == -1) { + par3EntityPlayer.getEntityData().getIntArray("PotionKnowledge")[damage] = 1; + + NewPacketHandler.UPDATE_POTION_KNOWLEDGE.sendToPlayer(par3EntityPlayer, par3EntityPlayer.getEntityData().getIntArray("PotionKnowledge")); + + Potion potion = Potion.potionTypes[CommonTickHandler.worldData.potionValues[damage]]; + String name = StatCollector.translateToLocal(potion.getName()) + " Potion"; + + if(!potion.isInstant()) { + int time = CommonTickHandler.worldData.potionDurations[damage]; + name += " (" + time + " seconds)"; + } + + NewPacketHandler.SEND_MESSAGE.sendToPlayer(par3EntityPlayer, "\u00A7oYou learnt Mystery Potion #" + (damage + 1) + " was a " + name + "!"); + } + } + + } else if(!par2World.isRemote) { + int value = ModjamMod.r.nextInt(Potion.potionTypes.length); + while(Potion.potionTypes[value] == null) {value = ModjamMod.r.nextInt(Potion.potionTypes.length);} + int time = 5 + ModjamMod.r.nextInt(26); + + if(!Potion.potionTypes[value].isInstant()) { + par3EntityPlayer.addPotionEffect(new PotionEffect(value, time * 20, 1, false)); + } else { + Potion.potionTypes[value].affectEntity(par3EntityPlayer, par3EntityPlayer, 1, 1); + } + + Potion potion = Potion.potionTypes[value]; + String name = StatCollector.translateToLocal(potion.getName()) + " Potion"; + + if(!potion.isInstant()) {name += " (" + time + " seconds)";} + + NewPacketHandler.SEND_MESSAGE.sendToPlayer(par3EntityPlayer, "\u00A7oYou drank a " + name + "."); + } + + return par1ItemStack; + } + + @SideOnly(Side.CLIENT) + public String getBlessing() { + return (Minecraft.getMinecraft().thePlayer != null && Minecraft.getMinecraft().thePlayer.getEntityData().hasKey("Blessing")) ? Minecraft.getMinecraft().thePlayer.getEntityData().getString("Blessing") : null; + } + + @Override + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { + return false; + } + +} diff --git a/java/fyresmodjam/items/ItemObsidianSceptre.java b/java/fyresmodjam/items/ItemObsidianSceptre.java new file mode 100644 index 0000000..78698f7 --- /dev/null +++ b/java/fyresmodjam/items/ItemObsidianSceptre.java @@ -0,0 +1,53 @@ +package fyresmodjam.items; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class ItemObsidianSceptre extends Item { + + public IIcon icon, icon2; + + public ItemObsidianSceptre() { + super(); + hasSubtypes = true; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + icon = par1IconRegister.registerIcon("fyresmodjam:unenchantedSceptre"); + icon2 = par1IconRegister.registerIcon("fyresmodjam:enchantedSceptre"); + itemIcon = icon; + } + + @Override + @SuppressWarnings({ "rawtypes", "unchecked" }) + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for(int i = 0; i < 2; i++) {par3List.add(new ItemStack(par1, 1, i));} + } + + @Override + @SideOnly(Side.CLIENT) + public String getItemStackDisplayName(ItemStack par1ItemStack) { + return (par1ItemStack.getItemDamage() == 0 ? "" : "Infused ") + super.getItemStackDisplayName(par1ItemStack); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) { + return par1 == 0 ? icon : icon2; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean hasEffect(ItemStack par1ItemStack) { + return par1ItemStack.getItemDamage() > 0; + } +} diff --git a/java/fyresmodjam/items/ItemPillar.java b/java/fyresmodjam/items/ItemPillar.java new file mode 100644 index 0000000..8295cbf --- /dev/null +++ b/java/fyresmodjam/items/ItemPillar.java @@ -0,0 +1,74 @@ +package fyresmodjam.items; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import fyresmodjam.ModjamMod; +import fyresmodjam.tileentities.TileEntityPillar; + +public class ItemPillar extends Item +{ + public ItemPillar() { + super(); + maxStackSize = 1; + setCreativeTab(CreativeTabs.tabBlock); + hasSubtypes = true; + } + + @Override + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + if(ModjamMod.showAllPillarsInCreative) { + for(int i = 0; i < TileEntityPillar.validBlessings.length + 1; i++) {par3List.add(new ItemStack(par1, 1, i));} + } else {super.getSubItems(par1, par2CreativeTabs, par3List);} + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + itemIcon = par1IconRegister.registerIcon("fyresmodjam:itemPillar"); + } + + @Override + @SideOnly(Side.CLIENT) + public String getItemStackDisplayName(ItemStack par1ItemStack) { + return super.getItemStackDisplayName(par1ItemStack) + (par1ItemStack.getItemDamage() == 0 ? "" : " (Blessing of the " + TileEntityPillar.validBlessings[(par1ItemStack.getItemDamage() - 1) % TileEntityPillar.validBlessings.length] + ")"); + } + + @Override + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) + { + Block block = ModjamMod.blockPillar; + + if(par7 == 0) {par5 -= 2;} + if(par7 == 1 && !par3World.getBlock(par4, par5, par6).isReplaceable(par3World, par4, par5, par6)) {++par5;} + if(par7 == 2) {--par6;} + if(par7 == 3) {++par6;} + if(par7 == 4) {--par4;} + if(par7 == 5) {++par4;} + + if(!block.canPlaceBlockAt(par3World, par4, par5, par6)) { + return false; + } else { + par3World.setBlock(par4, par5, par6, block); + par3World.setBlockMetadataWithNotify(par4, par5, par6, 0, 0); + + par3World.setBlock(par4, par5 + 1, par6, block); + par3World.setBlockMetadataWithNotify(par4, par5 + 1, par6, 1, 0); + + if(par1ItemStack.getItemDamage() != 0) {((TileEntityPillar) par3World.getTileEntity(par4, par5, par6)).blessing = TileEntityPillar.validBlessings[par1ItemStack.getItemDamage() - 1];} + + --par1ItemStack.stackSize; + + return true; + } + } +} diff --git a/java/fyresmodjam/items/ItemScroll.java b/java/fyresmodjam/items/ItemScroll.java new file mode 100644 index 0000000..fb89ece --- /dev/null +++ b/java/fyresmodjam/items/ItemScroll.java @@ -0,0 +1,97 @@ +package fyresmodjam.items; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.nbt.NBTTagString; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class ItemScroll extends Item { + + public static String[][] scrollText = new String[][] { + {"Unkown Adventurer", "Codex #1: Adventurer's Log", "This morning I fell out of the sky. I am unsure of where I am, or for what purpose, but I've begun construction of a small shelter for the time being.", "I've now spent days scouting the nearby area with no luck. Still alone, I'm made my decision to set out further.", "I've discovered an ancient stronghold. Writtings of end times cover the walls. What could it mean? Who built this place? Why was it here? And I have an unsettling feeling that I'm being watched..."}, + {"Village Elder", "Codex #2: An Elders Warning", "For thousands of years, we have lived peacefully. As stories of the distant past began to fade in time, the elders became tasked with remembering. I now join their ranks, but still I see there are those who choose to forget.", "The lines between worlds begin to blur once again. In the deepest caverns, we can see in to their world, and theirs in to ours. The end returns, yet no other will listen. It's clear I must find the crystal alone."}, + {"Pigman Warrior", "Codex #3: The Warriors Spirit", "We fight through the fires of this realm, thinking as one. It is the only way to survive this wretched landscape. Hurt one and the horde will know.", "Strangers enter our realm through even stranger portals. They seek the crystal which bonds our world. We refuse, we fight, but many die. Our numbers begin dwindle, but the crystal will stay ours.", "We can see the void seeping through the cracks of our realm, reanimating the dead. Empty husks of our fallen push back the intruders. But they too are affected by the void's forces."}, + {"Enderman Urchin", "Codex #4: From the Shadows", "The darkness shall consume all, below each of the worlds it boils. We now wait for our time to return, watching through the cracks of space and time. Us children of the Ender will reclaim what was once ours."}/*, + {"Author", "Codex #5", "Words"}*/ + }; + + public IIcon texture; + + public ItemScroll() { + super(); + hasSubtypes = true; + maxStackSize = 1; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + texture = iconRegister.registerIcon("fyresmodjam:scroll"); + itemIcon = texture; + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity entity, int par1, boolean b) { + if(!world.isRemote) { + if(!stack.hasTagCompound()) {stack.stackTagCompound = new NBTTagCompound();} + + if(!stack.getTagCompound().hasKey("initialized") || !stack.getTagCompound().getBoolean("initialized")) { + stack.getTagCompound().setBoolean("initialized", true); + + ItemStack book = new ItemStack(Items.written_book, 1, 0); + + NBTTagList pages = new NBTTagList(); + + for(int i = 2; i < scrollText[stack.getItemDamage() % scrollText.length].length; i++) { + pages.appendTag(new NBTTagString(scrollText[stack.getItemDamage() % scrollText.length][i])); + } + + book.setTagInfo("pages", pages); + book.setTagInfo("author", new NBTTagString(scrollText[stack.getItemDamage() % scrollText.length][0])); + book.setTagInfo("title", new NBTTagString(scrollText[stack.getItemDamage() % scrollText.length][1])); + + NBTTagCompound bookTag = new NBTTagCompound(); + book.writeToNBT(bookTag); + stack.setTagInfo("book", bookTag); + } + } + } + + @Override + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void getSubItems(Item id, CreativeTabs creativeTab, List list) { + for(int i = 0; i < scrollText.length; i++) {list.add(new ItemStack(id, 1, i));} + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + NBTTagCompound bookTag = par1ItemStack.getTagCompound().getCompoundTag("book"); + if(bookTag != null) {par3EntityPlayer.displayGUIBook(ItemStack.loadItemStackFromNBT(bookTag));} + return par1ItemStack; + } + + @Override + public String getItemStackDisplayName(ItemStack par1ItemStack) { + return scrollText[par1ItemStack.getItemDamage() % scrollText.length][1]; + } + + @Override + @SuppressWarnings({ "unchecked", "rawtypes" }) + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + par3List.add(EnumChatFormatting.GRAY + scrollText[par1ItemStack.getItemDamage() % scrollText.length][0]); + } +} diff --git a/java/fyresmodjam/items/ItemTrap.java b/java/fyresmodjam/items/ItemTrap.java new file mode 100644 index 0000000..f768648 --- /dev/null +++ b/java/fyresmodjam/items/ItemTrap.java @@ -0,0 +1,128 @@ +package fyresmodjam.items; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockDispenser; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.dispenser.IBehaviorDispenseItem; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import fyresmodjam.ModjamMod; +import fyresmodjam.blocks.BlockTrap; +import fyresmodjam.misc.BehaviorDispenseTrap; + +public class ItemTrap extends Item { + + private static final IBehaviorDispenseItem dispenseTrap = new BehaviorDispenseTrap(); + + public IIcon[] icons; + public static String[] iconLocations = new String[] {"fyresmodjam:itemTrap", "fyresmodjam:trap2", "fyresmodjam:trap3"}; + + public ItemTrap() { + super(); + setHasSubtypes(true); + BlockDispenser.dispenseBehaviorRegistry.putObject(this, dispenseTrap); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + icons = new IIcon[iconLocations.length]; + for(int i = 0; i < iconLocations.length; i++) {icons[i] = par1IconRegister.registerIcon(iconLocations[i]);} + + itemIcon = icons[0]; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for(int i = 0; i < BlockTrap.trapTypes; i++) {par3List.add(new ItemStack(par1, 1, i));} + } + + public static String[] names = {"Spike Trap", "Flame Trap", "Smoke Trap"}; + + @Override + @SideOnly(Side.CLIENT) + public String getItemStackDisplayName(ItemStack par1ItemStack) { + return names[par1ItemStack.getItemDamage() % BlockTrap.trapTypes]; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) { + return icons[par1 % BlockTrap.trapTypes]; + } + + @Override + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { + Block i1 = par3World.getBlock(par4, par5, par6); + + if(i1 == Blocks.snow && (par3World.getBlockMetadata(par4, par5, par6) & 7) < 1) { + par7 = 1; + } else if(i1 != Blocks.vine && i1 != Blocks.tallgrass && i1 != Blocks.deadbush && (i1 == null || !i1.isReplaceable(par3World, par4, par5, par6))) { + if(par7 == 0) {--par5;} + if(par7 == 1) {++par5;} + if(par7 == 2) {--par6;} + if(par7 == 3) {++par6;} + if(par7 == 4) {--par4;} + if(par7 == 5) {++par4;} + } + + if(par1ItemStack.stackSize == 0) { + return false; + } else if(!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) { + return false; + } else if(par5 == 255 && ModjamMod.blockTrap.getMaterial().isSolid()) { + return false; + } else if(par3World.canPlaceEntityOnSide(ModjamMod.blockTrap, par4, par5, par6, false, par7, par2EntityPlayer, par1ItemStack)) { + Block block = ModjamMod.blockTrap; + int j1 = getMetadata(par1ItemStack.getItemDamage()); + int k1 = ModjamMod.blockTrap.onBlockPlaced(par3World, par4, par5, par6, par7, par8, par9, par10, j1); + + if(placeBlockAt(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10, k1)) { + par3World.playSoundEffect(par4 + 0.5F, par5 + 0.5F, par6 + 0.5F, block.stepSound.func_150496_b(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F); + --par1ItemStack.stackSize; + } + + return true; + } else {return false;} + } + + @SideOnly(Side.CLIENT) + public boolean canPlaceItemBlockOnSide(World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer, ItemStack par7ItemStack) { + Block i1 = par1World.getBlock(par2, par3, par4); + + if(i1 == Blocks.snow) { + par5 = 1; + } else if(i1 != Blocks.vine && i1 != Blocks.tallgrass && i1 != Blocks.deadbush && (i1 == null || !i1.isReplaceable(par1World, par2, par3, par4))) { + if(par5 == 0) {--par3;} + if(par5 == 1) {++par3;} + if(par5 == 2) {--par4;} + if(par5 == 3) {++par4;} + if(par5 == 4) {--par2;} + if(par5 == 5) {++par2;} + } + + return par1World.canPlaceEntityOnSide(ModjamMod.blockTrap, par2, par3, par4, false, par5, (Entity)null, par7ItemStack); + } + + public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) { + if(!world.setBlock(x, y, z, ModjamMod.blockTrap, metadata, 3)) {return false;} + + if(world.getBlock(x, y, z) == ModjamMod.blockTrap) { + ModjamMod.blockTrap.onBlockPlacedBy(world, x, y, z, player, stack); + ModjamMod.blockTrap.onPostBlockPlaced(world, x, y, z, metadata); + } + + return true; + } +} diff --git a/java/fyresmodjam/misc/BehaviorDispenseTrap.java b/java/fyresmodjam/misc/BehaviorDispenseTrap.java new file mode 100644 index 0000000..835d956 --- /dev/null +++ b/java/fyresmodjam/misc/BehaviorDispenseTrap.java @@ -0,0 +1,38 @@ +package fyresmodjam.misc; + +import net.minecraft.block.BlockDispenser; +import net.minecraft.dispenser.BehaviorDefaultDispenseItem; +import net.minecraft.dispenser.IBlockSource; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; +import net.minecraft.world.World; +import fyresmodjam.ModjamMod; + +public class BehaviorDispenseTrap extends BehaviorDefaultDispenseItem { + + private final BehaviorDefaultDispenseItem field_96465_b = new BehaviorDefaultDispenseItem(); + + @Override + public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) { + + EnumFacing enumfacing = BlockDispenser.func_149937_b(par1IBlockSource.getBlockMetadata()); + + World world = par1IBlockSource.getWorld(); + + int i = par1IBlockSource.getXInt() + enumfacing.getFrontOffsetX(); + int j = par1IBlockSource.getYInt() + enumfacing.getFrontOffsetY(); + int k = par1IBlockSource.getZInt() + enumfacing.getFrontOffsetZ(); + + if(!ModjamMod.blockTrap.canPlaceBlockAt(world, i, j, k)){ + return field_96465_b.dispense(par1IBlockSource, par2ItemStack); + } + + world.setBlock(i, j, k, ModjamMod.blockTrap, par2ItemStack.getItemDamage(), 0); + world.markBlockForUpdate(i, j, k); + + par2ItemStack.splitStack(1); + + return par2ItemStack; + + } +} diff --git a/fyresmodjam/misc/CreativeTabModjamMod.java b/java/fyresmodjam/misc/CreativeTabModjamMod.java similarity index 78% rename from fyresmodjam/misc/CreativeTabModjamMod.java rename to java/fyresmodjam/misc/CreativeTabModjamMod.java index b62b858..2b94cd4 100644 --- a/fyresmodjam/misc/CreativeTabModjamMod.java +++ b/java/fyresmodjam/misc/CreativeTabModjamMod.java @@ -4,47 +4,49 @@ import java.util.ArrayList; import java.util.List; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import fyresmodjam.ModjamMod; import net.minecraft.block.Block; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import fyresmodjam.ModjamMod; public class CreativeTabModjamMod extends CreativeTabs { public CreativeTabModjamMod(int par1, String par2Str) { super(par1, par2Str); } - + @Override @SideOnly(Side.CLIENT) public ItemStack getIconItemStack() { - return new ItemStack(ModjamMod.itemTrap.itemID, 1, 0); + return new ItemStack(ModjamMod.itemTrap, 1, 0); } - + + @Override public String getTranslatedTabLabel(){ return "The \"You Will Die\" Mod"; } - + + @Override + @SuppressWarnings({ "rawtypes", "unchecked" }) public void displayAllReleventItems(List par1List) { try { ArrayList list = new ArrayList(); - + for(Field f : ModjamMod.class.getFields()) { if(f.getType() == Item.class) { Item item = (Item) f.get(ModjamMod.instance); if(item == null || item.getCreativeTab() == null) {continue;} - item.getSubItems(item.itemID, this, list); + item.getSubItems(item, this, list); } else if(f.getType() == Block.class) { Block block = (Block) f.get(ModjamMod.instance); if(block == null || block.getCreativeTabToDisplayOn() == null) {continue;} - block.getSubBlocks(block.blockID, this, list); + block.getSubBlocks(block.getItem(null, 0, 0, 0), this, list); } } - + for(ItemStack i : list) { if(i == null || i.getItem() == null) {continue;} if(i.getItem().getIconIndex(i) != null) {par1List.add(i);} @@ -52,4 +54,9 @@ public void displayAllReleventItems(List par1List) { } catch (Exception e) {e.printStackTrace();} } + @Override + public Item getTabIconItem() { + return ModjamMod.itemTrap; + } + } diff --git a/fyresmodjam/misc/EntityStatHelper.java b/java/fyresmodjam/misc/EntityStatHelper.java similarity index 50% rename from fyresmodjam/misc/EntityStatHelper.java rename to java/fyresmodjam/misc/EntityStatHelper.java index afdb37a..a2fcf34 100644 --- a/fyresmodjam/misc/EntityStatHelper.java +++ b/java/fyresmodjam/misc/EntityStatHelper.java @@ -1,243 +1,212 @@ package fyresmodjam.misc; -import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; -import java.io.IOException; import java.lang.reflect.Constructor; import java.util.ArrayList; import java.util.HashMap; import java.util.Random; -import cpw.mods.fml.common.ICraftingHandler; -import cpw.mods.fml.common.network.PacketDispatcher; -import cpw.mods.fml.common.network.Player; -import cpw.mods.fml.common.registry.GameRegistry; -import fyresmodjam.ModjamMod; -import fyresmodjam.handlers.CommonTickHandler; -import fyresmodjam.handlers.PacketHandler; -import fyresmodjam.misc.EntityStatHelper.EntityStat; -import fyresmodjam.misc.ItemStatHelper.ItemStatTracker; -import fyresmodjam.worldgen.FyresWorldData; - - -import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; +import net.minecraft.entity.Entity.EnumEntitySize; import net.minecraft.entity.EntityList; import net.minecraft.entity.EntityLiving; -import net.minecraft.entity.EnumEntitySize; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.boss.EntityDragon; +import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemAxe; import net.minecraft.item.ItemBow; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; -import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.nbt.NBTTagString; -import net.minecraft.network.packet.Packet; -import net.minecraft.network.packet.Packet250CustomPayload; -import net.minecraft.network.packet.Packet5PlayerInventory; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; import net.minecraft.util.StatCollector; import net.minecraft.world.World; -import net.minecraft.world.WorldServer; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.ForgeSubscribe; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.living.LivingDeathEvent; -import net.minecraftforge.event.entity.living.LivingHurtEvent; -import net.minecraftforge.event.entity.player.EntityItemPickupEvent; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import fyresmodjam.ModjamMod; +import fyresmodjam.handlers.CommonTickHandler; +import fyresmodjam.handlers.NewPacketHandler; +import fyresmodjam.worldgen.FyresWorldData; +@SuppressWarnings("rawtypes") public class EntityStatHelper { - + public static String[] knowledge = {"Clueless", "Novice", "Competent", "Talented", "Expert", "Professional", "Master", "Legendary"}; public static int[] killCount = {0, 10, 25, 50, 100, 250, 500, 1000}; public static float[] damageBonus = {0, 0.01F, 0.025F, 0.05F, 0.075F, 0.1F, 0.15F, 0.2F}; public static String[] damageBonusString = {"0", "1", "2.5", "5", "7.5", "10", "15", "20"}; - - //There's probably a better way of doing all of this. :P Oh well. - + public static class EntityStatTracker { public Class[] classes; - + public boolean instanceAllowed = false; - - public EntityStatTracker(Class[] classes, boolean instancesAllowed) {this.classes = classes; this.instanceAllowed = instancesAllowed;} + + public EntityStatTracker(Class[] classes, boolean instancesAllowed) {this.classes = classes; instanceAllowed = instancesAllowed;} public EntityStatTracker(Class c, boolean instancesAllowed) {this(new Class[] {c}, instancesAllowed);} - //public HashMap stats = new HashMap(); public ArrayList stats = new ArrayList(); - //public StatTracker giveStat(String name, String value) {stats.put(name, value); return this;} public void addStat(EntityStat stat) { if(!stats.contains(stat)) {stats.add(stat);} } } - + public static class EntityStat { public String name; public String value; - + public EntityStat(String name, String value) { this.name = name; this.value = value; } - + public Object getNewValue(Random r) {return value;} - public String getAlteredEntityName(EntityLiving entity) {return entity.getEntityName();} + public String getAlteredEntityName(EntityLiving entity) {return entity.getCommandSenderName();} public void modifyEntity(Entity entity) {} } - + public static String getUnalteredName(Entity entity) { String s = EntityList.getEntityString(entity); - if(s == null) {s = "generic";} - return StatCollector.translateToLocal("entity." + s + ".name"); + if(s == null) {s = "generic";} + return StatCollector.translateToLocal("entity." + s + ".name"); } - + public static String getUnalteredItemName(Item item) { - return StatCollector.translateToLocal(item.getUnlocalizedName() + ".name"); + return StatCollector.translateToLocal(item.getUnlocalizedName() + ".name"); } - + public static HashMap statTrackersByClass = new HashMap(); public static ArrayList genericTrackers = new ArrayList(); - + public static void addStatTracker(EntityStatTracker statTracker) { if(statTracker.classes != null) { for(Class c : statTracker.classes) {statTrackersByClass.put(c, statTracker);} if(statTracker.instanceAllowed) {genericTrackers.add(statTracker);} } } - + public static Entity giveStat(Entity entity, String name, Object value) { if(entity != null && name != null && value != null) {entity.getEntityData().setString(name, value.toString());} return entity; } - + public static Entity setName(EntityLiving entity, String name) { entity.setCustomNameTag(name); - //if(entity.getCustomNameTag().equals(entity.getEntityName())) {entity.setCustomNameTag("");} return entity; } - + public static String getStat(Entity entity, String name) { String s = null; if(entity.getEntityData() != null && entity.getEntityData().hasKey(name)) {s = entity.getEntityData().getString(name);} return s; } - + public static boolean hasStat(Entity entity, String name) { if(entity.getEntityData() != null && entity.getEntityData().hasKey(name)) {return true;} return false; } - - @ForgeSubscribe + + @SubscribeEvent public void entityJoinWorld(EntityJoinWorldEvent event) { if(!event.world.isRemote) { processEntity(event.entity, ModjamMod.r); - + boolean isClone = true; - - /*try { - isClone = event.entity.getDataWatcher().getWatchableObjectByte(30) != 0; - } catch (Exception e) { - isClone = false; - event.entity.getDataWatcher().addObject(30, (byte) 1); - }*/ - + isClone = event.entity.getEntityData().hasKey("isClone") ? event.entity.getEntityData().getBoolean("isClone") : false; - + if(CommonTickHandler.worldData != null && CommonTickHandler.worldData.getDisadvantage().equals("Increased Mob Spawn") && (event.entity instanceof EntityMob) && !(event.entity instanceof EntityDragon) && !isClone && ModjamMod.r.nextInt(3) == 0) { - + event.entity.getEntityData().setBoolean("isClone", true); - + Entity entityNew = null; - + try { Constructor[] constructors = event.entity.getClass().getConstructors(); - + for(int i = 0; i < constructors.length; i++) { Class[] parameters = constructors[i].getParameterTypes(); if(parameters.length == 1 && parameters[0].equals(World.class)) {entityNew = (Entity) event.entity.getClass().getConstructors()[i].newInstance(event.world);} } - + } catch (Exception e) {e.printStackTrace();} - + if(entityNew != null) { entityNew.setLocationAndAngles(event.entity.posX, event.entity.posY, event.entity.posZ, event.entity.rotationYaw, event.entity.rotationPitch); - //entityNew.getDataWatcher().addObject(30, (byte) 1); entityNew.getEntityData().setBoolean("isClone", true); entityNew.dimension = event.entity.dimension; - CommonTickHandler.addLater.add(entityNew); //event.world.spawnEntityInWorld(entityNew); + CommonTickHandler.addLater.add(entityNew); } } - + if(event.entity instanceof EntityPlayer) { - if(!event.entity.getEntityData().hasKey("Blessing") && CommonTickHandler.worldData.blessingByPlayer.containsKey(event.entity.getEntityName())) { - event.entity.getEntityData().setString("Blessing", CommonTickHandler.worldData.blessingByPlayer.get(event.entity.getEntityName())); - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.UPDATE_BLESSING, new Object[] {event.entity.getEntityData().getString("Blessing")}), (Player) event.entity); - CommonTickHandler.worldData.blessingByPlayer.remove(event.entity.getEntityName()); + if(!event.entity.getEntityData().hasKey("Blessing") && CommonTickHandler.worldData.blessingByPlayer.containsKey(event.entity.getCommandSenderName())) { + event.entity.getEntityData().setString("Blessing", CommonTickHandler.worldData.blessingByPlayer.get(event.entity.getCommandSenderName())); + + NewPacketHandler.UPDATE_BLESSING.sendToPlayer((EntityPlayer) event.entity, event.entity.getEntityData().getString("Blessing")); + + CommonTickHandler.worldData.blessingByPlayer.remove(event.entity.getCommandSenderName()); CommonTickHandler.worldData.markDirty(); } - - if(!event.entity.getEntityData().hasKey("PotionKnowledge") && CommonTickHandler.worldData.potionKnowledgeByPlayer.containsKey(event.entity.getEntityName())) { - event.entity.getEntityData().setIntArray("PotionKnowledge", CommonTickHandler.worldData.potionKnowledgeByPlayer.get(event.entity.getEntityName())); - PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.UPDATE_POTION_KNOWLEDGE, new Object[] {event.entity.getEntityData().getIntArray("PotionKnowledge")}), (Player) event.entity); - CommonTickHandler.worldData.potionKnowledgeByPlayer.remove(event.entity.getEntityName()); + + if(!event.entity.getEntityData().hasKey("PotionKnowledge") && CommonTickHandler.worldData.potionKnowledgeByPlayer.containsKey(event.entity.getCommandSenderName())) { + event.entity.getEntityData().setIntArray("PotionKnowledge", CommonTickHandler.worldData.potionKnowledgeByPlayer.get(event.entity.getCommandSenderName())); + + NewPacketHandler.UPDATE_POTION_KNOWLEDGE.sendToPlayer((EntityPlayer) event.entity, event.entity.getEntityData().getIntArray("PotionKnowledge")); + + CommonTickHandler.worldData.potionKnowledgeByPlayer.remove(event.entity.getCommandSenderName()); CommonTickHandler.worldData.markDirty(); } - - if(!event.entity.getEntityData().hasKey("KillStats") && CommonTickHandler.worldData.killStatsByPlayer.containsKey(event.entity.getEntityName())) { - event.entity.getEntityData().setCompoundTag("KillStats", CommonTickHandler.worldData.killStatsByPlayer.get(event.entity.getEntityName())); - CommonTickHandler.worldData.killStatsByPlayer.remove(event.entity.getEntityName()); + + if(!event.entity.getEntityData().hasKey("KillStats") && CommonTickHandler.worldData.killStatsByPlayer.containsKey(event.entity.getCommandSenderName())) { + event.entity.getEntityData().setTag("KillStats", CommonTickHandler.worldData.killStatsByPlayer.get(event.entity.getCommandSenderName())); + CommonTickHandler.worldData.killStatsByPlayer.remove(event.entity.getCommandSenderName()); CommonTickHandler.worldData.markDirty(); } - - if(!event.entity.getEntityData().hasKey("WeaponStats") && CommonTickHandler.worldData.weaponStatsByPlayer.containsKey(event.entity.getEntityName())) { - event.entity.getEntityData().setCompoundTag("WeaponStats", CommonTickHandler.worldData.weaponStatsByPlayer.get(event.entity.getEntityName())); - CommonTickHandler.worldData.killStatsByPlayer.remove(event.entity.getEntityName()); + + if(!event.entity.getEntityData().hasKey("WeaponStats") && CommonTickHandler.worldData.weaponStatsByPlayer.containsKey(event.entity.getCommandSenderName())) { + event.entity.getEntityData().setTag("WeaponStats", CommonTickHandler.worldData.weaponStatsByPlayer.get(event.entity.getCommandSenderName())); + CommonTickHandler.worldData.killStatsByPlayer.remove(event.entity.getCommandSenderName()); CommonTickHandler.worldData.markDirty(); } - - if(!event.entity.getEntityData().hasKey("CraftingStats") && CommonTickHandler.worldData.craftingStatsByPlayer.containsKey(event.entity.getEntityName())) { - event.entity.getEntityData().setCompoundTag("CraftingStats", CommonTickHandler.worldData.craftingStatsByPlayer.get(event.entity.getEntityName())); - CommonTickHandler.worldData.craftingStatsByPlayer.remove(event.entity.getEntityName()); + + if(!event.entity.getEntityData().hasKey("CraftingStats") && CommonTickHandler.worldData.craftingStatsByPlayer.containsKey(event.entity.getCommandSenderName())) { + event.entity.getEntityData().setTag("CraftingStats", CommonTickHandler.worldData.craftingStatsByPlayer.get(event.entity.getCommandSenderName())); + CommonTickHandler.worldData.craftingStatsByPlayer.remove(event.entity.getCommandSenderName()); CommonTickHandler.worldData.markDirty(); } } } } - + public static ArrayList temp = new ArrayList(); - + public static boolean b = false; - + + @SuppressWarnings("unchecked") public static void processEntity(Entity entity, Random r) { - + if(entity == null) {return;} - + temp.clear(); - + if(statTrackersByClass.containsKey(entity.getClass())) {temp.add(statTrackersByClass.get(entity.getClass()));} - + for(EntityStatTracker e : genericTrackers) { if(!temp.contains(e)) { for(Class c : e.classes) {if(c.isAssignableFrom(entity.getClass())) {temp.add(e); break;}} } } - + if(!temp.isEmpty()) { String processed = EntityStatHelper.getStat(entity, "processed"); - + if(processed == null || processed.equals("false")) { EntityStatHelper.giveStat(entity, "processed", "true"); - + for(EntityStatTracker statTracker : temp) { for(EntityStat s : statTracker.stats) { giveStat(entity, s.name, s.getNewValue(r).toString()); @@ -247,200 +216,207 @@ public static void processEntity(Entity entity, Random r) { } } } - - /*if(entity instanceof EntityLiving) { - String entityName = ((EntityLiving) entity).hasCustomNameTag() ? ((EntityLiving) entity).getCustomNameTag() : null; - - if(FyresWorldData.currentDisadvantage != null && FyresWorldData.currentDisadvantage.equals("Illiterate")) { - if((entityName == null || !entityName.startsWith("\u00A7k"))) { - setName((EntityLiving) entity, "\u00A7k" + (entityName == null ? entity.getEntityName() : entityName)); - } - } else if(entityName != null && entityName.startsWith("\u00A7k")) { - setName((EntityLiving) entity, entityName.replace("\u00A7k", "")); - } - }*/ } - + public void register() { MinecraftForge.EVENT_BUS.register(this); } - - @ForgeSubscribe + + @SuppressWarnings("unchecked") + @SubscribeEvent public void livingDeath(LivingDeathEvent event) { if(!event.entity.worldObj.isRemote) { if(event.entity.worldObj.getGameRules().getGameRuleBooleanValue("doMobLoot")) { - + if(event.entity instanceof EntityLivingBase && event.source != null && event.source.getEntity() != null) { if(event.source.getEntity().getEntityData().hasKey("Blessing")) { String blessing = event.source.getEntity().getEntityData().getString("Blessing"); - + if(blessing.equals("Thief") && ModjamMod.r.nextInt(20) == 0) { if(!event.entity.worldObj.isRemote) { - - //((EntityLivingBase) event.entity).dropFewItems(true, event.source.getEntity() instanceof EntityPlayer ? EnchantmentHelper.getLootingModifier((EntityLivingBase) event.source.getEntity()) : 0); - //((EntityLivingBase) event.entity).dropEquipment(true, event.source.getEntity() instanceof EntityPlayer ? EnchantmentHelper.getLootingModifier((EntityLivingBase) event.source.getEntity()) : 0); - - event.entity.dropItem(Item.goldNugget.itemID, 1); + event.entity.dropItem(Items.gold_nugget, 1); } - - //event.entity.worldObj.playSoundAtEntity(event.entity, "fyresmodjam:coin", 1.0F, 1.0F); } } } - + int level = 0; if(event.entity.getEntityData().hasKey("Level")) {level = Integer.parseInt(event.entity.getEntityData().getString("Level"));} - if(ModjamMod.r.nextInt(30) == 0 || level == 5) {event.entity.entityDropItem(new ItemStack(ModjamMod.mysteryPotion.itemID, 1, ModjamMod.r.nextInt(13)), event.entity.height/2);} + if(ModjamMod.r.nextInt(30) == 0 || level == 5) {event.entity.entityDropItem(new ItemStack(ModjamMod.mysteryPotion, 1, ModjamMod.r.nextInt(13)), event.entity.height/2);} } if(event.entity instanceof EntityLivingBase && event.source != null && event.source.getEntity() != null) { if(event.source.getEntity().getEntityData().hasKey("Blessing")) { String blessing = event.source.getEntity().getEntityData().getString("Blessing"); - + if(blessing.equals("Berserker")) { if(!EntityStatHelper.hasStat(event.source.getEntity(), "BlessingCounter")) {EntityStatHelper.giveStat(event.source.getEntity(), "BlessingCounter", 0);} EntityStatHelper.giveStat(event.source.getEntity(), "BlessingCounter", Math.min(10, Integer.parseInt(EntityStatHelper.getStat(event.source.getEntity(), "BlessingCounter")) + 1)); } } } - - if(CommonTickHandler.worldData.currentTask.equals("Kill") && CommonTickHandler.worldData.validMobs[CommonTickHandler.worldData.currentTaskID].isAssignableFrom(event.entity.getClass())) { + + if(CommonTickHandler.worldData.currentTask.equals("Kill") && FyresWorldData.validMobs[CommonTickHandler.worldData.currentTaskID].isAssignableFrom(event.entity.getClass())) { CommonTickHandler.worldData.progress++; - - String name1 = CommonTickHandler.worldData.currentTask.equals("Kill") ? FyresWorldData.validMobNames[CommonTickHandler.worldData.currentTaskID] : new ItemStack(Item.itemsList[CommonTickHandler.worldData.currentTaskID], 1).getDisplayName(); - + + String name1 = CommonTickHandler.worldData.currentTask.equals("Kill") ? FyresWorldData.validMobNames[CommonTickHandler.worldData.currentTaskID] : FyresWorldData.validItems[CommonTickHandler.worldData.currentTaskID].getDisplayName(); + if(name1.contains("Block")) {if(name1.contains("Block")) {name1 = name1.replace("Block", "Blocks").replace("block", "blocks");}} else {name1 += "s";} - - PacketDispatcher.sendPacketToAllPlayers(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7fCurrent Goal Progress: " + CommonTickHandler.worldData.progress + "/" + CommonTickHandler.worldData.currentTaskAmount + " " + name1 + " "+ CommonTickHandler.worldData.currentTask + "ed."})); - + + NewPacketHandler.SEND_MESSAGE.sendToAllPlayers("\u00A7fCurrent Goal Progress: " + CommonTickHandler.worldData.progress + "/" + CommonTickHandler.worldData.currentTaskAmount + " " + name1 + " "+ CommonTickHandler.worldData.currentTask + "ed."); + if(CommonTickHandler.worldData.progress >= CommonTickHandler.worldData.currentTaskAmount) { CommonTickHandler.worldData.progress = 0; CommonTickHandler.worldData.tasksCompleted++; - - PacketDispatcher.sendPacketToAllPlayers(PacketHandler.newPacket(PacketHandler.LEVEL_UP, new Object[] {CommonTickHandler.worldData.rewardLevels})); - + + NewPacketHandler.LEVEL_UP.sendToAllPlayers(CommonTickHandler.worldData.rewardLevels); + if(!CommonTickHandler.worldData.enderDragonKilled && event.entity instanceof EntityDragon) {CommonTickHandler.worldData.enderDragonKilled = true;} CommonTickHandler.worldData.giveNewTask(); - - PacketDispatcher.sendPacketToAllPlayers(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7eA world goal has been completed!" + (!CommonTickHandler.worldData.getDisadvantage().equals("None") ? " World disadvantage has been lifted!": "")})); - PacketDispatcher.sendPacketToAllPlayers(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7eA new world goal has been set: " + (CommonTickHandler.worldData.currentTask + " " + CommonTickHandler.worldData.currentTaskAmount + " " + (CommonTickHandler.worldData.currentTask.equals("Kill") ? FyresWorldData.validMobNames[CommonTickHandler.worldData.currentTaskID] : new ItemStack(Item.itemsList[CommonTickHandler.worldData.currentTaskID], 1).getDisplayName()) + "s. (" + CommonTickHandler.worldData.progress + " " + CommonTickHandler.worldData.currentTask + "ed)")})); - //PacketDispatcher.sendPacketToAllPlayers(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7eGoal Reward: " + CommonTickHandler.worldData.rewardLevels + " experience levels"})); - + + NewPacketHandler.SEND_MESSAGE.sendToAllPlayers("\u00A7eA world goal has been completed!" + (!CommonTickHandler.worldData.getDisadvantage().equals("None") ? " World disadvantage has been lifted!": "")); + + NewPacketHandler.SEND_MESSAGE.sendToAllPlayers("\u00A7eA new world goal has been set: " + (CommonTickHandler.worldData.currentTask + " " + CommonTickHandler.worldData.currentTaskAmount + " " + (CommonTickHandler.worldData.currentTask.equals("Kill") ? FyresWorldData.validMobNames[CommonTickHandler.worldData.currentTaskID] : FyresWorldData.validItems[CommonTickHandler.worldData.currentTaskID].getDisplayName()) + "s. (" + CommonTickHandler.worldData.progress + " " + CommonTickHandler.worldData.currentTask + "ed)")); + CommonTickHandler.worldData.currentDisadvantage = "None"; } - - PacketDispatcher.sendPacketToAllPlayers(PacketHandler.newPacket(PacketHandler.UPDATE_WORLD_DATA, new Object[] {CommonTickHandler.worldData.potionValues, CommonTickHandler.worldData.potionDurations, CommonTickHandler.worldData.getDisadvantage(), CommonTickHandler.worldData.currentTask, CommonTickHandler.worldData.currentTaskID, CommonTickHandler.worldData.currentTaskAmount, CommonTickHandler.worldData.progress, CommonTickHandler.worldData.tasksCompleted, CommonTickHandler.worldData.enderDragonKilled, ModjamMod.spawnTraps, CommonTickHandler.worldData.rewardLevels, CommonTickHandler.worldData.mushroomColors})); - + + NewPacketHandler.UPDATE_WORLD_DATA.sendToAllPlayers(CommonTickHandler.worldData.potionValues, CommonTickHandler.worldData.potionDurations, CommonTickHandler.worldData.getDisadvantage(), CommonTickHandler.worldData.currentTask, CommonTickHandler.worldData.currentTaskID, CommonTickHandler.worldData.currentTaskAmount, CommonTickHandler.worldData.progress, CommonTickHandler.worldData.tasksCompleted, CommonTickHandler.worldData.enderDragonKilled, ModjamMod.spawnTraps, CommonTickHandler.worldData.rewardLevels, CommonTickHandler.worldData.mushroomColors); + CommonTickHandler.worldData.markDirty(); } - + if(!CommonTickHandler.worldData.enderDragonKilled && event.entity instanceof EntityDragon) { CommonTickHandler.worldData.enderDragonKilled = true; - PacketDispatcher.sendPacketToAllPlayers(PacketHandler.newPacket(PacketHandler.UPDATE_WORLD_DATA, new Object[] {CommonTickHandler.worldData.potionValues, CommonTickHandler.worldData.potionDurations, CommonTickHandler.worldData.getDisadvantage(), CommonTickHandler.worldData.currentTask, CommonTickHandler.worldData.currentTaskID, CommonTickHandler.worldData.currentTaskAmount, CommonTickHandler.worldData.progress, CommonTickHandler.worldData.tasksCompleted, CommonTickHandler.worldData.enderDragonKilled, ModjamMod.spawnTraps, CommonTickHandler.worldData.rewardLevels, CommonTickHandler.worldData.mushroomColors})); + NewPacketHandler.UPDATE_WORLD_DATA.sendToAllPlayers(CommonTickHandler.worldData.potionValues, CommonTickHandler.worldData.potionDurations, CommonTickHandler.worldData.getDisadvantage(), CommonTickHandler.worldData.currentTask, CommonTickHandler.worldData.currentTaskID, CommonTickHandler.worldData.currentTaskAmount, CommonTickHandler.worldData.progress, CommonTickHandler.worldData.tasksCompleted, CommonTickHandler.worldData.enderDragonKilled, ModjamMod.spawnTraps, CommonTickHandler.worldData.rewardLevels, CommonTickHandler.worldData.mushroomColors); CommonTickHandler.worldData.markDirty(); } } - + if(event.entity instanceof EntityPlayer) { - + EntityPlayer player = (EntityPlayer) event.entity; - + player.triggerAchievement(ModjamMod.losingIsFun); - - CommonTickHandler.worldData.blessingByPlayer.put(player.getEntityName(), player.getEntityData().getString("Blessing")); - CommonTickHandler.worldData.potionKnowledgeByPlayer.put(player.getEntityName(), player.getEntityData().getIntArray("PotionKnowledge")); - if(player.getEntityData() != null && player.getEntityData().hasKey("KillStats")) {CommonTickHandler.worldData.killStatsByPlayer.put(player.getEntityName(), player.getEntityData().getCompoundTag("KillStats"));} - if(player.getEntityData() != null && player.getEntityData().hasKey("WeaponStats")) {CommonTickHandler.worldData.weaponStatsByPlayer.put(player.getEntityName(), player.getEntityData().getCompoundTag("WeaponStats"));} - if(player.getEntityData() != null && player.getEntityData().hasKey("CraftingStats")) {CommonTickHandler.worldData.craftingStatsByPlayer.put(player.getEntityName(), player.getEntityData().getCompoundTag("CraftingStats"));} - + + CommonTickHandler.worldData.blessingByPlayer.put(player.getCommandSenderName(), player.getEntityData().getString("Blessing")); + CommonTickHandler.worldData.potionKnowledgeByPlayer.put(player.getCommandSenderName(), player.getEntityData().getIntArray("PotionKnowledge")); + if(player.getEntityData() != null && player.getEntityData().hasKey("KillStats")) {CommonTickHandler.worldData.killStatsByPlayer.put(player.getCommandSenderName(), player.getEntityData().getCompoundTag("KillStats"));} + if(player.getEntityData() != null && player.getEntityData().hasKey("WeaponStats")) {CommonTickHandler.worldData.weaponStatsByPlayer.put(player.getCommandSenderName(), player.getEntityData().getCompoundTag("WeaponStats"));} + if(player.getEntityData() != null && player.getEntityData().hasKey("CraftingStats")) {CommonTickHandler.worldData.craftingStatsByPlayer.put(player.getCommandSenderName(), player.getEntityData().getCompoundTag("CraftingStats"));} + } else if(event.source != null && event.source.getEntity() != null && event.source.getEntity() instanceof EntityPlayer) { - + EntityPlayer player = (EntityPlayer) event.source.getEntity(); String mob = getUnalteredName(event.entity); - - if(!player.getEntityData().hasKey("KillStats")) {player.getEntityData().setCompoundTag("KillStats", new NBTTagCompound());} + + if(!player.getEntityData().hasKey("KillStats")) {player.getEntityData().setTag("KillStats", new NBTTagCompound());} NBTTagCompound killStats = player.getEntityData().getCompoundTag("KillStats"); - if(!killStats.hasKey(mob + "Kills")) {killStats.setInteger(mob + "Kills", 0);} - killStats.setInteger(mob + "Kills", killStats.getInteger(mob + "Kills") + 1); - + + if(!killStats.hasKey(mob)) { + killStats.setInteger(mob, 0); + + if(!killStats.hasKey("TrackedMobList")) { + killStats.setString("TrackedMobList", mob); + } else { + killStats.setString("TrackedMobList", killStats.getString("TrackedMobList") + ";" + mob); + } + } + + killStats.setInteger(mob, killStats.getInteger(mob) + 1); + if(ModjamMod.enableMobKillStats) { for(int i = 0; i < knowledge.length; i++) { - if(killCount[i] == killStats.getInteger(mob + "Kills")) {PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7o\u00A73You've become a " + knowledge[i].toLowerCase() + " " + mob.toLowerCase() + " slayer! (+" + damageBonusString[i] + "% damage against " + mob.toLowerCase() + "s.)" + (i < knowledge.length - 1 ? " " + (killCount[i + 1] - killCount[i]) + " " + mob.toLowerCase() + " kills to next rank." : "")}), (Player) player); break;} + if(killCount[i] == killStats.getInteger(mob)) { + NewPacketHandler.SEND_MESSAGE.sendToPlayer(player, "\u00A7o\u00A73You've become a " + knowledge[i].toLowerCase() + " " + mob.toLowerCase() + " slayer! (+" + damageBonusString[i] + "% damage against " + mob.toLowerCase() + "s.)" + (i < knowledge.length - 1 ? " " + (killCount[i + 1] - killCount[i]) + " " + mob.toLowerCase() + " kills to next rank." : "")); + break; + } } - + int count = 0; - - for(Object object : killStats.getTags()) { - if(object == null || !(object instanceof NBTBase)) {continue;} - if(killStats.getInteger(((NBTBase) object).getName()) >= killCount[2]) {count++;} + + if(killStats.hasKey("TrackedMobList") && killStats.getString("TrackedMobList") != null && killStats.getString("TrackedMobList").length() > 0) { + for(String object : killStats.getString("TrackedMobList").split(";")) { + if(killStats.hasKey(object) && killStats.getInteger(object) >= killCount[2]) {count++;} + } } - + if(count >= 5) {player.triggerAchievement(ModjamMod.theHunt);} } - + String weapon = "misc"; - + if(player.getHeldItem() == null) { weapon = "fist"; } else if(player.getHeldItem().getItem() != null && player.getHeldItem().getItem() instanceof ItemSword || player.getHeldItem().getItem() instanceof ItemBow || player.getHeldItem().getItem() instanceof ItemAxe) { weapon = getUnalteredItemName(player.getHeldItem().getItem()); } - - if(!player.getEntityData().hasKey("WeaponStats")) {player.getEntityData().setCompoundTag("WeaponStats", new NBTTagCompound());} + + if(!player.getEntityData().hasKey("WeaponStats")) {player.getEntityData().setTag("WeaponStats", new NBTTagCompound());} NBTTagCompound weaponStats = player.getEntityData().getCompoundTag("WeaponStats"); - if(!weaponStats.hasKey(weapon + "Kills")) {weaponStats.setInteger(weapon + "Kills", 0);} - weaponStats.setInteger(weapon + "Kills", weaponStats.getInteger(weapon + "Kills") + 1); - + + if(!weaponStats.hasKey(weapon)) { + weaponStats.setInteger(weapon, 0); + + if(!weaponStats.hasKey("TrackedItemList")) { + weaponStats.setString("TrackedItemList", weapon); + } else { + weaponStats.setString("TrackedItemList", weaponStats.getString("TrackedItemList") + ";" + weapon); + } + } + + weaponStats.setInteger(weapon, weaponStats.getInteger(weapon) + 1); + if(ModjamMod.enableWeaponKillStats) { for(int i = 0; i < knowledge.length; i++) { - if(killCount[i] * 2 == weaponStats.getInteger(weapon + "Kills")) {PacketDispatcher.sendPacketToPlayer(PacketHandler.newPacket(PacketHandler.SEND_MESSAGE, new Object[] {"\u00A7o\u00A73You've become a " + knowledge[i].toLowerCase() + " " + weapon.toLowerCase() + " user! (+" + damageBonusString[i] + "% damage with " + weapon.toLowerCase() + "s.)" + (i < knowledge.length - 1 ? " " + (killCount[i + 1] * 2 - killCount[i] * 2) + " " + weapon.toLowerCase() + " kills to next rank." : "")}), (Player) player); break;} + if(killCount[i] * 2 == weaponStats.getInteger(weapon)) { + NewPacketHandler.SEND_MESSAGE.sendToPlayer(player, "\u00A7o\u00A73You've become a " + knowledge[i].toLowerCase() + " " + weapon.toLowerCase() + " user! (+" + damageBonusString[i] + "% damage with " + weapon.toLowerCase() + "s.)" + (i < knowledge.length - 1 ? " " + (killCount[i + 1] * 2 - killCount[i] * 2) + " " + weapon.toLowerCase() + " kills to next rank." : "")); + break; + } } - + int count = 0; - - for(Object object : weaponStats.getTags()) { - if(object == null || !(object instanceof NBTBase)) {continue;} - if(weaponStats.getInteger(((NBTBase) object).getName()) >= killCount[1] * 2) {count++;} + + if(weaponStats.hasKey("TrackedItemList") && weaponStats.getString("TrackedItemList") != null && weaponStats.getString("TrackedItemList").length() > 0) { + for(String object : weaponStats.getString("TrackedItemList").split(";")) { + if(weaponStats.hasKey(object) && weaponStats.getInteger(object) >= killCount[1] * 2) {count++;} + } } - + if(count >= 10) {player.triggerAchievement(ModjamMod.jackOfAllTrades);} } - + } } - + public static void setEntitySize(Entity entity, float par1, float par2) { float f2; - if (par1 != entity.width || par2 != entity.height) { - f2 = entity.width; - entity.width = par1; - entity.height = par2; - entity.boundingBox.maxX = entity.boundingBox.minX + (double)entity.width; - entity.boundingBox.maxZ = entity.boundingBox.minZ + (double)entity.width; - entity.boundingBox.maxY = entity.boundingBox.minY + (double)entity.height; - - /*if (entity.width > f2 && !entity.firstUpdate && !entity.worldObj.isRemote) { - entity.moveEntity((double)(f2 - entity.width), 0.0D, (double)(f2 - entity.width)); - }*/ - } - - f2 = par1 % 2.0F; - - if ((double)f2 < 0.375D) { - entity.myEntitySize = EnumEntitySize.SIZE_1; - } else if ((double)f2 < 0.75D) { - entity.myEntitySize = EnumEntitySize.SIZE_2; - } else if ((double)f2 < 1.0D) { - entity.myEntitySize = EnumEntitySize.SIZE_3; - } else if ((double)f2 < 1.375D) { - entity.myEntitySize = EnumEntitySize.SIZE_4; - } else if ((double)f2 < 1.75D) { - entity.myEntitySize = EnumEntitySize.SIZE_5; - } else { - entity.myEntitySize = EnumEntitySize.SIZE_6; - } + if (par1 != entity.width || par2 != entity.height) { + f2 = entity.width; + entity.width = par1; + entity.height = par2; + entity.boundingBox.maxX = entity.boundingBox.minX + entity.width; + entity.boundingBox.maxZ = entity.boundingBox.minZ + entity.width; + entity.boundingBox.maxY = entity.boundingBox.minY + entity.height; + } + + f2 = par1 % 2.0F; + + if (f2 < 0.375D) { + entity.myEntitySize = EnumEntitySize.SIZE_1; + } else if (f2 < 0.75D) { + entity.myEntitySize = EnumEntitySize.SIZE_2; + } else if (f2 < 1.0D) { + entity.myEntitySize = EnumEntitySize.SIZE_3; + } else if (f2 < 1.375D) { + entity.myEntitySize = EnumEntitySize.SIZE_4; + } else if (f2 < 1.75D) { + entity.myEntitySize = EnumEntitySize.SIZE_5; + } else { + entity.myEntitySize = EnumEntitySize.SIZE_6; + } } } diff --git a/java/fyresmodjam/misc/ItemStatHelper.java b/java/fyresmodjam/misc/ItemStatHelper.java new file mode 100644 index 0000000..3d09275 --- /dev/null +++ b/java/fyresmodjam/misc/ItemStatHelper.java @@ -0,0 +1,362 @@ +package fyresmodjam.misc; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Random; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.monster.EntityMob; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.ItemAxe; +import net.minecraft.item.ItemBow; +import net.minecraft.item.ItemPickaxe; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemSword; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.nbt.NBTTagString; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.DamageSource; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.living.LivingHurtEvent; +import net.minecraftforge.event.entity.player.PlayerDropsEvent; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent; +import fyresmodjam.ModjamMod; +import fyresmodjam.handlers.CommonTickHandler; +import fyresmodjam.handlers.NewPacketHandler; + +@SuppressWarnings("rawtypes") +public class ItemStatHelper { + + public static class ItemStatTracker { + public Class[] classes; + + public boolean instanceAllowed = false; + + public ItemStatTracker(Class[] classes, boolean instanceAllowed) { + this.classes = classes; + this.instanceAllowed = instanceAllowed; + } + + public ItemStatTracker(Class c, boolean instanceAllowed) {this(new Class[] {c}, instanceAllowed);} + + public ArrayList stats = new ArrayList(); + + public void addStat(ItemStat stat) { + if(!stats.contains(stat)) {stats.add(stat);} + } + } + + public static class ItemStat { + public String name; + public String value; + + public ItemStat(String name, Object value) { + this.name = name; + this.value = value.toString(); + } + + public Object getNewValue(ItemStack stack, Random r) {return value;} + public String getLore(ItemStack stack) {return null;} + public String getAlteredStackName(ItemStack stack, Random r) {return stack.getDisplayName();} + public void modifyStack(ItemStack stack, Random r) {} + } + + public static HashMap> statTrackersByClass = new HashMap>(); + + public static ArrayList genericTrackers = new ArrayList(); + + public static ArrayList skip = new ArrayList(); + + public static void addStatTracker(ItemStatTracker statTracker) { + if(statTracker.classes != null) { + for(Class c : statTracker.classes) { + if(!statTrackersByClass.containsKey(c)) {statTrackersByClass.put(c, new ArrayList());} + statTrackersByClass.get(c).add(statTracker); + } + } + + if(statTracker.instanceAllowed) {genericTrackers.add(statTracker);} + } + + public static ItemStack giveStat(ItemStack stack, String name, Object value) { + if(!stack.hasTagCompound()) {stack.setTagCompound(new NBTTagCompound());} + NBTTagCompound data = stack.stackTagCompound; + data.setString(name, value.toString()); + return stack; + } + + public static ItemStack setName(ItemStack stack, String name) { + if(!stack.hasTagCompound()) {stack.setTagCompound(new NBTTagCompound());} + if(!stack.getTagCompound().hasKey("display")) {stack.getTagCompound().setTag("display", new NBTTagCompound());} + stack.getTagCompound().getCompoundTag("display").setString("Name", name); + + return stack; + } + + public static ItemStack addLore(ItemStack stack, String lore) { + if(!stack.hasTagCompound()) {stack.setTagCompound(new NBTTagCompound());} + if(!stack.getTagCompound().hasKey("display")) {stack.getTagCompound().setTag("display", new NBTTagCompound());} + if(!stack.getTagCompound().getCompoundTag("display").hasKey("Lore")) {stack.getTagCompound().getCompoundTag("display").setTag("Lore", new NBTTagList());} + if(lore != null) {((NBTTagList) stack.getTagCompound().getCompoundTag("display").getTag("Lore")).appendTag(new NBTTagString(lore));} + return stack; + } + + public static String getName(ItemStack stack) { + if(stack.getTagCompound() != null && stack.getTagCompound().hasKey("display") && stack.getTagCompound().getCompoundTag("display").hasKey("Name")) { + return stack.getTagCompound().getCompoundTag("display").getString("Name"); + } + + return null; + } + + public static String getStat(ItemStack stack, String name) { + String s = null; + if(stack.getTagCompound() != null && stack.getTagCompound().hasKey(name)) {s = stack.getTagCompound().getString(name);} + return s; + } + + public static boolean hasStat(ItemStack stack, String name) { + if(stack.getTagCompound() != null && stack.getTagCompound().hasKey(name)) {return true;} + return false; + } + + @SubscribeEvent + public void playerDrops(PlayerDropsEvent event) { + if(!event.entity.worldObj.isRemote) { + if(CommonTickHandler.worldData.getDisadvantage().equals("Permadeath")) { + for(EntityItem i : event.drops) {i.setDead();} + } + } + } + + @SubscribeEvent + public void livingHurt(LivingHurtEvent event) { + if(!event.entity.worldObj.isRemote) { + float damageMultiplier = 1.0F; + + boolean skip = false; + + if((CommonTickHandler.worldData.getDisadvantage().equals("Weak") && event.source.getDamageType().equals("player")) || (CommonTickHandler.worldData.getDisadvantage().equals("Tougher Mobs") && event.entity instanceof EntityMob)) { + damageMultiplier -= 0.25F; + } + + if(event.entity.getEntityData().hasKey("Blessing")) { + String blessing = event.entity.getEntityData().getString("Blessing"); + + if(blessing.equals("Guardian")) { + damageMultiplier -= 0.20F; + } else if(blessing.equals("Inferno") && (event.source.isFireDamage() || event.source.getDamageType().equals("inFire") || event.source.getDamageType().equals("onFire") || event.source.getDamageType().equals("lava"))) { + skip = true; + damageMultiplier = 0; + } else if(blessing.equals("Paratrooper") && event.source.getDamageType().equals("fall")) { + skip = true; + damageMultiplier = 0; + } else if(blessing.equals("Vampire")) { + if(event.entity.getBrightness(1.0F) > 0.5F && event.entity.worldObj.canBlockSeeTheSky((int) (event.entity.posX), (int) (event.entity.posY), (int) (event.entity.posZ))) { + damageMultiplier += 0.2F; + } + } else if(blessing.equals("Porcupine") && event.source.getEntity() != null && event.source.getEntity() instanceof EntityLivingBase && !event.source.isProjectile() && (event.source.damageType.equals("mob") || event.source.getDamageType().equals("player"))) { + DamageSource damage = DamageSource.causeThornsDamage(event.entity); + ((EntityLivingBase) event.source.getEntity()).attackEntityFrom(damage, event.ammount * 0.07F); + } + } + + if(!skip && event.entity instanceof EntityLivingBase) { + EntityLivingBase entity = (EntityLivingBase) event.entity; + + for(int i = 0; i < 4; i++) { + ItemStack stack = entity.getEquipmentInSlot(i + 1); + if(stack == null || stack.getTagCompound() == null || !stack.getTagCompound().hasKey("DamageReduction")) {continue;} + damageMultiplier -= Float.parseFloat(stack.getTagCompound().getString("DamageReduction").trim().replace(",", ".")) * 0.01F; + } + } + + if(!skip && event.source != null && event.source.getEntity() != null) { + if(event.source.getEntity() instanceof EntityLivingBase) { + EntityLivingBase entity = (EntityLivingBase) event.source.getEntity(); + + ItemStack held = entity.getEquipmentInSlot(0); + + if(held != null && ((event.source.getDamageType().equals("player") || event.source.getDamageType().equals("mob") || (held.getItem() == Items.bow && event.source.isProjectile())))) { + String s = getStat(held, "BonusDamage"); + if(s != null) {event.ammount += Float.parseFloat(s.trim().replace(",", "."));} + } + } + + String mob = EntityStatHelper.getUnalteredName(event.entity); + if(ModjamMod.enableMobKillStats && event.source.getEntity() instanceof EntityPlayer && event.source.getEntity().getEntityData().hasKey("KillStats") && event.source.getEntity().getEntityData().getCompoundTag("KillStats").hasKey(mob)) { + int kills = event.source.getEntity().getEntityData().getCompoundTag("KillStats").getInteger(mob); + + int last = 0; + for(int i = 0; i < EntityStatHelper.killCount.length; i++) { + if(kills >= EntityStatHelper.killCount[i]) {last = i; continue;} else {break;} + } + + damageMultiplier += EntityStatHelper.damageBonus[last]; + } + + String weapon = "misc"; + if(ModjamMod.enableWeaponKillStats && event.source.getEntity() instanceof EntityPlayer && event.source.getEntity().getEntityData().hasKey("WeaponStats") && event.source.getEntity().getEntityData().getCompoundTag("WeaponStats").hasKey(weapon)) { + EntityPlayer player = (EntityPlayer) event.source.getEntity(); + + if(player.getHeldItem() == null) { + weapon = "fist"; + } else if(player.getHeldItem().getItem() != null && player.getHeldItem().getItem() instanceof ItemSword || player.getHeldItem().getItem() instanceof ItemBow || player.getHeldItem().getItem() instanceof ItemAxe) { + weapon = EntityStatHelper.getUnalteredItemName(player.getHeldItem().getItem()); + } + + int kills = event.source.getEntity().getEntityData().getCompoundTag("WeaponStats").getInteger(weapon); + + int last = 0; + for(int i = 0; i < EntityStatHelper.killCount.length; i++) { + if(kills >= EntityStatHelper.killCount[i] * 2) {last = i; continue;} else {break;} + } + + damageMultiplier += EntityStatHelper.damageBonus[last]; + } + + if(event.source.getEntity().getEntityData().hasKey("Blessing")) { + String blessing = event.source.getEntity().getEntityData().getString("Blessing"); + + ItemStack held = null; + if(event.source.getEntity() instanceof EntityLivingBase) {held = ((EntityLivingBase) event.source.getEntity()).getHeldItem();} + + if(blessing.equals("Warrior") && (event.source.getDamageType().equals("player") || event.source.getDamageType().equals("mob"))) { + damageMultiplier += 0.2F; + } else if(blessing.equals("Hunter") && event.source.isProjectile()) { + damageMultiplier += 0.2F; + } else if(blessing.equals("Miner") && held != null && held.getItem() instanceof ItemPickaxe) { + damageMultiplier += 0.2F; + } else if(blessing.equals("Lumberjack") && held != null && held.getItem() instanceof ItemAxe) { + damageMultiplier += 0.15F; + } else if(event.entityLiving != null && blessing.equals("Ninja") && event.source.getEntity().isSneaking() && event.entityLiving.getHealth() == event.entityLiving.getMaxHealth()) { + damageMultiplier += 1.0F; + } else if(blessing.equals("Swamp") && event.entityLiving != null) { + event.entityLiving.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 100, 1, false)); + } else if(blessing.equals("Vampire") && event.source.getEntity() instanceof EntityLivingBase) { + ((EntityLivingBase) event.source.getEntity()).heal(event.ammount * damageMultiplier * 0.07F); + + if(event.source.getEntity().getBrightness(1.0F) > 0.5F && event.source.getEntity().worldObj.canBlockSeeTheSky((int) (event.source.getEntity().posX), (int) (event.source.getEntity().posY), (int) (event.source.getEntity().posZ))) { + damageMultiplier -= 0.2F; + } + } else if(blessing.equals("Inferno") && event.source.getEntity().isBurning()) { + damageMultiplier += 0.35F; + } else if(blessing.equals("Berserker") && EntityStatHelper.hasStat(event.source.getEntity(), "BlessingActive") ? Boolean.parseBoolean(EntityStatHelper.getStat(event.source.getEntity(), "BlessingActive")) : false) { + damageMultiplier += 0.3F; + } else if(event.source.getEntity() instanceof EntityLivingBase && blessing.equals("Loner")) { + damageMultiplier += 0.35F * (1.0F - (((EntityLivingBase) event.source.getEntity()).getHealth() / ((EntityLivingBase) event.source.getEntity()).getMaxHealth())); + } + } + } + + event.ammount *= damageMultiplier; + } + } + + public static ArrayList temp = new ArrayList(); + + @SuppressWarnings("unchecked") + public static void processItemStack(ItemStack stack, Random r) { + if(stack == null) {return;} + + temp.clear(); + + Class itemClass = stack.getItem().getClass(); + + if(statTrackersByClass.containsKey(itemClass)) {temp.addAll(statTrackersByClass.get(itemClass));} + + for(ItemStatTracker e : genericTrackers) { + if(!temp.contains(e)) { + for(Class c : e.classes) { + if(c.isAssignableFrom(itemClass)) { + ArrayList list = null; + + if(statTrackersByClass.containsKey(itemClass)) { + list = new ArrayList(); + statTrackersByClass.put(itemClass, list); + } else {list = statTrackersByClass.get(itemClass);} + + if(!statTrackersByClass.get(itemClass).contains(e)) {list.add(e);} + + temp.add(e); + + break; + } + } + } + } + + if(!temp.isEmpty()) { + if(!stack.hasTagCompound()) {stack.setTagCompound(new NBTTagCompound());} + + String processed = ItemStatHelper.getStat(stack, "processed"); + + if(processed == null || processed.equals("false")) { + stack.getTagCompound().setTag("Lore", new NBTTagList()); + + ItemStatHelper.giveStat(stack, "processed", "true"); + + for(ItemStatTracker statTracker : temp) { + for(ItemStat s : statTracker.stats) { + giveStat(stack, s.name, s.getNewValue(stack, r).toString()); + + String lore = s.getLore(stack); + if(lore != null) {addLore(stack, lore);} + + setName(stack, s.getAlteredStackName(stack, r)); + + s.modifyStack(stack, r); + } + } + } + } else {skip.add(itemClass);} + } + + @SubscribeEvent + public void onCrafting(ItemCraftedEvent event) { + + EntityPlayer player = event.player; + ItemStack item = event.crafting; + + if(!player.worldObj.isRemote) { + String itemName = null; + + if(item.getItem() != null && item.getItem() instanceof ItemSword || item.getItem() instanceof ItemBow || item.getItem() instanceof ItemAxe) {itemName = EntityStatHelper.getUnalteredItemName(item.getItem());} + + if(ModjamMod.enableCraftingStats && itemName != null) { + if(!player.getEntityData().hasKey("CraftingStats")) {player.getEntityData().setTag("CraftingStats", new NBTTagCompound());} + NBTTagCompound craftingStats = player.getEntityData().getCompoundTag("CraftingStats"); + + if(!craftingStats.hasKey(itemName)) { + craftingStats.setInteger(itemName, 0); + + if(!craftingStats.hasKey("TrackedItemList")) { + craftingStats.setString("TrackedItemList", itemName); + } else { + craftingStats.setString("TrackedItemList", craftingStats.getString("TrackedItemList") + ";" + itemName); + } + } + + craftingStats.setInteger(itemName, craftingStats.getInteger(itemName) + 1); + + for(int i = 0; i < EntityStatHelper.knowledge.length; i++) { + if(EntityStatHelper.killCount[i] == craftingStats.getInteger(itemName)) { + NewPacketHandler.SEND_MESSAGE.sendToPlayer(player, "\u00A7o\u00A73You've become a " + EntityStatHelper.knowledge[i].toLowerCase() + " " + itemName.toLowerCase() + " smith! (" + (i < EntityStatHelper.knowledge.length - 1 ? (EntityStatHelper.killCount[i + 1] * 2 - EntityStatHelper.killCount[i] * 2) + " " + itemName.toLowerCase() + " crafts to next rank." : "")); + break; + } + } + } + } + } + + public void register() { + MinecraftForge.EVENT_BUS.register(this); + } + + public void onSmelting(EntityPlayer player, ItemStack item) {} +} diff --git a/java/fyresmodjam/models/ModelCrystal.java b/java/fyresmodjam/models/ModelCrystal.java new file mode 100644 index 0000000..84da3a8 --- /dev/null +++ b/java/fyresmodjam/models/ModelCrystal.java @@ -0,0 +1,79 @@ +// Date: 12/13/2013 12:25:37 AM +// Template version 1.1 +// Java generated by Techne +// Keep in mind that you still need to fill in some blanks +// - ZeuX + +package fyresmodjam.models; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; + +public class ModelCrystal extends ModelBase { + + ModelRenderer CrystalMain; + ModelRenderer CrystalEdge1; + ModelRenderer CrystalEdge2; + ModelRenderer CrystalTop1; + ModelRenderer CrystalTop2; + + public ModelCrystal() { + textureWidth = 64; + textureHeight = 32; + + CrystalMain = new ModelRenderer(this, 0, 0); + CrystalMain.addBox(0F, 0F, 0F, 5, 7, 5); + CrystalMain.setRotationPoint(-3F, 10F, -3F); + CrystalMain.setTextureSize(64, 32); + CrystalMain.mirror = true; + setRotation(CrystalMain, 0F, 0F, 0F); + CrystalEdge1 = new ModelRenderer(this, 0, 14); + CrystalEdge1.addBox(0F, 0F, 0F, 3, 1, 3); + CrystalEdge1.setRotationPoint(-2F, 9F, -2F); + CrystalEdge1.setTextureSize(64, 32); + CrystalEdge1.mirror = true; + setRotation(CrystalEdge1, 0F, 0F, 0F); + CrystalEdge2 = new ModelRenderer(this, 0, 14); + CrystalEdge2.addBox(0F, 0F, 0F, 3, 1, 3); + CrystalEdge2.setRotationPoint(-2F, 17F, -2F); + CrystalEdge2.setTextureSize(64, 32); + CrystalEdge2.mirror = true; + setRotation(CrystalEdge2, 0F, 0F, 0F); + CrystalTop1 = new ModelRenderer(this, 0, 12); + CrystalTop1.addBox(0F, 8F, 0F, 1, 1, 1); + CrystalTop1.setRotationPoint(-1F, 0F, -1F); + CrystalTop1.setTextureSize(64, 32); + CrystalTop1.mirror = true; + setRotation(CrystalTop1, 0F, 0F, 0F); + CrystalTop2 = new ModelRenderer(this, 0, 12); + CrystalTop2.addBox(-1F, 18F, -1F, 1, 1, 1); + CrystalTop2.setRotationPoint(0F, 0F, 0F); + CrystalTop2.setTextureSize(64, 32); + CrystalTop2.mirror = true; + setRotation(CrystalTop2, 0F, 0F, 0F); + } + + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + setRotationAngles(f, f1, f2, f3, f4, f5, entity); + CrystalMain.render(f5); + CrystalEdge1.render(f5); + CrystalEdge2.render(f5); + CrystalTop1.render(f5); + CrystalTop2.render(f5); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + @Override + public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { + super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); + } + +} diff --git a/java/fyresmodjam/models/ModelCrystalStand.java b/java/fyresmodjam/models/ModelCrystalStand.java new file mode 100644 index 0000000..25e913e --- /dev/null +++ b/java/fyresmodjam/models/ModelCrystalStand.java @@ -0,0 +1,60 @@ +// Date: 12/13/2013 3:43:20 PM +// Template version 1.1 +// Java generated by Techne +// Keep in mind that you still need to fill in some blanks +// - ZeuX + +package fyresmodjam.models; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; + +public class ModelCrystalStand extends ModelBase +{ + //fields + ModelRenderer Shape1; + ModelRenderer Shape2; + + public ModelCrystalStand() + { + textureWidth = 64; + textureHeight = 64; + + Shape1 = new ModelRenderer(this, 0, 0); + Shape1.addBox(0F, 0F, 0F, 16, 4, 16); + Shape1.setRotationPoint(-8F, 20F, -8F); + Shape1.setTextureSize(64, 64); + Shape1.mirror = true; + setRotation(Shape1, 0F, 0F, 0F); + Shape2 = new ModelRenderer(this, 0, 20); + Shape2.addBox(0F, 0F, 0F, 10, 4, 10); + Shape2.setRotationPoint(-5F, 16F, -5F); + Shape2.setTextureSize(64, 64); + Shape2.mirror = true; + setRotation(Shape2, 0F, 0F, 0F); + } + + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) + { + super.render(entity, f, f1, f2, f3, f4, f5); + setRotationAngles(f, f1, f2, f3, f4, f5, entity); + Shape1.render(f5); + Shape2.render(f5); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + @Override + public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) + { + super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); + } + +} diff --git a/java/fyresmodjam/models/ModelPillar.java b/java/fyresmodjam/models/ModelPillar.java new file mode 100644 index 0000000..a591297 --- /dev/null +++ b/java/fyresmodjam/models/ModelPillar.java @@ -0,0 +1,68 @@ +// Date: 8/2/2013 9:09:39 AM +// Template version 1.1 +// Java generated by Techne +// Keep in mind that you still need to fill in some blanks +// - ZeuX + +package fyresmodjam.models; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; + +public class ModelPillar extends ModelBase +{ + //fields + ModelRenderer Shape1; + ModelRenderer Shape2; + ModelRenderer Shape3; + + public ModelPillar() + { + textureWidth = 64; + textureHeight = 64; + + Shape1 = new ModelRenderer(this, 0, 0); + Shape1.addBox(0F, 0F, 0F, 12, 26, 12); + Shape1.setRotationPoint(-6F, -2F, -6F); + Shape1.setTextureSize(64, 64); + Shape1.mirror = true; + setRotation(Shape1, 0F, 0F, 0F); + Shape2 = new ModelRenderer(this, 0, 38); + Shape2.addBox(0F, 0F, 0F, 10, 2, 10); + Shape2.setRotationPoint(-5F, -4F, -5F); + Shape2.setTextureSize(64, 64); + Shape2.mirror = true; + setRotation(Shape2, 0F, 0F, 0F); + Shape3 = new ModelRenderer(this, 0, 50); + Shape3.addBox(0F, 0F, 0F, 8, 2, 8); + Shape3.setRotationPoint(-4F, -6F, -4F); + Shape3.setTextureSize(64, 64); + Shape3.mirror = true; + setRotation(Shape3, 0F, 0F, 0F); + } + + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) + { + super.render(entity, f, f1, f2, f3, f4, f5); + setRotationAngles(f, f1, f2, f3, f4, f5, entity); + Shape1.render(f5); + Shape2.render(f5); + Shape3.render(f5); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + @Override + public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) + { + super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); + } + +} diff --git a/java/fyresmodjam/models/ModelSpikes.java b/java/fyresmodjam/models/ModelSpikes.java new file mode 100644 index 0000000..41a640a --- /dev/null +++ b/java/fyresmodjam/models/ModelSpikes.java @@ -0,0 +1,307 @@ +// Date: 8/3/2013 3:14:02 PM +// Template version 1.1 +// Java generated by Techne +// Keep in mind that you still need to fill in some blanks +// - ZeuX + +package fyresmodjam.models; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; + +public class ModelSpikes extends ModelBase { + //fields + ModelRenderer Shape1; + ModelRenderer Shape2; + ModelRenderer Shape3; + ModelRenderer Shape4; + ModelRenderer Shape5; + ModelRenderer Shape6; + ModelRenderer Shape7; + ModelRenderer Shape8; + ModelRenderer Shape9; + ModelRenderer Shape10; + ModelRenderer Shape12; + ModelRenderer Shape13; + ModelRenderer Shape11; + ModelRenderer Shape14; + ModelRenderer Shape15; + ModelRenderer Shape16; + ModelRenderer Shape17; + ModelRenderer Shape18; + ModelRenderer Shape19; + ModelRenderer Shape20; + ModelRenderer Shape21; + ModelRenderer Shape22; + ModelRenderer Shape23; + ModelRenderer Shape24; + ModelRenderer Shape25; + ModelRenderer Shape26; + ModelRenderer Shape27; + ModelRenderer Shape28; + ModelRenderer Shape29; + ModelRenderer Shape30; + ModelRenderer Shape31; + ModelRenderer Shape32; + ModelRenderer Shape33; + + public ModelSpikes() + { + textureWidth = 64; + textureHeight = 32; + + Shape1 = new ModelRenderer(this, 0, 5); + Shape1.addBox(0F, 0F, 0F, 14, 1, 13); + Shape1.setRotationPoint(-7F, 23F, -6.5F); + Shape1.setTextureSize(64, 32); + Shape1.mirror = true; + setRotation(Shape1, 0F, 0F, 0F); + Shape2 = new ModelRenderer(this, 0, 0); + Shape2.addBox(0F, 0F, 0F, 2, 3, 2); + Shape2.setRotationPoint(4F, 20F, 3.5F); + Shape2.setTextureSize(64, 32); + Shape2.mirror = true; + setRotation(Shape2, 0F, 0F, 0F); + Shape3 = new ModelRenderer(this, 0, 0); + Shape3.addBox(0F, 0F, 0F, 1, 3, 1); + Shape3.setRotationPoint(4.5F, 17F, 4F); + Shape3.setTextureSize(64, 32); + Shape3.mirror = true; + setRotation(Shape3, 0F, 0F, 0F); + Shape4 = new ModelRenderer(this, 0, 0); + Shape4.addBox(0F, 0F, 0F, 1, 3, 1); + Shape4.setRotationPoint(-5.5F, 17F, 4F); + Shape4.setTextureSize(64, 32); + Shape4.mirror = true; + setRotation(Shape4, 0F, 0F, 0F); + Shape5 = new ModelRenderer(this, 0, 0); + Shape5.addBox(0F, 0F, 0F, 2, 3, 2); + Shape5.setRotationPoint(-6F, 20F, 3.5F); + Shape5.setTextureSize(64, 32); + Shape5.mirror = true; + setRotation(Shape5, 0F, 0F, 0F); + Shape6 = new ModelRenderer(this, 0, 0); + Shape6.addBox(0F, 0F, 0F, 1, 3, 1); + Shape6.setRotationPoint(-2.5F, 17F, 4F); + Shape6.setTextureSize(64, 32); + Shape6.mirror = true; + setRotation(Shape6, 0F, 0F, 0F); + Shape7 = new ModelRenderer(this, 0, 0); + Shape7.addBox(0F, 0F, 0F, 2, 3, 2); + Shape7.setRotationPoint(-3F, 20F, 3.5F); + Shape7.setTextureSize(64, 32); + Shape7.mirror = true; + setRotation(Shape7, 0F, 0F, 0F); + Shape8 = new ModelRenderer(this, 0, 0); + Shape8.addBox(0F, 0F, 0F, 2, 3, 2); + Shape8.setRotationPoint(0.4666667F, 20F, 3.5F); + Shape8.setTextureSize(64, 32); + Shape8.mirror = true; + setRotation(Shape8, 0F, 0F, 0F); + Shape9 = new ModelRenderer(this, 0, 0); + Shape9.addBox(0F, 0F, 0F, 1, 3, 1); + Shape9.setRotationPoint(1F, 17F, 4F); + Shape9.setTextureSize(64, 32); + Shape9.mirror = true; + setRotation(Shape9, 0F, 0F, 0F); + Shape10 = new ModelRenderer(this, 0, 0); + Shape10.addBox(0F, 0F, 0F, 2, 3, 2); + Shape10.setRotationPoint(-3F, 20F, -5.5F); + Shape10.setTextureSize(64, 32); + Shape10.mirror = true; + setRotation(Shape10, 0F, 0F, 0F); + Shape12 = new ModelRenderer(this, 0, 0); + Shape12.addBox(0F, 0F, 0F, 2, 3, 2); + Shape12.setRotationPoint(-6F, 20F, -5.5F); + Shape12.setTextureSize(64, 32); + Shape12.mirror = true; + setRotation(Shape12, 0F, 0F, 0F); + Shape13 = new ModelRenderer(this, 0, 0); + Shape13.addBox(0F, 0F, 0F, 1, 3, 1); + Shape13.setRotationPoint(-5.5F, 17F, -5F); + Shape13.setTextureSize(64, 32); + Shape13.mirror = true; + setRotation(Shape13, 0F, 0F, 0F); + Shape11 = new ModelRenderer(this, 0, 0); + Shape11.addBox(0F, 0F, 0F, 1, 3, 1); + Shape11.setRotationPoint(-2.5F, 17F, -5F); + Shape11.setTextureSize(64, 32); + Shape11.mirror = true; + setRotation(Shape11, 0F, 0F, 0F); + Shape14 = new ModelRenderer(this, 0, 0); + Shape14.addBox(0F, 0F, 0F, 2, 3, 2); + Shape14.setRotationPoint(0.4666667F, 20F, -5.5F); + Shape14.setTextureSize(64, 32); + Shape14.mirror = true; + setRotation(Shape14, 0F, 0F, 0F); + Shape15 = new ModelRenderer(this, 0, 0); + Shape15.addBox(0F, 0F, 0F, 1, 3, 1); + Shape15.setRotationPoint(1F, 17F, -5F); + Shape15.setTextureSize(64, 32); + Shape15.mirror = true; + setRotation(Shape15, 0F, 0F, 0F); + Shape16 = new ModelRenderer(this, 0, 0); + Shape16.addBox(0F, 0F, 0F, 2, 3, 2); + Shape16.setRotationPoint(4F, 20F, -5.5F); + Shape16.setTextureSize(64, 32); + Shape16.mirror = true; + setRotation(Shape16, 0F, 0F, 0F); + Shape17 = new ModelRenderer(this, 0, 0); + Shape17.addBox(0F, 0F, 0F, 1, 3, 1); + Shape17.setRotationPoint(4.5F, 17F, -5F); + Shape17.setTextureSize(64, 32); + Shape17.mirror = true; + setRotation(Shape17, 0F, 0F, 0F); + Shape18 = new ModelRenderer(this, 0, 0); + Shape18.addBox(0F, 0F, 0F, 2, 3, 2); + Shape18.setRotationPoint(-3F, 20F, -2.5F); + Shape18.setTextureSize(64, 32); + Shape18.mirror = true; + setRotation(Shape18, 0F, 0F, 0F); + Shape19 = new ModelRenderer(this, 0, 0); + Shape19.addBox(0F, 0F, 0F, 2, 3, 2); + Shape19.setRotationPoint(-6F, 20F, -2.5F); + Shape19.setTextureSize(64, 32); + Shape19.mirror = true; + setRotation(Shape19, 0F, 0F, 0F); + Shape20 = new ModelRenderer(this, 0, 0); + Shape20.addBox(0F, 0F, 0F, 1, 3, 1); + Shape20.setRotationPoint(-5.5F, 17F, -2F); + Shape20.setTextureSize(64, 32); + Shape20.mirror = true; + setRotation(Shape20, 0F, 0F, 0F); + Shape21 = new ModelRenderer(this, 0, 0); + Shape21.addBox(0F, 0F, 0F, 1, 3, 1); + Shape21.setRotationPoint(-2.5F, 17F, -2F); + Shape21.setTextureSize(64, 32); + Shape21.mirror = true; + setRotation(Shape21, 0F, 0F, 0F); + Shape22 = new ModelRenderer(this, 0, 0); + Shape22.addBox(0F, 0F, 0F, 2, 3, 2); + Shape22.setRotationPoint(0.4666667F, 20F, -2.5F); + Shape22.setTextureSize(64, 32); + Shape22.mirror = true; + setRotation(Shape22, 0F, 0F, 0F); + Shape23 = new ModelRenderer(this, 0, 0); + Shape23.addBox(0F, 0F, 0F, 1, 3, 1); + Shape23.setRotationPoint(1F, 17F, -2F); + Shape23.setTextureSize(64, 32); + Shape23.mirror = true; + setRotation(Shape23, 0F, 0F, 0F); + Shape24 = new ModelRenderer(this, 0, 0); + Shape24.addBox(0F, 0F, 0F, 2, 3, 2); + Shape24.setRotationPoint(4F, 20F, -2.5F); + Shape24.setTextureSize(64, 32); + Shape24.mirror = true; + setRotation(Shape24, 0F, 0F, 0F); + Shape25 = new ModelRenderer(this, 0, 0); + Shape25.addBox(0F, 0F, 0F, 1, 3, 1); + Shape25.setRotationPoint(4.5F, 17F, -2F); + Shape25.setTextureSize(64, 32); + Shape25.mirror = true; + setRotation(Shape25, 0F, 0F, 0F); + Shape26 = new ModelRenderer(this, 0, 0); + Shape26.addBox(0F, 0F, 0F, 2, 3, 2); + Shape26.setRotationPoint(-3F, 20F, 0.5F); + Shape26.setTextureSize(64, 32); + Shape26.mirror = true; + setRotation(Shape26, 0F, 0F, 0F); + Shape27 = new ModelRenderer(this, 0, 0); + Shape27.addBox(0F, 0F, 0F, 2, 3, 2); + Shape27.setRotationPoint(-6F, 20F, 0.5F); + Shape27.setTextureSize(64, 32); + Shape27.mirror = true; + setRotation(Shape27, 0F, 0F, 0F); + Shape28 = new ModelRenderer(this, 0, 0); + Shape28.addBox(0F, 0F, 0F, 1, 3, 1); + Shape28.setRotationPoint(-5.5F, 17F, 1F); + Shape28.setTextureSize(64, 32); + Shape28.mirror = true; + setRotation(Shape28, 0F, 0F, 0F); + Shape29 = new ModelRenderer(this, 0, 0); + Shape29.addBox(0F, 0F, 0F, 1, 3, 1); + Shape29.setRotationPoint(-2.5F, 17F, 1F); + Shape29.setTextureSize(64, 32); + Shape29.mirror = true; + setRotation(Shape29, 0F, 0F, 0F); + Shape30 = new ModelRenderer(this, 0, 0); + Shape30.addBox(0F, 0F, 0F, 2, 3, 2); + Shape30.setRotationPoint(0.4666667F, 20F, 0.5F); + Shape30.setTextureSize(64, 32); + Shape30.mirror = true; + setRotation(Shape30, 0F, 0F, 0F); + Shape31 = new ModelRenderer(this, 0, 0); + Shape31.addBox(0F, 0F, 0F, 1, 3, 1); + Shape31.setRotationPoint(1F, 17F, 1F); + Shape31.setTextureSize(64, 32); + Shape31.mirror = true; + setRotation(Shape31, 0F, 0F, 0F); + Shape32 = new ModelRenderer(this, 0, 0); + Shape32.addBox(0F, 0F, 0F, 2, 3, 2); + Shape32.setRotationPoint(4F, 20F, 0.5F); + Shape32.setTextureSize(64, 32); + Shape32.mirror = true; + setRotation(Shape32, 0F, 0F, 0F); + Shape33 = new ModelRenderer(this, 0, 0); + Shape33.addBox(0F, 0F, 0F, 1, 3, 1); + Shape33.setRotationPoint(4.5F, 17F, 1F); + Shape33.setTextureSize(64, 32); + Shape33.mirror = true; + setRotation(Shape33, 0F, 0F, 0F); + } + + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) + { + super.render(entity, f, f1, f2, f3, f4, f5); + setRotationAngles(f, f1, f2, f3, f4, f5, entity); + Shape1.render(f5); + Shape2.render(f5); + Shape3.render(f5); + Shape4.render(f5); + Shape5.render(f5); + Shape6.render(f5); + Shape7.render(f5); + Shape8.render(f5); + Shape9.render(f5); + Shape10.render(f5); + Shape12.render(f5); + Shape13.render(f5); + Shape11.render(f5); + Shape14.render(f5); + Shape15.render(f5); + Shape16.render(f5); + Shape17.render(f5); + Shape18.render(f5); + Shape19.render(f5); + Shape20.render(f5); + Shape21.render(f5); + Shape22.render(f5); + Shape23.render(f5); + Shape24.render(f5); + Shape25.render(f5); + Shape26.render(f5); + Shape27.render(f5); + Shape28.render(f5); + Shape29.render(f5); + Shape30.render(f5); + Shape31.render(f5); + Shape32.render(f5); + Shape33.render(f5); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + @Override + public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) + { + super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); + } + +} diff --git a/java/fyresmodjam/models/ModelTrap2.java b/java/fyresmodjam/models/ModelTrap2.java new file mode 100644 index 0000000..98a8253 --- /dev/null +++ b/java/fyresmodjam/models/ModelTrap2.java @@ -0,0 +1,84 @@ +// Date: 8/4/2013 9:26:07 AM +// Template version 1.1 +// Java generated by Techne +// Keep in mind that you still need to fill in some blanks +// - ZeuX + +package fyresmodjam.models; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; + +public class ModelTrap2 extends ModelBase +{ + //fields + ModelRenderer Shape1; + ModelRenderer Shape22; + ModelRenderer Shape26; + ModelRenderer Shape30; + ModelRenderer Shape27; + + public ModelTrap2() + { + textureWidth = 64; + textureHeight = 32; + + Shape1 = new ModelRenderer(this, 0, 6); + Shape1.addBox(0F, 0F, 0F, 14, 1, 14); + Shape1.setRotationPoint(-7F, 23F, -7F); + Shape1.setTextureSize(64, 32); + Shape1.mirror = true; + setRotation(Shape1, 0F, 0F, 0F); + Shape22 = new ModelRenderer(this, 0, 0); + Shape22.addBox(0F, 0F, 0F, 3, 2, 1); + Shape22.setRotationPoint(-2.033333F, 21F, -2F); + Shape22.setTextureSize(64, 32); + Shape22.mirror = true; + setRotation(Shape22, 0F, 0F, 0F); + Shape26 = new ModelRenderer(this, 0, 0); + Shape26.addBox(0F, 0F, 0F, 1, 2, 4); + Shape26.setRotationPoint(1F, 21F, -2F); + Shape26.setTextureSize(64, 32); + Shape26.mirror = true; + setRotation(Shape26, 0F, 0F, 0F); + Shape30 = new ModelRenderer(this, 0, 0); + Shape30.addBox(0F, 0F, 0F, 3, 2, 1); + Shape30.setRotationPoint(-2.033333F, 21F, 1F); + Shape30.setTextureSize(64, 32); + Shape30.mirror = true; + setRotation(Shape30, 0F, 0F, 0F); + Shape27 = new ModelRenderer(this, 0, 0); + Shape27.addBox(0F, 0F, 0F, 1, 2, 2); + Shape27.setRotationPoint(-2F, 21F, -1F); + Shape27.setTextureSize(64, 32); + Shape27.mirror = true; + setRotation(Shape27, 0F, 0F, 0F); + } + + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) + { + super.render(entity, f, f1, f2, f3, f4, f5); + setRotationAngles(f, f1, f2, f3, f4, f5, entity); + Shape1.render(f5); + Shape22.render(f5); + Shape26.render(f5); + Shape30.render(f5); + Shape27.render(f5); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + @Override + public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) + { + super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); + } + +} diff --git a/fyresmodjam/tileentities/TileEntityCrystal.java b/java/fyresmodjam/tileentities/TileEntityCrystal.java similarity index 50% rename from fyresmodjam/tileentities/TileEntityCrystal.java rename to java/fyresmodjam/tileentities/TileEntityCrystal.java index f478c96..f76cc02 100644 --- a/fyresmodjam/tileentities/TileEntityCrystal.java +++ b/java/fyresmodjam/tileentities/TileEntityCrystal.java @@ -2,35 +2,40 @@ import java.util.Random; -import fyresmodjam.items.ItemCrystal; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.INetworkManager; -import net.minecraft.network.packet.Packet; -import net.minecraft.network.packet.Packet132TileEntityData; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; +import fyresmodjam.items.ItemCrystal; public class TileEntityCrystal extends TileEntity { public TileEntityCrystal() {} - + public static Random random = new Random(); - + + @Override public void updateEntity() { super.updateEntity(); - + if(random.nextInt(4) == 0) { - this.worldObj.spawnParticle(ItemCrystal.particleNames[this.getBlockMetadata() % ItemCrystal.particleNames.length], this.xCoord + random.nextFloat(), this.yCoord + random.nextFloat(), this.zCoord + random.nextFloat(), 0.0f, 0.0f, 0.0f); + worldObj.spawnParticle(ItemCrystal.particleNames[getBlockMetadata() % ItemCrystal.particleNames.length], xCoord + random.nextFloat(), yCoord + random.nextFloat(), zCoord + random.nextFloat(), 0.0f, 0.0f, 0.0f); } } - + + @Override public void writeToNBT(NBTTagCompound par1NBTTagCompound) {super.writeToNBT(par1NBTTagCompound);} - + + @Override public void readFromNBT(NBTTagCompound par1NBTTagCompound) {super.readFromNBT(par1NBTTagCompound);} - + + @Override public Packet getDescriptionPacket() { NBTTagCompound tag = new NBTTagCompound(); - this.writeToNBT(tag); - return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 1, tag); + writeToNBT(tag); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag); } - - public void onDataPacket(INetworkManager net, Packet132TileEntityData packet) {this.readFromNBT(packet.data);} + + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {readFromNBT(pkt.func_148857_g());} } diff --git a/fyresmodjam/tileentities/TileEntityCrystalStand.java b/java/fyresmodjam/tileentities/TileEntityCrystalStand.java similarity index 55% rename from fyresmodjam/tileentities/TileEntityCrystalStand.java rename to java/fyresmodjam/tileentities/TileEntityCrystalStand.java index 1433fd5..912a927 100644 --- a/fyresmodjam/tileentities/TileEntityCrystalStand.java +++ b/java/fyresmodjam/tileentities/TileEntityCrystalStand.java @@ -1,25 +1,30 @@ package fyresmodjam.tileentities; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.INetworkManager; -import net.minecraft.network.packet.Packet; -import net.minecraft.network.packet.Packet132TileEntityData; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; public class TileEntityCrystalStand extends TileEntity { public TileEntityCrystalStand() {} - + + @Override public void updateEntity() {super.updateEntity();} - + + @Override public void writeToNBT(NBTTagCompound par1NBTTagCompound) {super.writeToNBT(par1NBTTagCompound);} - + + @Override public void readFromNBT(NBTTagCompound par1NBTTagCompound) {super.readFromNBT(par1NBTTagCompound);} - + + @Override public Packet getDescriptionPacket() { NBTTagCompound tag = new NBTTagCompound(); - this.writeToNBT(tag); - return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 1, tag); + writeToNBT(tag); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag); } - - public void onDataPacket(INetworkManager net, Packet132TileEntityData packet) {this.readFromNBT(packet.data);} + + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {readFromNBT(pkt.func_148857_g());} } diff --git a/java/fyresmodjam/tileentities/TileEntityPillar.java b/java/fyresmodjam/tileentities/TileEntityPillar.java new file mode 100644 index 0000000..6c057a7 --- /dev/null +++ b/java/fyresmodjam/tileentities/TileEntityPillar.java @@ -0,0 +1,73 @@ +package fyresmodjam.tileentities; + +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.EnumSkyBlock; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import fyresmodjam.ModjamMod; + +public class TileEntityPillar extends TileEntity { + + public static String[] validBlessings = {"Miner", "Lumberjack", "Warrior", "Hunter", "Swamp", "Thief", "Ninja", "Mechanic", "Alchemist", "Scout", "Guardian", "Vampire", "Inferno", "Diver", "Berserker", "Loner", "Paratrooper", "Porcupine"}; + public static String[] blessingDescriptions = {"+25% breaking speed on stone and iron blocks, and +20% damage with pickaxes", "+25% breaking speed on wooden blocks, and +15% damage with axes", "+20% melee damage", "+20% projectile damage", "Attacks will slow enemies", "Enemies have a chance to drop gold nuggets", "While sneaking you are invisble and attacks on enemies with full health do double damage", "@@\u00A7ePASSIVE - \u00A7oYou disarm traps 3x as often and have 2x the chance to salvage disarmed traps.@@\u00A7eACTIVE - \u00A7oOnce per day, you may disarm and salvage target trap for free", "All potions act like wildcard potions", "You can see traps without sneaking, but take 25% more damage from traps", "Take 20% less damage from all sources", "Heal 7% of damage dealt to enemies and, in direct sunlight, you take 20% more damage and deal 20% less damage", "You don't take fire damage, do +35% damage while on fire, and take damage when wet", "You can breathe underwater", "@@\u00A7ePASSIVE - \u00A7oKills are added to berserk counter. (10 max)@@\u00A7eACTIVE - \u00A7oTurn on/off berserk mode. While berserk mode is active, you do 30% more damage, and berserk counter ticks down every 2 seconds", "The lower your health, the higher your damage, to a maximum of +35%", "You don't take fall damage", "Melee attackers take receive damage"}; + + public String blessing = null; + + public TileEntityPillar() {} + + @Override + public void updateEntity() { + super.updateEntity(); + + if(worldObj.isRemote) { + spawnParticles(); + + if(ModjamMod.pillarGlow) {worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord);} + } + } + + @SideOnly(Side.CLIENT) + public void spawnParticles() { + EntityPlayer player = Minecraft.getMinecraft().thePlayer; + + if(player != null && player.getEntityData().hasKey("Blessing") && player.getEntityData().getString("Blessing").equals(blessing)) { + for(int i = 0; i < 2; i++) {worldObj.spawnParticle("portal", xCoord + ModjamMod.r.nextDouble(), yCoord + ModjamMod.r.nextDouble() * 2, zCoord + ModjamMod.r.nextDouble(), (ModjamMod.r.nextDouble() - 0.5D) * 2.0D, -ModjamMod.r.nextDouble(), (ModjamMod.r.nextDouble() - 0.5D) * 2.0D);} + } + } + + @Override + public void writeToNBT(NBTTagCompound par1NBTTagCompound) { + super.writeToNBT(par1NBTTagCompound); + if(blessing == null) {blessing = validBlessings[ModjamMod.r.nextInt(validBlessings.length)];} + par1NBTTagCompound.setString("Blessing", blessing); + } + + @Override + public void readFromNBT(NBTTagCompound par1NBTTagCompound) { + super.readFromNBT(par1NBTTagCompound); + blessing = par1NBTTagCompound.hasKey("Blessing") ? par1NBTTagCompound.getString("Blessing") : validBlessings[ModjamMod.r.nextInt(validBlessings.length)]; + } + + @Override + public Packet getDescriptionPacket() { + NBTTagCompound tag = new NBTTagCompound(); + writeToNBT(tag); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag); + } + + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {readFromNBT(pkt.func_148857_g());} + + @Override + @SideOnly(Side.CLIENT) + public AxisAlignedBB getRenderBoundingBox() { + return INFINITE_EXTENT_AABB; + } +} \ No newline at end of file diff --git a/java/fyresmodjam/tileentities/TileEntityTrap.java b/java/fyresmodjam/tileentities/TileEntityTrap.java new file mode 100644 index 0000000..d545800 --- /dev/null +++ b/java/fyresmodjam/tileentities/TileEntityTrap.java @@ -0,0 +1,86 @@ +package fyresmodjam.tileentities; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import fyresmodjam.ModjamMod; +import fyresmodjam.handlers.NewPacketHandler; + +public class TileEntityTrap extends TileEntity { + + public static String[] settings = {"invisible to and damages all but player", "visible to all and damages all but player", "visible to all and only damages mobs", "decorative"}; + + public String placedBy = null; + public int setting = 0; + + public TileEntityTrap() {} + + @Override + public void updateEntity() { + super.updateEntity(); + + if(worldObj.isRemote) {spawnParticles();} + } + + @Override + public void writeToNBT(NBTTagCompound par1NBTTagCompound) { + super.writeToNBT(par1NBTTagCompound); + + if(placedBy != null) {par1NBTTagCompound.setString("PlacedBy", placedBy);} + par1NBTTagCompound.setInteger("Setting", setting % settings.length); + } + + @Override + public void readFromNBT(NBTTagCompound par1NBTTagCompound) { + super.readFromNBT(par1NBTTagCompound); + + if(par1NBTTagCompound.hasKey("PlacedBy")) {placedBy = par1NBTTagCompound.getString("PlacedBy");} else {placedBy = null;} + if(par1NBTTagCompound.hasKey("Setting")) {setting = par1NBTTagCompound.getInteger("Setting") % settings.length;} + } + + @Override + public Packet getDescriptionPacket() { + NBTTagCompound tag = new NBTTagCompound(); + writeToNBT(tag); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag); + } + + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {readFromNBT(pkt.func_148857_g());} + + @Override + @SideOnly(Side.CLIENT) + public AxisAlignedBB getRenderBoundingBox() { + return INFINITE_EXTENT_AABB; + } + + @Override + @SideOnly(Side.CLIENT) + public double getMaxRenderDistanceSquared() { + EntityPlayer player = Minecraft.getMinecraft().thePlayer; + return (player != null && (player.getCommandSenderName().equals(placedBy) || setting != 0)) ? 4096.0F: 36.0F; + } + + @SideOnly(Side.CLIENT) + public void spawnParticles() { + EntityPlayer player = Minecraft.getMinecraft().thePlayer; + int type = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); + + if(player != null && (!NewPacketHandler.trapsDisabled || placedBy != null) && (player.getCommandSenderName().equals(placedBy) || player.isSneaking() || setting != 0 || (player.getEntityData().hasKey("Blessing") && player.getEntityData().getString("Blessing").equals("Scout"))) && getDistanceFrom(TileEntityRendererDispatcher.staticPlayerX, TileEntityRendererDispatcher.staticPlayerY, TileEntityRendererDispatcher.staticPlayerZ) < (player.getCommandSenderName().equals(placedBy) ? 4096 : 36.0F)) { + if(type == 1) { + if(ModjamMod.r.nextInt(5) == 0) {worldObj.spawnParticle("smoke", xCoord + 0.5F, yCoord + 0.175F, zCoord + 0.5F, (ModjamMod.r.nextFloat() - 0.5F)/16, ModjamMod.r.nextFloat()/16, (ModjamMod.r.nextFloat() - 0.5F)/16);} + worldObj.spawnParticle("flame", xCoord + 0.5F, yCoord + 0.175F, zCoord + 0.5F, 0.0F, 0.0F, 0.0F); + } else if(type == 2) { + for(int i = 0; i < 3; i++) {worldObj.spawnParticle("smoke", xCoord + 0.5F, yCoord + 0.175F, zCoord + 0.5F, (ModjamMod.r.nextFloat() - 0.5F)/16, ModjamMod.r.nextFloat()/16, (ModjamMod.r.nextFloat() - 0.5F)/16);} + } + } + } +} \ No newline at end of file diff --git a/fyresmodjam/tileentities/renderers/TileEntityCrystalRenderer.java b/java/fyresmodjam/tileentities/renderers/TileEntityCrystalRenderer.java similarity index 78% rename from fyresmodjam/tileentities/renderers/TileEntityCrystalRenderer.java rename to java/fyresmodjam/tileentities/renderers/TileEntityCrystalRenderer.java index 721621e..353c170 100644 --- a/fyresmodjam/tileentities/renderers/TileEntityCrystalRenderer.java +++ b/java/fyresmodjam/tileentities/renderers/TileEntityCrystalRenderer.java @@ -2,12 +2,6 @@ import java.awt.Color; -import org.lwjgl.opengl.GL11; - -import fyresmodjam.ModjamMod; -import fyresmodjam.items.ItemCrystal; -import fyresmodjam.models.ModelCrystal; -import fyresmodjam.tileentities.TileEntityCrystal; import net.minecraft.block.Block; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.Tessellator; @@ -16,40 +10,47 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; +import org.lwjgl.opengl.GL11; + +import fyresmodjam.ModjamMod; +import fyresmodjam.items.ItemCrystal; +import fyresmodjam.models.ModelCrystal; +import fyresmodjam.tileentities.TileEntityCrystal; + public class TileEntityCrystalRenderer extends TileEntitySpecialRenderer { - + private ModelCrystal modelCrystal = new ModelCrystal(); - + public static ResourceLocation texture = new ResourceLocation("fyresmodjam", "textures/blocks/crystal.png"); @Override public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { GL11.glPushMatrix(); GL11.glTranslatef((float) d0, (float) d1, (float) d2); - + TileEntityCrystal crystal = (TileEntityCrystal) tileentity; Block block = ModjamMod.crystal; - World world = crystal.worldObj; - + World world = crystal.getWorldObj(); + Tessellator tessellator = Tessellator.instance; - float f2 = block.getBlockBrightness(world, crystal.xCoord, crystal.yCoord, crystal.zCoord); + float f2 = block.getMixedBrightnessForBlock(world, crystal.xCoord, crystal.yCoord, crystal.zCoord); int l = world.getLightBrightnessForSkyBlocks(crystal.xCoord, crystal.yCoord, crystal.zCoord, 0); int l1 = l % 65536; int l2 = l / 65536; tessellator.setColorOpaque_F(f2, f2, f2); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) l1, (float) l2); - - float f3 = (float) (world.getWorldInfo().getWorldTime() % 20) / 20.0F; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, l1, l2); + + float f3 = world.getWorldInfo().getWorldTime() % 20 / 20.0F; GL11.glTranslatef(0.5F, -0.4F + (f3 > 0.5F ? 0.25F - 0.25F * f3 : 0.25F * f3), 0.5F); - + GL11.glRotatef((float) world.getWorldInfo().getWorldTime() % 360, 0.0F, 1.0F, 0.0F); - + Color color = ItemCrystal.colors[crystal.getBlockMetadata() % ItemCrystal.colors.length]; - GL11.glColor3f((float) color.getRed() / 255.0F, (float) color.getGreen() / 255.0F, (float) color.getBlue() / 255.0F); - - this.tileEntityRenderer.renderEngine.bindTexture(texture); + GL11.glColor3f(color.getRed() / 255.0F, color.getGreen() / 255.0F, color.getBlue() / 255.0F); + + bindTexture(texture); modelCrystal.render(null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F); - + GL11.glPopMatrix(); } diff --git a/fyresmodjam/tileentities/renderers/TileEntityCrystalStandRenderer.java b/java/fyresmodjam/tileentities/renderers/TileEntityCrystalStandRenderer.java similarity index 79% rename from fyresmodjam/tileentities/renderers/TileEntityCrystalStandRenderer.java rename to java/fyresmodjam/tileentities/renderers/TileEntityCrystalStandRenderer.java index b1a4887..5aa3b9a 100644 --- a/fyresmodjam/tileentities/renderers/TileEntityCrystalStandRenderer.java +++ b/java/fyresmodjam/tileentities/renderers/TileEntityCrystalStandRenderer.java @@ -1,14 +1,5 @@ package fyresmodjam.tileentities.renderers; -import java.awt.Color; - -import org.lwjgl.opengl.GL11; - -import fyresmodjam.ModjamMod; -import fyresmodjam.items.ItemCrystal; -import fyresmodjam.models.ModelCrystalStand; -import fyresmodjam.tileentities.TileEntityCrystal; -import fyresmodjam.tileentities.TileEntityCrystalStand; import net.minecraft.block.Block; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.Tessellator; @@ -17,35 +8,41 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; +import org.lwjgl.opengl.GL11; + +import fyresmodjam.ModjamMod; +import fyresmodjam.models.ModelCrystalStand; +import fyresmodjam.tileentities.TileEntityCrystalStand; + public class TileEntityCrystalStandRenderer extends TileEntitySpecialRenderer { - + private ModelCrystalStand model = new ModelCrystalStand(); - + public static ResourceLocation texture = new ResourceLocation("fyresmodjam", "textures/blocks/crystal_stand.png"); @Override public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { GL11.glPushMatrix(); GL11.glTranslatef((float) d0, (float) d1, (float) d2); - + TileEntityCrystalStand crystalStand = (TileEntityCrystalStand) tileentity; Block block = ModjamMod.crystalStand; - World world = crystalStand.worldObj; - + World world = crystalStand.getWorldObj(); + Tessellator tessellator = Tessellator.instance; - float f2 = block.getBlockBrightness(world, crystalStand.xCoord, crystalStand.yCoord, crystalStand.zCoord); + float f2 = block.getMixedBrightnessForBlock(world, crystalStand.xCoord, crystalStand.yCoord, crystalStand.zCoord); int l = world.getLightBrightnessForSkyBlocks(crystalStand.xCoord, crystalStand.yCoord, crystalStand.zCoord, 0); int l1 = l % 65536; int l2 = l / 65536; tessellator.setColorOpaque_F(f2, f2, f2); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) l1, (float) l2); - + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, l1, l2); + GL11.glTranslatef(0.5F, 1.5F, 0.5F); GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F); - - this.tileEntityRenderer.renderEngine.bindTexture(texture); + + bindTexture(texture); model.render(null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F); - + GL11.glPopMatrix(); } diff --git a/java/fyresmodjam/tileentities/renderers/TileEntityPillarRenderer.java b/java/fyresmodjam/tileentities/renderers/TileEntityPillarRenderer.java new file mode 100644 index 0000000..537e16b --- /dev/null +++ b/java/fyresmodjam/tileentities/renderers/TileEntityPillarRenderer.java @@ -0,0 +1,62 @@ +package fyresmodjam.tileentities.renderers; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; + +import org.lwjgl.opengl.GL11; + +import fyresmodjam.ModjamMod; +import fyresmodjam.models.ModelPillar; +import fyresmodjam.tileentities.TileEntityPillar; + + +public class TileEntityPillarRenderer extends TileEntitySpecialRenderer +{ + private ModelPillar modelPillar = new ModelPillar(); + + public static ResourceLocation[] textures = { + new ResourceLocation("fyresmodjam", "textures/blocks/pillar.png"), + new ResourceLocation("fyresmodjam", "textures/blocks/pillarActive.png") + }; + + @Override + public void renderTileEntityAt(TileEntity tileEntity, double d, double d1, double d2, float f) + { + GL11.glPushMatrix(); + GL11.glTranslatef((float)d, (float)d1, (float)d2); + TileEntityPillar tileEntityYour = (TileEntityPillar) tileEntity; + renderBlockYour(tileEntityYour, tileEntity.getWorldObj(), tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, ModjamMod.blockPillar); + GL11.glPopMatrix(); + } + + public void renderBlockYour(TileEntityPillar tl, World world, int i, int j, int k, Block block) + { + Tessellator tessellator = Tessellator.instance; + float f = block.getMixedBrightnessForBlock(world, i, j, k); + int l = world.getLightBrightnessForSkyBlocks(i, j, k, 0); + int l1 = l % 65536; + int l2 = l / 65536; + tessellator.setColorOpaque_F(f, f, f); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, l1, l2); + + EntityPlayer player = Minecraft.getMinecraft().thePlayer; + boolean active = player != null && player.getEntityData().hasKey("Blessing") && player.getEntityData().getString("Blessing").equals(tl.blessing); + + GL11.glPushMatrix(); + + GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F); + GL11.glTranslatef(0.5F, -1.5F, -0.5F); + + bindTexture(!active ? textures[0] : textures[1]); + modelPillar.render((Entity) null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F); + GL11.glPopMatrix(); + } +} \ No newline at end of file diff --git a/java/fyresmodjam/tileentities/renderers/TileEntityTrapRenderer.java b/java/fyresmodjam/tileentities/renderers/TileEntityTrapRenderer.java new file mode 100644 index 0000000..1c3856c --- /dev/null +++ b/java/fyresmodjam/tileentities/renderers/TileEntityTrapRenderer.java @@ -0,0 +1,66 @@ +package fyresmodjam.tileentities.renderers; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; + +import org.lwjgl.opengl.GL11; + +import fyresmodjam.ModjamMod; +import fyresmodjam.blocks.BlockTrap; +import fyresmodjam.handlers.NewPacketHandler; +import fyresmodjam.models.ModelSpikes; +import fyresmodjam.models.ModelTrap2; +import fyresmodjam.tileentities.TileEntityTrap; + +public class TileEntityTrapRenderer extends TileEntitySpecialRenderer { + + private ModelBase[] models = {new ModelSpikes(), new ModelTrap2(), new ModelTrap2()}; + + public static ResourceLocation[] textures = {new ResourceLocation("fyresmodjam", "textures/blocks/spikes.png"), new ResourceLocation("fyresmodjam", "textures/blocks/trap2.png"), new ResourceLocation("fyresmodjam", "textures/blocks/trap3.png")}; + + @Override + public void renderTileEntityAt(TileEntity tileEntity, double d, double d1, double d2, float f) + { + GL11.glPushMatrix(); + GL11.glTranslatef((float)d, (float)d1, (float)d2); + TileEntityTrap tileEntityYour = (TileEntityTrap) tileEntity; + renderBlockYour(tileEntityYour, tileEntity.getWorldObj(), tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, ModjamMod.blockTrap); + GL11.glPopMatrix(); + } + + public void renderBlockYour(TileEntityTrap tl, World world, int i, int j, int k, Block block) { + Tessellator tessellator = Tessellator.instance; + float f = block.getMixedBrightnessForBlock(world, i, j, k); + int l = world.getLightBrightnessForSkyBlocks(i, j, k, 0); + int l1 = l % 65536; + int l2 = l / 65536; + tessellator.setColorOpaque_F(f, f, f); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, l1, l2); + + EntityPlayer player = Minecraft.getMinecraft().thePlayer; + boolean active = player != null && (!NewPacketHandler.trapsDisabled || tl.placedBy != null) && (player.getCommandSenderName().equals(tl.placedBy) || tl.setting != 0 || player.isSneaking() || (player.getEntityData().hasKey("Blessing") && player.getEntityData().getString("Blessing").equals("Scout"))); + + int type = world.getBlockMetadata(i, j, k); + + if(active) { + GL11.glPushMatrix(); + + GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F); + GL11.glTranslatef(0.5F, -1.5F, -0.5F); + + bindTexture(textures[type % BlockTrap.trapTypes]); + models[type % BlockTrap.trapTypes].render((Entity) null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F); + + GL11.glPopMatrix(); + } + } +} \ No newline at end of file diff --git a/fyresmodjam/worldgen/FyresWorldData.java b/java/fyresmodjam/worldgen/FyresWorldData.java similarity index 70% rename from fyresmodjam/worldgen/FyresWorldData.java rename to java/fyresmodjam/worldgen/FyresWorldData.java index ab0f024..43ac72c 100644 --- a/fyresmodjam/worldgen/FyresWorldData.java +++ b/java/fyresmodjam/worldgen/FyresWorldData.java @@ -3,65 +3,61 @@ import java.awt.Color; import java.util.HashMap; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.registry.GameRegistry; -import fyresmodjam.ModjamMod; -import net.minecraft.block.Block; -import net.minecraft.entity.Entity; import net.minecraft.entity.boss.EntityDragon; import net.minecraft.entity.boss.EntityWither; import net.minecraft.entity.monster.EntityGhast; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; import net.minecraft.server.MinecraftServer; import net.minecraft.world.World; import net.minecraft.world.WorldSavedData; -import net.minecraft.world.WorldServer; import net.minecraft.world.storage.MapStorage; +import cpw.mods.fml.common.FMLCommonHandler; +import fyresmodjam.ModjamMod; public class FyresWorldData extends WorldSavedData { - public static String[] validDisadvantages = {/*"Illiterate",*/ "Tougher Mobs", "Weak", "Explosive Traps", "Increased Mob Spawn", "Neverending Rain", "Neverending Night", "Permadeath"}; - public static String[] disadvantageDescriptions = {/*"Item names are unreadable",*/ "Hostile enemies takes 25% less damage", "-25% melee damage", "Traps also trigger explosions when set off", "+33% hostile mob spawn rate", "Constantly rains", "Constant night", "Items dropped upon death are permanently lost"}; - + public static String[] validDisadvantages = {"Tougher Mobs", "Weak", "Explosive Traps", "Increased Mob Spawn", "Neverending Rain", "Neverending Night", "Permadeath"}; + public static String[] disadvantageDescriptions = {"Hostile enemies takes 25% less damage", "-25% melee damage", "Traps also trigger explosions when set off", "+33% hostile mob spawn rate", "Constantly rains", "Constant night", "Items dropped upon death are permanently lost"}; + public static String[] validTasks = {"Kill", "Burn"}; - + public static String key = "FyresWorldData"; - + public int[] potionValues = null; public int[] potionDurations = null; - - //public int[] mushroomValues = null; + public int[][] mushroomColors = null; - + public String currentDisadvantage = null; - + public String currentTask = null; public int currentTaskID = -1; public int currentTaskAmount = 0; public int progress = 0; public int tasksCompleted = 0; public int rewardLevels = -1; - + public boolean enderDragonKilled = false; - + + @SuppressWarnings("rawtypes") public static Class[] validMobs = {EntityDragon.class, EntityGhast.class, EntityWither.class}; + public static String[] validMobNames = {"Ender Dragon", "Ghast", "Wither"}; public static int[][] mobNumbers = {new int[] {1, 1}, new int[] {5, 15} , new int[] {1, 1}}; - + public HashMap blessingByPlayer = new HashMap(); public HashMap potionKnowledgeByPlayer = new HashMap(); - + public HashMap killStatsByPlayer = new HashMap(); public HashMap weaponStatsByPlayer = new HashMap(); public HashMap craftingStatsByPlayer = new HashMap(); - - public static int[] validItems = {Block.blockDiamond.blockID, Block.blockGold.blockID, Block.blockEmerald.blockID, Block.blockLapis.blockID, Item.diamond.itemID, Item.emerald.itemID, Item.ingotGold.itemID, Item.netherStar.itemID, Item.ghastTear.itemID}; + + public static ItemStack[] validItems = {new ItemStack(Blocks.diamond_block), new ItemStack(Blocks.gold_block), new ItemStack(Blocks.emerald_block), new ItemStack(Blocks.lapis_block), new ItemStack(Items.diamond), new ItemStack(Items.emerald), new ItemStack(Items.gold_ingot), new ItemStack(Items.nether_star), new ItemStack(Items.ghast_tear)}; public FyresWorldData() { super(key); @@ -72,13 +68,13 @@ public FyresWorldData(String key) { } public static FyresWorldData forWorld(World world) { - + MapStorage storage = world.perWorldStorage; FyresWorldData result = (FyresWorldData) storage.loadData(FyresWorldData.class, key); - + if(result == null) {result = new FyresWorldData(); storage.setData(key, result); result.checkWorldData();} - - return result; + + return result; } @Override @@ -86,107 +82,100 @@ public void readFromNBT(NBTTagCompound nbttagcompound) { if(nbttagcompound.hasKey("values")) {potionValues = nbttagcompound.getIntArray("values");} if(nbttagcompound.hasKey("durations")) {potionDurations = nbttagcompound.getIntArray("durations");} if(nbttagcompound.hasKey("currentDisadvantage")) {currentDisadvantage = nbttagcompound.getString("currentDisadvantage");} - + if(nbttagcompound.hasKey("currentTask")) {currentTask = nbttagcompound.getString("currentTask");} if(nbttagcompound.hasKey("currentTaskID")) {currentTaskID = nbttagcompound.getInteger("currentTaskID");} if(nbttagcompound.hasKey("currentTaskAmount")) {currentTaskAmount = nbttagcompound.getInteger("currentTaskAmount");} if(nbttagcompound.hasKey("progress")) {progress = nbttagcompound.getInteger("progress");} if(nbttagcompound.hasKey("tasksCompleted")) {tasksCompleted = nbttagcompound.getInteger("tasksCompleted");} - + if(nbttagcompound.hasKey("enderDragonKilled")) {enderDragonKilled = nbttagcompound.getBoolean("enderDragonKilled");} - + if(nbttagcompound.hasKey("rewardLevels")) {rewardLevels = nbttagcompound.getInteger("rewardLevels");} - + mushroomColors = new int[13][]; for(int i = 0; i < 13; i++) { if(nbttagcompound.hasKey("mushroomColors_" + (i + 1))) {mushroomColors[i] = nbttagcompound.getIntArray("mushroomColors_" + (i + 1));} } - + if(nbttagcompound.hasKey("TempPlayerStats")) { NBTTagCompound tempStats = nbttagcompound.getCompoundTag("TempPlayerStats"); - - for(Object o : tempStats.getTags()) { + + for(Object o : tempStats.func_150296_c()) { if(o == null || !(o instanceof NBTTagCompound)) {continue;} NBTTagCompound player = (NBTTagCompound) o; - - blessingByPlayer.put(player.getName(), player.getString("Blessing")); - potionKnowledgeByPlayer.put(player.getName(), player.getIntArray("PotionKnowledge")); - if(player.hasKey("KillStats")) {killStatsByPlayer.put(player.getName(), player.getCompoundTag("KillStats"));} - if(player.hasKey("WeaponStats")) {weaponStatsByPlayer.put(player.getName(), player.getCompoundTag("WeaponStats"));} - if(player.hasKey("CraftingStats")) {craftingStatsByPlayer.put(player.getName(), player.getCompoundTag("CraftingStats"));} + + blessingByPlayer.put(player.getString("Name"), player.getString("Blessing")); + potionKnowledgeByPlayer.put(player.getString("Name"), player.getIntArray("PotionKnowledge")); + if(player.hasKey("KillStats")) {killStatsByPlayer.put(player.getString("Name"), player.getCompoundTag("KillStats"));} + if(player.hasKey("WeaponStats")) {weaponStatsByPlayer.put(player.getString("Name"), player.getCompoundTag("WeaponStats"));} + if(player.hasKey("CraftingStats")) {craftingStatsByPlayer.put(player.getString("Name"), player.getCompoundTag("CraftingStats"));} } } - + checkWorldData(); - - /*for(int i = 0; i < 13; i++) { - GameRegistry.addShapelessRecipe(output, params); - }*/ - } + } @Override public void writeToNBT(NBTTagCompound nbttagcompound) { checkWorldData(); - + nbttagcompound.setIntArray("values", potionValues); nbttagcompound.setIntArray("durations", potionDurations); nbttagcompound.setString("currentDisadvantage", currentDisadvantage); - + nbttagcompound.setString("currentTask", currentTask); nbttagcompound.setInteger("currentTaskID", currentTaskID); nbttagcompound.setInteger("currentTaskAmount", currentTaskAmount); nbttagcompound.setInteger("progress", progress); nbttagcompound.setInteger("tasksCompleted", tasksCompleted); - + nbttagcompound.setBoolean("enderDragonKilled", enderDragonKilled); - + nbttagcompound.setInteger("rewardLevels", rewardLevels); - + for(int i = 0; i < 13; i++) {nbttagcompound.setIntArray("mushroomColors_" + (i + 1), mushroomColors[i]);} - + if(!blessingByPlayer.isEmpty()) { NBTTagCompound tempPlayerStats = new NBTTagCompound(); - + for(String s : blessingByPlayer.keySet()) { if(s == null) {continue;} - + NBTTagCompound player = new NBTTagCompound(); - + + player.setString("Name", s); player.setString("Blessing", blessingByPlayer.get(s)); player.setIntArray("PotionKnowledge", potionKnowledgeByPlayer.get(s)); - if(killStatsByPlayer.containsKey(s)) {player.setCompoundTag("KillStats", killStatsByPlayer.get(s));} - if(weaponStatsByPlayer.containsKey(s)) {player.setCompoundTag("WeaponStats", weaponStatsByPlayer.get(s));} - if(craftingStatsByPlayer.containsKey(s)) {player.setCompoundTag("CraftingStats", craftingStatsByPlayer.get(s));} - + if(killStatsByPlayer.containsKey(s)) {player.setTag("KillStats", killStatsByPlayer.get(s));} + if(weaponStatsByPlayer.containsKey(s)) {player.setTag("WeaponStats", weaponStatsByPlayer.get(s));} + if(craftingStatsByPlayer.containsKey(s)) {player.setTag("CraftingStats", craftingStatsByPlayer.get(s));} + tempPlayerStats.setTag(s, player); } - - nbttagcompound.setCompoundTag("TempPlayerStats", tempPlayerStats); + + nbttagcompound.setTag("TempPlayerStats", tempPlayerStats); } } - + private void checkWorldData() { if(potionValues == null) { potionValues = new int[] {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; - + for(int i = 0; i < 12; i++) { int i2 = ModjamMod.r.nextInt(Potion.potionTypes.length); - + boolean stop = false; while(Potion.potionTypes[i2] == null || !stop) { stop = true; i2 = ModjamMod.r.nextInt(Potion.potionTypes.length); - + for(int i3 = 0; i3 < 12; i3++) { if(potionValues[i3] == i2) {stop = false; break;} } } - - //boolean skip = false; - //for(int i3 = 0; i3 < potionValues.length; i3++) {if(potionValues[i] == i3) {skip = true; break;}} - //if(skip) {continue;} - - potionValues[i] = i2;// break; + + potionValues[i] = i2; } } else { for(int i = 0; i < 12; i++) { @@ -197,53 +186,34 @@ private void checkWorldData() { } } } - + if(potionDurations == null) {potionDurations = new int[12];} for(int i = 0; i < 12; i++) {if(potionDurations[i] != 0) {continue;} potionDurations[i] = 5 + ModjamMod.r.nextInt(26);} - - /*if(mushroomValues == null) { - mushroomValues = new int[13]; - - for(int i = 0; i < 13; i++) {} - }*/ - + if(mushroomColors == null) { mushroomColors = new int[13][2]; - + for(int i = 0; i < 13; i++) { mushroomColors[i][0] = Color.HSBtoRGB(ModjamMod.r.nextFloat(), ModjamMod.r.nextFloat(), ModjamMod.r.nextFloat()); mushroomColors[i][1] = Color.HSBtoRGB(ModjamMod.r.nextFloat(), ModjamMod.r.nextFloat(), ModjamMod.r.nextFloat()); } } - + boolean changeDisadvantage = currentDisadvantage == null; - + if(!changeDisadvantage) { boolean valid = false; for(String s : validDisadvantages) {if(s.equals(currentDisadvantage)) {valid = true; break;}} changeDisadvantage = !valid && !currentDisadvantage.equals("None"); } - + if(changeDisadvantage) { currentDisadvantage = validDisadvantages[ModjamMod.r.nextInt(validDisadvantages.length)]; - + MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); while(server != null && server.isHardcore() && currentDisadvantage.equals("Permadeath")) {currentDisadvantage = validDisadvantages[ModjamMod.r.nextInt(validDisadvantages.length)];} - - /*MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); - - for(int i = 0; i < server.worldServers.length; i++) { - WorldServer s = FMLCommonHandler.instance().getMinecraftServerInstance().worldServers[i]; - - if(s == null) {continue;} - - for(Object o : s.loadedEntityList) { - if(o == null || o instanceof EntityPlayer) {continue;} - EntityStatHelper.processEntity((Entity) o, ModjamMod.r); - } - }*/ } - + if(currentTask == null) { giveNewTask(); } else { @@ -251,32 +221,32 @@ private void checkWorldData() { for(String s : validTasks) {if(s.equals(currentTask)) {changeTask = false; break;}} if(changeTask || (currentTask != null && currentTask.equals("Kill") && currentTaskID == 0 && enderDragonKilled)) {giveNewTask();} else {if(currentTask.equals("Kill")) {currentTaskID %= validMobs.length;}} } - + if(rewardLevels == -1) {rewardLevels = 5 + ModjamMod.r.nextInt(6);} } public void giveNewTask() { progress = 0; - + currentTask = validTasks[ModjamMod.r.nextInt(validTasks.length)]; - + if(currentTask.equals("Kill")) { currentTaskID = !enderDragonKilled ? ModjamMod.r.nextInt(validMobs.length) : 1 + ModjamMod.r.nextInt(validMobs.length - 1); currentTaskAmount = mobNumbers[currentTaskID][0] + ModjamMod.r.nextInt(mobNumbers[currentTaskID][1]); } else if(currentTask.equals("Burn")) { - currentTaskID = validItems[ModjamMod.r.nextInt(validItems.length)]; - - if(currentTaskID == Item.netherStar.itemID) {currentTaskAmount = 1;} + currentTaskID = ModjamMod.r.nextInt(validItems.length); + + if(validItems[currentTaskID].getItem() == Items.nether_star) {currentTaskAmount = 1;} else {currentTaskAmount = 5 + ModjamMod.r.nextInt(28);} - - if(Item.itemsList[currentTaskID] instanceof ItemBlock) {currentTaskAmount /= 4;} + + if(validItems[currentTaskID].getItem() instanceof ItemBlock) {currentTaskAmount /= 4;} } - + rewardLevels = 5 + ModjamMod.r.nextInt(6); - + markDirty(); } - + public String getDisadvantage() { return ModjamMod.disableDisadvantages ? "None" : currentDisadvantage; } diff --git a/java/fyresmodjam/worldgen/PillarGen.java b/java/fyresmodjam/worldgen/PillarGen.java new file mode 100644 index 0000000..ce44a8b --- /dev/null +++ b/java/fyresmodjam/worldgen/PillarGen.java @@ -0,0 +1,44 @@ +package fyresmodjam.worldgen; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkProvider; +import cpw.mods.fml.common.IWorldGenerator; +import fyresmodjam.ModjamMod; + +public class PillarGen implements IWorldGenerator { + @Override + public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { + if(ModjamMod.spawnRandomPillars && world.provider.dimensionId == 0 && random.nextInt(ModjamMod.pillarGenChance) == 0) { + boolean placed = false; + + int max = random.nextInt(ModjamMod.maxPillarsPerChunk) + 1; + + for(int y = 127, added = 0; y > 30 && !placed && added < max; y--) { + for(int x = chunkX * 16; x < chunkX * 16 + 16 && !placed && added < max; x++) { + for(int z = chunkZ * 16; z < chunkZ * 16 + 16 && !placed && added < max; z++) { + if(random.nextInt(15) != 0 || world.isAirBlock(x, y, z) || world.getBlock(x, y, z).isReplaceable(world, x, y, z) || world.getBlock(x, y, z) == ModjamMod.blockTrap || world.getBlock(x, y, z) == Blocks.leaves) {continue;} + + Block block = ModjamMod.blockPillar; + + if(block.canPlaceBlockAt(world, x, y + 1, z)) { + world.setBlock(x, y + 1, z, block); + world.setBlockMetadataWithNotify(x, y + 1, z, 0, 0); + + world.setBlock(x, y + 2, z, block); + world.setBlockMetadataWithNotify(x, y + 2, z, 1, 0); + + placed = random.nextBoolean(); + + y -= 10; + added++; + } + } + } + } + } + } +} diff --git a/fyresmodjam/worldgen/WorldGenMoreDungeons.java b/java/fyresmodjam/worldgen/WorldGenMoreDungeons.java similarity index 67% rename from fyresmodjam/worldgen/WorldGenMoreDungeons.java rename to java/fyresmodjam/worldgen/WorldGenMoreDungeons.java index c9a7c81..0a3542c 100644 --- a/fyresmodjam/worldgen/WorldGenMoreDungeons.java +++ b/java/fyresmodjam/worldgen/WorldGenMoreDungeons.java @@ -2,21 +2,21 @@ import java.util.Random; -import cpw.mods.fml.common.IWorldGenerator; import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.feature.WorldGenDungeons; +import cpw.mods.fml.common.IWorldGenerator; public class WorldGenMoreDungeons extends WorldGenDungeons implements IWorldGenerator { @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { for(int k1 = 0; k1 < 24; ++k1) { - int l1 = chunkX * 16 + random.nextInt(16) + 8; - int i2 = random.nextInt(128); - int j2 = chunkZ * 16 + random.nextInt(16) + 8; - super.generate(world, random, l1, i2, j2); - } + int l1 = chunkX * 16 + random.nextInt(16) + 8; + int i2 = random.nextInt(128); + int j2 = chunkZ * 16 + random.nextInt(16) + 8; + super.generate(world, random, l1, i2, j2); + } } } diff --git a/java/fyresmodjam/worldgen/WorldGenTrapsTowersAndMore.java b/java/fyresmodjam/worldgen/WorldGenTrapsTowersAndMore.java new file mode 100644 index 0000000..201deca --- /dev/null +++ b/java/fyresmodjam/worldgen/WorldGenTrapsTowersAndMore.java @@ -0,0 +1,153 @@ +package fyresmodjam.worldgen; + +import java.util.Random; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.tileentity.TileEntityChest; +import net.minecraft.tileentity.TileEntityMobSpawner; +import net.minecraft.util.WeightedRandomChestContent; +import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkProvider; +import net.minecraftforge.common.ChestGenHooks; +import net.minecraftforge.common.DungeonHooks; +import cpw.mods.fml.common.IWorldGenerator; +import fyresmodjam.ModjamMod; +import fyresmodjam.blocks.BlockTrap; + +public class WorldGenTrapsTowersAndMore implements IWorldGenerator { + + public static final WeightedRandomChestContent[] field_111189_a = new WeightedRandomChestContent[] { + new WeightedRandomChestContent(Items.iron_ingot, 0, 1, 4, 10), + new WeightedRandomChestContent(Items.bread, 0, 1, 1, 10), + new WeightedRandomChestContent(Items.wheat, 0, 1, 4, 10), + new WeightedRandomChestContent(Items.gunpowder, 0, 1, 4, 10), + new WeightedRandomChestContent(Items.string, 0, 1, 4, 10), + new WeightedRandomChestContent(Items.bucket, 0, 1, 1, 10), + new WeightedRandomChestContent(Items.redstone, 0, 1, 4, 10), + new WeightedRandomChestContent(Items.name_tag, 0, 1, 1, 10), + }; + + public static boolean genning = false; + + public static final String TOWER_CHESTS = "towerChests"; + + public static ChestGenHooks chestGenInfo = new ChestGenHooks(TOWER_CHESTS, field_111189_a, 8, 8); + + @Override + public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { + + genning = true; + + boolean addedDungeon = !ModjamMod.spawnTowers || random.nextInt(ModjamMod.towerGenChance) != 0; + + for(int y = 1; y < 127; y++) { + for(int x = chunkX * 16; x < chunkX * 16 + 16; x++) { + for(int z = chunkZ * 16; z < chunkZ * 16 + 16; z++) { + if((world.isAirBlock(x, y, z) || (world.getBlock(x, y, z).isReplaceable(world, x, y, z) && world.getBlock(x, y, z) != Blocks.water && world.getBlock(x, y, z) != Blocks.flowing_water && world.getBlock(x, y, z) != Blocks.lava && world.getBlock(x, y, z) != Blocks.flowing_lava)) && (!world.isAirBlock(x, y - 1, z) && world.getBlock(x, y - 1, z) != ModjamMod.blockTrap && !world.getBlock(x, y - 1, z).isReplaceable(world, x, y - 1, z)) && random.nextInt(ModjamMod.trapGenChance) == 0) { + boolean skip = ModjamMod.trapsBelowGroundOnly && (world.getBlock(x, y - 1, z) == Blocks.grass || world.getBlock(x, y - 1, z) == Blocks.sand || world.getBlock(x, y - 1, z) == Blocks.log || world.getBlock(x, y - 1, z) == Blocks.log2 || world.canBlockSeeTheSky(x, y, z)); + if(!skip && ModjamMod.blockTrap.canPlaceBlockAt(world, x, y, z)) {world.setBlock(x, y, z, ModjamMod.blockTrap, random.nextInt(BlockTrap.trapTypes), 0);} + } + + if((world.getBlock(x, y, z) == Blocks.brown_mushroom || world.getBlock(x, y, z) == Blocks.red_mushroom) && random.nextInt(ModjamMod.mushroomReplaceChance) == 0) { + world.setBlock(x, y, z, ModjamMod.mysteryMushroomBlock, random.nextInt(13), 0); + } + + if(!addedDungeon && ((world.getBlock(x, y, z) == Blocks.grass || ((world.getBlock(x, y, z) == Blocks.sand || world.getBlock(x, y, z) == Blocks.netherrack || world.getBlock(x, y, z) == Blocks.soul_sand || world.getBlock(x, y, z) == Blocks.gravel) && world.isAirBlock(x, y + 1, z)))) && world.getBlock(x, y + 1, z) != Blocks.water && world.getBlock(x, y + 1, z) != Blocks.flowing_water && world.getBlock(x, y + 1, z) != Blocks.lava && world.getBlock(x, y + 1, z) != Blocks.flowing_lava && ModjamMod.r.nextInt(100) == 0) { + + boolean obsidian = !world.provider.isHellWorld && ModjamMod.r.nextInt(100) == 0; + + y--; + + int floors = 3 + random.nextInt(6); + + for(int y2 = 0; y2 <= floors * 6; y2++) { + for(int x2 = -5; x2 <= 5; x2++) { + for(int z2 = -5; z2 <= 5; z2++) { + + if(((y2/6) % 2 == 0 ^ y2 % 6 < 2) && x2 == -2 && z2 == -5 && y2 > 1 && y2 <= floors * 6 - 5) { + world.setBlock(x + x2, y + y2, z + z2 + 2, Blocks.ladder, 3, 0); + } + + if(((y2/6) % 2 == 1 ^ y2 % 6 < 2) && x2 == 2 && z2 == 5 && y2 > 1 && y2 <= floors * 6 - 5) { + world.setBlock(x + x2, y + y2, z + z2 - 2, Blocks.ladder, 2, 0); + } + + if((x2 * x2 + z2 * z2 <= 25) && ((y2 % 6 == 0 || y2 % 6 == 1) || z2 > 3 + (y2 < 6 ? 1 : 0) || z2 < -3 || Math.abs(x2) > 3 + (y2 < 5 ? 1 : 0))) { + if(world.getBlock(x + x2, y + y2, z + z2) != Blocks.ladder && world.getBlock(x + x2, y + y2, z + z2) != Blocks.obsidian) { + if(!obsidian && Math.abs(x2) <= 1 && Math.abs(z2) <= 1 && y2 != floors * 6 && y2 != 1 && y2 % 6 == 1) { + world.setBlock(x + x2, y + y2, z + z2, Blocks.obsidian); + } else { + world.setBlock(x + x2, y + y2, z + z2, !world.provider.isHellWorld ? (!obsidian ? (random.nextBoolean() ? Blocks.mossy_cobblestone : Blocks.cobblestone) : Blocks.obsidian) : Blocks.nether_brick); + } + } + } else if(y2 % 6 == 2 && x2 == 0 && z2 == ((y2/6) % 2 == 1 ? 3 : -3) && (y2/6 >= floors - 1 || random.nextInt(3) == 0) && y2 >= 5) { + world.setBlock(x + x2, y + y2, z + z2, Blocks.chest, 0, 2); + + boolean b = (y2/6) % 2 == 1; + + TileEntityChest tileentitychest = (TileEntityChest) world.getTileEntity(x + x2, y + y2, z + z2); + + if(tileentitychest != null) { + WeightedRandomChestContent.generateChestContents(random, ((y2/6 >= floors - 1 || obsidian) ? ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST) : chestGenInfo).getItems(random), tileentitychest, chestGenInfo.getCount(random)); + } + + if(!obsidian) { + world.setBlock(x + x2, y + y2 - 1, z + z2, Blocks.obsidian); + world.setBlock(x + x2, y + y2 + 2, z + z2, Blocks.obsidian); + world.setBlock(x + x2, y + y2, z + z2 + (b ? 1 : -1), Blocks.obsidian); + world.setBlock(x + x2, y + y2 + 1, z + z2 + (b ? 1 : -1), Blocks.obsidian); + world.setBlock(x + x2 + 1, y + y2, z + z2, Blocks.obsidian); + world.setBlock(x + x2 - 1, y + y2, z + z2, Blocks.obsidian); + world.setBlock(x + x2 + 1, y + y2 + 1, z + z2, Blocks.obsidian); + world.setBlock(x + x2 - 1, y + y2 + 1, z + z2, Blocks.obsidian); + } + } else if(y2 % 6 == 2 && x2 == 0 && z2 == 0) { + if(y2 != 2) { + world.setBlock(x + x2, y + y2, z + z2, Blocks.mob_spawner, 0, 2); + TileEntityMobSpawner tileentitymobspawner = (TileEntityMobSpawner)world.getTileEntity(x + x2, y + y2, z + z2); + + if(tileentitymobspawner != null) { + tileentitymobspawner.func_145881_a().setEntityName(DungeonHooks.getRandomDungeonMob(ModjamMod.r));; + } + } else { + world.setBlock(x + x2, y + y2, z + z2, ModjamMod.blockPillar); + world.setBlockMetadataWithNotify(x + x2, y + y2, z + z2, 0, 0); + + world.setBlock(x + x2, y + y2 + 1, z + z2, ModjamMod.blockPillar); + world.setBlockMetadataWithNotify(x + x2, y + y2 + 1, z + z2, 1, 0); + } + } else if((x2 * x2 + z2 * z2 <= 25) && world.getBlock(x + x2, y + y2, z + z2) != ModjamMod.blockPillar && world.getBlock(x + x2, y + y2, z + z2) != Blocks.mob_spawner && world.getBlock(x + x2, y + y2, z + z2) != Blocks.ladder && world.getBlock(x + x2, y + y2, z + z2) != Blocks.chest && world.getBlock(x + x2, y + y2, z + z2) != Blocks.obsidian) { + world.setBlockToAir(x + x2, y + y2, z + z2); + } + + } + } + } + + int changes = 0, y2 = -1; + + do { + changes = 0; + + for(int x2 = -5; x2 <= 5; x2++) { + for(int z2 = -5; z2 <= 5; z2++) { + if(x2 * x2 + z2 * z2 <= 25 && world.isAirBlock(x + x2, y + y2, z + z2)) {world.setBlock(x + x2, y + y2, z + z2, !obsidian ? (random.nextBoolean() ? Blocks.mossy_cobblestone : Blocks.cobblestone) : Blocks.obsidian); changes++;} + } + } + + y2--; + } while(changes != 0 && y + y2 >= 0); + + addedDungeon = true; + + y++; + } + } + } + } + + genning = false; + } + +} diff --git a/resources/assets/fyresmodjam/lang/en_US.lang b/resources/assets/fyresmodjam/lang/en_US.lang new file mode 100644 index 0000000..47801f3 --- /dev/null +++ b/resources/assets/fyresmodjam/lang/en_US.lang @@ -0,0 +1,16 @@ +item.blockPillar.name=Pillar +item.mysteryPotion.name=Mystery Potion +item.itemTrap.name=Trap +item.mysteryMushroom.name=Mystery Mushroom +item.sceptre.name=Obsidian Sceptre +tile.blockPillar.name=Pillar Block +tile.blockTrap.name=Trap +tile.mysteryMushroomBlock.name=Mystery Mushroom +entity.MysteryPotion.name=Mystery Potion +commands.currentBlessing.usage=/currentBlessing - used to check your current blessing +commands.currentDisadvantage.usage=/currentDisadvantage - used to check your current world disadvantage +commands.currentGoal.usage=/currentGoal - used to check your current world goal +commands.creatureKnowledge.usage=/creatureKnowledge [page] - used to check your current creature knowledge stats +commands.weaponKnowledge.usage=/weaponKnowledge [page] - used to check your current weapon knowledge stats +commands.craftingKnowledge.usage=/craftingKnowledge [page] - used to check your current crafting knowledge stats +fyresmodjam.newVersion=\u00A7bA newer version of the "You Will Die" Mod has been found \ No newline at end of file diff --git a/resources/assets/fyresmodjam/sounds.json b/resources/assets/fyresmodjam/sounds.json new file mode 100644 index 0000000..348c793 --- /dev/null +++ b/resources/assets/fyresmodjam/sounds.json @@ -0,0 +1,3 @@ +{ + "pillarActivated": {"catagory":"master","sounds":[{"name":"pillarActivated","stream":"false"}]} +} \ No newline at end of file diff --git a/resources/assets/fyresmodjam/sounds/pillarActivated.ogg b/resources/assets/fyresmodjam/sounds/pillarActivated.ogg new file mode 100644 index 0000000..a6038eb Binary files /dev/null and b/resources/assets/fyresmodjam/sounds/pillarActivated.ogg differ diff --git a/assets/fyresmodjam/textures/blocks/crystal.png b/resources/assets/fyresmodjam/textures/blocks/crystal.png similarity index 100% rename from assets/fyresmodjam/textures/blocks/crystal.png rename to resources/assets/fyresmodjam/textures/blocks/crystal.png diff --git a/assets/fyresmodjam/textures/blocks/crystal_stand.png b/resources/assets/fyresmodjam/textures/blocks/crystal_stand.png similarity index 100% rename from assets/fyresmodjam/textures/blocks/crystal_stand.png rename to resources/assets/fyresmodjam/textures/blocks/crystal_stand.png diff --git a/assets/fyresmodjam/textures/blocks/mushroomBlock.png b/resources/assets/fyresmodjam/textures/blocks/mushroomBlock.png similarity index 100% rename from assets/fyresmodjam/textures/blocks/mushroomBlock.png rename to resources/assets/fyresmodjam/textures/blocks/mushroomBlock.png diff --git a/assets/fyresmodjam/textures/blocks/mushroomBlock_overlay.png b/resources/assets/fyresmodjam/textures/blocks/mushroomBlock_overlay.png similarity index 100% rename from assets/fyresmodjam/textures/blocks/mushroomBlock_overlay.png rename to resources/assets/fyresmodjam/textures/blocks/mushroomBlock_overlay.png diff --git a/assets/fyresmodjam/textures/blocks/pillar.png b/resources/assets/fyresmodjam/textures/blocks/pillar.png similarity index 100% rename from assets/fyresmodjam/textures/blocks/pillar.png rename to resources/assets/fyresmodjam/textures/blocks/pillar.png diff --git a/assets/fyresmodjam/textures/blocks/pillarActive.png b/resources/assets/fyresmodjam/textures/blocks/pillarActive.png similarity index 100% rename from assets/fyresmodjam/textures/blocks/pillarActive.png rename to resources/assets/fyresmodjam/textures/blocks/pillarActive.png diff --git a/assets/fyresmodjam/textures/blocks/spikes.png b/resources/assets/fyresmodjam/textures/blocks/spikes.png similarity index 100% rename from assets/fyresmodjam/textures/blocks/spikes.png rename to resources/assets/fyresmodjam/textures/blocks/spikes.png diff --git a/assets/fyresmodjam/textures/blocks/spikes2.png b/resources/assets/fyresmodjam/textures/blocks/spikes2.png similarity index 100% rename from assets/fyresmodjam/textures/blocks/spikes2.png rename to resources/assets/fyresmodjam/textures/blocks/spikes2.png diff --git a/assets/fyresmodjam/textures/blocks/trap2.png b/resources/assets/fyresmodjam/textures/blocks/trap2.png similarity index 100% rename from assets/fyresmodjam/textures/blocks/trap2.png rename to resources/assets/fyresmodjam/textures/blocks/trap2.png diff --git a/assets/fyresmodjam/textures/blocks/trap3.png b/resources/assets/fyresmodjam/textures/blocks/trap3.png similarity index 100% rename from assets/fyresmodjam/textures/blocks/trap3.png rename to resources/assets/fyresmodjam/textures/blocks/trap3.png diff --git a/assets/fyresmodjam/textures/items/basic_staff.png b/resources/assets/fyresmodjam/textures/items/basic_staff.png similarity index 100% rename from assets/fyresmodjam/textures/items/basic_staff.png rename to resources/assets/fyresmodjam/textures/items/basic_staff.png diff --git a/assets/fyresmodjam/textures/items/crystal_item.png b/resources/assets/fyresmodjam/textures/items/crystal_item.png similarity index 100% rename from assets/fyresmodjam/textures/items/crystal_item.png rename to resources/assets/fyresmodjam/textures/items/crystal_item.png diff --git a/assets/fyresmodjam/textures/items/crystal_stand_item.png b/resources/assets/fyresmodjam/textures/items/crystal_stand_item.png similarity index 100% rename from assets/fyresmodjam/textures/items/crystal_stand_item.png rename to resources/assets/fyresmodjam/textures/items/crystal_stand_item.png diff --git a/assets/fyresmodjam/textures/items/enchantedSceptre.png b/resources/assets/fyresmodjam/textures/items/enchantedSceptre.png similarity index 100% rename from assets/fyresmodjam/textures/items/enchantedSceptre.png rename to resources/assets/fyresmodjam/textures/items/enchantedSceptre.png diff --git a/assets/fyresmodjam/textures/items/fire_amulet.png b/resources/assets/fyresmodjam/textures/items/fire_amulet.png similarity index 100% rename from assets/fyresmodjam/textures/items/fire_amulet.png rename to resources/assets/fyresmodjam/textures/items/fire_amulet.png diff --git a/assets/fyresmodjam/textures/items/fire_amulet_overlay.png b/resources/assets/fyresmodjam/textures/items/fire_amulet_overlay.png similarity index 100% rename from assets/fyresmodjam/textures/items/fire_amulet_overlay.png rename to resources/assets/fyresmodjam/textures/items/fire_amulet_overlay.png diff --git a/assets/fyresmodjam/textures/items/itemPillar.png b/resources/assets/fyresmodjam/textures/items/itemPillar.png similarity index 100% rename from assets/fyresmodjam/textures/items/itemPillar.png rename to resources/assets/fyresmodjam/textures/items/itemPillar.png diff --git a/assets/fyresmodjam/textures/items/itemTrap.png b/resources/assets/fyresmodjam/textures/items/itemTrap.png similarity index 100% rename from assets/fyresmodjam/textures/items/itemTrap.png rename to resources/assets/fyresmodjam/textures/items/itemTrap.png diff --git a/assets/fyresmodjam/textures/items/mushroom.png b/resources/assets/fyresmodjam/textures/items/mushroom.png similarity index 100% rename from assets/fyresmodjam/textures/items/mushroom.png rename to resources/assets/fyresmodjam/textures/items/mushroom.png diff --git a/assets/fyresmodjam/textures/items/mushroom_overlay.png b/resources/assets/fyresmodjam/textures/items/mushroom_overlay.png similarity index 100% rename from assets/fyresmodjam/textures/items/mushroom_overlay.png rename to resources/assets/fyresmodjam/textures/items/mushroom_overlay.png diff --git a/assets/fyresmodjam/textures/items/mysteryPotionThrowable_1.png b/resources/assets/fyresmodjam/textures/items/mysteryPotionThrowable_1.png similarity index 100% rename from assets/fyresmodjam/textures/items/mysteryPotionThrowable_1.png rename to resources/assets/fyresmodjam/textures/items/mysteryPotionThrowable_1.png diff --git a/assets/fyresmodjam/textures/items/mysteryPotionThrowable_10.png b/resources/assets/fyresmodjam/textures/items/mysteryPotionThrowable_10.png similarity index 100% rename from assets/fyresmodjam/textures/items/mysteryPotionThrowable_10.png rename to resources/assets/fyresmodjam/textures/items/mysteryPotionThrowable_10.png diff --git a/assets/fyresmodjam/textures/items/mysteryPotionThrowable_11.png b/resources/assets/fyresmodjam/textures/items/mysteryPotionThrowable_11.png similarity index 100% rename from assets/fyresmodjam/textures/items/mysteryPotionThrowable_11.png rename to resources/assets/fyresmodjam/textures/items/mysteryPotionThrowable_11.png diff --git a/assets/fyresmodjam/textures/items/mysteryPotionThrowable_12.png b/resources/assets/fyresmodjam/textures/items/mysteryPotionThrowable_12.png similarity index 100% rename from assets/fyresmodjam/textures/items/mysteryPotionThrowable_12.png rename to resources/assets/fyresmodjam/textures/items/mysteryPotionThrowable_12.png diff --git a/assets/fyresmodjam/textures/items/mysteryPotionThrowable_13.png b/resources/assets/fyresmodjam/textures/items/mysteryPotionThrowable_13.png similarity index 100% rename from assets/fyresmodjam/textures/items/mysteryPotionThrowable_13.png rename to resources/assets/fyresmodjam/textures/items/mysteryPotionThrowable_13.png diff --git a/assets/fyresmodjam/textures/items/mysteryPotionThrowable_2.png b/resources/assets/fyresmodjam/textures/items/mysteryPotionThrowable_2.png similarity index 100% rename from assets/fyresmodjam/textures/items/mysteryPotionThrowable_2.png rename to resources/assets/fyresmodjam/textures/items/mysteryPotionThrowable_2.png diff --git a/assets/fyresmodjam/textures/items/mysteryPotionThrowable_3.png b/resources/assets/fyresmodjam/textures/items/mysteryPotionThrowable_3.png similarity index 100% rename from assets/fyresmodjam/textures/items/mysteryPotionThrowable_3.png rename to resources/assets/fyresmodjam/textures/items/mysteryPotionThrowable_3.png diff --git a/assets/fyresmodjam/textures/items/mysteryPotionThrowable_4.png b/resources/assets/fyresmodjam/textures/items/mysteryPotionThrowable_4.png similarity index 100% rename from assets/fyresmodjam/textures/items/mysteryPotionThrowable_4.png rename to resources/assets/fyresmodjam/textures/items/mysteryPotionThrowable_4.png diff --git a/assets/fyresmodjam/textures/items/mysteryPotionThrowable_5.png b/resources/assets/fyresmodjam/textures/items/mysteryPotionThrowable_5.png similarity index 100% rename from assets/fyresmodjam/textures/items/mysteryPotionThrowable_5.png rename to resources/assets/fyresmodjam/textures/items/mysteryPotionThrowable_5.png diff --git a/assets/fyresmodjam/textures/items/mysteryPotionThrowable_6.png b/resources/assets/fyresmodjam/textures/items/mysteryPotionThrowable_6.png similarity index 100% rename from assets/fyresmodjam/textures/items/mysteryPotionThrowable_6.png rename to resources/assets/fyresmodjam/textures/items/mysteryPotionThrowable_6.png diff --git a/assets/fyresmodjam/textures/items/mysteryPotionThrowable_7.png b/resources/assets/fyresmodjam/textures/items/mysteryPotionThrowable_7.png similarity index 100% rename from assets/fyresmodjam/textures/items/mysteryPotionThrowable_7.png rename to resources/assets/fyresmodjam/textures/items/mysteryPotionThrowable_7.png diff --git a/assets/fyresmodjam/textures/items/mysteryPotionThrowable_8.png b/resources/assets/fyresmodjam/textures/items/mysteryPotionThrowable_8.png similarity index 100% rename from assets/fyresmodjam/textures/items/mysteryPotionThrowable_8.png rename to resources/assets/fyresmodjam/textures/items/mysteryPotionThrowable_8.png diff --git a/assets/fyresmodjam/textures/items/mysteryPotionThrowable_9.png b/resources/assets/fyresmodjam/textures/items/mysteryPotionThrowable_9.png similarity index 100% rename from assets/fyresmodjam/textures/items/mysteryPotionThrowable_9.png rename to resources/assets/fyresmodjam/textures/items/mysteryPotionThrowable_9.png diff --git a/assets/fyresmodjam/textures/items/mysteryPotion_1.png b/resources/assets/fyresmodjam/textures/items/mysteryPotion_1.png similarity index 100% rename from assets/fyresmodjam/textures/items/mysteryPotion_1.png rename to resources/assets/fyresmodjam/textures/items/mysteryPotion_1.png diff --git a/assets/fyresmodjam/textures/items/mysteryPotion_10.png b/resources/assets/fyresmodjam/textures/items/mysteryPotion_10.png similarity index 100% rename from assets/fyresmodjam/textures/items/mysteryPotion_10.png rename to resources/assets/fyresmodjam/textures/items/mysteryPotion_10.png diff --git a/assets/fyresmodjam/textures/items/mysteryPotion_11.png b/resources/assets/fyresmodjam/textures/items/mysteryPotion_11.png similarity index 100% rename from assets/fyresmodjam/textures/items/mysteryPotion_11.png rename to resources/assets/fyresmodjam/textures/items/mysteryPotion_11.png diff --git a/assets/fyresmodjam/textures/items/mysteryPotion_12.png b/resources/assets/fyresmodjam/textures/items/mysteryPotion_12.png similarity index 100% rename from assets/fyresmodjam/textures/items/mysteryPotion_12.png rename to resources/assets/fyresmodjam/textures/items/mysteryPotion_12.png diff --git a/assets/fyresmodjam/textures/items/mysteryPotion_13.png b/resources/assets/fyresmodjam/textures/items/mysteryPotion_13.png similarity index 100% rename from assets/fyresmodjam/textures/items/mysteryPotion_13.png rename to resources/assets/fyresmodjam/textures/items/mysteryPotion_13.png diff --git a/assets/fyresmodjam/textures/items/mysteryPotion_2.png b/resources/assets/fyresmodjam/textures/items/mysteryPotion_2.png similarity index 100% rename from assets/fyresmodjam/textures/items/mysteryPotion_2.png rename to resources/assets/fyresmodjam/textures/items/mysteryPotion_2.png diff --git a/assets/fyresmodjam/textures/items/mysteryPotion_3.png b/resources/assets/fyresmodjam/textures/items/mysteryPotion_3.png similarity index 100% rename from assets/fyresmodjam/textures/items/mysteryPotion_3.png rename to resources/assets/fyresmodjam/textures/items/mysteryPotion_3.png diff --git a/assets/fyresmodjam/textures/items/mysteryPotion_4.png b/resources/assets/fyresmodjam/textures/items/mysteryPotion_4.png similarity index 100% rename from assets/fyresmodjam/textures/items/mysteryPotion_4.png rename to resources/assets/fyresmodjam/textures/items/mysteryPotion_4.png diff --git a/assets/fyresmodjam/textures/items/mysteryPotion_5.png b/resources/assets/fyresmodjam/textures/items/mysteryPotion_5.png similarity index 100% rename from assets/fyresmodjam/textures/items/mysteryPotion_5.png rename to resources/assets/fyresmodjam/textures/items/mysteryPotion_5.png diff --git a/assets/fyresmodjam/textures/items/mysteryPotion_6.png b/resources/assets/fyresmodjam/textures/items/mysteryPotion_6.png similarity index 100% rename from assets/fyresmodjam/textures/items/mysteryPotion_6.png rename to resources/assets/fyresmodjam/textures/items/mysteryPotion_6.png diff --git a/assets/fyresmodjam/textures/items/mysteryPotion_7.png b/resources/assets/fyresmodjam/textures/items/mysteryPotion_7.png similarity index 100% rename from assets/fyresmodjam/textures/items/mysteryPotion_7.png rename to resources/assets/fyresmodjam/textures/items/mysteryPotion_7.png diff --git a/assets/fyresmodjam/textures/items/mysteryPotion_8.png b/resources/assets/fyresmodjam/textures/items/mysteryPotion_8.png similarity index 100% rename from assets/fyresmodjam/textures/items/mysteryPotion_8.png rename to resources/assets/fyresmodjam/textures/items/mysteryPotion_8.png diff --git a/assets/fyresmodjam/textures/items/mysteryPotion_9.png b/resources/assets/fyresmodjam/textures/items/mysteryPotion_9.png similarity index 100% rename from assets/fyresmodjam/textures/items/mysteryPotion_9.png rename to resources/assets/fyresmodjam/textures/items/mysteryPotion_9.png diff --git a/assets/fyresmodjam/textures/items/sceptre.png b/resources/assets/fyresmodjam/textures/items/sceptre.png similarity index 100% rename from assets/fyresmodjam/textures/items/sceptre.png rename to resources/assets/fyresmodjam/textures/items/sceptre.png diff --git a/assets/fyresmodjam/textures/items/scroll.png b/resources/assets/fyresmodjam/textures/items/scroll.png similarity index 100% rename from assets/fyresmodjam/textures/items/scroll.png rename to resources/assets/fyresmodjam/textures/items/scroll.png diff --git a/assets/fyresmodjam/textures/items/star_amulet.png b/resources/assets/fyresmodjam/textures/items/star_amulet.png similarity index 100% rename from assets/fyresmodjam/textures/items/star_amulet.png rename to resources/assets/fyresmodjam/textures/items/star_amulet.png diff --git a/assets/fyresmodjam/textures/items/star_amulet_overlay.png b/resources/assets/fyresmodjam/textures/items/star_amulet_overlay.png similarity index 100% rename from assets/fyresmodjam/textures/items/star_amulet_overlay.png rename to resources/assets/fyresmodjam/textures/items/star_amulet_overlay.png diff --git a/assets/fyresmodjam/textures/items/trap2.png b/resources/assets/fyresmodjam/textures/items/trap2.png similarity index 100% rename from assets/fyresmodjam/textures/items/trap2.png rename to resources/assets/fyresmodjam/textures/items/trap2.png diff --git a/assets/fyresmodjam/textures/items/trap3.png b/resources/assets/fyresmodjam/textures/items/trap3.png similarity index 100% rename from assets/fyresmodjam/textures/items/trap3.png rename to resources/assets/fyresmodjam/textures/items/trap3.png diff --git a/assets/fyresmodjam/textures/items/unenchantedSceptre.png b/resources/assets/fyresmodjam/textures/items/unenchantedSceptre.png similarity index 100% rename from assets/fyresmodjam/textures/items/unenchantedSceptre.png rename to resources/assets/fyresmodjam/textures/items/unenchantedSceptre.png diff --git a/resources/mcmod.info b/resources/mcmod.info new file mode 100644 index 0000000..838359f --- /dev/null +++ b/resources/mcmod.info @@ -0,0 +1,16 @@ +[ +{ + "modid": "fyresmodjam", + "name": "The You Will Die Mod", + "description": "The You Will Die Mod by xFyreStorm.", + "version": "v0.0.3e", + "mcversion": "1.7.2", + "url": "", + "updateUrl": "", + "authors": ["xFyreStorm"], + "credits": "xFyreStorm - All", + "logoFile": "", + "screenshots": [], + "dependencies": [] +} +]