The Meaning of Life, the Universe, and Everything.
Join Date:
5/1/2015
Posts:
52
Minecraft:
RangerPJ
Member Details
Important note before we start:
I'm making these tutorials for a few reasons. There aren't a lot of tutorials for 1.8 tutorials and with the massive changed, everything is of help. This isn't meant to be step by step guide to making your first mod or everything you need to know about a certain topic. You're not going to learn to mod from copying and pasting a whole class and changing a few lines. Instead I'm going to touch on common topics and give you a starting point for you with both example code and an explanation on it in hopes that you get a firm starting point to dive more in depth to that concept. There won't be any one big project that you make so everything should be easy to fit right into your own code. Each topic will be stand alone as much as it can be. You won't find a source download either. I'm going to show you the code to start off with and then break it down line by line.
While this says beginner, were not starting from total scratch and this isn't a "My First Mod Guide". I hope you read the part above. You should have some prior knowledge to modding from 1.8 or before, and some basic java/oop knowledge. You know what overriding is, implementing, casting and abstract classes are. You are expected to have a basic mod file set up at the minimal. Were going to be using eclipse but another ide should work. These are NOT for 1.7 or before but you may be able to translate them back if you want. Stuff like blocks that got a complete redo, don't even think about it. Now we're ready!
Adding Dispenser Behavior
Adding dispenser behavior is really simple. No forge hook is needed, all we need to do is call a vanilla method:
The static method takes an item like Items.apple or, if you want a block, Item.getItemFromBlock(Blocks.planks). Let's look at an example. For this example, we are going to make the dispenser place down a stone blocks instead of dispensing it as an item.
BlockDispenser.dispenseBehaviorRegistry.putObject(Item.getItemFromBlock(Blocks.stone), new BehaviorDefaultDispenseItem() {
@Override
protected ItemStack dispenseStack(IBlockSource source, ItemStack stack) {
World world = source.getWorld();
BlockPos blockpos = source.getBlockPos().offset(BlockDispenser.getFacing(source.getBlockMetadata()));
if (world.isAirBlock(blockpos)) {
if (!world.isRemote) {
world.setBlockState(blockpos, Blocks.stone.getStateFromMeta(stack.getMetadata()), 3);
world.notifyNeighborsOfStateChange(source.getBlockPos(), source.getBlock());
}
--stack.stackSize;
}
returnstack;
}
});
The particles don't look so good, so lets remove them. Override the default particle method with this. You could even make it spawn different particles.
Be sure to register dispenser behavior in the preinit of your mod. Here are a few helpful classes:
net.minecraft.init.Bootstrap.class All vanilla dispenser behavior is added here.
net.minecraft.dispenser.BehaviorDefaultDispenseItem.class The dispenser behavior base class.
Adding behavior is the same as in 1.7 but with come change. Obviously there is not BlockPos or BlockState but you use the same methods.
Changing Dungeon Mobs
This is simple, forge has a hook for it. All you need to do is the following in preinit
DungeonHooks.addDungeonMob(mob_name, rarity);
Rarity is an int, for zombies its 200, skeletons and spiders it's 100. For the mob_name you need to find the mobs name. You can find the vanilla ones in net.minecraft.entity.EntityList at the end of the class. Hint, they should be the same as the one you use in /summon.
Removing mobs is easy to.
DungeonHooks.removeDungeonMob(mob_name);
Adding An Achievement
Adding an achievement is easy. We're going to make an achievement called Talk To Villager.
public static Achievement talkToVillager = new Achievement("achievement.talkToVillager", "talkToVillager", -2, 0, Items.emerald, AchievementList.openInventory)
Then register it with:
talkToVillager.func_180788_c();
The first two parameters that you pass in are the unlocalized names. First the name, then the description. Add this to your lang file.
achievement.talkToVillager=Villager Friend
achievement.talkToVillager.desc=Talk to a villager!
Next is the location of the achievement on the screen. After that is the item or block that goes with it. You can pass an item, block or itemStack. Finally we have the achievement you need before it. In this case, the player must have opened there inventory.
Giving the player the achievement is a little harder, a forge event is mostly the best option if a vanilla item block or mob gives it to you. You give it to them, use this code.
net.minecraft.stats.AchievementList A list of minecraft achievements and there location on the achievement screen.
More tutorials coming soon. Real soon.
Additional Tutorials:
Here are some other modding stuff that I recommend. If you have a tutorial that you think should be added, please post so in the comments but remember the following, they must be for 1.8 and not for 1.7 or before.
Don't hesitate to ask me a Forge Modding question. If you can create a thread for the question instead of a PM, so others can learn from it, and PM me the link so I can find it.
Doubtful that this will become a mod if if I make it (the mod will be simply making enderdragons able to be found in dungeons. All I need is a empty JavaScript.
DungeonHooks.addDungeonMob(enderdragon, 500)
Rollback Post to RevisionRollBack
[p]I am under you, and underground all the time...[/p]
[/p]
[/p]
:dirt: :dirt: :dirt:[/p]
:dirt: :dirt: :dirt:[/p]
:stone ::stone: [/p]
[/p]
[/p]
[/p]
[/p]
[/p]
To post a comment, please login or register a new account.
Important note before we start:
I'm making these tutorials for a few reasons. There aren't a lot of tutorials for 1.8 tutorials and with the massive changed, everything is of help. This isn't meant to be step by step guide to making your first mod or everything you need to know about a certain topic. You're not going to learn to mod from copying and pasting a whole class and changing a few lines. Instead I'm going to touch on common topics and give you a starting point for you with both example code and an explanation on it in hopes that you get a firm starting point to dive more in depth to that concept. There won't be any one big project that you make so everything should be easy to fit right into your own code. Each topic will be stand alone as much as it can be. You won't find a source download either. I'm going to show you the code to start off with and then break it down line by line.
While this says beginner, were not starting from total scratch and this isn't a "My First Mod Guide". I hope you read the part above. You should have some prior knowledge to modding from 1.8 or before, and some basic java/oop knowledge. You know what overriding is, implementing, casting and abstract classes are. You are expected to have a basic mod file set up at the minimal. Were going to be using eclipse but another ide should work. These are NOT for 1.7 or before but you may be able to translate them back if you want. Stuff like blocks that got a complete redo, don't even think about it. Now we're ready!
Adding Dispenser Behavior
Adding dispenser behavior is really simple. No forge hook is needed, all we need to do is call a vanilla method:
The static method takes an item like Items.apple or, if you want a block, Item.getItemFromBlock(Blocks.planks). Let's look at an example. For this example, we are going to make the dispenser place down a stone blocks instead of dispensing it as an item.
BlockDispenser.dispenseBehaviorRegistry.putObject(Item.getItemFromBlock(Blocks.stone), new BehaviorDefaultDispenseItem() { @Override protected ItemStack dispenseStack(IBlockSource source, ItemStack stack) { World world = source.getWorld(); BlockPos blockpos = source.getBlockPos().offset(BlockDispenser.getFacing(source.getBlockMetadata())); if (world.isAirBlock(blockpos)) { if (!world.isRemote) { world.setBlockState(blockpos, Blocks.stone.getStateFromMeta(stack.getMetadata()), 3); world.notifyNeighborsOfStateChange(source.getBlockPos(), source.getBlock()); } --stack.stackSize; } returnstack; } });The particles don't look so good, so lets remove them. Override the default particle method with this. You could even make it spawn different particles.
@Override protectedvoid spawnDispenseParticles(IBlockSource source, EnumFacing facingIn) {}Removing or changing the sound is simple. Override this method.
@Override protectedvoid playDispenseSound(IBlockSource source) {}Replacing vanilla behavior is also easy. Just register your behavior with the item you want.
Be sure to register dispenser behavior in the preinit of your mod. Here are a few helpful classes:
net.minecraft.init.Bootstrap.class All vanilla dispenser behavior is added here.
net.minecraft.dispenser.BehaviorDefaultDispenseItem.class The dispenser behavior base class.
Adding behavior is the same as in 1.7 but with come change. Obviously there is not BlockPos or BlockState but you use the same methods.
Changing Dungeon Mobs
This is simple, forge has a hook for it. All you need to do is the following in preinit
Rarity is an int, for zombies its 200, skeletons and spiders it's 100. For the mob_name you need to find the mobs name. You can find the vanilla ones in net.minecraft.entity.EntityList at the end of the class. Hint, they should be the same as the one you use in /summon.
Removing mobs is easy to.
Adding An Achievement
Adding an achievement is easy. We're going to make an achievement called Talk To Villager.
public static Achievement talkToVillager = new Achievement("achievement.talkToVillager", "talkToVillager", -2, 0, Items.emerald, AchievementList.openInventory)Then register it with:
The first two parameters that you pass in are the unlocalized names. First the name, then the description. Add this to your lang file.
achievement.talkToVillager=Villager Friend
achievement.talkToVillager.desc=Talk to a villager!
Next is the location of the achievement on the screen. After that is the item or block that goes with it. You can pass an item, block or itemStack. Finally we have the achievement you need before it. In this case, the player must have opened there inventory.
Giving the player the achievement is a little harder, a forge event is mostly the best option if a vanilla item block or mob gives it to you. You give it to them, use this code.
Here are some helpful classes:
net.minecraft.stats.AchievementList A list of minecraft achievements and there location on the achievement screen.
More tutorials coming soon. Real soon.
Additional Tutorials:
Here are some other modding stuff that I recommend. If you have a tutorial that you think should be added, please post so in the comments but remember the following, they must be for 1.8 and not for 1.7 or before.
Common mistakes in blocks with variants:
http://greyminecraftcoder.blogspot.com.au/2015/05/common-mistakes-in-blocks-with-variants.html
Be sure to ask any questions you have or give a suggestion or request.
Don't hesitate to ask me a Forge Modding question. If you can create a thread for the question instead of a PM, so others can learn from it, and PM me the link so I can find it.
Tutorial on custom book, with information and pictures. Gui with pages
Tutorial on custom potion effect.
Basics with server mods(proxies, initialization, registration, gui, tile entitys)
Doubtful that this will become a mod if if I make it (the mod will be simply making enderdragons able to be found in dungeons. All I need is a empty JavaScript.
DungeonHooks.addDungeonMob(enderdragon, 500)