Jump to content

[1.16.1] Glass Block


Luis_ST

Recommended Posts

I want to creat the Tinted Glass Block for the new Minecraft Snapshot but i can look through the block into the "world"/void

This is the code:

 

package net.luis.cave.blocks;

import net.minecraft.block.AbstractBlock;
import net.minecraft.block.AbstractGlassBlock;
import net.minecraft.block.BlockState;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.material.PushReaction;
import net.minecraftforge.common.ToolType;

public class TintedGlass extends AbstractGlassBlock {

	public TintedGlass() {
		
		super(AbstractBlock.Properties.create(Material.GLASS)
				.zeroHardnessAndResistance()
				.sound(SoundType.GLASS)
				.harvestLevel(0)
				.harvestTool(ToolType.PICKAXE));
		
	}
	
	@Override
	public boolean isTransparent(BlockState state) {
		
		return true;
		
	}
	
	@Override
	public PushReaction getPushReaction(BlockState state) {
		
		return PushReaction.DESTROY;
		
	}

}

 

Link to comment
Share on other sites

i get this code for the glass class but it dosent work

 

package net.luis.cave.blocks;

import net.minecraft.block.AbstractBlock;
import net.minecraft.block.AbstractGlassBlock;
import net.minecraft.block.BlockState;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.material.PushReaction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.world.IBlockReader;

public class TintedGlass extends AbstractGlassBlock {

	public TintedGlass() {
		
		super(AbstractBlock.Properties.create(Material.GLASS)
				.zeroHardnessAndResistance()
				.sound(SoundType.GLASS)
				.harvestLevel(0));
		
	}
	
	@Override
	public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) {

		return true;
		
	}
	
	@Override
	public boolean isTransparent(BlockState state) {
		
		return true;
		
	}
	
	@Override
	public PushReaction getPushReaction(BlockState state) {
		
		return PushReaction.DESTROY;
		
	}
	
	@Override
	public float getAmbientOcclusionLightValue(BlockState state, IBlockReader worldIn, BlockPos pos) {
		
		return 1.0f;
		
	}
	
	@Override
	public VoxelShape func_230322_a_(BlockState p_230322_1_, IBlockReader p_230322_2_, BlockPos p_230322_3_, ISelectionContext p_230322_4_) {
		
	      return VoxelShapes.empty();
	      
	}

}

 

Edited by Luis_ST
Link to comment
Share on other sites

I believe that method was renamed to setOpaque in recent mappings. Anyway in your case it should be the func_235828_a_. You can take a look here to see what unmapped methods looks like in the most recent mappings: https://docs.google.com/spreadsheets/d/14knNUYjYkKkGpW9VTyjtlhaCTUsPWRJ91GLOFX2d23Q/edit#gid=721555859

Alternatively if you do not know what method does what you want you can try to search where those methods could have been used in vanilla code..for example, you are trying to create a block that is similar to glass in behaviour. Then go inside the Blocks class and see how the various glass blocks and their properties are defined, and you may found the informations that could help you deducing which of those non-sense name method is the one you need to use

Check out the port of the BetterEnd fabric mod (WIP): https://www.curseforge.com/minecraft/mc-mods/betterend-forge-port

Link to comment
Share on other sites

i just looked into the vanilla glass block class:

 

package net.minecraft.block;

public class GlassBlock extends AbstractGlassBlock {
   public GlassBlock(AbstractBlock.Properties properties) {
      super(properties);
   }
}

 

and the Abstract Glass Block class:

package net.minecraft.block;

import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.world.IBlockReader;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

public abstract class AbstractGlassBlock extends BreakableBlock {
   protected AbstractGlassBlock(AbstractBlock.Properties p_i49999_1_) {
      super(p_i49999_1_);
   }

   public VoxelShape func_230322_a_(BlockState p_230322_1_, IBlockReader p_230322_2_, BlockPos p_230322_3_, ISelectionContext p_230322_4_) {
      return VoxelShapes.empty();
   }

   @OnlyIn(Dist.CLIENT)
   public float getAmbientOcclusionLightValue(BlockState state, IBlockReader worldIn, BlockPos pos) {
      return 1.0F;
   }

   public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) {
      return true;
   }
}

 

there are no properties

 

Link to comment
Share on other sites

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.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.