Jump to content

Recommended Posts

Posted

My achievements aren't getting triggered for some reason. Code:

 

AchievementEvent.class:

package dudesmods.extraachievements.extraachievements2;

import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent;

public class AchievementEvent {

@SubscribeEvent
public void onPickup(PlayerEvent.ItemPickupEvent e) {
	if(e.pickedUp.getEntityItem() == new ItemStack(Items.clay_ball)) {
		e.player.addStat(ExtraAchievements.aquireClay, 1);
	}
	if(e.pickedUp.getEntityItem() == new ItemStack(Items.skull, 1)) {
		e.player.addStat(ExtraAchievements.witherSkulls, 1);
	}
	if(e.pickedUp.getEntityItem() == new ItemStack(Blocks.soul_sand)) {
		e.player.addStat(ExtraAchievements.soulSand, 1);
	}
	if(e.pickedUp.getEntityItem() == new ItemStack(Blocks.netherrack)) {
		e.player.addStat(ExtraAchievements.aquireNetherrack, 1);
	}
	if(e.pickedUp.getEntityItem() == new ItemStack(Blocks.sand)) {
		e.player.addStat(ExtraAchievements.aquireSand, 1);
	}
}

@SubscribeEvent
public void onCrafting(PlayerEvent.ItemCraftedEvent e) {
	/**Tools**/
	/*Hoes*/
	if (e.crafting.getItem() == Items.stone_hoe)
        {
                e.player.addStat(ExtraAchievements.buildHoeStone, 1);
        }
	if (e.crafting.getItem() == Items.iron_hoe)
	{
		e.player.addStat(ExtraAchievements.buildHoeIron, 1);
	}
	if (e.crafting.getItem() == Items.golden_hoe)
	{
		e.player.addStat(ExtraAchievements.buildHoeGold, 1);
	}
	if (e.crafting.getItem() == Items.diamond_hoe)
	{
		e.player.addStat(ExtraAchievements.buildHoeDiamond, 1);
	}
	/*Pickaxe*/
	if (e.crafting.getItem() == Items.iron_pickaxe)
	{
		e.player.addStat(ExtraAchievements.buildPickaxeIron, 1);
	}
	if (e.crafting.getItem() == Items.golden_pickaxe)
	{
		e.player.addStat(ExtraAchievements.buildPickaxeGold, 1);
	}
	if (e.crafting.getItem() == Items.diamond_pickaxe)
	{
		e.player.addStat(ExtraAchievements.buildPickaxeDiamond, 1);
	}
	/*Swords*/
	if (e.crafting.getItem() == Items.stone_sword)
        {
                e.player.addStat(ExtraAchievements.buildSwordStone, 1);
        }
	if (e.crafting.getItem() == Items.iron_sword)
	{
		e.player.addStat(ExtraAchievements.buildSwordIron, 1);
	}
	if (e.crafting.getItem() == Items.golden_sword)
	{
		e.player.addStat(ExtraAchievements.buildSwordGold, 1);
	}
	if (e.crafting.getItem() == Items.diamond_sword)
	{
		e.player.addStat(ExtraAchievements.buildSwordDiamond, 1);
	}
	/*Axes*/
	if (e.crafting.getItem() == Items.wooden_axe) {
		e.player.addStat(ExtraAchievements.buildAxeWood, 1);
	}
	if (e.crafting.getItem() == Items.stone_axe)
        {
                e.player.addStat(ExtraAchievements.buildAxeStone, 1);
        }
	if (e.crafting.getItem() == Items.iron_axe)
	{
		e.player.addStat(ExtraAchievements.buildAxeIron, 1);
	}
	if (e.crafting.getItem() == Items.golden_axe)
	{
		e.player.addStat(ExtraAchievements.buildAxeGold, 1);
	}
	if (e.crafting.getItem() == Items.diamond_axe)
	{
		e.player.addStat(ExtraAchievements.buildAxeDiamond, 1);
	}
	/*Shovels*/
	if (e.crafting.getItem() == Items.wooden_shovel) {
		e.player.addStat(ExtraAchievements.buildShovelWood, 1);
	}
	if (e.crafting.getItem() == Items.stone_shovel)
        {
                e.player.addStat(ExtraAchievements.buildShovelStone, 1);
        }
	if (e.crafting.getItem() == Items.iron_shovel)
	{
		e.player.addStat(ExtraAchievements.buildShovelIron, 1);
	}
	if (e.crafting.getItem() == Items.golden_shovel)
	{
		e.player.addStat(ExtraAchievements.buildShovelGold, 1);
	}
	if (e.crafting.getItem() == Items.diamond_shovel)
	{
		e.player.addStat(ExtraAchievements.buildShovelDiamond, 1);
	}
	/**Armor**/
	/*Helmet*/
	if (e.crafting.getItem() == Items.leather_helmet) {
		e.player.addStat(ExtraAchievements.buildHelmetLeather, 1);
	}
	if (e.crafting.getItem() == Items.chainmail_helmet)
        {
                e.player.addStat(ExtraAchievements.buildHelmetChain, 1);
        }
	if (e.crafting.getItem() == Items.iron_helmet)
	{
		e.player.addStat(ExtraAchievements.buildHelmetIron, 1);
	}
	if (e.crafting.getItem() == Items.golden_helmet)
	{
		e.player.addStat(ExtraAchievements.buildHelmetGold, 1);
	}
	if (e.crafting.getItem() == Items.diamond_helmet)
	{
		e.player.addStat(ExtraAchievements.buildHelmetDiamond, 1);
	}
	/*Chest*/
	if (e.crafting.getItem() == Items.leather_chestplate) {
		e.player.addStat(ExtraAchievements.buildChestpieceLeather, 1);
	}
	if (e.crafting.getItem() == Items.chainmail_chestplate)
        {
                e.player.addStat(ExtraAchievements.buildChestpieceChain, 1);
        }
	if (e.crafting.getItem() == Items.iron_chestplate)
	{
		e.player.addStat(ExtraAchievements.buildChestpieceIron, 1);
	}
	if (e.crafting.getItem() == Items.golden_chestplate)
	{
		e.player.addStat(ExtraAchievements.buildChestpieceGold, 1);
	}
	if (e.crafting.getItem() == Items.diamond_chestplate)
	{
		e.player.addStat(ExtraAchievements.buildChestpieceDiamond, 1);
	}
	/*Legs*/
	if (e.crafting.getItem() == Items.leather_leggings) {
		e.player.addStat(ExtraAchievements.buildLeggingsLeather, 1);
	}
	if (e.crafting.getItem() == Items.chainmail_leggings)
        {
                e.player.addStat(ExtraAchievements.buildLeggingsChain, 1);
        }
	if (e.crafting.getItem() == Items.iron_leggings)
	{
		e.player.addStat(ExtraAchievements.buildLeggingsIron, 1);
	}
	if (e.crafting.getItem() == Items.golden_leggings)
	{
		e.player.addStat(ExtraAchievements.buildLeggingsGold, 1);
	}
	if (e.crafting.getItem() == Items.diamond_leggings)
	{
		e.player.addStat(ExtraAchievements.buildLeggingsDiamond, 1);
	}
	/*Boots*/
	if (e.crafting.getItem() == Items.leather_boots) {
		e.player.addStat(ExtraAchievements.buildBootsLeather, 1);
	}
	if (e.crafting.getItem() == Items.chainmail_boots)
        {
                e.player.addStat(ExtraAchievements.buildBootsChain, 1);
        }
	if (e.crafting.getItem() == Items.iron_boots)
	{
		e.player.addStat(ExtraAchievements.buildBootsIron, 1);
	}
	if (e.crafting.getItem() == Items.golden_boots)
	{
		e.player.addStat(ExtraAchievements.buildBootsGold, 1);
	}
	if (e.crafting.getItem() == Items.diamond_boots)
	{
		e.player.addStat(ExtraAchievements.buildBootsDiamond, 1);
	}

	/**Misc**/
	if (e.crafting.getItem() == Items.compass) {
		e.player.addStat(ExtraAchievements.craftCompass, 1);
	}
	if (e.crafting.getItem() == Items.clock) {
		e.player.addStat(ExtraAchievements.craftClock, 1);
	}
	if (Block.getBlockFromItem(e.crafting.getItem()) == Blocks.brick_block) {
		e.player.addStat(ExtraAchievements.craftBricks, 1);
	}
	if (Block.getBlockFromItem(e.crafting.getItem()) == Blocks.glass_pane) {
		e.player.addStat(ExtraAchievements.craftGlassPane, 1);
	}
	if (e.crafting.getItem() == Items.bowl) {
		e.player.addStat(ExtraAchievements.craftBowl, 1);
	}
	if (e.crafting.getItem() == Items.mushroom_stew) {
		e.player.addStat(ExtraAchievements.craftSoup, 1);
	}
	if (Block.getBlockFromItem(e.crafting.getItem()) == Blocks.nether_brick) {
		e.player.addStat(ExtraAchievements.craftNetherBrick, 1);
	}
}

@SubscribeEvent
public void onSmelting(PlayerEvent.ItemSmeltedEvent e) {
	if (e.smelting.getItem() == Items.brick) {
		e.player.addStat(ExtraAchievements.smeltBrick, 1);
	}
	if (e.smelting.getItem() == Items.gold_ingot) {
		e.player.addStat(ExtraAchievements.aquireGold, 1);
	}
	if (Block.getBlockFromItem(e.smelting.getItem()) == Blocks.glass) {
		e.player.addStat(ExtraAchievements.smeltGlass, 1);

	}
	if (e.smelting.getItem() == Items.porkchop) {
		e.player.addStat(ExtraAchievements.cookPork, 1);
	}
	if (e.smelting.getItem() == Items.cooked_beef) {
		e.player.addStat(ExtraAchievements.cookBeef, 1);
	}
	if (e.smelting.getItem() == Items.cooked_chicken) {
		e.player.addStat(ExtraAchievements.cookChicken, 1);
	}
	if (e.smelting.getItem() == Items.netherbrick) {
		e.player.addStat(ExtraAchievements.smeltNetherBrick, 1);
	}
}

}

 

(main class) ExtraAchievements.class:

package dudesmods.extraachievements.extraachievements2;

import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement;
import net.minecraft.stats.AchievementList;
import net.minecraftforge.common.AchievementPage;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
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.registry.GameRegistry;
import dudesmods.extraachievements.extraachievements2.proxy.CommonProxy;


@Mod(modid = ExtraAchievements.MODID, name = ExtraAchievements.NAME, version = ExtraAchievements.VERSION)

public class ExtraAchievements {

public static final String MODID = "extraachievements";
public static final String NAME = "Extra Achievements";
public static final String VERSION = "2.0.0";

public static AchievementPage ExtraAchievements;
/**Tools**/
/*Hoe*/
public static Achievement buildHoeStone;
public static Achievement buildHoeIron;
public static Achievement buildHoeGold;
public static Achievement buildHoeDiamond;
/*Picks*/
public static Achievement buildPickaxeIron;
public static Achievement buildPickaxeGold;
public static Achievement buildPickaxeDiamond;
/*Swords*/
public static Achievement buildSwordStone;
public static Achievement buildSwordIron;
public static Achievement buildSwordGold;
public static Achievement buildSwordDiamond;
/*Axes*/
public static Achievement buildAxeWood;
public static Achievement buildAxeStone;
public static Achievement buildAxeIron;
public static Achievement buildAxeGold;
public static Achievement buildAxeDiamond;
/*Shovels*/
public static Achievement buildShovelWood;
public static Achievement buildShovelStone;
public static Achievement buildShovelIron;
public static Achievement buildShovelGold;
public static Achievement buildShovelDiamond;
/**Armour**/
/*Helmets*/
public static Achievement buildHelmetLeather;
public static Achievement buildHelmetChain;
public static Achievement buildHelmetIron;
public static Achievement buildHelmetGold;
public static Achievement buildHelmetDiamond;
/*ChestPeices*/
public static Achievement buildChestpieceLeather;
public static Achievement buildChestpieceChain;
public static Achievement buildChestpieceIron;
public static Achievement buildChestpieceGold;
public static Achievement buildChestpieceDiamond;
/*Leggings*/
public static Achievement buildLeggingsLeather;
public static Achievement buildLeggingsChain;
public static Achievement buildLeggingsIron;
public static Achievement buildLeggingsGold;
public static Achievement buildLeggingsDiamond;
/*Boots*/
public static Achievement buildBootsLeather;
public static Achievement buildBootsChain;
public static Achievement buildBootsIron;
public static Achievement buildBootsGold;
public static Achievement buildBootsDiamond;
/*Wither*/
public static Achievement soulSand;
public static Achievement witherSkulls;
public static Achievement witherDead;
public static Achievement craftBeacon;
/**Misc.**/
public static Achievement craftCompass;
public static Achievement craftClock;
public static Achievement aquireClay;
public static Achievement smeltBrick;
public static Achievement craftBricks;
public static Achievement aquireGold;
public static Achievement aquireSand;
public static Achievement smeltGlass;
public static Achievement craftGlassPane;
public static Achievement craftBowl;
public static Achievement craftSoup;
public static Achievement cookPork;
public static Achievement cookBeef;
public static Achievement cookChicken;
public static Achievement aquireNetherrack;
public static Achievement smeltNetherBrick;
public static Achievement craftNetherBrick;

@SidedProxy(clientSide="dudesmods.extraachievements.extraachievements2.proxy.ClientProxy", serverSide="dudesmods.extraachievements.extraachievements2.proxy.CommonProxy")
public static CommonProxy proxy;

@EventHandler
public void preLoad(FMLPreInitializationEvent event) {
	initAchieves();
	AchievementPage.registerAchievementPage(ExtraAchievements);

}

@EventHandler
public void mainLoad(FMLInitializationEvent event) {
	MinecraftForge.EVENT_BUS.register(new AchievementEvent());
}

@EventHandler
public void postLoad(FMLPostInitializationEvent event) {

}

public void initAchieves() {
	aquireGold = new Achievement("achievement.aquireGold", "aquireGold", 1, 6, Items.gold_ingot, AchievementList.acquireIron).registerStat();//Vinilla Page

	/*Hoe*/
	buildHoeStone = new Achievement("achievement.buildStoneHoe", "buildHoeStone", 0, -7, Items.stone_hoe, AchievementList.buildHoe).registerStat();
	buildHoeIron = new Achievement("achievement.buildHoeIron", "buildHoeIron", 1, -7, Items.iron_hoe, buildHoeStone).registerStat();
	buildHoeGold = new Achievement("achievement.buildHoeGold", "buildHoeGold", 1, -6, Items.golden_hoe, buildHoeIron).registerStat();
	buildHoeDiamond = new Achievement("achievement.buildHoeDiamond", "buildHoeDiamond", 2, -7, Items.diamond_hoe, buildHoeIron).setSpecial().registerStat();

	/*Pickaxe*/
	buildPickaxeIron = new Achievement("achievement.buildPickaxeIron", "buildPickaxeIron", 1, -4, Items.iron_pickaxe, AchievementList.buildBetterPickaxe).registerStat();
	buildPickaxeGold = new Achievement("achievement.buildPickaxeGold", "buildPickaxeGold", 1, -3, Items.golden_pickaxe, buildPickaxeIron).registerStat();
	buildPickaxeDiamond = new Achievement("achievement.buildPickaxeDiamond", "buildPickaxeDiamond", 2, -4, Items.diamond_pickaxe, buildPickaxeIron).setSpecial().registerStat();

	/*Sword*/
	buildSwordStone = new Achievement("achievement.buildSwordStone", "buildSwordStone", 0, -1, Items.stone_sword, AchievementList.buildSword).registerStat();
	buildSwordIron = new Achievement("achievement.buildSwordIron", "buildSwordIron", 1, -1, Items.iron_sword, buildSwordStone).registerStat();
	buildSwordGold = new Achievement("achievement.buildSwordGold", "buildSwordGold", 1, 0, Items.golden_sword, buildSwordIron).registerStat();
	buildSwordDiamond = new Achievement("achievement.buildSwordDiamond", "buildSwordDiamond", 2, -1, Items.diamond_sword, buildSwordIron).setSpecial().registerStat();

	/*Axe*/
	buildAxeWood = new Achievement("achievement.buildAxeWood", "buildAxeWood", -1, 2, Items.wooden_axe, AchievementList.buildWorkBench).registerStat();
	buildAxeStone = new Achievement("achievement.buildAxeStone", "buildAxeStone", 0, 2, Items.stone_axe, buildAxeWood).registerStat();
	buildAxeIron = new Achievement("achievement.buildAxeIron", "buildAxeIron", 1, 2, Items.iron_axe, buildAxeStone).registerStat();
	buildAxeGold = new Achievement("achievement.buildAxeGold", "buildAxeGold", 1, 3, Items.golden_axe, buildAxeIron).registerStat();
	buildAxeDiamond = new Achievement("achievement.buildAxeDiamond", "buildAxeDiamond", 2, 2, Items.diamond_axe, buildAxeIron).setSpecial().registerStat();

	/*Shovel*/
	buildShovelWood = new Achievement("achievement.buildShovelWood", "buildShovelWood", -1, 5, Items.wooden_shovel, AchievementList.buildWorkBench).registerStat();
	buildShovelStone = new Achievement("achievement.buildShovelStone", "buildShovelStone", 0, 5, Items.stone_shovel, buildShovelWood).registerStat();
	buildShovelIron = new Achievement("achievement.buildShovelIron", "buildShovelIron", 1, 5, Items.iron_shovel, buildShovelStone).registerStat();
	buildShovelGold = new Achievement("achievement.buildShovelGold", "buildShovelGold", 1, 6, Items.golden_shovel, buildShovelIron).registerStat();
	buildShovelDiamond = new Achievement("achievement.buildShovelDiamond", "buildShovelDiamond", 2, 5, Items.diamond_shovel, buildShovelIron).setSpecial().registerStat();

	/*Helmet*/
	buildHelmetLeather = new Achievement("achievement.buildHelmetLeather", "buildHelmetLeather", 4, -7, Items.leather_helmet, AchievementList.killCow).registerStat();
	buildHelmetChain = new Achievement("achievement.buildHelmetChain", "buildHelmetChain", 5, -7, Items.chainmail_helmet, buildHelmetLeather).registerStat();
	buildHelmetIron = new Achievement("achievement.buildHelmetIron", "buildHelmetIron", 6, -7, Items.iron_helmet, buildHelmetLeather).registerStat();
	buildHelmetGold = new Achievement("achievement.buildHelmetGold", "buildHelmetGold", 7, -7, Items.golden_helmet, buildHelmetIron).registerStat();
	buildHelmetDiamond = new Achievement("achievement.buildHelmetDiamond", "buildHelmetDiamond", 8, -7, Items.diamond_helmet, buildHelmetIron).setSpecial().registerStat();

	/*Chestpiece*/
	buildChestpieceLeather = new Achievement("achievement.buildChestpieceLeather", "buildChestpieceLeather", 4, -6, Items.leather_chestplate, AchievementList.killCow).registerStat();
	buildChestpieceChain = new Achievement("achievement.buildChestpieceChain", "buildChestpieceChain", 5, -6, Items.chainmail_chestplate, buildChestpieceLeather).registerStat();
	buildChestpieceIron = new Achievement("achievement.buildChestpieceIron", "buildChestpieceIron", 6, -6, Items.iron_chestplate, buildChestpieceLeather).registerStat();
	buildChestpieceGold = new Achievement("achievement.buildChestpieceGold", "buildChestpieceGold", 7, -6, Items.golden_chestplate, buildChestpieceIron).registerStat();
	buildChestpieceDiamond = new Achievement("achievement.buildChestpieceDiamond", "buildChestpieceDiamond", 8, -6, Items.diamond_chestplate, buildChestpieceIron).setSpecial().registerStat();

	/*Leggings*/
	buildLeggingsLeather = new Achievement("achievement.buildLeggingsLeather", "buildLeggingsLeather", 4, -5, Items.leather_leggings, AchievementList.killCow).registerStat();
	buildLeggingsChain = new Achievement("achievement.buildLeggingsChain", "buildLeggingsChain", 5, -5, Items.chainmail_leggings, buildLeggingsLeather).registerStat();
	buildLeggingsIron = new Achievement("achievement.buildLeggingsIron", "buildLeggingsIron", 6, -5, Items.iron_leggings, buildLeggingsLeather).registerStat();
	buildLeggingsGold = new Achievement("achievement.buildLeggingsGold", "buildLeggingsGold", 7, -5, Items.golden_leggings, buildLeggingsIron).registerStat();
	buildLeggingsDiamond = new Achievement("achievement.buildLeggingsDiamond", "buildLeggingsDiamond", 8, -5, Items.diamond_leggings, buildLeggingsIron).setSpecial().registerStat();

	/*Boots*/
	buildBootsLeather = new Achievement("achievement.buildBootsLeather", "buildBootsLeather", 4, -4, Items.leather_boots, AchievementList.killCow).registerStat();
	buildBootsChain = new Achievement("achievement.buildBootsChain", "buildBootsChain", 5, -4, Items.chainmail_boots, buildBootsLeather).registerStat();
	buildBootsIron = new Achievement("achievement.buildBootsIron", "buildBootsIron", 6, -4, Items.iron_boots, buildBootsLeather).registerStat();
	buildBootsGold = new Achievement("achievement.buildBootsGold", "buildBootsGold", 7, -4, Items.golden_boots, buildBootsIron).registerStat();
	buildBootsDiamond = new Achievement("achievement.buildBootsDiamond", "buildBootsDiamond", 8, -4, Items.diamond_boots, buildBootsIron).setSpecial().registerStat();

	/**Misc.**/
	craftCompass = new Achievement("achievement.craftCompass", "craftCompass", 4, 0, Items.compass, AchievementList.acquireIron).registerStat();
	craftClock = new Achievement("achievement.craftClock", "craftClock", 5, 0, Items.clock, aquireGold).registerStat();

	aquireClay = new Achievement("achievement.aquireClay", "aquireClay", 3, 1, Items.clay_ball, null).registerStat();
	smeltBrick = new Achievement("achievement.smeltBrick", "smeltBrick", 4, 1, Items.brick, aquireClay).registerStat();
	craftBricks = new Achievement("achievement.craftBricks", "craftBricks", 5, 1, Blocks.brick_block, smeltBrick).registerStat();

	aquireSand = new Achievement("achievement.aquireSand", "aquireSand", 3, 2, Blocks.sand, null).registerStat();
	smeltGlass = new Achievement("achievement.smeltGlass", "smeltGlass", 4, 2, Blocks.glass, aquireSand).registerStat();
	craftGlassPane = new Achievement("achievement.craftGlassPane", "craftGlassPane", 5, 2, Blocks.glass_pane, smeltGlass).registerStat();

	craftBowl = new Achievement("achievement.craftBowl", "craftBowl", 4, 3, Items.bowl, AchievementList.buildWorkBench).registerStat();
	craftSoup = new Achievement("achievement.craftSoup", "craftSoup", 5, 3, Items.mushroom_stew, craftBowl).registerStat();

	cookPork = new Achievement("achievement.cookPork", "cookPork", 6, 3, Items.porkchop, AchievementList.buildFurnace).registerStat();
	cookBeef = new Achievement("achievement.cookBeef", "cookBeef", 7, 3, Items.cooked_beef, AchievementList.buildFurnace).registerStat();
	cookChicken = new Achievement("achievement.cookChicken", "cookChicken", 8, 3, Items.cooked_chicken, AchievementList.buildFurnace).registerStat();

	aquireNetherrack = new Achievement("achievement.aquireNetherrack", "aquireNetherrack", 6, 1, Blocks.netherrack, AchievementList.portal).registerStat();
	smeltNetherBrick = new Achievement("achievement.smeltNetherBrick", "smeltNetherBrick", 7, 1, Items.netherbrick, aquireNetherrack).registerStat();
	craftNetherBrick = new Achievement("achievement.craftNetherBrick", "craftNetherBrick", 8, 1, Blocks.nether_brick, smeltNetherBrick).registerStat();

	soulSand = new Achievement("achievement.soulSand", "soulSand", 6, 2, Blocks.soul_sand, null).registerStat();
	witherSkulls = new Achievement("achievement.witherSkulls", "witherSkulls", 7, 2, new ItemStack(Items.skull, 1, 1), null).registerStat();

	ExtraAchievements = new AchievementPage("Extra Achievements", 
			buildHoeStone, buildHoeIron, buildHoeGold, buildHoeDiamond,
			buildPickaxeIron, buildPickaxeGold, buildPickaxeDiamond,
			buildSwordStone, buildSwordIron, buildSwordGold, buildSwordDiamond,
			buildAxeWood, buildAxeStone, buildAxeIron, buildAxeGold, buildAxeDiamond,
			buildShovelWood, buildShovelStone, buildShovelIron, buildShovelGold, buildShovelDiamond,
			buildHelmetLeather, buildHelmetChain, buildHelmetIron, buildHelmetGold, buildHelmetDiamond,
			buildChestpieceLeather, buildChestpieceChain, buildChestpieceIron, buildChestpieceGold, buildChestpieceDiamond,
			buildLeggingsLeather, buildLeggingsChain, buildLeggingsIron, buildLeggingsGold, buildLeggingsDiamond,
			buildBootsLeather, buildBootsChain, buildBootsIron, buildBootsGold, buildBootsDiamond,
			craftCompass, craftClock,
			aquireClay, smeltBrick, craftBricks,
			aquireSand, smeltGlass, craftGlassPane,
			craftBowl, craftSoup,
			cookPork, cookBeef, cookChicken,
			aquireNetherrack, smeltNetherBrick, craftNetherBrick,
			soulSand, witherSkulls);
}
}

 

Legend of Zelda Mod[updated September 20th to 3.1.1]

Extra Achievements(Minecraft 1.8!)[updated April 3rd to 2.3.0]

Fancy Cheeses[updated May 8th to 0.5.0]

Posted

You are subscribing to FML events, then you need to use the FML EventBus.

MinecraftForge.EVENT_BUS.register(new AchievementEvent());

Is this not the event bus?

Legend of Zelda Mod[updated September 20th to 3.1.1]

Extra Achievements(Minecraft 1.8!)[updated April 3rd to 2.3.0]

Fancy Cheeses[updated May 8th to 0.5.0]

Posted

You are subscribing to FML events, then you need to use the FML EventBus.

That is the Forge EventBus.

 

So what are you telling me to do?

Legend of Zelda Mod[updated September 20th to 3.1.1]

Extra Achievements(Minecraft 1.8!)[updated April 3rd to 2.3.0]

Fancy Cheeses[updated May 8th to 0.5.0]

Posted

I am telling you to use the FML EventBus. You will surely find it if you search for where instances of the EventBus class are created (use your IDE).

You said to use the event bus but then you said i was already using it.

Legend of Zelda Mod[updated September 20th to 3.1.1]

Extra Achievements(Minecraft 1.8!)[updated April 3rd to 2.3.0]

Fancy Cheeses[updated May 8th to 0.5.0]

Posted

And again we have someone posting code :(

 

Yeah, I hoped people would actually use their IDE for sources.

Seriously, people need to start learning on their own instead of people giving them answers (code, in this case).

Posted

FMLCommonHandler.instance().bus().register(new AchievementEvent());

still doesn't work.

Legend of Zelda Mod[updated September 20th to 3.1.1]

Extra Achievements(Minecraft 1.8!)[updated April 3rd to 2.3.0]

Fancy Cheeses[updated May 8th to 0.5.0]

Posted

So can anyone help me with my problem?

Legend of Zelda Mod[updated September 20th to 3.1.1]

Extra Achievements(Minecraft 1.8!)[updated April 3rd to 2.3.0]

Fancy Cheeses[updated May 8th to 0.5.0]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Version 1.19 - Forge 41.0.63 I want to create a wolf entity that I can ride, so far it seems to be working, but the problem is that when I get on the wolf, I can’t control it. I then discovered that the issue is that the server doesn’t detect that I’m riding the wolf, so I’m struggling with synchronization. However, it seems to not be working properly. As I understand it, the server receives the packet but doesn’t register it correctly. I’m a bit new to Java, and I’ll try to provide all the relevant code and prints *The comments and prints are translated by chatgpt since they were originally in Spanish* Thank you very much in advance No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. MountableWolfEntity package com.vals.valscraft.entity; import com.vals.valscraft.network.MountSyncPacket; import com.vals.valscraft.network.NetworkHandler; import net.minecraft.client.Minecraft; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.animal.Wolf; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.Entity; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import net.minecraftforge.event.TickEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.network.PacketDistributor; public class MountableWolfEntity extends Wolf { private boolean hasSaddle; private static final EntityDataAccessor<Byte> DATA_ID_FLAGS = SynchedEntityData.defineId(MountableWolfEntity.class, EntityDataSerializers.BYTE); public MountableWolfEntity(EntityType<? extends Wolf> type, Level level) { super(type, level); this.hasSaddle = false; } @Override protected void defineSynchedData() { super.defineSynchedData(); this.entityData.define(DATA_ID_FLAGS, (byte)0); } public static AttributeSupplier.Builder createAttributes() { return Wolf.createAttributes() .add(Attributes.MAX_HEALTH, 20.0) .add(Attributes.MOVEMENT_SPEED, 0.3); } @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(hand); if (itemstack.getItem() == Items.SADDLE && !this.hasSaddle()) { if (!player.isCreative()) { itemstack.shrink(1); } this.setSaddle(true); return InteractionResult.SUCCESS; } else if (!level.isClientSide && this.hasSaddle()) { player.startRiding(this); MountSyncPacket packet = new MountSyncPacket(true); // 'true' means the player is mounted NetworkHandler.CHANNEL.sendToServer(packet); // Ensure the server handles the packet return InteractionResult.SUCCESS; } return InteractionResult.PASS; } @Override public void travel(Vec3 travelVector) { if (this.isVehicle() && this.getControllingPassenger() instanceof Player) { System.out.println("The wolf has a passenger."); System.out.println("The passenger is a player."); Player player = (Player) this.getControllingPassenger(); // Ensure the player is the controller this.setYRot(player.getYRot()); this.yRotO = this.getYRot(); this.setXRot(player.getXRot() * 0.5F); this.setRot(this.getYRot(), this.getXRot()); this.yBodyRot = this.getYRot(); this.yHeadRot = this.yBodyRot; float forward = player.zza; float strafe = player.xxa; if (forward <= 0.0F) { forward *= 0.25F; } this.flyingSpeed = this.getSpeed() * 0.1F; this.setSpeed((float) this.getAttributeValue(Attributes.MOVEMENT_SPEED) * 1.5F); this.setDeltaMovement(new Vec3(strafe, travelVector.y, forward).scale(this.getSpeed())); this.calculateEntityAnimation(this, false); } else { // The wolf does not have a passenger or the passenger is not a player System.out.println("No player is mounted, or the passenger is not a player."); super.travel(travelVector); } } public boolean hasSaddle() { return this.hasSaddle; } public void setSaddle(boolean hasSaddle) { this.hasSaddle = hasSaddle; } @Override protected void dropEquipment() { super.dropEquipment(); if (this.hasSaddle()) { this.spawnAtLocation(Items.SADDLE); this.setSaddle(false); } } @SubscribeEvent public static void onServerTick(TickEvent.ServerTickEvent event) { if (event.phase == TickEvent.Phase.START) { MinecraftServer server = net.minecraftforge.server.ServerLifecycleHooks.getCurrentServer(); if (server != null) { for (ServerPlayer player : server.getPlayerList().getPlayers()) { if (player.isPassenger() && player.getVehicle() instanceof MountableWolfEntity) { MountableWolfEntity wolf = (MountableWolfEntity) player.getVehicle(); System.out.println("Tick: " + player.getName().getString() + " is correctly mounted on " + wolf); } } } } } private boolean lastMountedState = false; @Override public void tick() { super.tick(); if (!this.level.isClientSide) { // Only on the server boolean isMounted = this.isVehicle() && this.getControllingPassenger() instanceof Player; // Only print if the state changed if (isMounted != lastMountedState) { if (isMounted) { Player player = (Player) this.getControllingPassenger(); // Verify the passenger is a player System.out.println("Server: Player " + player.getName().getString() + " is now mounted."); } else { System.out.println("Server: The wolf no longer has a passenger."); } lastMountedState = isMounted; } } } @Override public void addPassenger(Entity passenger) { super.addPassenger(passenger); if (passenger instanceof Player) { Player player = (Player) passenger; if (!this.level.isClientSide && player instanceof ServerPlayer) { // Send the packet to the server to indicate the player is mounted NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new MountSyncPacket(true)); } } } @Override public void removePassenger(Entity passenger) { super.removePassenger(passenger); if (passenger instanceof Player) { Player player = (Player) passenger; if (!this.level.isClientSide && player instanceof ServerPlayer) { // Send the packet to the server to indicate the player is no longer mounted NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new MountSyncPacket(false)); } } } @Override public boolean isControlledByLocalInstance() { Entity entity = this.getControllingPassenger(); return entity instanceof Player; } @Override public void positionRider(Entity passenger) { if (this.hasPassenger(passenger)) { double xOffset = Math.cos(Math.toRadians(this.getYRot() + 90)) * 0.4; double zOffset = Math.sin(Math.toRadians(this.getYRot() + 90)) * 0.4; passenger.setPos(this.getX() + xOffset, this.getY() + this.getPassengersRidingOffset() + passenger.getMyRidingOffset(), this.getZ() + zOffset); } } } MountSyncPacket package com.vals.valscraft.network; import com.vals.valscraft.entity.MountableWolfEntity; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class MountSyncPacket { private final boolean isMounted; public MountSyncPacket(boolean isMounted) { this.isMounted = isMounted; } public void encode(FriendlyByteBuf buffer) { buffer.writeBoolean(isMounted); } public static MountSyncPacket decode(FriendlyByteBuf buffer) { return new MountSyncPacket(buffer.readBoolean()); } public void handle(NetworkEvent.Context context) { context.enqueueWork(() -> { ServerPlayer player = context.getSender(); // Get the player from the context if (player != null) { // Verifies if the player has dismounted if (!isMounted) { Entity vehicle = player.getVehicle(); if (vehicle instanceof MountableWolfEntity wolf) { // Logic to remove the player as a passenger wolf.removePassenger(player); System.out.println("Server: Player " + player.getName().getString() + " is no longer mounted."); } } } }); context.setPacketHandled(true); // Marks the packet as handled } } networkHandler package com.vals.valscraft.network; import com.vals.valscraft.valscraft; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.network.NetworkRegistry; import net.minecraftforge.network.simple.SimpleChannel; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class NetworkHandler { private static final String PROTOCOL_VERSION = "1"; public static final SimpleChannel CHANNEL = NetworkRegistry.newSimpleChannel( new ResourceLocation(valscraft.MODID, "main"), () -> PROTOCOL_VERSION, PROTOCOL_VERSION::equals, PROTOCOL_VERSION::equals ); public static void init() { int packetId = 0; // Register the mount synchronization packet CHANNEL.registerMessage( packetId++, MountSyncPacket.class, MountSyncPacket::encode, MountSyncPacket::decode, (msg, context) -> msg.handle(context.get()) // Get the context with context.get() ); } }  
    • Do you use features of inventory profiles next (ipnext) or is there a change without it?
    • Remove rubidium - you are already using embeddium, which is a fork of rubidium
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.