Everything posted by Yagoki
-
Search for Entitys in a special Radius.
AxisAlignedBB box = AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ) this should be what you're looking for to put in as the second parameter the x, y and z values are respective to the origin so you will probably have to do something like "posX+radius"
-
Polymorphism problem with mod
Not too sure what you're asking as your question doesn't seem to be worded greatly. From my understanding (just going to include this to make sure we're both talking about the same thing) polymorphism is, to put it simply, extending or implementing a class or interface. going on this I'm guessing that you want to change the type of vehicle based on the string you're passing it. (if this assumption is wrong please tell me, i couldn't really get an excellent grasp for what you were asking) in that case you could do something like: EntityVehicle var35; if(entityVehicle.equals(VehicleType1.class.getSimpleName())) // VehicleType1 extends EntityVehicle var35 = new VehicleType1(/*constructor stuff*/); else if(entityVehicle.equals(VehicleType2.class.getSimpleName())) // VehicleType2 extends EntityVehicle var35 = new VehicleType2(/*constructor stuff*/); else var35 = new EntityVehicle(/*constructor stuff*/); i believe you could do something like what you're asking using the Java reflection api, which if i recall correctly allows you to get a class and a constructor form a string, but i'm not very familiar with reflection so can't help that much with that but i can say there are probably many good tutorials on google. One problem you could have with that however is you may not know the required constructors, however if you know that all the constructors take all the same parameters then this shouldn't be a problem. Also i think that reflection can be slower in some cases than direct accesses to the class so use wisely. hope that helps, i could be answering a different question, in which case sorry for wasting your time and *bump*
-
How to give a tool unlimited uses
Over ride these two methods from ItemTool: /** * Current implementations of this method in child classes do not use the entry argument beside ev. They just raise * the damage on the stack. */ public boolean hitEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving) { par1ItemStack.damageItem(2, par3EntityLiving); return true; } public boolean onBlockDestroyed(ItemStack par1ItemStack, World par2World, int par3, int par4, int par5, int par6, EntityLiving par7EntityLiving) { if ((double)Block.blocksList[par3].getBlockHardness(par2World, par4, par5, par6) != 0.0D) { par1ItemStack.damageItem(1, par7EntityLiving); } return true; } and remove the part which damages it. this should also work, and allows for tool materials and effectiveness without having to add extra stuff to your item code
-
Jetpack-like script/mod
do the following in your common proxy public void registerHandlers() { TickRegistry.registerTickHandler(new PlayerTickHandler(), Side.SERVER); } in your client proxy @Override public void registerHandlers() { TickRegistry.registerTickHandler(new PlayerTickHandler(), Side.CLIENT); } PlayerTickHandler.java public class PlayerTickHandler implements ITickHandler { @Override public void tickStart(EnumSet<TickType> type, Object... tickData) { // can't remember but you may need a null check here for the tickData[0] onPlayerTick((EntityPlayer)tickData[0]); } @Override public void tickEnd(EnumSet<TickType> type, Object... tickData) { } @Override public EnumSet<TickType> ticks() { return EnumSet.of(TickType.PLAYER); } @Override public String getLabel() { return "PlayerTickHandler"; } public static void onPlayerTick(EntityPlayer player) { //code for player to be called each tick such as "if(Keyboard.isKeyPressed(Keyboard.KEY_SPACE)) player.motionY += 0.09" //FYI 0.09 seems to be a fairly good value for this from my experience } } finaly in your init method in your mod file do proxy.registerHandlers(); [EDIT] i'd also suggest learning java properly
-
Nether and End ore generation not working [Solved - see end for solution]
ok sorry
-
Jetpack-like script/mod
from my recollection of doing something like this in 1.4.7 it needs to be called on client side as well, so create a tick handler like ashtonr12 has shown, but @Override public EnumSet<TickType> ticks() { return EnumSet.of(TickType.PLAYER, TickType.SERVER); } should be @Override public EnumSet<TickType> ticks() { return EnumSet.of(TickType.PLAYER); } and then call it in both the client and common proxys under the respective sides for each. if you don't the client and server desynchronise because that the server thinks the player is flying but the client doesn't meaning the desired effect is not achieved. not tried this since 1.4.7 though so things may have changed but i think it's unlikely give the nature of it
-
Nether and End ore generation not working [Solved - see end for solution]
yay it worked i'll put the class here for anyone looking through here for something similar http://paste.minecraftforge.net/view/a7b35844 @LexManos not sure what to do with that URL you posted sorry
-
Nether and End ore generation not working [Solved - see end for solution]
How very odd... looking further through the class, and the paths for all the variables i was passing it the target which can be set using the other constructors seems to be rather redundant the following line is called before the ore is added to the chunk, and in the declaration for the method none of the parameters are relay necessary other than the block as when it's called it just checks to see if the id == stone.blockID. if (d12 * d12 + d13 * d13 + d14 * d14 < 1.0D && (block != null && block.isGenMineableReplaceable(par1World, k2, l2, i3, field_94523_c))) field_94523_c is supposed to be the id of the target block, and the bit which seems odd is the block.isGenMineableReplaceable(...) method. this all seems rather odd to me, as i can't find it overridden in netherrack or anything this could explain the problem, please say if I've missed anything here with the code or what it's actually doing. I do have a fair amount of experience of java, but we all make mistakes so i could've missed something. P.S. currently making custom class to test
-
Nether and End ore generation not working [Solved - see end for solution]
i know what the classes are using, if you look in the code for WorldGenMinable there are 3 constructors, one which will only replace stone and two where you can specify a target block (at least that's my understanding of it looking through the class). in my code i've specified the target blocks as netherrack and whitestone (endstone) so which is where my confusion arises from. your point was one of the first things i though of, hence to start with i tred with my own versions of the code for this replacing the Block.stone.blockID with the necessary ones, which still had no effect.
-
Nether and End ore generation not working [Solved - see end for solution]
Sorted out all of my blocks for the world section of my mod, and have managed to get them to generate successfully in the overworld, however the ores which i set to generate in the nether and end do not seem to be spawning anywhere (several extended searches and high spawn rates for testing yielded nothing). not sure what i'm doing wrong so any help would be welcome. World Generator class (only showing one ore form each method as there's a lot of them) package mods.mtech.code.common; import java.util.Random; import mods.mtech.code.blocks.BlockOreNether; import mods.mtech.code.blocks.BlockOreOverworld; import mods.mtech.code.client.Config; 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; public class OreGeneration implements IWorldGenerator { @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { switch(world.provider.dimensionId) { case -1: generateNether(random, chunkX*16, chunkZ*16, world, chunkGenerator, chunkProvider); break; case 1: generateEnd(random, chunkX*16, chunkZ*16, world, chunkGenerator, chunkProvider); break; case 0: generateOverworld(random, chunkX*16, chunkZ*16, world, chunkGenerator, chunkProvider); break; } } private void generateOverworld(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { System.out.println("generating overworld"); if(Config.Blocks.aluminiumOreEnabled) { for (int i = 0; i < 10; i++) { (new WorldGenMinable(BlockOreOverworld.oreAluminium.blockID, 5)).generate(world, random, chunkX + random.nextInt(16), random.nextInt(32), chunkZ + random.nextInt(16)); } } } private void generateNether(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { System.out.println("generating nether"); if(Config.Blocks.azuriteOreEnabled) { for (int i = 0; i < 30; i++) { (new WorldGenMinable(BlockOreNether.oreAzurite.blockID, 50, Block.netherrack.blockID)).generate(world, random, chunkX + random.nextInt(16), random.nextInt(256), chunkZ + random.nextInt(16)); } } } private void generateEnd(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { System.out.println("generating end"); if(Config.Blocks.calciteOreEnabled) { for (int i = 0; i < 50; i++) { (new WorldGenMinable(BlockOreNether.oreCalciteEnd.blockID, 10, Block.whiteStone.blockID)).generate(world, random, chunkX + random.nextInt(16), random.nextInt(256), chunkZ + random.nextInt(16)); } } } } the debug printing shows the correct prints for each dimension, but there's still no ore. (other than in the overworld) I've also tried this with adapted versions of the WorldGenMinable class (just replacing the block id it was replacing with the one i was trying to spawn it in), but the results were the same Thanks in advance
-
Jetpack-like script/mod
not how i'd do it, personally i'd use onArmortTickUpdate(parameters which i cant remember) in the item class and have if(Keyboard.isKeyDown(Keyboard.KEY_SPACE)) { //flight code } or do a tick handler of type player, which is called in the common and client proxys using TickRegistry.registerTickHandler(handler, side) side being Side.CLIENT when called in the client proxy and Side.SERVER in the common proxy. and having the flight code in the on tick start method (wrighting this from memory, so please excuse any errors, any trouble and i'll be willing to help further
- Updating to 1.5
-
Updating to 1.5
OK, so I decided I'd move my mod across to 1.5 asap so that I'm not several versions behind when I get to a point where I can release it, but I'm not sure how to update all the things that have changed. I've looked through all the post's on this page I can see asking a similar thing, but I'm still unsure as to how the texture file is assigned, and how to say where it is. (Also if there are any other major changes I haven't noticed yet please tell me so I don't get confused when I come across them, I all ready fixed the set item name thing... I think) thanks in advance
-
Automatic NailGun
ok i'm guessing this is just a momentary derp on your part, but you've told it to check if countDown (an int) is equal to 0.2 (a float/double) as this will never happen the variable never gets reset once it progresses past 1. so ether replace the variable with an int of value 2 or larger dependent on your required delay, or use a >= check rather than == not going to get pissed off and tell you to learn java as i make these mistakes all the time and i've been doing this for ages (only recently minecraft)
-
Automatic NailGun
this is what i got to work now package yagoki.mtech.item; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class TestItem extends Item { public TestItem(int par1) { super(par1); } public static Item testItem; public static void addItems() { testItem = new TestItem(1000).setItemName("testItem").setCreativeTab(CreativeTabs.tabMisc); } private int coolDown = 0; /** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { if(coolDown == 0||coolDown == 1) { System.out.println(coolDown + " @1@"); if (true) { System.out.println(coolDown + " @1.1@"); EntityArrow var8 = new EntityArrow(world, player, 2.0F); stack.damageItem(1, player); if (!world.isRemote) world.spawnEntityInWorld(var8); } coolDown++; } else if(coolDown == 5) //time between shots in ticks { System.out.println(coolDown + " @2@"); coolDown = 0; } else { System.out.println(coolDown + " @3@"); coolDown++; } return stack; } } it didn't work if it was called for only one tick, but adding the "if(countDown ==1||countDown == 2){" made it work for me. I can't comment on what this will do with a custom entity as i'm too lazy to make one, but best of luck [EDIT] you can remove the println() bits they were just my debug stuff, you know... cuz idiots and stuff... you probably don't nee this edit... i'll stop typing now. also the if(true) was just cuz i cba to remove the if statement and did't think to change it back to the if creative or has ammo thingy
-
Automatic NailGun
code? (if you just copy and pasted mine I forgot an =, the first should be if(coolDown == 0){) otherwise show the code and where the error is being thrown, I did the coolDown thing without testing it, or typing it into the IDE, just as idea but it should work
-
[Solved]Proper Rendering and offset.
i can help, i'm just sorting out the specifics before i post, so don't think you'r being ignored
-
Error Code
show us your code for the class MagicBeans, it appears you are trying to cast a variable to a type which it does not extend. (ie does the class MagicBeans extend ItemSeeds at any point?)
-
Lighting the area around the player
cool any chance you could share? I saw it earlier when looking round for examples of how to do this, seems like a pretty cool mod.
-
Screen flashing on teleport
well i don't know how to fix it, but i can say that the flashing seems to be caused by the fact it actually moves the player (or maybe just the camera) up quickly, rather than just changing the position of the player and the camera (i can tell this as it appeared as i did this with larger amounts of movement that there were frames where the player was between the start and the end (or so it seems)
-
Automatic NailGun
well that wasn't too hard, just had to remove if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(Class3.nail.itemID)) { par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); } now it should work fine if you want to slow down the fire rate then just add a private variable containing the time isnce the lasst shot then do if(coolDown = 0){ //do code coolDown++ } else if(coolDown == 5) //time between shots in ticks { coolDown = 0; } else coolDown++; hope that works for you, i only tested with a quickly made item which fires arrows [EDIT] define cooldown outside the onItemRightClick method
-
Automatic NailGun
maybe public void onUsingItemTick(ItemStack stack, EntityPlayer player, int count){} not tried so not sure but worth a shot
-
Screen flashing on teleport
not too sure about the flashy screen thing, i don't get a very good frame rate, but have you tried player.setPosition(player.posX, player.posY+5, player.posZ);
-
Lighting the area around the player
One of my friends saw me making mods and asked me to make him a mod which adds a mining helmet to light up the area around him when he's mining. I'm not that experienced with this kind of stuff, i'm assuming it's some stuff in the tick handler, but my early guesses using the "player.worldobj.setLightValue(" method have proved unsuccessful so i was wandering if you lovely people would be able to help. P.S. i had a look in the dynamic lights src but to me it currently seems like gobbledygook and i cant identify the necessaries parts.
-
make block change on right click?(with a certain item in player hand)[solved]
just going on a hunch here, but have you tried using null checks (given that your error is caused by a null value) is just add a few bits like if(player != null){ or if(player.inventory.getCurrentItem() != null){ again this is just a hunch as i don't know what is on line 27 of TGrayCobble, where it seems throwing a null pointer exception
IPS spam blocked by CleanTalk.