Jump to content

Custom Door Help?


Killjoy0593

Recommended Posts

Hi

 

Why not just use the existing door?

 

i.e. what do you want to do differently?

 

Door is a bit complicated because it needs its own renderer and it's made up of two blocks not one.  It's also got a pile of logic  related to opening & closing, whether entities can pass through it or not, changes to the bounding box, etc.

 

If you want to tweak something simple, like the sound it makes when it opens, then it's easy.  Otherwise it's going to take a fair bit of skill and knowledge about the vanilla door and renderers in particular.

 

-TGG

 

 

Link to comment
Share on other sites

Hi

 

Why not just use the existing door?

 

i.e. what do you want to do differently?

 

Door is a bit complicated because it needs its own renderer and it's made up of two blocks not one.  It's also got a pile of logic  related to opening & closing, whether entities can pass through it or not, changes to the bounding box, etc.

 

If you want to tweak something simple, like the sound it makes when it opens, then it's easy.  Otherwise it's going to take a fair bit of skill and knowledge about the vanilla door and renderers in particular.

 

-TGG

I want to create a new door. with the material of rock, my own texture, name, and id. Doesn't it use the texture-map?

Link to comment
Share on other sites

Hi

 

In that case, I think you're in luck.  I'd suggest

 

create your

class BlockMyNewDoor extends BlockDoor

add a constructor

add icon member variables (copy the ones from BlockDoor)

override

    public void registerIcons(IconRegister par1IconRegister)

to register your new icons/textures into BlockMyNewDoor member variables (the BlockDoor ones are private unfortunately)

 

and override

    public Icon getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)

copy the code from BlockDoor.getBlockTexture into BlockMyNewDoor.getBlockTexture and change the references to the icon fields to your own icon texture member variables.

 

The material is in the constructor so it's relatively easy - and if you want your stone door to act like a wooden door (i.e. players can open it) then you probably don't need to change onBlockActivated either.

 

-TGG

 

 

Link to comment
Share on other sites

Thanks Man, Figured It Out :) Here's The Code For Those Who Are Struggling With This :)

 

Main Class

//Making The Door And Item
public final static Block AdobeDoor = new AdobeDoor(900, Material.rock)
		.setHardness(2.0F).setResistance(10.0F)
		.setStepSound(Block.soundStoneFootstep)
		.setUnlocalizedName("adobe_door");
public final static Item AdobeDoorItem = new AdobeDoorItem(901, AdobeDoor)
		.setUnlocalizedName("adobe_door_icon");
//Registering The Door And Items
LanguageRegistry.addName(AdobeDoorItem, "Adobe Door");
GameRegistry.registerBlock(AdobeDoor, "AdobeDoor");
LanguageRegistry.addName(AdobeDoor, "Adobe Door");

 

Item Class

package SavageCraft.Adobe;

import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemDoor;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

public class AdobeDoorItem extends Item {
public Block doorBlock;

public AdobeDoorItem(int par1, Block block) {
	super(par1);
	this.doorBlock = block;
	this.maxStackSize = 1;
	this.setCreativeTab(CreativeTabs.tabRedstone);
}

public boolean onItemUse(ItemStack par1ItemStack,
		EntityPlayer par2EntityPlayer, World par3World, int par4, int par5,
		int par6, int par7, float par8, float par9, float par10) {
	if (par7 != 1) {
		return false;
	} else {
		++par5;
		Block block = this.doorBlock;

		if (par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7,
				par1ItemStack)
				&& par2EntityPlayer.canPlayerEdit(par4, par5 + 1, par6,
						par7, par1ItemStack)) {
			if (!block.canPlaceBlockAt(par3World, par4, par5, par6)) {
				return false;
			} else {
				int i1 = MathHelper
						.floor_double((double) ((par2EntityPlayer.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
				ItemDoor.placeDoorBlock(par3World, par4, par5, par6, i1,
						block);
				--par1ItemStack.stackSize;
				return true;
			}
		} else {
			return false;
		}
	}
}

@Override
public void registerIcons(IconRegister iconRegister) {
	itemIcon = iconRegister.registerIcon(AdobeInfo.NAME.toLowerCase()
			+ ":adobe_door_icon");
}
}

 

Door block Class

package SavageCraft.Adobe;

import java.util.Random;

import net.minecraft.block.BlockDoor;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.IconFlipped;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

public class AdobeDoor extends BlockDoor {
public Item placerItem;
public Icon topDoorIcon;
public Icon[] flippedIcons = new Icon[2];

public AdobeDoor(int par1, Material par2Material) {
	super(par1, par2Material);
	float f = 0.5F;
	float f1 = 1.0F;
	this.setLightOpacity(0);
	this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f);
}

public Icon getBlockTexture(IBlockAccess par1IBlockAccess, int par2,
		int par3, int par4, int par5) {
	if (par5 == 1 || par5 == 0) {
		return this.blockIcon;
	}
	int meta = getFullMetadata(par1IBlockAccess, par2, par3, par4);
	boolean flag = (meta & 4) != 0;
	int halfMeta = meta & 3;
	boolean flipped = false;

	if (flag) {
		if (halfMeta == 0 && par5 == 2)
			flipped = !flipped;
		else if (halfMeta == 1 && par5 == 5)
			flipped = !flipped;
		else if (halfMeta == 2 && par5 == 3)
			flipped = !flipped;
		else if (halfMeta == 3 && par5 == 4)
			flipped = !flipped;
	} else {
		if (halfMeta == 0 && par5 == 5)
			flipped = !flipped;
		else if (halfMeta == 1 && par5 == 3)
			flipped = !flipped;
		else if (halfMeta == 2 && par5 == 4)
			flipped = !flipped;
		else if (halfMeta == 3 && par5 == 2)
			flipped = !flipped;
		if ((meta & 16) != 0)
			flipped = !flipped;
	}

	if (flipped)
		return flippedIcons[(meta &  != 0 ? 1 : 0];
	else
		return (meta &  != 0 ? this.topDoorIcon : this.blockIcon;
}

public Icon getIcon(int par1, int par2) {
	return this.blockIcon;
}

@Override
public void registerIcons(IconRegister iconRegister) {
	this.blockIcon = iconRegister.registerIcon(AdobeInfo.NAME.toLowerCase()
			+ ":adobe_door_lower");
	this.topDoorIcon = iconRegister.registerIcon(AdobeInfo.NAME
			.toLowerCase() + ":adobe_door_upper");
	this.flippedIcons[0] = new IconFlipped(blockIcon, true, false);
	this.flippedIcons[1] = new IconFlipped(topDoorIcon, true, false);
}

public int idPicked(World par1World, int par2, int par3, int par4) {
	return AdobeBlock.AdobeDoorItem.itemID;
}

public int idDropped(int par1, Random par2Random, int par3) {
	return (par1 &  != 0 ? 0 : (AdobeBlock.AdobeDoorItem.itemID);
}
        
        //Remove This Below If You Want It To Open Like A Wooden Door
public boolean onBlockActivated(World par1World, int par2, int par3,
		int par4, EntityPlayer par5EntityPlayer, int par6, float par7,
		float par8, float par9) {
	return false;
}

}

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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I have done this now but have got the error:   'food(net.minecraft.world.food.FoodProperties)' in 'net.minecraft.world.item.Item.Properties' cannot be applied to                '(net.minecraftforge.registries.RegistryObject<net.minecraft.world.item.Item>)' public static final RegistryObject<Item> LEMON_JUICE = ITEMS.register( "lemon_juice", () -> new Item( new HoneyBottleItem.Properties().stacksTo(1).food( (new FoodProperties.Builder()) .nutrition(3) .saturationMod(0.25F) .effect(() -> new MobEffectInstance(MobEffects.DAMAGE_RESISTANCE, 1500), 0.01f ) .build() ) )); The code above is from the ModFoods class, the one below from the ModItems class. public static final RegistryObject<Item> LEMON_JUICE = ITEMS.register("lemon_juice", () -> new Item(new Item.Properties().food(ModFoods.LEMON_JUICE)));   I shall keep going between them to try and figure out the cause. I am sorry if this is too much for you to help with, though I thank you greatly for your patience and all the effort you have put in to help me.
    • I have been following these exact tutorials for quite a while, I must agree that they are amazing and easy to follow. I have registered the item in the ModFoods class, I tried to do it in ModItems (Where all the items should be registered) but got errors, I think I may need to revert this and figure it out from there. Once again, thank you for your help! 👍 Just looking back, I have noticed in your code you added ITEMS.register, which I am guessing means that they are being registered in ModFoods, I shall go through the process of trial and error to figure this out.
    • ♈+2349027025197ஜ Are you a pastor, business man or woman, politician, civil engineer, civil servant, security officer, entrepreneur, Job seeker, poor or rich Seeking how to join a brotherhood for protection and wealth here’s is your opportunity, but you should know there’s no ritual without repercussions but with the right guidance and support from this great temple your destiny is certain to be changed for the better and equally protected depending if you’re destined for greatness Call now for enquiry +2349027025197☎+2349027025197₩™ I want to join ILLUMINATI occult without human sacrificeGREATORLDRADO BROTHERHOOD OCCULT , Is The Club of the Riches and Famous; is the world oldest and largest fraternity made up of 3 Millions Members. We are one Family under one father who is the Supreme Being. In Greatorldrado BROTHERHOOD we believe that we were born in paradise and no member should struggle in this world. Hence all our new members are given Money Rewards once they join in order to upgrade their lifestyle.; interested viewers should contact us; on. +2349027025197 ۝ஐℰ+2349027025197 ₩Greatorldrado BROTHERHOOD OCCULT IS A SACRED FRATERNITY WITH A GRAND LODGE TEMPLE SITUATED IN G.R.A PHASE 1 PORT HARCOURT NIGERIA, OUR NUMBER ONE OBLIGATION IS TO MAKE EVERY INITIATE MEMBER HERE RICH AND FAMOUS IN OTHER RISE THE POWERS OF GUARDIANS OF AGE+. +2349027025197   SEARCHING ON HOW TO JOIN THE Greatorldrado BROTHERHOOD MONEY RITUAL OCCULT IS NOT THE PROBLEM BUT MAKE SURE YOU'VE THOUGHT ABOUT IT VERY WELL BEFORE REACHING US HERE BECAUSE NOT EVERYONE HAS THE HEART TO DO WHAT IT TAKES TO BECOME ONE OF US HERE, BUT IF YOU THINK YOU'RE SERIOUS MINDED AND READY TO RUN THE SPIRITUAL RACE OF LIFE IN OTHER TO ACQUIRE ALL YOU NEED HERE ON EARTH CONTACT SPIRITUAL GRANDMASTER NOW FOR INQUIRY +2349027025197   +2349027025197 Are you a pastor, business man or woman, politician, civil engineer, civil servant, security officer, entrepreneur, Job seeker, poor or rich Seeking how to join
    • Hi, I'm trying to use datagen to create json files in my own mod. This is my ModRecipeProvider class. public class ModRecipeProvider extends RecipeProvider implements IConditionBuilder { public ModRecipeProvider(PackOutput pOutput) { super(pOutput); } @Override protected void buildRecipes(Consumer<FinishedRecipe> pWriter) { ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ModBlocks.COMPRESSED_DIAMOND_BLOCK.get()) .pattern("SSS") .pattern("SSS") .pattern("SSS") .define('S', ModItems.COMPRESSED_DIAMOND.get()) .unlockedBy(getHasName(ModItems.COMPRESSED_DIAMOND.get()), has(ModItems.COMPRESSED_DIAMOND.get())) .save(pWriter); ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, ModItems.COMPRESSED_DIAMOND.get(),9) .requires(ModBlocks.COMPRESSED_DIAMOND_BLOCK.get()) .unlockedBy(getHasName(ModBlocks.COMPRESSED_DIAMOND_BLOCK.get()), has(ModBlocks.COMPRESSED_DIAMOND_BLOCK.get())) .save(pWriter); ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ModItems.COMPRESSED_DIAMOND.get()) .pattern("SSS") .pattern("SSS") .pattern("SSS") .define('S', Blocks.DIAMOND_BLOCK) .unlockedBy(getHasName(ModItems.COMPRESSED_DIAMOND.get()), has(ModItems.COMPRESSED_DIAMOND.get())) .save(pWriter); } } When I try to run the runData client, it shows an error:  Caused by: java.lang.IllegalStateException: Duplicate recipe compressed:compressed_diamond I know that it's caused by the fact that there are two recipes for the ModItems.COMPRESSED_DIAMOND. But I need both of these recipes, because I need a way to craft ModItems.COMPRESSED_DIAMOND_BLOCK and restore 9 diamond blocks from ModItems.COMPRESSED_DIAMOND. Is there a way to solve this?
  • Topics

×
×
  • Create New...

Important Information

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