
FoxxCommand
Members-
Posts
10 -
Joined
-
Last visited
Converted
-
Gender
Undisclosed
-
Personal Text
I am new!
FoxxCommand's Achievements

Tree Puncher (2/8)
3
Reputation
-
Editing Player Class (Custom Player Class?)
FoxxCommand replied to FoxxCommand's topic in Modder Support
I'm not sure what the problem is but whenever I try to use one of the functions it gives me an error and crashes the game, something about and uninitialized variable or something, and I know it's the functions causing it because when I take it out I don't get the errors -
Editing Player Class (Custom Player Class?)
FoxxCommand replied to FoxxCommand's topic in Modder Support
Like adding in functions to the entity like I have "getMana()" and the only reason I have it extending entity was because of something so I could use it for something but I can't remember what and I can't check now cause I'm at work -
Editing Player Class (Custom Player Class?)
FoxxCommand replied to FoxxCommand's topic in Modder Support
So I read up a bit on what you said, but is it possible to use custom functions with it? Because I did everything right I assume but when I use a custome function to get a variable or change it the whole thing crashes How I registered it public class EventHookContainerClass { @ForgeSubscribe public void entityConstructed(EntityConstructing event) { if (event.entity instanceof EntityLiving) { //event.entity.dropItem(Item.arrow.itemID, 1); event.entity.registerExtendedProperties("custom Player", new EntityCustomPlayer(event.entity.worldObj)); } } @ForgeSubscribe public void entityHurt(LivingHurtEvent event) { if (event.entity instanceof EntityLiving) { if (((EntityCustomPlayer) event.entity).getMana() >= 5) { ((EntityLiving) event.entity).addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 1000)); } } } } the 'custom entity' class public class EntityCustomPlayer extends Entity implements IExtendedEntityProperties { private int mana; public EntityCustomPlayer(World worldObj) { //this.mana = 0; super(worldObj); } public void setMana(int m) { this.mana = m; } public int getMana() { return this.mana; } @Override public void saveNBTData(NBTTagCompound compound) { // TODO Auto-generated method stub } @Override public void loadNBTData(NBTTagCompound compound) { // TODO Auto-generated method stub } @Override public void init(Entity entity, World world) { mana = 0; } @Override protected void entityInit() { // TODO Auto-generated method stub } @Override protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { // TODO Auto-generated method stub } @Override protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { // TODO Auto-generated method stub } } -
Editing Player Class (Custom Player Class?)
FoxxCommand replied to FoxxCommand's topic in Modder Support
Think you could give me an example, cause this is a little confusing to me [EDIT] Like if you could give me an example of how to add variables and then get those variables in other things is pretty much all I need to know and I'll figure the rest out myself c: -
Editing Player Class (Custom Player Class?)
FoxxCommand replied to FoxxCommand's topic in Modder Support
I see.. think you could help me with an example class or something? like would it be like package whatever public class CustomPlayer extends IExtendedEntityProperties { private int mana; public void setMana(int m) { mana = m; } public int getMana() { return mana; } } and then how would I use those functions in an item would I just use a normal player statement and it'll fill itself out for me? -
Editing Player Class (Custom Player Class?)
FoxxCommand replied to FoxxCommand's topic in Modder Support
Well I code my own games in Java and for Android (Which uses Java) and I'm pretty well versed in it, I just suck at online/multiplayer stuff Pretty much these bunch of items use like 'mana' and whenever the player uses them it uses their mana and then goes on a cooldown and does things according to what level the player is, I also need to cap the level the player can reach as well as doing some stuff to it's inventory like not drop the stuff when they die and do things like "When holding shift they go invisible" and have like custom player models as well -
So I'm aware that in Forge you're not allowed to edit the base class files and you're definitely not allowed to edit the player class file (found out the hard way) so I'm wondering what's the best way to edit player functions and what not in a custom mod or if it's possible to make a custom player file and get the game to use that, any ideas or help?
-
Craftable Item that spawns mobs? [Unsolved]
FoxxCommand replied to Scatterbuns's topic in Modder Support
First make your standard item class and register it and all that in your main mod class, I'm going to assume you know how to add in a custom recipe if not then stop here and go learn about that, because that's easy compared to making your own entity, anyway back to your item class add in this function public boolean onItemUse(ItemStack item, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffSet) { if (world.getBlockId(x, y + 1, z) == 0 && (world.getBlockId(x, y, z) == Block.grass.blockID || world.getBlockId(x, y, z) == Block.stone.blockID || world.getBlockId(x, y, z) == Block.dirt.blockID || world.getBlockId(x, y, z) == Block.sand.blockID)) { EntitySkeleton ent = new EntitySkeleton(world); //change to whatever entity you're trying to spawn ent.setLocationAndAngles(x, y + 1, z, MathHelper.wrapAngleTo180_float(world.rand.nextFloat() * 360.0F), 0.0F); ent.initCreature(); world.spawnEntityInWorld(ent); } return true; } that function will make it when ever they right click, it will spawn a skeleton, though you can change that to whatever, but first it checks if there's air for it to spawn and if you're spawning it on dirt, grass or sand, though you can take that check out if you wish -
From an item whenever you right-click public ItemStack onItemRightClick(ItemStack par1ItemStack, World world, EntityPlayer player) { if (!player.capabilities.isCreativeMode) { --par1ItemStack.stackSize; } world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!world.isRemote) { world.spawnEntityInWorld(new EntityPoisonDart(world, player)); } return par1ItemStack; } The stuff that's been commented out is stuff that I've tried and didn't work or just gave me errors, I do it so I remember I've already tried it and whatever I think I'm setting the same Id, not sure... I'm using ModLoader functions because that's what all the tutorials told me to do, not sure how to do it otherwise, but I'm pretty sure that it's an issue with registering the render but I'm not sure
-
So long story short I was trying to make a ball that you can lob and it hurts things, but it just won't render, the render class looks good, the entity looks good, I even initialize it which I know is the number one reason for things to not show up and I've looked at this long and hard and I just don't know what's wrong, so hopefully someone with a fresh pair of eyes can have a look at it and tell me what could possibly be wrong Main mod class package fxxcmd.minecraftmods.hardcraft; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.liquids.LiquidStack; import net.minecraftforge.liquids.LiquidDictionary; import net.minecraftforge.liquids.LiquidContainerData; import net.minecraftforge.liquids.LiquidContainerRegistry; import net.minecraft.src.ModLoader; import net.minecraftforge.client.MinecraftForgeClient; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.Init; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.Mod.PostInit; import cpw.mods.fml.common.Mod.PreInit; 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.network.NetworkMod; import cpw.mods.fml.common.registry.EntityRegistry; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import fxxcmd.minecraftmods.hardcraft.abilities.*; import fxxcmd.minecraftmods.hardcraft.block.BlockThunderPlate; import fxxcmd.minecraftmods.hardcraft.entity.EntityPoisonDart; @Mod(modid="fxxcmdHardCraft", name="HardCraft", version="0.0.0") @NetworkMod(clientSideRequired=true, serverSideRequired=false) public class HardCraft { // The instance of your mod that Forge uses. @Instance("Generic") public static HardCraft instance; public static CreativeTabs tabCustom = new CreativeTabAbilities("tabAbilities"); public final static Item itemLightningRod = new AbilityLightningRod(5003); public final static Item itemThunderPlate = new AbilityThunderPlate(5004); public final static Item itemBlowGun = new AbilityBlowGun(5005); //public final static Block blockFermentationTankWall = new BlockFermentationTankWall(500, Material.wood).setHardness(0).setStepSound(Block.soundWoodFootstep).setBlockName("fermentationTankWall").setCreativeTab(CreativeTabs.tabBrewing); public final static Block blockThunderPlate = new BlockThunderPlate(500, null, Material.wood).setHardness(0).setStepSound(Block.soundWoodFootstep); /*{ public ItemStack getIconItemStack() { return new ItemStack(itemThunderPlate, 1, 0); } };*/ // Says where the client and server 'proxy' code is loaded. @SidedProxy(clientSide="fxxcmd.minecraftmods.hardcraft.ClientProxy", serverSide="fxxcmd.minecraftmods.hardcraft.CommonProxy") public static ClientProxy proxy; public static CommonProxy sProxy; @PreInit public void preInit(FMLPreInitializationEvent event) { // Stub Method } @Init public void load(FMLInitializationEvent event) { //EntityRegistry.registerModEntity(EntityPoisonDart.class, "PoisonDart", 1, this, 128, 1, true); proxy.registerRenderers(); //sProxy.registerRenderers(); LanguageRegistry.addName(itemLightningRod, "Lightning Rod"); LanguageRegistry.addName(itemThunderPlate, "Thunder Rune"); LanguageRegistry.addName(itemBlowGun, "Blow Gun"); LanguageRegistry.addName(blockThunderPlate, "Thunder Plate Block"); LanguageRegistry.instance().addStringLocalization("itemGroup.tabAbilities", "en_US", "Abilities"); GameRegistry.registerBlock(blockThunderPlate, "thunderPlate"); //EntityRegistry.registerGlobalEntityID(EntityPoisonDart.class, "PoisonDart", EntityRegistry.findGlobalUniqueEntityId()); //GameRegistry.registerTileEntity(TileEntityBoozeBarrel.class, "tileEntityBoozeBarrel"); //itemLightningRod.setIconIndex(ModLoader.addOverride("/gui/items.png", "/lightningRod.png")); //itemThunderPlate.updateIcons //barrelValveSideTexture = ModLoader.addOverride("/terrain.png", "/fermentationTankWallSealed.png"); } @PostInit public void postInit(FMLPostInitializationEvent event) { // Stub Method } } Entity class package fxxcmd.minecraftmods.hardcraft.entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.monster.EntityBlaze; import net.minecraft.entity.projectile.EntityThrowable; import net.minecraft.util.DamageSource; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; public class EntityPoisonDart extends EntityThrowable { public EntityPoisonDart(World par1World) { super(par1World); } public EntityPoisonDart(World par1World, EntityLiving par2EntityLiving) { super(par1World, par2EntityLiving); } public EntityPoisonDart(World par1World, double par2, double par4, double par6) { super(par1World, par2, par4, par6); } /** * Called when this EntityThrowable hits a block or entity. */ protected void onImpact(MovingObjectPosition par1MovingObjectPosition) { if (par1MovingObjectPosition.entityHit != null) { byte b0 = 0; if (par1MovingObjectPosition.entityHit instanceof EntityBlaze) { b0 = 3; } par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), b0); } for (int i = 0; i < 8; ++i) { this.worldObj.spawnParticle("snowballpoof", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); } if (!this.worldObj.isRemote) { this.setDead(); } } } Renderer class package fxxcmd.minecraftmods.hardcraft.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.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 org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; @SideOnly(Side.CLIENT) public class RenderPoisonDart extends Render { private Item field_94151_a; private int field_94150_f; public RenderPoisonDart(Item par1, int par2) { this.field_94151_a = par1; this.field_94150_f = par2; } public RenderPoisonDart(Item par1) { this(par1, 0); } /** * 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<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1, * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that. */ public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { Icon icon = this.field_94151_a.getIconFromDamage(this.field_94150_f); 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); this.loadTexture("/gui/items.png"); Tessellator tessellator = Tessellator.instance; if (icon == ItemPotion.func_94589_d("potion_splash")) { int i = PotionHelper.func_77915_a(((EntityPotion)par1Entity).getPotionDamage(), false); float f2 = (float)(i >> 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("potion_contents")); GL11.glPopMatrix(); GL11.glColor3f(1.0F, 1.0F, 1.0F); } this.func_77026_a(tessellator, icon); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); } } 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(); } } ClientProxy class package fxxcmd.minecraftmods.hardcraft; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.registry.EntityRegistry; import net.minecraft.client.renderer.entity.RenderArrow; import net.minecraft.item.Item; import net.minecraft.src.ModLoader; import net.minecraftforge.client.MinecraftForgeClient; import fxxcmd.minecraftmods.hardcraft.CommonProxy; import fxxcmd.minecraftmods.hardcraft.entity.EntityPoisonDart; import fxxcmd.minecraftmods.hardcraft.renderers.RenderPoisonDart; public class ClientProxy extends CommonProxy { @Override public void registerRenderers() { MinecraftForgeClient.preloadTexture(ITEMS_PNG); MinecraftForgeClient.preloadTexture(BLOCK_PNG); EntityRegistry.registerGlobalEntityID(EntityPoisonDart.class, "PoisonDart", ModLoader.getUniqueEntityId()); //EntityRegistry.registerModEntity(EntityPoisonDart.class, "PoisonDart", 0, this, 128, 1, true); RenderingRegistry.registerEntityRenderingHandler(EntityPoisonDart.class, new RenderPoisonDart(Item.snowball, 1)); } }