Trajectory989 Posted July 7, 2017 Posted July 7, 2017 I am incredibly new to modding and inexperienced in Java. I worked with a lot of event based JavaScript and some C before, but modding mc is a totally different animal. That said, common sense and reading having taken me to grasp the basics, but I am wanting to go a little beyond that. I have created a block with its purpose to be like dirt; I want the effective tool to be a shovel, but I want it to still drop itself when mined by hand. setHarvestLevel() I think can be used with an onBlockHarvested() event that spawns itself in, but lack of experience leads me to not know how to implement this or if that idea is even a good one. Quote
Jay Avery Posted July 7, 2017 Posted July 7, 2017 If you're making your own block class, it's easiest not to use events. Everything you want to do can be controlled in the block class itself if you are writing it. If you want your block to be almost the same as an existing vanilla block, the very easiest thing to do is extend the vanilla class and only make the changes you need. Quote
Trajectory989 Posted July 7, 2017 Author Posted July 7, 2017 (edited) 13 minutes ago, Jay Avery said: If you're making your own block class, it's easiest not to use events. Everything you want to do can be controlled in the block class itself if you are writing it. If you want your block to be almost the same as an existing vanilla block, the very easiest thing to do is extend the vanilla class and only make the changes you need. I thank you very much for your reply, especially for how prompt it was. However, changing my block to extend BlockDirt has caused it to loose its texture on the ground and the block is still unresponsive to tool effectiveness (hand mines as fast as wood shovel which is as fast as a gold shovel). Any more ideas that still keep the hand harvestability? Edited July 7, 2017 by Trajectory989 clarification Quote
Trajectory989 Posted July 7, 2017 Author Posted July 7, 2017 package com.Trajectory989.Ender_Expansion.blocks; import com.Trajectory989.Ender_Expansion.VariablesNJunk; import net.minecraft.block.Block; import net.minecraft.block.BlockDirt; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.item.Item; import net.minecraft.world.World; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; public class BlockProfanePutrefaction extends BlockDirt { public BlockProfanePutrefaction() { setUnlocalizedName(VariablesNJunk.EnderExpansionBlocks.PROFANEPUTREFACTION.getUnlocalizedName()); setRegistryName(VariablesNJunk.EnderExpansionBlocks.PROFANEPUTREFACTION.getRegistryName()); setHardness(1.0F); setResistance(7.0F); } } I know there are a lot of imports....that is from previous attempts. BlockProfanePutrefaction.java Quote
Draco18s Posted July 7, 2017 Posted July 7, 2017 The block doesn't control texture and model. The json files and the registry name do. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
V0idWa1k3r Posted July 7, 2017 Posted July 7, 2017 51 minutes ago, Trajectory989 said: public BlockProfanePutrefaction() { setUnlocalizedName(VariablesNJunk.EnderExpansionBlocks.PROFANEPUTREFACTION.getUnlocalizedName()); setRegistryName(VariablesNJunk.EnderExpansionBlocks.PROFANEPUTREFACTION.getRegistryName()); setHardness(1.0F); setResistance(7.0F); } You are missing a super call at this constructor. Quote
Trajectory989 Posted July 7, 2017 Author Posted July 7, 2017 the super call was removed when I changed it to extend BlockDirt. Before it called Material.GROUND. and json files were properly configured before I changed the block to extend BlockDirt....the texture problem arised from changing that. Quote
V0idWa1k3r Posted July 7, 2017 Posted July 7, 2017 2 minutes ago, Trajectory989 said: the super call was removed when I changed it to extend BlockDirt. You still need it regardless of your parent class. Otherwise a lot of things are not set, such as the default blockstate which indirectly controls the texture and the model, or the material which indirectly controls break speed with tools... Quote
Trajectory989 Posted July 7, 2017 Author Posted July 7, 2017 adding super(Material.GROUND); results in an error which fails the mod during pre-initialization. It also shows up as an error in eclipse. Eclipse corrects it to simply super(); in which case there is no change...still a texture problem and unresponsiveness to tool efficiency. Quote
V0idWa1k3r Posted July 7, 2017 Posted July 7, 2017 1 minute ago, Trajectory989 said: Eclipse corrects it to simply super(); in which case there is no change...still a texture problem and unresponsiveness to tool efficiency. This is the correct way. Please show the code where you initialize your block and the edited block class's constructor. Quote
Trajectory989 Posted July 7, 2017 Author Posted July 7, 2017 (edited) package com.Trajectory989.Ender_Expansion.init; import com.Trajectory989.Ender_Expansion.blocks.BlockCorruptStone; import com.Trajectory989.Ender_Expansion.blocks.BlockProfanePutrefaction; import com.Trajectory989.Ender_Expansion.blocks.BlockSaturatedAsh; import com.Trajectory989.Ender_Expansion.items.ItemViscousTenevris; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraftforge.fml.common.registry.GameRegistry; public class ModBlocks { public static Block saturatedAsh; public static Block corruptStone; public static Block profanePutrefaction; public static void init() { saturatedAsh = new BlockSaturatedAsh(ModItems.viscousTenevris, 1, 5); corruptStone = new BlockCorruptStone(); profanePutrefaction = new BlockProfanePutrefaction(); } public static void register() { registerBlock(saturatedAsh); registerBlock(corruptStone); registerBlock(profanePutrefaction); } private static void registerBlock(Block block) { GameRegistry.register(block); ItemBlock item = new ItemBlock(block); item.setRegistryName(block.getRegistryName()); GameRegistry.register(item); } public static void registerRenders() { registerRender(saturatedAsh); registerRender(corruptStone); registerRender(profanePutrefaction); } private static void registerRender(Block block) { Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), "inventory")); } } this is the class where I initialize my blocks, I believe. Else it would be here: package com.Trajectory989.Ender_Expansion; public class VariablesNJunk { public static final String MOD_ID = "leedle"; public static final String NAME = "Ender Expansion"; public static final String VERSION = "pleb (1.0.0)"; public static final String ACCEPTED_VERSIONS = "[1.11.2]"; public static final String CLIENT_PROXY_CLASS = "com.Trajectory989.Ender_Expansion.proxy.ClientProxy"; public static final String SERVER_PROXY_CLASS = "com.Trajectory989.Ender_Expansion.proxy.ServerProxy"; public static final String COMMON_PROXY_CLASS = "com.Trajectory989.Ender_Expansion.proxy.CommonProxy"; public static enum EnderExpansionItems { VISCOUSTENEVRIS("viscousTenevris", "ItemViscousTenevris"), INGOTTENEVRIS("ingot_Tenevris", "ItemIngotTenevris"); private String unlocalizedName; private String registryName; EnderExpansionItems(String unlocalizedName, String registryName) { this.unlocalizedName = unlocalizedName; this.registryName = registryName; } public String getUnlocalizedName() { return unlocalizedName; } public String getRegistryName() { return registryName; } } public static enum EnderExpansionBlocks { SATURATEDASH("saturatedAsh", "BlockSaturatedAsh"), CORRUPTSTONE("corruptStone", "BlockCorruptStone"), PROFANEPUTREFACTION("profanePutrefaction", "BlockProfanePutrefaction"); private String unlocalizedName; private String registryName; EnderExpansionBlocks(String unlocalizedName, String registryName) { this.unlocalizedName = unlocalizedName; this.registryName = registryName; } public String getUnlocalizedName() { return unlocalizedName; } public String getRegistryName() { return registryName; } } } the rest of my source can be found in the provided zip. I have it left with super(Material.GROUND); so there is a fatal error there still. Source.zip Edited July 7, 2017 by Trajectory989 Quote
V0idWa1k3r Posted July 7, 2017 Posted July 7, 2017 (edited) 23 minutes ago, Trajectory989 said: PROFANEPUTREFACTION("profanePutrefaction", "BlockProfanePutrefaction"); 23 minutes ago, Trajectory989 said: EnderExpansionBlocks(String unlocalizedName, String registryName) registry names must be entirely lower case. GameRegistry.register is outdated. You should use registry events. ItemModelMesher is outdated and buggy, never use it. You should use ModelLoader in the approptiate ModelRegistryEvent instead. Or at least do it in pre-init and not init. Your BlockProfanePutrefaction still uses incorrect super call in the code you've attached. Your version is invalid. See this. BlockDirt specifies additional variants to your blockstate, but your json does not contain them. You will need to either override all methods that use them and noop them or choose a different class to extend, like Block. If you want a tool to be effective agains a certain block in that block's constructor you can use Block::setHarvestLevel. The first parameter is a tool class, for a shovel it is "shovel", the second parameter is the harvest level. You can leave it at 0. As it is the material by default that determines whether the block is harvestable by hand or not the GROUND material will still make your block harvestable by hand even if you call this method. Edited July 7, 2017 by V0idWa1k3r Quote
Trajectory989 Posted July 7, 2017 Author Posted July 7, 2017 I have something going on for the next week so it wont be for a while until I can make the adjustments, but thank you. All of you. I'm sure these changes have a high probability of fixing the problem, but if for any reason they do not, I will probably be posting back here in a little over a week. Thank you for all of your time and consideration. Quote
Catwolf Posted July 13, 2017 Posted July 13, 2017 If you're having issues still, I believe if you set the harvest level to -1 it can be mined with hands and you can set the effective tool still. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.