Jump to content

Metadata Blocks


Rogem
 Share

Recommended Posts

Second time bothering you guys. I'll make a habit out of this ;D

 

So, I'm having trouble with creating a metadata block that has differing textures and name from the normal one.

 

Main .class:

 

package scienceMod;

 

import net.minecraft.block.Block;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.item.crafting.FurnaceRecipes;

import net.minecraft.src.ModLoader;

import net.minecraftforge.client.MinecraftForgeClient;

import net.minecraftforge.common.Configuration;

import cpw.mods.fml.common.Mod;

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

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.FMLPreInitializationEvent;

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

import cpw.mods.fml.common.registry.GameRegistry;

import cpw.mods.fml.common.registry.LanguageRegistry;

 

@Mod(modid = "mod_scienceMod", name = "Science Mod", version = "1.0")

@NetworkMod(clientSideRequired = true, serverSideRequired = false)

 

 

public class scienceMod

{

@SidedProxy(clientSide = "scienceMod.ClientProxy", serverSide = "scienceMod.CommonProxy")

public static CommonProxy proxy;

 

public static int scienceMetaItemID;

public static int scienceMetaIngotID;

public static int scienceMetaOreID;

public static int scienceMetaOreBlockID;

 

public static Item scienceMetaItem;

public static Item scienceMetaOre;

public static Item scienceMetaIngot;

 

public static Block scienceMetaOreBlock;

 

 

 

@PreInit

public void loadConfig(FMLPreInitializationEvent event)

{

Configuration config = new Configuration(event.getSuggestedConfigurationFile());

 

config.load();

 

scienceMetaOreID = config.getItem("Science Ore ID", 10500).getInt();

scienceMetaItemID = config.getItem("Science Item ID", 10501).getInt();

scienceMetaIngotID = config.getItem("Science Ingot ID", 10502).getInt();

scienceMetaOreBlockID = config.getBlock("Science Ore ID", 500).getInt();

 

config.save();

}

 

 

 

@Init

public void load(FMLInitializationEvent event)

{

addItems();

nameItems();

registerItems();

addBlocks();

registerBlocks();

 

MinecraftForgeClient.preloadTexture("/testMod/mod_items.png");

MinecraftForgeClient.preloadTexture("/testMod/mod_blocks.png");

 

proxy.registerRenderThings();

}

 

 

 

public static void addBlocks()

{

scienceMetaOreBlock = new BlockScienceMetaOre(scienceMetaOreBlockID).setBlockName("Meta Ore Block");

}

 

 

 

public void registerBlocks()

{

//Ore Blocks

GameRegistry.registerBlock(scienceMetaOreBlock, "Meta Ore Block");

ModLoader.addName(new ItemStack(scienceMetaOreBlock, 1, 0), "Cuprite");

ModLoader.addName(new ItemStack(scienceMetaOreBlock, 1, 1), "Cassiterite");

ModLoader.addName(new ItemStack(scienceMetaOreBlock, 1, 2), "Periclase");

ModLoader.addName(new ItemStack(scienceMetaOreBlock, 1, 3), "Garnierite");

}

 

 

 

public static void addItems()

{

scienceMetaItem = new ItemScienceMetaItem(scienceMetaItemID).setItemName("Meta Item");

scienceMetaIngot = new ItemScienceMetaIngot(scienceMetaIngotID).setItemName("Meta Ingot");

scienceMetaOre = new ItemScienceMetaOre(scienceMetaOreID).setItemName("Meta Ore");

// item = new item.class(int itemID).setItemName(string name)

}

 

 

 

private void registerItems()

{

GameRegistry.registerItem(scienceMetaItem, "Meta Item");

GameRegistry.registerItem(scienceMetaIngot, "Meta Ingot");

GameRegistry.registerItem(scienceMetaOre, "Meta Ore");

// GameRegistry.registerItem(Item item, string name)

}

 

 

 

private void nameItems()

{

LanguageRegistry.addName(new ItemStack(scienceMetaItem, 1, 0), "Gearbox");

LanguageRegistry.addName(new ItemStack(scienceMetaItem, 1, 1), "Wire");

LanguageRegistry.addName(new ItemStack(scienceMetaItem, 1, 2), "Magnet");

LanguageRegistry.addName(new ItemStack(scienceMetaItem, 1, 3), "Coil");

LanguageRegistry.addName(new ItemStack(scienceMetaIngot, 1, 0), "Copper Ingot");

LanguageRegistry.addName(new ItemStack(scienceMetaIngot, 1, 1), "Tin Ingot");

LanguageRegistry.addName(new ItemStack(scienceMetaIngot, 1, 2), "Magnesium Ingot");

LanguageRegistry.addName(new ItemStack(scienceMetaIngot, 1, 3), "Nickel Ingot");

LanguageRegistry.addName(new ItemStack(scienceMetaOre, 1, 0), "Cuprite Chunk");

LanguageRegistry.addName(new ItemStack(scienceMetaOre, 1, 1), "Cassiterite Chunk");

LanguageRegistry.addName(new ItemStack(scienceMetaOre, 1, 2), "Periclase Chunk");

LanguageRegistry.addName(new ItemStack(scienceMetaOre, 1, 3), "Garnierite Chunk");

// LanguageRegistry.addName(new ItemStack(Item item, int amount, int meta), string name)

}

 

 

}

 

And the BlockScienceMetaOre.class:

 

package scienceMod;

 

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.block.material.Material;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.item.ItemStack;

 

public class BlockScienceMetaOre extends Block

{

public static String[] scienceMetaOreBlockNames = new String[]{"Cuprite", "Cassiterite", "Periclase", "Garnierite"};

 

public BlockScienceMetaOre(int id)

{

super(id, Material.rock);

this.setCreativeTab(CreativeTabs.tabBlock);

}

 

public String getTextureFile()

{

return CommonProxy.blocks;

}

 

public int getBlockTextureFromSideAndMetadata (int side, int metadata) {

return 16+metadata;

}

 

@Override

public int idDropped(int par1, Random rand, int par2)

{

return scienceMod.scienceMetaOre.itemID;

}

 

 

@Override

public int damageDropped(int i)

    {

return i;

    }

 

public int quantityDropped(Random rand)

{

int drop = 1;

return drop;

}

 

@SideOnly(Side.CLIENT)

public void getSubBlocks(int par1, CreativeTabs tab, List subItems) {

for (int ix = 0; ix < 4; ix++) {

subItems.add(new ItemStack(this, 1, ix));

}

}

}

 

 

 

Have tried a number of different methods, and I'm feeling really clueless now, so please help.

 

For the science.  ::)

Link to comment
Share on other sites

You need an itemBlock (Your item oreclass)

 

That class stores the metainformation.

 

public class OreMetaItem extends ItemBlock

{

    public OreMetaItem(int par1)

    {

          super(par1);

          setHasSubtypes(true);

    }

 

    public int getMetadata(int par1)

    {

        return par1;

    }

 

}

 

Than you have to add this to your BaseModfile

 

GameRegistry.registerBlock(block, ItemBlock.class);

 

 

Link to comment
Share on other sites

Weird, that cause me to error like hell earlier. Oh well, I guess I'll try it again.

 

Edit: okay, I got them to spawn as separate blocks that drop the respective ores. Next thing is fixing the names. I don't want my periclase called garnierite.

 

Edit 2: And it's working, thanks for the help.

Link to comment
Share on other sites

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
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.

 Share



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • ---- Minecraft Crash Report ---- // Uh... Did I do that? Time: 2023-02-07 01:42:22 Description: Unexpected error java.lang.NoClassDefFoundError: me/jellysquid/mods/sodium/client/model/vertex/type/VertexType     at net.minecraft.class_702.handler$zml001$render(class_702.java:3138)     at net.minecraft.class_702.method_3049(class_702.java)     at net.minecraft.class_761.method_22710(class_761.java:1502)     at net.minecraft.class_757.method_3188(class_757.java:1085)     at net.minecraft.class_757.method_3192(class_757.java:864)     at net.minecraft.class_310.method_1523(class_310.java:1193)     at net.minecraft.class_310.method_1514(class_310.java:781)     at net.minecraft.client.main.Main.method_44604(Main.java:244)     at net.minecraft.client.main.Main.main(Main.java:51)     at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:461)     at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74)     at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23) Caused by: java.lang.ClassNotFoundException: me.jellysquid.mods.sodium.client.model.vertex.type.VertexType     at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)     at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)     at net.fabricmc.loader.impl.launch.knot.KnotClassDelegate.loadClass(KnotClassDelegate.java:226)     at net.fabricmc.loader.impl.launch.knot.KnotClassLoader.loadClass(KnotClassLoader.java:112)     at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)     ... 12 more A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Render thread Stacktrace:     at net.minecraft.class_702.handler$zml001$render(class_702.java:3138)     at net.minecraft.class_702.method_3049(class_702.java)     at net.minecraft.class_761.method_22710(class_761.java:1502)     at net.minecraft.class_757.method_3188(class_757.java:1085) -- Affected level -- Details:     All players: 1 total; [class_746['RappyTheToy'/199, l='ClientLevel', x=-8.50, y=68.00, z=9.50]]     Chunk stats: 1024, 475     Level dimension: minecraft:overworld     Level spawn location: World: (0,72,0), Section: (at 0,8,0 in 0,4,0; chunk contains blocks 0,-64,0 to 15,319,15), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,-64,0 to 511,319,511)     Level time: 62 game time, 62 day time     Server brand: fabric     Server type: Integrated singleplayer server Stacktrace:     at net.minecraft.class_638.method_8538(class_638.java:455)     at net.minecraft.class_310.method_1587(class_310.java:2390)     at net.minecraft.class_310.method_1514(class_310.java:805)     at net.minecraft.client.main.Main.method_44604(Main.java:244)     at net.minecraft.client.main.Main.main(Main.java:51)     at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:461)     at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74)     at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23) -- Last reload -- Details:     Reload number: 1     Reload reason: initial     Finished: Yes     Packs: vanilla, Fabric Mods, minecraft/physicsmod -- System Details -- Details:     Minecraft Version: 1.19.3     Minecraft Version ID: 1.19.3     Operating System: Windows 10 (amd64) version 10.0     Java Version: 17.0.3, Microsoft     Java VM Version: OpenJDK 64-Bit Server VM (mixed mode), Microsoft     Memory: 825264992 bytes (787 MiB) / 2147483648 bytes (2048 MiB) up to 2147483648 bytes (2048 MiB)     CPUs: 24     Processor Vendor: AuthenticAMD     Processor Name: AMD Ryzen 9 5900X 12-Core Processor                 Identifier: AuthenticAMD Family 25 Model 33 Stepping 2     Microarchitecture: Zen 3     Frequency (GHz): 4.20     Number of physical packages: 1     Number of physical CPUs: 12     Number of logical CPUs: 24     Graphics card #0 name: NVIDIA GeForce RTX 3080     Graphics card #0 vendor: NVIDIA (0x10de)     Graphics card #0 VRAM (MB): 4095.00     Graphics card #0 deviceId: 0x2216     Graphics card #0 versionInfo: DriverVersion=31.0.15.2824     Memory slot #0 capacity (MB): 8192.00     Memory slot #0 clockSpeed (GHz): 2.13     Memory slot #0 type: DDR4     Memory slot #1 capacity (MB): 8192.00     Memory slot #1 clockSpeed (GHz): 2.13     Memory slot #1 type: DDR4     Memory slot #2 capacity (MB): 8192.00     Memory slot #2 clockSpeed (GHz): 2.13     Memory slot #2 type: DDR4     Memory slot #3 capacity (MB): 8192.00     Memory slot #3 clockSpeed (GHz): 2.13     Memory slot #3 type: DDR4     Virtual memory max (MB): 37790.38     Virtual memory used (MB): 15848.40     Swap memory total (MB): 5120.00     Swap memory used (MB): 12.06     JVM Flags: 9 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xss1M -Xmx2G -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M     Fabric Mods:          fabric-api: Fabric API 0.72.0+1.19.3             fabric-api-base: Fabric API Base 0.4.20+afca2f3e85             fabric-api-lookup-api-v1: Fabric API Lookup API (v1) 1.6.19+49abcf7e85             fabric-biome-api-v1: Fabric Biome API (v1) 12.1.0+b5d379b085             fabric-block-api-v1: Fabric Block API (v1) 1.0.4+e022e5d185             fabric-blockrenderlayer-v1: Fabric BlockRenderLayer Registration (v1) 1.1.29+c6af733c85             fabric-client-tags-api-v1: Fabric Client Tags 1.0.11+1134c5b885             fabric-command-api-v1: Fabric Command API (v1) 1.2.21+f71b366f85             fabric-command-api-v2: Fabric Command API (v2) 2.2.0+3fc4752e85             fabric-commands-v0: Fabric Commands (v0) 0.2.38+df3654b385             fabric-containers-v0: Fabric Containers (v0) 0.1.46+df3654b385             fabric-content-registries-v0: Fabric Content Registries (v0) 3.5.0+1d37d50285             fabric-convention-tags-v1: Fabric Convention Tags 1.2.1+8e4e694f85             fabric-crash-report-info-v1: Fabric Crash Report Info (v1) 0.2.13+aeb40ebe85             fabric-data-generation-api-v1: Fabric Data Generation API (v1) 11.1.4+1134c5b885             fabric-dimensions-v1: Fabric Dimensions API (v1) 2.1.40+48349a3f85             fabric-entity-events-v1: Fabric Entity Events (v1) 1.5.6+b83334a085             fabric-events-interaction-v0: Fabric Events Interaction (v0) 0.4.39+3baeb27a85             fabric-events-lifecycle-v0: Fabric Events Lifecycle (v0) 0.2.42+df3654b385             fabric-game-rule-api-v1: Fabric Game Rule API (v1) 1.0.29+99f9db8085             fabric-item-api-v1: Fabric Item API (v1) 2.1.8+1134c5b885             fabric-item-group-api-v1: Fabric Item Group API (v1) 2.1.11+1134c5b885             fabric-key-binding-api-v1: Fabric Key Binding API (v1) 1.0.30+bc01e09785             fabric-keybindings-v0: Fabric Key Bindings (v0) 0.2.28+df3654b385             fabric-lifecycle-events-v1: Fabric Lifecycle Events (v1) 2.2.9+23a79c8a85             fabric-loot-api-v2: Fabric Loot API (v2) 1.1.19+75e9821185             fabric-loot-tables-v1: Fabric Loot Tables (v1) 1.1.23+9e7660c685             fabric-message-api-v1: Fabric Message API (v1) 5.0.13+6ede1da985             fabric-mining-level-api-v1: Fabric Mining Level API (v1) 2.1.30+49abcf7e85             fabric-models-v0: Fabric Models (v0) 0.3.26+11ba9c3b85             fabric-networking-api-v1: Fabric Networking API (v1) 1.2.16+4017a8cb85             fabric-networking-v0: Fabric Networking (v0) 0.3.33+df3654b385             fabric-object-builder-api-v1: Fabric Object Builder API (v1) 5.3.0+85f102ee85             fabric-particles-v1: Fabric Particles (v1) 1.0.19+f1e4495b85             fabric-recipe-api-v1: Fabric Recipe API (v1) 1.0.0+5176f73d85             fabric-registry-sync-v0: Fabric Registry Sync (v0) 2.0.4+1134c5b885             fabric-renderer-api-v1: Fabric Renderer API (v1) 2.2.0+9f179aa185             fabric-renderer-indigo: Fabric Renderer - Indigo 0.7.0+9f179aa185             fabric-renderer-registries-v1: Fabric Renderer Registries (v1) 3.2.29+df3654b385             fabric-rendering-data-attachment-v1: Fabric Rendering Data Attachment (v1) 0.3.24+afca2f3e85             fabric-rendering-fluids-v1: Fabric Rendering Fluids (v1) 3.0.17+f1e4495b85             fabric-rendering-v0: Fabric Rendering (v0) 1.1.32+df3654b385             fabric-rendering-v1: Fabric Rendering (v1) 1.12.0+6dc0edd785             fabric-resource-conditions-api-v1: Fabric Resource Conditions API (v1) 2.2.2+1134c5b885             fabric-resource-loader-v0: Fabric Resource Loader (v0) 0.10.4+a91e48b785             fabric-screen-api-v1: Fabric Screen API (v1) 1.0.40+f1e4495b85             fabric-screen-handler-api-v1: Fabric Screen Handler API (v1) 1.3.12+99f9db8085             fabric-sound-api-v1: Fabric Sound API (v1) 1.0.7+75e9821185             fabric-transfer-api-v1: Fabric Transfer API (v1) 2.1.14+ccd377ba85             fabric-transitive-access-wideners-v1: Fabric Transitive Access Wideners (v1) 2.3.0+5b9a588b85         fabricloader: Fabric Loader 0.14.14         java: OpenJDK 64-Bit Server VM 17         minecraft: Minecraft 1.19.3         physicsmod: Physics Mod 2.10.1         sodium: Sodium 0.4.9+build.23     Launched Version: fabric-loader-0.14.14-1.19.3     Backend library: LWJGL version 3.3.1 SNAPSHOT     Backend API: NVIDIA GeForce RTX 3080/PCIe/SSE2 GL version 3.2.0 NVIDIA 528.24, NVIDIA Corporation     Window size: 1920x1080     GL Caps: Using framebuffer using OpenGL 3.2     GL debug messages:      Using VBOs: Yes     Is Modded: Definitely; Client brand changed to 'fabric'; Server brand changed to 'fabric'     Type: Integrated Server (map_client.txt)     Graphics mode: fancy     Resource Packs: fabric     Current Language: English (US)     CPU: 24x AMD Ryzen 9 5900X 12-Core Processor      Server Running: true     Player Count: 1 / 8; [class_3222['RappyTheToy'/199, l='ServerLevel[re]', x=-8.50, y=68.00, z=9.50]]     Data Packs: vanilla, fabric     Enabled Feature Flags: minecraft:vanilla     World Generation: Stable
    • The error message "attempting to assign weaker access privileges; was public" usually occurs in Java when you try to change the access level of a member (such as a field or method) to a less restrictive level than it was defined with originally. For example, if a method is defined as public, you cannot change its access level to private or protected. In Java, the access level for a member can only be made more restrictive, not less restrictive, to ensure that subclasses cannot weaken the accessibility of members inherited from their superclasses.
    • Ive been browsing the web for solutions as when I try to run gradlew genIntellijRuns, it states it cannot find a specific file in a folder called in Bundled_repo I checked the supposed location of this file but could not find the folders it should be contained in, which are bundeled_repo/net. I deleted the chache and ran it again but it did not fix the issue.
    • I have no idea why but my forge server console is spammed by BlockPos {x=0, y=0, z=0} nearly every second on the server console. Anyone have any idea how to stop this?
  • Topics

×
×
  • Create New...

Important Information

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