-
Posts
2638 -
Joined
-
Last visited
-
Days Won
4
Everything posted by Ernio
-
Don't give what works, give us what doesn't (because you cut code from different places) Also, remove this ridiculus Id stuff from your new ItemAluminum(15029), don't use IDs at all actually (since 1,6). I'd try lowercasing everything (EVERYTHING). EDIT: Is there some console output?
-
I am trying to get Class<? extends EntityLivingBase> by String. E.g: "Zombie" returns EntityZombie.class (from EntityList.class) Is it just me, or am I looking in wrong place that I don't see getClassFromString method. Method is either somewhere else or minecraft doesn't care about my feelings :C (Why u du dis ;_ Obviously I can just get public field. public static final Map stringToClassMapping = Maps.newHashMap(); Just asking if there is no methods somewhere else for this?
-
1.7.10 Custom Enchantment/Server Tick Handler Error
Ernio replied to Hextor's topic in Modder Support
Fixed some of code for you: @SubscribeEvent public void onPlayer(PlayerTickEvent event) { if (event.phase == Phase.START && !event.player.worldObj.isRemote) { if (event.player.getCurrentArmor(3) != null) { ItemStack helmet = event.player.getCurrentArmor(3); if (helmet.getItem() == Items.diamond_helmet || helmet.getItem() == Items.golden_helmet || helmet.getItem() == Items.iron_helmet || helmet.getItem() == Items.leather_helmet || helmet.getItem() == Items.chainmail_helmet) { int j = EnchantmentHelper.getEnchantmentLevel(integerSomeId, helmet); // This will check if given itemstack (helmet) has an enchantment with given id. *** if (j > 0) { event.player.addPotionEffect(new PotionEffect(Potion.moveSpeed.getId(), 60, j)); // Adds speed potion effect to player. } } } } } Now you need to register the class contining it with FML. This event is launched twice per tick, you need to pick one phase. Also you want to add effect on server, vanilla will do rest for you. Finally - I have no idea why and what are you trying to do by using EnchantmentHelper, it's strictly reserved to read vanilla scroll enchantments. You need to either write your own NBT reader for ItemStack (that will find your buff-NBT) or use vanilla id's (which are defined there, check in IDE what methods are calling getEnchantmentLevel(...) and what are they putting there as an ID as an exerice. -
If you want your Item to be Sword you need to use ItemSword (or ItemTool) which has ToolMaterial field in it. Item.class is used mostly for very basic items or as a base for extending classes (like food).
-
I personally think you shouldn't go further than handleKeyboardInput, even that is really far (it's the top-generic method in mc Gui handling), going straight to lwjgl breaks the idea of using API/ready-code. If handleKeyboardInput will work for you then it's a right way to do it, if not (the "But key input seems to cease to work when a GUI is open"). Other than that you can hook yourself into InputEvent.KeyInputEvent: Minecraft mc = Minecraft.getMinecraft(); if (key.isPressed() && FMLClientHandler.instance().getClient().inGameHasFocus) { if (//check if mc.currentScreen == YourGuiClass) { // set some static value to true inside YourGuiClass } } Now you can use that static boolean inside your gui as a reassurance that key has ben clicked. Obviously to set it back to false you can use KeyBinding to do so (idk, there is probably method onUnpressed() or similar, idk, not in IDE). This way (with event) you will stay with universal KeyBinding (that are settled inside options menu), not static ones. EDIT: PS: I totally don't remember methods in KeyBinding right now, the ones above are jus tgeneral idea. Doing it is matter of looking there,
-
Oh your highness, could you be enormously generous and provide us with some code of your world generator?
-
Just look... e.g isShiftKeyDown()
-
protected void keyTyped(char chr, int id) {} Look at GuiScreen - A LOT of helper methods there.
-
What's the most efficient way to use event handlers?
Ernio replied to Bedrock_Miner's topic in Modder Support
Personally I've separated: Common: *ForgeEvents *FMLEvents Client: *ClientForgeEvents and hadn't a chance to make ClientFMLEvents yet. I register whole class once in proxy and in case of Client events I do that in client proxy ofc. I doubt that there is any difference here other than readability. -
[1.8] how to use worldRendering to render an item.
Ernio replied to karelmikie3's topic in Modder Support
Well, the examples I linked tell how to add renderer to block when it's in inventory. https://github.com/TheGreyGhost/MinecraftByExample/blob/master/src/main/java/minecraftbyexample/mbe01_block_simple/StartupClientOnly.java This is ofc. based on .json model. If you ought to use other renderer then I can't help you - each works differently, there is no universal answer here. Post some code and what you are trying / tried. -
[1.8] how to use worldRendering to render an item.
Ernio replied to karelmikie3's topic in Modder Support
Are you talking about placed block or block as an item? Block as an item (in inventory) are represented by ItemBlock (or BlockItem, i don't remember) and when dropped into world they are still treated as EntityItem. If you are referring to placed-blocks then there are several ways. If you are looking for simple, yet not cubic shape: Have look at how .json models work (Blocks section): http://greyminecraftcoder.blogspot.co.at/p/list-of-topics.html Code examples: http://www.minecraftforge.net/forum/index.php/topic,26267.0.html For more advanced stuff (custom models) you will need TileEntitySpecialRenderer or ISmartBlockModel, depends on what you want to render. All those classes are either in minecraft.client package or minecraftforge.client.model I don't have much experience here aside from very simple renderer for my crystals Ask TGG (GreyGhost), he's probably dealing with those lately. -
[1.8] how to use worldRendering to render an item.
Ernio replied to karelmikie3's topic in Modder Support
As of 1.8 IItemRenderer has been deprecated and EntityItem is always rendered the same (using .json model). To "override" it you would need to make custom EntityItem (extension) with custom renderer registered (like for any other entity). Then operate on your custom renderer. That's what I did ;p P.S - I might not understood your problem - you could be more precise -
There is a difference between world rendering and screen rendering. World rendering occurs always when you are in world (not main menu / other non-ingame gui). If you are looking to render thing into the world like this: Then RenderWorldLastEvent is your friend (which I alredy pointed out in last thread). As for "want to render the In-game GUI", I also pointed out - RenderGameOverlayEvent. If not it, I have no idea what you are looking for, there are few other events look into: net.minecraftforge.client.event
-
I need help with this! I dont know what is wrong D:
Ernio replied to DreamBeatGaming's topic in Support & Bug Reports
Wrong forum then. Tip: uninstall all mods and throw them one after another, see at which it will start crashing - this mod is corrupted, try checking if there are some new updates/fixes for it, if not, you can't use it. -
EntityLightningBolt extends EntityWeatherEffect extends Entity public EntityLightningBolt(World worldIn, double posX, double posY, double posZ) { super(worldIn); this.setLocationAndAngles(posX, posY, posZ, 0.0F, 0.0F); Ligtning entity has x,y,z you can easily get it from EntityJoinWorldEvent with checking if entity is lightning (and ofc. side). EDIT: Whoa (post below) - I didn't know that, sry OP.
-
Ye, exacly what I was going to add when I noticed they require 1.8, not just 1.7.
-
Why are you using default methods... I never liked those Anyway - you need to add this: compileJava { sourceCompatibility = 1.8 targetCompatibility = 1.8 } To your build.gradle
-
[1.8] Get ahold of working (pre-obf) minecraft+forge.jar
Ernio replied to Ernio's topic in Modder Support
I just need a library I can refere to with not-a-mod application. This is totally outside of forge (even java I could say). Anyone know how I could compile such lib? -
Not that I know much about ASM, but couldn't you use your map as an addition (not overwrite) and read it (execute bindings) using client KeyEvents? You can make that one binding launches other bindings there (in event). EDIT: To below: Ah, yes, true that.
-
I just hate giving working code. Learn java. pos = pos.offset(side); This moves clicked position to block next to block you clicked, facing the face you clicked. So basically when you click on wall you will not check if wall is air and set it to fire, but do it (check and ignite) block before it. Logically you can't do tnt-ignite on block NEXT to tnt, it's not logical. You need to do it 1st (on block you clicked). Now look at BlockTNT class. if (block instanceof BlockTNT) { ((BlockTNT) block).explode(worldIn, pos, state, igniter); } And now go learn java.
-
RenderWorldLastEvent or RenderGameOverlayEvent is maybe what you're after.
-
This is somehow hard to explain if one doesn't know what I mean. Let's say there are 3 states of mod: 1- In-Dev as a fully decompiled code working with fully decompiled minecraft and LOGICAL method names. 2- Compiled using "build" and ready-to-use by obfuscated minecraft.jar (the one in .minecraft, launched by launcher). 3- Running and loaded by forge. Tho I have no idea how it actually works, I am kinda on track with what I see. Let's take a code: How it looks in eclipse: ItemSword testSword = new ItemSword(...); testSword.onHit(...); When you compile mod: ItemSword testSword = new ItemSword(...); testSword.func_34252_f(...); //Not actual name And then suddenly minecraft happens and ItemSword.class is obfuscated to some "xyz" and and onHit(...) to some other WUT (say "bba") stuff. xyz testSword = new xyz(...); testSword.bba(...) Now what I am looking for is the state of minecraft.jar (library) that is NOT totally decompiled, but uses this mid-phase (2nd example) which contains real-names classes (like itemSword) and SRG names used by forge. The ONLY thing I could find inside my workspace (aside from other .jars that contain .java files, not .class) is: ...workspace\build\tmp\deobfuscateJar\deobfed.jar Everything would be cool (it actually has this mid-phase naming (ItemSword and testSword.func_34252_f(...) for example) if not for the fact that it doesn't have forge injected in it. Is there a way to get ahold of this particualar library? I know that working-jar is being "generated" by Loaders and actually mods are translated into minecraft names on startup, so the question is actually how to make a library like it. I REALLY need it. EDIT: Since for about few hours of putting together different files and seraching web I didn't find anything I though - maybe I could dump (extract) JVM loaded classes into one .jar, that is not really my field of knowledge, but would that work? Like literally get all loaded classes and throw them into single .jar just to get working library?
-
[1.8]Is posible to write nbtTags in onUsingTick() method ?? bug?
Ernio replied to perromercenary00's topic in Modder Support
Aside from the fact that is the worst way of animating, you shouldn't be using try/catch. NBTTagCompound tag = stack.getTagCompound(); if (tag == null) tag = new NBTTagCompound(); // Do your stuff. Other than that I don't really see anything out of ordinary that could cause problems. Your operations SEEM valid (not very good tho, animating should be done by client and rendering engine, not data manipulation). -
You shouldn't be manipulating world values. This value (worldTime) is not actually used much in vanilla, but still someone might be using it in mod. Simply do: time % 24000L, don't set it. And btw.: What description? (There is nothing that says it should)
-
I doubt it is conventionally possible. I have some idea for workaround with caching data, but idk if it will be 100% comp with all mods: If you are interested: Since player mines one block at the time, you can save WeakHashMap<EntityPlayer, BlockPos> and WeakHashMap<BlockPos, Float> (all server-side). You will want to put EntityPlayer to 1st map on start of BreakSpeed with the pos of block mined. Then count Float for given pos and put it into 2nd map. And do this all only if pos != saved pos. Then use those keys. Bad thing here: If 2 players will start mining same block it will override. So ou have to figure something for it. (extend BlockPos as TreeBlockPos and add reference to EntityPlayer (owner of block being mined) and just check if he's not the same, ofc HashMap will be then WeakHashMap<TreeBlockPos, Float>). EDIT: Tho I am proposing Weak references I don't think they will always be predictable, better check how your map expands and if it really is "weak" (removes not used obj). Ofc. we are talking about 2nd map, 1st one has only one entry per player so I wound't worry. "After breaking a log the BreakSpeed wont stop getting called." You mean it is being called even if you are not mining anything?