Jump to content

Recommended Posts

Posted

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

Posted

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)

Posted

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

Posted

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

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

    • Hello! There is an issue with my world(Chocolate Edition modpack), after joining the world all creatures are frozen and the game is not responding or the game crashes after short period of time. Reproduction Steps: Turn on the game Join the world Game crashes immediately or after short period of time. Additional info: Crash log saying that an entity crashed the game is created after the crash(not the logs that I posted, different file from crash-logs, game crashed 3x by Snail, 1x by Small Snail, 1x by Tortoise) Specification: CPU: i5-13600KF GPU: GTX 1070 RAM: 32GB 3200MhZ - allocated 10GB Log links: latest.log: https://mclo.gs/Lp8zlsv crash-reports/crash: https://mclo.gs/XhtyJQI Minecraft version: 1.19.2 Modpack Version: Chocolate Edition 1.9 OS: Windows 10 Java Version: 22.0.2 Minecraft Java: Java 17
    • Hello, for several days I've been trying to find a way to add my animations in this style. @Override public void setupAnim(Entity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { }   My current public class is : public class FakePlayerModelWithAnim<T extends FakePlayerEntity> extends EntityModel<EntityRenderState>   But i can't do that :  public class FakePlayerModelWithAnim<T extends FakePlayerEntity> extends EntityModel<T> Type parameter 'T' is not within its bound; should extend 'net.minecraft.client.renderer.entity.state.EntityRenderState' But with EntityRenderState it ok and it work !   But my setupAnim look like this :  @Override public void setupAnim(EntityRenderState p_370046_) { super.setupAnim(p_370046_); }   I don't have any access to my entity ! Look like 1.21.1 : @Override public void setupAnim(FakePlayerEntity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { this.root().getAllParts().forEach(ModelPart::resetPose); this.applyHeadRotation(netHeadYaw, headPitch); this.animateWalk(FakePlayerEntityAnimations.ANIM_PLAYERS_WALKING, limbSwing, limbSwingAmount, 2f, 2.5f); this.animate(entity.idleAnimationState, FakePlayerEntityAnimations.ANIM_PLAYERS_IDLE, ageInTicks, 1f); } But i'm stuck with new version of Forge...
    • Looks like an issue with abyssalsovereigns - this mod has functions that are not working on a server (client-side-only mod)
    • I added some new mods and updated old ones to my forge server and they will run successfully but the moment I try to join ill briefly load into the world and get booted with the message, internal server error. The mods in question work fine on singleplayer and removing too many from the server causes it to stop working so I cant be sure which one is causing the problem... any ideas? server log: https://pastebin.com/hGH8UUjm client log (from modrinth app): https://mclo.gs/a3oOUGY
    • The level.dat contains an invalid tag ID (115) Try to load the world in singleplayer - then test this world on the server
  • Topics

×
×
  • Create New...

Important Information

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