Jump to content

[1.12.2] Mimicry of Other Blocks


Recommended Posts

Hi everyone. I am making a mod where there is a block that can "mask" itself so that people can't find it. However, I cannot seem to get the code to work, no matter how hard I try. I have tried a


, however this wouldn't work, I also have tried storing the blockstate and simply returning the blockstate in the tileentity in




, but nothing works. I don't understand why. A little help would help me greatly.



package com.obcletter.moddingchallenge.block.explosive_clay;

import com.obcletter.moddingchallenge.Reference;
import com.obcletter.moddingchallenge.tile.TileEntityBase;

import net.minecraft.block.state.IBlockState;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTUtil;

public class TileEntityExplosiveClay extends TileEntityBase {

    private static final String DEFAULT_BLOCK_VALUE = Reference.MOD_ID + ":explosive_clay";

    private IBlockState state;

    public void readFromNBT(NBTTagCompound compound) {
        state = NBTUtil.readBlockState(compound.getCompoundTag("state"));

    public NBTTagCompound writeToNBT(NBTTagCompound compound) {
        NBTTagCompound stateTag = new NBTTagCompound();
        if (state != null) {
            NBTUtil.writeBlockState(stateTag, state);
            compound.setTag("state", stateTag);
        return super.writeToNBT(compound);

    public IBlockState getState() {
        return state;

    public boolean setState(IBlockState state) {
        this.state = state;
        return true;




package com.obcletter.moddingchallenge.block.explosive_clay;

import com.obcletter.moddingchallenge.block.BlockTileEntity;

import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

public class BlockExplosiveClay extends BlockTileEntity<TileEntityExplosiveClay> {

    public BlockExplosiveClay() {
        super("explosive_clay", Material.CLAY);

    public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
            EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
        if (!worldIn.isRemote) {
            TileEntity te = worldIn.getTileEntity(pos);
            if (te instanceof TileEntityExplosiveClay) {
                TileEntityExplosiveClay explosive_clay = (TileEntityExplosiveClay) te;
                ItemStack stack = playerIn.getHeldItem(hand);
                IBlockState staate = Block.getBlockFromItem(stack.getItem()).getStateFromMeta(stack.getMetadata());
                if (staate != Blocks.AIR.getDefaultState()) {
                    return explosive_clay.setState(staate);

                } else {
                    return explosive_clay.setState(getDefaultState());
        return false;

    public Class<TileEntityExplosiveClay> getTileEntityClass() {
        return TileEntityExplosiveClay.class;

    public TileEntity createNewTileEntity(World worldIn, int meta) {
        return new TileEntityExplosiveClay();
    public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
        TileEntity entity = world.getTileEntity(pos);
        if (entity instanceof TileEntityExplosiveClay) {
            TileEntityExplosiveClay explosiveTe = (TileEntityExplosiveClay) entity;
            if (explosiveTe.getState() != null) {
                return explosiveTe.getState();
        return super.getExtendedState(state, world, pos);




Edited by OBCLetter

Hi! I'm a Java programmer but barely know anything Minecraft related. 

Link to comment
Share on other sites

You don't need TEs or TESRs for this, is possible with blockstates.


Take a look at GreyGhosts's Minecraft By Example mod:


  • Like 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.


Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.


DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in

Sign In Now


  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • It wasnt mappings issue, I was reading fabric and not forge. Fabric has PlayerEntity while forge has Player. Through a mixin I was able to change the player's velocity so that there is a sort of slow-motion type movement. Only issue is that jumping seems to be handled separately. Changing that velocity only makes the jump lower, not slower. Unsure how to increase the duration in which a jump happens.   @Mixin(LivingEntity.class) public abstract class ExampleMixin extends Entity { public ExampleMixin(EntityType<?> type, World world) { super(type, world); } @Inject(method = "tickMovement", at = @At("HEAD")) private void onTickMovement(CallbackInfo ci) { // Access the player entity LivingEntity entity = (LivingEntity)(Object)this; // Modify player's acceleration by applying a force in the opposite direction double slowdownFactor = 0.75; // Adjust as needed entity.setVelocity(entity.getVelocity().multiply(1, slowdownFactor, 1)); } }  
    • Hi so i made a modded survival, and when i go to the page 13 of my JEI,  my game instant crash and give this error "The game crashed whilst rendering item Error", I don't know what to do i give you the crash report : https://pastebin.com/EhzYdEZg
    • You need to run build at least once before running the game for the first time in a dev environment. Make sure stuff's working *before* you start making changes to the mdk template
    • Greetings, people of the forge forums: I come to you in a time of need. While creating my silly block entity that is (in theory) supposed to point to a position within world space I've started to question how to actually implement it.   How would I get a tile entity element (or bone) to change its pitch/yaw/roll? While I do have prior experience with programming, I have no actual experience with the forge API except the things listed in its docs. Please correct me if I am in any way wrong.
    • Making my own screen by extending from net.minecraft.client.gui.screens.Screen and override render method. I am trying to make green square only to be visible when intersecting with red square. This is what I got so far: @Override public void render(PoseStack poseStack, int mx, int my, float partialTick) {     RenderSystem.enableDepthTest(); // Red square     GuiComponent.fill(pPoseStack, 32, 32, 64, 64, 0xFFFF0000);     RenderSystem.depthFunc(GlConst.GL_LEQUAL); // Green square     GuiComponent.fill(pPoseStack, mx-16, my-16, mx+16, my+16, 0xFF00FF00); } Thank you in advance.
  • Topics

  • Who's Online (See full list)

  • Create New...

Important Information

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