Jump to content

Recommended Posts

Posted

I'm trying to do meta data blocks but I keep getting errors. Also how would I give each block a texture. The tutorial on it wasn't very in depth.For the code look at the metadata blocks tutorials because I was basically going off that. http://www.minecraftforge.net/wiki/Metadata_Based_Subblocks

 

The method getItemNameIS(ItemStack) of type BrickItems must override or implement a supertype method(works when i remove the @Override)

@Override

public String getItemNameIS(ItemStack itemstack) {

return getItemName() + "." + subNames[itemstack.getItemDamage()];

}

 

 

The method setItemName(String) is undefined for the type BrickItems

setItemName("brick");

 

The method getTextureFile() of type Brick must override or implement a supertype method

public String getTextureFile () {

return CommonProxy.BLOCK_PNG;

}

Posted

Main class:

 

package whatsfast.MoreBricks;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.item.ItemStack;
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;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;

@Mod(modid="moreBricks", name="More Bricks", version="1.5.2 V0.1")
@NetworkMod(clientSideRequired=true, serverSideRequired=false)
public class MoreBricks {
	public static final int brickID = 502;
	public static final Block brick = new Brick(brickID);

	private static final String[] multiBlockNames = { 
		"White Brick", "Orange Brick", "Magenta Brick", "Light Blue Brick",
		"Yellow Brick", "Light Green Brick", "Pink Brick", "Dark Grey Brick",
		"Light Grey Brick", "Cyan Brick", "Purple Brick", "Blue Brick",
		"Brown Brick", "Green Brick", "Red Brick", "Black Brick"
	};


        // The instance of your mod that Forge uses.
        @Instance("moreBricks")
        public static MoreBricks instance;
        
        // Says where the client and server 'proxy' code is loaded.
        @SidedProxy(clientSide="whatsfast.minecraft.MoreBricks.ClientProxy", serverSide="whatsfast.minecraft.MoreBricks.CommonProxy")
        public static CommonProxy proxy;
        
        @PreInit
        public void preInit(FMLPreInitializationEvent event) {
                // Stub Method
        }
        @Init
        public void load(FMLInitializationEvent event) {
                proxy.registerRenderers();
                
                GameRegistry.registerBlock(brick, BrickItems.class);
        		
        		for (int ix = 0; ix < 16; ix++) {
        			ItemStack cloth = new ItemStack(Block.cloth, 1, ix);
        			ItemStack brickStack = new ItemStack(brick, 1, ix);
        			
        			GameRegistry.addShapelessRecipe(brickStack, cloth);
        			LanguageRegistry.addName(brickStack, multiBlockNames[brickStack.getItemDamage()]);
        		}
        }
        
        @PostInit
        public void postInit(FMLPostInitializationEvent event) {
                // Stub Method
        }
}

 

CommonProxy

 

package whatsfast.MoreBricks;

public class CommonProxy {
    //Don't know what to do for this
    public static String Red Brick = "/tutorial/generic/block.png";
    
    // Client stuff
    public void registerRenderers() {
            // Nothing here as the server doesn't render graphics!
    }
}

 

ClientProxy

 

package whatsfast.MoreBricks.client;

import net.minecraftforge.client.MinecraftForgeClient;
import whatsfast.MoreBricks.CommonProxy;

public class ClientProxy extends CommonProxy {
        
        @Override
        public void registerRenderers() {
        		//still don't know
                MinecraftForgeClient.preloadTexture(red);
        }
        
}

 

Birck.java

 

package whatsfast.MoreBricks;

import java.util.List;
import java.util.Random;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.block.material.Material;

public class Brick extends Block {
public Brick (int id) {
	super(id, Material.ground);
	setBlockName("Brick");
	setCreativeTab(CreativeTabs.tabBlock);
}

public int getBlockTextureFromSideAndMetadata (int side, int metadata) {
	return 16 + metadata;
}
@Override
public String getTextureFile () {
	return CommonProxy.BLOCK_PNG;
}

@Override
public int damageDropped (int metadata) {
	return metadata;
}

@SideOnly(Side.CLIENT)
public void getSubBlocks(int par1, CreativeTabs tab, List subItems) {
	for (int ix = 0; ix < 16; ix++) {
		subItems.add(new ItemStack(this, 1, ix));
	}
}
}

 

BrickItems.java

 

package whatsfast.MoreBricks;

import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;

public class BrickItems extends ItemBlock {

private final static String[] subNames = {
	"white", "orange",  "magenta", "lightBlue", "yellow", "lightGreen",
	"pink", "darkGrey", "lightGrey", "cyan", "purple", "blue", "brown",
	"green", "red", "black"
};

public BrickItems(int id) {
	super(id);
	setHasSubtypes(true);
	setItemName("brick");
}

@Override
public int getMetadata (int damageValue) {
	return damageValue;
}

@Override
public String getItemNameIS(ItemStack itemstack) {
	return getItemName() + "." + subNames[itemstack.getItemDamage()];
}

}

 

Posted

Are you modding in minecraft 1.4.7? Cause in 1.5.x you dont have to preload textures anymore. I've got a link for you that can help you out:

 

http://wuppy29.blogspot.nl/2013/04/modding-151-metadata-blocks.html

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

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

    • I want to create block with entity, that will have height of 3 or more(configurable) and I tried to change first VoxelShape by increasing collision box on height I want and for changing block height on visual side i tried to configure BlockModelBuilder:  base.element() .from(0, 0, 0) .to(16f, 48f, 16f) .face(Direction.UP).texture("#top").end() .face(Direction.DOWN).texture("#bottom").end() .face(Direction.NORTH).texture("#side").end() .face(Direction.SOUTH).texture("#side").end() .face(Direction.WEST).texture("#side").end() .face(Direction.EAST).texture("#side").end() .end(); but, getting crash with next error: Position y out of range, must be within [-16, 32]. Found: %d [48.0]; Looks like game wont to block height modified by more than 32. Is there any way to fix that problem?
    • As long as the packets you are sending aren't lost, there's nothing wrong with what you're currently doing. Although, this sounds like something that would benefit from you making your own datapack registry instead of trying to arbitrarily sync static maps. Check out `DataPackRegistryEvent.NewRegistry`.
    • Hey all, I've been working a lot with datapacks lately, and I'm wondering what the most efficient way to get said data from server to client is.  I'm currently using packets, but given that a lot of the data I'm storing involves maps along the lines of Map<ResourceLocation, CustomDataType>, it can easily start to get messy if I need to transmit a lot of that data all at once. Recently I started looking into the ReloadableServerResources class, which is where Minecraft stores its built-ins.  I see you can access it via the server from the server's resources.managers, and it seems like this can be done even from the client to appropriately retrieve data from the server, unless I'm misunderstanding.  However, from what I can tell, this only works via built-in methods such as getRecipeManager() or getLootTables(), etc.  These are all SimpleJsonResourceReloadListeners, just like my datapack entries are, so it seems like it could be possible for me to access my datapack entries similarly?  But I don't see anywhere in ReloadableServerResources that stores loaded modded entries, so either I'm looking in the wrong place or it doesn't seem to be a thing. Are packets really the best way of doing this, or am I missing a method that would let me use ReloadableServerResources or something similar?
    • Hi, everyone! I'm new to minecraft modding stuff and want ask you some questions. 1. I checked forge references and saw there com.mojang and net.minecraft (not net.minecraftforge) and as I understand it's original game packages with all minecraft logic inside including renderers and so on, right? 2. Does it mean that forge has a limited set of instruments which doesn't cover all the aspects of the game? If make my question more specific then does forge provide such instruments that allow me totally change minecraft itself, like base mechanics and etc.? Or I have to use "original game packages" to implement such things? 3. I actively learning basic concepts with forge documentation and tutorials. So in my plans make different inventory system like in diabloids. Is that possible with forge? 4. It is last question related to the second one. So how deeply I can change minecraft with forge? I guess all my questions above because of that I haven't globally understanding what forge is and how it works inside and how it works with minecraft. It would be great if you provide some links or topics about it or explain it by yourself but I guess it's to big to be explained in that post at once. Anyway, thank you all for any help!
    • Im trying add to block a hole in center, just a usual block and in center of it on up side, there is should be a hole. I tried to add it via BlockModelBuilder, but its not working. Problem is that it only can change block size outside. I tried it to do with VoxelShape and its working, but its has been on server side and looks like its just changed collision shape, but for client, there is a texture covering this hole. I tried to use: base.renderType("cutout"); and removed some pixels from texture. I thought its should work, but game optimization makes block inside looks transparent. So, only custom model?
  • Topics

×
×
  • Create New...

Important Information

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