Jump to content

Recommended Posts

Posted

Hello! My block Drill's name is not displaying correctly. The block has the three properties, PropertyEnum for types, PropertyDirection for model rotation and PropertyBool for redstone activation. For some reason, both the basic drill and advanced drill, in the inventory show the same block.drill.basic.name. Yet, the placed blocks display (using Waila) the block.drill.basic.name and block.drill.advanced.name. I'm presuming it's an issue with it's unlocalized name in my block's BlockDrill.java?

Basic Drill Image https://ibb.co/jpWM16

Advanced Drill Image https://ibb.co/d1XiER

BlockDrill.java 

package archieab.andustry.blocks;

import java.util.List;

import archieab.andustry.Reference;
import archieab.andustry.blocks.item.IMetaBlockName;
import archieab.andustry.handlers.EnumHandler.MacTypes;
import net.minecraft.block.Block;
import net.minecraft.block.BlockPistonBase;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;

public class BlockDrill extends Block implements IMetaBlockName {

	public static final PropertyEnum TYPE = PropertyEnum.create("type", MacTypes.class);
	public static final PropertyDirection FACING = PropertyDirection.create("facing");
	public static final PropertyBool ACTIVATED = PropertyBool.create("activated");
	
	public BlockDrill(String unlocalizedName) {
		super(Material.IRON);
		this.setUnlocalizedName(unlocalizedName);
		this.setRegistryName(new ResourceLocation(Reference.MODID, unlocalizedName));
		this.setDefaultState(this.blockState.getBaseState().withProperty(TYPE, MacTypes.BASIC).withProperty(FACING, EnumFacing.NORTH).withProperty(ACTIVATED, Boolean.valueOf(false)));
	}
	
	@Override
	protected BlockStateContainer createBlockState() {
		return new BlockStateContainer(this, new IProperty[] {TYPE,FACING,ACTIVATED});
	}
	
	@Override
	public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY,
			float hitZ, int meta, EntityLivingBase placer, EnumHand hand) {
		return this.getDefaultState().withProperty(FACING, EnumFacing.getDirectionFromEntityLiving(pos, placer)).withProperty(ACTIVATED, Boolean.valueOf(false)).withProperty(TYPE, getStateFromMeta(meta * EnumFacing.values().length).getValue(TYPE));
	}
	
	@Override
	public int getMetaFromState(IBlockState state) {
		MacTypes type = (MacTypes) state.getValue(TYPE);
		EnumFacing facing = (EnumFacing) state.getValue(FACING);
		int meta = type.getID() * EnumFacing.values().length + facing.ordinal();
		return meta;
	}
	
	@Override
	public IBlockState getStateFromMeta(int meta) {
		MacTypes type = MacTypes.values()[(int)(meta / EnumFacing.values().length) % MacTypes.values().length];
		EnumFacing facing = EnumFacing.values()[meta % EnumFacing.values().length];
		return this.getDefaultState().withProperty(TYPE, type).withProperty(FACING, facing);
	}
	
	@Override
	public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos,
			EntityPlayer player) {
		return new ItemStack(Item.getItemFromBlock(this), 1, (int) (getMetaFromState(world.getBlockState(pos)) / EnumFacing.values().length));
	}
	
	@Override
	public int damageDropped(IBlockState state) {
		return (int) (getMetaFromState(state) / EnumFacing.values().length);
	}

	@Override
	public String getSpecialName(ItemStack stack) {
		return MacTypes.values()[stack.getItemDamage() / EnumFacing.values().length].getName();
	}

    @Override
    public void getSubBlocks(Item itemIn, CreativeTabs tab, NonNullList<ItemStack> list) {
        for (int i = 0; i < MacTypes.values().length; i++) {
            list.add(new ItemStack(itemIn, 1, i));
        }
    }
	
}

Any help would be greatly appreciated!

Posted
  On 1/30/2018 at 1:49 PM, Sunser said:

Can you show us your language file (en_US.lang I guess) ?

Expand  

It's not to do with the lang. I haven't added the block's into the lang purely so you can see the raw name. I'm almost certain the issue is to do with it's SpecialName or UnlocalizedName.

Posted
  On 1/30/2018 at 1:57 PM, Sunser said:

Sorry, my bad.

Have you check when you register your blocks that the String is correct ? It could be a copy/paste which has not been edited.

Expand  

Are you talking about my ModBlocks.java? If so, here's the code:

package archieab.andustry.init;

import archieab.andustry.Andustry;
import archieab.andustry.Reference;
import archieab.andustry.blocks.BlockCopperOre;
import archieab.andustry.blocks.BlockDrill;
import archieab.andustry.blocks.BlockMachineFrameAdvanced;
import archieab.andustry.blocks.BlockMachineFrameBasic;
import archieab.andustry.blocks.BlockTinOre;
import archieab.andustry.blocks.BlockCoalCatalystBlock;
import archieab.andustry.blocks.item.ItemBlockDrill;
import archieab.andustry.handlers.EnumHandler;
import archieab.andustry.util.Utils;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class ModBlocks {

	public static Block copper_ore;
	public static Block tin_ore;
	public static Block machineframebasic;
	public static Block machineframeadvanced;
	public static Block drill;
	public static Block coalcatalystblock;
	
	public static void init() {
		copper_ore = new BlockCopperOre("copper_ore", "copper_ore");
		tin_ore = new BlockTinOre("tin_ore", "tin_ore");
		machineframebasic = new BlockMachineFrameBasic("machineframebasic", "machineframebasic");
		machineframeadvanced = new BlockMachineFrameAdvanced("machineframeadvanced", "machineframeadvanced");
		drill = new BlockDrill("drill");
		coalcatalystblock = new BlockCoalCatalystBlock("coal_catalyst_block", "coal_catalyst_block");
	}
	
	public static void register() {
		registerBlock(copper_ore);
		registerBlock(tin_ore);
		registerBlock(machineframebasic);
		registerBlock(machineframeadvanced);
		registerBlock(drill, new ItemBlockDrill(drill));
		registerBlock(coalcatalystblock);
	}
	
	public static void registerRenders() {
		registerRender(copper_ore);
		registerRender(tin_ore);
		registerRender(machineframebasic);
		registerRender(machineframeadvanced);
		for(int i = 0; i < EnumHandler.MacTypes.values().length; i++) {
			registerRender(drill, i, "block_drill_" + EnumHandler.MacTypes.values()[i].getName());
		}
		registerRender(coalcatalystblock);
	}
	
	public static void registerBlock(Block block) {
		block.setCreativeTab(Andustry.Blocks);
		GameRegistry.register(block);
		GameRegistry.register(new ItemBlock(block).setRegistryName(block.getRegistryName()));
		Utils.getLogger().info("Registered Block: " + block.getUnlocalizedName().substring(5));
	}
	
	public static void registerBlock(Block block, ItemBlock itemBlock) {
		block.setCreativeTab(Andustry.Blocks);
		GameRegistry.register(block);
		GameRegistry.register(itemBlock.setRegistryName(block.getRegistryName()));
		Utils.getLogger().info("Registered Block: " + block.getUnlocalizedName().substring(5));
	}
	
	public static void registerRender(Block block) {
		ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(new ResourceLocation(Reference.MODID, block.getUnlocalizedName().substring(5)), "inventory"));
		Utils.getLogger().info("Registered render for " + block.getUnlocalizedName().substring(5));
	}
	
	public static void registerRender(Block block, int meta, String fileName) {
		ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), meta, new ModelResourceLocation(new ResourceLocation(Reference.MODID, fileName), "inventory"));
		Utils.getLogger().info("Register render for " + block.getUnlocalizedName().substring(5));
	}
	
}

 

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • my game keeps crashing right before launching the game before full screen and keeps poping up this error message "error code 1 " The game crashed: rendering overlay Error: java.lang.IllegalAccessError: failed to access class com.mojang.blaze3d.platform.GlStateManager$TextureState from class net.coderbot.iris.gl.IrisRenderSystem$DSAARB (com.mojang.blaze3d.platform.GlStateManager$TextureState is in module minecraft@1.18.2 of loader 'TRANSFORMER' @d919544; net.coderbot.iris.gl.IrisRenderSystem$DSAARB is in module oculus@1.6.4 of loader 'TRANSFORMER' @d919544)
    • removing oculus or any of ETF or EMF or even embeddium doesn't change anything it just crashes again with error -1  https://gist.github.com/Tikalian-coconut/d49e8fb83bf57d5e04eb042522046786 this time i removed all 4 at same time and that gave it something is wrong with the game seriously..
    • crash report -> https://gist.github.com/Tikalian-coconut/18c41f97bdacef54725e5141f57697d7 from what i see it seems like Entity Texture Features doesn't like Oculus doing something or invert.. not sure it's why everything is all black textured but that causes a -1 error
    • well that's bad, cuz there's no crash report at all (the last crash report is from previous replies) it's probably another issue that doesn't fit in this bug report, the game works fine except that everything is black, no texture except the sky and skin, everything else is just black i've tried reloading the textures in game, see for drivers updates but it did nothing, seems like an issue with Embeddium or Oculus i think, but i know nothing compared to you i can still send the latest debug and latest.log files.. edit: it seems that when i re-add rechiseled (1.1.6-1.20.1) it crashes as error 1 (i can't remove it off from the modpack cuz that'll break all my builds on some maps) lemme start the game and get it to crash to get a crash report done)
    • If you've fallen victim to a crypto scam, you're not alone and thankfully, you're not without options. I highly recommend iBolt Cyber Hacker Company for anyone seeking professional and effective assistance in recovering scammed cryptocurrency. After extensive research and hearing from multiple satisfied clients, it's clear that iBolt stands out in a crowded and often unreliable market. Their team of experienced cyber experts and blockchain analysts uses advanced tracking techniques to follow stolen funds across the blockchain and engage with crypto exchanges when possible. They’re not just tech-savvy—they’re strategic and persistent. WHY CHOOSE iBOLT CYBER HACKER COMPANY? (1) Proven success in crypto asset recovery (2) Fast, professional, and discreet service (3) Skilled in blockchain forensics and cyber investigation (4) Committed to fighting online fraud and supporting victims Don’t give up. I strongly recommend reaching out to iBolt Cyber Hacker Company. ENQUIRIES: info @ iboltcyberhack . org/ www . iboltcyberhack. org/ +39. 351. 105. 3619.
  • Topics

×
×
  • Create New...

Important Information

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