Jump to content

HELP! Block rotations are messing up, 1.6.2 specific.


kris91268

Recommended Posts

Hello to anyone reading this,

 

I am kris91268, the creator of Light bridges and doors, if you may know

 

On a previous version of Minecraft (1.5.2) My light door rotated correctly when you place it on the underside of a block.

 

But in the 1.6 versions, it doesn't do this anymore, and only can rotate in one way (I would of said one direction, but I don't want to).

I was wandering if anyone on the forums could help me with this dilemma. Below is the source code of the whole BlockLightDoorSource file, any help would be much appreciated.

 

BlockLightDoorSource.java

package kris91268.lbd.Blocks;

import java.util.Random;

import kris91268.lbd.ModLBD;
import kris91268.lbd.Tileentity.TileEntityLightDoorSource;
import cpw.mods.fml.common.registry.BlockProxy;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLiving;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import static net.minecraftforge.common.ForgeDirection.*;

/**
* 
* @author Arbiter
*
*/
public class BlockLightDoorSource extends BlockContainer implements BlockProxy
{
public final boolean powered;

public BlockLightDoorSource(int par1, boolean par2)
{
	super(par1, Material.iron);
	powered = par2;
	setHardness(1.5F);
	setResistance(0.5F);
	setStepSound(Block.soundMetalFootstep);
	setUnlocalizedName("lightDoorSource");
	setCreativeTab(CreativeTabs.tabRedstone);
}
public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
    {
        return false;
    }
public int getRenderBlockPass()
{
	return 1;
}
public void onBlockAdded(World par1World, int par2, int par3, int par4)
{
	if (par1World.getBlockMetadata(par2, par3, par4) == 0)
	{
		if (par1World.isBlockSolidOnSide(par2, par3 + 1, par4, DOWN, true))
		{
			par1World.setBlockMetadataWithNotify(par2, par3, par4, 5, 2);
		}
		else if (par1World.isBlockSolidOnSide(par2, par3 + 1, par4, DOWN, true))
		{
			par1World.setBlockMetadataWithNotify(par2, par3, par4, 1, 2);
		}
		else if (par1World.isBlockSolidOnSide(par2, par3 + 1, par4, DOWN, true))
		{
			par1World.setBlockMetadataWithNotify(par2, par3, par4, 2, 2);
		}
		else if (par1World.isBlockSolidOnSide(par2, par3 + 1, par4, DOWN, true))
		{
			par1World.setBlockMetadataWithNotify(par2, par3, par4, 3, 2);
		}
		else
		{
			this.dropLightDoorIfCantStay(par1World, par2, par3, par4);
		}
	}
	if (par1World.isRemote)
	{
		if (this.powered && !par1World.isBlockIndirectlyGettingPowered(par2, par3, par4))
		{
			par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, 4);
		}
		else if (!this.powered && par1World.isBlockIndirectlyGettingPowered(par2, par3, par4))
		{
			int par5 = par1World.getBlockMetadata(par2, par3, par4);
			if (par5 == 5)
			{
				par1World.setBlock(par2, par3, par4, ModLBD.lightDoorSourceActive.blockID, 5, 2);
				for (int par7 = par3 - 1; par7 >= par3 - 50; --par7)
				{
					if (par1World.isAirBlock(par2, par7, par4))
					{
						par1World.setBlock(par2, par7, par4, ModLBD.lightDoorSection.blockID, 0, 2);
					}
					else
					{
						break;
					}
				}
			}
			if (par5 == 1)
			{
				par1World.setBlock(par2, par3, par4, ModLBD.lightDoorSourceActive.blockID, 1, 2);
				for (int par7 = par3 - 1; par7 >= par3 - 50; --par7)
				{
					if (par1World.isAirBlock(par2, par7, par4))
					{
						par1World.setBlock(par2, par7, par4, ModLBD.lightDoorSection.blockID, 1, 2);
					}
					else
					{
						break;
					}
				}
			}
			if (par5 == 2)
			{
				par1World.setBlock(par2, par3, par4, ModLBD.lightDoorSourceActive.blockID, 2, 2);
				for (int par7 = par3 - 1; par7 >= par3 - 50; --par7)
				{
					if (par1World.isAirBlock(par2, par7, par4))
					{
						par1World.setBlock(par2, par7, par4, ModLBD.lightDoorSection.blockID, 2, 2);
					}
					else
					{
						break;
					}
				}
			}
			if (par5 == 3)
			{
				par1World.setBlock(par2, par3, par4, ModLBD.lightDoorSourceActive.blockID, 3, 2);
				for (int par7 = par3 - 1; par7 >= par3 - 50; --par7)
				{
					if (par1World.isAirBlock(par2, par7, par4))
					{
						par1World.setBlock(par2, par7, par4, ModLBD.lightDoorSection.blockID, 3, 2);
					}
					else
					{
						break;
					}
				}
			}
		}
	}
}
public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
{
	return par1World.isBlockSolidOnSide(par2, par3 + 1, par4, DOWN, true);
}
public int onBlockPlaced(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9)
{
	int par10 = par9;
	if (par9 == 1 && par1World.isBlockSolidOnSide(par2, par3 + 1, par4, DOWN, true))
	{
		par10 = 1;
	}
	if (par9 == 3 && par1World.isBlockSolidOnSide(par2, par3 + 1, par4, DOWN, true))
	{
		par10 = 3;
	}
	if (par9 == 5 && par1World.isBlockSolidOnSide(par2, par3 + 1, par4, DOWN, true))
	{
		par10 = 5;
	}
	if (par9 == 2 && par1World.isBlockSolidOnSide(par2, par3 + 1, par4, DOWN, true))
	{
		par10 = 2;
	}
	return par10;
}
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
	int par5 = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
    float par6 = 0.625F;
    float par7 = 0.575F;
    if (par5 == 5)
    {
    	// Shorter side facing west
    	setBlockBounds(1.0F - par6, 1.0F, 0.0F, 0.55F, 0.8F, 1.0F);
    }
    if (par5 == 1)
    {
    	// Shorter side facing north
    	setBlockBounds(0.0F, 1.0F, 1.0F - par7, 1.0F, 0.8F, 0.625F);
    }
    if (par5 == 2)
    {
    	// Shorter side facing east
    	setBlockBounds(1.0F - par7, 1.0F, 0.0F, 0.625F, 0.8F, 1.0F);
    }
    if (par5 == 3)
    {
    	// Shorter side facing south
    	setBlockBounds(0.0F, 1.0F, 1.0F - par6, 1.0F, 0.8F, 0.55F);
    }
}
protected boolean dropLightDoorIfCantStay(World par1World, int par2, int par3, int par4)
{
	if (!this.canPlaceBlockAt(par1World, par2, par3, par4))
	{
		if (par1World.getBlockId(par2, par3, par4) == this.blockID)
		{
			this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
			par1World.setBlockToAir(par2, par3, par4);
		}
		return false;
	}
	else
	{
		return true;
	}
}
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
{
	if (this.dropLightDoorIfCantStay(par1World, par2, par3, par4))
	{
		int par6 = par1World.getBlockMetadata(par2, par3, par4);
		boolean flag = false;
		if (!par1World.isBlockSolidOnSide(par2, par3 + 1, par4, DOWN, true) && par6 == 5)
		{
			flag = true;
		}
		if (!par1World.isBlockSolidOnSide(par2, par3 + 1, par4, DOWN, true) && par6 == 2)
		{
			flag = true;
		}
		if (!par1World.isBlockSolidOnSide(par2, par3 + 1, par4, DOWN, true) && par6 == 3)
		{
			flag = true;
		}
		if (!par1World.isBlockSolidOnSide(par2, par3 + 1, par4, DOWN, true) && par6 == 1)
		{
			flag = true;
		}
		if (flag)
		{
			this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
			par1World.setBlockToAir(par2, par3, par4);
		}
	}
	if (!par1World.isRemote)
	{
		if (this.powered && !par1World.isBlockIndirectlyGettingPowered(par2, par3, par4))
		{
			par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, 4);
		}
		else if (!this.powered && par1World.isBlockIndirectlyGettingPowered(par2, par3, par4))
		{
			int par6 = par1World.getBlockMetadata(par2, par3, par4);
			if (par6 == 5)
			{
				par1World.setBlock(par2, par3, par4, ModLBD.lightDoorSourceActive.blockID, 5, 2);
				for (int par7 = par3 - 1; par7 >= par3 - 50; --par7)
				{
					if (par1World.isAirBlock(par2, par7, par4))
					{
						par1World.setBlock(par2, par7, par4, ModLBD.lightDoorSection.blockID, 0, 2);
					}
					else
					{
						break;
					}
				}
			}
			if (par6 == 1)
			{
				par1World.setBlock(par2, par3, par4, ModLBD.lightDoorSourceActive.blockID, 1, 2);
				for (int par7 = par3 - 1; par7 >= par3 - 50; --par7)
				{
					if (par1World.isAirBlock(par2, par7, par4))
					{
						par1World.setBlock(par2, par7, par4, ModLBD.lightDoorSection.blockID, 1, 2);
					}
					else
					{
						break;
					}
				}
			}
			if (par6 == 2)
			{
				par1World.setBlock(par2, par3, par4, ModLBD.lightDoorSourceActive.blockID, 2, 2);
				for (int par7 = par3 - 1; par7 >= par3 - 50; --par7)
				{
					if (par1World.isAirBlock(par2, par7, par4))
					{
						par1World.setBlock(par2, par7, par4, ModLBD.lightDoorSection.blockID, 2, 2);
					}
					else
					{
						break;
					}
				}
			}
			if (par6 == 3)
			{
				par1World.setBlock(par2, par3, par4, ModLBD.lightDoorSourceActive.blockID, 3, 2);
				for (int par7 = par3 - 1; par7 >= par3 - 50; --par7)
				{
					if (par1World.isAirBlock(par2, par7, par4))
					{
						par1World.setBlock(par2, par7, par4, ModLBD.lightDoorSection.blockID, 3, 2);
					}
					else
					{
						break;
					}
				}
			}
		}
	}
}
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
	if (!par1World.isRemote && this.powered && !par1World.isBlockIndirectlyGettingPowered(par2, par3, par4))
	{
		int par6 = par1World.getBlockMetadata(par2, par3, par4);
		if (par6 == 5)
		{
			par1World.setBlock(par2, par3, par4, ModLBD.lightDoorSource.blockID, 5, 2);
		}
		if (par6 == 1)
		{
			par1World.setBlock(par2, par3, par4, ModLBD.lightDoorSource.blockID, 1, 2);
		}
		if (par6 == 2)
		{
			par1World.setBlock(par2, par3, par4, ModLBD.lightBridgeSource.blockID, 2, 2);
		}
		if (par6 == 3)
		{
			par1World.setBlock(par2, par3, par4, ModLBD.lightDoorSource.blockID, 3, 2);
		}
	}
}
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving, ItemStack par6ItemStack)
{
	int par7 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
	if (par7 == 0)
	{
		par1World.setBlockMetadataWithNotify(par2, par3, par4, 1, 2);
	}
	if (par7 == 1)
	{
		par1World.setBlockMetadataWithNotify(par2, par3, par4, 5, 2);
	}
	if (par7 == 2)
	{
		par1World.setBlockMetadataWithNotify(par2, par3, par4, 3, 2);
	}
	if (par7 == 3)
	{
		par1World.setBlockMetadataWithNotify(par2, par3, par4, 2, 2);
	}
	if (par6ItemStack.hasDisplayName())
	{
		((TileEntityLightDoorSource)par1World.getBlockTileEntity(par2, par3, par4)).func_91249_a(par6ItemStack.getDisplayName());
	}
}
public int quantityDropped(Random par1Random)
{
	return 1;
}
public boolean isOpaqueCube()
{
	return false;
}
public boolean renderAsNormalBlock()
{
	return false;
}
public int getRenderType()
{
	return -1;
}
public TileEntity getBlockEntity()
{
	return new TileEntityLightDoorSource();
}
public TileEntity createNewTileEntity(World par1World)
{
	return new TileEntityLightDoorSource();
}
}

 

Thanks

kris91268

Link to comment
Share on other sites

Change this Line:

public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving, ItemStack par6ItemStack)

into this Line:

public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLiving, ItemStack par6ItemStack)

Link to comment
Share on other sites

You could have figured this out much earlier (and on your own) if you had used @Override.

 

Sorry, but I am not that good with annotations, it never occurs to me to use the @Override annotation.

 

But I do feel stupid about myself because I didn't see this

Link to comment
Share on other sites

Change this Line:

public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving, ItemStack par6ItemStack)

into this Line:

public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLiving, ItemStack par6ItemStack)

 

Thank you so much, you are amazing.

I would of figured this out myself, but I did not see that the other method was a new one (notch changed the onBlockPlacedBy method), but anyway, thanks so much. +Thank 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

    • https://pastebin.com/VwpAW6PX My game crashes upon launch when trying to implement the Oculus mod to this mod compilation, above is the crash report, I do not know where to begin to attempt to fix this issue and require assistance.
    • https://youtube.com/shorts/gqLTSMymgUg?si=5QOeSvA4TTs-bL46
    • CubeHaven is a SMP server with unique features that can't be found on the majority of other servers! Java: MC.CUBEHAVEN.NET Bedrock: MC.CUBEHAVEN.NET:19132 3 different stores: - CubeHaven Store: Our store to purchase using real money. - Bitcoin Store: Store for Bitcoin. Bitcoin can be earned from playing the server. Giving options for players if they want to spend real money or grind to obtain exclusive packages. - Black Market: A hidden store for trading that operates outside our traditional stores, like custom enchantments, exclusive items and more. Some of our features include: Rank Up: Progress through different ranks to unlock new privileges and perks. 📈 Skills: RPG-style skill system that enhances your gaming experience! 🎮 Leaderboards: Compete and shine! Top players are rewarded weekly! 🏆 Random Teleporter: Travel instantly across different worlds with a click! 🌐 Custom World Generation: Beautifully generated world. 🌍 Dungeons: Explore challenging and rewarding dungeons filled with treasures and monsters. 🏰 Kits: Unlock ranks and gain access to various kits. 🛠️ Fishing Tournament: Compete in a friendly fishing tournament! 🎣 Chat Games: Enjoy games right within the chat! 🎲 Minions: Get some help from your loyal minions. 👥 Piñata Party: Enjoy a festive party with Piñatas! 🎉 Quests: Over 1000 quests that you can complete! 📜 Bounty Hunter: Set a bounty on a player's head. 💰 Tags: Displayed on nametags, in the tab list, and in chat. 🏷️ Coinflip: Bet with other players on coin toss outcomes, victory, or defeat! 🟢 Invisible & Glowing Frames: Hide your frames for a cleaner look or apply a glow to it for a beautiful look. 🔲✨[ Player Warp: Set your own warp points for other players to teleport to. 🌟 Display Shop: Create your own shop and sell to other players! 🛒 Item Skins: Customize your items with unique skins. 🎨 Pets: Your cute loyal companion to follow you wherever you go! 🐾 Cosmetics: Enhance the look of your character with beautiful cosmetics! 💄 XP-Bottle: Store your exp safely in a bottle for later use! 🍶 Chest & Inventory Sorting: Keep your items neatly sorted in your inventory or chest! 📦 Glowing: Stand out from other players with a colorful glow! ✨ Player Particles: Over 100 unique particle effects to show off. 🎇 Portable Inventories: Over virtual inventories with ease. 🧳 And a lot more! Become part of our growing community today! Discord: https://cubehaven.net/discord Java: MC.CUBEHAVEN.NET Bedrock: MC.CUBEHAVEN.NET:19132
    • # Problematic frame: # C [libopenal.so+0x9fb4d] It is always the same issue - this refers to the Linux OS - so your system may prevent Java from working   I am not familiar with Linux - check for similar/related issues  
  • Topics

×
×
  • Create New...

Important Information

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