Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.8][Solved]Block with tile entity is completely transparent


The_Fireplace
 Share

Recommended Posts

So, I added a block with a tile entity, and it is completely transparent when placed in the world. It renders just fine in the inventory. Here is a screenshot:

mpLwK9l.png

And my code:

Block:

 

public class BlockPopFurnace extends BlockContainer {
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);

public BlockPopFurnace() {
	super(Material.iron);
	setUnlocalizedName("pop_furnace");
	setCreativeTab(UnLogicII.TabUnLogicII);
	setHardness(5F);
	setResistance(15F);
	this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
}
@Override
public boolean isOpaqueCube(){
	return true;
}

@Override
public boolean isVisuallyOpaque()
{
	return true;
}

@Override
@SideOnly(Side.CLIENT)
public EnumWorldBlockLayer getBlockLayer(){
	return EnumWorldBlockLayer.SOLID;
}

@Override
public TileEntity createNewTileEntity(World worldIn, int meta) {
	return new TileEntityPopFurnace();
}

@Override
public void onBlockAdded(World world, BlockPos pos, IBlockState state){
	super.onBlockAdded(world, pos, state);
	setDefaultDirection(world, pos, state);
}

private void setDefaultDirection(World worldIn, BlockPos pos, IBlockState state){
	if(!worldIn.isRemote){
		Block block = worldIn.getBlockState(pos.north()).getBlock();
		Block block1 = worldIn.getBlockState(pos.south()).getBlock();
		Block block2 = worldIn.getBlockState(pos.west()).getBlock();
		Block block3 = worldIn.getBlockState(pos.east()).getBlock();
		EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);

		if (enumfacing == EnumFacing.NORTH && block.isFullBlock() && !block1.isFullBlock())
		{
			enumfacing = EnumFacing.SOUTH;
		}
		else if (enumfacing == EnumFacing.SOUTH && block1.isFullBlock() && !block.isFullBlock())
		{
			enumfacing = EnumFacing.NORTH;
		}
		else if (enumfacing == EnumFacing.WEST && block2.isFullBlock() && !block3.isFullBlock())
		{
			enumfacing = EnumFacing.EAST;
		}
		else if (enumfacing == EnumFacing.EAST && block3.isFullBlock() && !block2.isFullBlock())
		{
			enumfacing = EnumFacing.WEST;
		}

		worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2);
	}
}

@Override
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
	return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
}

@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
	worldIn.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing().getOpposite()), 2);
}

@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
	if (!worldIn.isRemote)
	{
		TileEntity tileentity = worldIn.getTileEntity(pos);

		if (tileentity instanceof TileEntityPopFurnace)
		{
			FMLNetworkHandler.openGui(playerIn, UnLogicII.MODID, 0, worldIn, pos.getX(), pos.getY(), pos.getZ());
		}
	}
	return true;
}

@Override
protected BlockState createBlockState(){ 
	return new BlockState(this, new IProperty[] {FACING});
}

@Override
public IBlockState getStateFromMeta(int meta)
{
	EnumFacing enumfacing = EnumFacing.getFront(meta);

	if (enumfacing.getAxis() == EnumFacing.Axis.Y)
	{
		enumfacing = EnumFacing.NORTH;
	}

	return this.getDefaultState().withProperty(FACING, enumfacing);
}
@Override
public int getMetaFromState(IBlockState state)
{
	return ((EnumFacing)state.getValue(FACING)).getIndex();
}
}

 

And the tile entity:

 

/**
* 
* @author The_Fireplace
*
*/
public class TileEntityPopFurnace extends TileEntity implements IInventory {
private ItemStack[] inventory;
short storedGunpowder = -32768;
public static final short storedGunpowderMin = -32768;
int storedFirestarter;
public static final byte storedFirestarterMin = 0;

public TileEntityPopFurnace(){
	inventory = new ItemStack[12];
}

@Override
public String getName() {
	return StatCollector.translateToLocal("tile.pop_furnace.name");
}

@Override
public boolean hasCustomName() {
	return false;
}

@Override
public IChatComponent getDisplayName() {
	return null;
}

@Override
public int getSizeInventory() {
	return inventory.length;
}

@Override
public ItemStack getStackInSlot(int index) {
	return inventory[index];
}

@Override
public ItemStack decrStackSize(int index, int count) {
	ItemStack is = getStackInSlot(index);
	if(is != null){
		if(is.stackSize <= count){
			setInventorySlotContents(index, null);
		}else{
			is = is.splitStack(count);
			markDirty();
		}
	}
	return is;
}

@Override
public ItemStack getStackInSlotOnClosing(int index) {
	ItemStack is = getStackInSlot(index);
	setInventorySlotContents(index, null);
	return is;
}

@Override
public void setInventorySlotContents(int index, ItemStack stack) {
	inventory[index] = stack;

	if(stack != null && stack.stackSize > getInventoryStackLimit()){
		stack.stackSize = getInventoryStackLimit();
	}
	markDirty();
}

@Override
public int getInventoryStackLimit() {
	return 64;
}

@Override
public boolean isUseableByPlayer(EntityPlayer player) {
	return player.getDistanceSq(this.pos.getX() + 0.5D, this.pos.getY() + 0.5D, this.pos.getZ() + 0.5D) <= 64;
}

@Override
public void openInventory(EntityPlayer player) {
}

@Override
public void closeInventory(EntityPlayer player) {
}

@Override
public boolean isItemValidForSlot(int index, ItemStack stack) {
	return true;
}

@Override
public int getField(int id) {
	return 0;
}

@Override
public void setField(int id, int value) {
}

@Override
public int getFieldCount() {
	return 0;
}

@Override
public void clear() {
	for(int i = 0; i < inventory.length; ++i){
		inventory[i]=null;
	}
}

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

	NBTTagList list = new NBTTagList();
	for(int i = 0; i<getSizeInventory();i++){
		ItemStack is = getStackInSlot(i);
		if(is != null){
			NBTTagCompound item = new NBTTagCompound();

			item.setByte("SlotPopFurnace", (byte)i);
			is.writeToNBT(item);

			list.appendTag(item);
		}
	}
	compound.setTag("ItemsPopFurnace", list);
}

@Override
public void readFromNBT(NBTTagCompound compound){
	super.readFromNBT(compound);
	NBTTagList list = (NBTTagList) compound.getTag("ItemsPopFurnace");
	if(list != null){
		for(int i = 0; i<list.tagCount();i++){
			NBTTagCompound item = (NBTTagCompound) list.get(i);
			int slot = item.getByte("SlotPopFurnace");
			if(slot >= 0 && slot < getSizeInventory()){
				setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(item));
			}
		}
	}else{
		System.out.println("List was null when reading TileEntityPopFurnace NBTTagCompound");
	}
}

public void addToGunpowder(int amount){
	if(storedGunpowder+amount <= 32767){
		storedGunpowder += amount;
	}else{
		storedGunpowder = 32767;
		System.out.println("Someone actually managed to cram 1024 stacks of gunpowder in to a Pop Furnace. Congratulations to them for hitting the limit.");
		System.out.println("I recommend turning down the number of items popped per gunpowder in the UnLogic II config, to help use some of that up.");
	}
}

public void removeFromGunpowder(int amount){
	if(storedGunpowder-amount < storedGunpowderMin){
		storedGunpowder=storedGunpowderMin;
		System.out.println("Error: something tried subtracting more gunpowder than was stored in a Pop Furnace. This is not a good sign.");
	}else{
		storedGunpowder -= amount;
	}
}

public void addToFireStarter(int amount){
	storedFirestarter += amount;
	System.out.println(storedFirestarter);
}

public void removeFromFirestarter(int amount){
	storedFirestarter -= amount;
	if(storedFirestarter < storedFirestarterMin){
		storedFirestarter = storedFirestarterMin;
	}
}
}

 

And the related json files

 

{
    "variants": {
        "facing=north": { "model": "unlogicii:pop_furnace" },
        "facing=south": { "model": "unlogicii:pop_furnace", "y": 180 },
        "facing=west":  { "model": "unlogicii:pop_furnace", "y": 270 },
        "facing=east":  { "model": "unlogicii:pop_furnace", "y": 90 }
    }
}

{
    "parent": "block/orientable",
    "textures": {
        "top": "blocks/iron_block",
        "front": "unlogicii:blocks/pop_furnace_front",
        "side": "blocks/iron_block"
    }
}

 

Any help would be appreciated.

If I helped please press the Thank You button.

 

Check out my mods at http://www.curse.com/users/The_Fireplace/projects

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Currently, I'm trying to figure out how to read in data from a custom datapack.  The intention is to have the Item have a reference to this pack (IE "modname:material/materialname") as an NBT tag, and i would overwrite some use functions based off of that.  How should I go about reading in the data from the datapack?
    • Game version is 1.16.5, no mods were installed, using Java8 while it happened. And I have multiple different versions of Java including Java8, 11, 12, 13, 14, 15, 16, 18 were installed in my system, but there is only Java8's path inside the environment variable. Could them be one of the reasons? I'm new here so I almost don't know anythings about forge server. Please tell me if you need other files or logs. Following is the output inside CMD after I open the "start.bat": ECHO 处于打开状态。 C:\Users\30121\Desktop\N0u3_OL_server>"C:\Program Files\Java\jre1.8.0_321\bin\java.exe" -Xms2G -Xmx2G -jar forge-1.16.5-36.2.35.jar nogui 2022-05-25 12:42:52,637 main ERROR Error processing element Queue ([Appenders: null]): CLASS_NOT_FOUND 2022-05-25 12:42:52,670 main WARN Advanced terminal features are not available in this environment 2022-05-25 12:42:52,709 main ERROR Unable to locate appender "ServerGuiConsole" for logger config "root" [12:42:52] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher running: args [--gameDir, ., --launchTarget, fmlserver, --fml.forgeVersion, 36.2.35, --fml.mcpVersion, 20210115.111550, --fml.mcVersion, 1.16.5, --fml.forgeGroup, net.minecraftforge, nogui] [12:42:52] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher 8.1.3+8.1.3+main-8.1.x.c94d18ec starting: java version 1.8.0_321 by Oracle Corporation [12:42:53] [main/INFO] [ne.mi.fm.lo.FixSSL/CORE]: Added Lets Encrypt root certificates as additional trust Exception in thread "main" [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]: java.lang.NoClassDefFoundError: com/google/common/base/Preconditions [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at org.spongepowered.asm.service.modlauncher.MixinTransformationHandler.offer(MixinTransformationHandler.java:67) [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at org.spongepowered.asm.service.modlauncher.MixinServiceModLauncher.offer(MixinServiceModLauncher.java:162) [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at org.spongepowered.asm.launch.MixinBootstrap.offerInternals(MixinBootstrap.java:227) [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at org.spongepowered.asm.launch.MixinBootstrap.start(MixinBootstrap.java:148) [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at org.spongepowered.asm.launch.MixinTransformationServiceAbstract.initialize(MixinTransformationServiceAbstract.java:88) [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.TransformationServiceDecorator.onInitialize(TransformationServiceDecorator.java:68) [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.TransformationServicesHandler.lambda$initialiseTransformationServices$7(TransformationServicesHandler.java:107) [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at java.util.HashMap$Values.forEach(Unknown Source) [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.TransformationServicesHandler.initialiseTransformationServices(TransformationServicesHandler.java:107) [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.TransformationServicesHandler.initializeTransformationServices(TransformationServicesHandler.java:59) [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.Launcher.run(Launcher.java:76) [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at net.minecraftforge.server.ServerMain$Runner.runLauncher(ServerMain.java:49) [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at net.minecraftforge.server.ServerMain$Runner.access$100(ServerMain.java:46) [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at net.minecraftforge.server.ServerMain.main(ServerMain.java:43) [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]: Caused by: java.lang.ClassNotFoundException: com.google.common.base.Preconditions [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at java.net.URLClassLoader.findClass(Unknown Source) [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at java.lang.ClassLoader.loadClass(Unknown Source) [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at java.lang.ClassLoader.loadClass(Unknown Source) [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         ... 15 more C:\Users\30121\Desktop\N0u3_OL_server>pause 请按任意键继续. . .
    • Although I am not exactly sure how a try-finally block would help (i.e. what code I should run even if a runtime exception is thrown), I have made some progress. The custom mob renders, but it does not rotate--even when I apply rotations to it before calling render(). private static boolean renderingCustomEntity = false; private static CustomEntity customEntity; private static void initializeCustomEntityIfNull(LocalPlayer localPlayer) { if (customEntity == null) { customEntity = ModEntities.CUSTOM_ENTITY.get().create(localPlayer.clientLevel); } } @SubscribeEvent public static void replaceMobModel(RenderLivingEvent.Pre<LivingEntity, EntityModel<LivingEntity>> event) { LocalPlayer localPlayer = Minecraft.getInstance().player; if (localPlayer != null && event.getEntity() instanceof Mob mob) { try { if (!renderingCustomEntity) { renderingCustomEntity = true; event.setCanceled(true); initializeCustomEntityIfNull(localPlayer); // I try to apply rotations to the custom entity before it rendered, but it still does not rotate at all. customEntity.setYRot(mob.getYRot()); customEntity.setYHeadRot(mob.getYHeadRot()); customEntity.setPose(mob.getPose()); // For some reason, the custom mob did not render when I called EntityRenderDispatcher#render. // So I called render() from EntityRenderDispatcher#getRenderer instead. Minecraft.getInstance().getEntityRenderDispatcher().getRenderer(customEntity).render( customEntity, customEntity.getYRot(), event.getPartialTick(), event.getPoseStack(), event.getMultiBufferSource(), event.getPackedLight() ); } } finally { renderingCustomEntity = false; } } } What would I be missing? Thank you for the help.
    • https://ileanafilio.com/cong-ty-co-phan-dau-tu-lien-doanh-viet-anh/ https://ileanafilio.com/tu-dong-viet-hoa-dau-dong-trong-excel-2007/ https://ileanafilio.com/tai-bai-hat-yeu-lai-tu-dau/ https://ileanafilio.com/phan-ky-dau-tu-du-an/ https://ileanafilio.com/su-lua-chon-so-phan-tap-62/ https://ileanafilio.com/cong-ty-co-phan-thuong-mai-dau-tu-va-phat-trien-cong-nghe-sctt/ https://ileanafilio.com/karate-co-nguon-goc-tu-dau/ https://ileanafilio.com/tap-doan-co-khi-xay-dung-thuong-mai-dai-dung/ https://ileanafilio.com/cach-tinh-dau-tu-tai-san-co-dinh/
    • Yes, I used it. And when I deleted the unnecessary parts and ran it again, I got an error. Now when I repaired that error and ran it, it worked fine. Thanks!
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.