Jump to content

Recommended Posts

Posted (edited)

Hello again!

 

I've been messing around with block properties.

I wanted to create a block with multiple properties so I've created a TileEntity for that block.

 

Code \/

Spoiler

Block

Spoiler


package com.test;

import javax.annotation.Nullable;

import com.nuclearbanana.cheesemod.util.IHasModel;
import com.nuclearbanana.cheesemod.util.Reference;
import com.nuclearbanana.cheesemod.util.RegisterHandler;

import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.BlockHorizontal;
import net.minecraft.block.SoundType;
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.properties.PropertyInteger;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Mirror;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

public class TestBlock extends BlockContainer implements IHasModel {
	
	public static final PropertyInteger VALUE = PropertyInteger.create("value", 0, 15);
    public static final PropertyDirection FACING = BlockHorizontal.FACING;
    public static final PropertyEnum TYPE = PropertyEnum.create("type", EnumTest.class);
    
	private String name;
	
	public TestBlock(String name) {
		super(Material.PISTON);
		this.setHardness(0.6F);
		this.setSoundType(SoundType.STONE);
		this.setHarvestLevel("axe", 1);
		this.setDefaultState(this.blockState.getBaseState().withProperty(TYPE, EnumTest.TYPE1).withProperty(VALUE, Integer.valueOf(0)));
		this.name = name;
		this.setRegistryName(name);
		RegisterHandler.registerBlock(this);
	}
	
	@Override
	public String getUnlocalizedName() {

		return "tile." + Reference.RESOURCE_PREFIX + this.name;
	}
    
    @Override
	public void registerModels() {
		CheeseMod.proxy.registerItemRenderer(Item.getItemFromBlock(this), 0, "inventory");
	}

	@Override
	public TileEntity createNewTileEntity(World worldIn, int meta) {
		return new TileEntityTestBlock();
	}
	
	@Override
    public boolean hasTileEntity(final IBlockState state)
    {
        return true;
    }
    
	protected BlockStateContainer createBlockState()
    {
        return new BlockStateContainer(this, new IProperty[] {VALUE, FACING, TYPE});
    }
	
	@Nullable
    public TileEntityTestBlock getTileEntity(final IBlockAccess world, final BlockPos pos)
    {
        return (TileEntityTestBlock) world.getTileEntity(pos);
    }
	
	public int getCheese(final IBlockAccess world, final BlockPos pos)
    {
        final TileEntityTestBlock tileEntity = getTileEntity(world, pos);
        return tileEntity != null ? tileEntity.getCheese() : 0;
    }
	
	public EnumFacing getFacing(final IBlockAccess world, final BlockPos pos)
    {
        final TileEntityTestBlock tileEntity = getTileEntity(world, pos);
        return tileEntity != null ? tileEntity.getFacing() : EnumFacing.NORTH;
    }
	
	public void setFacing(final IBlockAccess world, final BlockPos pos, final EnumFacing facing)
    {
        final TileEntityTestBlock tileEntity = getTileEntity(world, pos);
        if (tileEntity != null) {
            tileEntity.setFacing(facing);
        }
    }
	
	public EnumTest getType(final IBlockAccess world, final BlockPos pos)
    {
        final TileEntityTestBlock tileEntity = getTileEntity(world, pos);
        return tileEntity != null ? tileEntity.getType() : EnumTest.TYPE1;
    }
	
	private void setDefaultFacing(World worldIn, BlockPos pos, IBlockState state)
    {
        if (!worldIn.isRemote)
        {
            IBlockState iblockstate = worldIn.getBlockState(pos.north());
            IBlockState iblockstate1 = worldIn.getBlockState(pos.south());
            IBlockState iblockstate2 = worldIn.getBlockState(pos.west());
            IBlockState iblockstate3 = worldIn.getBlockState(pos.east());
            EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);

            if (enumfacing == EnumFacing.NORTH && iblockstate.isFullBlock() && !iblockstate1.isFullBlock())
            {
                enumfacing = EnumFacing.SOUTH;
            }
            else if (enumfacing == EnumFacing.SOUTH && iblockstate1.isFullBlock() && !iblockstate.isFullBlock())
            {
                enumfacing = EnumFacing.NORTH;
            }
            else if (enumfacing == EnumFacing.WEST && iblockstate2.isFullBlock() && !iblockstate3.isFullBlock())
            {
                enumfacing = EnumFacing.EAST;
            }
            else if (enumfacing == EnumFacing.EAST && iblockstate3.isFullBlock() && !iblockstate2.isFullBlock())
            {
                enumfacing = EnumFacing.WEST;
            }

            worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2);
        }
    }
	
	public IBlockState withRotation(IBlockState state, Rotation rot)
    {
        return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING)));
    }
    
    public IBlockState withMirror(IBlockState state, Mirror mirrorIn)
    {
        return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING)));
    }

    @SuppressWarnings("deprecation")
    @Override
    public IBlockState getActualState(final IBlockState state, final IBlockAccess worldIn, final BlockPos pos)
    {
        return state.withProperty(VALUE, getValue(worldIn, pos))
        		.withProperty(FACING, getFacing(worldIn, pos))
                .withProperty(TYPE, getType(worldIn, pos));
    }
    
    @Override
    public IBlockState getStateFromMeta(int meta)
    {
        return this.getDefaultState().withProperty(VALUE, Integer.valueOf(meta));
    }

    public int getMetaFromState(IBlockState state)
    {
    	return ((Integer)state.getValue(VALUE)).intValue();
    }
}

 

 

TileEntity


package com.test;

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

import javax.annotation.Nullable;

import net.minecraft.block.BlockHorizontal;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

public class TileEntityTestBlock extends TileEntity implements ITickable {

    private int value;
    private EnumFacing facing;
    private EnumTest type;
	
	@Override
	public void update() {
		if (!world.isRemote) {
			// System.out.println("it works");
		}
	}
	
	public int getValue() {
		return this.Value
	}
	
	public EnumFacing getFacing() {
		return this.facing;
	}
	
	public void setFacing(final EnumFacing facing) {
        this.facing = facing;
        markDirty();
    }
	
	public EnumTest getType() {
		return this.type;
	}
	
	@Override
    public NBTTagCompound writeToNBT(NBTTagCompound compound) {
        super.writeToNBT(compound);

        compound.setInteger("value", this.value);
        compound.setInteger("facing", facing.getIndex());
        compound.setInteger("type", type.getIndex());
        
        return compound;
    }

    @Override
    public void readFromNBT(NBTTagCompound compound) {
        super.readFromNBT(compound);

        this.value = compound.getInteger("value");
        this.facing = EnumFacing.getFront(compound.getInteger("facing"));
        this.type = EnumTest.getType(compound.getInteger("type"));
        
    }
    
    private void notifyBlockUpdate() {
        final IBlockState state = getWorld().getBlockState(getPos());
        getWorld().notifyBlockUpdate(getPos(), state, state, 3);
    }
    
    @Override
    public void markDirty() {
        super.markDirty();
        notifyBlockUpdate();
    }
    
    @Override
    public NBTTagCompound getUpdateTag() {
        return writeToNBT(new NBTTagCompound());
    }
    
    @Nullable
    @Override
    public SPacketUpdateTileEntity getUpdatePacket()
    {
        return new SPacketUpdateTileEntity(getPos(), 0, getUpdateTag());
    }

    @Override
    public void onDataPacket(final NetworkManager net, final SPacketUpdateTileEntity pkt)
    {
        readFromNBT(pkt.getNbtCompound());
        notifyBlockUpdate();
    }

    @Override
    public boolean shouldRefresh(final World world, final BlockPos pos, final IBlockState oldState, final IBlockState newState)
    {
        return oldState.getBlock() != newState.getBlock();
    }
}

 

EnumTest


package com.test;

import net.minecraft.block.BlockDoublePlant.EnumBlockHalf;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3i;

public enum EnumTest implements IStringSerializable {
	
	TYPE1(0, "first_type"),
	TYPE2(1, "second_type"),
	TYPE3(2, "third_type");

	private int index;
	private String name;
	
	public static final EnumTest[] VALUES = new EnumTest[3];
	
	private EnumTest(int index, String name)
    {
        this.index = index;
        this.name = name;
    }
	
	public static EnumTest getType(int index) {
		return VALUES[MathHelper.abs(index % VALUES.length)];
	}
	
	public void setIndex(int index) {
		this.index = index;
	}
	
	public int getIndex() {
        return this.index;
    }
	
	@Override
	public String getName() {
		return this.name;
	}
	
	
}

 

I registered the TileEntity in pre init in common proxy class


public void preInit(FMLPreInitializationEvent event) {
	GameRegistry.registerTileEntity(TileEntityTestBlock.class, "tile_entity_test_block");
}

 

And I called that method in main class preinit method

 

 

 

Everything compiles and runs ok, Even placing the block works, but whenever I F3 or destroy the block it crashes by throwing and IllegalArgumentException that It cannot set property.

 

What am I doing wrong here? I am new with tile entities so I am probably making some mistakes

 

 

 

 

 

 

Edited by ShowerManiac
Posted

The default state doesn't contain the FACING property.

 

10 minutes ago, ShowerManiac said:

it crashes

This time it was easy to discover the issue without logs. Next time, always post logs when you crash.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted (edited)

Now when I try to place a block it crashes.

 

Log

Spoiler


[14:22:01] [Server thread/INFO]: [Player266: Given [tile.testmod:test_block.name] * 1 to Player266]
[14:22:01] [main/INFO]: [CHAT] Given [tile.testmod:test_block.name] * 1 to Player266
[14:22:05] [Server thread/ERROR]: Encountered an unexpected exception
net.minecraft.util.ReportedException: Exception ticking world
    at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:835) ~[MinecraftServer.class:?]
    at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:741) ~[MinecraftServer.class:?]
    at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192) ~[IntegratedServer.class:?]
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:590) [MinecraftServer.class:?]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_144]
Caused by: java.lang.NullPointerException
    at com.test.tileentity.TileEntityTestBlock.writeToNBT(TileEntityTestBlock.java:60) ~[TileEntityTestBlock.class:?]
    at com.test.tileentity.TileEntityTestBlock.getUpdateTag(TileEntityTestBlock.java:89) ~[TileEntityTestBlock.class:?]
    at com.test.tileentity.TileEntityTestBlock.getUpdatePacket(TileEntityTestBlock.java:96) ~[TileEntityTestBlock.class:?]
    at net.minecraft.server.management.PlayerChunkMapEntry.sendBlockEntity(PlayerChunkMapEntry.java:296) ~[PlayerChunkMapEntry.class:?]
    at net.minecraft.server.management.PlayerChunkMapEntry.update(PlayerChunkMapEntry.java:258) ~[PlayerChunkMapEntry.class:?]
    at net.minecraft.server.management.PlayerChunkMap.tick(PlayerChunkMap.java:139) ~[PlayerChunkMap.class:?]
    at net.minecraft.world.WorldServer.tick(WorldServer.java:236) ~[WorldServer.class:?]
    at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:829) ~[MinecraftServer.class:?]
    ... 4 more
[14:22:05] [Server thread/ERROR]: This crash report has been saved to: mod location\run\.\crash-reports\crash-2018-02-11_14.22.05-server.txt
[14:22:05] [Server thread/INFO]: Stopping server
[14:22:05] [Server thread/INFO]: Saving players
[14:22:05] [Server thread/INFO]: Player266 lost connection: Server closed
[14:22:05] [Server thread/INFO]: Player266 left the game
[14:22:05] [Server thread/INFO]: Stopping singleplayer server as player logged out
[14:22:05] [Server thread/INFO]: Saving worlds
[14:22:05] [Server thread/INFO]: Saving chunks for level 'te test'/overworld
[14:22:05] [Server thread/ERROR] [FML]: A TileEntity type com.test.tileentity.TileEntityTestBlock has throw an exception trying to write state. It will not persist. Report this to the mod author
java.lang.NullPointerException: null
    at com.test.tileentity.TileEntityTestBlock.writeToNBT(TileEntityTestBlock.java:60) ~[TileEntityTestBlock.class:?]
    at net.minecraft.world.chunk.storage.AnvilChunkLoader.writeChunkToNBT(AnvilChunkLoader.java:412) [AnvilChunkLoader.class:?]
    at net.minecraft.world.chunk.storage.AnvilChunkLoader.saveChunk(AnvilChunkLoader.java:183) [AnvilChunkLoader.class:?]
    at net.minecraft.world.gen.ChunkProviderServer.saveChunkData(ChunkProviderServer.java:214) [ChunkProviderServer.class:?]
    at net.minecraft.world.gen.ChunkProviderServer.saveChunks(ChunkProviderServer.java:242) [ChunkProviderServer.class:?]
    at net.minecraft.world.WorldServer.saveAllChunks(WorldServer.java:1060) [WorldServer.class:?]
    at net.minecraft.server.MinecraftServer.saveAllWorlds(MinecraftServer.java:468) [MinecraftServer.class:?]
    at net.minecraft.server.integrated.IntegratedServer.saveAllWorlds(IntegratedServer.java:274) [IntegratedServer.class:?]
    at net.minecraft.server.MinecraftServer.stopServer(MinecraftServer.java:509) [MinecraftServer.class:?]
    at net.minecraft.server.integrated.IntegratedServer.stopServer(IntegratedServer.java:413) [IntegratedServer.class:?]
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:643) [MinecraftServer.class:?]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_144]
[14:22:05] [Server thread/INFO]: Saving chunks for level 'te test'/the_nether
[14:22:05] [Server thread/INFO]: Saving chunks for level 'te test'/the_end
[14:22:05] [Server thread/INFO] [FML]: Unloading dimension 0
[14:22:05] [Server thread/INFO] [FML]: Unloading dimension -1
[14:22:05] [Server thread/INFO] [FML]: Unloading dimension 1
[14:22:05] [Server thread/INFO] [FML]: Applying holder lookups
[14:22:05] [Server thread/INFO] [FML]: Holder lookups applied
[14:22:05] [Server thread/INFO] [FML]: The state engine was in incorrect state SERVER_STOPPING and forced into state SERVER_STOPPED. Errors may have been discarded.
 

 

Edited by ShowerManiac
Posted
1 hour ago, ShowerManiac said:

Caused by: java.lang.NullPointerException
    at com.test.tileentity.TileEntityTestBlock.writeToNBT(TileEntityTestBlock.java:60) ~[TileEntityTestBlock.class:?]

One of the values used in writeToNBT is null.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

How can it be null if the block has a default state?

 

I surrounded writeNBT with a try/catch block. Not a difference

 

crash log

Spoiler

[16:36:05] [Server thread/INFO]: [Player991: Given [tile.testmod:test_block.name] * 1 to Player991]
[16:36:05] [main/INFO]: [CHAT] Given [tile.testmod:test_block.name] * 1 to Player991
[16:36:09] [Server thread/INFO] [STDOUT]: [com.test.tileentity.TileEntityTestBlock:writeToNBT:65]: Ex: null
[16:36:13] [Server thread/INFO]: Stopping server
[16:36:13] [Server thread/INFO]: Saving players
[16:36:13] [Server thread/INFO]: Saving worlds
[16:36:13] [Server thread/INFO]: Saving chunks for level 'te test'/overworld
[16:36:13] [Server thread/INFO] [STDOUT]: [com.test.tileentity.TileEntityTestBlock:writeToNBT:65]: Ex: null
[16:36:13] [Server thread/INFO]: Saving chunks for level 'te test'/the_nether
[16:36:13] [Server thread/INFO]: Saving chunks for level 'te test'/the_end
[16:36:13] [Server thread/INFO] [FML]: Unloading dimension 0
[16:36:13] [Server thread/INFO] [FML]: Unloading dimension -1
[16:36:13] [Server thread/INFO] [FML]: Unloading dimension 1
[16:36:13] [Server thread/INFO] [FML]: Applying holder lookups
[16:36:13] [Server thread/INFO] [FML]: Holder lookups applied
[16:36:14] [main/FATAL]: Unreported exception thrown!
java.lang.IllegalArgumentException: Cannot set property PropertyDirection{name=facing, clazz=class net.minecraft.util.EnumFacing, values=[north, south, west, east]} to down on block testmod:test_block, it is not an allowed value
    at net.minecraft.block.state.BlockStateContainer$StateImplementation.withProperty(BlockStateContainer.java:233) ~[BlockStateContainer$StateImplementation.class:?]
    at com.test.blocks.TestBlock.getActualState(TestBlock.java:153) ~[TestBlock.class:?]
    at net.minecraft.block.state.BlockStateContainer$StateImplementation.getActualState(BlockStateContainer.java:435) ~[BlockStateContainer$StateImplementation.class:?]
    at net.minecraft.client.gui.GuiOverlayDebug.getDebugInfoRight(GuiOverlayDebug.java:208) ~[GuiOverlayDebug.class:?]
    at net.minecraftforge.client.GuiIngameForge$GuiOverlayDebugForge.getRight(GuiIngameForge.java:932) ~[GuiIngameForge$GuiOverlayDebugForge.class:?]
    at net.minecraftforge.client.GuiIngameForge$GuiOverlayDebugForge.access$200(GuiIngameForge.java:914) ~[GuiIngameForge$GuiOverlayDebugForge.class:?]
    at net.minecraftforge.client.GuiIngameForge.renderHUDText(GuiIngameForge.java:708) ~[GuiIngameForge.class:?]
    at net.minecraftforge.client.GuiIngameForge.renderGameOverlay(GuiIngameForge.java:172) ~[GuiIngameForge.class:?]
    at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1151) ~[EntityRenderer.class:?]
    at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1207) ~[Minecraft.class:?]
    at net.minecraft.client.Minecraft.run(Minecraft.java:441) [Minecraft.class:?]
    at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_144]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_144]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_144]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_144]
    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_144]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_144]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_144]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_144]
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
    at GradleStart.main(GradleStart.java:26) [start/:?]
[16:36:14] [main/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:629]: ---- Minecraft Crash Report ----
// Would you like a cupcake?

Time: 2/11/18 4:36 PM
Description: Unexpected error

java.lang.IllegalArgumentException: Cannot set property PropertyDirection{name=facing, clazz=class net.minecraft.util.EnumFacing, values=[north, south, west, east]} to down on block testmod:test_block, it is not an allowed value
    at net.minecraft.block.state.BlockStateContainer$StateImplementation.withProperty(BlockStateContainer.java:233)
    at com.test.blocks.TestBlock.getActualState(TestBlock.java:153)
    at net.minecraft.block.state.BlockStateContainer$StateImplementation.getActualState(BlockStateContainer.java:435)
    at net.minecraft.client.gui.GuiOverlayDebug.getDebugInfoRight(GuiOverlayDebug.java:208)
    at net.minecraftforge.client.GuiIngameForge$GuiOverlayDebugForge.getRight(GuiIngameForge.java:932)
    at net.minecraftforge.client.GuiIngameForge$GuiOverlayDebugForge.access$200(GuiIngameForge.java:914)
    at net.minecraftforge.client.GuiIngameForge.renderHUDText(GuiIngameForge.java:708)
    at net.minecraftforge.client.GuiIngameForge.renderGameOverlay(GuiIngameForge.java:172)
    at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1151)
    at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1207)
    at net.minecraft.client.Minecraft.run(Minecraft.java:441)
    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)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Client thread
Stacktrace:
    at net.minecraft.block.state.BlockStateContainer$StateImplementation.withProperty(BlockStateContainer.java:233)
    at com.test.blocks.TestBlock.getActualState(TestBlock.java:153)
    at net.minecraft.block.state.BlockStateContainer$StateImplementation.getActualState(BlockStateContainer.java:435)
    at net.minecraft.client.gui.GuiOverlayDebug.getDebugInfoRight(GuiOverlayDebug.java:208)
    at net.minecraftforge.client.GuiIngameForge$GuiOverlayDebugForge.getRight(GuiIngameForge.java:932)
    at net.minecraftforge.client.GuiIngameForge$GuiOverlayDebugForge.access$200(GuiIngameForge.java:914)
    at net.minecraftforge.client.GuiIngameForge.renderHUDText(GuiIngameForge.java:708)
    at net.minecraftforge.client.GuiIngameForge.renderGameOverlay(GuiIngameForge.java:172)

-- Affected level --
Details:
    Level name: MpServer
    All players: 1 total; [EntityPlayerSP['Player991'/104, l='MpServer', x=201.60, y=59.00, z=350.51]]
    Chunk stats: MultiplayerChunkCache: 225, 225
    Level seed: 0
    Level generator: ID 02 - largeBiomes, ver 0. Features enabled: false
    Level generator options: 
    Level spawn location: World: (20,64,256), Chunk: (at 4,4,0 in 1,16; contains blocks 16,0,256 to 31,255,271), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
    Level time: 16823 game time, 6000 day time
    Level dimension: 0
    Level storage version: 0x00000 - Unknown?
    Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)
    Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false
    Forced entities: 1 total; [EntityPlayerSP['Player991'/104, l='MpServer', x=201.60, y=59.00, z=350.51]]
    Retry entities: 0 total; []
    Server brand: fml,forge
    Server type: Integrated singleplayer server
Stacktrace:
    at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:461)
    at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2896)
    at net.minecraft.client.Minecraft.run(Minecraft.java:470)
    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)

-- System Details --
Details:
    Minecraft Version: 1.12.2
    Operating System: Windows 7 (amd64) version 6.1
    Java Version: 1.8.0_144, Oracle Corporation
    Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    Memory: 747461072 bytes (712 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
    JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
    IntCache: cache: 0, tcache: 8, allocated: 20, tallocated: 90
    FML: MCP 9.42 Powered by Forge 14.23.1.2581 5 mods loaded, 5 mods active
    States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored

    | State     | ID        | Version      | Source                           | Signature |
    |:--------- |:--------- |:------------ |:-------------------------------- |:--------- |
    | UCHIJAAAA | minecraft | 1.12.2       | minecraft.jar                    | None      |
    | UCHIJAAAA | mcp       | 9.42         | minecraft.jar                    | None      |
    | UCHIJAAAA | FML       | 8.0.99.99    | forgeSrc-1.12.2-14.23.1.2581.jar | None      |
    | UCHIJAAAA | forge     | 14.23.1.2581 | forgeSrc-1.12.2-14.23.1.2581.jar | None      |
    | UCHIJAAAA | testmod   | alpha 1.0    | bin                              | None      |

    Loaded coremods (and transformers): 
    GL info: ' Vendor: 'ATI Technologies Inc.' Version: '4.5.13397 Compatibility Profile Context 15.200.1046.0' Renderer: 'AMD Radeon R7 250 Series'
    Launched Version: 1.12.2
    LWJGL: 2.9.4
    OpenGL: AMD Radeon R7 250 Series GL version 4.5.13397 Compatibility Profile Context 15.200.1046.0, ATI Technologies Inc.
    GL Caps: Using GL 1.3 multitexturing.
Using GL 1.3 texture combiners.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Shaders are available because OpenGL 2.1 is supported.
VBOs are available because OpenGL 1.5 is supported.

    Using VBOs: Yes
    Is Modded: Definitely; Client brand changed to 'fml,forge'
    Type: Client (map_client.txt)
    Resource Packs: 
    Current Language: English (US)
    Profiler Position: N/A (disabled)
    CPU: 4x AMD Athlon(tm) X4 840 Quad Core Processor 
[16:36:14] [main/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:629]: #@!@# Game crashed! Crash report saved to: #@!@# yup\run\.\crash-reports\crash-2018-02-11_16.36.14-client.txt
AL lib: (EE) alc_cleanup: 1 device not closed
Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
 

 

Posted (edited)
1 hour ago, ShowerManiac said:

How can it be null if the block has a default state?

You need to add the FACING property to the container, eg:

https://github.com/Draco18s/ReasonableRealism/blob/master/src/main/java/com/draco18s/ores/block/BlockMillstone.java#L48-L51

https://github.com/Draco18s/ReasonableRealism/blob/master/src/main/java/com/draco18s/ores/block/BlockAxel.java#L60-L63

Edited by Draco18s

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
1 hour ago, Draco18s said:

there is 

protected BlockStateContainer createBlockState()
    {
        return new BlockStateContainer(this, new IProperty[] {VALUE, FACING, TYPE});
    }

 

Posted
6 hours ago, ShowerManiac said:

BlockContainer

By the way, don't extend BlockContainer. It does nothing you want.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted (edited)
28 minutes ago, Draco18s said:

By the way, don't extend BlockContainer. It does nothing you want.

Okay. That actually was the problem. It works now.

 

One more question. Do I update/set the block state with regular 

world.setBlockState(pos, world.getBlockState(pos).withProperty(VALUE, Integer.valueOf(4)), 2);

Or do I do it somehow different? because this is happening (values should be the same as Val in the console)

Image

Edited by ShowerManiac
Posted

If your state is stored by the TE, you need to update the TE's value. SetBlockState only changes the metadata.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.