Jump to content

Recommended Posts

Posted

Hi so before I started using forge to make my mod pack I used MCP Which allowed me to make mods by base editing. However my mods would only work for the sever and I could not do all the things I wanted to do. So I started using forge so I could do more and make my mods work on both server and client. The thing is now I need to know how I can override base minecraft code with forge so I can include my old mods in to my new mod pack. Some of my mods include making glass drop its self when destroyed with out a silktouch pickaxe, making a boat drop 5 planks if it smashes in to something that causes it to break so you can re-make i with ease, making some of the mobs drop more Xp when killed, making some of the command names shorter for faster typing them, and allowing people in survival mode to fly. How can I override base minecraft code so I can bring my old mods to work with forge?

Posted

In my experiences I've seen other mods that create their own versions of those things. For example "MyBoat" which extends the vanilla class and/or whatnot except that it drops as you desire. There are implications about how it gets crafted and so forth, I guess.

 

Alternatively, I just started playing with it, you can investigate "MinecraftForge.EVENT_BUS" and perhaps there's an event you can listen for and, to it, respond as you desire when the situation merits.

 

Were I you I would steer clear of overriding the base Minecraft code since who knows when/if/what will change from release to release. IMO, that's not the way to go and is, in fact, what Forge helps establish (that is, a means to make mods work release to release as much as possible with less impact).

 

I am not sure if that helps except to provide some avenues to explore, and maybe others have better ideas, too :)

Posted
  On 8/19/2014 at 9:46 PM, KeeperofMee said:

All the mods you had are possible to easily recreate in forge without base edits.

 

Ok then but how would I go about doing that? So lets start with the glass drop mod how can I tell minecraft to make glass drop itself when mined with out silk touch? Also, how would I make obsidian quicker to mine?

Posted

Ok. So to do that would I go in my main mod class and do this?

 

@EventHandler

public void (BlockEvent.BreakEvent event)

 

If so then what would I do? And where is it that I can read about forge events?

 

 

Posted
  On 8/21/2014 at 6:12 PM, tminor1 said:

Ok. So to do that would I go in my main mod class and do this?

 

@EventHandler

public void (BlockEvent.BreakEvent event)

 

If so then what would I do? And where is it that I can read about forge events?

 

No, the @EventHandler is for certain types of events, but not the BreakEvent.  You can read more to understand better my tutorial here: http://jabelarminecraft.blogspot.com/p/minecraft-forge-172-event-handling.html

 

 

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

Ok lets start over. I believe I will understand better if some one can give me an example. So lets do the glass drop mod. Can someone give me an example of how I would make glass drop itself when broken without silcktouch?

Posted

If you're searching for copy->paste code, you won't find it here

 

If there's been a plethora of links posted so far, if you can't figure it out from them, you need to learn java some more before you attempt making mods.

 

Use an IDE (like Eclipse), and try some code out for yourself.

 

No-one here will give you code to paste, as we aren't making the mods for you.

 

Posted
  On 8/24/2014 at 2:36 AM, Tslat said:

If you're searching for copy->paste code, you won't find it here

 

If there's been a plethora of links posted so far, if you can't figure it out from them, you need to learn java some more before you attempt making mods.

 

Use an IDE (like Eclipse), and try some code out for yourself.

 

No-one here will give you code to paste, as we aren't making the mods for you.

It's pretty obvious he knows how to mod since he used MCP to make base edits before forge was the standard... He wants to know how to use the event... telling someone to go find it on their own isn't helpful at all... it would be more productive if you would just take the few minutes to explain it to him since I assume you know how to do it...

Posted
  On 8/24/2014 at 1:41 PM, theOriginalByte said:

  Quote

If you're searching for copy->paste code, you won't find it here

 

If there's been a plethora of links posted so far, if you can't figure it out from them, you need to learn java some more before you attempt making mods.

 

Use an IDE (like Eclipse), and try some code out for yourself.

 

No-one here will give you code to paste, as we aren't making the mods for you.

It's pretty obvious he knows how to mod since he used MCP to make base edits before forge was the standard... He wants to know how to use the event... telling someone to go find it on their own isn't helpful at all... it would be more productive if you would just take the few minutes to explain it to him since I assume you know how to do it...

 

But we literally gave him 5 links on how to use events, all of which have plenty of examples!  I already took the time to write several pages of explanation in my tutorial linked above so I don't have to write it over and over again each time someone asks the same questions.

 

Basically we're saying "we've already written you pages and pages of explanation".  Go read it and try something.  Then we'll be willing to help.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

Ok well I tried to make something work but can't figure it out.

 

package net.Cristalore.mod;

import net.minecraftforge.event.world.BlockEvent;

public class glassDrop {

@ForgeSubscribe
public void blockBreak(BlockEvent.BreakEvent event)
{

}

 

It says that @ForgeSubscribe cannot be resolved to a type. I am trying to make the glassDrop mod.

Posted

Would something like this work? I tried to do this and minecraft crashed. Am I on the right track or have I just completely messed up?

 

  Reveal hidden contents

 

Posted

Well the break block event handler method shouldn't be in your actual block, but instead probably best to make an event handler class and put it in there.  Because the break block event will be fired for EVERY block that breaks.  So what you need to do in that method is check which block got broken and then proceed from there.

 

The event handling code there shouldn't crash things (it doesn't even do anything).  So it must be something else. What is the crash log say?

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

Well as for making a class file for the event that is what I was trying to do and the reason I have the part of the code for the glass in there is because I didn't know what I needed to do to make it check to see if you destroyed a glass block and there for drop a glass block. as for the crash report here it is.

 

  Reveal hidden contents

 

Posted

Hey by any chance is this doing anything?

package net.Cristalore.mod;

import java.util.Random;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.block.BlockGlass;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraftforge.event.world.BlockEvent;

public class glassDrop  {

@SubscribeEvent
public void blockBreak(BlockEvent.BreakEvent event)
{
	if (Blocks.glass != null);
}
	public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
    {
        return Item.getItemFromBlock(Blocks.glass);
    }


}

Posted

That won't work. Try this:

 

@SubscribeEvent
public void glassDrop(BreakEvent evt){

	if (evt.block == Blocks.glass){
		EntityItem item = new EntityItem(evt.world, evt.x, evt.y, evt.z, new ItemStack(Item.getItemFromBlock(Blocks.glass)));
		EntityPlayer player = evt.getPlayer();

		if(!player.capabilities.isCreativeMode) evt.world.spawnEntityInWorld(item);
	}

}

 

That just spawns a glass item entity when a glass block is broken. Unfortunately, it would drop 2 items when broken with Silk Touch. There is probably a way to fix that with player.getHeldItem().

Check out my mod, Realms of Chaos, here.

 

If I helped you, be sure to press the "Thank You" button!

Posted
  On 8/27/2014 at 9:48 PM, Eternaldoom said:

That won't work. Try this:

 

@SubscribeEvent
public void glassDrop(BreakEvent evt){

	if (evt.block == Blocks.glass){
		EntityItem item = new EntityItem(evt.world, evt.x, evt.y, evt.z, new ItemStack(Item.getItemFromBlock(Blocks.glass)));
		EntityPlayer player = evt.getPlayer();

		if(!player.capabilities.isCreativeMode) evt.world.spawnEntityInWorld(item);
	}

}

 

That just spawns a glass item entity when a glass block is broken. Unfortunately, it would drop 2 items when broken with Silk Touch. There is probably a way to fix that with player.getHeldItem().

 

Thanks. But is there a way to not make the glass item go straight for the player causing the player to instantly pick it up and not have it fall to the ground like normal. Because that is what is happening I mine the glass block and the glass item spawns and goes to the player. If I had to I would just go with that, but I would like it to fall to the ground like normal and the player has to walk over to pick it up not it come to the player. Also, how would I make this work for if a boat crashes and breaks so I can make it drop 5 planks?

Posted

Sorry, I can't seem to make the item stay still. There is probably a way to make the boat drop 5 planks, but I'm not sure how.

Check out my mod, Realms of Chaos, here.

 

If I helped you, be sure to press the "Thank You" button!

Posted

Hey now that I have my glassDrops working I was working on more of my mods and one of things I want to do is every time a cow dies it will spawn 1 leather. I got a start on it but I am having some trouble. Can some one help me with this?

package net.glassDrops.mod;

import java.util.Random;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.block.BlockGlass;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.event.entity.living.LivingDropsEvent;


public class leatherDrop  {

@SubscribeEvent
public void giveLeather(LivingDropsEvent evt){

	if (evt.entity == Entity.Cow){
		EntityItem item = new EntityItem(evt.world, evt.x, evt.y, evt.z, new ItemStack(Items.leather));
		EntityPlayer player = evt.getPlayer();

		if(!player.capabilities.isCreativeMode) evt.world.spawnEntityInWorld(item);
	}

}}

Posted
  On 8/29/2014 at 9:28 PM, tminor1 said:

Hey now that I have my glassDrops working I was working on more of my mods and one of things I want to do is every time a cow dies it will spawn 1 leather. I got a start on it but I am having some trouble. Can some one help me with this?

package net.glassDrops.mod;

import java.util.Random;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.block.BlockGlass;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.event.entity.living.LivingDropsEvent;


public class leatherDrop  {

@SubscribeEvent
public void giveLeather(LivingDropsEvent evt){

	if (evt.entity == Entity.Cow){
		EntityItem item = new EntityItem(evt.world, evt.x, evt.y, evt.z, new ItemStack(Items.leather));
		EntityPlayer player = evt.getPlayer();

		if(!player.capabilities.isCreativeMode) evt.world.spawnEntityInWorld(item);
	}

}}

 

You have to check with instanceof, since the entity is an instance of the EntityCow

something like that if (evt.entity instanceof EntityCow){

evt.drops is a list of all the drops, so if u want the cow to ONLY spawn 1 leather, u can say evt.drops.clear();

and then add the leather it back in

evt.drops.add(new EntityItem(evt.entity.worldObj, evt.entity.posX, evt.entity.posY, evt.entity.posZ, new ItemStack(Items.leather)));

Posted

You might want to get rid of the creative mode check, since you probably want it to drop leather anyway

Check out my mod, Realms of Chaos, here.

 

If I helped you, be sure to press the "Thank You" button!

Posted
  On 8/28/2014 at 7:29 PM, tminor1 said:

  Quote

That won't work. Try this:

 

@SubscribeEvent
public void glassDrop(BreakEvent evt){

	if (evt.block == Blocks.glass){
		EntityItem item = new EntityItem(evt.world, evt.x, evt.y, evt.z, new ItemStack(Item.getItemFromBlock(Blocks.glass)));
		EntityPlayer player = evt.getPlayer();

		if(!player.capabilities.isCreativeMode) evt.world.spawnEntityInWorld(item);
	}

}

 

That just spawns a glass item entity when a glass block is broken. Unfortunately, it would drop 2 items when broken with Silk Touch. There is probably a way to fix that with player.getHeldItem().

 

Thanks. But is there a way to not make the glass item go straight for the player causing the player to instantly pick it up and not have it fall to the ground like normal. Because that is what is happening I mine the glass block and the glass item spawns and goes to the player. If I had to I would just go with that, but I would like it to fall to the ground like normal and the player has to walk over to pick it up not it come to the player. Also, how would I make this work for if a boat crashes and breaks so I can make it drop 5 planks?

To the instant pick up, I think u just have to set item.delayBeforeCanPickup to any value u wish ^^

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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