Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hello i have been on this problem for a while and is stumped at the moment so i have no idea what i should do as of hint as in why i am here now. If any one can help me that would be awesome. This is my first time making a mod for Minecraft but i know some what about java so ill try my best to understand.

 

So what is happening is that i am trying to get a block to place in the direction of what i am facing. I have no clue what to do now. In-game i see my texture for my model in my inventory and i can place it. f3 also confirms i am placing it in a certain direction.

 

This is the code for my block

 

package faethorn.magitech.blocks;

import faethorn.magitech.Reference;
import net.minecraft.block.Block;
import net.minecraft.block.BlockHorizontal;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Blocks;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

public class BlockCrystalGrinder extends BlockHorizontal {

	public BlockCrystalGrinder() {
		super(Material.ANVIL);
		setUnlocalizedName(Reference.MagiTechBlocks.CRYSTALGRINDER.getUnlocalizedName());
		setRegistryName(Reference.MagiTechBlocks.CRYSTALGRINDER.getRegistryName());
		setHardness(5.0f);
		setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
	}
	
	@Override
	public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ,int meta, EntityLivingBase placer) {
		IBlockState state = super.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer);
		return state.withProperty(FACING, placer.getHorizontalFacing() );
	}
	@Override
	public int getMetaFromState(IBlockState state) {
		return state.getValue(FACING).getHorizontalIndex();
	}
	@Override
	public IBlockState getStateFromMeta(int meta) {
		return getDefaultState().withProperty(FACING, EnumFacing.getHorizontal(meta));
	}
	@Override
	protected BlockStateContainer createBlockState() {
		return new BlockStateContainer(this, FACING);
	}
}

 

This is code for my ModBlock.

package faethorn.magitech.init;

import javax.tools.Tool;

import faethorn.magitech.blocks.BlockCrystalGrinder;
import faethorn.magitech.blocks.BlockFayriumOre;

import faethorn.magitech.items.ItemMagiIngot;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class ModBlocks {
	
	public static Block fayriumore;
	public static Block crystalgrinder;
	
	public static void init() {
		fayriumore = new BlockFayriumOre();
		crystalgrinder = new BlockCrystalGrinder();
	}

	public static void register() {
		registerBlock(fayriumore);
		registerBlock(crystalgrinder);
		
			}
	
	private static void registerBlock(Block block) {
		GameRegistry.register(block);
		ItemBlock item = new ItemBlock(block);
		item.setRegistryName(block.getRegistryName());
		GameRegistry.register(item);
		
	}
	
	public static void registerRenders() {
		registerRender(fayriumore);
		registerRender(crystalgrinder);
		
	}
	private static void registerRender(Block block) {
		Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block),0,new ModelResourceLocation(block.getRegistryName(), "inventory"));
	}
}

 

This is my .json script for blockstates

{
    "variants": {
        "facing=north": { "models": "fmt:crystalgrinder" },
        "facing=west":  { "models": "fmt:crystalgrinder" },
        "facing=east":  { "models": "fmt:crystalgrinder" },
        "facing=south": { "models": "fmt:crystalgrinder" }
    }

} 

 

this is my .json script for models block class

{
    "parent": "block/cube",
    "textures": {
        "particle": "fmt:blocks/MagiCrystalGrinderleftandright",
        "0": "fmt:blocks/magicrystalgrinderrear",
        "1": "fmt:blocks/MagiCrystalGrinderTop",
        "2": "fmt:blocks/MagiCrystalGrinderFront",
        "3": "fmt:blocks/MagiCrystalGrinderleftandright",
        "4": "fmt:blocks/MagiCrystalGrinderbottom"
    },
     "elements": [
        {
            "name": "Cube",
            "from": [ 0.0, 0.0, 0.0 ], 
            "to": [ 16.0, 16.0, 16.0 ], 
            "faces": {
                "north": { "texture": "#0", "uv": [ 0.0, 0.0, 16.0, 16.0 ] },
                "east": { "texture": "#1", "uv": [ 0.0, 0.0, 16.0, 16.0 ] },
                "south": { "texture": "#2", "uv": [ 0.0, 0.0, 16.0, 16.0 ] },
                "west": { "texture": "#3", "uv": [ 0.0, 0.0, 16.0, 16.0 ] },
                "up": { "texture": "#3", "uv": [ 0.0, 0.0, 15.0, 9.0 ] },
                "down": { "texture": "#4", "uv": [ 0.0, 0.0, 16.0, 16.0 ] }
            }
        }
    ]
}

 

this is my .json script for my models items class

{
    "parent": "fmt:block/crystalgrinder",
    "textures": {
        "particle": "fmt:blocks/MagiCrystalGrinderleftandright",
        "0": "fmt:blocks/magicrystalgrinderrear",
        "1": "fmt:blocks/MagiCrystalGrinderTop",
        "2": "fmt:blocks/MagiCrystalGrinderFront",
        "3": "fmt:blocks/MagiCrystalGrinderleftandright",
        "4": "fmt:blocks/MagiCrystalGrinderbottom"
    },
     "elements": [
        {
            "name": "Cube",
            "from": [ 0.0, 0.0, 0.0 ], 
            "to": [ 16.0, 16.0, 16.0 ], 
            "faces": {
                "north": { "texture": "#0", "uv": [ 0.0, 0.0, 16.0, 16.0 ] },
                "east": { "texture": "#1", "uv": [ 0.0, 0.0, 16.0, 16.0 ] },
                "south": { "texture": "#2", "uv": [ 0.0, 0.0, 16.0, 16.0 ] },
                "west": { "texture": "#3", "uv": [ 0.0, 0.0, 16.0, 16.0 ] },
                "up": { "texture": "#3", "uv": [ 0.0, 0.0, 15.0, 9.0 ] },
                "down": { "texture": "#4", "uv": [ 0.0, 0.0, 16.0, 16.0 ] }
            }
        }
    ]
     
}

 

this is error message i get when loading in game im posting one section of it but it says this for all sides ( north,west,south,east)

 

[20:17:24] [Client thread/ERROR] [FML]: Exception loading model for variant fmt:BlockCrystalGrinder#facing=east for blockstate "fmt:BlockCrystalGrinder[facing=east]"
net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model fmt:BlockCrystalGrinder#facing=east with loader VariantLoader.INSTANCE, skipping
	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:153) ~[ModelLoaderRegistry.class:?]
	at net.minecraftforge.client.model.ModelLoader.registerVariant(ModelLoader.java:241) ~[ModelLoader.class:?]
	at net.minecraft.client.renderer.block.model.ModelBakery.loadBlock(ModelBakery.java:145) ~[ModelBakery.class:?]
	at net.minecraftforge.client.model.ModelLoader.loadBlocks(ModelLoader.java:229) ~[ModelLoader.class:?]
	at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:146) ~[ModelLoader.class:?]
	at net.minecraft.client.renderer.block.model.ModelManager.onResourceManagerReload(ModelManager.java:28) [ModelManager.class:?]
	at net.minecraft.client.resources.SimpleReloadableResourceManager.notifyReloadListeners(SimpleReloadableResourceManager.java:132) [SimpleReloadableResourceManager.class:?]
	at net.minecraft.client.resources.SimpleReloadableResourceManager.reloadResources(SimpleReloadableResourceManager.java:113) [SimpleReloadableResourceManager.class:?]
	at net.minecraft.client.Minecraft.refreshResources(Minecraft.java:799) [Minecraft.class:?]
	at net.minecraft.client.Minecraft.processKeyF3(Minecraft.java:2146) [Minecraft.class:?]
	at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2002) [Minecraft.class:?]
	at net.minecraft.client.Minecraft.runTick(Minecraft.java:1846) [Minecraft.class:?]
	at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1118) [Minecraft.class:?]
	at net.minecraft.client.Minecraft.run(Minecraft.java:406) [Minecraft.class:?]
	at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_161]
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_161]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_161]
	at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_161]
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_161]
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_161]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_161]
	at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_161]
	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
	at GradleStart.main(GradleStart.java:26) [start/:?]
Caused by: net.minecraft.client.renderer.block.model.ModelBlockDefinition$MissingVariantException
	at net.minecraft.client.renderer.block.model.ModelBlockDefinition.getVariant(ModelBlockDefinition.java:78) ~[ModelBlockDefinition.class:?]
	at net.minecraftforge.client.model.ModelLoader$VariantLoader.loadModel(ModelLoader.java:1184) ~[ModelLoader$VariantLoader.class:?]
	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:149) ~[ModelLoaderRegistry.class:?]
	... 26 more

 

 

here is a screen of what it looks like in game 

Quote

BGr341R.png

 

  • Author

Okay update i got it to where it fixes textures in game but it does not rotate block 

  • Author

hey hey glad to say that i fixed this problem though it was kinda hacky the way i did it probably not the correct way i fixed it so thanks!

Often the best way to fix problems like this is to look at the vanilla code for a block that does the same thing. For example, check the code for pistons.

  • Author

Aw yes I didn't even think about looking at vanilla code I will have to keep this in mind next time I have a problem thanks!

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.