Jump to content

Recommended Posts

Posted (edited)

So... I'm attempting to make something that may be a bit excessive.

 

I'm trying to add more skulls to the game. I simply decided to use the existing tile entity in the game... but I'm not sure if this is the right approach. However, that doesn't seem to be the case as both the block and item are registered without an issue... it's only when the game attempts to RENDER it, that it finally crashes. I've tested a little with this by changing the Creeper Head's texture, but nothing changed. I'm not sure if I have to register a new tile entity completely, but if that is the case, I've attempted that already with identical results.

 

So, I guess what I'm trying to do, is replace the TileEntityRenderer for SkullTileEntity.

 

Here is the code that I have so far, and hopefully, someone can show me what I'm doing wrong... (which is probably also the WAY I'm doing it)

 

My TileEntityRenderer (A slightly modified version of Vanilla's SkullTileEntityRenderer):

@OnlyIn(Dist.CLIENT)
public class NewSkullTileEntityRenderer extends TileEntityRenderer<SkullTileEntity> {
	private static final Map<SkullBlock.ISkullType, GenericHeadModel> MODELS = Util.make(Maps.newHashMap(), (p_209262_0_) -> {
		GenericHeadModel genericheadmodel = new GenericHeadModel(0, 0, 64, 32);
		GenericHeadModel genericheadmodel1 = new HumanoidHeadModel();
		DragonHeadModel dragonheadmodel = new DragonHeadModel(0.0F);
		p_209262_0_.put(SkullBlock.Types.SKELETON, genericheadmodel);
		p_209262_0_.put(SkullBlock.Types.WITHER_SKELETON, genericheadmodel);
		p_209262_0_.put(SkullBlock.Types.PLAYER, genericheadmodel1);
		p_209262_0_.put(SkullBlock.Types.ZOMBIE, genericheadmodel1);
		p_209262_0_.put(SkullBlock.Types.CREEPER, genericheadmodel);
		p_209262_0_.put(SkullBlock.Types.DRAGON, dragonheadmodel);
		p_209262_0_.put(NewSkullBlock.Types.STEVE, genericheadmodel1);
		p_209262_0_.put(NewSkullBlock.Types.ALEX, genericheadmodel1);
	});
	private static final Map<SkullBlock.ISkullType, ResourceLocation> SKINS = Util.make(Maps.newHashMap(), (p_209263_0_) -> {
		p_209263_0_.put(SkullBlock.Types.SKELETON, new ResourceLocation("textures/entity/skeleton/skeleton.png"));
		p_209263_0_.put(SkullBlock.Types.WITHER_SKELETON, new ResourceLocation("textures/entity/skeleton/wither_skeleton.png"));
		p_209263_0_.put(SkullBlock.Types.ZOMBIE, new ResourceLocation("textures/entity/zombie/zombie.png"));
		p_209263_0_.put(SkullBlock.Types.CREEPER, new ResourceLocation("textures/entity/creeper/creeper.png"));
		p_209263_0_.put(SkullBlock.Types.DRAGON, new ResourceLocation("textures/entity/enderdragon/dragon.png"));
		p_209263_0_.put(SkullBlock.Types.PLAYER, DefaultPlayerSkin.getDefaultSkinLegacy());
		p_209263_0_.put(NewSkullBlock.Types.STEVE, new ResourceLocation("textures/entity/steve.png"));
		p_209263_0_.put(NewSkullBlock.Types.ALEX, new ResourceLocation("textures/entity/alex.png"));
	});

	public NewSkullTileEntityRenderer(TileEntityRendererDispatcher p_i226015_1_) {
		super(p_i226015_1_);
	}

	public void func_225616_a_(SkullTileEntity p_225616_1_, float p_225616_2_, MatrixStack p_225616_3_, IRenderTypeBuffer p_225616_4_, int p_225616_5_, int p_225616_6_) {
		float f = p_225616_1_.getAnimationProgress(p_225616_2_);
		BlockState blockstate = p_225616_1_.getBlockState();
		boolean flag = blockstate.getBlock() instanceof WallSkullBlock;
		Direction direction = flag ? blockstate.get(WallSkullBlock.FACING) : null;
		float f1 = 22.5F * (float)(flag ? (2 + direction.getHorizontalIndex()) * 4 : blockstate.get(SkullBlock.ROTATION));
		func_228879_a_(direction, f1, ((AbstractSkullBlock)blockstate.getBlock()).getSkullType(), p_225616_1_.getPlayerProfile(), f, p_225616_3_, p_225616_4_, p_225616_5_);
	}

	public static void func_228879_a_(@Nullable Direction p_228879_0_, float p_228879_1_, SkullBlock.ISkullType p_228879_2_, @Nullable GameProfile p_228879_3_, float p_228879_4_, MatrixStack p_228879_5_, IRenderTypeBuffer p_228879_6_, int p_228879_7_) {
		GenericHeadModel genericheadmodel = MODELS.get(p_228879_2_);
		p_228879_5_.func_227860_a_();
		if (p_228879_0_ == null) {
			p_228879_5_.func_227861_a_(0.5D, 0.0D, 0.5D);
		} else {
			switch(p_228879_0_) {
				case NORTH:
					p_228879_5_.func_227861_a_(0.5D, 0.25D, (double)0.74F);
					break;
				case SOUTH:
					p_228879_5_.func_227861_a_(0.5D, 0.25D, (double)0.26F);
					break;
				case WEST:
					p_228879_5_.func_227861_a_((double)0.74F, 0.25D, 0.5D);
					break;
				case EAST:
				default:
					p_228879_5_.func_227861_a_((double)0.26F, 0.25D, 0.5D);
			}
		}

		p_228879_5_.func_227862_a_(-1.0F, -1.0F, 1.0F);
		IVertexBuilder ivertexbuilder = p_228879_6_.getBuffer(func_228878_a_(p_228879_2_, p_228879_3_));
		genericheadmodel.func_225603_a_(p_228879_4_, p_228879_1_, 0.0F);
		genericheadmodel.func_225598_a_(p_228879_5_, ivertexbuilder, p_228879_7_, OverlayTexture.field_229196_a_, 1.0F, 1.0F, 1.0F, 1.0F);
		p_228879_5_.func_227865_b_();
	}

	private static RenderType func_228878_a_(SkullBlock.ISkullType p_228878_0_, @Nullable GameProfile p_228878_1_) {
		ResourceLocation resourcelocation = SKINS.get(p_228878_0_);
		if (p_228878_0_ == SkullBlock.Types.PLAYER && p_228878_1_ != null) {
			Minecraft minecraft = Minecraft.getInstance();
			Map<Type, MinecraftProfileTexture> map = minecraft.getSkinManager().loadSkinFromCache(p_228878_1_);
			return map.containsKey(Type.SKIN) ? RenderType.func_228644_e_(minecraft.getSkinManager().loadSkin(map.get(Type.SKIN), Type.SKIN)) : RenderType.func_228640_c_(DefaultPlayerSkin.getDefaultSkin(PlayerEntity.getUUID(p_228878_1_)));
		} else {
			return RenderType.func_228640_c_(resourcelocation);
		}
	}
}

 

My Registry:

	  @SubscribeEvent
	  public void init(FMLClientSetupEvent event)
	  {
		  ClientRegistry.bindTileEntityRenderer(TileEntityType.Builder.create(SkullTileEntity::new,
			  ModBlocks.steve_head,
			  ModBlocks.steve_head_wall,
			  ModBlocks.alex_head,
			  ModBlocks.alex_head_wall
		  ).build(null), NewSkullTileEntityRenderer::new);
	  }

 

My NewSkullBlock (Since SkullBlock is Private):

public class NewSkullBlock extends SkullBlock {
	public static final IntegerProperty ROTATION = BlockStateProperties.ROTATION_0_15;
	protected static final VoxelShape SHAPE = Block.makeCuboidShape(4.0D, 0.0D, 4.0D, 12.0D, 8.0D, 12.0D);

	public NewSkullBlock(SkullBlock.ISkullType type, Block.Properties properties) {
		super(type, properties);
		this.setDefaultState(this.stateContainer.getBaseState().with(ROTATION, Integer.valueOf(0)));
	}

	public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
		return SHAPE;
	}

	public VoxelShape getRenderShape(BlockState state, IBlockReader worldIn, BlockPos pos) {
		return VoxelShapes.empty();
	}

	public BlockState getStateForPlacement(BlockItemUseContext context) {
		return this.getDefaultState().with(ROTATION, Integer.valueOf(MathHelper.floor((double)(context.getPlacementYaw() * 16.0F / 360.0F) + 0.5D) & 15));
	}

	public BlockState rotate(BlockState state, Rotation rot) {
		return state.with(ROTATION, Integer.valueOf(rot.rotate(state.get(ROTATION), 16)));
	}

	public BlockState mirror(BlockState state, Mirror mirrorIn) {
		return state.with(ROTATION, Integer.valueOf(mirrorIn.mirrorRotation(state.get(ROTATION), 16)));
	}

	protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
		builder.add(ROTATION);
	}

	public interface ISkullType {
	}

	public static enum Types implements SkullBlock.ISkullType {
		STEVE,
		ALEX;
	}
}

 

My (WallSkullBlock is also private) NewWallSkullBlock:

public class NewWallSkullBlock extends WallSkullBlock {
	public static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING;
	private static final Map<Direction, VoxelShape> SHAPES = Maps.newEnumMap(ImmutableMap.of(Direction.NORTH, Block.makeCuboidShape(4.0D, 4.0D, 8.0D, 12.0D, 12.0D, 16.0D), Direction.SOUTH, Block.makeCuboidShape(4.0D, 4.0D, 0.0D, 12.0D, 12.0D, 8.0D), Direction.EAST, Block.makeCuboidShape(0.0D, 4.0D, 4.0D, 8.0D, 12.0D, 12.0D), Direction.WEST, Block.makeCuboidShape(8.0D, 4.0D, 4.0D, 16.0D, 12.0D, 12.0D)));

	public NewWallSkullBlock(SkullBlock.ISkullType type, Block.Properties properties) {
		super(type, properties);
		this.setDefaultState(this.stateContainer.getBaseState().with(FACING, Direction.NORTH));
	}

	public String getTranslationKey() {
		return this.asItem().getTranslationKey();
	}

	public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
		return SHAPES.get(state.get(FACING));
	}

	public BlockState getStateForPlacement(BlockItemUseContext context) {
		BlockState blockstate = this.getDefaultState();
		IBlockReader iblockreader = context.getWorld();
		BlockPos blockpos = context.getPos();
		Direction[] adirection = context.getNearestLookingDirections();

		for(Direction direction : adirection) {
			if (direction.getAxis().isHorizontal()) {
				Direction direction1 = direction.getOpposite();
				blockstate = blockstate.with(FACING, direction1);
				if (!iblockreader.getBlockState(blockpos.offset(direction)).isReplaceable(context)) {
					return blockstate;
				}
			}
		}

		return null;
	}

	public BlockState rotate(BlockState state, Rotation rot) {
		return state.with(FACING, rot.rotate(state.get(FACING)));
	}

	public BlockState mirror(BlockState state, Mirror mirrorIn) {
		return state.rotate(mirrorIn.toRotation(state.get(FACING)));
	}

	protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
		builder.add(FACING);
	}
}

 

My Item Registry:

new SkullItem(ModBlocks.steve_head, ModBlocks.steve_head_wall, (new Item.Properties()).group(ItemGroup.DECORATIONS).rarity(Rarity.UNCOMMON)).setRegistryName("[NAMESPACE HERE]","steve_head"),
new SkullItem(ModBlocks.alex_head, ModBlocks.alex_head_wall, (new Item.Properties()).group(ItemGroup.DECORATIONS).rarity(Rarity.UNCOMMON)).setRegistryName("[NAMESPACE HERE]","alex_head"),

 

My Block Registry:

steve_head = registerBlock(new NewSkullBlock(NewSkullBlock.Types.STEVE, Block.Properties.create(Material.MISCELLANEOUS).hardnessAndResistance(1.0F)),"[NAMESPACE HERE]","steve_head");
steve_head_wall = registerBlock(new NewWallSkullBlock(NewSkullBlock.Types.STEVE, Block.Properties.create(Material.MISCELLANEOUS).hardnessAndResistance(1.0F)),"[NAMESPACE HERE]","wall_steve_head");
alex_head = registerBlock(new NewSkullBlock(NewSkullBlock.Types.ALEX, Block.Properties.create(Material.MISCELLANEOUS).hardnessAndResistance(1.0F)),"[NAMESPACE HERE]","alex_head");
alex_head_wall = registerBlock(new NewWallSkullBlock(NewSkullBlock.Types.ALEX, Block.Properties.create(Material.MISCELLANEOUS).hardnessAndResistance(1.0F)),"[NAMESPACE HERE]","wall_alex_head");

 

Sorry for the huge amount of code, but I honestly don't know what's wrong here.

Thanks in advance!

Edited by MattNL
Updated code
  • 1 month later...
Posted

Hey everyone! I'm just gonna give this topic a bump. It's been over a month, and I still haven't got a clue what I'm doing wrong. Thanks in advance!

Posted

For starters this: 

.setRegistryName("[NAMESPACE HERE]","steve_head")

 won't work, everything has to be lowercase (and the namespace should be your modid).

 

Secondly, 

On 2/10/2020 at 11:27 PM, MattNL said:

it's only when the game attempts to RENDER it, that it finally crashes.

What is the error? Show us your log file.

Posted

 

On 3/24/2020 at 8:23 AM, Alpvax said:

For starters this: 


.setRegistryName("[NAMESPACE HERE]","steve_head")

 won't work, everything has to be lowercase (and the namespace should be your modid).

I tend to censor my namespaces. It's just something that I do. (The namespace is a proper lowercase modid)

Second, I should have posted the crash log before, and that's my bad.

 

---- Minecraft Crash Report ----
// Shall we play a game?

Time: 3/25/20 5:30 PM
Description: Rendering item

java.lang.NullPointerException: Rendering item
	at java.util.Objects.requireNonNull(Objects.java:203) ~[?:1.8.0_201] {}
	at java.util.Optional.<init>(Optional.java:96) ~[?:1.8.0_201] {}
	at java.util.Optional.of(Optional.java:108) ~[?:1.8.0_201] {}
	at net.minecraft.client.renderer.RenderState$TextureState.<init>(SourceFile:192) ~[forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.RenderType.func_230167_a_(SourceFile:116) ~[forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.RenderType.func_228640_c_(SourceFile:130) ~[forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.tileentity.SkullTileEntityRenderer.func_228878_a_(SourceFile:105) ~[forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.tileentity.SkullTileEntityRenderer.func_228879_a_(SourceFile:95) ~[forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer.func_228364_a_(SourceFile:81) ~[forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.ItemRenderer.func_229111_a_(ItemRenderer.java:108) ~[forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.ItemRenderer.renderItemModelIntoGUI(ItemRenderer.java:190) ~[forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.ItemRenderer.renderItemAndEffectIntoGUI(ItemRenderer.java:211) ~[forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.gui.screen.inventory.ContainerScreen.drawSlot(ContainerScreen.java:220) ~[forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.gui.screen.inventory.ContainerScreen.render(ContainerScreen.java:91) ~[forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.gui.DisplayEffectsScreen.render(DisplayEffectsScreen.java:45) ~[forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.gui.screen.inventory.CreativeScreen.render(CreativeScreen.java:605) ~[forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraftforge.client.ForgeHooksClient.drawScreen(ForgeHooksClient.java:359) ~[forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {re:classloading}
	at net.minecraft.client.renderer.GameRenderer.updateCameraAndRender(GameRenderer.java:480) ~[forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:925) ~[forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.run(Minecraft.java:554) ~[forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.main.Main.main(SourceFile:204) ~[forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_201] {}
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_201] {}
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_201] {}
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_201] {}
	at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:55) ~[forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-5.0.0-milestone.4.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-5.0.0-milestone.4.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-5.0.0-milestone.4.jar:?] {}
	at cpw.mods.modlauncher.Launcher.run(Launcher.java:81) [modlauncher-5.0.0-milestone.4.jar:?] {}
	at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) [modlauncher-5.0.0-milestone.4.jar:?] {}
	at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:102) [forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {}


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

-- Head --
Thread: Render thread
Stacktrace:
	at java.util.Objects.requireNonNull(Objects.java:203)
	at java.util.Optional.<init>(Optional.java:96)
	at java.util.Optional.of(Optional.java:108)
	at net.minecraft.client.renderer.RenderState$TextureState.<init>(SourceFile:192)
	at net.minecraft.client.renderer.RenderType.func_230167_a_(SourceFile:116)
	at net.minecraft.client.renderer.RenderType.func_228640_c_(SourceFile:130)
	at net.minecraft.client.renderer.tileentity.SkullTileEntityRenderer.func_228878_a_(SourceFile:105)
	at net.minecraft.client.renderer.tileentity.SkullTileEntityRenderer.func_228879_a_(SourceFile:95)
	at net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer.func_228364_a_(SourceFile:81)
	at net.minecraft.client.renderer.ItemRenderer.func_229111_a_(ItemRenderer.java:108)
	at net.minecraft.client.renderer.ItemRenderer.renderItemModelIntoGUI(ItemRenderer.java:190)

-- Item being rendered --
Details:
	Item Type: steve_head
	Registry Name: namespace_here:steve_head
	Item Damage: 0
	Item NBT: null
	Item Foil: false
Stacktrace:
	at net.minecraft.client.renderer.ItemRenderer.renderItemAndEffectIntoGUI(ItemRenderer.java:211)
	at net.minecraft.client.gui.screen.inventory.ContainerScreen.drawSlot(ContainerScreen.java:220)
	at net.minecraft.client.gui.screen.inventory.ContainerScreen.render(ContainerScreen.java:91)
	at net.minecraft.client.gui.DisplayEffectsScreen.render(DisplayEffectsScreen.java:45)
	at net.minecraft.client.gui.screen.inventory.CreativeScreen.render(CreativeScreen.java:605)
	at net.minecraftforge.client.ForgeHooksClient.drawScreen(ForgeHooksClient.java:359)

-- Screen render details --
Details:
	Screen name: net.minecraft.client.gui.screen.inventory.CreativeScreen
	Mouse location: Scaled: (280, 154). Absolute: (561.000000, 308.000000)
	Screen size: Scaled: (427, 240). Absolute: (854, 480). Scale factor of 2.000000

-- Affected level --
Details:
	All players: 1 total; [ClientPlayerEntity['MattNL'/15, l='MpServer', x=-366.95, y=95.00, z=83.23]]
	Chunk stats: Client Chunk Cache: 841, 187
	Level dimension: DimensionType{minecraft:overworld}
	Level name: MpServer
	Level seed: -1113229301927640182
	Level generator: ID 00 - default, ver 1. Features enabled: false
	Level generator options: {}
	Level spawn location: World: (112,75,-192), Chunk: (at 0,4,0 in 7,-12; contains blocks 112,0,-192 to 127,255,-177), Region: (0,-1; contains chunks 0,-32 to 31,-1, blocks 0,0,-512 to 511,255,-1)
	Level time: 194158 game time, 36310 day time
	Known server brands: 
	Level was modded: false
	Level storage version: 0x00000 - Unknown?
	Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)
	Level game mode: Game mode: survival (ID 0). Hardcore: false. Cheats: false
	Server brand: forge
	Server type: Integrated singleplayer server
Stacktrace:
	at net.minecraft.client.world.ClientWorld.fillCrashReport(ClientWorld.java:442)
	at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:1764)
	at net.minecraft.client.Minecraft.run(Minecraft.java:568)
	at net.minecraft.client.main.Main.main(SourceFile:204)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:55)
	at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37)
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54)
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72)
	at cpw.mods.modlauncher.Launcher.run(Launcher.java:81)
	at cpw.mods.modlauncher.Launcher.main(Launcher.java:65)
	at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:102)

-- System Details --
Details:
	Minecraft Version: 1.15.2
	Minecraft Version ID: 1.15.2
	Operating System: Windows 10 (amd64) version 10.0
	Java Version: 1.8.0_201, Oracle Corporation
	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
	Memory: 300534696 bytes (286 MB) / 1183842304 bytes (1129 MB) up to 1873805312 bytes (1787 MB)
	CPUs: 8
	JVM Flags: 1 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump
	ModLauncher: 5.0.0-milestone.4+67+b1a340b
	ModLauncher launch target: fmluserdevclient
	ModLauncher naming: mcp
	ModLauncher services: 
		/eventbus-2.0.0-milestone.1-service.jar eventbus PLUGINSERVICE 
		/forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3-launcher.jar object_holder_definalize PLUGINSERVICE 
		/forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3-launcher.jar runtime_enum_extender PLUGINSERVICE 
		/accesstransformers-2.0.0-milestone.1-shadowed.jar accesstransformer PLUGINSERVICE 
		/forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3-launcher.jar capability_inject_definalize PLUGINSERVICE 
		/forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3-launcher.jar runtimedistcleaner PLUGINSERVICE 
		/forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3-launcher.jar fml TRANSFORMATIONSERVICE 
	FML: 31.1
	Forge: net.minecraftforge:31.1.0
	FML Language Providers: 
		[email protected]
		minecraft@1
	Mod List: 
		client-extra.jar Minecraft {[email protected] DONE}
		main Minecraft: namespace_here {namespace_here@NONE DONE}
		forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar Forge {[email protected] DONE}
	Launched Version: MOD_DEV
	Backend library: LWJGL version 3.2.2 build 10
	Backend API: Intel(R) UHD Graphics 630 GL version 4.5.0 - Build 23.20.16.5018, Intel
	GL Caps: Using framebuffer using OpenGL 3.0
	Using VBOs: Yes
	Is Modded: Definitely; Client brand changed to 'forge'
	Type: Client (map_client.txt)
	Resource Packs: vanilla, mod_resources, programer_art
	Current Language: English (US)
	CPU: 8x Intel(R) Core(TM) i5-8300H CPU @ 2.30GHz

 

Sorry for the lack of detail, before. Thanks, in advance.

Posted (edited)

If it helps, these are the item models...

 

Items (Identical to all other skulls in Vanilla):

{
    "parent": "item/template_skull"
}

 

Template Skull (Vanilla):

{
    "parent": "builtin/entity",
    "textures": {
        "particle": "block/soul_sand"
    },
    "display": {
        "gui": {
            "rotation": [ 30, 45, 0 ],
            "translation": [ 0, 3, 0 ],
            "scale": [ 1, 1, 1 ]
        },
        "fixed": {
            "rotation": [ 0, 180, 0 ],
            "translation": [ 0, 4, 0],
            "scale":[ 1, 1, 1 ]
        },
        "ground": {
            "rotation": [ 0, 0, 0 ],
            "translation": [ 0, 3, 0 ],
            "scale": [ 0.5, 0.5, 0.5 ]
        },
        "thirdperson_righthand": {
            "rotation": [ 45, 45, 0 ],
            "translation": [ 0, 3, 0 ],
            "scale": [ 0.5, 0.5, 0.5 ]
        }
    }
}

 

Edited by MattNL
Posted

Howdy

 

This part here

	at java.util.Objects.requireNonNull(Objects.java:203)
	at java.util.Optional.<init>(Optional.java:96)
	at java.util.Optional.of(Optional.java:108)
	at net.minecraft.client.renderer.RenderState$TextureState.<init>(SourceFile:192)

tells me that you are trying to initialise your Renderer with a texture ResourceLocation that is null, i.e. hasn't been set properly.

 

Looking at your code, I suspect this:

p_209263_0_.put(SkullBlock.Types.PLAYER, DefaultPlayerSkin.getDefaultSkinLegacy());

 

I would suggest you put a breakpoint in a suitable location and have a look at what the ResourceLocation has been set to.

eg in the put statement above, or in SkullEntityTileRenderer::func_228879_a_

 

Cheers

  TGG

 

 

 

 

 

 

 

 

Posted (edited)

I've replaced the function with a texture path instead, but I still got the RenderState$TextureState crash. Perhaps the renderer isn't being registered?

 

---- Minecraft Crash Report ----
// Don't do that.

Time: 3/25/20 6:57 PM
Description: Rendering item

java.lang.NullPointerException: Rendering item
	at java.util.Objects.requireNonNull(Objects.java:203) ~[?:1.8.0_201] {}
	at java.util.Optional.<init>(Optional.java:96) ~[?:1.8.0_201] {}
	at java.util.Optional.of(Optional.java:108) ~[?:1.8.0_201] {}
	at net.minecraft.client.renderer.RenderState$TextureState.<init>(SourceFile:192) ~[forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.RenderType.func_230167_a_(SourceFile:116) ~[forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.RenderType.func_228640_c_(SourceFile:130) ~[forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.tileentity.SkullTileEntityRenderer.func_228878_a_(SourceFile:105) ~[forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.tileentity.SkullTileEntityRenderer.func_228879_a_(SourceFile:95) ~[forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer.func_228364_a_(SourceFile:81) ~[forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.ItemRenderer.func_229111_a_(ItemRenderer.java:108) ~[forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.ItemRenderer.renderItemModelIntoGUI(ItemRenderer.java:190) ~[forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.ItemRenderer.renderItemAndEffectIntoGUI(ItemRenderer.java:211) ~[forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.gui.screen.inventory.ContainerScreen.drawSlot(ContainerScreen.java:220) ~[forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.gui.screen.inventory.ContainerScreen.render(ContainerScreen.java:91) ~[forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.gui.DisplayEffectsScreen.render(DisplayEffectsScreen.java:45) ~[forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.gui.screen.inventory.CreativeScreen.render(CreativeScreen.java:605) ~[forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraftforge.client.ForgeHooksClient.drawScreen(ForgeHooksClient.java:359) ~[forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {re:classloading}
	at net.minecraft.client.renderer.GameRenderer.updateCameraAndRender(GameRenderer.java:480) ~[forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:925) ~[forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.run(Minecraft.java:554) ~[forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.main.Main.main(SourceFile:204) ~[forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_201] {}
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_201] {}
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_201] {}
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_201] {}
	at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:55) ~[forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-5.0.0-milestone.4.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-5.0.0-milestone.4.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-5.0.0-milestone.4.jar:?] {}
	at cpw.mods.modlauncher.Launcher.run(Launcher.java:81) [modlauncher-5.0.0-milestone.4.jar:?] {}
	at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) [modlauncher-5.0.0-milestone.4.jar:?] {}
	at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:102) [forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar:?] {}


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

-- Head --
Thread: Render thread
Stacktrace:
	at java.util.Objects.requireNonNull(Objects.java:203)
	at java.util.Optional.<init>(Optional.java:96)
	at java.util.Optional.of(Optional.java:108)
	at net.minecraft.client.renderer.RenderState$TextureState.<init>(SourceFile:192)
	at net.minecraft.client.renderer.RenderType.func_230167_a_(SourceFile:116)
	at net.minecraft.client.renderer.RenderType.func_228640_c_(SourceFile:130)
	at net.minecraft.client.renderer.tileentity.SkullTileEntityRenderer.func_228878_a_(SourceFile:105)
	at net.minecraft.client.renderer.tileentity.SkullTileEntityRenderer.func_228879_a_(SourceFile:95)
	at net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer.func_228364_a_(SourceFile:81)
	at net.minecraft.client.renderer.ItemRenderer.func_229111_a_(ItemRenderer.java:108)
	at net.minecraft.client.renderer.ItemRenderer.renderItemModelIntoGUI(ItemRenderer.java:190)

-- Item being rendered --
Details:
	Item Type: steve_head
	Registry Name: namespace_here:steve_head
	Item Damage: 0
	Item NBT: null
	Item Foil: false
Stacktrace:
	at net.minecraft.client.renderer.ItemRenderer.renderItemAndEffectIntoGUI(ItemRenderer.java:211)
	at net.minecraft.client.gui.screen.inventory.ContainerScreen.drawSlot(ContainerScreen.java:220)
	at net.minecraft.client.gui.screen.inventory.ContainerScreen.render(ContainerScreen.java:91)
	at net.minecraft.client.gui.DisplayEffectsScreen.render(DisplayEffectsScreen.java:45)
	at net.minecraft.client.gui.screen.inventory.CreativeScreen.render(CreativeScreen.java:605)
	at net.minecraftforge.client.ForgeHooksClient.drawScreen(ForgeHooksClient.java:359)

-- Screen render details --
Details:
	Screen name: net.minecraft.client.gui.screen.inventory.CreativeScreen
	Mouse location: Scaled: (311, 179). Absolute: (1246.000000, 715.000000)
	Screen size: Scaled: (480, 251). Absolute: (1920, 1001). Scale factor of 4.000000

-- Affected level --
Details:
	All players: 1 total; [ClientPlayerEntity['MattNL'/14, l='MpServer', x=-376.70, y=68.00, z=-114.70]]
	Chunk stats: Client Chunk Cache: 841, 575
	Level dimension: DimensionType{minecraft:overworld}
	Level name: MpServer
	Level seed: -1113229301927640182
	Level generator: ID 00 - default, ver 1. Features enabled: false
	Level generator options: {}
	Level spawn location: World: (112,75,-192), Chunk: (at 0,4,0 in 7,-12; contains blocks 112,0,-192 to 127,255,-177), Region: (0,-1; contains chunks 0,-32 to 31,-1, blocks 0,0,-512 to 511,255,-1)
	Level time: 201942 game time, 44094 day time
	Known server brands: 
	Level was modded: false
	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
	Server brand: forge
	Server type: Integrated singleplayer server
Stacktrace:
	at net.minecraft.client.world.ClientWorld.fillCrashReport(ClientWorld.java:442)
	at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:1764)
	at net.minecraft.client.Minecraft.run(Minecraft.java:568)
	at net.minecraft.client.main.Main.main(SourceFile:204)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:55)
	at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37)
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54)
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72)
	at cpw.mods.modlauncher.Launcher.run(Launcher.java:81)
	at cpw.mods.modlauncher.Launcher.main(Launcher.java:65)
	at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:102)

-- System Details --
Details:
	Minecraft Version: 1.15.2
	Minecraft Version ID: 1.15.2
	Operating System: Windows 10 (amd64) version 10.0
	Java Version: 1.8.0_201, Oracle Corporation
	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
	Memory: 453994992 bytes (432 MB) / 950534144 bytes (906 MB) up to 1873805312 bytes (1787 MB)
	CPUs: 8
	JVM Flags: 1 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump
	ModLauncher: 5.0.0-milestone.4+67+b1a340b
	ModLauncher launch target: fmluserdevclient
	ModLauncher naming: mcp
	ModLauncher services: 
		/eventbus-2.0.0-milestone.1-service.jar eventbus PLUGINSERVICE 
		/forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3-launcher.jar object_holder_definalize PLUGINSERVICE 
		/forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3-launcher.jar runtime_enum_extender PLUGINSERVICE 
		/accesstransformers-2.0.0-milestone.1-shadowed.jar accesstransformer PLUGINSERVICE 
		/forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3-launcher.jar capability_inject_definalize PLUGINSERVICE 
		/forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3-launcher.jar runtimedistcleaner PLUGINSERVICE 
		/forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3-launcher.jar fml TRANSFORMATIONSERVICE 
	FML: 31.1
	Forge: net.minecraftforge:31.1.0
	FML Language Providers: 
		[email protected]
		minecraft@1
	Mod List: 
		client-extra.jar Minecraft {[email protected] DONE}
		main Minecraft: namespace_here {namespace_here@NONE DONE}
		forge-1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3.jar Forge {[email protected] DONE}
	Launched Version: MOD_DEV
	Backend library: LWJGL version 3.2.2 build 10
	Backend API: Intel(R) UHD Graphics 630 GL version 4.5.0 - Build 23.20.16.5018, Intel
	GL Caps: Using framebuffer using OpenGL 3.0
	Using VBOs: Yes
	Is Modded: Definitely; Client brand changed to 'forge'
	Type: Client (map_client.txt)
	Resource Packs: vanilla, mod_resources, programer_art
	Current Language: English (US)
	CPU: 8x Intel(R) Core(TM) i5-8300H CPU @ 2.30GHz

 

Edited by MattNL
  • 1 year later...
Posted (edited)

So, after tons of rage quitting and a short 2-day break, I figured out what was wrong.
I had the exact same issue and here's the solution for anyone who needs it in the future:

Edit: Yeah, no. My old method isn't correct at all (Thanks to diesieben07 for the help). Just add the code below and it should be fine. You can also change "new GenericHeadModel(0, 0, 32, 32)" to a custom model or you can change the last 2 values to modify the texture size.

	@SubscribeEvent
    public static void registerCustomSkullRenderers(final FMLClientSetupEvent event) {
        Field ModelField;
        Field SkinField;
        try {
            ModelField = SkullTileEntityRenderer.class.getDeclaredField("MODEL_BY_TYPE");
            ModelField.setAccessible(true);
            Map<SkullBlock.ISkullType, GenericHeadModel> Model = (Map<SkullBlock.ISkullType, GenericHeadModel>) ModelField.get(SkullTileEntityRenderer.class);
            Model.put(<Insert Custom Skull Type>, new GenericHeadModel(0, 0, 32, 32));

            SkinField = SkullTileEntityRenderer.class.getDeclaredField("SKIN_BY_TYPE");
            SkinField.setAccessible(true);
            Map<SkullBlock.ISkullType, ResourceLocation> Skin = (Map<SkullBlock.ISkullType, ResourceLocation>) SkinField.get(SkullTileEntityRenderer.class);
            Skin.put(<Insert Custom Skull Type>, new ResourceLocation("<Mod ID>:<Texture Location>"));
        }
        catch (NoSuchFieldException | IllegalAccessException e) {
            e.printStackTrace();
        }
    }


Basically, you have to register a custom item renderer. Let's say the block and the tile entities were done properly (Too lazy to check) and the item (more exactly the texture) was the issue.
All you need to do is add the following two methods to your main project class:

 

public static Item.Properties setupISTER(Item.Properties group) {
	return group.setISTER(MainClass::getISTER);
}

@OnlyIn(Dist.CLIENT)
public static Callable<ItemStackTileEntityRenderer> getISTER() {
	return ItemRenderer::new;
}

and after that you need to add this to your block item:
 

MainClass.setupISTER(new Item.Properties())

Item.Properties() is of course your item properties like tab, rarity and etc.

Then finally you're gonna need your Item Renderer class which should be something similar to this:

 

@OnlyIn(Dist.CLIENT)
public class ItemRenderer extends ItemStackTileEntityRenderer {
    public static final ItemStackTileEntityRenderer instance = new PA_ItemRenderer();

    @Override
    public void renderByItem(ItemStack stack, ItemCameraTransforms.TransformType transform, MatrixStack matrix, IRenderTypeBuffer renderer, int light, int overlay) {
        Item item = stack.getItem();
        if (item instanceof BlockItem) {
            Block block = ((BlockItem) item).getBlock();
            if (block instanceof AbstractSkullBlock) {
                PA_SkullRenderer.renderSkull(null, 180.0F, ((AbstractSkullBlock) block).getType(), null, 0.0F, matrix, renderer, light);
            }
        }
    }
}

The renderer is a slightly modified version of the vanilla one and all the code was made on 1.16.5.

Edited by uSkizzik

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.