Jump to content

[SOLVED] [1.15.1] Translucent blocks with see-through bottoms


Recommended Posts

Posted (edited)

Hello Folks,

 

Porting a custom glass block from 1.14.4 to 1.15.1.   Added render layer type to make it translucent, but the bottom of the block shows through like X-ray on the ground beneath.

 

I attached a pic that shows a vanilla glass next to my glass for example.

 

Any thoughts?

 

Screen Shot 2020-01-02 at 8.35.26 AM.png

package com.kwpugh.gobber2.blocks;

import java.util.List;

import javax.annotation.Nullable;

import com.kwpugh.gobber2.lists.BlockList;

import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.GlassBlock;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

public class BlockGobberGlass extends GlassBlock
{
	public BlockGobberGlass(Properties properties)
	{
		super(properties);
	}
	
	@OnlyIn(Dist.CLIENT)
	public void addInformation(ItemStack stack, @Nullable IBlockReader world, List<ITextComponent> tooltip, ITooltipFlag flag)
	{
		super.addInformation(stack, world, tooltip, flag);				
		tooltip.add(new StringTextComponent(TextFormatting.BLUE + "A very sturdy glass block, drops the block when broken"));
	}
}

 

package com.kwpugh.gobber2;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import com.kwpugh.gobber2.lists.BlockList;
import com.kwpugh.gobber2.util.Gobber2_Group;
import com.kwpugh.gobber2.util.GobberConfig;
import com.kwpugh.gobber2.util.SpecialAbilities;
import com.kwpugh.gobber2.util.SupportMods;
import com.kwpugh.gobber2.world.OreGenerator;

import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.RenderTypeLookup;

//import top.theillusivec4.curios.api.CuriosAPI;
//import top.theillusivec4.curios.api.imc.CurioIMCMessage;


import net.minecraft.item.ItemGroup;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.InterModComms;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLDedicatedServerSetupEvent;
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fml.loading.FMLPaths;
import top.theillusivec4.curios.api.CuriosAPI;
import top.theillusivec4.curios.api.imc.CurioIMCMessage;


@Mod(Gobber2.modid)
public class Gobber2 
{
	public static Gobber2 instance;
		
	public static final String modid = "gobber2";
	public static final Logger logger = LogManager.getLogger(modid);	
	public static final ItemGroup gobber2 = new Gobber2_Group();
    
	public Gobber2() 
	{
		instance = this;
		
		ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, GobberConfig.SERVER_CONFIG);
		GobberConfig.loadConfig(GobberConfig.SERVER_CONFIG, FMLPaths.CONFIGDIR.get().resolve("gobber-general.toml"));
		
		FMLJavaModLoadingContext.get().getModEventBus().addListener(this::modSetup);
		FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientSetup);
		FMLJavaModLoadingContext.get().getModEventBus().addListener(this::serverSetup);
		FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueueIMC);
		 
		MinecraftForge.EVENT_BUS.register(this);
	}
    
	private void modSetup(final FMLCommonSetupEvent event)
	{
		OreGenerator.setupOregen();
		OreGenerator.setupNetherOregen();
		OreGenerator.setupEndOregen();
		
		MinecraftForge.EVENT_BUS.register(new SpecialAbilities());
		
		logger.info("Mod setup completed");
	}
	
	private void clientSetup(final FMLClientSetupEvent event)
	{
		RenderType cutoutMipped = RenderType.func_228641_d_();
		RenderType translucent = RenderType.func_228645_f_();
		
		RenderTypeLookup.setRenderLayer(BlockList.gobber2_plant, cutoutMipped);
		RenderTypeLookup.setRenderLayer(BlockList.gobber2_plant_nether, cutoutMipped);
		RenderTypeLookup.setRenderLayer(BlockList.gobber2_plant_end, cutoutMipped);	
		RenderTypeLookup.setRenderLayer(BlockList.gobber2_glass, translucent);	
		RenderTypeLookup.setRenderLayer(BlockList.gobber2_glass_nether, translucent);	
		RenderTypeLookup.setRenderLayer(BlockList.gobber2_glass_end, translucent);	
		
		logger.info("Mod client setup completed");
	}
	
	private void serverSetup(final FMLDedicatedServerSetupEvent event)
	{
		logger.info("Mod server setup completed");
	}
	
    private void enqueueIMC(final InterModEnqueueEvent event)
    {
        if (SupportMods.CURIOS.isLoaded())
        {
        	InterModComms.sendTo("curios", CuriosAPI.IMC.REGISTER_TYPE, () -> new CurioIMCMessage("ring").setSize(2));
        } 
    }
}



 

Edited by kwpugh
Posted (edited)

Hey! try to use this in your block properties:

Block.Properties#func_226896_b_()

Is to set the block to none solid.

To look like this:

public class BlockGobberGlass extends GlassBlock
{
	public BlockGobberGlass(Properties properties)
	{
		super(properties.func_226896_b_());
	}
	
	@OnlyIn(Dist.CLIENT)
	public void addInformation(ItemStack stack, @Nullable IBlockReader world, List<ITextComponent> tooltip, ITooltipFlag flag)
	{
		super.addInformation(stack, world, tooltip, flag);				
		tooltip.add(new StringTextComponent(TextFormatting.BLUE + "A very sturdy glass block, drops the block when broken"));
	}
}

 

Edited by xieao
  • kwpugh changed the title to [SOLVED] [1.15.1] Translucent blocks with see-through bottoms

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.