-
Posts
1689 -
Joined
-
Last visited
-
Days Won
1
Everything posted by SanAndreaP
-
I now made it with a tick handler. It works like a charm. You know the code you did in your bow? You don't need that. Create a client-side tick handler with TickType RENDER, then go to the tickStart method, check if it's TickType.RENDER, the player is using an item and if the used item ID equals with your bow. If yes, execute the method from the proxy.
-
I now made it with a tick handler. It works like a charm. You know the code you did in your bow? You don't need that. Create a client-side tick handler with TickType RENDER, then go to the tickStart method, check if it's TickType.RENDER, the player is using an item and if the used item ID equals with your bow. If yes, execute the method from the proxy.
-
It's because the zoom tries to reset every time. I have to improve this stuff (or wait for a hack, or make one myself and do a PR to Forge)
-
It's because the zoom tries to reset every time. I have to improve this stuff (or wait for a hack, or make one myself and do a PR to Forge)
-
The first thing you should do is swapping those around: MinecraftForge.setBlockHarvestLevel(TradeStation, "Pickaxe", 2); TradeStation = (new TradeStation(TradeStationID)); You can't register the harvest level to a null reference.
-
The first thing you should do is swapping those around: MinecraftForge.setBlockHarvestLevel(TradeStation, "Pickaxe", 2); TradeStation = (new TradeStation(TradeStationID)); You can't register the harvest level to a null reference.
-
hm, now that you say it... I don't know It has the value 0.1F in the EntityPlayer class and I don't see any modification to that value, so I guess you can use the actual value
-
hm, now that you say it... I don't know It has the value 0.1F in the EntityPlayer class and I don't see any modification to that value, so I guess you can use the actual value
-
http://www.minecraftforge.net/forum/index.php/topic,7773.msg39517.html#msg39517
-
http://www.minecraftforge.net/forum/index.php/topic,7773.msg39517.html#msg39517
-
I did it as following: 1. In your bow, override the onUsingItemTick method 2. Create a method in your CommonProxy class, which can hold the ItemStack, the Player and the count parameter from the above overridden method as its own parameters (here I call it onBowFOVZoom): onBowFOVZoom(ItemStack stack, EntityPlayer player, int count) 3. call the proxy method created before in your onUsingItemTick method, like this: MyMod.proxy.onBowFOVZoom(stack, player, count); 4. Leave the method onBowFOVZoom in your CommonProxy blank, go to the ClientProxy and override that method there, here will be the neccessary code 5. copy the code inside the getFOVMultiplier() method (except the return statement) and paste it in the ClientProxy FOV method. Replace every "this" with the player parameter. WARNING: You need Reflection to access the speedOnGround variable. Here I suggest you use the ObfuscationReflectionHelper class. To access the field, do this: float speedOnGround = ObfuscationReflectionHelper.getPrivateValue(EntityPlayer.class, player, "speedOnGround", "field_71108_cd"); The parameters are as following: Class to access - instance to access - decompiled variable name (for usage inside MCP) - "SRG-name" (for usage outside MCP, as an actual mod). float f1 = (float)i / 20.0F; This line determines how many ticks the bow needs to be fully charged. If your bow needs only 10 ticks, change the last float to 10F, if it needs 40, then to 40F. get it? 6. Go into the EntityRenderer class and find the method called "updateFovModifierHand()". Copy its code below the code you've already copied inside your ClientProxy method. But don't copy the first if-else statement, you don't need that. The block you would need is this one: this.fovModifierHand += (this.fovMultiplierTemp - this.fovModifierHand) * 0.5F; if (this.fovModifierHand > 1.5F) { this.fovModifierHand = 1.5F; } if (this.fovModifierHand < 0.1F) { this.fovModifierHand = 0.1F; } this.fovModifierHand and this.fovMultiplierTemp are private in EntityRenderer. this.fovMultiplierTemp is just the float variable f inside your method, so replace this.fovMultiplierTemp with f. Now you need some more Reflection. Get the current fovModifierHand from the EntityRenderer instance you get with Minecraft.getMinecraft().entityRenderer _before_ the block this.fovModifierHand += (this.fovMultiplierTemp - this.fovModifierHand) * 0.5F; like this: float fovModifierHand = ObfuscationReflectionHelper.getPrivateValue(EntityRenderer.class, Minecraft.getMinecraft().entityRenderer, "fovModifierHand", "field_78507_R"); You see how I used the ObfuscationReflectionHelper class again? After doing that, you can remove every "this." in front of every fovModifierHand reference. 7. Now the final step: set the calculated FOV to the actual fovModifierHand variable inside Minecrafts EntityRenderer instance. To do this, use the ObfuscationReflectionHelper class again, but instead of getting a private value, you set one: ObfuscationReflectionHelper.setPrivateValue(EntityRenderer.class, Minecraft.getMinecraft().entityRenderer, fovModifierHand, "fovModifierHand", "field_78507_R"); Note that this is really hacky and somehow "ugly", since the code is called every tick, but it works quite well and it doesn't impact the performance (I didn't noticed any difference, you have to test it out for yourself though). Also you have to keep track of variable name changes when you use the ObfuscationReflectionHelper, since inside the MCP environment, those name changes. The SRG-names are very unlikely to change, so you don't have to keep track on them as much as for the deobf-names. But nevertheless, you should test your stuff first before you publish your mod, not that the users get crashes
-
I did it as following: 1. In your bow, override the onUsingItemTick method 2. Create a method in your CommonProxy class, which can hold the ItemStack, the Player and the count parameter from the above overridden method as its own parameters (here I call it onBowFOVZoom): onBowFOVZoom(ItemStack stack, EntityPlayer player, int count) 3. call the proxy method created before in your onUsingItemTick method, like this: MyMod.proxy.onBowFOVZoom(stack, player, count); 4. Leave the method onBowFOVZoom in your CommonProxy blank, go to the ClientProxy and override that method there, here will be the neccessary code 5. copy the code inside the getFOVMultiplier() method (except the return statement) and paste it in the ClientProxy FOV method. Replace every "this" with the player parameter. WARNING: You need Reflection to access the speedOnGround variable. Here I suggest you use the ObfuscationReflectionHelper class. To access the field, do this: float speedOnGround = ObfuscationReflectionHelper.getPrivateValue(EntityPlayer.class, player, "speedOnGround", "field_71108_cd"); The parameters are as following: Class to access - instance to access - decompiled variable name (for usage inside MCP) - "SRG-name" (for usage outside MCP, as an actual mod). float f1 = (float)i / 20.0F; This line determines how many ticks the bow needs to be fully charged. If your bow needs only 10 ticks, change the last float to 10F, if it needs 40, then to 40F. get it? 6. Go into the EntityRenderer class and find the method called "updateFovModifierHand()". Copy its code below the code you've already copied inside your ClientProxy method. But don't copy the first if-else statement, you don't need that. The block you would need is this one: this.fovModifierHand += (this.fovMultiplierTemp - this.fovModifierHand) * 0.5F; if (this.fovModifierHand > 1.5F) { this.fovModifierHand = 1.5F; } if (this.fovModifierHand < 0.1F) { this.fovModifierHand = 0.1F; } this.fovModifierHand and this.fovMultiplierTemp are private in EntityRenderer. this.fovMultiplierTemp is just the float variable f inside your method, so replace this.fovMultiplierTemp with f. Now you need some more Reflection. Get the current fovModifierHand from the EntityRenderer instance you get with Minecraft.getMinecraft().entityRenderer _before_ the block this.fovModifierHand += (this.fovMultiplierTemp - this.fovModifierHand) * 0.5F; like this: float fovModifierHand = ObfuscationReflectionHelper.getPrivateValue(EntityRenderer.class, Minecraft.getMinecraft().entityRenderer, "fovModifierHand", "field_78507_R"); You see how I used the ObfuscationReflectionHelper class again? After doing that, you can remove every "this." in front of every fovModifierHand reference. 7. Now the final step: set the calculated FOV to the actual fovModifierHand variable inside Minecrafts EntityRenderer instance. To do this, use the ObfuscationReflectionHelper class again, but instead of getting a private value, you set one: ObfuscationReflectionHelper.setPrivateValue(EntityRenderer.class, Minecraft.getMinecraft().entityRenderer, fovModifierHand, "fovModifierHand", "field_78507_R"); Note that this is really hacky and somehow "ugly", since the code is called every tick, but it works quite well and it doesn't impact the performance (I didn't noticed any difference, you have to test it out for yourself though). Also you have to keep track of variable name changes when you use the ObfuscationReflectionHelper, since inside the MCP environment, those name changes. The SRG-names are very unlikely to change, so you don't have to keep track on them as much as for the deobf-names. But nevertheless, you should test your stuff first before you publish your mod, not that the users get crashes
-
There was an Error when starting up Minecraft.
SanAndreaP replied to Buildex15's topic in Support & Bug Reports
Install Optifine AFTER Forge. -
There was an Error when starting up Minecraft.
SanAndreaP replied to Buildex15's topic in Support & Bug Reports
Install Optifine AFTER Forge. -
Maybe it has changed in a newer Version of Forge. I have to look into this...
-
What you should have is following: - Have an own Item class (here ItemMyCompass) - Have an own TextureStitched class (here TextureMyCompass, you can copy the code from the TextureCompass class and change the stuff in that code, it's what I did) Seems like you have both. In order to "bind" the TextureStitched to your item, do these lines of code in your updateIcons method (if you don't have one, create and override one): Minecraft.getMinecraft().renderEngine.textureMapItems.setTextureEntry("playercompass:playercompass", new TextureMyCompass()); this.iconIndex = TextureMyCompass.compassTexture; The first line registers the TextureStitched to Minecraft and binds the right texture for it. "playercompass:playercompass" is the string you would also normally use when you register an "ordinary" texture The second line grabs the newly created instance from the custom TextureStitched class and assigns it to the texture field of the Item.
-
Porting my mod (Does Forge have what it needs?)
SanAndreaP replied to Dayanto's topic in Modder Support
Ok, I'll keep looking. (Is this what you mean by asm?) Out of the three, I was pretty much expecting the hook to exist. (I had to know for sure though) The other two however are my main concern. If you happen to know anything about them, it would help a lot. Edit: I rewrote the original post a bit to make it clearer. For the first issue, you can use the ITickHandler (or the IScheduledTickHandler). Just set its TickType to TickType.RENDER and register it on the Client-side! Here's a tutorial on how to create one: -
Well you can pack the streaming stuff in your mod and copy it from the classpath into the file system. I made it like this: [*]Get the file from the streaming folder and check if it exists and is valid [*]If it's valid, register it [*]If not, get the InputStream from your streaming file in your classpath like this: InputStream is = MyMod.class.getClassLoader().getResourceAsStream("mod/streaming/file.ogg"); // The file is under Minecraft/src/mod/streaming/file.ogg [*]check if the InputStream is not null and write the InputStream to the streaming folder [*]check if the new file is created and valid [*]If it's valid, register it [*]If not, either print a warning or throw an exception (I would rather go for the first one)
-
You need an IItemRenderer to get it to work.
-
where do you want to use your code? Can I see what you've got so far?
-
hm, I will give you some code to get a List of all entities: First make a right AABB: AxisAlignedBB bb = AxisAlignedBB.getBoundingBox(this.posX - 16, this.posY, this.posZ - 16, this.posX + 16, this.posY + 16, this.posZ + 16); 'this' is the entity instance which you want to be at the center (for example the player if you wanna check if there are entities around it) Next thing you do is to get a list of entities inside that bounding box. You have two possibillities: List<EntityCreeper> entities = worldObj.getEntitiesWithinAABB(EntityCreeper.class, bb); This will give you all entities which classes are equal to or are extending the class given (here you will get all entities which have EntityCreeper as a class or extend this class). This works also for interfaces (for example if you use IMob.class as parameter, it'll give you all entities which implement IMob, like Creepers, Zombies, Slimes etc). List entities = worldObj.getEntitiesWithinAABBExcludingEntity(EntityPlayer.class, bb); This will give you all entities (also paintings, arrows, fireballs etc.), so you have to check what entity it is when you iterate over the list. The class parameter in this will determine which entities won't be recognized, here the EntityPlayer. As above the rule is: Each entity which it's class is equal, extending or implementing the parameter class, will be excluded from the list. Now the rest you have to figure out yourself. If you have any questions or errors, post them.
-
Minor help needed. [Solved and fixed code given]
SanAndreaP replied to xXRoboJackXx's topic in Modder Support
Thanks but the par1World.editingBlocks = true; Is still not working. Thanks for the function one though, if anyone knows what I'm doing wrong on ^^ please tell me. Fixed it I was being a complete idiot sorry. Thanks everyone and how? -
I thought of something different, sorry. Well, if you want to edit the drops, you need to have a LivingDropsEvent, check if the entity is an instanceof EntityPlayer and if so, add new EntityItems to the event.drops list which are holding ItemStacks with your Items.