Jump to content

1.12.2 OreGen Problem


MonolinkTV

Recommended Posts

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);

}

 

Link to comment
Share on other sites

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();
			}
		}
	}
}

 

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
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 everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
    • It is an issue with quark - update it to this build: https://www.curseforge.com/minecraft/mc-mods/quark/files/3642325
    • Remove Instant Massive Structures Mod from your server     Add new crash-reports with sites like https://paste.ee/  
    • Update your drivers: https://www.amd.com/en/support/graphics/amd-radeon-r9-series/amd-radeon-r9-200-series/amd-radeon-r9-280x
  • Topics

×
×
  • Create New...

Important Information

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