LittleTiles

LittleTiles

12M Downloads

littletiles:premade item, tiles invisible in hand or when dropped

Doc-1 opened this issue ยท 5 comments

commented

I've made a premade structure, and there are a few tiles missing when rendered as an item, in hand, or when dropped on the ground. These missing tiles are constant and in the same location. Placing it down in the world does render all tiles. Lastly, it only occurs if the item is premade; this does not affect the structure a advanced recipe displays.

Versions: LittleTiles_v1.5.0-pre199_64, CreativeCore_v1.10.28
Structure: premade_item.txt

Item in hand:
2020-10-16_08 20 17

commented

Hm, not sure if this issue is related to LT directly. It depends on how you implemented your item. Maybe show me your code?

commented

It does occur to regular premade structures added with LittleStructurePremade::registerPremadeStructureType as well. Little hard to see it when holding though.
Regular Premade Structure:
pic2

package com.littleforge.common.item;

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

import javax.annotation.Nullable;

import com.creativemd.creativecore.client.rendering.RenderBox;
import com.creativemd.creativecore.client.rendering.model.ICreativeRendered;
import com.creativemd.littletiles.LittleTiles;
import com.creativemd.littletiles.common.structure.registry.LittleStructureRegistry;
import com.creativemd.littletiles.common.structure.type.premade.LittleStructurePremade;
import com.creativemd.littletiles.common.structure.type.premade.LittleStructurePremade.LittleStructureTypePremade;
import com.creativemd.littletiles.common.tile.preview.LittlePreview;
import com.creativemd.littletiles.common.tile.preview.LittlePreviews;

import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class PremadeItem extends Item implements ICreativeRendered {
	
	String registryName;
	
	public PremadeItem(String unlocalizedName, String registryNm) {
		registryName = registryNm;
		setUnlocalizedName(unlocalizedName);
		setRegistryName(registryNm);
		setCreativeTab(LittleTiles.littleTab);
		hasSubtypes = true;
		setMaxStackSize(1);
	}

	@Override
	public float getDestroySpeed(ItemStack stack, IBlockState state) {
		return 0F;
	}
	
	@Override
	@SideOnly(Side.CLIENT)
	public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
	}
	
	@Override
	public boolean canDestroyBlockInCreative(World world, BlockPos pos, ItemStack stack, EntityPlayer player) {
		return false;
	}
	
	@Override
	@SideOnly(Side.CLIENT)
	public List<RenderBox> getRenderingCubes(IBlockState state, TileEntity te, ItemStack stack) {
		LittleStructureTypePremade premade = (LittleStructureTypePremade) LittleStructureRegistry.getStructureType(registryName);
		LittlePreviews previews = LittleStructurePremade.getPreviews(premade.id).copy();
		List<RenderBox> cubes = premade.getRenderingCubes(previews);
		if (cubes == null) {
			cubes = new ArrayList<>();
			for (LittlePreview preview : previews.allPreviews())
				cubes.add(preview.getCubeBlock(previews.getContext()));
		}
		return cubes;	
	}

	
	@SideOnly(Side.CLIENT)
	public static IBakedModel model;
	
}

commented

Why exactly do you need a new item for that? Can't you use the normal premade structure? Not sure what is going wrong there, are these changes commited so I can test them myself?

commented

I don't want the structure to be placed. Also, to change the rotation of the item while being held. The code is pushed, it is in the LittleSmithing repository. Works with the most recent pull of LittleTiles and CreativeCore. The item name in question is littleforge:wooden_tongs

commented

Tested it for a very long time. Conclusion is that your structure is somewhat broken, place it down and select it with a new recipe. That should hopefully fix it.