Jump to content

Recommended Posts

Posted

Hey guys, I'm a brand new modder and I am having trouble with this. Minecraft will crash after I finish up the genericBlock.

(I am using eclipse)

Here's my code, the parts highlighted in red are what eclipse show as wrong.

 

 

 

 

Generic.java

 

 

 

 

package tutorial.generic;

 

import cpw.mods.fml.common.Mod;

import cpw.mods.fml.common.Mod.Init;

import cpw.mods.fml.common.Mod.Instance;

import cpw.mods.fml.common.Mod.PostInit;

import cpw.mods.fml.common.Mod.PreInit;

import cpw.mods.fml.common.SidedProxy;

import cpw.mods.fml.common.event.FMLInitializationEvent;

import cpw.mods.fml.common.event.FMLPostInitializationEvent;

import cpw.mods.fml.common.event.FMLPreInitializationEvent;

import cpw.mods.fml.common.network.NetworkMod;

 

@Mod(modid="Generic", name="Generic", version="0.0.0")

@NetworkMod(clientSideRequired=true, serverSideRequired=false)

public class Generic {

 

        // The instance of your mod that Forge uses.

        @Instance("Generic")

        public static Generic instance;

       

        // Says where the client and server 'proxy' code is loaded.

        @SidedProxy(clientSide="tutorial.generic.client.ClientProxy", serverSide="tutorial.generic.CommonProxy")

        public static CommonProxy proxy;

       

        @PreInit

        public void preInit(FMLPreInitializationEvent event) {

                // Stub Method

        }

       

        @Init

        public void load(FMLInitializationEvent event)

        {

                proxy.registerRenderers();

               

              [glow=red,2,300] GameRegistry.registerBlock(genericDirt, "genericDirt");

                LanguageRegistry.addName(genericDirt, "Generic Dirt");

                MinecraftForge.setBlockHarvestLevel(genericDirt, "shovel", 0);[/glow]

        }

       

        @PostInit

        public void postInit(FMLPostInitializationEvent event) {

                // Stub Method

        }

}

 

 

 

 

 

GenericBlock.java

 

 

 

 

package tutorial.generic;

 

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

 

public class GenericBlock extends Block {

 

        public GenericBlock (int id, int texture, Material material) {

                super(500, material.ground);

        }

       

        @Override

        [glow=red,2,300]public void registerIcons(IconRegister iconRegister) {[/glow]

                this.blockIcon = iconRegister.registerIcon("generic:generic");

        }

 

}

 

 

 

 

 

Block.java

 

 

 

 

package net.minecraft.block;

    /**

    * Flag if block ID should use the brightest neighbor light value as its own

    */

    public static boolean[] useNeighborBrightness = new boolean[4096];

    public static final Block stone = (new BlockStone(1)).setHardness(1.5F).setResistance(10.0F).setStepSound(soundStoneFootstep).setUnlocalizedName("stone");

    public static final BlockGrass grass = (BlockGrass)(new BlockGrass(2)).setHardness(0.6F).setStepSound(soundGrassFootstep).setUnlocalizedName("grass");

    public static final Block dirt = (new BlockDirt(3)).setHardness(0.5F).setStepSound(soundGravelFootstep).setUnlocalizedName("dirt");

[glow=green,2,300]    public final static Block genericDirt = (new GenericBlock(500)).setHardness(0.5F).setStepSound(soundGravelFootstep).setUnlocalizedName("genericDirt");[/glow]

    public static final Block cobblestone = (new Block(4, Material.rock)).setHardness(2.0F).setResistance(10.0F).setStepSound(soundStoneFootstep).setUnlocalizedName("stonebrick").setCreativeTab(CreativeTabs.tabBlock);

    public static final Block planks = (new BlockWood(5)).setHardness(2.0F).setResistance(5.0F).setStepSound(soundWoodFootstep).setUnlocalizedName("wood");

    public static final Block sapling = (new BlockSapling(6)).setHardness(0.0F).setStepSound(soundGrassFootstep).setUnlocalizedName("sapling");

    public static final Block bedrock = (new Block(7, Material.rock)).setBlockUnbreakable().setResistance(6000000.0F).setStepSound(soundStoneFootstep).setUnlocalizedName("bedrock").disableStats().setCreativeTab(CreativeTabs.tabBlock);

    public static final BlockFluid waterMoving = (BlockFluid)(new BlockFlowing(8, Material.water)).setHardness(100.0F).setLightOpacity(3).setUnlocalizedName("water").disableStats();

    public static final Block waterStill = (new BlockStationary(9, Material.water)).setHardness(100.0F).setLightOpacity(3).setUnlocalizedName("water").disableStats();

    public static final BlockFluid lavaMoving = (BlockFluid)(new BlockFlowing(10, Material.lava)).setHardness(0.0F).setLightValue(1.0F).setUnlocalizedName("lava").disableStats();

 

 

 

Posted

You need to create the object for that block in you mod class, it would be something like this in your Generic.java:

 

public final static Block genericDirt = new GenericBlock(id, "you texture path", Material.ground)

 

Take a look at the tutorials here:

http://www.minecraftforge.net/wiki/Basic_Blocks

 

And this one for texturing the block later:

http://www.minecraftforge.net/wiki/Icons_and_Textures

 

EDIT: Just noticed you have putted the object creation in the Block.java, don't do that(generally NEVER edit any vanilla files), put it in your Generic.java instead

Posted

every place it says "//here"

 

 

package tutorial.generic;

 

import cpw.mods.fml.common.Mod;

import cpw.mods.fml.common.Mod.Init;

import cpw.mods.fml.common.Mod.Instance;

import cpw.mods.fml.common.Mod.PostInit;

import cpw.mods.fml.common.Mod.PreInit;

import cpw.mods.fml.common.SidedProxy;

import cpw.mods.fml.common.event.FMLInitializationEvent;

import cpw.mods.fml.common.event.FMLPostInitializationEvent;

import cpw.mods.fml.common.event.FMLPreInitializationEvent;

import cpw.mods.fml.common.network.NetworkMod;

 

@Mod(modid="Generic", name="Generic", version="0.0.0")

@NetworkMod(clientSideRequired=true, serverSideRequired=false)

public class Generic {

//here

        // The instance of your mod that Forge uses.

        @Instance("Generic")

        public static Generic instance;

      //here, preferably here

        // Says where the client and server 'proxy' code is loaded.

        @SidedProxy(clientSide="tutorial.generic.client.ClientProxy", serverSide="tutorial.generic.CommonProxy")

        public static CommonProxy proxy;

      //here

        @PreInit

        public void preInit(FMLPreInitializationEvent event) {

                // Stub Method

        }

      //or here

        @Init

        public void load(FMLInitializationEvent event)

        {

                proxy.registerRenderers();

             

                GameRegistry.registerBlock(genericDirt, "genericDirt");

                LanguageRegistry.addName(genericDirt, "Generic Dirt");

                MinecraftForge.setBlockHarvestLevel(genericDirt, "shovel", 0);

        }

     

        @PostInit

        public void postInit(FMLPostInitializationEvent event) {

                // Stub Method

        }

}

 

 

but please learn to code before doing modding, if you couldnt figure it was because you didnt declare a variable you will clearly have much worst problem later on, sorry :(

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

ahhh, yeah well with help you can usually do fine, tough watch out wich question you ask because people end up asking stuff were you just know they have no idea what they're doing.

 

good modding

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

I would recommend at least having a basic understanding of java before making a mod :)

 

A good place to learn the basics of java programming would be:

http://thenewboston.org/list.php?cat=31

 

And if you have enough time, and the will to complete some more detailed tutorials, check out the online tutorials or free e-books from oracle them selves :)

 

Online tutorials: http://docs.oracle.com/javase/tutorial/

E-Books: http://www.oracle.com/technetwork/java/javase/downloads/java-se-7-tutorial-2012-02-28-1536013.html

 

For the E-Books, I would recommend the "getstartedtrail" and "essentialtrail". But keep in mind that these books are more advanced than the video tutorials I linked in the beginning of this post, but they will also give you a much better understanding of java(You could also just use them to look up some things that you find difficult) :)

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hello, I have this same problem. Did you manage to find a solution? Any help would be appreciated. Thanks.
    • log: https://mclo.gs/QJg3wYX as stated in the title, my game freezes upon loading into the server after i used a far-away waystone in it. The modpack i'm using is better minecraft V18. Issue only comes up in this specific server, singleplayer and other servers are A-okay. i've already experimented with removing possible culprits like modernfix and various others to no effect. i've also attempted a full reinstall of the modpack profile. Issue occurs shortly after the 'cancel' button dissapears on the 'loading world' section of the loading screen.   thanks in advance.
    • You would have better results asking a more specific question. What have you done? What exactly do you need help with? Please also read the FAQ regarding posting logs.
    • Hi, this is my second post with the same content as no one answered this and it's been a long time since I made the last post, I want to make a client-only mod, everything is ok, but when I use shaders, none of the textures rendered in RenderLevelStageEvent nor the crow entity model are rendered, I want them to be visible, because it's a horror themed mod I've already tried it with different shaders, but it didn't work with any of them and I really want to add support for shaders Here is how i render the crow model in the CrowEntityRenderer<CrowEntity>, by the time i use this method, i know is not the right method but i don't think this is the cause of the problem, the renderType i'm using is entityCutout @Override public void render(CrowEntity p_entity, float entityYaw, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight) { super.render(p_entity, entityYaw, partialTick, poseStack, bufferSource, packedLight); ClientEventHandler.getClient().crow.renderToBuffer(poseStack, bufferSource.getBuffer(ClientEventHandler.getClient().crow .renderType(TEXTURE)), packedLight, OverlayTexture.NO_OVERLAY, Utils.rgb(255, 255, 255)); } Here renderLevelStage @Override public void renderWorld(RenderLevelStageEvent e) { horrorEvents.draw(e); } Here is how i render every event public void draw(RenderLevelStageEvent e) { for (HorrorEvent event : currentHorrorEvents) { event.tick(e.getPartialTick()); event.draw(e); } } Here is how i render the crow model on the event @Override public void draw(RenderLevelStageEvent e) { if(e.getStage() == RenderLevelStageEvent.Stage.AFTER_ENTITIES) { float arcProgress = getArcProgress(0.25f); int alpha = (int) Mth.lerp(arcProgress, 0, 255); int packedLight = LevelRenderer.getLightColor(Minecraft.getInstance().level, blockPos); VertexConsumer builder = ClientEventHandler.bufferSource.getBuffer(crow); Crow<CreepyBirdHorrorEvent> model = ClientEventHandler .getClient().crow; model.setupAnim(this); RenderHelper.renderModelInWorld(model, position, offset, e.getCamera(), e.getPoseStack(), builder, packedLight, OverlayTexture.NO_OVERLAY, alpha); builder = ClientEventHandler.bufferSource.getBuffer(eyes); RenderHelper.renderModelInWorld(model, position, offset, e.getCamera(), e.getPoseStack(), builder, 15728880, OverlayTexture.NO_OVERLAY, alpha); } } How i render the model public static void renderModelInWorld(Model model, Vector3f pos, Vector3f offset, Camera camera, PoseStack matrix, VertexConsumer builder, int light, int overlay, int alpha) { matrix.pushPose(); Vec3 cameraPos = camera.getPosition(); double finalX = pos.x - cameraPos.x + offset.x; double finalY = pos.y - cameraPos.y + offset.y; double finalZ = pos.z - cameraPos.z + offset.z; matrix.pushPose(); matrix.translate(finalX, finalY, finalZ); matrix.mulPose(Axis.XP.rotationDegrees(180f)); model.renderToBuffer(matrix, builder, light, overlay, Utils .rgba(255, 255, 255, alpha)); matrix.popPose(); matrix.popPose(); } Thanks in advance
  • Topics

×
×
  • Create New...

Important Information

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