Jump to content

Recommended Posts

Posted

I'm making a list for my ore gen followed Harry's tutorials but this is what I get

https://pastebin.com/CYmZ0kUN

Here is all the code you should need

ModBlocks

package com.mrf.infinityweapons.init;

import java.util.ArrayList;
import java.util.List;

import com.mrf.infinityweapons.blocks.BlockBase;
import com.mrf.infinityweapons.blocks.Electric_Compressor;
import com.mrf.infinityweapons.blocks.FuturiumOre;
import com.mrf.infinityweapons.blocks.Lava_Compressor;
import com.mrf.infinityweapons.blocks.Tier1_Energy_Cell;
import com.mrf.infinityweapons.blocks.Tier2_Energy_Cell;
import com.mrf.infinityweapons.blocks.Tier3_Energy_Cell;
import com.mrf.infinityweapons.blocks.Tier4_Energy_Cell;
import com.mrf.infinityweapons.blocks.Tier5_Energy_Cell;
import com.mrf.infinityweapons.blocks.ores.BlockOres;
import com.mrf.infinityweapons.blocks.trees.LeavesBase;
import com.mrf.infinityweapons.blocks.trees.LogsBase;
import com.mrf.infinityweapons.blocks.trees.PlanksBase;
import com.mrf.infinityweapons.blocks.trees.SaplingsBase;

import net.minecraft.block.Block;
import net.minecraft.block.BlockLeaves;
import net.minecraft.block.material.Material;

public class ModBlocks
{
	public static final List<Block> BLOCKS = new ArrayList<Block>();

	//Compressor
	public static Block LAVA_COMPRESSOR_BLOCK = new Lava_Compressor("lava_compressor_block", Material.ANVIL);
	public static Block ELECTRIC_COMPRESSOR_BLOCK = new Electric_Compressor("electric_compressor_block", Material.ANVIL);

	//Bunker Things/Ascetics
	public static Block REINFORCED_CONCRETE = new BlockBase("reinforced_concrete", Material.ROCK);
	public static Block CONCRETE = new BlockBase("concrete", Material.ROCK);
	public static Block MARBLE_BRICK = new BlockBase("marble_brick", Material.ROCK);
	public static Block CRACKED_MARBLE_BRICK = new BlockBase("cracked_marble_brick", Material.ROCK);
	public static Block BASAULT_BRICK = new BlockBase("basault_brick", Material.ROCK);

	//Ores
	
	public static Block ORE_OVERWORLD = new BlockOres("ore_overworld", "overworld");


	//Energy Cells
	public static Block TIER1_ENERGY_CELL = new Tier1_Energy_Cell("tier1_energy_cell", Material.ANVIL);
	public static Block TIER2_ENERGY_CELL = new Tier2_Energy_Cell("tier2_energy_cell", Material.ANVIL);
	public static Block TIER3_ENERGY_CELL = new Tier3_Energy_Cell("tier3_energy_cell", Material.ANVIL);
	public static Block TIER4_ENERGY_CELL = new Tier4_Energy_Cell("tier4_energy_cell", Material.ANVIL);
	public static Block TIER5_ENERGY_CELL = new Tier5_Energy_Cell("tier5_energy_cell", Material.ANVIL);

	//Variants
	
	//Leaves/Log
	/*public static Block LEAVES = new LeavesBase("leaves");
	public static Block LOGS = new LogsBase("logs");
	public static Block PLANKS = new PlanksBase("planks");
	public static Block SAPLINGS = new SaplingsBase("saplings");*/




}

BlockOres

package com.mrf.infinityweapons.blocks.ores;

import com.mrf.infinityweapons.Main;
import com.mrf.infinityweapons.init.ModBlocks;
import com.mrf.infinityweapons.init.ModItems;
import com.mrf.infinityweapons.items.ItemBlockVariants;
import com.mrf.infinityweapons.util.IHasModel;
import com.mrf.infinityweapons.util.IMetaName;
import com.mrf.infinityweapons.util.handlers.EnumHandler;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;

public class BlockOres extends Block implements IHasModel, IMetaName {

	public static final PropertyEnum<EnumHandler.EnumType> VARIANT = PropertyEnum.<EnumHandler.EnumType>create(
			"variant", EnumHandler.EnumType.class);

	private String name, dimension;

	public BlockOres(String name, String dimension) {
		super(Material.ROCK);
		setUnlocalizedName(name);
		setRegistryName(name);
		setCreativeTab(Main.infinityweaponstab);
		setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, EnumHandler.EnumType.URANIUM));

		ModBlocks.BLOCKS.add(this);
		ModItems.ITEMS.add(new ItemBlockVariants(this.setRegistryName(this.getRegistryName())));
		this.name = name;
		this.dimension = dimension;

	}

	@Override
	public int damageDropped(IBlockState state) {
		return ((EnumHandler.EnumType) state.getValue(VARIANT)).getMeta();
	}

	@Override
	public int getMetaFromState(IBlockState state) {
		return ((EnumHandler.EnumType) state.getValue(VARIANT)).getMeta();
	}

	@Override
	public IBlockState getStateFromMeta(int meta) {
		return this.getDefaultState().withProperty(VARIANT, EnumHandler.EnumType.byMetadata(meta));
	}

	@Override
	public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos,
			EntityPlayer player) {
		return new ItemStack(Item.getItemFromBlock(this), 1, getMetaFromState(world.getBlockState(pos)));
	}

	@Override
	public void getSubBlocks(CreativeTabs itemIn, NonNullList<ItemStack> items) {
		for (EnumHandler.EnumType variant : EnumHandler.EnumType.values()) {
			items.add(new ItemStack(this, 1, variant.getMeta()));
		}
	}

	@Override
	protected BlockStateContainer createBlockState() {
		return new BlockStateContainer(this, new IProperty[] { VARIANT });
	}

	@Override
	public String getSpecialName(ItemStack stack) {
		return EnumHandler.EnumType.values()[stack.getItemDamage()].getName();
	}

	@Override
	public void registerModels() {
		for (int i = 0; i < EnumHandler.EnumType.values().length; i++) {
			Main.proxy.registerVariantRenderer(Item.getItemFromBlock(this), 1,
					"ore_" + this.dimension + EnumHandler.EnumType.values()[i].getName(), "inventory");
		}

	}

}

EnumHandler And EnumType

package com.mrf.infinityweapons.util.handlers;

import com.mrf.infinityweapons.blocks.trees.PlanksBase;

import net.minecraft.util.IStringSerializable;

public class EnumHandler 
{
	public static enum EnumType implements IStringSerializable
	{

		URANIUM(0, "uranium"),
		TITANIUM(1, "titanium"),
		FUTURIUM(2, "futurium");


		private static final EnumType[] META_LOOKUP = new EnumType[values().length];
		private final int meta;
		private final String name, unlocalizedName;

		private EnumType(int meta, String name) {
			this(meta, name, name);
		}

		private EnumType(int meta, String name, String unlocalizedName) {
			this.meta = meta;
			this.name = name;
			this.unlocalizedName = unlocalizedName;

		}

		@Override
		public String getName() {
			return this.name;
		}

		public int getMeta() {
			return this.meta;
		}

		public String getUnlocalizedName() {
			return this.unlocalizedName;
		}

		@Override
		public String toString() {
			return this.name();
		}

		public static EnumType byMetadata(int meta) {
			return META_LOOKUP[meta];
		}

		static {
			for (EnumType enumtype : values()) {
				META_LOOKUP[enumtype.getMeta()] = enumtype;
			}
		}
		
	}
}

ClientProxy Then CommonProxy

package com.mrf.infinityweapons.proxy;

import com.mrf.infinityweapons.util.Referance;

import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.ModelLoader;

public class ClientProxy extends CommonProxy
{

	public void registerItemRenderer(Item item, int meta, String id)
	{
		ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(item.getRegistryName(), id));
	}
	@Override
	public void registerVariantRenderer(Item item, int meta, String filename, String id)
	{
		ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(new ResourceLocation(Referance.MOD_ID, filename), "inventory"));
	}

}
package com.mrf.infinityweapons.proxy;

import com.mrf.infinityweapons.items.ItemBase;

import net.minecraft.item.Item;

public class CommonProxy
{

	public void registerItemRenderer(Item item, int meta, String id)
	{

	}
	public void registerVariantRenderer(Item item, int meta, String filename, String id)
	{

	}
}

ItemBlockVariants

package com.mrf.infinityweapons.items;

import com.mrf.infinityweapons.util.IMetaName;

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

public class ItemBlockVariants extends ItemBlock {

	public ItemBlockVariants(Block block) 
	{
		super(block);
		setHasSubtypes(true);
		setMaxDamage(0);
	}
	
	@Override
	public String getUnlocalizedName(ItemStack stack) {
		return super.getUnlocalizedName() + "_" + ((IMetaName)this.block).getSpecialName(stack);
	}
	
	@Override
	public int getMetadata(int damage) {
		return damage;
	}

}

IMetaName

package com.mrf.infinityweapons.util;

import net.minecraft.item.ItemStack;

public interface IMetaName 
{
	public String getSpecialName(ItemStack stack);

}

 

Posted

Lol my bad 

RegistryHandler

package com.mrf.infinityweapons.util.handlers;

import com.mrf.infinityweapons.init.ModBlocks;
import com.mrf.infinityweapons.init.ModItems;
import com.mrf.infinityweapons.init.ModTileEntitys;
import com.mrf.infinityweapons.util.IHasModel;
import com.mrf.infinityweapons.util.IHasTileEntity;

import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

@EventBusSubscriber
public class RegistryHandler
{
	@SubscribeEvent
	public static void onItemRegester(RegistryEvent.Register<Item> event)
	{
		event.getRegistry().registerAll(ModItems.ITEMS.toArray(new Item[0]));
	}

	@SubscribeEvent
	public static void onBlockRegister(RegistryEvent.Register<Block> event)
	{
		event.getRegistry().registerAll(ModBlocks.BLOCKS.toArray(new Block[0]));
	}

	@SubscribeEvent
	public static void onModelRegister(ModelRegistryEvent event)
	{
		for (Item item : ModItems.ITEMS) {
			if (item instanceof IHasModel) {
				((IHasModel) item).registerModels();
			}
		}

		for (Block block : ModBlocks.BLOCKS) {
			if (block instanceof IHasModel) {
				((IHasModel) block).registerModels();
			}
		}
		for (TileEntity tileEntity : ModTileEntitys.TILEENTITYS) {
			if (tileEntity instanceof IHasTileEntity) {
				((IHasTileEntity) tileEntity).registerTileEntity();
			}
		}
	}
}

 

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 tried do download the essential mod to my mod pack but i didnt work. I paly on 1.21 and it should work. I use neoforge for my modding. The weird things is my friend somehow added the mod to his modpack and many others that I somehow can´t. Is there anything i can do? 
    • Thanks, I've now installed a slightly newer version and the server is at least starting up now.
    • i have the same issue. Found 1 Create mod class dependency(ies) in createdeco-1.3.3-1.19.2.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Found 11 Create mod class dependency(ies) in createaddition-fabric+1.19.2-20230723a.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Detailed walkthrough of mods which rely on missing Create mod classes: Mod: createaddition-fabric+1.19.2-20230723a.jar Missing classes of create: com/simibubi/create/compat/jei/category/sequencedAssembly/JeiSequencedAssemblySubCategory com/simibubi/create/compat/recipeViewerCommon/SequencedAssemblySubCategoryType com/simibubi/create/compat/rei/CreateREI com/simibubi/create/compat/rei/EmptyBackground com/simibubi/create/compat/rei/ItemIcon com/simibubi/create/compat/rei/category/CreateRecipeCategory com/simibubi/create/compat/rei/category/WidgetUtil com/simibubi/create/compat/rei/category/animations/AnimatedBlazeBurner com/simibubi/create/compat/rei/category/animations/AnimatedKinetics com/simibubi/create/compat/rei/category/sequencedAssembly/ReiSequencedAssemblySubCategory com/simibubi/create/compat/rei/display/CreateDisplay Mod: createdeco-1.3.3-1.19.2.jar Missing classes of create: com/simibubi/create/content/kinetics/fan/SplashingRecipe
    • The crash points to moonlight lib - try other builds or make a test without this mod and the mods requiring it
    • Do you have shaders enabled? There is an issue with the mod simpleclouds - remove this mod or disable shaders, if enabled  
  • Topics

×
×
  • Create New...

Important Information

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