Jump to content

Recommended Posts

Posted

Hello, I've got a big problem and I can't figured what is the problem.

 

First, the error :

 

java.lang.IllegalArgumentException: Cannot set property PropertyEnum{name=axis, clazz=class fr.steamhouse.mod.blocks.BlockFaiteMoi$EnumAxis, values=[x, y, z, none]} as it does not exist in BlockStateContainer{block=stm:faitemoi, properties=[axis]}
	at net.minecraft.block.state.BlockStateContainer$StateImplementation.withProperty(BlockStateContainer.java:216) ~[BlockStateContainer$StateImplementation.class:?]
	at fr.steamhouse.mod.blocks.BlockFaiteMoi.onBlockPlaced(BlockFaiteMoi.java:42) ~[BlockFaiteMoi.class:?]
	at net.minecraft.block.Block.getStateForPlacement(Block.java:2309) ~[Block.class:?]
	at net.minecraft.item.ItemBlock.onItemUse(ItemBlock.java:58) ~[ItemBlock.class:?]
	at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:160) ~[ItemStack.class:?]
	at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClickBlock(PlayerControllerMP.java:486) ~[PlayerControllerMP.class:?]
	at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1603) ~[Minecraft.class:?]
	at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2281) ~[Minecraft.class:?]
	at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2058) ~[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_131]
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
	at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_131]
	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_131]
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
	at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_131]
	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
	at GradleStart.main(GradleStart.java:26) [start/:?]
[14:02:04] [Client thread/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:649]: ---- Minecraft Crash Report ----
// Everything's going to plan. No, really, that was supposed to happen.

Time: 03/07/17 14:02
Description: Unexpected error

java.lang.IllegalArgumentException: Cannot set property PropertyEnum{name=axis, clazz=class fr.steamhouse.mod.blocks.BlockFaiteMoi$EnumAxis, values=[x, y, z, none]} as it does not exist in BlockStateContainer{block=stm:faitemoi, properties=[axis]}
	at net.minecraft.block.state.BlockStateContainer$StateImplementation.withProperty(BlockStateContainer.java:216)
	at fr.steamhouse.mod.blocks.BlockFaiteMoi.onBlockPlaced(BlockFaiteMoi.java:42)
	at net.minecraft.block.Block.getStateForPlacement(Block.java:2309)
	at net.minecraft.item.ItemBlock.onItemUse(ItemBlock.java:58)
	at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:160)
	at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClickBlock(PlayerControllerMP.java:486)
	at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1603)
	at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2281)
	at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2058)
	at net.minecraft.client.Minecraft.runTick(Minecraft.java:1846)
	at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1118)
	at net.minecraft.client.Minecraft.run(Minecraft.java:406)
	at net.minecraft.client.main.Main.main(Main.java:118)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
	at GradleStart.main(GradleStart.java:26)

 

Annnd here the code: 

 

package fr.steamhouse.mod.blocks;

import java.util.Random;

import fr.steamhouse.mod.References;
import net.minecraft.block.Block;
import net.minecraft.block.BlockHorizontal;
import net.minecraft.block.BlockRotatedPillar;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

public class BlockFaiteMoi extends BlockRotatedPillar{
	
    public static final PropertyEnum<BlockFaiteMoi.EnumAxis> FAITEMOI_AXIS = PropertyEnum.<BlockFaiteMoi.EnumAxis>create("axis", BlockFaiteMoi.EnumAxis.class);
	
		public BlockFaiteMoi(String unlocalizedName, String registryName) {
			super(Material.WOOD);
			this.setUnlocalizedName(unlocalizedName);
			this.setRegistryName(new ResourceLocation(References.MODID, registryName));
			this.setHardness(20); //Sets how hard the block is to break
			this.setResistance(20); //Sets the blocks blast resistance to explosions
		}
		
	    /**
	     * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
	     * IBlockstate
	     */
	    public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
	    {
	        return this.getStateFromMeta(meta).withProperty(FAITEMOI_AXIS, BlockFaiteMoi.EnumAxis.fromFacingAxis(facing.getAxis()));
	    }

	    /**
	     * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed
	     * blockstate.
	     */
	    public IBlockState withRotation(IBlockState state, Rotation rot)
	    {
	        switch (rot)
	        {
	            case COUNTERCLOCKWISE_90:
	            case CLOCKWISE_90:

	                switch ((BlockFaiteMoi.EnumAxis)state.getValue(FAITEMOI_AXIS))
	                {
	                    case X:
	                        return state.withProperty(FAITEMOI_AXIS, BlockFaiteMoi.EnumAxis.Z);
	                    case Z:
	                        return state.withProperty(FAITEMOI_AXIS, BlockFaiteMoi.EnumAxis.X);
	                    default:
	                        return state;
	                }

	            default:
	                return state;
	        }
	    }

	    public static enum EnumAxis implements IStringSerializable
	    {
	        X("x"),
	        Y("y"),
	        Z("z"),
	        NONE("none");

	        private final String name;

	        private EnumAxis(String name)
	        {
	            this.name = name;
	        }

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

	        public static BlockFaiteMoi.EnumAxis fromFacingAxis(EnumFacing.Axis axis)
	        {
	            switch (axis)
	            {
	                case X:
	                    return X;
	                case Y:
	                    return Y;
	                case Z:
	                    return Z;
	                default:
	                    return NONE;
	            }
	        }

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

 

The question is : why the console says "error with BlockContainer" when I don't have used any BlockContainer in this code ? 

 

thanks for the help.

Posted

BlockStateContainer, not BlockContainer. You need to register all your block state variants in your block. I can't remember to method that you have to override, but look at something like wool.

Posted
6 minutes ago, themistik said:

The question is : why the console says "error with BlockContainer" when I don't have used any BlockContainer in this code ? 

 

Because BlockRotatedPillar specifies it.

When you are setting a property in your blockstate the BlockStateContainer associated with that block must have that property in it's list of valid properties. You are setting a value of your property but the BlockStateContainer does not have it registered in it's list. Why are you extending BlockRotatedPillar that already has the rotation axis coded in and reinventing the wheel introducing your own axis property? Either do not extend BlockRotatedPillar or drop your property and enum completely.

 

Posted

Beacause for the story, I wanted to make a block rotate with a texture, first I have followed this tutorial : 

 

 

But it dosen't work, so for help me I've searched a lot of tutorial, but I've find NOTHING, I have even search on the source code for, by exemple, the Oak Wood Block, but same : Nothing. Many Documentations : Nothing. After one day of searching (a REAL day), I've finally find the code for the Oak Wood Block, But I was 100% salty, so I just copy and past the code like a retard and modify some things to work out. But this happends.

 

So I Guess I just need to extends to Block ?

Posted
7 minutes ago, themistik said:

After one day of searching (a REAL day), I've finally find the code for the Oak Wood Block

You can simply use your IDE to navigate to any vanilla class (IDEA: Navigate -> Class, Eclipse: Navigate -> Open Type) and type in the name of the class you wish to go to.

 

7 minutes ago, themistik said:

I wanted to make a block rotate with a texture

You can drop your own property and the enum and simply let BlockRotatedPillar do everything for you then.

  • Like 1

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



×
×
  • Create New...

Important Information

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