Jump to content

Romejanic

Forge Modder
  • Posts

    71
  • Joined

  • Last visited

Everything posted by Romejanic

  1. Try making an item which places the block. Then just remove the block's creative visibility and use the item instead. Use this code: import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; public class ItemBlockPlacer extends Item { public int blockID; public String textureName; public ItemFlintAndSteel(int par1, String textureName, int blockID) { super(par1); this.blockID = blockID; } /** * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return * True if something happen and false if it don't. This is for ITEMS, not BLOCKS */ public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { 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 (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) { return false; } else { if (par3World.isAirBlock(par4, par5, par6)) { par3World.playSoundEffect((double)par4 + 0.5D, (double)par5 + 0.5D, (double)par6 + 0.5D, Block.blocksList[blockID].stepSound.getPlaceSound(), 1.0F, itemRand.nextFloat() * 0.4F + 0.8F); par3World.setBlock(par4, par5, par6, blockID); } --par1ItemStack.stackSize; return true; } } @SideOnly(Side.CLIENT) public void registerIcons(IconRegister ir) { this.itemIcon = ir.registerIcon(textureName); } } and when setting it up in the mod file, type this: myBlockPlacer = new ItemBlockPlacer(/* TODO item ID */, /* TODO texture name e.g. "mymod:myitemplacer" */, myBlock.blockID)/* .setCreativeTab(CreativeTabs.tabBlock) etc. */; Hope I helped! Romejanic
  2. Just a quick addition, I noticed the entity wasn't registered in my main class, so I did that and it still does not render.
  3. Hey there! I am updating one of my 1.5.2 mods to 1.6.4. I ran ion problems so I re-wrote the entire mod. But I have a little problem... I am adding a projectile entity which extends EntityThrowable. I copied the old 1.5 code because it worked. What it does is render the chicken model because that is what I want it to render. But in the game, it does nothing. I even tried to make it render with RenderSnowball but even that does not work. Here's the render class: package assets.exchicken.client.renderer; import org.lwjgl.opengl.GL11; import assets.exchicken.common.entity.EntityChickenFired; import assets.exchicken.common.entity.EntityExplosiveChicken; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelChicken; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.passive.EntityChicken; import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; import net.minecraft.util.Vec3; @SideOnly(Side.CLIENT) public class RenderFiredChicken extends Render { protected ModelBase modelChicken; public RenderFiredChicken() { super(); this.modelChicken = new ModelChicken(); } public void renderChicken(EntityChickenFired par1EntityChicken, double par2, double par4, double par6, float par8, float par9) { GL11.glPushMatrix(); long i = (long)par1EntityChicken.entityId * 493286711L; i = i * i * 4392167121L + i * 98761L; float f2 = (((float)(i >> 16 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F; float f3 = (((float)(i >> 20 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F; float f4 = (((float)(i >> 24 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F; GL11.glTranslatef(f2, f3, f4); double d3 = par1EntityChicken.lastTickPosX + (par1EntityChicken.posX - par1EntityChicken.lastTickPosX) * (double)par9; double d4 = par1EntityChicken.lastTickPosY + (par1EntityChicken.posY - par1EntityChicken.lastTickPosY) * (double)par9; double d5 = par1EntityChicken.lastTickPosZ + (par1EntityChicken.posZ - par1EntityChicken.lastTickPosZ) * (double)par9; double d6 = 0.30000001192092896D; float f5 = par1EntityChicken.prevRotationPitch + (par1EntityChicken.rotationPitch - par1EntityChicken.prevRotationPitch) * par9; GL11.glTranslatef((float)par2, (float)par4, (float)par6); GL11.glRotatef(180.0F - par8, 0.0F, 1.0F, 0.0F); GL11.glRotatef(-f5, 0.0F, 0.0F, 1.0F); GL11.glScalef(-1.0F, -1.0F, 1.0F); this.modelChicken.render(par1EntityChicken, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); GL11.glPopMatrix(); } protected float getWingRotation(EntityExplosiveChicken par1EntityChicken, float par2) { float f1 = par1EntityChicken.field_70888_h + (par1EntityChicken.field_70886_e - par1EntityChicken.field_70888_h) * par2; float f2 = par1EntityChicken.field_70884_g + (par1EntityChicken.destPos - par1EntityChicken.field_70884_g) * par2; return (MathHelper.sin(f1) + 1.0F) * f2; } /** * Defines what float the third param in setRotationAngles of ModelBase is */ protected float handleRotationFloat(EntityLiving par1EntityLiving, float par2) { return this.getWingRotation((EntityExplosiveChicken)par1EntityLiving, par2); } public void doRenderLiving(Entity par1EntityLiving, double par2, double par4, double par6, float par8, float par9) { this.renderChicken((EntityChickenFired)par1EntityLiving, par2, par4, par6, par8, par9); } /** * 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) { this.renderChicken((EntityChickenFired)par1Entity, par2, par4, par6, par8, par9); } @Override protected ResourceLocation getEntityTexture(Entity entity) { return new ResourceLocation("textures/entity/chicken.png"); } } And here's my ClientProxy: package assets.exchicken.client.core; import net.minecraft.client.model.ModelChicken; import net.minecraft.client.renderer.entity.RenderSnowball; import net.minecraft.item.Item; import cpw.mods.fml.client.registry.RenderingRegistry; import assets.exchicken.client.renderer.RenderChickenMob; import assets.exchicken.client.renderer.RenderFiredChicken; import assets.exchicken.common.core.CommonProxy; import assets.exchicken.common.entity.EntityChickenFired; import assets.exchicken.common.entity.EntityExplosiveChicken; public class ClientProxy extends CommonProxy { @Override public void registerRenderers() { RenderingRegistry.registerEntityRenderingHandler(EntityExplosiveChicken.class, new RenderChickenMob(new ModelChicken(), 0.0f)); RenderingRegistry.registerEntityRenderingHandler(EntityChickenFired.class, new RenderFiredChicken()); } } Any ideas? Any help would be much appreciated! Thanks, Romejanic
  4. Firstly, you are a bit wrong. You need to add this method to your main class: @EventHandler public void preInit(FMLPreInitialization event) { init(); addNames(); registerRecipes(); } and put this above your class declaration: @Mod(modid="Items", name="Items", version="1.0") @NetworkMod(clientSideRequired=true, serverSideRequired=false) public class Items { hope i helped a bit! Romejanic
  5. If you are dive;oping a basic mod, you probably don't need it, but if you have any public objects in your class, it is 100% necessary. For example: public static Item myItem; // this will NOT require the instance, you access it like: MyMod.myItem public boolean updateAvaliable = false; // this WILL require the instance, you access it like: MyMod.instance.updateAvaliable Hope this helped!
  6. This happened to me one time. When you reobfuscate the mod, check that every package and class is in the re-obf folder. Is it is not, try reobfuscating again. If that still does not work, try coping the source code and setting up a new MCP workspace. Then try reobfuscating from there. Hope this helps! Romejanic
  7. Hello Everyone! I know I have been posting many things on this forum recently but I just need a lot of help! Anyway, I am making a boos mob which I will record a voice track for. However, I want multiple files to be attached to one Sound Pool Entry. It is confusing with the SoundLoadEvent as the addSound() method only points to one file. How am I supposed to do this? Thanks, Romejanic
  8. Sorry could you please explain this a bit further or maybe post some code? Thanks, Romejanic
  9. Hello everyone! I am developing the mob and I have a mob. It attacks the player properly and just how I want it to, but how can I make it avoid the player when holding a certain item. I have an item which the mob drops called ectoplasm. I want the mob to avoid players who are holding ectoplasm. How do I do this? This is my code so far: public EntityGhost(World par1World) { super(par1World); this.tasks.addTask(1, new EntityAIWander(this, 1.0d)); this.tasks.addTask(2, new EntityAISwimming(this)); this.tasks.addTask(3, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(4, new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.0D, false)); this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false)); this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true)); this.dataWatcher.updateObject(6, 300f); isAngry = false; } public void onLivingUpdate() { if(!(findPlayerToAttack() == null)) { isAngry = true; // This is the code for the scared of. if(((EntityPlayer) findPlayerToAttack()).getCurrentEquippedItem() == new ItemStack(BetterMinecraft.ectoplasm, 1)) { this.tasks.removeTask((EntityAIBase)tasks.taskEntries.get(4)); this.tasks.addTask(4, new EntityAIAvoidEntity(this, EntityPlayer.class, 8.0F, 0.6D, 0.6D)); } else { this.tasks.removeTask((EntityAIBase)tasks.taskEntries.get(4)); this.tasks.addTask(4, new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.0D, false)); } } else { isAngry = false; } if (this.worldObj.isDaytime() && !this.worldObj.isRemote) { float f = this.getBrightness(1.0F); if (f > 0.5F && this.rand.nextFloat() * 30.0F < (f - 0.4F) * 2.0F && this.worldObj.canBlockSeeTheSky(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ))) { boolean flag = true; if (flag) { isDaytime = true; } } else { isDaytime = false; } } super.onLivingUpdate(); } What I have tried to do is every time the target player is holding ectoplasm, the AI for attack is removed and the AI for flee is added. And when ectoplasm is unequipped, it attacks the player again. EDIT: Instead of calling new EntityAIBase() when removing the AI, I tried this: tasks.removeTask((EntityAIBase)tasks.taskEntries.get(4)); But this crashes the game when the mob spawns. Does anyone know what I need to do here? Any help is greatly appreciated. Thanks, Romejanic
  10. Hello Everyone! I am developing a mod and I making a mob that is semi-transparent. I used photoshop to make the skins semi-transparent. In the game, if the mob is in the nether, it is sometimes transparent. And is not transparent at all in the over world. Should I put some code in my rendering class? I was looking at GL11.glColor4f() and making the red, green and blue 1 with the alpha 0.5 but I think I put that code in the wrong method. Here is my render code: package assets.bm.romejanic.client.render; import assets.bm.romejanic.common.entity.EntityGhost; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.model.ModelSkeleton; import net.minecraft.client.renderer.entity.RenderBiped; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.monster.EntitySkeleton; import net.minecraft.item.Item; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.ForgeHooksClient; import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) public class RenderGhost extends RenderBiped { private static final ResourceLocation[] textures = new ResourceLocation[] { new ResourceLocation(EntityGhost.getGhostTexture(0)), new ResourceLocation(EntityGhost.getGhostTexture(1)) }; public RenderGhost(ModelBiped model) { super(model, 0.5F); } protected void func_82422_c() { GL11.glTranslatef(0.09375F, 0.1875F, 0.0F); } protected ResourceLocation func_110860_a(EntityGhost ghost) { return ghost.isAngry ? textures[1] : textures[0]; } protected ResourceLocation func_110856_a(EntityLiving par1EntityLiving) { return this.func_110860_a((EntityGhost)par1EntityLiving); } /** * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. */ protected ResourceLocation getEntityTexture(Entity par1Entity) { return this.func_110860_a((EntityGhost)par1Entity); } } An I tried to put the GL11.glColor4f(1.0, 1.0, 1.0, 0.5); in the func_82422_c() method, but am I wrong? Thanks! Romejanic
  11. [move]Hello there everyone![/move] I am trying to create my own horse armor for my mod. I am quite experienced with Java and Minecraft Modding and I thought horse armor would fit well into the mod I was doing. I have had a look at the horse code and realised that the horse armor items are just default items. All of the code is in the EntityHorse class. Looking in this class revealed that there is an array of string with the horse armor textures. Just to see if that worked, i added my own armor texture to that array. Then I found a method called "getHorseArmorIndex(ItemStack)" that told it which texture to use in the array based on what item was placed in the GUI. I added my own code so it would recognise my custom item as a horse armor and load the texture. I tested it in the game, tamed a horse, opened the GUI and tried to drop the item on but nothing happened. What can I do and is it even possible? I would love to know. Thanks! Romejanic
  12. MY GOD It works! Thank you so much for that! I really appreciate it! Thanks! Romejanic
  13. Hello Guys! I have a little problem with a mod I am developing. It is my first mod to include a tile entity. I have registered the tile entity in the main mod file, and the block interacts with the tile entity perfectly. If I close the world and open it again, the data is reloaded and it is great! However, whenever you close the game and open the world again, the tile entity throws this exception: and it's data is lost. For some reason when the game restarts, it has problems reading the block's NBT data from the world save files, resulting in the tile entity's complete file loss. It would be brilliant of someone could help me out with this! I would really appreciate it and you would help a good mod reach the goal of release! Here is some of my code... Registry in main mod file: GameRegistry.registerTileEntity(TileEntityTeleporter.class, "fortress_teleporter_tile_ent"); Tile Entity Code: package assets.fortress.romejanic.common.tileentity; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; public class TileEntityTeleporter extends TileEntity{ public boolean onlyOwner = false; public boolean hasBeenSetUp = false; public String owner = null; public double x = 0d; public double y = 0d; public double z = 0d; @Override public void writeToNBT(NBTTagCompound par1) { par1.setBoolean("onlyOwnerCanTeleport", onlyOwner); par1.setBoolean("hasBeenSetUp", hasBeenSetUp); if(owner != null){ par1.setString("owner", owner); } else{ par1.setString("owner", ""); } par1.setDouble("x", x); par1.setDouble("y", y); par1.setDouble("z", z); super.writeToNBT(par1); } @Override public void readFromNBT(NBTTagCompound par1) { onlyOwner = par1.getBoolean("onlyOwnerCanTeleport"); hasBeenSetUp = par1.getBoolean("hasBeenSetUp"); owner = par1.getString("owner"); x = par1.getDouble("x"); y = par1.getDouble("y"); z = par1.getDouble("z"); super.readFromNBT(par1); } } Thanks Guys! Hope you can help out! Romejanic
  14. Hey there! If it helps out, one of the problems I faced with making custom GUI is actually displaying it. So, here is some code for you to put in your mod to display it easily! Mod File: First, make a variable for your common proxy class public static CommonProxy proxy; Common Proxy Class: public void displayGUI(EntityPlayer player) { } Client Proxy Class: public void displayGUI(EntityPlayer player) { FMLClientHandler.instance().displayGuiScreen(player, new GuiScreenClass()); } Then, whenever you want to display the GUI, just insert this code: ModFileName.proxy.displayGuiScreen(paramEntityPlayer); Hoped this helped! Romejanic
  15. Thanks Guys! I appreciate it! Thanks! Romejanic
  16. Hey guys! I am attempting to make a mod which causes a living entity to emit a particles which looks like blood. I have already handled the particle, but which ForgeSubscribe method is right for a entity attack listener? Here is my code so far; Main Mod File: package romejanic.blood.common; import net.minecraftforge.common.MinecraftForge; import romejanic.blood.common.core.CommonProxy; import romejanic.blood.common.core.ConfigHandler; import romejanic.blood.common.core.EntityListener; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.Init; 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.FMLPreInitializationEvent; import cpw.mods.fml.common.network.NetworkMod; @Mod(modid="BloodParticles", name="Blood Particles", version="1.0") @NetworkMod(clientSideRequired=true, serverSideRequired=false) public class BloodParticles { @SidedProxy(clientSide="romejanic.blood.client.core.ClientCore", serverSide="romejanic.blood.common.core.CommonProxy") public static CommonProxy proxy; @PreInit public void preLoad(FMLPreInitializationEvent event){ ConfigHandler.load(); MinecraftForge.EVENT_BUS.register(new EntityListener()); } @Init public void load(FMLInitializationEvent event){ } } ConfigHandler package romejanic.blood.common.core; import java.io.File; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraftforge.common.Configuration; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.relauncher.Side; public class ConfigHandler { public static int blockID; private static final String set = "Settings"; public static void load(){ File location = null; Side s = FMLCommonHandler.instance().getEffectiveSide(); if(s == s.CLIENT){ location = new File(Minecraft.getMinecraftDir().toString()+"/romejanic/Blood Particles.txt"); } if(s == s.SERVER){ location = new File("./romejanic/Blood Particles.txt"); } config(location); } private static void config(File location){ Configuration config = new Configuration(location); config.load(); config.addCustomCategoryComment(set, "Various settings which control how the mod operates"); blockID = config.get(set, "Blood Block ID", Block.blockRedstone.blockID, "The ID of the block which the mod uses for the blood particles.").getInt(); config.save(); } } EntityListener package romejanic.blood.common.core; import net.minecraft.entity.EntityLiving; import net.minecraft.world.World; import net.minecraftforge.event.ForgeSubscribe; import net.minecraftforge.event.entity.EntityEvent; public class EntityListener { @ForgeSubscribe public void onEntityAttacked(EntityEvent event){ World world = event.entity.worldObj; if(event.entity instanceof EntityLiving){ world.spawnParticle("tilecrack_"+ConfigHandler.blockID+"_0", event.entity.posX, event.entity.posY, event.entity.posZ, 0, 0, 0); } } } What happens at this point is that living entities ALWAYS emit the particle, and a bunch of errors spam the console. Where have I gone wrong? How can this be resolved? Any help would be greatly appreciated Thanks! Romejanic
  17. @LexManos Really? That's strange, because I've never had any problems doing this. Thanks anyway! Romejanic
  18. I've tried just coding my own from scratch, but still have no clue! Thanks! Romejanic
  19. Hello Guys! It's Romejanic here! And I want to give you a little tutorial! If you have seen my recent mods, you would know that my config files all go to the folder /romejanic in the Minecraft folder and server folder. So in this simple tutorial, I will show you how to not only get you config files in a custom directory, but to also make it work universally! Ok. So first, I would recommend making a new class. Usually I call it 'ConfigLoader.java'. You can call it anything you want though! So first in the new class, type make a new void method like this; public static void load(){ } Inside that method, you are going to type this code: File location = null; After that, you also need to import java.io.File. Now, the reason you have typed null at the end is because if it was not an assignment, you would not be able to use it in other declarations. Anyway, we will move on. Next, you need to type this code; Side s = FMLCommonHandler.instance().getEffectiveSide(); After that, you need to make two if statements. One for the client declarations and one for the server declarations. You will type the statements like this; if(s == s.CLIENT){ } if(s == s.SERVER){ } After you type that in, you need to import cpw.mods.fml.common.FMLCommonHandler and cpw.mods.fml.relauncher.Side. Now inside the first if statement (The client statement) you will type the following; location = new File(Minecraft.getMinecraftDir().toString()+"/<foldername>/<file-name>"); Ok. This is where the file's null assignment is replaced. But before we go on, you need to import net.minecraft.client.Minecraft. Except you must replace <foldername> for the name of your custom folder and <file-name> for you file's name. But for the file name, it must be followed by an extension. I would suggest making the extension .txt for easy access but it is really up to you. So, if I wanted my file to go to /romejanic/Ghost.txt, I would type; location = new File(Minecraft.getMinecraftDir().toString()+"/romejanic/Ghost.txt"); Next let's go onto the server! You will probably just copy most of the code except since the Minecaft class doesn't exist in the server, you must change the directory. Instead, you must change it to this; location = new File("./<foldername>/<file-name>"); Once that is complete, you need to create a new void method. It should look like this; private static void config(File location){ } Now, underneath the last if statement in the first void method (the server declaration) you need to type config(location); Next, in the second method, you need to type the following; Configuration config = new Configuration(location); config.load(); config.save(); Ok, you need to import net.minecraftforge.common.Configuration and you are done with the ConfigLoader class! Next, you need to move over to your main mod class. In the pre-init method, you need to add this bit of code; ConfigLoader.load(); If the config file is not in the same package as the main mod class, make sure to import it. So that should be it! After this, just follow the tutorials on how to make config files, unless you know how to make them, but skip the step for the config variable. And when you start the game, you will have your own custom config file directory! BTW The final class should look like this; import java.io.File; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.relauncher.Side; import net.minecraft.client.Minecraft; import net.minecraftforge.common.Configuration; public class ConfigLoader { public static void load(){ File location = null; Side s = FMLCommonHandler.instance().getEffectiveSide(); if(s == s.CLIENT){ location = new File(Minecraft.getMinecraftDir().toString()+"/romejanic/Ghost.txt"); } if(s == s.SERVER){ location = new File("./romejanic/Ghost.txt"); } config(location); } private static void config(File location){ Configuration config = new Configuration(location); config.load(); config.save(); } } Thanks! Romejanic
×
×
  • Create New...

Important Information

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