Jump to content

[SOLVED][1.11.2] Block texture


IvanSteklow
 Share

Recommended Posts

Hello everyone! I need a help with Block textures. On starting MC I get this message:

https://pastebin.com/SBS88ELq

 

This is my block class:

 

BlockJar.java

package ivansteklow.ishelper.blocks;

import javax.annotation.Nullable;

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.entity.player.EntityPlayerMP;
import net.minecraft.init.Items;
import net.minecraft.init.PotionTypes;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionUtils;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

public class BlockJar extends Block {

	public BlockJar() {
		super(Material.ROCK);
		setSoundType(SoundType.STONE);
		setHardness(1.0f);
		setHarvestLevel("pickaxe", 1);
		setUnlocalizedName("waterjar");
	}

	public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
			EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
		ItemStack itemstack = playerIn.getHeldItem(hand);

		if (itemstack.isEmpty()) {
			return true;
		} else {

			Item item = heldItem.getItem();

			if (item == Items.BUCKET) {

				itemstack.shrink(1);

				if (itemstack.isEmpty()) {
					playerIn.setHeldItem(hand, new ItemStack(Items.WATER_BUCKET));
				} else if (!playerIn.inventory.addItemStackToInventory(new ItemStack(Items.WATER_BUCKET))) {
					playerIn.dropItem(new ItemStack(Items.WATER_BUCKET), false);
				}

				return true;
			} else if (item == Items.GLASS_BOTTLE) {

				ItemStack itemstack1 = PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM),
						PotionTypes.WATER);

				if (itemstack.isEmpty()) {
					playerIn.setHeldItem(hand, itemstack1);
				} else if (!playerIn.inventory.addItemStackToInventory(itemstack1)) {
					playerIn.dropItem(itemstack1, false);
				} else if (playerIn instanceof EntityPlayerMP) {
					((EntityPlayerMP) playerIn).sendContainerToPlayer(playerIn.inventoryContainer);
				}

				return true;
			}

			return false;
		}
	}
}

 

This is my Registering blocks class:

 

ModBlocks.java

package ivansteklow.ishelper.init;

import ivansteklow.isdev.BlockRegisterer;
import ivansteklow.ishelper.blocks.BlockJar;
import net.minecraft.block.Block;
import net.minecraft.util.ResourceLocation;

public class ModBlocks {

	public static Block blockJar;

	public static void init() {
		blockJar = new BlockJar().setRegistryName(new ResourceLocation(Refs.MOD_ID, "waterjar"));
		BlockRegisterer.regBlock(blockJar);
	}

	public static void initRender() {
		BlockRegisterer.regRender(blockJar, Refs.MOD_ID);
	}
}

 

BlockRegisterer.java (My API)

package ivansteklow.isdev;

import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class BlockRegisterer {
	public static void regRender(Block block, String modid) {
		Item item = Item.getItemFromBlock(block);
		Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(block.getRegistryName(), "inventory"));
	}
	public static void regBlock(Block block){
		GameRegistry.register(block);
		ItemBlock item = new ItemBlock(block);
		item.setRegistryName(block.getRegistryName());
		GameRegistry.register(item);
	}
}

 

I have some files:

 

/assets/ishelper/blockstates/waterjar.json

{
    "variants": {
        "normal": {
            "model": "ishelper:waterjar" 
		}
    }
}

/assets/ishelper/models/block/waterjar.json

 {
 	"parent": "block/cube_all",
 	"textures": {
 		"all": "ishelper:blocks/waterjar"
 	}
 }

/assets/ishelper/models/item/waterjar.json

{
	"parent": "block/cube_all",
	"textures": {
		"all": "ishelper:blocks/waterjar"
	}
}

 

What's wrong?! HELP ME PLS!

Edited by IvanSteklow
Solved
  • Like 1
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
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.

 Share



×
×
  • Create New...

Important Information

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