Jump to content

[1.7.2]Custom Furnace


Z@Nka

Recommended Posts

Hi,

My custom furnace is not working the way i would like it to still, I made a post yesterday about it and fixed it but now i have another problem. :'(

The furnace is not facing the way i want it to. Instead of acting like a normal furnace where the side your looking at will be the front, it is the block you click on. For example, i click on the west side of a block and the front is towards the west, even though i was standing north.

 

Block class

package electro.blocks;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import electro.lib.Referance;
import electro.mod.Electrocuted;
import electro.tileentity.TileEntityCompressionFurnace;

public class BlockCompressionFurnace extends BlockContainer {

private final boolean isActive;

@SideOnly(Side.CLIENT)
private IIcon iconFront;
@SideOnly(Side.CLIENT)
private IIcon iconTop;


public BlockCompressionFurnace(boolean isActive) {
	super(Material.rock);
	this.setCreativeTab(Electrocuted.ElectrocutedTab);

	this.isActive = isActive;
}

public Item idDropped(int par1, Random random, int par3) {
	return Item.getItemFromBlock(Electrocuted.CompressionFurnaceIdle);
}

public void onBlockAdded(World world, int x, int y, int z) {
	super.onBlockAdded(world, x, y, z);
	this.setDefaultDirection(world, x, y, z);
}

 private void setDefaultDirection(World world, int x, int y, int z)
	 {
	        if (!world.isRemote)
	        {
	            Block block = world.getBlock(x, y, z - 1);
	            Block block1 = world.getBlock(x, y, z + 1);
	            Block block2 = world.getBlock(x - 1, y, z);
	            Block block3 = world.getBlock(x + 1, y, z);
	            byte b0 = 3;

	            if (block.func_149730_j() && !block1.func_149730_j())
	            {
	                b0 = 3;
	            }

	            if (block1.func_149730_j() && !block.func_149730_j())
	            {
	                b0 = 2;
	            }

	            if (block2.func_149730_j() && !block3.func_149730_j())
	            {
	                b0 = 5;
	            }

	            if (block3.func_149730_j() && !block2.func_149730_j())
	            {
	                b0 = 4;
	            }

	            world.setBlockMetadataWithNotify(x, y, z, b0, 2);
	        }
	    }

 @SideOnly(Side.CLIENT)
 public IIcon getIcon(int p_149691_1_, int p_149691_2_) {
	 return p_149691_1_ == 1 ? this.iconTop : (p_149691_1_ == 0 ? this.iconTop : (p_149691_1_ != p_149691_2_ ? this.blockIcon : this.iconFront));
    }

 @SideOnly(Side.CLIENT)
 public void registerBlockIcons(IIconRegister iconRegister) {
	 this.blockIcon = iconRegister.registerIcon("electrocuted:CompressionFurnace_side");
	 this.iconFront = iconRegister.registerIcon(this.isActive ? "electrocuted:CompressionFurnace_Active_front" : "electrocuted:CompressionFurnace_Idle_Front");
	 this.iconTop = iconRegister.registerIcon("electrocuted:CompressionFurnace_top");
 }

 public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
	 if(world.isRemote) {
		 FMLNetworkHandler.openGui(player, Electrocuted.instance, Electrocuted.guiIdCompressionFurnace, world, x, y, z);
	 }
	 return true;
 }

    
public TileEntity createNewTileEntity(World world, int var1) {
return new TileEntityCompressionFurnace();
}

public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLivingBase, ItemStack itemstack) {
	 int l = MathHelper.floor_double((double)(entityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;

        if (l == 0)
        {
            world.setBlockMetadataWithNotify(x, y, z, 2, 2);
        }

        if (l == 1)
        {
        	world.setBlockMetadataWithNotify(x, y, z, 5, 2);
        }

        if (l == 2)
        {
        	world.setBlockMetadataWithNotify(x, y, z, 3, 2);
        }

        if (l == 3)
        {
        	world.setBlockMetadataWithNotify(x, y, z, 4, 2);
        }

        if (itemstack.hasDisplayName())
        {
            ((TileEntityCompressionFurnace)world.getTileEntity(x, y, z)).setGuiDisplayName(itemstack.getDisplayName());
        }
    }
}

 

 

TileEntity class (not done)

package electro.tileentity;

import net.minecraft.tileentity.TileEntity;

public class TileEntityCompressionFurnace extends TileEntity {

private String localizedName;

public void setGuiDisplayName(String displayName) {
	this.localizedName = displayName;
}

}

If I helped then you help, hit that Thank You button or Applaud.

Link to comment
Share on other sites

You are setting your Block's metadata in two different places with two different methods. One is obviously messing up the other.

Link to comment
Share on other sites

here is a pretty good tutorial for a custom furnace:

 

 

he explains everything. follow this tutorial and everything will be fine.

only one thing is not up to date, and that is:

public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_)

 

i copied it from the BlockFurnace.class, then it worked.

*********************************

**  Always remember you are unique,  **

**  just like everyone else                   **     

**********************************

Was my post helpful? Say thanks and

press the thank you button, on my post!!

God, damn it!

Link to comment
Share on other sites

here is a pretty good tutorial for a custom furnace:

 

 

Thats the series i watched... ;)

But, I still don't understand where i'm steeing the metadata again...

If I helped then you help, hit that Thank You button or Applaud.

Link to comment
Share on other sites

here is a pretty good tutorial for a custom furnace:

 

 

Thats the series i watched... ;)

But, I still don't understand where i'm steeing the metadata again...

 

OnBlockPlacedBy() and setDefaultDirection() are both setting the metadata for the block. One function sets direction based on furnace surroundings (so it doesn't face a block). The other bases it on the facing of the player (like a door or stairs). They should agree?

Link to comment
Share on other sites

here is a pretty good tutorial for a custom furnace:

 

 

Thats the series i watched... ;)

But, I still don't understand where i'm steeing the metadata again...

Ohh ok.

I looked at the code from the normal furnace and thats what i got.

 

 

OnBlockPlacedBy() and setDefaultDirection() are both setting the metadata for the block. One function sets direction based on furnace surroundings (so it doesn't face a block). The other bases it on the facing of the player (like a door or stairs). They should agree?

If I helped then you help, hit that Thank You button or Applaud.

Link to comment
Share on other sites

  • 1 month later...

Hello,

 

your problem is that the set default direction function works based on the surrounding blocks,

not on you

 

i had the same problem

 

i left the on block added function out completely and added a function (in the block class) and call it in the on block placed by function like so:

onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase, ItemStack p_149689_6_){
byte b0 = 3;
b0=rotateBlock(b0, entity);//call my function
world.setBlockMetadataWithNotify(i, j, k, b0, 2);
}

 

and here is the function:

public byte rotateBlock(byte b0, EntityLivingBase entity){

	if((entity.rotationYaw>=135&&entity.rotationYaw<=181)||(entity.rotationYaw<=-135&&entity.rotationYaw>=-181)){
		//if entity is faceing north
		b0 = 3;
	}else if(entity.rotationYaw>-135&&entity.rotationYaw<-45){
		//if entity is faceing east
		b0 = 4;
	}else if(entity.rotationYaw>=-45&&entity.rotationYaw<=45){
		//if entity is faceing south
		b0 = 2;
	}else if(entity.rotationYaw>45&&entity.rotationYaw<135){
		//if entity is faceing west
		b0 = 5;

		//sometimes rotationYaw gets over 180 or under -180
		//for example 185 equals the rotation at -175
		//so im fixing that by subtracting 360 if it is over 180 or under -180

	}else if(entity.rotationYaw>=181){
		entity.rotationYaw=entity.rotationYaw-360;
		b0=rotateBlock(b0, entity);
	}else if(entity.rotationYaw<=-181){
		entity.rotationYaw=entity.rotationYaw+360;
		b0=rotateBlock(b0, entity);
	}
	return b0;
}

 

i hope that helps you

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

    • Minecraft Version: 1.8-1.20.X Forge Version: All (Tested on 49.0.27, 11.14.4.1577 and some others) Steps to Reproduce: Setup a server with IPV6 only Setup a docker container with forge Try to connect to the Forge Server Description of issue: Hello, I am reaching out to seek your expertise within this forum to clarify a technical situation I am encountering, suspecting a potential issue related to Forge in a Docker environment, specifically in an IPv6 context. Initial Configuration: Debian 12 server, configured exclusively for IPv6, with Docker installed. Using the Docker image ghcr.io/pterodactyl/yolks:java_17, launching a Minecraft Vanilla server version 1.20.4 proceeds without any issues. Problem: The issue arises when deploying a Minecraft Forge server version 1.20.4 with the same Docker image (ghcr.io/pterodactyl/yolks:java_17), where connecting to the server becomes impossible. Notably, this issue does not occur when launching outside of Docker, where the server functions as expected. Hypothesis: This situation leads me to question the interaction between Forge and Docker, particularly in an IPv6-only configuration, despite several resolution attempts (testing with different versions of Forge, adjusting container network configurations (0.0.0.0, ::/0, and the server's ipv6), trials with various network settings, and modifications of Java options). Further testing was conducted with and without the use of the Pterodactyl game panel, unsuccessfully. The parameter -Djava.net.preferIPv4Stack=false also did not provide a solution. I tried to do the same things on multiple Minecraft server (include vanilla,spigot,fabric,sponge) and this work fine. The problem only happend with Forge. This issue seem to happend on all forge versions.   I appreciate your time and assistance in advance.
    • The game crashed whilst exception ticking world Error: java.lang.NullPointerException: Cannot invoke "net.minecraft.resources.ResourceLocation.equals(Object)" because "this.lootTableId" is null Error given is above. I was already playing for around 15 minutes and wasn't doing anything specific or even breaking anything when the crashed happened. This is update 1.19.2 forge: 43.2.23 Mod list: ESSENTIAL Mod (by SparkUniverse_) Traveler's Titles (Forge) (by YUNGNICKYOUNG) Resourceful Config (by ThatGravyBoat) Dynamic Lights (by atomicstrykergrumpy) TenzinLib (by CommodoreThrawn) Nature's Compass (by Chaosyr) Library Ferret - Forge (by jtl_elisa) Cold Sweat (by Mikul) Simple Voice Chat (by henkelmax) Waystones (by BlayTheNinth) Carry On (by Tschipp) [Let's Do] Meadow (by satisfy) Creeper Overhaul (by joosh_7889) AutoRegLib (by Vazkii) Moonlight Lib (by MehVahdJukaar) AppleSkin (by squeek502) Xaero's World Map (by xaero96) Rotten Creatures (by fusionstudiomc) YUNG's API (Forge) (by YUNGNICKYOUNG) Village Artifacts (by Lothrazar) Right Click, Get Crops (by TeamCoFH) Supplementaries (by MehVahdJukaar) Automatic Tool Swap (by MelanX) Better Third Person (by Socolio) Supplementaries Squared (by plantspookable) Traveler's Backpack (by Tiviacz1337) Caelus API (Forge/NeoForge) (by TheIllusiveC4) Creatures and Beasts (by joosh_7889) Architectury API (Fabric/Forge/NeoForge) (by shedaniel) Quark Oddities (by Vazkii) Origins (Forge) (by EdwinMindcraft) Villager Names (by Serilum) GeckoLib (by Gecko) Realistic Bees (by Serilum) Illuminations Forge 🔥 (by dimadencep) Serene Seasons (by TheAdubbz) Critters and Companions (by joosh_7889) [Let's Do] Bakery (by satisfy) Falling Leaves (Forge) (by Cheaterpaul) Jade 🔍 (by Snownee) Collective (by Serilum) TerraBlender (Forge) (by TheAdubbz) [Let's Do] API (by Cristelknight) Towns and Towers (by Biban_Auriu) More Villagers (by SameDifferent) Biomes O' Plenty (by Forstride) Goblin Traders (by MrCrayfish) Corpse (by henkelmax) Tree Harvester (by Serilum) Balm (Forge Edition) (by BlayTheNinth) Mouse Tweaks (by YaLTeR) Sound Physics Remastered (by henkelmax) Xaero's Minimap (by xaero96) Just Enough Items (JEI) (by mezz) Terralith (by Starmute) Quark (by Vazkii) [Let's Do] Vinery (by satisfy) [Let's Do] Candlelight (by satisfy) Repurposed Structures (Neoforge/Forge) (by telepathicgrunt) Dusty Decorations (by flint_mischiff) Immersive Armors [Fabric/Forge] (by Conczin) Serene Seasons Fix (by Or_OS) Shutup Experimental Settings! (by Corgi_Taco) Skin Layers 3D (Fabric/Forge) (by tr7zw)
    • Make sure Java is running via Nvidia GPU https://windowsreport.com/minecraft-not-using-gpu/  
    • Also make a test with other Custom Launchers like AT Launcher, MultiMC or Technic Launcher
    • Embeddium and valkyrienskies are not working together - remove one of these mods With removing Embeddium, also remove Oculus, TexTrue's Embeddium Options and Embeddium Extras Or use Rubidium instead
  • Topics

×
×
  • Create New...

Important Information

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