-
Posts
867 -
Joined
-
Last visited
-
Days Won
3
Everything posted by JimiIT92
-
Topic modified. P.S: img tag don't work with imgur
-
Hi guys! I'm having problem spawning a structure in my custom dimension. First: i want it spawn only 1 in dimension, it's inteended to be a dimension's boss strcuture so i don't want it to spawn more than one. Second: it is a giant hole in the ground so i don't want that this will intersecate with other structures or blocks, like trees or caves. I made two screenshots of what it happen right now: In the first screenshot you see how the planks from a village are inside the hole area. This is not supposed to happen so how can i made this not happening? In the second screenshot you see how the sctructure generates itself 5 times (instead of one). Again, how can i made this not happening? Here is the code for my custom dimension (the biome), and the structure Biome http://pastebin.com/RF5gbeVd WorldGenCorruptedCrate Part 1: http://pastebin.com/MjrQ26ND Part 2: http://pastebin.com/THMNEVHQ http://pastebin.com/CHFELfZV Part 3: http://pastebin.com/8vxYx5ZL Part 4: http://pastebin.com/6U9sGxdZ Also here is my console log when creating a new world: http://pastebin.com/jHHMY98Z Thanks in advance for all who will help me
-
Hi everybody! I'm making my custom dimension but what i've noticed is that when i run out the portal, to get back in the overworld, i'm not spawning where the original portal was but a little far from them (like 10-11 blocks). Also when entering or leaving the dimension there are no messages (instead ii've defined them). Here is a video to show what is my problem: http://youtu.be/gw2GxmfFnJI And here are my files: Block Corrupted Portal package mod.mineworld.blocks.mod_dimension; import mod.mineworld.mod_dimension; import mod.mineworld.mod_tabs; import mod.mineworld.world.mod_dimension.TeleporterCorrupted; import net.minecraft.block.Block; import net.minecraft.block.BlockPortal; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Blocks; import net.minecraft.server.MinecraftServer; import net.minecraft.world.World; public class BlockCorruptedPortal extends BlockPortal { public BlockCorruptedPortal() { super(); this.setCreativeTab(mod_tabs.tabDimensionBlocks); } @Override public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity) { if ((par5Entity.ridingEntity == null) && (par5Entity.riddenByEntity == null) && ((par5Entity instanceof EntityPlayerMP))) { EntityPlayerMP player = (EntityPlayerMP) par5Entity; MinecraftServer mServer = MinecraftServer.getServer(); if (player.timeUntilPortal > 0) { player.timeUntilPortal = 10; } else if (player.dimension != 2) { player.timeUntilPortal = 10; player.mcServer.getConfigurationManager().transferPlayerToDimension(player, 2, new TeleporterCorrupted(mServer.worldServerForDimension(2))); } else { player.timeUntilPortal = 10; player.mcServer.getConfigurationManager().transferPlayerToDimension(player, 0, new TeleporterCorrupted(mServer.worldServerForDimension(1))); } } } public boolean func_150000_e(World par1World, int par2, int par3, int par4) { byte b0 = 0; byte b1 = 0; if (par1World.getBlock(par2 - 1, par3, par4) == Blocks.stone || par1World.getBlock(par2 + 1, par3, par4) == Blocks.stone) { b0 = 1; } if (par1World.getBlock(par2, par3, par4 - 1) == Blocks.stone || par1World.getBlock(par2, par3, par4 + 1) == Blocks.stone) { b1 = 1; } if (b0 == b1) { return false; } else { if (par1World.isAirBlock(par2 - b0, par3, par4 - b1)) { par2 -= b0; par4 -= b1; } int l; int i1; for (l = -1; l <= 2; ++l) { for (i1 = -1; i1 <= 3; ++i1) { boolean flag = l == -1 || l == 2 || i1 == -1 || i1 == 3; if (l != -1 && l != 2 || i1 != -1 && i1 != 3) { Block j1 = par1World.getBlock(par2 + b0 * l, par3 + i1, par4 + b1 * l); boolean isAirBlock = par1World.isAirBlock(par2 + b0 * l, par3 + i1, par4 + b1 * l); if (flag) { if (j1 != Blocks.stone) { return false; } } else if (!isAirBlock && j1 != Blocks.fire) { return false; } } } } for (l = 0; l < 2; ++l) { for (i1 = 0; i1 < 3; ++i1) { par1World.setBlock(par2 + b0 * l, par3 + i1, par4 + b1 * l, mod_dimension.corrupted_portal, 0, 2); } } return true; } } @Override public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, Block par5) { byte b0 = 0; byte b1 = 1; if (par1World.getBlock(par2 - 1, par3, par4) == this || par1World.getBlock(par2 + 1, par3, par4) == this) { b0 = 1; b1 = 0; } int i1; for (i1 = par3; par1World.getBlock(par2, i1 - 1, par4) == this; --i1) { ; } if (par1World.getBlock(par2, i1 - 1, par4) != Blocks.stone) { par1World.setBlockToAir(par2, par3, par4); } else { int j1; for (j1 = 1; j1 < 4 && par1World.getBlock(par2, i1 + j1, par4) == this; ++j1) { ; } if (j1 == 3 && par1World.getBlock(par2, i1 + j1, par4) == Blocks.stone) { boolean flag = par1World.getBlock(par2 - 1, par3, par4) == this || par1World.getBlock(par2 + 1, par3, par4) == this; boolean flag1 = par1World.getBlock(par2, par3, par4 - 1) == this || par1World.getBlock(par2, par3, par4 + 1) == this; if (flag && flag1) { par1World.setBlockToAir(par2, par3, par4); } else { if ((par1World.getBlock(par2 + b0, par3, par4 + b1) != Blocks.stone || par1World.getBlock(par2 - b0, par3, par4 - b1) != this) && (par1World.getBlock(par2 - b0, par3, par4 - b1) != Blocks.stone || par1World.getBlock(par2 + b0, par3, par4 + b1) != this)) { par1World.setBlockToAir(par2, par3, par4); } } } else { par1World.setBlockToAir(par2, par3, par4); } } } public void registerBlockIcons(IIconRegister par1) { this.blockIcon = par1.registerIcon(this.getTextureName()); } } Teleporter Corrupted package mod.mineworld.world.mod_dimension; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Random; import mod.mineworld.mod_dimension; import net.minecraft.entity.Entity; import net.minecraft.init.Blocks; import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.Direction; import net.minecraft.util.LongHashMap; import net.minecraft.util.MathHelper; import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.Teleporter; import net.minecraft.world.WorldServer; public class TeleporterCorrupted extends Teleporter { private final WorldServer worldServerInstance; /** A private Random() function in Teleporter */ private final Random random; /** Stores successful portal placement locations for rapid lookup. */ private final LongHashMap destinationCoordinateCache = new LongHashMap(); /** * A list of valid keys for the destinationCoordainteCache. These are based on the X & Z of the players initial * location. */ @SuppressWarnings("rawtypes") private final List destinationCoordinateKeys = new ArrayList(); public TeleporterCorrupted(WorldServer par1WorldServer) { super(par1WorldServer); this.worldServerInstance = par1WorldServer; this.random = new Random(par1WorldServer.getSeed()); } /** * Place an entity in a nearby portal, creating one if necessary. */ @Override public void placeInPortal(Entity par1Entity, double par2, double par4, double par6, float par8) { if (this.worldServerInstance.provider.dimensionId != 1) { if (!this.placeInExistingPortal(par1Entity, par2, par4, par6, par8)) { this.makePortal(par1Entity); this.placeInExistingPortal(par1Entity, par2, par4, par6, par8); } } else { int i = MathHelper.floor_double(par1Entity.posX); int j = MathHelper.floor_double(par1Entity.posY) - 1; int k = MathHelper.floor_double(par1Entity.posZ); byte b0 = 1; byte b1 = 0; for (int l = -2; l <= 2; ++l) { for (int i1 = -2; i1 <= 2; ++i1) { for (int j1 = -1; j1 < 3; ++j1) { int k1 = i + i1 * b0 + l * b1; int l1 = j + j1; int i2 = k + i1 * b1 - l * b0; boolean flag = j1 < 0; this.worldServerInstance.setBlock(k1, l1, i2, flag ? Blocks.stone : Blocks.air); } } } par1Entity.setLocationAndAngles((double)i, (double)j, (double)k, par1Entity.rotationYaw, 0.0F); par1Entity.motionX = par1Entity.motionY = par1Entity.motionZ = 0.0D; } } /** * Place an entity in a nearby portal which already exists. */ @SuppressWarnings("unchecked") @Override public boolean placeInExistingPortal(Entity par1Entity, double par2, double par4, double par6, float par8) { short short1 = 128; double d3 = -1.0D; int i = 0; int j = 0; int k = 0; int l = MathHelper.floor_double(par1Entity.posX); int i1 = MathHelper.floor_double(par1Entity.posZ); long j1 = ChunkCoordIntPair.chunkXZ2Int(l, i1); boolean flag = true; double d4; int k1; if (this.destinationCoordinateCache.containsItem(j1)) { PortalPosition portalposition = (PortalPosition)this.destinationCoordinateCache.getValueByKey(j1); d3 = 0.0D; i = portalposition.posX; j = portalposition.posY; k = portalposition.posZ; portalposition.lastUpdateTime = this.worldServerInstance.getTotalWorldTime(); flag = false; } else { for (k1 = l - short1; k1 <= l + short1; ++k1) { double d5 = (double)k1 + 0.5D - par1Entity.posX; for (int l1 = i1 - short1; l1 <= i1 + short1; ++l1) { double d6 = (double)l1 + 0.5D - par1Entity.posZ; for (int i2 = this.worldServerInstance.getActualHeight() - 1; i2 >= 0; --i2) { if (this.worldServerInstance.getBlock(k1, i2, l1) == mod_dimension.corrupted_portal) { while (this.worldServerInstance.getBlock(k1, i2 - 1, l1) == mod_dimension.corrupted_portal) { --i2; } d4 = (double)i2 + 0.5D - par1Entity.posY; double d7 = d5 * d5 + d4 * d4 + d6 * d6; if (d3 < 0.0D || d7 < d3) { d3 = d7; i = k1; j = i2; k = l1; } } } } } } if (d3 >= 0.0D) { if (flag) { this.destinationCoordinateCache.add(j1, new PortalPosition(i, j, k, this.worldServerInstance.getTotalWorldTime())); this.destinationCoordinateKeys.add(Long.valueOf(j1)); } double d8 = (double)i + 0.5D; double d9 = (double)j + 0.5D; d4 = (double)k + 0.5D; int j2 = -1; if (this.worldServerInstance.getBlock(i - 1, j, k) == mod_dimension.corrupted_portal) { j2 = 2; } if (this.worldServerInstance.getBlock(i + 1, j, k) == mod_dimension.corrupted_portal) { j2 = 0; } if (this.worldServerInstance.getBlock(i, j, k - 1) == mod_dimension.corrupted_portal) { j2 = 3; } if (this.worldServerInstance.getBlock(i, j, k + 1) == mod_dimension.corrupted_portal) { j2 = 1; } int k2 = par1Entity.getTeleportDirection(); if (j2 > -1) { int l2 = Direction.rotateLeft[j2]; int i3 = Direction.offsetX[j2]; int j3 = Direction.offsetZ[j2]; int k3 = Direction.offsetX[l2]; int l3 = Direction.offsetZ[l2]; boolean flag1 = !this.worldServerInstance.isAirBlock(i + i3 + k3, j, k + j3 + l3) || !this.worldServerInstance.isAirBlock(i + i3 + k3, j + 1, k + j3 + l3); boolean flag2 = !this.worldServerInstance.isAirBlock(i + i3, j, k + j3) || !this.worldServerInstance.isAirBlock(i + i3, j + 1, k + j3); if (flag1 && flag2) { j2 = Direction.rotateOpposite[j2]; l2 = Direction.rotateOpposite[l2]; i3 = Direction.offsetX[j2]; j3 = Direction.offsetZ[j2]; k3 = Direction.offsetX[l2]; l3 = Direction.offsetZ[l2]; k1 = i - k3; d8 -= (double)k3; int i4 = k - l3; d4 -= (double)l3; flag1 = !this.worldServerInstance.isAirBlock(k1 + i3 + k3, j, i4 + j3 + l3) || !this.worldServerInstance.isAirBlock(k1 + i3 + k3, j + 1, i4 + j3 + l3); flag2 = !this.worldServerInstance.isAirBlock(k1 + i3, j, i4 + j3) || !this.worldServerInstance.isAirBlock(k1 + i3, j + 1, i4 + j3); } float f1 = 0.5F; float f2 = 0.5F; if (!flag1 && flag2) { f1 = 1.0F; } else if (flag1 && !flag2) { f1 = 0.0F; } else if (flag1 && flag2) { f2 = 0.0F; } d8 += (double)((float)k3 * f1 + f2 * (float)i3); d4 += (double)((float)l3 * f1 + f2 * (float)j3); float f3 = 0.0F; float f4 = 0.0F; float f5 = 0.0F; float f6 = 0.0F; if (j2 == k2) { f3 = 1.0F; f4 = 1.0F; } else if (j2 == Direction.rotateOpposite[k2]) { f3 = -1.0F; f4 = -1.0F; } else if (j2 == Direction.rotateRight[k2]) { f5 = 1.0F; f6 = -1.0F; } else { f5 = -1.0F; f6 = 1.0F; } double d10 = par1Entity.motionX; double d11 = par1Entity.motionZ; par1Entity.motionX = d10 * (double)f3 + d11 * (double)f6; par1Entity.motionZ = d10 * (double)f5 + d11 * (double)f4; par1Entity.rotationYaw = par8 - (float)(k2 * 90) + (float)(j2 * 90); } else { par1Entity.motionX = par1Entity.motionY = par1Entity.motionZ = 0.0D; } par1Entity.setLocationAndAngles(d8, d9, d4, par1Entity.rotationYaw, par1Entity.rotationPitch); return true; } else { return false; } } @Override public boolean makePortal(Entity par1Entity) { byte b0 = 16; double d0 = -1.0D; int i = MathHelper.floor_double(par1Entity.posX); int j = MathHelper.floor_double(par1Entity.posY); int k = MathHelper.floor_double(par1Entity.posZ); int l = i; int i1 = j; int j1 = k; int k1 = 0; int l1 = this.random.nextInt(4); int i2; double d1; double d2; int j2; int k2; int l2; int i3; int j3; int k3; int l3; int i4; int j4; int k4; double d3; double d4; for (i2 = i - b0; i2 <= i + b0; ++i2) { d1 = (double)i2 + 0.5D - par1Entity.posX; for (j2 = k - b0; j2 <= k + b0; ++j2) { d2 = (double)j2 + 0.5D - par1Entity.posZ; label274: for (k2 = this.worldServerInstance.getActualHeight() - 1; k2 >= 0; --k2) { if (this.worldServerInstance.isAirBlock(i2, k2, j2)) { while (k2 > 0 && this.worldServerInstance.isAirBlock(i2, k2 - 1, j2)) { --k2; } for (i3 = l1; i3 < l1 + 4; ++i3) { l2 = i3 % 2; k3 = 1 - l2; if (i3 % 4 >= 2) { l2 = -l2; k3 = -k3; } for (j3 = 0; j3 < 3; ++j3) { for (i4 = 0; i4 < 4; ++i4) { for (l3 = -1; l3 < 4; ++l3) { k4 = i2 + (i4 - 1) * l2 + j3 * k3; j4 = k2 + l3; int l4 = j2 + (i4 - 1) * k3 - j3 * l2; if (l3 < 0 && !this.worldServerInstance.getBlock(k4, j4, l4).getMaterial().isSolid() || l3 >= 0 && !this.worldServerInstance.isAirBlock(k4, j4, l4)) { continue label274; } } } } d4 = (double)k2 + 0.5D - par1Entity.posY; d3 = d1 * d1 + d4 * d4 + d2 * d2; if (d0 < 0.0D || d3 < d0) { d0 = d3; l = i2; i1 = k2; j1 = j2; k1 = i3 % 4; } } } } } } if (d0 < 0.0D) { for (i2 = i - b0; i2 <= i + b0; ++i2) { d1 = (double)i2 + 0.5D - par1Entity.posX; for (j2 = k - b0; j2 <= k + b0; ++j2) { d2 = (double)j2 + 0.5D - par1Entity.posZ; label222: for (k2 = this.worldServerInstance.getActualHeight() - 1; k2 >= 0; --k2) { if (this.worldServerInstance.isAirBlock(i2, k2, j2)) { while (k2 > 0 && this.worldServerInstance.isAirBlock(i2, k2 - 1, j2)) { --k2; } for (i3 = l1; i3 < l1 + 2; ++i3) { l2 = i3 % 2; k3 = 1 - l2; for (j3 = 0; j3 < 4; ++j3) { for (i4 = -1; i4 < 4; ++i4) { l3 = i2 + (j3 - 1) * l2; k4 = k2 + i4; j4 = j2 + (j3 - 1) * k3; if (i4 < 0 && !this.worldServerInstance.getBlock(l3, k4, j4).getMaterial().isSolid() || i4 >= 0 && !this.worldServerInstance.isAirBlock(l3, k4, j4)) { continue label222; } } } d4 = (double)k2 + 0.5D - par1Entity.posY; d3 = d1 * d1 + d4 * d4 + d2 * d2; if (d0 < 0.0D || d3 < d0) { d0 = d3; l = i2; i1 = k2; j1 = j2; k1 = i3 % 2; } } } } } } } int i5 = l; int j5 = i1; j2 = j1; int k5 = k1 % 2; int l5 = 1 - k5; if (k1 % 4 >= 2) { k5 = -k5; l5 = -l5; } boolean flag; if (d0 < 0.0D) { if (i1 < 70) { i1 = 70; } if (i1 > this.worldServerInstance.getActualHeight() - 10) { i1 = this.worldServerInstance.getActualHeight() - 10; } j5 = i1; for (k2 = -1; k2 <= 1; ++k2) { for (i3 = 1; i3 < 3; ++i3) { for (l2 = -1; l2 < 3; ++l2) { k3 = i5 + (i3 - 1) * k5 + k2 * l5; j3 = j5 + l2; i4 = j2 + (i3 - 1) * l5 - k2 * k5; flag = l2 < 0; this.worldServerInstance.setBlock(k3, j3, i4, flag ? Blocks.stone : Blocks.air); } } } } for (k2 = 0; k2 < 4; ++k2) { for (i3 = 0; i3 < 4; ++i3) { for (l2 = -1; l2 < 4; ++l2) { k3 = i5 + (i3 - 1) * k5; j3 = j5 + l2; i4 = j2 + (i3 - 1) * l5; flag = i3 == 0 || i3 == 3 || l2 == -1 || l2 == 3; this.worldServerInstance.setBlock(k3, j3, i4, flag ? Blocks.stone : mod_dimension.corrupted_portal, 0, 2); } } for (i3 = 0; i3 < 4; ++i3) { for (l2 = -1; l2 < 4; ++l2) { k3 = i5 + (i3 - 1) * k5; j3 = j5 + l2; i4 = j2 + (i3 - 1) * l5; this.worldServerInstance.notifyBlocksOfNeighborChange(k3, j3, i4, this.worldServerInstance.getBlock(k3, j3, i4)); } } } return true; } /** * called periodically to remove out-of-date portal locations from the cache list. Argument par1 is a * WorldServer.getTotalWorldTime() value. */ @SuppressWarnings("rawtypes") @Override public void removeStalePortalLocations(long par1) { if (par1 % 100L == 0L) { Iterator iterator = this.destinationCoordinateKeys.iterator(); long j = par1 - 600L; while (iterator.hasNext()) { Long olong = (Long)iterator.next(); PortalPosition portalposition = (PortalPosition)this.destinationCoordinateCache.getValueByKey(olong.longValue()); if (portalposition == null || portalposition.lastUpdateTime < j) { iterator.remove(); this.destinationCoordinateCache.remove(olong.longValue()); } } } } public class PortalPosition extends ChunkCoordinates { /** The worldtime at which this PortalPosition was last verified */ public long lastUpdateTime; public PortalPosition(int par2, int par3, int par4, long par5) { super(par2, par3, par4); this.lastUpdateTime = par5; } } } World Provider Corrupted package mod.mineworld.world.mod_dimension; import mod.mineworld.mod_dimension; import net.minecraft.world.WorldProvider; import net.minecraft.world.WorldProviderEnd; import net.minecraft.world.WorldProviderHell; import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.biome.WorldChunkManagerHell; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.ChunkProviderHell; import net.minecraftforge.common.DimensionManager; public class WorldProviderCorrupted extends WorldProvider { /** * creates a new world chunk manager for WorldProvider */ public void registerWorldChunkManager() { this.worldChunkMgr = new WorldChunkManagerCorrupted(mod_dimension.biomeCorrupted, 1.0F); this.dimensionId = 2; System.out.println("registerWorldChunkManager"); } /** * A message to display to the user when they transfer to this dimension. * * @return The message to be displayed */ @Override public String getWelcomeMessage() { System.out.println("messageIn"); return "Entering the corruption"; } /** * A Message to display to the user when they transfer out of this dismension. * * @return The message to be displayed */ @Override public String getDepartMessage() { System.out.println("messageOut"); return "Leaving the corruption"; } /** * The dimensions movement factor. Relative to normal overworld. * It is applied to the players position when they transfer dimensions. * Exa: Nether movement is 8.0 * @return The movement factor */ @Override public double getMovementFactor() { return 1.0; } /** * Returns a new chunk provider which generates chunks for this world */ public IChunkProvider createChunkGenerator() { return new ChunkProviderCorrupted(this.worldObj, this.worldObj.getSeed(), false); } /** * True if the player can respawn in this dimension */ public boolean canRespawnHere() { return true; } /** * Returns the dimension's name */ public String getDimensionName() { return "Corrupted"; } public static WorldProvider getProviderForDimension(int par0) { return DimensionManager.createProviderFor(par0); } } Thanks in advice for all who will help me
-
[1.7.2] Custom Biome not spawning in custom dimension
JimiIT92 replied to JimiIT92's topic in Modder Support
Anyone? -
Hi everibody! I'm trying to make a new dimension for my mod, but i've noticed that when entering this dimension a custom biome defined for it is not spawning. All i can see is only my custom stone block and my custom water, nothing elese, instead to have a biome with custom grass and dirt Here is all the files i have for the dimension WorldProviderCorrupted: package mod.mineworld.world.mod_dimension; import mod.mineworld.mod_dimension; import net.minecraft.world.WorldProvider; import net.minecraft.world.WorldProviderEnd; import net.minecraft.world.WorldProviderHell; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.ChunkProviderHell; public class WorldProviderCorrupted extends WorldProvider { /** * creates a new world chunk manager for WorldProvider */ public void registerWorldChunkManager() { this.worldChunkMgr = new WorldChunkManagerCorrupted(mod_dimension.biomeCorrupted, 0.0F); this.dimensionId = 2; } /** * A message to display to the user when they transfer to this dimension. * * @return The message to be displayed */ @Override public String getWelcomeMessage() { return "Entering the corruption"; } /** * A Message to display to the user when they transfer out of this dismension. * * @return The message to be displayed */ @Override public String getDepartMessage() { return "Leaving the corruption"; } /** * The dimensions movement factor. Relative to normal overworld. * It is applied to the players position when they transfer dimensions. * Exa: Nether movement is 8.0 * @return The movement factor */ @Override public double getMovementFactor() { return 1.0; } /** * Returns a new chunk provider which generates chunks for this world */ public IChunkProvider createChunkGenerator() { return new ChunkProviderCorrupted(this.worldObj, this.worldObj.getSeed(), false); } /** * True if the player can respawn in this dimension */ public boolean canRespawnHere() { return true; } /** * Returns the dimension's name */ public String getDimensionName() { return "Corrupted"; } } WorldChunkManagerCorrupted: package mod.mineworld.world.mod_dimension; import java.util.Arrays; import java.util.List; import java.util.Random; import net.minecraft.world.ChunkPosition; import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.biome.WorldChunkManager; public class WorldChunkManagerCorrupted extends WorldChunkManager { /** The biome generator object. */ private BiomeGenBase biomeGenerator; /** The rainfall in the world */ private float rainfall; public WorldChunkManagerCorrupted(BiomeGenBase par1, float par2) { this.biomeGenerator = par1; this.rainfall = par2; } /** * Returns the BiomeGenBase related to the x, z position on the world. */ public BiomeGenBase getBiomeGenAt(int par1, int par2) { return this.biomeGenerator; } /** * Returns an array of biomes for the location input. */ public BiomeGenBase[] getBiomesForGeneration(BiomeGenBase[] par1ArrayOfBiomeGenBase, int par2, int par3, int par4, int par5) { if (par1ArrayOfBiomeGenBase == null || par1ArrayOfBiomeGenBase.length < par4 * par5) { par1ArrayOfBiomeGenBase = new BiomeGenBase[par4 * par5]; } Arrays.fill(par1ArrayOfBiomeGenBase, 0, par4 * par5, this.biomeGenerator); return par1ArrayOfBiomeGenBase; } /** * Returns a list of rainfall values for the specified blocks. Args: listToReuse, x, z, width, length. */ public float[] getRainfall(float[] par1ArrayOfFloat, int par2, int par3, int par4, int par5) { if (par1ArrayOfFloat == null || par1ArrayOfFloat.length < par4 * par5) { par1ArrayOfFloat = new float[par4 * par5]; } Arrays.fill(par1ArrayOfFloat, 0, par4 * par5, this.rainfall); return par1ArrayOfFloat; } /** * Returns biomes to use for the blocks and loads the other data like temperature and humidity onto the * WorldChunkManager Args: oldBiomeList, x, z, width, depth */ public BiomeGenBase[] loadBlockGeneratorData(BiomeGenBase[] par1ArrayOfBiomeGenBase, int par2, int par3, int par4, int par5) { if (par1ArrayOfBiomeGenBase == null || par1ArrayOfBiomeGenBase.length < par4 * par5) { par1ArrayOfBiomeGenBase = new BiomeGenBase[par4 * par5]; } Arrays.fill(par1ArrayOfBiomeGenBase, 0, par4 * par5, this.biomeGenerator); return par1ArrayOfBiomeGenBase; } /** * Return a list of biomes for the specified blocks. Args: listToReuse, x, y, width, length, cacheFlag (if false, * don't check biomeCache to avoid infinite loop in BiomeCacheBlock) */ public BiomeGenBase[] getBiomeGenAt(BiomeGenBase[] par1ArrayOfBiomeGenBase, int par2, int par3, int par4, int par5, boolean par6) { return this.loadBlockGeneratorData(par1ArrayOfBiomeGenBase, par2, par3, par4, par5); } public ChunkPosition findBiomePosition(int par1, int par2, int par3, List par4List, Random par5Random) { return par4List.contains(this.biomeGenerator) ? new ChunkPosition(par1 - par3 + par5Random.nextInt(par3 * 2 + 1), 0, par2 - par3 + par5Random.nextInt(par3 * 2 + 1)) : null; } /** * checks given Chunk's Biomes against List of allowed ones */ public boolean areBiomesViable(int par1, int par2, int par3, List par4List) { return par4List.contains(this.biomeGenerator); } } TeleporterCorrupted: package mod.mineworld.world.mod_dimension; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Random; import mod.mineworld.mod_dimension; import net.minecraft.entity.Entity; import net.minecraft.init.Blocks; import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.Direction; import net.minecraft.util.LongHashMap; import net.minecraft.util.MathHelper; import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.Teleporter; import net.minecraft.world.WorldServer; public class TeleporterCorrupted extends Teleporter { private final WorldServer worldServerInstance; /** A private Random() function in Teleporter */ private final Random random; /** Stores successful portal placement locations for rapid lookup. */ private final LongHashMap destinationCoordinateCache = new LongHashMap(); /** * A list of valid keys for the destinationCoordainteCache. These are based on the X & Z of the players initial * location. */ @SuppressWarnings("rawtypes") private final List destinationCoordinateKeys = new ArrayList(); public TeleporterCorrupted(WorldServer par1WorldServer) { super(par1WorldServer); this.worldServerInstance = par1WorldServer; this.random = new Random(par1WorldServer.getSeed()); } /** * Place an entity in a nearby portal, creating one if necessary. */ @Override public void placeInPortal(Entity par1Entity, double par2, double par4, double par6, float par8) { if (this.worldServerInstance.provider.dimensionId != 1) { if (!this.placeInExistingPortal(par1Entity, par2, par4, par6, par8)) { this.makePortal(par1Entity); this.placeInExistingPortal(par1Entity, par2, par4, par6, par8); } } else { int i = MathHelper.floor_double(par1Entity.posX); int j = MathHelper.floor_double(par1Entity.posY) - 1; int k = MathHelper.floor_double(par1Entity.posZ); byte b0 = 1; byte b1 = 0; for (int l = -2; l <= 2; ++l) { for (int i1 = -2; i1 <= 2; ++i1) { for (int j1 = -1; j1 < 3; ++j1) { int k1 = i + i1 * b0 + l * b1; int l1 = j + j1; int i2 = k + i1 * b1 - l * b0; boolean flag = j1 < 0; this.worldServerInstance.setBlock(k1, l1, i2, flag ? Blocks.sandstone : Blocks.air); } } } par1Entity.setLocationAndAngles((double)i, (double)j, (double)k, par1Entity.rotationYaw, 0.0F); par1Entity.motionX = par1Entity.motionY = par1Entity.motionZ = 0.0D; } } /** * Place an entity in a nearby portal which already exists. */ @SuppressWarnings("unchecked") @Override public boolean placeInExistingPortal(Entity par1Entity, double par2, double par4, double par6, float par8) { short short1 = 128; double d3 = -1.0D; int i = 0; int j = 0; int k = 0; int l = MathHelper.floor_double(par1Entity.posX); int i1 = MathHelper.floor_double(par1Entity.posZ); long j1 = ChunkCoordIntPair.chunkXZ2Int(l, i1); boolean flag = true; double d4; int k1; if (this.destinationCoordinateCache.containsItem(j1)) { PortalPosition portalposition = (PortalPosition)this.destinationCoordinateCache.getValueByKey(j1); d3 = 0.0D; i = portalposition.posX; j = portalposition.posY; k = portalposition.posZ; portalposition.lastUpdateTime = this.worldServerInstance.getTotalWorldTime(); flag = false; } else { for (k1 = l - short1; k1 <= l + short1; ++k1) { double d5 = (double)k1 + 0.5D - par1Entity.posX; for (int l1 = i1 - short1; l1 <= i1 + short1; ++l1) { double d6 = (double)l1 + 0.5D - par1Entity.posZ; for (int i2 = this.worldServerInstance.getActualHeight() - 1; i2 >= 0; --i2) { if (this.worldServerInstance.getBlock(k1, i2, l1) == mod_dimension.corrupted_portal) { while (this.worldServerInstance.getBlock(k1, i2 - 1, l1) == mod_dimension.corrupted_portal) { --i2; } d4 = (double)i2 + 0.5D - par1Entity.posY; double d7 = d5 * d5 + d4 * d4 + d6 * d6; if (d3 < 0.0D || d7 < d3) { d3 = d7; i = k1; j = i2; k = l1; } } } } } } if (d3 >= 0.0D) { if (flag) { this.destinationCoordinateCache.add(j1, new PortalPosition(i, j, k, this.worldServerInstance.getTotalWorldTime())); this.destinationCoordinateKeys.add(Long.valueOf(j1)); } double d8 = (double)i + 0.5D; double d9 = (double)j + 0.5D; d4 = (double)k + 0.5D; int j2 = -1; if (this.worldServerInstance.getBlock(i - 1, j, k) == mod_dimension.corrupted_portal) { j2 = 2; } if (this.worldServerInstance.getBlock(i + 1, j, k) == mod_dimension.corrupted_portal) { j2 = 0; } if (this.worldServerInstance.getBlock(i, j, k - 1) == mod_dimension.corrupted_portal) { j2 = 3; } if (this.worldServerInstance.getBlock(i, j, k + 1) == mod_dimension.corrupted_portal) { j2 = 1; } int k2 = par1Entity.getTeleportDirection(); if (j2 > -1) { int l2 = Direction.rotateLeft[j2]; int i3 = Direction.offsetX[j2]; int j3 = Direction.offsetZ[j2]; int k3 = Direction.offsetX[l2]; int l3 = Direction.offsetZ[l2]; boolean flag1 = !this.worldServerInstance.isAirBlock(i + i3 + k3, j, k + j3 + l3) || !this.worldServerInstance.isAirBlock(i + i3 + k3, j + 1, k + j3 + l3); boolean flag2 = !this.worldServerInstance.isAirBlock(i + i3, j, k + j3) || !this.worldServerInstance.isAirBlock(i + i3, j + 1, k + j3); if (flag1 && flag2) { j2 = Direction.rotateOpposite[j2]; l2 = Direction.rotateOpposite[l2]; i3 = Direction.offsetX[j2]; j3 = Direction.offsetZ[j2]; k3 = Direction.offsetX[l2]; l3 = Direction.offsetZ[l2]; k1 = i - k3; d8 -= (double)k3; int i4 = k - l3; d4 -= (double)l3; flag1 = !this.worldServerInstance.isAirBlock(k1 + i3 + k3, j, i4 + j3 + l3) || !this.worldServerInstance.isAirBlock(k1 + i3 + k3, j + 1, i4 + j3 + l3); flag2 = !this.worldServerInstance.isAirBlock(k1 + i3, j, i4 + j3) || !this.worldServerInstance.isAirBlock(k1 + i3, j + 1, i4 + j3); } float f1 = 0.5F; float f2 = 0.5F; if (!flag1 && flag2) { f1 = 1.0F; } else if (flag1 && !flag2) { f1 = 0.0F; } else if (flag1 && flag2) { f2 = 0.0F; } d8 += (double)((float)k3 * f1 + f2 * (float)i3); d4 += (double)((float)l3 * f1 + f2 * (float)j3); float f3 = 0.0F; float f4 = 0.0F; float f5 = 0.0F; float f6 = 0.0F; if (j2 == k2) { f3 = 1.0F; f4 = 1.0F; } else if (j2 == Direction.rotateOpposite[k2]) { f3 = -1.0F; f4 = -1.0F; } else if (j2 == Direction.rotateRight[k2]) { f5 = 1.0F; f6 = -1.0F; } else { f5 = -1.0F; f6 = 1.0F; } double d10 = par1Entity.motionX; double d11 = par1Entity.motionZ; par1Entity.motionX = d10 * (double)f3 + d11 * (double)f6; par1Entity.motionZ = d10 * (double)f5 + d11 * (double)f4; par1Entity.rotationYaw = par8 - (float)(k2 * 90) + (float)(j2 * 90); } else { par1Entity.motionX = par1Entity.motionY = par1Entity.motionZ = 0.0D; } par1Entity.setLocationAndAngles(d8, d9, d4, par1Entity.rotationYaw, par1Entity.rotationPitch); return true; } else { return false; } } @Override public boolean makePortal(Entity par1Entity) { byte b0 = 16; double d0 = -1.0D; int i = MathHelper.floor_double(par1Entity.posX); int j = MathHelper.floor_double(par1Entity.posY); int k = MathHelper.floor_double(par1Entity.posZ); int l = i; int i1 = j; int j1 = k; int k1 = 0; int l1 = this.random.nextInt(4); int i2; double d1; double d2; int j2; int k2; int l2; int i3; int j3; int k3; int l3; int i4; int j4; int k4; double d3; double d4; for (i2 = i - b0; i2 <= i + b0; ++i2) { d1 = (double)i2 + 0.5D - par1Entity.posX; for (j2 = k - b0; j2 <= k + b0; ++j2) { d2 = (double)j2 + 0.5D - par1Entity.posZ; label274: for (k2 = this.worldServerInstance.getActualHeight() - 1; k2 >= 0; --k2) { if (this.worldServerInstance.isAirBlock(i2, k2, j2)) { while (k2 > 0 && this.worldServerInstance.isAirBlock(i2, k2 - 1, j2)) { --k2; } for (i3 = l1; i3 < l1 + 4; ++i3) { l2 = i3 % 2; k3 = 1 - l2; if (i3 % 4 >= 2) { l2 = -l2; k3 = -k3; } for (j3 = 0; j3 < 3; ++j3) { for (i4 = 0; i4 < 4; ++i4) { for (l3 = -1; l3 < 4; ++l3) { k4 = i2 + (i4 - 1) * l2 + j3 * k3; j4 = k2 + l3; int l4 = j2 + (i4 - 1) * k3 - j3 * l2; if (l3 < 0 && !this.worldServerInstance.getBlock(k4, j4, l4).getMaterial().isSolid() || l3 >= 0 && !this.worldServerInstance.isAirBlock(k4, j4, l4)) { continue label274; } } } } d4 = (double)k2 + 0.5D - par1Entity.posY; d3 = d1 * d1 + d4 * d4 + d2 * d2; if (d0 < 0.0D || d3 < d0) { d0 = d3; l = i2; i1 = k2; j1 = j2; k1 = i3 % 4; } } } } } } if (d0 < 0.0D) { for (i2 = i - b0; i2 <= i + b0; ++i2) { d1 = (double)i2 + 0.5D - par1Entity.posX; for (j2 = k - b0; j2 <= k + b0; ++j2) { d2 = (double)j2 + 0.5D - par1Entity.posZ; label222: for (k2 = this.worldServerInstance.getActualHeight() - 1; k2 >= 0; --k2) { if (this.worldServerInstance.isAirBlock(i2, k2, j2)) { while (k2 > 0 && this.worldServerInstance.isAirBlock(i2, k2 - 1, j2)) { --k2; } for (i3 = l1; i3 < l1 + 2; ++i3) { l2 = i3 % 2; k3 = 1 - l2; for (j3 = 0; j3 < 4; ++j3) { for (i4 = -1; i4 < 4; ++i4) { l3 = i2 + (j3 - 1) * l2; k4 = k2 + i4; j4 = j2 + (j3 - 1) * k3; if (i4 < 0 && !this.worldServerInstance.getBlock(l3, k4, j4).getMaterial().isSolid() || i4 >= 0 && !this.worldServerInstance.isAirBlock(l3, k4, j4)) { continue label222; } } } d4 = (double)k2 + 0.5D - par1Entity.posY; d3 = d1 * d1 + d4 * d4 + d2 * d2; if (d0 < 0.0D || d3 < d0) { d0 = d3; l = i2; i1 = k2; j1 = j2; k1 = i3 % 2; } } } } } } } int i5 = l; int j5 = i1; j2 = j1; int k5 = k1 % 2; int l5 = 1 - k5; if (k1 % 4 >= 2) { k5 = -k5; l5 = -l5; } boolean flag; if (d0 < 0.0D) { if (i1 < 70) { i1 = 70; } if (i1 > this.worldServerInstance.getActualHeight() - 10) { i1 = this.worldServerInstance.getActualHeight() - 10; } j5 = i1; for (k2 = -1; k2 <= 1; ++k2) { for (i3 = 1; i3 < 3; ++i3) { for (l2 = -1; l2 < 3; ++l2) { k3 = i5 + (i3 - 1) * k5 + k2 * l5; j3 = j5 + l2; i4 = j2 + (i3 - 1) * l5 - k2 * k5; flag = l2 < 0; this.worldServerInstance.setBlock(k3, j3, i4, flag ? Blocks.sandstone : Blocks.air); } } } } for (k2 = 0; k2 < 4; ++k2) { for (i3 = 0; i3 < 4; ++i3) { for (l2 = -1; l2 < 4; ++l2) { k3 = i5 + (i3 - 1) * k5; j3 = j5 + l2; i4 = j2 + (i3 - 1) * l5; flag = i3 == 0 || i3 == 3 || l2 == -1 || l2 == 3; this.worldServerInstance.setBlock(k3, j3, i4, flag ? Blocks.sandstone : mod_dimension.corrupted_portal, 0, 2); } } for (i3 = 0; i3 < 4; ++i3) { for (l2 = -1; l2 < 4; ++l2) { k3 = i5 + (i3 - 1) * k5; j3 = j5 + l2; i4 = j2 + (i3 - 1) * l5; this.worldServerInstance.notifyBlocksOfNeighborChange(k3, j3, i4, this.worldServerInstance.getBlock(k3, j3, i4)); } } } return true; } /** * called periodically to remove out-of-date portal locations from the cache list. Argument par1 is a * WorldServer.getTotalWorldTime() value. */ @SuppressWarnings("rawtypes") @Override public void removeStalePortalLocations(long par1) { if (par1 % 100L == 0L) { Iterator iterator = this.destinationCoordinateKeys.iterator(); long j = par1 - 600L; while (iterator.hasNext()) { Long olong = (Long)iterator.next(); PortalPosition portalposition = (PortalPosition)this.destinationCoordinateCache.getValueByKey(olong.longValue()); if (portalposition == null || portalposition.lastUpdateTime < j) { iterator.remove(); this.destinationCoordinateCache.remove(olong.longValue()); } } } } public class PortalPosition extends ChunkCoordinates { /** The worldtime at which this PortalPosition was last verified */ public long lastUpdateTime; public PortalPosition(int par2, int par3, int par4, long par5) { super(par2, par3, par4); this.lastUpdateTime = par5; } } } ChunkProviderCorrupted: package mod.mineworld.world.mod_dimension; import static net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.CAVE; import static net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.MINESHAFT; import static net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.RAVINE; import static net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.SCATTERED_FEATURE; import static net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.STRONGHOLD; import static net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.VILLAGE; import static net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.ANIMALS; import static net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.DUNGEON; import static net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.ICE; import static net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.LAKE; import static net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.LAVA; import java.util.List; import java.util.Random; import mod.mineworld.mod_dimension; import net.minecraft.block.Block; import net.minecraft.block.BlockFalling; import net.minecraft.entity.EnumCreatureType; import net.minecraft.init.Blocks; import net.minecraft.util.IProgressUpdate; import net.minecraft.util.MathHelper; import net.minecraft.world.ChunkPosition; import net.minecraft.world.SpawnerAnimals; import net.minecraft.world.World; import net.minecraft.world.WorldType; import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.MapGenBase; import net.minecraft.world.gen.MapGenCaves; import net.minecraft.world.gen.MapGenRavine; import net.minecraft.world.gen.NoiseGenerator; import net.minecraft.world.gen.NoiseGeneratorOctaves; import net.minecraft.world.gen.NoiseGeneratorPerlin; import net.minecraft.world.gen.feature.WorldGenDungeons; import net.minecraft.world.gen.feature.WorldGenLakes; import net.minecraft.world.gen.structure.MapGenMineshaft; import net.minecraft.world.gen.structure.MapGenScatteredFeature; import net.minecraft.world.gen.structure.MapGenStronghold; import net.minecraft.world.gen.structure.MapGenVillage; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.terraingen.ChunkProviderEvent; import net.minecraftforge.event.terraingen.PopulateChunkEvent; import net.minecraftforge.event.terraingen.TerrainGen; import cpw.mods.fml.common.eventhandler.Event.Result; public class ChunkProviderCorrupted implements IChunkProvider { /** RNG. */ private Random rand; private NoiseGeneratorOctaves noiseGeneratorOctaves1; private NoiseGeneratorOctaves noiseGeneratorOctaves2; private NoiseGeneratorOctaves noiseGeneratorOctaves3; private NoiseGeneratorPerlin noiseGeneratorPerlin; /** A NoiseGeneratorOctaves used in generating terrain */ public NoiseGeneratorOctaves noiseGen5; /** A NoiseGeneratorOctaves used in generating terrain */ public NoiseGeneratorOctaves noiseGen6; public NoiseGeneratorOctaves mobSpawnerNoise; /** Reference to the World object. */ private World worldObj; /** are map structures going to be generated (e.g. strongholds) */ private final boolean mapFeaturesEnabled; private WorldType world_type; private final double[] field_147434_q; private final float[] parabolicField; private double[] stoneNoise = new double[256]; private MapGenBase caveGenerator = new MapGenCaves(); /** Holds Stronghold Generator */ private MapGenStronghold strongholdGenerator = new MapGenStronghold(); /** Holds Village Generator */ private MapGenVillage villageGenerator = new MapGenVillage(); /** Holds Mineshaft Generator */ private MapGenMineshaft mineshaftGenerator = new MapGenMineshaft(); private MapGenScatteredFeature scatteredFeatureGenerator = new MapGenScatteredFeature(); /** Holds ravine generator */ private MapGenBase ravineGenerator = new MapGenRavine(); /** The biomes that are used to generate the chunk */ private BiomeGenBase[] biomesForGeneration; double[] field_147427_d; double[] field_147428_e; double[] field_147425_f; double[] field_147426_g; int[][] field_73219_j = new int[32][32]; { caveGenerator = TerrainGen.getModdedMapGen(caveGenerator, CAVE); strongholdGenerator = (MapGenStronghold) TerrainGen.getModdedMapGen(strongholdGenerator, STRONGHOLD); villageGenerator = (MapGenVillage) TerrainGen.getModdedMapGen(villageGenerator, VILLAGE); mineshaftGenerator = (MapGenMineshaft) TerrainGen.getModdedMapGen(mineshaftGenerator, MINESHAFT); scatteredFeatureGenerator = (MapGenScatteredFeature) TerrainGen.getModdedMapGen(scatteredFeatureGenerator, SCATTERED_FEATURE); ravineGenerator = TerrainGen.getModdedMapGen(ravineGenerator, RAVINE); } public ChunkProviderCorrupted(World par1World, long par2, boolean par4) { this.worldObj = par1World; this.mapFeaturesEnabled = par4; this.world_type = par1World.getWorldInfo().getTerrainType(); this.rand = new Random(par2); this.noiseGeneratorOctaves1 = new NoiseGeneratorOctaves(this.rand, 16); this.noiseGeneratorOctaves2 = new NoiseGeneratorOctaves(this.rand, 16); this.noiseGeneratorOctaves3 = new NoiseGeneratorOctaves(this.rand, ; this.noiseGeneratorPerlin = new NoiseGeneratorPerlin(this.rand, 4); this.noiseGen5 = new NoiseGeneratorOctaves(this.rand, 10); this.noiseGen6 = new NoiseGeneratorOctaves(this.rand, 16); this.mobSpawnerNoise = new NoiseGeneratorOctaves(this.rand, ; this.field_147434_q = new double[825]; this.parabolicField = new float[25]; for (int j = -2; j <= 2; ++j) { for (int k = -2; k <= 2; ++k) { float f = 10.0F / MathHelper.sqrt_float((float)(j * j + k * k) + 0.2F); this.parabolicField[j + 2 + (k + 2) * 5] = f; } } NoiseGenerator[] noiseGens = {noiseGeneratorOctaves1, noiseGeneratorOctaves2, noiseGeneratorOctaves3, noiseGeneratorPerlin, noiseGen5, noiseGen6, mobSpawnerNoise}; noiseGens = TerrainGen.getModdedNoiseGenerators(par1World, this.rand, noiseGens); this.noiseGeneratorOctaves1 = (NoiseGeneratorOctaves)noiseGens[0]; this.noiseGeneratorOctaves2 = (NoiseGeneratorOctaves)noiseGens[1]; this.noiseGeneratorOctaves3 = (NoiseGeneratorOctaves)noiseGens[2]; this.noiseGeneratorPerlin = (NoiseGeneratorPerlin)noiseGens[3]; this.noiseGen5 = (NoiseGeneratorOctaves)noiseGens[4]; this.noiseGen6 = (NoiseGeneratorOctaves)noiseGens[5]; this.mobSpawnerNoise = (NoiseGeneratorOctaves)noiseGens[6]; } public void func_147424_a(int par1, int par2, Block[] par3BlockArray) { byte b0 = 63; this.biomesForGeneration = this.worldObj.getWorldChunkManager().getBiomesForGeneration(this.biomesForGeneration, par1 * 4 - 2, par2 * 4 - 2, 10, 10); this.func_147423_a(par1 * 4, 0, par2 * 4); for (int k = 0; k < 4; ++k) { int l = k * 5; int i1 = (k + 1) * 5; for (int j1 = 0; j1 < 4; ++j1) { int k1 = (l + j1) * 33; int l1 = (l + j1 + 1) * 33; int i2 = (i1 + j1) * 33; int j2 = (i1 + j1 + 1) * 33; for (int k2 = 0; k2 < 32; ++k2) { double d0 = 0.125D; double d1 = this.field_147434_q[k1 + k2]; double d2 = this.field_147434_q[l1 + k2]; double d3 = this.field_147434_q[i2 + k2]; double d4 = this.field_147434_q[j2 + k2]; double d5 = (this.field_147434_q[k1 + k2 + 1] - d1) * d0; double d6 = (this.field_147434_q[l1 + k2 + 1] - d2) * d0; double d7 = (this.field_147434_q[i2 + k2 + 1] - d3) * d0; double d8 = (this.field_147434_q[j2 + k2 + 1] - d4) * d0; for (int l2 = 0; l2 < 8; ++l2) { double d9 = 0.25D; double d10 = d1; double d11 = d2; double d12 = (d3 - d1) * d9; double d13 = (d4 - d2) * d9; for (int i3 = 0; i3 < 4; ++i3) { int j3 = i3 + k * 4 << 12 | 0 + j1 * 4 << 8 | k2 * 8 + l2; short short1 = 256; j3 -= short1; double d14 = 0.25D; double d16 = (d11 - d10) * d14; double d15 = d10 - d16; for (int k3 = 0; k3 < 4; ++k3) { if ((d15 += d16) > 0.0D) { par3BlockArray[j3 += short1] = mod_dimension.corrupted_stone; } else if (k2 * 8 + l2 < b0) { par3BlockArray[j3 += short1] = mod_dimension.corrupted_water; } else { par3BlockArray[j3 += short1] = null; } } d10 += d12; d11 += d13; } d1 += d5; d2 += d6; d3 += d7; d4 += d8; } } } } } public void replaceBlocksForBiome(int par1, int par2, Block[] par3BlockArray, byte[] par4ByteArray, BiomeGenBase[] par5BiomeGenBaseArray) { ChunkProviderEvent.ReplaceBiomeBlocks event = new ChunkProviderEvent.ReplaceBiomeBlocks(this, par1, par2, par3BlockArray, par4ByteArray, par5BiomeGenBaseArray); MinecraftForge.EVENT_BUS.post(event); if (event.getResult() == Result.DENY) return; double d0 = 0.03125D; this.stoneNoise = this.noiseGeneratorPerlin.func_151599_a(this.stoneNoise, (double)(par1 * 16), (double)(par2 * 16), 16, 16, d0 * 2.0D, d0 * 2.0D, 1.0D); for (int k = 0; k < 16; ++k) { for (int l = 0; l < 16; ++l) { BiomeGenBase biomegenbase = par5BiomeGenBaseArray[l + k * 16]; biomegenbase.genTerrainBlocks(this.worldObj, this.rand, par3BlockArray, par4ByteArray, par1 * 16 + k, par2 * 16 + l, this.stoneNoise[l + k * 16]); } } } /** * loads or generates the chunk at the chunk location specified */ public Chunk loadChunk(int par1, int par2) { return this.provideChunk(par1, par2); } /** * Will return back a chunk, if it doesn't exist and its not a MP client it will generates all the blocks for the * specified chunk from the map seed and chunk seed */ public Chunk provideChunk(int par1, int par2) { this.rand.setSeed((long)par1 * 341873128712L + (long)par2 * 132897987541L); Block[] ablock = new Block[65536]; byte[] abyte = new byte[65536]; this.func_147424_a(par1, par2, ablock); this.biomesForGeneration = this.worldObj.getWorldChunkManager().loadBlockGeneratorData(this.biomesForGeneration, par1 * 16, par2 * 16, 16, 16); this.replaceBlocksForBiome(par1, par2, ablock, abyte, this.biomesForGeneration); this.caveGenerator.func_151539_a(this, this.worldObj, par1, par2, ablock); this.ravineGenerator.func_151539_a(this, this.worldObj, par1, par2, ablock); if (this.mapFeaturesEnabled) { this.mineshaftGenerator.func_151539_a(this, this.worldObj, par1, par2, ablock); this.villageGenerator.func_151539_a(this, this.worldObj, par1, par2, ablock); this.strongholdGenerator.func_151539_a(this, this.worldObj, par1, par2, ablock); this.scatteredFeatureGenerator.func_151539_a(this, this.worldObj, par1, par2, ablock); } Chunk chunk = new Chunk(this.worldObj, ablock, abyte, par1, par2); byte[] abyte1 = chunk.getBiomeArray(); for (int k = 0; k < abyte1.length; ++k) { abyte1[k] = (byte)this.biomesForGeneration[k].biomeID; } chunk.generateSkylightMap(); return chunk; } private void func_147423_a(int par1, int par2, int par3) { double d0 = 684.412D; double d1 = 684.412D; double d2 = 512.0D; double d3 = 512.0D; this.field_147426_g = this.noiseGen6.generateNoiseOctaves(this.field_147426_g, par1, par3, 5, 5, 200.0D, 200.0D, 0.5D); this.field_147427_d = this.noiseGeneratorOctaves3.generateNoiseOctaves(this.field_147427_d, par1, par2, par3, 5, 33, 5, 8.555150000000001D, 4.277575000000001D, 8.555150000000001D); this.field_147428_e = this.noiseGeneratorOctaves1.generateNoiseOctaves(this.field_147428_e, par1, par2, par3, 5, 33, 5, 684.412D, 684.412D, 684.412D); this.field_147425_f = this.noiseGeneratorOctaves2.generateNoiseOctaves(this.field_147425_f, par1, par2, par3, 5, 33, 5, 684.412D, 684.412D, 684.412D); boolean flag1 = false; boolean flag = false; int l = 0; int i1 = 0; double d4 = 8.5D; for (int j1 = 0; j1 < 5; ++j1) { for (int k1 = 0; k1 < 5; ++k1) { float f = 0.0F; float f1 = 0.0F; float f2 = 0.0F; byte b0 = 2; BiomeGenBase biomegenbase = this.biomesForGeneration[j1 + 2 + (k1 + 2) * 10]; for (int l1 = -b0; l1 <= b0; ++l1) { for (int i2 = -b0; i2 <= b0; ++i2) { BiomeGenBase biomegenbase1 = this.biomesForGeneration[j1 + l1 + 2 + (k1 + i2 + 2) * 10]; float f3 = biomegenbase1.rootHeight; float f4 = biomegenbase1.heightVariation; if (this.world_type == WorldType.AMPLIFIED && f3 > 0.0F) { f3 = 1.0F + f3 * 2.0F; f4 = 1.0F + f4 * 4.0F; } float f5 = this.parabolicField[l1 + 2 + (i2 + 2) * 5] / (f3 + 2.0F); if (biomegenbase1.rootHeight > biomegenbase.rootHeight) { f5 /= 2.0F; } f += f4 * f5; f1 += f3 * f5; f2 += f5; } } f /= f2; f1 /= f2; f = f * 0.9F + 0.1F; f1 = (f1 * 4.0F - 1.0F) / 8.0F; double d12 = this.field_147426_g[i1] / 8000.0D; if (d12 < 0.0D) { d12 = -d12 * 0.3D; } d12 = d12 * 3.0D - 2.0D; if (d12 < 0.0D) { d12 /= 2.0D; if (d12 < -1.0D) { d12 = -1.0D; } d12 /= 1.4D; d12 /= 2.0D; } else { if (d12 > 1.0D) { d12 = 1.0D; } d12 /= 8.0D; } ++i1; double d13 = (double)f1; double d14 = (double)f; d13 += d12 * 0.2D; d13 = d13 * 8.5D / 8.0D; double d5 = 8.5D + d13 * 4.0D; for (int j2 = 0; j2 < 33; ++j2) { double d6 = ((double)j2 - d5) * 12.0D * 128.0D / 256.0D / d14; if (d6 < 0.0D) { d6 *= 4.0D; } double d7 = this.field_147428_e[l] / 512.0D; double d8 = this.field_147425_f[l] / 512.0D; double d9 = (this.field_147427_d[l] / 10.0D + 1.0D) / 2.0D; double d10 = MathHelper.denormalizeClamp(d7, d8, d9) - d6; if (j2 > 29) { double d11 = (double)((float)(j2 - 29) / 3.0F); d10 = d10 * (1.0D - d11) + -10.0D * d11; } this.field_147434_q[l] = d10; ++l; } } } } /** * Checks to see if a chunk exists at x, y */ public boolean chunkExists(int par1, int par2) { return true; } /** * Populates chunk with ores etc etc */ public void populate(IChunkProvider par1IChunkProvider, int par2, int par3) { BlockFalling.fallInstantly = true; int k = par2 * 16; int l = par3 * 16; BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(k + 16, l + 16); this.rand.setSeed(this.worldObj.getSeed()); long i1 = this.rand.nextLong() / 2L * 2L + 1L; long j1 = this.rand.nextLong() / 2L * 2L + 1L; this.rand.setSeed((long)par2 * i1 + (long)par3 * j1 ^ this.worldObj.getSeed()); boolean flag = false; MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Pre(par1IChunkProvider, worldObj, rand, par2, par3, flag)); if (this.mapFeaturesEnabled) { this.mineshaftGenerator.generateStructuresInChunk(this.worldObj, this.rand, par2, par3); flag = this.villageGenerator.generateStructuresInChunk(this.worldObj, this.rand, par2, par3); this.strongholdGenerator.generateStructuresInChunk(this.worldObj, this.rand, par2, par3); this.scatteredFeatureGenerator.generateStructuresInChunk(this.worldObj, this.rand, par2, par3); } int k1; int l1; int i2; if (biomegenbase != BiomeGenBase.desert && biomegenbase != BiomeGenBase.desertHills && !flag && this.rand.nextInt(4) == 0 && TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, flag, LAKE)) { k1 = k + this.rand.nextInt(16) + 8; l1 = this.rand.nextInt(256); i2 = l + this.rand.nextInt(16) + 8; (new WorldGenLakes(mod_dimension.corrupted_water)).generate(this.worldObj, this.rand, k1, l1, i2); } if (TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, flag, LAVA) && !flag && this.rand.nextInt( == 0) { k1 = k + this.rand.nextInt(16) + 8; l1 = this.rand.nextInt(this.rand.nextInt(248) + ; i2 = l + this.rand.nextInt(16) + 8; if (l1 < 63 || this.rand.nextInt(10) == 0) { (new WorldGenLakes(Blocks.lava)).generate(this.worldObj, this.rand, k1, l1, i2); } } boolean doGen = TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, flag, DUNGEON); for (k1 = 0; doGen && k1 < 8; ++k1) { l1 = k + this.rand.nextInt(16) + 8; i2 = this.rand.nextInt(256); int j2 = l + this.rand.nextInt(16) + 8; (new WorldGenDungeons()).generate(this.worldObj, this.rand, l1, i2, j2); } biomegenbase.decorate(this.worldObj, this.rand, k, l); if (TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, flag, ANIMALS)) { SpawnerAnimals.performWorldGenSpawning(this.worldObj, biomegenbase, k + 8, l + 8, 16, 16, this.rand); } k += 8; l += 8; doGen = TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, flag, ICE); for (k1 = 0; doGen && k1 < 16; ++k1) { for (l1 = 0; l1 < 16; ++l1) { i2 = this.worldObj.getPrecipitationHeight(k + k1, l + l1); if (this.worldObj.isBlockFreezable(k1 + k, i2 - 1, l1 + l)) { this.worldObj.setBlock(k1 + k, i2 - 1, l1 + l, Blocks.ice, 0, 2); } if (this.worldObj.func_147478_e(k1 + k, i2, l1 + l, true)) { this.worldObj.setBlock(k1 + k, i2, l1 + l, Blocks.snow_layer, 0, 2); } } } MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Post(par1IChunkProvider, worldObj, rand, par2, par3, flag)); BlockFalling.fallInstantly = false; } /** * Two modes of operation: if passed true, save all Chunks in one go. If passed false, save up to two chunks. * Return true if all chunks have been saved. */ public boolean saveChunks(boolean par1, IProgressUpdate par2IProgressUpdate) { return true; } /** * Save extra data not associated with any Chunk. Not saved during autosave, only during world unload. Currently * unimplemented. */ public void saveExtraData() {} /** * Unloads chunks that are marked to be unloaded. This is not guaranteed to unload every such chunk. */ public boolean unloadQueuedChunks() { return false; } /** * Returns if the IChunkProvider supports saving. */ public boolean canSave() { return true; } /** * Converts the instance data to a readable string. */ public String makeString() { return "RandomLevelSourceCorrupted"; } /** * Returns a list of creatures of the specified type that can spawn at the given location. */ public List getPossibleCreatures(EnumCreatureType par1EnumCreatureType, int par2, int par3, int par4) { BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(par2, par4); return par1EnumCreatureType == EnumCreatureType.monster && this.scatteredFeatureGenerator.func_143030_a(par2, par3, par4) ? this.scatteredFeatureGenerator.getScatteredFeatureSpawnList() : biomegenbase.getSpawnableList(par1EnumCreatureType); } public ChunkPosition func_147416_a(World par1, String par2String, int par3, int par4, int par5) { return "Stronghold".equals(par2String) && this.strongholdGenerator != null ? this.strongholdGenerator.func_151545_a(par1, par3, par4, par5) : null; } public int getLoadedChunkCount() { return 0; } public void recreateStructures(int par1, int par2) { if (this.mapFeaturesEnabled) { this.mineshaftGenerator.func_151539_a(this, this.worldObj, par1, par2, (Block[])null); this.villageGenerator.func_151539_a(this, this.worldObj, par1, par2, (Block[])null); this.strongholdGenerator.func_151539_a(this, this.worldObj, par1, par2, (Block[])null); this.scatteredFeatureGenerator.func_151539_a(this, this.worldObj, par1, par2, (Block[])null); } } } BiomeGenCorrupted: package mod.mineworld.world.mod_dimension; import java.util.Random; import mod.mineworld.mod_dimension; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.gen.feature.WorldGenerator; public class BiomeGenCorrupted extends BiomeGenBase { private WorldGenerator UnDeadworldGeneratorBigTree; public final Material blockMaterial; public BiomeGenCorrupted(int par1) { super(par1); this.blockMaterial = Material.water; this.setHeight(BiomeGenBase.height_MidHills); this.spawnableMonsterList.clear(); this.spawnableCreatureList.clear(); this.topBlock = mod_dimension.corrupted_grass; this.fillerBlock = mod_dimension.corrupted_stone; } @Override public void genTerrainBlocks(World world, Random random, Block[] blocks, byte[] bytes, int int1, int int2, double d) { boolean flag = true; Block block = this.topBlock; byte b0 = (byte)(this.field_150604_aj & 255); Block block1 = this.fillerBlock; int k = -1; int l = (int)(d / 3.0D + 3.0D + random.nextDouble() * 0.25D); int i1 = int1 & 15; int j1 = int2 & 15; int k1 = blocks.length / 256; for (int l1 = 255; l1 >= 0; --l1) { int i2 = (j1 * 16 + i1) * k1 + l1; if (l1 <= 0 + random.nextInt(5)) { blocks[i2] = Blocks.bedrock; } else { Block block2 = blocks[i2]; if (block2 != null && block2.getMaterial() != Material.air) { if (block2 == mod_dimension.corrupted_grass) { if (k == -1) { if (l <= 0) { block = null; b0 = 0; block1 = mod_dimension.corrupted_grass; } else if (l1 >= 59 && l1 <= 64) { block = this.topBlock; b0 = (byte)(this.field_150604_aj & 255); block1 = this.fillerBlock; } if (l1 < 63 && (block == null || block.getMaterial() == Material.air)) { if (this.getFloatTemperature(int1, l1, int2) < 0.15F) { block = Blocks.ice; b0 = 0; } else { block = mod_dimension.corrupted_water; b0 = 0; } } k = l; if (l1 >= 62) { blocks[i2] = block; bytes[i2] = b0; } else if (l1 < 56 - l) { block = null; block1 = mod_dimension.corrupted_grass; blocks[i2] = Blocks.gravel; } else { blocks[i2] = block1; } } else if (k > 0) { --k; blocks[i2] = block1; if (k == 0 && block1 == Blocks.sand) { k = random.nextInt(4) + Math.max(0, l1 - 63); block1 = Blocks.sandstone; } } } } else { k = -1; } } } } } BlockCorruptedPortal: package mod.mineworld.blocks.mod_dimension; import mod.mineworld.mod_dimension; import mod.mineworld.mod_tabs; import mod.mineworld.world.mod_dimension.TeleporterCorrupted; import net.minecraft.block.Block; import net.minecraft.block.BlockPortal; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Blocks; import net.minecraft.server.MinecraftServer; import net.minecraft.world.World; public class BlockCorruptedPortal extends BlockPortal { public BlockCorruptedPortal() { super(); } @Override public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity) { if ((par5Entity.ridingEntity == null) && (par5Entity.riddenByEntity == null) && ((par5Entity instanceof EntityPlayerMP))) { EntityPlayerMP player = (EntityPlayerMP) par5Entity; MinecraftServer mServer = MinecraftServer.getServer(); if (player.timeUntilPortal > 0) { player.timeUntilPortal = 10; } else if (player.dimension != 2) { player.timeUntilPortal = 10; player.mcServer.getConfigurationManager().transferPlayerToDimension(player, 2, new TeleporterCorrupted(mServer.worldServerForDimension(2))); } else { player.timeUntilPortal = 10; player.mcServer.getConfigurationManager().transferPlayerToDimension(player, 0, new TeleporterCorrupted(mServer.worldServerForDimension(1))); } } } public boolean func_150000_e(World par1World, int par2, int par3, int par4) { byte b0 = 0; byte b1 = 0; if (par1World.getBlock(par2 - 1, par3, par4) == Blocks.sandstone || par1World.getBlock(par2 + 1, par3, par4) == Blocks.sandstone) { b0 = 1; } if (par1World.getBlock(par2, par3, par4 - 1) == Blocks.sandstone || par1World.getBlock(par2, par3, par4 + 1) == Blocks.sandstone) { b1 = 1; } if (b0 == b1) { return false; } else { if (par1World.isAirBlock(par2 - b0, par3, par4 - b1)) { par2 -= b0; par4 -= b1; } int l; int i1; for (l = -1; l <= 2; ++l) { for (i1 = -1; i1 <= 3; ++i1) { boolean flag = l == -1 || l == 2 || i1 == -1 || i1 == 3; if (l != -1 && l != 2 || i1 != -1 && i1 != 3) { Block j1 = par1World.getBlock(par2 + b0 * l, par3 + i1, par4 + b1 * l); boolean isAirBlock = par1World.isAirBlock(par2 + b0 * l, par3 + i1, par4 + b1 * l); if (flag) { if (j1 != Blocks.sandstone) { return false; } } else if (!isAirBlock && j1 != Blocks.fire) { return false; } } } } for (l = 0; l < 2; ++l) { for (i1 = 0; i1 < 3; ++i1) { par1World.setBlock(par2 + b0 * l, par3 + i1, par4 + b1 * l, mod_dimension.corrupted_portal, 0, 2); } } return true; } } @Override public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, Block par5) { byte b0 = 0; byte b1 = 1; if (par1World.getBlock(par2 - 1, par3, par4) == this || par1World.getBlock(par2 + 1, par3, par4) == this) { b0 = 1; b1 = 0; } int i1; for (i1 = par3; par1World.getBlock(par2, i1 - 1, par4) == this; --i1) { ; } if (par1World.getBlock(par2, i1 - 1, par4) != Blocks.sandstone) { par1World.setBlockToAir(par2, par3, par4); } else { int j1; for (j1 = 1; j1 < 4 && par1World.getBlock(par2, i1 + j1, par4) == this; ++j1) { ; } if (j1 == 3 && par1World.getBlock(par2, i1 + j1, par4) == Blocks.sandstone) { boolean flag = par1World.getBlock(par2 - 1, par3, par4) == this || par1World.getBlock(par2 + 1, par3, par4) == this; boolean flag1 = par1World.getBlock(par2, par3, par4 - 1) == this || par1World.getBlock(par2, par3, par4 + 1) == this; if (flag && flag1) { par1World.setBlockToAir(par2, par3, par4); } else { if ((par1World.getBlock(par2 + b0, par3, par4 + b1) != Blocks.sandstone || par1World.getBlock(par2 - b0, par3, par4 - b1) != this) && (par1World.getBlock(par2 - b0, par3, par4 - b1) != Blocks.sandstone || par1World.getBlock(par2 + b0, par3, par4 + b1) != this)) { par1World.setBlockToAir(par2, par3, par4); } } } else { par1World.setBlockToAir(par2, par3, par4); } } } public void registerBlockIcons(IIconRegister par1) { this.blockIcon = par1.registerIcon(this.getTextureName()); } } BlockCorruptedGrass: package mod.mineworld.blocks.mod_dimension; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import java.util.Random; import mod.mineworld.mod_dimension; import mod.mineworld.mod_tabs; import net.minecraft.block.Block; import net.minecraft.block.BlockGrass; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.util.IIcon; import net.minecraft.world.ColorizerGrass; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; public class BlockCorruptedGrass extends BlockGrass { private static final Logger logger = LogManager.getLogger(); @SideOnly(Side.CLIENT) private IIcon icon_top; @SideOnly(Side.CLIENT) private IIcon icon_snowy; @SideOnly(Side.CLIENT) public BlockCorruptedGrass() { super(); this.setTickRandomly(true); this.setCreativeTab(mod_tabs.tabDimensionBlocks); } /** * Gets the block's texture. Args: side, meta */ @SideOnly(Side.CLIENT) public IIcon getIcon(int par1, int par2) { return par1 == 1 ? this.icon_top : (par1 == 0 ? Blocks.dirt.getBlockTextureFromSide(par1) : this.blockIcon); } /** * Ticks the block if it's been scheduled */ public void updateTick(World par1World, int par2, int par3, int par4, Random par5) { if (!par1World.isRemote) { if (par1World.getBlockLightValue(par2, par3 + 1, par4) < 4 && par1World.getBlockLightOpacity(par2, par3 + 1, par4) > 2) { par1World.setBlock(par2, par3, par4, mod_dimension.corrupted_dirt); } else if (par1World.getBlockLightValue(par2, par3 + 1, par4) >= 9) { for (int l = 0; l < 4; ++l) { int i1 = par2 + par5.nextInt(3) - 1; int j1 = par3 + par5.nextInt(5) - 3; int k1 = par4 + par5.nextInt(3) - 1; Block block = par1World.getBlock(i1, j1 + 1, k1); if (par1World.getBlock(i1, j1, k1) == mod_dimension.corrupted_dirt && par1World.getBlockMetadata(i1, j1, k1) == 0 && par1World.getBlockLightValue(i1, j1 + 1, k1) >= 4 && par1World.getBlockLightOpacity(i1, j1 + 1, k1) <= 2) { par1World.setBlock(i1, j1, k1, mod_dimension.corrupted_grass); } } } } } public Item getItemDropped(int par1, Random par2Random, int par3) { return Item.getItemFromBlock(mod_dimension.corrupted_dirt); } @SideOnly(Side.CLIENT) public IIcon getIcon(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) { if (par5 == 1) { return this.icon_top; } else if (par5 == 0) { return mod_dimension.corrupted_dirt.getBlockTextureFromSide(par5); } else { Material material = par1IBlockAccess.getBlock(par2, par3 + 1, par4).getMaterial(); return material != Material.snow && material != Material.craftedSnow ? this.blockIcon : this.icon_snowy; } } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister par1IconRegister) { this.blockIcon = par1IconRegister.registerIcon(this.getTextureName() + "_side"); this.icon_top = par1IconRegister.registerIcon(this.getTextureName() + "_top"); } } BlockCorruptedStone: package mod.mineworld.blocks.mod_dimension; import java.util.Random; import mod.mineworld.mod_dimension; import mod.mineworld.mod_tabs; import net.minecraft.block.BlockStone; import net.minecraft.block.material.Material; import net.minecraft.item.Item; public class BlockCorruptedStone extends BlockStone { public BlockCorruptedStone() { super(); this.setCreativeTab(mod_tabs.tabDimensionBlocks); } public Item getItemDropped(int par1, Random par2Random, int par3) { return Item.getItemFromBlock(mod_dimension.corrupted_cobblestone); } } BlockCorruptedWater: package mod.mineworld.blocks.mod_dimension; import mod.mineworld.MineWorld; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fluids.BlockFluidClassic; import net.minecraftforge.fluids.Fluid; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class BlockCorruptedWater extends BlockFluidClassic { @SideOnly(Side.CLIENT) protected IIcon stillIcon; @SideOnly(Side.CLIENT) protected IIcon flowingIcon; public BlockCorruptedWater(Fluid fluid, Material material) { super(fluid, material); } @Override public IIcon getIcon(int side, int meta) { return (side == 0 || side == 1)? stillIcon : flowingIcon; } @SideOnly(Side.CLIENT) @Override public void registerBlockIcons(IIconRegister register) { stillIcon = register.registerIcon(MineWorld.MODID + ":mod_dimension/" + "corrupted_water_still"); flowingIcon = register.registerIcon(MineWorld.MODID + ":mod_dimension/" + "corrupted_water_flow"); } @Override public boolean canDisplace(IBlockAccess world, int x, int y, int z) { if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false; return super.canDisplace(world, x, y, z); } @Override public boolean displaceIfPossible(World world, int x, int y, int z) { if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false; return super.displaceIfPossible(world, x, y, z); } } BlockDimension: package mod.mineworld.blocks.mod_dimension; import mod.mineworld.mod_tabs; import net.minecraft.block.Block; import net.minecraft.block.material.Material; public class BlockDimension extends Block{ public BlockDimension(Material par1) { super(par1); this.setCreativeTab(mod_tabs.tabDimensionBlocks); } } And in the main sub-mod file: Declarations public static Block corrupted_grass; public static Block corrupted_dirt; public static Block corrupted_stone; public static Block corrupted_cobblestone; public static Block corrupted_water; public static Block corrupted_portal; public static BiomeGenBase biomeCorrupted; public static Fluid corrupted_fluid = new Fluid("corrupted_fluid"); And inside the preInit method corrupted_grass=new BlockCorruptedGrass().setBlockName("corrupted_grass").setHardness(0.6F).setStepSound(Block.soundTypeGrass).setBlockTextureName(MineWorld.MODID + ":mod_dimension/" + "corrupted_grass"); corrupted_dirt=new BlockDimension(Material.ground).setHardness(0.5F).setStepSound(Block.soundTypeGravel).setBlockName("corrupted_dirt").setBlockTextureName(MineWorld.MODID + ":mod_dimension/" + "corrupted_dirt"); corrupted_stone=new BlockCorruptedStone().setHardness(1.5F).setResistance(10.0F).setStepSound(Block.soundTypePiston).setBlockName("corrupted_stone").setBlockTextureName(MineWorld.MODID + ":mod_dimension/" + "corrupted_stone"); corrupted_cobblestone = new BlockDimension(Material.rock).setHardness(2.0F).setResistance(10.0F).setStepSound(Block.soundTypePiston).setBlockName("corrupted_cobblestone").setBlockTextureName(MineWorld.MODID + ":mod_dimension/" + "corrupted_cobblestone"); corrupted_portal = (new BlockCorruptedPortal()).setHardness(-1.0F).setStepSound(Block.soundTypeGlass).setLightLevel(0.75F).setBlockName("corrupted_portal").setBlockTextureName(MineWorld.MODID + ":mod_dimension/" + "corrupted_portal"); biomeCorrupted = new BiomeGenCorrupted(160).setBiomeName("Corrupted Plains"); GameRegistry.registerBlock(corrupted_grass, "corrupted_grass"); GameRegistry.registerBlock(corrupted_dirt, "corrupted_dirt"); GameRegistry.registerBlock(corrupted_stone, "corrupted_stone"); GameRegistry.registerBlock(corrupted_cobblestone, "corrupted_cobblestone"); FluidRegistry.registerFluid(corrupted_fluid); corrupted_water = new BlockCorruptedWater(corrupted_fluid, Material.water).setBlockName("corrupted_water"); GameRegistry.registerBlock(corrupted_water, "corrupted_water"); GameRegistry.registerBlock(corrupted_portal, "corrupted_portal"); BiomeDictionary.registerBiomeType(biomeCorrupted, Type.FOREST, Type.MOUNTAIN); DimensionManager.registerProviderType(3, WorldProviderCorrupted.class, false); DimensionManager.registerDimension(2, 3); Thanks in advice for all who will support me
-
[SOLVED] [1.7.2] Can't place redstone on top of custom slab
JimiIT92 replied to JimiIT92's topic in Modder Support
I've done this classes many times ago, when i don't know anything, so i just copy&paste classes. I know is an error, but for the moment i think to solve this bug and them (when i will update to 1.7.10) i will clear many lines of code -
[SOLVED] [1.7.2] Can't place redstone on top of custom slab
JimiIT92 replied to JimiIT92's topic in Modder Support
Solved: i've overrided the method isSideSolid in my BlockOreSlab class For all to know, Minecraft use this method in the Block class: public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { int meta = world.getBlockMetadata(x, y, z); if (this instanceof BlockSlab) { return (((meta & == 8 && (side == UP)) || func_149730_j()); } else if (this instanceof BlockFarmland) { return (side != DOWN && side != UP); } else if (this instanceof BlockStairs) { boolean flipped = ((meta & 4) != 0); return ((meta & 3) + side.ordinal() == 5) || (side == UP && flipped); } else if (this instanceof BlockSnow) { return (meta & 7) == 7; } else if (this instanceof BlockHopper && side == UP) { return true; } else if (this instanceof BlockCompressedPowered) { return true; } return isNormalCube(world, x, y, z); } as you can see the first lines are for the slabs, so it is how it works Thanks for helped me -
[SOLVED] [1.7.2] Can't place redstone on top of custom slab
JimiIT92 replied to JimiIT92's topic in Modder Support
I think i was misunderstaned I know that you can't place redstone on slabs, but if they ure upside down you can. Here is an image to explain what i'm saying: As you can see i can place redstone on the top side of Stone Slab but i can't on the top side of my custom slab -
[SOLVED] [1.7.2] Can't place torches on top of custom wall or fences
JimiIT92 replied to JimiIT92's topic in Modder Support
Yes i know but if i do i can't place torches on top of them EDIT: i was forgotten the @Override annotation -.- Allright, thanks for supported me -
[SOLVED] [1.7.2] Can't place torches on top of custom wall or fences
JimiIT92 replied to JimiIT92's topic in Modder Support
I've changed it from false to true but now i have no icon in inventory (if i select the first slot in the previous image i see no icon, only the block name) -
[SOLVED] [1.7.2] Can't place torches on top of custom wall or fences
JimiIT92 replied to JimiIT92's topic in Modder Support
Allright, it worked Thanks! But now i have another error: my fences has a wrong icon in inventory. This was caused because i had to make a separated class and renderBlock for this fences (otherwise it shouldn't work) and now i have the plain planks icon This is the BlockColoredFence class: package mod.mineworld.blocks.mod_colors; import java.util.List; import mod.mineworld.mod_colors; import mod.mineworld.mod_ores; import net.minecraft.block.Block; import net.minecraft.block.BlockFence; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemLead; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class BlockColoredFence extends Block { private final String texture_path; public BlockColoredFence(String par1, Material par2) { super(par2); this.texture_path = par1; } /** * Adds all intersecting collision boxes to a list. (Be sure to only add boxes to the list if they intersect the * mask.) Parameters: World, X, Y, Z, mask, list, colliding entity */ public void addCollisionBoxesToList(World par1, int par2, int par3, int par4, AxisAlignedBB par5, List par6, Entity par7) { boolean flag = this.canConnectFenceTo(par1, par2, par3, par4 - 1); boolean flag1 = this.canConnectFenceTo(par1, par2, par3, par4 + 1); boolean flag2 = this.canConnectFenceTo(par1, par2 - 1, par3, par4); boolean flag3 = this.canConnectFenceTo(par1, par2 + 1, par3, par4); float f = 0.375F; float f1 = 0.625F; float f2 = 0.375F; float f3 = 0.625F; if (flag) { f2 = 0.0F; } if (flag1) { f3 = 1.0F; } if (flag || flag1) { this.setBlockBounds(f, 0.0F, f2, f1, 1.5F, f3); super.addCollisionBoxesToList(par1, par2, par3, par4, par5, par6, par7); } f2 = 0.375F; f3 = 0.625F; if (flag2) { f = 0.0F; } if (flag3) { f1 = 1.0F; } if (flag2 || flag3 || !flag && !flag1) { this.setBlockBounds(f, 0.0F, f2, f1, 1.5F, f3); super.addCollisionBoxesToList(par1, par2, par3, par4, par5, par6, par7); } if (flag) { f2 = 0.0F; } if (flag1) { f3 = 1.0F; } this.setBlockBounds(f, 0.0F, f2, f1, 1.0F, f3); } /** * Updates the blocks bounds based on its current state. Args: world, x, y, z */ public void setBlockBoundsBasedOnState(IBlockAccess par1, int par2, int par3, int par4) { boolean flag = this.canConnectFenceTo(par1, par2, par3, par4 - 1); boolean flag1 = this.canConnectFenceTo(par1, par2, par3, par4 + 1); boolean flag2 = this.canConnectFenceTo(par1, par2 - 1, par3, par4); boolean flag3 = this.canConnectFenceTo(par1, par2 + 1, par3, par4); float f = 0.375F; float f1 = 0.625F; float f2 = 0.375F; float f3 = 0.625F; if (flag) { f2 = 0.0F; } if (flag1) { f3 = 1.0F; } if (flag2) { f = 0.0F; } if (flag3) { f1 = 1.0F; } this.setBlockBounds(f, 0.0F, f2, f1, 1.0F, f3); } /** * Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block. */ public boolean isOpaqueCube() { return false; } /** * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) */ public boolean renderAsNormalBlock() { return false; } public boolean getBlocksMovement(IBlockAccess par1, int par2, int par3, int par4) { return false; } /** * The type of render function that is called for this block */ public int getRenderType() { return mod_colors.fenceModelID; } /** * Returns true if the specified block can be connected by a fence */ public boolean canConnectFenceTo(IBlockAccess par1, int par2, int par3, int par4) { Block block = par1.getBlock(par2, par3, par4); for(int i = 0; i < 16; i++) {if(block == mod_colors.colored_fence_gate[i]) return true;} if(block == mod_colors.colored_fence[0] || block == mod_colors.colored_fence[1] || block == mod_colors.colored_fence[2] || block == mod_colors.colored_fence[3] || block == mod_colors.colored_fence[4] || block == mod_colors.colored_fence[5] || block == mod_colors.colored_fence[6] || block == mod_colors.colored_fence[7] || block == mod_colors.colored_fence[8] || block == mod_colors.colored_fence[9] || block == mod_colors.colored_fence[10] || block == mod_colors.colored_fence[11] || block == mod_colors.colored_fence[12] || block == mod_colors.colored_fence[13] || block == mod_colors.colored_fence[14] || block == mod_colors.colored_fence[15]) return true; else return block != this && block != Blocks.fence_gate && block != mod_colors.colored_fence_gate[0] && block != mod_colors.colored_fence_gate[0] && block != mod_colors.colored_fence_gate[1] && block != mod_colors.colored_fence_gate[2] && block != mod_colors.colored_fence_gate[3] && block != mod_colors.colored_fence_gate[4] && block != mod_colors.colored_fence_gate[5] && block != mod_colors.colored_fence_gate[6] && block != mod_colors.colored_fence_gate[7] && block != mod_colors.colored_fence_gate[8] && block != mod_colors.colored_fence_gate[9] && block != mod_colors.colored_fence_gate[10] && block != mod_colors.colored_fence_gate[11] && block != mod_colors.colored_fence_gate[12] && block != mod_colors.colored_fence_gate[13] && block != mod_colors.colored_fence_gate[14] && block != mod_colors.colored_fence_gate[15]? (block.getMaterial().isOpaque() && block.renderAsNormalBlock() ? block.getMaterial() != Material.gourd : false) : true; } public static boolean func_149825_a(Block par1) { return par1 == Blocks.fence || par1 == Blocks.nether_brick_fence; } /** * Returns true if the given side of this block type should be rendered, if the adjacent block is at the given * coordinates. Args: blockAccess, x, y, z, side */ @SideOnly(Side.CLIENT) public boolean shouldSideBeRendered(IBlockAccess par1, int par2, int par3, int par4, int par5) { return true; } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister par1) { this.blockIcon = par1.registerIcon(this.texture_path); } /** * Called upon block activation (right click on the block.) */ public boolean onBlockActivated(World par1, int par2, int par3, int par4, EntityPlayer par5, int par6, float par7, float par8, float par9) { return par1.isRemote ? true : ItemLead.func_150909_a(par5, par1, par2, par3, par4); } public boolean canPlaceTorchOnTop(World world, int x, int y, int z) { return true; } } This is the RenderColoredFence class: package mod.mineworld.items.render.mod_colors; import mod.mineworld.mod_colors; import mod.mineworld.mod_redstone; import mod.mineworld.blocks.mod_colors.BlockColoredFence; import mod.mineworld.blocks.mod_redstone.BlockLantern; import net.minecraft.block.Block; import net.minecraft.block.BlockCocoa; import net.minecraft.block.BlockDirectional; import net.minecraft.block.BlockFence; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.init.Blocks; import net.minecraft.util.IIcon; import net.minecraft.util.Vec3; import net.minecraft.world.IBlockAccess; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderColoredFence implements ISimpleBlockRenderingHandler { public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { } public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { return renderBlockColoredFence((BlockColoredFence)block, x, y, z, renderer); } public boolean shouldRender3DInInventory(int modelID) { return false; } @Override public int getRenderId() { return 0; } public int getRenderType() { return mod_colors.fenceModelID; } public boolean renderBlockColoredFence(BlockColoredFence par1, int par2, int par3, int par4, RenderBlocks renderer) { boolean flag = false; float f = 0.375F; float f1 = 0.625F; renderer.setRenderBounds((double)f, 0.0D, (double)f, (double)f1, 1.0D, (double)f1); renderer.renderStandardBlock(par1, par2, par3, par4); flag = true; boolean flag1 = false; boolean flag2 = false; if (par1.canConnectFenceTo(renderer.blockAccess, par2 - 1, par3, par4) || par1.canConnectFenceTo(renderer.blockAccess, par2 + 1, par3, par4)) { flag1 = true; } if (par1.canConnectFenceTo(renderer.blockAccess, par2, par3, par4 - 1) || par1.canConnectFenceTo(renderer.blockAccess, par2, par3, par4 + 1)) { flag2 = true; } boolean flag3 = par1.canConnectFenceTo(renderer.blockAccess, par2 - 1, par3, par4); boolean flag4 = par1.canConnectFenceTo(renderer.blockAccess, par2 + 1, par3, par4); boolean flag5 = par1.canConnectFenceTo(renderer.blockAccess, par2, par3, par4 - 1); boolean flag6 = par1.canConnectFenceTo(renderer.blockAccess, par2, par3, par4 + 1); if (!flag1 && !flag2) { flag1 = true; } f = 0.4375F; f1 = 0.5625F; float f2 = 0.75F; float f3 = 0.9375F; float f4 = flag3 ? 0.0F : f; float f5 = flag4 ? 1.0F : f1; float f6 = flag5 ? 0.0F : f; float f7 = flag6 ? 1.0F : f1; if (flag1) { renderer.setRenderBounds((double)f4, (double)f2, (double)f, (double)f5, (double)f3, (double)f1); renderer.renderStandardBlock(par1, par2, par3, par4); flag = true; } if (flag2) { renderer.setRenderBounds((double)f, (double)f2, (double)f6, (double)f1, (double)f3, (double)f7); renderer.renderStandardBlock(par1, par2, par3, par4); flag = true; } f2 = 0.375F; f3 = 0.5625F; if (flag1) { renderer.setRenderBounds((double)f4, (double)f2, (double)f, (double)f5, (double)f3, (double)f1); renderer.renderStandardBlock(par1, par2, par3, par4); flag = true; } if (flag2) { renderer.setRenderBounds((double)f, (double)f2, (double)f6, (double)f1, (double)f3, (double)f7); renderer.renderStandardBlock(par1, par2, par3, par4); flag = true; } par1.setBlockBoundsBasedOnState(renderer.blockAccess, par2, par3, par4); return flag; } } in the ClientProxy: mod_colors.fenceModelID = RenderingRegistry.instance().getNextAvailableRenderId(); RenderingRegistry.instance().registerBlockHandler(mod_colors.fenceModelID , new RenderColoredFence()); -
Hi everybody! I figured it out that i can't place torches on my custon walls or fences. Here is the code for my custom wall: package mod.mineworld.blocks.mod_vanilla; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import java.util.List; import mod.mineworld.mod_tabs; import mod.mineworld.mod_vanilla; import net.minecraft.block.Block; import net.minecraft.block.BlockWall; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class BlockVanillaWall extends BlockWall { private Block block; private int meta; public BlockVanillaWall(Block par1, int par2) { super(par1); this.setHardness(1.0F); this.setResistance(3.0F / 3.0F); this.setStepSound(par1.stepSound); this.setCreativeTab(mod_tabs.tabVanillaBlocks); this.block = par1; this.meta = par2; if(this == mod_vanilla.packed_ice_wall) this.slipperiness = 0.98F; } /** * Gets the block's texture. Args: side, meta */ @SideOnly(Side.CLIENT) public IIcon getIcon(int par1, int par2) { return this.block.getIcon(par1, this.meta); } /** * The type of render function that is called for this block */ public int getRenderType() { return 32; } /** * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) */ public boolean renderAsNormalBlock() { return false; } public boolean getBlocksMovement(IBlockAccess par1, int par2, int par3, int par4) { return false; } /** * Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block. */ public boolean isOpaqueCube() { return false; } /** * Updates the blocks bounds based on its current state. Args: world, x, y, z */ public void setBlockBoundsBasedOnState(IBlockAccess par1, int par2, int par3, int par4) { boolean flag = this.canConnectWallTo(par1, par2, par3, par4 - 1); boolean flag1 = this.canConnectWallTo(par1, par2, par3, par4 + 1); boolean flag2 = this.canConnectWallTo(par1, par2 - 1, par3, par4); boolean flag3 = this.canConnectWallTo(par1, par2 + 1, par3, par4); float f = 0.25F; float f1 = 0.75F; float f2 = 0.25F; float f3 = 0.75F; float f4 = 1.0F; if (flag) { f2 = 0.0F; } if (flag1) { f3 = 1.0F; } if (flag2) { f = 0.0F; } if (flag3) { f1 = 1.0F; } if (flag && flag1 && !flag2 && !flag3) { f4 = 0.8125F; f = 0.3125F; f1 = 0.6875F; } else if (!flag && !flag1 && flag2 && flag3) { f4 = 0.8125F; f2 = 0.3125F; f3 = 0.6875F; } this.setBlockBounds(f, 0.0F, f2, f1, f4, f3); } /** * Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been * cleared to be reused) */ public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1, int par2, int par3, int par4) { this.setBlockBoundsBasedOnState(par1, par2, par3, par4); this.maxY = 1.5D; return super.getCollisionBoundingBoxFromPool(par1, par2, par3, par4); } /** * Return whether an adjacent block can connect to a wall. */ public boolean canConnectWallTo(IBlockAccess par1, int par2, int par3, int par4) { Block block = par1.getBlock(par2, par3, par4); return block != this && block != Blocks.fence_gate ? (block.getMaterial().isOpaque() && block.renderAsNormalBlock() ? block.getMaterial() != Material.gourd : false) : true; } /** * Returns true if the given side of this block type should be rendered, if the adjacent block is at the given * coordinates. Args: blockAccess, x, y, z, side */ @SideOnly(Side.CLIENT) public boolean shouldSideBeRendered(IBlockAccess par1, int par2, int par3, int par4, int par5) { return par5 == 0 ? super.shouldSideBeRendered(par1, par2, par3, par4, par5) : true; } /** * Returns the mobility information of the block, 0 = free, 1 = can't push but can move over, 2 = total immobility * and stop pistons */ public int getMobilityFlag() { if(this == mod_vanilla.obsidian_wall) return 2; else return 0; } } For fences i have no code, i've just call the vanilla BlockFence class to create them. white_marble_fence = new BlockFence(MineWorld.MODID + ":mod_ores/" + "oreMarble_white", Material.rock).setCreativeTab(mod_tabs.tabOreDecorations).setHardness(2.0F).setResistance(5.0F).setStepSound(Block.soundTypeStone).setBlockName("whiteMarbleFence"); pink_marble_fence = new BlockFence(MineWorld.MODID + ":mod_ores/" + "oreMarble_pink", Material.rock).setCreativeTab(mod_tabs.tabOreDecorations).setHardness(2.0F).setResistance(5.0F).setStepSound(Block.soundTypeStone).setBlockName("pinkMarbleFence"); Thanks in advice for all who will help me
-
Hi everybody! I've noticed a curious thing while making a custom slab. I can't place redstone or torches on top of it if placing the slab in the upper half part of a block. Here is my BlockHalfSlab class: package mod.mineworld.blocks.mod_ores; import java.util.List; import java.util.Random; import mod.mineworld.MineWorld; import mod.mineworld.mod_ores; import mod.mineworld.mod_tabs; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class BlockHalfSlab extends BlockOreSlab { public static final String[] slab_names = new String[] {"ruby", "sapphire", "copper", "bronze", "silver", "aluminium", "whiteMarble", "pinkMarble"}; @SideOnly(Side.CLIENT) private IIcon icon; public BlockHalfSlab(boolean par1) { super(par1, Material.rock); this.setCreativeTab(mod_tabs.tabOreBlock); } /** * Gets the block's texture. Args: side, meta */ @SideOnly(Side.CLIENT) public IIcon getIcon(int par1, int par2) { int k = par2 & 7; if (this.isDoubleSlab && (par2 & != 0) { par1 = 1; } return k == 0 ? (par1 != 1 && par1 != 0 ? mod_ores.block_ruby.getBlockTextureFromSide(par1) : mod_ores.block_ruby.getBlockTextureFromSide(par1)) : (k == 1 ? mod_ores.block_sapphire.getBlockTextureFromSide(par1) : (k == 2 ? mod_ores.block_copper.getBlockTextureFromSide(par1) : (k == 3 ? mod_ores.block_bronze.getBlockTextureFromSide(par1) : (k == 4 ? mod_ores.block_silver.getBlockTextureFromSide(par1) : (k == 5 ? mod_ores.block_aluminium.getIcon(par1, 0) : (k == 6 ? mod_ores.ore_marble.getBlockTextureFromSide(1) : this.blockIcon)))))); } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister par1) { this.blockIcon = par1.registerIcon(MineWorld.MODID + ":mod_ores/" + "oreMarble_pink"); this.icon = par1.registerIcon(MineWorld.MODID + ":mod_ores/" + "oreMarble_pink"); } public Item getItemDropped(int par1, Random par2, int par3) { return Item.getItemFromBlock(mod_ores.ore_single_slab); } /** * Returns an item stack containing a single instance of the current block type. 'i' is the block's subtype/damage * and is ignored for blocks which do not support subtypes. Blocks which cannot be harvested should return null. */ protected ItemStack createStackedBlock(int par1) { return new ItemStack(Item.getItemFromBlock(mod_ores.ore_single_slab), 2, par1 & 7); } public String getFullSlabName(int par1) { if (par1 < 0 || par1 >= slab_names.length) { par1 = 0; } return super.getUnlocalizedName() + "." + slab_names[par1]; } /** * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) */ @SideOnly(Side.CLIENT) public void getSubBlocks(Item par1, CreativeTabs par2, List par3) { if (par1 != Item.getItemFromBlock(mod_ores.ore_double_slab)) { for (int i = 0; i <= 7; ++i) { par3.add(new ItemStack(par1, 1, i)); } } } } The BlockOreSlab class: package mod.mineworld.blocks.mod_ores; import java.util.List; import java.util.Random; import mod.mineworld.mod_ores; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.Entity; import net.minecraft.item.Item; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.Facing; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public abstract class BlockOreSlab extends Block { protected final boolean isDoubleSlab; private static boolean power = false; private static int power_level; private static int metadata; public BlockOreSlab(boolean par1, Material par2) { super(par2); this.isDoubleSlab = par1; if (par1) { this.opaque = true; } else { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); } this.setLightOpacity(0); } /** * Updates the blocks bounds based on its current state. Args: world, x, y, z */ public void setBlockBoundsBasedOnState(IBlockAccess par1, int par2, int par3, int par4) { if (this.isDoubleSlab) { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } else { boolean flag = (par1.getBlockMetadata(par2, par3, par4) & != 0; if (flag) { this.setBlockBounds(0.0F, 0.5F, 0.0F, 1.0F, 1.0F, 1.0F); } else { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); } } } /** * Sets the block's bounds for rendering it as an item */ public void setBlockBoundsForItemRender() { if (this.isDoubleSlab) { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } else { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); } } /** * Adds all intersecting collision boxes to a list. (Be sure to only add boxes to the list if they intersect the * mask.) Parameters: World, X, Y, Z, mask, list, colliding entity */ public void addCollisionBoxesToList(World par1, int par2, int par3, int par4, AxisAlignedBB par5, List par6, Entity par7) { this.setBlockBoundsBasedOnState(par1, par2, par3, par4); super.addCollisionBoxesToList(par1, par2, par3, par4, par5, par6, par7); } /** * Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block. */ public boolean isOpaqueCube() { return this.isDoubleSlab; } /** * Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY, hitZ, block metadata */ public int onBlockPlaced(World par1, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9) { metadata = par9; return this.isDoubleSlab ? par9 : (par5 != 0 && (par5 == 1 || (double)par7 <= 0.5D) ? par9 : par9 | ; } /** * Returns the quantity of items to drop on block destruction. */ public int quantityDropped(Random par1) { return this.isDoubleSlab ? 2 : 1; } /** * Determines the damage on the item the block drops. Used in cloth and wood. */ public int damageDropped(int par1) { return par1 & 7; } /** * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) */ public boolean renderAsNormalBlock() { return this.isDoubleSlab; } /** * Returns true if the given side of this block type should be rendered, if the adjacent block is at the given * coordinates. Args: blockAccess, x, y, z, side */ @SideOnly(Side.CLIENT) public boolean shouldSideBeRendered(IBlockAccess par1, int par2, int par3, int par4, int par5) { if (this.isDoubleSlab) { return super.shouldSideBeRendered(par1, par2, par3, par4, par5); } else if (par5 != 1 && par5 != 0 && !super.shouldSideBeRendered(par1, par2, par3, par4, par5)) { return false; } else { int i1 = par2 + Facing.offsetsXForSide[Facing.oppositeSide[par5]]; int j1 = par3 + Facing.offsetsYForSide[Facing.oppositeSide[par5]]; int k1 = par4 + Facing.offsetsZForSide[Facing.oppositeSide[par5]]; boolean flag = (par1.getBlockMetadata(i1, j1, k1) & != 0; return flag ? (par5 == 0 ? true : (par5 == 1 && super.shouldSideBeRendered(par1, par2, par3, par4, par5) ? true : !isBlockSingleSlab(par1.getBlock(par2, par3, par4)) || (par1.getBlockMetadata(par2, par3, par4) & == 0)) : (par5 == 1 ? true : (par5 == 0 && super.shouldSideBeRendered(par1, par2, par3, par4, par5) ? true : !isBlockSingleSlab(par1.getBlock(par2, par3, par4)) || (par1.getBlockMetadata(par2, par3, par4) & != 0)); } } @SideOnly(Side.CLIENT) private static boolean isBlockSingleSlab(Block par1) { return par1 == mod_ores.ore_single_slab; } public abstract String getFullSlabName(int var1); /** * Get the block's damage value (for use with pick block). */ public int getDamageValue(World par1, int par2, int par3, int par4) { return super.getDamageValue(par1, par2, par3, par4) & 7; } /** * Gets an item for the block being called on. Args: world, x, y, z */ @SideOnly(Side.CLIENT) public Item getItem(World par1, int par2, int par3, int par4) { return Item.getItemFromBlock(mod_ores.ore_single_slab); } /** * Returns true if the block is emitting indirect/weak redstone power on the specified side. If isBlockNormalCube * returns true, standard redstone propagation rules will apply instead and this will not be called. Args: World, X, * Y, Z, side. Note that the side is reversed - eg it is 1 (up) when checking the bottom of the block. */ @Override public int isProvidingWeakPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) { if(par1IBlockAccess.getBlockMetadata(par2, par3, par4) == 2) return 10; else if(par1IBlockAccess.getBlockMetadata(par2, par3, par4) == 3) return 5; else return 0; } } the ItemOreSlab class: package mod.mineworld.blocks.mod_ores; import mod.mineworld.mod_ores; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.World; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class ItemOreSlab extends ItemBlock { private final boolean isDoubleSlab; private final BlockOreSlab single_slab; private final BlockOreSlab double_slab; public ItemOreSlab(Block block) { super(block); this.single_slab = mod_ores.ore_single_slab; this.double_slab = mod_ores.ore_double_slab; this.isDoubleSlab = false; this.setHasSubtypes(true); } /** * Gets an icon index based on an item's damage value */ @SideOnly(Side.CLIENT) public IIcon getIconFromDamage(int par1) { return Block.getBlockFromItem(this).getIcon(1, par1); } /** * Returns the metadata of the block which this Item (ItemBlock) can place */ public int getMetadata(int par1) { return par1; } /** * Returns the unlocalized name of this item. This version accepts an ItemStack so different stacks can have * different names based on their damage or NBT. */ public String getUnlocalizedName(ItemStack par1ItemStack) { return this.single_slab.getFullSlabName(par1ItemStack.getItemDamage()); } /** * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return * True if something happen and false if it don't. This is for ITEMS, not BLOCKS */ public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { if (this.isDoubleSlab) { return super.onItemUse(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10); } else if (par1ItemStack.stackSize == 0) { return false; } else if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) { return false; } else { Block block = par3World.getBlock(par4, par5, par6); int i1 = par3World.getBlockMetadata(par4, par5, par6); int j1 = i1 & 7; boolean flag = (i1 & != 0; if ((par7 == 1 && !flag || par7 == 0 && flag) && block == this.single_slab && j1 == par1ItemStack.getItemDamage()) { if (par3World.checkNoEntityCollision(this.double_slab.getCollisionBoundingBoxFromPool(par3World, par4, par5, par6)) && par3World.setBlock(par4, par5, par6, this.double_slab, j1, 3)) { par3World.playSoundEffect((double)((float)par4 + 0.5F), (double)((float)par5 + 0.5F), (double)((float)par6 + 0.5F), this.double_slab.stepSound.func_150496_b(), (this.double_slab.stepSound.getVolume() + 1.0F) / 2.0F, this.double_slab.stepSound.getPitch() * 0.8F); --par1ItemStack.stackSize; } return true; } else { return this.isBlockDoubleSlab(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7) ? true : super.onItemUse(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10); } } } @SideOnly(Side.CLIENT) public boolean isBlockSingleSlab(World par1, int par2, int par3, int par4, int par5, EntityPlayer par6, ItemStack par7) { int i1 = par2; int j1 = par3; int k1 = par4; Block block = par1.getBlock(par2, par3, par4); int l1 = par1.getBlockMetadata(par2, par3, par4); int i2 = l1 & 7; boolean flag = (l1 & != 0; if ((par5 == 1 && !flag || par5 == 0 && flag) && block == this.single_slab && i2 == par7.getItemDamage()) { return true; } else { if (par5 == 0) { --par3; } if (par5 == 1) { ++par3; } if (par5 == 2) { --par4; } if (par5 == 3) { ++par4; } if (par5 == 4) { --par2; } if (par5 == 5) { ++par2; } Block block1 = par1.getBlock(par2, par3, par4); int j2 = par1.getBlockMetadata(par2, par3, par4); i2 = j2 & 7; return block1 == this.single_slab && i2 == par7.getItemDamage() ? true : super.func_150936_a(par1, i1, j1, k1, par5, par6, par7); } } private boolean isBlockDoubleSlab(ItemStack par1, EntityPlayer par2, World par3, int par4, int par5, int par6, int par7) { if (par7 == 0) { --par5; } if (par7 == 1) { ++par5; } if (par7 == 2) { --par6; } if (par7 == 3) { ++par6; } if (par7 == 4) { --par4; } if (par7 == 5) { ++par4; } Block block = par3.getBlock(par4, par5, par6); int i1 = par3.getBlockMetadata(par4, par5, par6); int j1 = i1 & 7; if (block == this.single_slab && j1 == par1.getItemDamage()) { if (par3.checkNoEntityCollision(this.double_slab.getCollisionBoundingBoxFromPool(par3, par4, par5, par6)) && par3.setBlock(par4, par5, par6, this.double_slab, j1, 3)) { par3.playSoundEffect((double)((float)par4 + 0.5F), (double)((float)par5 + 0.5F), (double)((float)par6 + 0.5F), this.double_slab.stepSound.func_150496_b(), (this.double_slab.stepSound.getVolume() + 1.0F) / 2.0F, this.double_slab.stepSound.getPitch() * 0.8F); --par1.stackSize; } return true; } else { return false; } } } Thanks in advice for all who will help me
-
Hi guys! I'm making an item (a torch) that when helded it spawn a light block, so i simulated a dynamic light. What the onUpdate method do is to spawn this block above the player and destroy all other blocks around this light block, otherwise while moving the player will leave a light trail. This actually work but it cause a lot of lag, i think because the removing cicles. So my question is, how can i make this works without lag? Here the code for my item package mod.mineworld.items.mod_redstone; import mod.mineworld.mod_redstone; import mod.mineworld.mod_tabs; import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ChatComponentText; import net.minecraft.util.MathHelper; import net.minecraft.util.Vec3; import net.minecraft.world.EnumSkyBlock; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; public class ItemFlambeau extends Item { private int usage = 10000; public ItemFlambeau() { super(); maxStackSize = 64; this.setCreativeTab(mod_tabs.tabModRedstone); } /** * Callback for item usage. If the item does something special on right * clicking, he will have one of those. Return True if something happen and * false if it don't. This is for ITEMS, not BLOCKS */ public boolean isInWater(World par1, int par2, int par3, int par4) { if (par1.getBlock(par2 + 1, par3, par4) == Blocks.water) return true; else if (par1.getBlock(par2 - 1, par3, par4) == Blocks.water) return true; else if (par1.getBlock(par2, par3 + 1, par4) == Blocks.water) return true; else if (par1.getBlock(par2, par3 - 1, par4) == Blocks.water) return true; else if (par1.getBlock(par2, par3, par4 + 1) == Blocks.water) return true; else if (par1.getBlock(par2, par3, par4 - 1) == Blocks.water) return true; else return false; } public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5,int par6, int par7, float par8, float par9, float par10) { if (this.isInWater(par3World, par4, par5, par6)) { return false; } if (par3World.isSideSolid(par4, par5, par6,ForgeDirection.getOrientation(par7)) || par3World.getBlock(par4, par5, par6) == Blocks.snow_layer) { ForgeDirection dir = ForgeDirection.getOrientation(par7); int x = par4, y = par5, z = par6; switch (dir) { case UP: if (!isFlambeauAttached(par3World, par4, par5 + 1, par6)) { if (par3World.getBlock(par4, par5, par6) == Blocks.snow_layer) { par3World.setBlock(par4, par5, par6,mod_redstone.flambeau_block, 5, 2); x = par4; y = par5; z = par6; } else { par3World.setBlock(par4, par5 + 1, par6,mod_redstone.flambeau_block, 5, 2); x = par4; y = par5 + 1; z = par6; } par3World.playSoundEffect((double) ((float) par4 + 0.5F),(double) ((float) par5 + 0.5F),(double) ((float) par6 + 0.5F), "dig.wood", 1.0F,0.8F); if (!par2EntityPlayer.capabilities.isCreativeMode) --par1ItemStack.stackSize; } else { par1ItemStack.stackSize -= 0; return false; } break; case DOWN: par1ItemStack.stackSize -= 0; return false; case NORTH: if (!isFlambeauAttached(par3World, par4, par5, par6 - 1)) { if (par3World.getBlock(par4, par5, par6) == Blocks.snow_layer) { par3World.setBlock(par4, par5, par6,mod_redstone.flambeau_block, 5, 2); x = par4; y = par5; z = par6; } else { par3World.setBlock(par4, par5, par6 - 1,mod_redstone.flambeau_block, 4, 2); x = par4; y = par5; z = par6 - 1; } par3World.playSoundEffect((double) ((float) par4 + 0.5F),(double) ((float) par5 + 0.5F),(double) ((float) par6 + 0.5F), "dig.wood", 1.0F,0.8F); if (!par2EntityPlayer.capabilities.isCreativeMode) --par1ItemStack.stackSize; } else { par1ItemStack.stackSize -= 0; return false; } break; case SOUTH: if (!isFlambeauAttached(par3World, par4, par5, par6 + 1)) { if (par3World.getBlock(par4, par5, par6) == Blocks.snow_layer) { par3World.setBlock(par4, par5, par6,mod_redstone.flambeau_block, 5, 2); x = par4; y = par5; z = par6; } else { par3World.setBlock(par4, par5, par6 + 1,mod_redstone.flambeau_block, 3, 2); x = par4; y = par5; z = par6 + 1; } par3World.playSoundEffect((double) ((float) par4 + 0.5F),(double) ((float) par5 + 0.5F),(double) ((float) par6 + 0.5F), "dig.wood", 1.0F,0.8F); if (!par2EntityPlayer.capabilities.isCreativeMode) --par1ItemStack.stackSize; } else { par1ItemStack.stackSize -= 0; return false; } break; case WEST: if (!isFlambeauAttached(par3World, par4 - 1, par5, par6)) { if (par3World.getBlock(par4, par5, par6) == Blocks.snow_layer) { par3World.setBlock(par4, par5, par6,mod_redstone.flambeau_block, 5, 2); x = par4; y = par5; z = par6; } else { par3World.setBlock(par4 - 1, par5, par6,mod_redstone.flambeau_block, 2, 2); x = par4 - 1; y = par5; z = par6; } par3World.playSoundEffect((double) ((float) par4 + 0.5F),(double) ((float) par5 + 0.5F),(double) ((float) par6 + 0.5F), "dig.wood", 1.0F,0.8F); if (!par2EntityPlayer.capabilities.isCreativeMode) --par1ItemStack.stackSize; } else { par1ItemStack.stackSize -= 0; par3World.setBlock(par4-1, par5, par6, par3World.getBlock(par4-1, par5, par6), par3World.getBlockMetadata(par4-1, par5, par6), 2); return false; } break; case EAST: if (!isFlambeauAttached(par3World, par4 + 1, par5, par6)) { if (par3World.getBlock(par4, par5, par6) == Blocks.snow_layer) { par3World.setBlock(par4, par5, par6,mod_redstone.flambeau_block, 5, 2); x = par4; y = par5; z = par6; } else { par3World.setBlock(par4 + 1, par5, par6,mod_redstone.flambeau_block, 1, 2); x = par4 + 1; y = par5; z = par6; } par3World.playSoundEffect((double) ((float) par4 + 0.5F),(double) ((float) par5 + 0.5F),(double) ((float) par6 + 0.5F), "dig.wood", 1.0F,0.8F); if (!par2EntityPlayer.capabilities.isCreativeMode) --par1ItemStack.stackSize; } else { par1ItemStack.stackSize -= 0; par3World.setBlock(par4+1, par5, par6, par3World.getBlock(par4+1, par5, par6), par3World.getBlockMetadata(par4+1, par5, par6), 2); return false; } break; default: break; } return true; } return false; } @Override public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5){ World world = par2World; EntityPlayer player = (EntityPlayer)par3Entity; ItemStack hand = player.getCurrentEquippedItem(); if(!player.isInWater()){ int x = (int) player.posX; int y = (int) player.posY; int z = (int) player.posZ; for(int i = -1; i < 2; i++) for(int j = -1; j < 2; j++) for(int k = -1; k < 2; k++) if(world.getBlock(x+i, y+j, z+k) == mod_redstone.light) world.setBlockToAir(x+i, y+j, z+k); if(player.getCurrentEquippedItem() != null){ if(hand.getItem() == mod_redstone.flambeau){ world.setBlock(x, y+1, z, mod_redstone.light); this.usage--; if(this.usage <= 0){ player.inventory.consumeInventoryItem(this); this.usage = 10000; } } }} } public boolean isFlambeauAttached(World par1, int par2, int par3,int par4) { if (par1.getBlock(par2, par3, par4) == mod_redstone.flambeau_block) return true; else return false; } } And here is the BlockLight code package mod.mineworld.blocks.mod_redstone; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.item.Item; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; public class BlockLight extends Block{ public BlockLight() { super(Material.air); this.setLightLevel(1.0F); } /** * Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been * cleared to be reused) */ public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) { return null; } /** * Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block. */ public boolean isOpaqueCube() { return false; } /** * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) */ public boolean renderAsNormalBlock() { return false; } /** * Returns whether this block is collideable based on the arguments passed in n@param par1 block metaData n@param * par2 whether the player right-clicked while holding a boat */ public boolean canCollideCheck(int p_149678_1_, boolean p_149678_2_) { return false; } /** * Returns the ID of the items to drop on destruction. */ public Item idDropped(int par1, Random par2Random, int par3) { return null; } /** * only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative) */ public Item idPicked(World par1World, int par2, int par3, int par4) { return null; } } Thanks in advice for all who will help me
-
Ok this works but i have to create a new World Type (so when creating a new world specifing this new type)... but how to make it works WITHOUT making this new World Type? How can i add my custom biome to the default world type GenLayer?
-
Hi guys I'm making a new biome today but since there isn't anymore the method GameRegistry.registerBiome i can't figure it out how to add a new biome and make it spawn. Actually i've only coded it and registered in the way i see online but it doesn't spawn Here is the code of my custom biome: package mod.mineworld.world.mod_plants; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.gen.feature.WorldGenLiquids; import net.minecraft.world.gen.feature.WorldGenerator; public class BiomeGenAppleForest extends BiomeGenBase { private WorldGenerator WorldGenTrees; private WorldGenerator WorldGenLakes; int color; public BiomeGenAppleForest(int par1) { super(par1); this.theBiomeDecorator.treesPerChunk = 50; this.topBlock = Blocks.grass; this.fillerBlock = Blocks.dirt; this.WorldGenTrees = new WorldGenAppleTrees(false); this.WorldGenLakes = new WorldGenLiquids(Blocks.water); } /** * Gets a WorldGen appropriate for this biome. */ public WorldGenerator getRandomWorldGenForTrees(Random par1Random) { return (WorldGenerator)(par1Random.nextInt(5) == 0 ? this.WorldGenLakes : (par1Random.nextInt(10) == 0 ? this.WorldGenTrees : this.WorldGenTrees)); } public BiomeGenBase setColor(int par1) { this.color = 16711680; return this; } } And here is how i registered it in the main sub-mod file: public static BiomeGenBase AppleForest AppleForest = new BiomeGenAppleForest(154).setColor(353825).setBiomeName("Apple Forest"); BiomeDictionary.registerBiomeType(AppleForest, Type.FOREST); BiomeManager.addSpawnBiome(AppleForest); I think it should be registered this way but i don't know why it doesn't spawn
-
[1.7.2]Custom metadata sapling not return two different icons
JimiIT92 replied to JimiIT92's topic in Modder Support
Yes i have the ItemBlock file for the saplings and i already register it with GameRegistry.registerBlock(saplings, ItemSaplings.class, "saplings"); but it doesn't work I'm pretty sure the problem is not the ItemSapling.class beacuse i also have two metadata woods wich hase the same ItemBlock class and it all works fine, so i don't know why it's not working with the saplings This is the ItemSaplings class package mod.mineworld.blocks.mod_plants; import net.minecraft.block.Block; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; public class ItemSaplings extends ItemBlock { private final static String[] subNames = { "apple", "palm" }; public ItemSaplings(Block id) { super(id); setHasSubtypes(true); } @Override public int getMetadata (int damageValue) { return damageValue; } @Override public String getUnlocalizedName(ItemStack itemstack) { return getUnlocalizedName() + "." + subNames[itemstack.getItemDamage()]; } } -
Hi guys I'm making two new saplings and i want to make it like the vanilla saplings (Same id with different meta). I have copy the BlockSapling class and change id to returns 2 blocks, but it not returns two different icons but only the icon of the first sapling for both the blocks. It's only the icon because if i place them the texture is correct. Here is the BlockSaplingMod file: package mod.mineworld.blocks.mod_plants; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import java.util.List; import java.util.Random; import mod.mineworld.mod_tabs; import net.minecraft.block.Block; import net.minecraft.block.BlockBush; import net.minecraft.block.IGrowable; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenBigTree; import net.minecraft.world.gen.feature.WorldGenCanopyTree; import net.minecraft.world.gen.feature.WorldGenForest; import net.minecraft.world.gen.feature.WorldGenMegaJungle; import net.minecraft.world.gen.feature.WorldGenMegaPineTree; import net.minecraft.world.gen.feature.WorldGenSavannaTree; import net.minecraft.world.gen.feature.WorldGenTaiga2; import net.minecraft.world.gen.feature.WorldGenTrees; import net.minecraft.world.gen.feature.WorldGenerator; public class BlockSaplings extends BlockBush implements IGrowable { public static final String[] sapling_names = new String[] {"apple", "palm"}; private static final IIcon[] icon = new IIcon[sapling_names.length]; public BlockSaplings() { float f = 0.4F; this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 2.0F, 0.5F + f); this.setCreativeTab(mod_tabs.tabPlantsDecorations); } /** * Ticks the block if it's been scheduled */ public void updateTick(World par1, int par2, int par3, int par4, Random par5) { if (!par1.isRemote) { super.updateTick(par1, par2, par3, par4, par5); if (par1.getBlockLightValue(par2, par3 + 1, par4) >= 9 && par5.nextInt(7) == 0) { this.markOrGrowMarked(par1, par2, par3, par4, par5); } } } /** * Gets the block's texture. Args: side, meta */ @SideOnly(Side.CLIENT) public IIcon getIcon(int par1, int par2) { par2 &= 7; return icon[MathHelper.clamp_int(par2, 0, 5)]; } /** * Returns an item stack containing a single instance of the current block type. 'i' is the block's subtype/damage * and is ignored for blocks which do not support subtypes. Blocks which cannot be harvested should return null. */ protected ItemStack createStackedBlock(int par1) { return new ItemStack(this, 1, par1 & 3); } public void markOrGrowMarked(World par1, int par2, int par3, int par4, Random par5) { int l = par1.getBlockMetadata(par2, par3, par4); if ((l & == 0) { par1.setBlockMetadataWithNotify(par2, par3, par4, l | 8, 4); } else { this.growTree(par1, par2, par3, par4, par5); } } public void growTree(World par1, int par2, int par3, int par4, Random par5) { if (!net.minecraftforge.event.terraingen.TerrainGen.saplingGrowTree(par1, par5, par2, par3, par4)) return; int l = par1.getBlockMetadata(par2, par3, par4) & 7; Object object = par5.nextInt(10) == 0 ? new WorldGenBigTree(true) : new WorldGenTrees(true); int i1 = 0; int j1 = 0; boolean flag = false; switch (l) { case 0: default: break; case 1: label78: for (i1 = 0; i1 >= -1; --i1) { for (j1 = 0; j1 >= -1; --j1) { if (this.isSameSapling(par1, par2 + i1, par3, par4 + j1, 1) && this.isSameSapling(par1, par2 + i1 + 1, par3, par4 + j1, 1) && this.isSameSapling(par1, par2 + i1, par3, par4 + j1 + 1, 1) && this.isSameSapling(par1, par2 + i1 + 1, par3, par4 + j1 + 1, 1)) { object = new WorldGenMegaPineTree(false, par5.nextBoolean()); flag = true; break label78; } } } if (!flag) { j1 = 0; i1 = 0; object = new WorldGenTaiga2(true); } break; case 2: object = new WorldGenForest(true, false); break; case 3: label93: for (i1 = 0; i1 >= -1; --i1) { for (j1 = 0; j1 >= -1; --j1) { if (this.isSameSapling(par1, par2 + i1, par3, par4 + j1, 3) && this.isSameSapling(par1, par2 + i1 + 1, par3, par4 + j1, 3) && this.isSameSapling(par1, par2 + i1, par3, par4 + j1 + 1, 3) && this.isSameSapling(par1, par2 + i1 + 1, par3, par4 + j1 + 1, 3)) { object = new WorldGenMegaJungle(true, 10, 20, 3, 3); flag = true; break label93; } } } if (!flag) { j1 = 0; i1 = 0; object = new WorldGenTrees(true, 4 + par5.nextInt(7), 3, 3, false); } break; case 4: object = new WorldGenSavannaTree(true); break; case 5: label108: for (i1 = 0; i1 >= -1; --i1) { for (j1 = 0; j1 >= -1; --j1) { if (this.isSameSapling(par1, par2 + i1, par3, par4 + j1, 5) && this.isSameSapling(par1, par2 + i1 + 1, par3, par4 + j1, 5) && this.isSameSapling(par1, par2 + i1, par3, par4 + j1 + 1, 5) && this.isSameSapling(par1, par2 + i1 + 1, par3, par4 + j1 + 1, 5)) { object = new WorldGenCanopyTree(true); flag = true; break label108; } } } if (!flag) { return; } } Block block = Blocks.air; if (flag) { par1.setBlock(par2 + i1, par3, par4 + j1, block, 0, 4); par1.setBlock(par2 + i1 + 1, par3, par4 + j1, block, 0, 4); par1.setBlock(par2 + i1, par3, par4 + j1 + 1, block, 0, 4); par1.setBlock(par2 + i1 + 1, par3, par4 + j1 + 1, block, 0, 4); } else { par1.setBlock(par2, par3, par4, block, 0, 4); } if (!((WorldGenerator)object).generate(par1, par5, par2 + i1, par3, par4 + j1)) { if (flag) { par1.setBlock(par2 + i1, par3, par4 + j1, this, l, 4); par1.setBlock(par2 + i1 + 1, par3, par4 + j1, this, l, 4); par1.setBlock(par2 + i1, par3, par4 + j1 + 1, this, l, 4); par1.setBlock(par2 + i1 + 1, par3, par4 + j1 + 1, this, l, 4); } else { par1.setBlock(par2, par3, par4, this, l, 4); } } } public boolean isSameSapling(World par1, int par2, int par3, int par4, int par5) { return par1.getBlock(par2, par3, par4) == this && (par1.getBlockMetadata(par2, par3, par4) & 7) == par5; } /** * Determines the damage on the item the block drops. Used in cloth and wood. */ public int damageDropped(int par1) { return MathHelper.clamp_int(par1 & 7, 0, 5); } /** * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) */ @SideOnly(Side.CLIENT) public void getSubBlocks(Item par1, CreativeTabs par2, List par3) { par3.add(new ItemStack(par1, 1, 0)); par3.add(new ItemStack(par1, 1, 1)); } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister par1) { for (int i = 0; i < icon.length; ++i) { icon[i] = par1.registerIcon(this.getTextureName() + "_" + sapling_names[i]); } } public boolean func_149851_a(World p_149851_1_, int p_149851_2_, int p_149851_3_, int p_149851_4_, boolean p_149851_5_) { return true; } public boolean func_149852_a(World par1, Random par2, int par3, int par4, int par5) { return (double)par1.rand.nextFloat() < 0.45D; } public void func_149853_b(World par1, Random par2, int par3, int par4, int par5) { this.markOrGrowMarked(par1, par3, par4, par5, par2); } } And here is a snapshot of the item Icons (wich is wrong): and here a snapshot of the block texture when placed (wich is correct) Thanks in advice for all who will help me
-
[SOLVED] [1.7.2] Custom leaves always render in fancy graphic
JimiIT92 replied to JimiIT92's topic in Modder Support
I've add that line in the registerIcon method, not in the getIcon method, now i've changed it and placed it in the right place and it works! Thanks man! -
Hi guys I wanna ask you how to render my custom leaves in fast graphic too, like the normal leafes? Here is my BlockLeafMod file: package mod.mineworld.blocks.mod_plants; import java.util.List; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import mod.mineworld.MineWorld; import mod.mineworld.mod_tabs; import net.minecraft.block.BlockLeaves; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class BlockLeafMod extends BlockLeaves { public static final String[][] leaf_names = new String[][] {{"leaves_apple", "leaves_palm"}, {"leaves_apple_opaque", "leaves_palm_opaque"}}; public static final String[] leaf_types = new String[] {"apple", "palm"}; protected IIcon[][] icon = new IIcon[2][]; public BlockLeafMod() { this.setCreativeTab(mod_tabs.tabPlantsDecorations); this.setHardness(0.2F); this.setLightOpacity(1); this.setStepSound(soundTypeGrass); this.setTickRandomly(true); } protected void dropBlockAsItemWithChance(World par1, int par2, int par3, int par4, int par5, int par6) { if ((par5 & 3) == 0 && par1.rand.nextInt(par6) == 0) { this.dropBlockAsItem(par1, par2, par3, par4, new ItemStack(Items.apple, 1, 0)); } } protected int func_150123_b(int par1) { int j = super.func_150123_b(par1); if ((par1 & 3) == 3) { j = 40; } return j; } /** * Gets the block's texture. Args: side, meta */ @SideOnly(Side.CLIENT) public IIcon getIcon(int par1, int par2) { return (par2 & 3) == 1 ? this.icon[this.field_150127_b][1] : ((par2 & 3) == 3 ? this.icon[this.field_150127_b][3] : ((par2 & 3) == 2 ? this.icon[this.field_150127_b][2] : this.icon[this.field_150127_b][0])); } @SideOnly(Side.CLIENT) @Override public void registerBlockIcons(IIconRegister par1) { setGraphicsLevel(Minecraft.getMinecraft().gameSettings.fancyGraphics); for (int i = 0; i < leaf_names.length; ++i) { this.icon[i] = new IIcon[leaf_names[i].length]; for (int j = 0; j < leaf_names[i].length; ++j) { this.icon[i][j] = par1.registerIcon(MineWorld.MODID + ":mod_plants/" + leaf_names[i][j]); } } } public String[] func_150125_e() { return leaf_types; } /** * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) */ @SideOnly(Side.CLIENT) public void getSubBlocks(Item par1, CreativeTabs par2, List par3) { par3.add(new ItemStack(par1, 1, 0)); par3.add(new ItemStack(par1, 1, 1)); } /** * Returns an item stack containing a single instance of the current block type. 'i' is the block's subtype/damage * and is ignored for blocks which do not support subtypes. Blocks which cannot be harvested should return null. */ protected ItemStack createStackedBlock(int par1) { return new ItemStack(this, 1, par1 & 3); } /** * Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block. */ public boolean isOpaqueCube() { return false; } } and the ItemLeaf file: package mod.mineworld.blocks.mod_plants; import net.minecraft.block.Block; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; public class ItemLeaf extends ItemBlock { private final static String[] subNames = { "apple", "palm" }; public ItemLeaf(Block id) { super(id); setHasSubtypes(true); } @Override public int getMetadata (int damageValue) { return damageValue; } @Override public String getUnlocalizedName(ItemStack itemstack) { return getUnlocalizedName() + "." + subNames[itemstack.getItemDamage()]; } } Thanks in advice for all who will help me
-
[1.7.2] Providing power only for some specific metadata values
JimiIT92 replied to JimiIT92's topic in Modder Support
Ok so now i have: BlockOreSlab: package mod.mineworld.blocks.mod_ores; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import java.util.List; import java.util.Random; import mod.mineworld.mod_ores; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.ChatComponentText; import net.minecraft.util.Facing; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public abstract class BlockOreSlab extends Block { protected final boolean isDoubleSlab; private static boolean power = false; private static int power_level; private static int metadata; public BlockOreSlab(boolean par1, Material par2) { super(par2); this.isDoubleSlab = par1; if (par1) { this.opaque = true; } else { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); } this.setLightOpacity(0); } /** * Updates the blocks bounds based on its current state. Args: world, x, y, z */ public void setBlockBoundsBasedOnState(IBlockAccess par1, int par2, int par3, int par4) { if (this.isDoubleSlab) { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } else { boolean flag = (par1.getBlockMetadata(par2, par3, par4) & != 0; if (flag) { this.setBlockBounds(0.0F, 0.5F, 0.0F, 1.0F, 1.0F, 1.0F); } else { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); } } } /** * Sets the block's bounds for rendering it as an item */ public void setBlockBoundsForItemRender() { if (this.isDoubleSlab) { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } else { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); } } /** * Adds all intersecting collision boxes to a list. (Be sure to only add boxes to the list if they intersect the * mask.) Parameters: World, X, Y, Z, mask, list, colliding entity */ public void addCollisionBoxesToList(World par1, int par2, int par3, int par4, AxisAlignedBB par5, List par6, Entity par7) { this.setBlockBoundsBasedOnState(par1, par2, par3, par4); super.addCollisionBoxesToList(par1, par2, par3, par4, par5, par6, par7); } /** * Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block. */ public boolean isOpaqueCube() { return this.isDoubleSlab; } /** * Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY, hitZ, block metadata */ public int onBlockPlaced(World par1, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9) { metadata = par9; return this.isDoubleSlab ? par9 : (par5 != 0 && (par5 == 1 || (double)par7 <= 0.5D) ? par9 : par9 | ; } /** * Returns the quantity of items to drop on block destruction. */ public int quantityDropped(Random par1) { return this.isDoubleSlab ? 2 : 1; } /** * Determines the damage on the item the block drops. Used in cloth and wood. */ public int damageDropped(int par1) { return par1 & 7; } /** * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) */ public boolean renderAsNormalBlock() { return this.isDoubleSlab; } /** * Returns true if the given side of this block type should be rendered, if the adjacent block is at the given * coordinates. Args: blockAccess, x, y, z, side */ @SideOnly(Side.CLIENT) public boolean shouldSideBeRendered(IBlockAccess par1, int par2, int par3, int par4, int par5) { if (this.isDoubleSlab) { return super.shouldSideBeRendered(par1, par2, par3, par4, par5); } else if (par5 != 1 && par5 != 0 && !super.shouldSideBeRendered(par1, par2, par3, par4, par5)) { return false; } else { int i1 = par2 + Facing.offsetsXForSide[Facing.oppositeSide[par5]]; int j1 = par3 + Facing.offsetsYForSide[Facing.oppositeSide[par5]]; int k1 = par4 + Facing.offsetsZForSide[Facing.oppositeSide[par5]]; boolean flag = (par1.getBlockMetadata(i1, j1, k1) & != 0; return flag ? (par5 == 0 ? true : (par5 == 1 && super.shouldSideBeRendered(par1, par2, par3, par4, par5) ? true : !isBlockSingleSlab(par1.getBlock(par2, par3, par4)) || (par1.getBlockMetadata(par2, par3, par4) & == 0)) : (par5 == 1 ? true : (par5 == 0 && super.shouldSideBeRendered(par1, par2, par3, par4, par5) ? true : !isBlockSingleSlab(par1.getBlock(par2, par3, par4)) || (par1.getBlockMetadata(par2, par3, par4) & != 0)); } } @SideOnly(Side.CLIENT) private static boolean isBlockSingleSlab(Block par1) { return par1 == mod_ores.ore_single_slab; } public abstract String getFullSlabName(int var1); /** * Get the block's damage value (for use with pick block). */ public int getDamageValue(World par1, int par2, int par3, int par4) { return super.getDamageValue(par1, par2, par3, par4) & 7; } /** * Gets an item for the block being called on. Args: world, x, y, z */ @SideOnly(Side.CLIENT) public Item getItem(World par1, int par2, int par3, int par4) { return Item.getItemFromBlock(mod_ores.ore_single_slab); } /** * Can this block provide power. Only wire currently seems to have this change based on its state. */ public boolean canProvidePower() { //this.func_150002_b(metadata) gets the full slab name (see BlockHalfSlab) if(this.getFullSlabName(metadata).equals("tile.oreSingleSlab.copper")) { power = true; power_level = 10; return power;} else if (this.getFullSlabName(metadata).equals("tile.oreSingleSlab.bronze")) {power = true; power_level = 5; return power;} else {power = false; power_level = 0; return power; } } /** * Returns true if the block is emitting indirect/weak redstone power on the specified side. If isBlockNormalCube * returns true, standard redstone propagation rules will apply instead and this will not be called. Args: World, X, * Y, Z, side. Note that the side is reversed - eg it is 1 (up) when checking the bottom of the block. */ @Override public int isProvidingWeakPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) { return power_level; } } BlockHalfSlab package mod.mineworld.blocks.mod_ores; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import java.util.List; import java.util.Random; import mod.mineworld.MineWorld; import mod.mineworld.mod_ores; import mod.mineworld.mod_tabs; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ChatComponentText; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class BlockHalfSlab extends BlockOreSlab { public static final String[] slab_names = new String[] {"ruby", "sapphire", "copper", "bronze", "silver", "aluminium", "whiteMarble", "pinkMarble"}; @SideOnly(Side.CLIENT) private IIcon icon; private int power; public BlockHalfSlab(boolean par1) { super(par1, Material.rock); this.setCreativeTab(mod_tabs.tabOreBlock); } /** * Gets the block's texture. Args: side, meta */ @SideOnly(Side.CLIENT) public IIcon getIcon(int par1, int par2) { int k = par2 & 7; if (this.isDoubleSlab && (par2 & != 0) { par1 = 1; } return k == 0 ? (par1 != 1 && par1 != 0 ? mod_ores.block_ruby.getBlockTextureFromSide(par1) : mod_ores.block_ruby.getBlockTextureFromSide(par1)) : (k == 1 ? mod_ores.block_sapphire.getBlockTextureFromSide(par1) : (k == 2 ? mod_ores.block_copper.getBlockTextureFromSide(par1) : (k == 3 ? mod_ores.block_bronze.getBlockTextureFromSide(par1) : (k == 4 ? mod_ores.block_silver.getBlockTextureFromSide(par1) : (k == 5 ? mod_ores.block_aluminium.getIcon(par1, 0) : (k == 6 ? mod_ores.ore_marble.getBlockTextureFromSide(1) : this.blockIcon)))))); } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister par1) { this.blockIcon = par1.registerIcon(MineWorld.MODID + ":mod_ores/" + "oreMarble_pink"); this.icon = par1.registerIcon(MineWorld.MODID + ":mod_ores/" + "oreMarble_pink"); } public Item getItemDropped(int par1, Random par2, int par3) { return Item.getItemFromBlock(mod_ores.ore_single_slab); } /** * Returns an item stack containing a single instance of the current block type. 'i' is the block's subtype/damage * and is ignored for blocks which do not support subtypes. Blocks which cannot be harvested should return null. */ protected ItemStack createStackedBlock(int par1) { return new ItemStack(Item.getItemFromBlock(mod_ores.ore_single_slab), 2, par1 & 7); } public String getFullSlabName(int par1) { if (par1 < 0 || par1 >= slab_names.length) { par1 = 0; } return super.getUnlocalizedName() + "." + slab_names[par1]; } /** * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) */ @SideOnly(Side.CLIENT) public void getSubBlocks(Item par1, CreativeTabs par2, List par3) { if (par1 != Item.getItemFromBlock(mod_ores.ore_double_slab)) { for (int i = 0; i <= 7; ++i) { par3.add(new ItemStack(par1, 1, i)); } } } } ItemOreSlab package mod.mineworld.blocks.mod_ores; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import mod.mineworld.mod_ores; import net.minecraft.block.Block; import net.minecraft.block.BlockSlab; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class ItemOreSlab extends ItemBlock { private final boolean isDoubleSlab; private final BlockOreSlab single_slab; private final BlockOreSlab double_slab; public ItemOreSlab(Block block) { super(block); this.single_slab = mod_ores.ore_single_slab; this.double_slab = mod_ores.ore_double_slab; this.isDoubleSlab = false; this.setHasSubtypes(true); } /** * Gets an icon index based on an item's damage value */ @SideOnly(Side.CLIENT) public IIcon getIconFromDamage(int par1) { return Block.getBlockFromItem(this).getIcon(1, par1); } /** * Returns the metadata of the block which this Item (ItemBlock) can place */ public int getMetadata(int par1) { return par1; } /** * Returns the unlocalized name of this item. This version accepts an ItemStack so different stacks can have * different names based on their damage or NBT. */ public String getUnlocalizedName(ItemStack par1ItemStack) { return this.single_slab.getFullSlabName(par1ItemStack.getItemDamage()); } /** * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return * True if something happen and false if it don't. This is for ITEMS, not BLOCKS */ public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { if (this.isDoubleSlab) { return super.onItemUse(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10); } else if (par1ItemStack.stackSize == 0) { return false; } else if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) { return false; } else { Block block = par3World.getBlock(par4, par5, par6); int i1 = par3World.getBlockMetadata(par4, par5, par6); int j1 = i1 & 7; boolean flag = (i1 & != 0; if ((par7 == 1 && !flag || par7 == 0 && flag) && block == this.single_slab && j1 == par1ItemStack.getItemDamage()) { if (par3World.checkNoEntityCollision(this.double_slab.getCollisionBoundingBoxFromPool(par3World, par4, par5, par6)) && par3World.setBlock(par4, par5, par6, this.double_slab, j1, 3)) { par3World.playSoundEffect((double)((float)par4 + 0.5F), (double)((float)par5 + 0.5F), (double)((float)par6 + 0.5F), this.double_slab.stepSound.func_150496_b(), (this.double_slab.stepSound.getVolume() + 1.0F) / 2.0F, this.double_slab.stepSound.getPitch() * 0.8F); --par1ItemStack.stackSize; } return true; } else { return this.func_150946_a(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7) ? true : super.onItemUse(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10); } } } @SideOnly(Side.CLIENT) public boolean func_150936_a(World par1, int par2, int par3, int par4, int par5, EntityPlayer par6, ItemStack par7) { int i1 = par2; int j1 = par3; int k1 = par4; Block block = par1.getBlock(par2, par3, par4); int l1 = par1.getBlockMetadata(par2, par3, par4); int i2 = l1 & 7; boolean flag = (l1 & != 0; if ((par5 == 1 && !flag || par5 == 0 && flag) && block == this.single_slab && i2 == par7.getItemDamage()) { return true; } else { if (par5 == 0) { --par3; } if (par5 == 1) { ++par3; } if (par5 == 2) { --par4; } if (par5 == 3) { ++par4; } if (par5 == 4) { --par2; } if (par5 == 5) { ++par2; } Block block1 = par1.getBlock(par2, par3, par4); int j2 = par1.getBlockMetadata(par2, par3, par4); i2 = j2 & 7; return block1 == this.single_slab && i2 == par7.getItemDamage() ? true : super.func_150936_a(par1, i1, j1, k1, par5, par6, par7); } } private boolean func_150946_a(ItemStack par1, EntityPlayer par2, World par3, int par4, int par5, int par6, int par7) { if (par7 == 0) { --par5; } if (par7 == 1) { ++par5; } if (par7 == 2) { --par6; } if (par7 == 3) { ++par6; } if (par7 == 4) { --par4; } if (par7 == 5) { ++par4; } Block block = par3.getBlock(par4, par5, par6); int i1 = par3.getBlockMetadata(par4, par5, par6); int j1 = i1 & 7; if (block == this.single_slab && j1 == par1.getItemDamage()) { if (par3.checkNoEntityCollision(this.double_slab.getCollisionBoundingBoxFromPool(par3, par4, par5, par6)) && par3.setBlock(par4, par5, par6, this.double_slab, j1, 3)) { par3.playSoundEffect((double)((float)par4 + 0.5F), (double)((float)par5 + 0.5F), (double)((float)par6 + 0.5F), this.double_slab.stepSound.func_150496_b(), (this.double_slab.stepSound.getVolume() + 1.0F) / 2.0F, this.double_slab.stepSound.getPitch() * 0.8F); --par1.stackSize; } return true; } else { return false; } } } The last two functions in ItemOreSlab has not a simple name because i don't know what they represent so i can't "translate" them -
Hi guys! I'm creating a new flowers but my question is: how can i place this new flowers in the vanilla Flower Pot (so without creating a specific new one) ? Here is my BlockFlowerMod file: package mod.mineworld.blocks.mod_plants; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import java.util.List; import mod.mineworld.MineWorld; import mod.mineworld.mod_plants; import mod.mineworld.mod_tabs; import net.minecraft.block.Block; import net.minecraft.block.BlockBush; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; public class BlockFlowerMod extends BlockBush { private static final String[][] flower_names = new String[][] {{"blue_flower"}}; public static final String[] names = new String[] {"blueFlower"}; public static final String[] dandelion = new String[] {"dandelion"}; @SideOnly(Side.CLIENT) private IIcon[] icon; private int metadata; public BlockFlowerMod(int par1) { super(Material.plants); this.metadata = par1; this.setCreativeTab(mod_tabs.tabPlantsDecorations); this.setStepSound(Block.soundTypeGrass); } /** * Gets the block's texture. Args: side, meta */ @SideOnly(Side.CLIENT) public IIcon getIcon(int par1, int par2) { if (par2 >= this.icon.length) { par2 = 0; } return this.icon[par2]; } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister par1) { this.icon = new IIcon[flower_names[this.metadata].length]; for (int i = 0; i < this.icon.length; ++i) { this.icon[i] = par1.registerIcon(MineWorld.MODID + ":mod_plants/" + flower_names[this.metadata][i]); } } /** * Determines the damage on the item the block drops. Used in cloth and wood. */ public int damageDropped(int par1) { return par1; } /** * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) */ @SideOnly(Side.CLIENT) public void getSubBlocks(Item par1, CreativeTabs par2, List par3) { for (int i = 0; i < this.icon.length; ++i) { par3.add(new ItemStack(par1, 1, i)); } } public static BlockFlowerMod getBlock(String par1) { String[] astring = dandelion; int i = astring.length; int j; String s1; for (j = 0; j < i; ++j) { s1 = astring[j]; if (s1.equals(par1)) { return mod_plants.blue_flower; } } astring = names; i = astring.length; for (j = 0; j < i; ++j) { s1 = astring[j]; if (s1.equals(par1)) { return mod_plants.blue_flower; } } return null; } public static int func_149856_f(String par1) { int i; for (i = 0; i < dandelion.length; ++i) { if (dandelion[i].equals(par1)) { return i; } } for (i = 0; i < names.length; ++i) { if (names[i].equals(par1)) { return i; } } return 0; } } Thanks in advice for all who will help me
-
[1.7.2] Providing power only for some specific metadata values
JimiIT92 replied to JimiIT92's topic in Modder Support
Here is the "new" code: BlockOreSlab: package mod.mineworld.blocks.mod_ores; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import java.util.List; import java.util.Random; import mod.mineworld.mod_ores; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.ChatComponentText; import net.minecraft.util.Facing; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public abstract class BlockOreSlab extends Block { protected final boolean isDoubleSlab; private static final String __OBFID = "CL_00000253"; private static boolean power = false; private static int power_level; private static int metadata; public BlockOreSlab(boolean par1, Material par2) { super(par2); this.isDoubleSlab = par1; if (par1) { this.opaque = true; } else { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); } this.setLightOpacity(0); } /** * Updates the blocks bounds based on its current state. Args: world, x, y, z */ public void setBlockBoundsBasedOnState(IBlockAccess par1, int par2, int par3, int par4) { if (this.isDoubleSlab) { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } else { boolean flag = (par1.getBlockMetadata(par2, par3, par4) & != 0; if (flag) { this.setBlockBounds(0.0F, 0.5F, 0.0F, 1.0F, 1.0F, 1.0F); } else { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); } } } /** * Sets the block's bounds for rendering it as an item */ public void setBlockBoundsForItemRender() { if (this.isDoubleSlab) { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } else { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); } } /** * Adds all intersecting collision boxes to a list. (Be sure to only add boxes to the list if they intersect the * mask.) Parameters: World, X, Y, Z, mask, list, colliding entity */ public void addCollisionBoxesToList(World par1, int par2, int par3, int par4, AxisAlignedBB par5, List par6, Entity par7) { this.setBlockBoundsBasedOnState(par1, par2, par3, par4); super.addCollisionBoxesToList(par1, par2, par3, par4, par5, par6, par7); } /** * Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block. */ public boolean isOpaqueCube() { return this.isDoubleSlab; } /** * Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY, hitZ, block metadata */ public int onBlockPlaced(World par1, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9) { metadata = par9; return this.isDoubleSlab ? par9 : (par5 != 0 && (par5 == 1 || (double)par7 <= 0.5D) ? par9 : par9 | ; } /** * Returns the quantity of items to drop on block destruction. */ public int quantityDropped(Random par1) { return this.isDoubleSlab ? 2 : 1; } /** * Determines the damage on the item the block drops. Used in cloth and wood. */ public int damageDropped(int par1) { return par1 & 7; } /** * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) */ public boolean renderAsNormalBlock() { return this.isDoubleSlab; } /** * Returns true if the given side of this block type should be rendered, if the adjacent block is at the given * coordinates. Args: blockAccess, x, y, z, side */ @SideOnly(Side.CLIENT) public boolean shouldSideBeRendered(IBlockAccess par1, int par2, int par3, int par4, int par5) { if (this.isDoubleSlab) { return super.shouldSideBeRendered(par1, par2, par3, par4, par5); } else if (par5 != 1 && par5 != 0 && !super.shouldSideBeRendered(par1, par2, par3, par4, par5)) { return false; } else { int i1 = par2 + Facing.offsetsXForSide[Facing.oppositeSide[par5]]; int j1 = par3 + Facing.offsetsYForSide[Facing.oppositeSide[par5]]; int k1 = par4 + Facing.offsetsZForSide[Facing.oppositeSide[par5]]; boolean flag = (par1.getBlockMetadata(i1, j1, k1) & != 0; return flag ? (par5 == 0 ? true : (par5 == 1 && super.shouldSideBeRendered(par1, par2, par3, par4, par5) ? true : !isBlockSingleSlab(par1.getBlock(par2, par3, par4)) || (par1.getBlockMetadata(par2, par3, par4) & == 0)) : (par5 == 1 ? true : (par5 == 0 && super.shouldSideBeRendered(par1, par2, par3, par4, par5) ? true : !isBlockSingleSlab(par1.getBlock(par2, par3, par4)) || (par1.getBlockMetadata(par2, par3, par4) & != 0)); } } @SideOnly(Side.CLIENT) private static boolean isBlockSingleSlab(Block par1) { return par1 == mod_ores.ore_single_slab; } public abstract String getFullSlabName(int var1); /** * Get the block's damage value (for use with pick block). */ public int getDamageValue(World par1, int par2, int par3, int par4) { return super.getDamageValue(par1, par2, par3, par4) & 7; } /** * Gets an item for the block being called on. Args: world, x, y, z */ @SideOnly(Side.CLIENT) public Item getItem(World par1, int par2, int par3, int par4) { return Item.getItemFromBlock(mod_ores.ore_single_slab); } /** * Can this block provide power. Only wire currently seems to have this change based on its state. */ public boolean canProvidePower() { //this.func_150002_b(metadata) gets the full slab name (see BlockHalfSlab) if(this.getFullSlabName(metadata).equals("tile.oreSingleSlab.copper")) { power = true; power_level = 10; return power;} else if (this.getFullSlabName(metadata).equals("tile.oreSingleSlab.bronze")) {power = true; power_level = 5; return power;} else {power = false; power_level = 0; return power; } } /** * Returns true if the block is emitting indirect/weak redstone power on the specified side. If isBlockNormalCube * returns true, standard redstone propagation rules will apply instead and this will not be called. Args: World, X, * Y, Z, side. Note that the side is reversed - eg it is 1 (up) when checking the bottom of the block. */ @Override public int isProvidingWeakPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) { return power_level; } } BlockHalfSlab: package mod.mineworld.blocks.mod_ores; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import java.util.List; import java.util.Random; import mod.mineworld.MineWorld; import mod.mineworld.mod_ores; import mod.mineworld.mod_tabs; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ChatComponentText; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class BlockHalfSlab extends BlockOreSlab { public static final String[] slab_names = new String[] {"ruby", "sapphire", "copper", "bronze", "silver", "aluminium", "whiteMarble", "pinkMarble"}; @SideOnly(Side.CLIENT) private IIcon icon; private static final String __OBFID = "CL_00000320"; private int power; public BlockHalfSlab(boolean par1) { super(par1, Material.rock); this.setCreativeTab(mod_tabs.tabOreBlock); } /** * Gets the block's texture. Args: side, meta */ @SideOnly(Side.CLIENT) public IIcon getIcon(int par1, int par2) { int k = par2 & 7; if (this.isDoubleSlab && (par2 & != 0) { par1 = 1; } return k == 0 ? (par1 != 1 && par1 != 0 ? mod_ores.block_ruby.getBlockTextureFromSide(par1) : mod_ores.block_ruby.getBlockTextureFromSide(par1)) : (k == 1 ? mod_ores.block_sapphire.getBlockTextureFromSide(par1) : (k == 2 ? mod_ores.block_copper.getBlockTextureFromSide(par1) : (k == 3 ? mod_ores.block_bronze.getBlockTextureFromSide(par1) : (k == 4 ? mod_ores.block_silver.getBlockTextureFromSide(par1) : (k == 5 ? mod_ores.block_aluminium.getIcon(par1, 0) : (k == 6 ? mod_ores.ore_marble.getBlockTextureFromSide(1) : this.blockIcon)))))); } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister par1) { this.blockIcon = par1.registerIcon(MineWorld.MODID + ":mod_ores/" + "oreMarble_pink"); this.icon = par1.registerIcon(MineWorld.MODID + ":mod_ores/" + "oreMarble_pink"); } public Item getItemDropped(int par1, Random par2, int par3) { return Item.getItemFromBlock(mod_ores.ore_single_slab); } /** * Returns an item stack containing a single instance of the current block type. 'i' is the block's subtype/damage * and is ignored for blocks which do not support subtypes. Blocks which cannot be harvested should return null. */ protected ItemStack createStackedBlock(int par1) { return new ItemStack(Item.getItemFromBlock(mod_ores.ore_single_slab), 2, par1 & 7); } public String getFullSlabName(int par1) { if (par1 < 0 || par1 >= slab_names.length) { par1 = 0; } return super.getUnlocalizedName() + "." + slab_names[par1]; } /** * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) */ @SideOnly(Side.CLIENT) public void getSubBlocks(Item par1, CreativeTabs par2, List par3) { if (par1 != Item.getItemFromBlock(mod_ores.ore_double_slab)) { for (int i = 0; i <= 7; ++i) { par3.add(new ItemStack(par1, 1, i)); } } } } And the ItemOreSlab file (sorry i was forget it ) package mod.mineworld.blocks.mod_ores; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import mod.mineworld.mod_ores; import net.minecraft.block.Block; import net.minecraft.block.BlockSlab; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class ItemOreSlab extends ItemBlock { private final boolean isDoubleSlab; private final BlockOreSlab single_slab; private final BlockOreSlab double_slab; private static final String __OBFID = "CL_00000071"; public ItemOreSlab(Block block) { super(block); this.single_slab = mod_ores.ore_single_slab; this.double_slab = mod_ores.ore_double_slab; this.isDoubleSlab = false; this.setHasSubtypes(true); } /** * Gets an icon index based on an item's damage value */ @SideOnly(Side.CLIENT) public IIcon getIconFromDamage(int par1) { return Block.getBlockFromItem(this).getIcon(1, par1); } /** * Returns the metadata of the block which this Item (ItemBlock) can place */ public int getMetadata(int par1) { return par1; } /** * Returns the unlocalized name of this item. This version accepts an ItemStack so different stacks can have * different names based on their damage or NBT. */ public String getUnlocalizedName(ItemStack par1ItemStack) { return this.single_slab.getFullSlabName(par1ItemStack.getItemDamage()); } /** * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return * True if something happen and false if it don't. This is for ITEMS, not BLOCKS */ public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { if (this.isDoubleSlab) { return super.onItemUse(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10); } else if (par1ItemStack.stackSize == 0) { return false; } else if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) { return false; } else { Block block = par3World.getBlock(par4, par5, par6); int i1 = par3World.getBlockMetadata(par4, par5, par6); int j1 = i1 & 7; boolean flag = (i1 & != 0; if ((par7 == 1 && !flag || par7 == 0 && flag) && block == this.single_slab && j1 == par1ItemStack.getItemDamage()) { if (par3World.checkNoEntityCollision(this.double_slab.getCollisionBoundingBoxFromPool(par3World, par4, par5, par6)) && par3World.setBlock(par4, par5, par6, this.double_slab, j1, 3)) { par3World.playSoundEffect((double)((float)par4 + 0.5F), (double)((float)par5 + 0.5F), (double)((float)par6 + 0.5F), this.double_slab.stepSound.func_150496_b(), (this.double_slab.stepSound.getVolume() + 1.0F) / 2.0F, this.double_slab.stepSound.getPitch() * 0.8F); --par1ItemStack.stackSize; } return true; } else { return this.func_150946_a(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7) ? true : super.onItemUse(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10); } } } @SideOnly(Side.CLIENT) public boolean func_150936_a(World par1, int par2, int par3, int par4, int par5, EntityPlayer par6, ItemStack par7) { int i1 = par2; int j1 = par3; int k1 = par4; Block block = par1.getBlock(par2, par3, par4); int l1 = par1.getBlockMetadata(par2, par3, par4); int i2 = l1 & 7; boolean flag = (l1 & != 0; if ((par5 == 1 && !flag || par5 == 0 && flag) && block == this.single_slab && i2 == par7.getItemDamage()) { return true; } else { if (par5 == 0) { --par3; } if (par5 == 1) { ++par3; } if (par5 == 2) { --par4; } if (par5 == 3) { ++par4; } if (par5 == 4) { --par2; } if (par5 == 5) { ++par2; } Block block1 = par1.getBlock(par2, par3, par4); int j2 = par1.getBlockMetadata(par2, par3, par4); i2 = j2 & 7; return block1 == this.single_slab && i2 == par7.getItemDamage() ? true : super.func_150936_a(par1, i1, j1, k1, par5, par6, par7); } } private boolean func_150946_a(ItemStack par1, EntityPlayer par2, World par3, int par4, int par5, int par6, int par7) { if (par7 == 0) { --par5; } if (par7 == 1) { ++par5; } if (par7 == 2) { --par6; } if (par7 == 3) { ++par6; } if (par7 == 4) { --par4; } if (par7 == 5) { ++par4; } Block block = par3.getBlock(par4, par5, par6); int i1 = par3.getBlockMetadata(par4, par5, par6); int j1 = i1 & 7; if (block == this.single_slab && j1 == par1.getItemDamage()) { if (par3.checkNoEntityCollision(this.double_slab.getCollisionBoundingBoxFromPool(par3, par4, par5, par6)) && par3.setBlock(par4, par5, par6, this.double_slab, j1, 3)) { par3.playSoundEffect((double)((float)par4 + 0.5F), (double)((float)par5 + 0.5F), (double)((float)par6 + 0.5F), this.double_slab.stepSound.func_150496_b(), (this.double_slab.stepSound.getVolume() + 1.0F) / 2.0F, this.double_slab.stepSound.getPitch() * 0.8F); --par1.stackSize; } return true; } else { return false; } } } -
Hi everybody! Here's is my question: i want to provide a power from a slab only if its metadata is 2 or 3. I have 8 half slabs wich have the same id but different metadata and i want that if this metadata value is 2 or 3 than the slab can provide power, else it can't... I don't know how to do this beacuse in the "canProvidePower" method i don't know how to get the block metadata... Here are the BlockOreSlab file and the (modded) BlockHalfSlab file BlockOreSlab package mod.mineworld.blocks.mod_ores; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import java.util.List; import java.util.Random; import mod.mineworld.mod_ores; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.ChatComponentText; import net.minecraft.util.Facing; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public abstract class BlockOreSlab extends Block { protected final boolean field_150004_a; private static final String __OBFID = "CL_00000253"; private static boolean power = false; private static int power_level; private static int metadata; public BlockOreSlab(boolean p_i45410_1_, Material p_i45410_2_) { super(p_i45410_2_); this.field_150004_a = p_i45410_1_; if (p_i45410_1_) { this.opaque = true; } else { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); } this.setLightOpacity(0); } /** * Updates the blocks bounds based on its current state. Args: world, x, y, z */ public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) { if (this.field_150004_a) { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } else { boolean flag = (p_149719_1_.getBlockMetadata(p_149719_2_, p_149719_3_, p_149719_4_) & != 0; if (flag) { this.setBlockBounds(0.0F, 0.5F, 0.0F, 1.0F, 1.0F, 1.0F); } else { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); } } } /** * Sets the block's bounds for rendering it as an item */ public void setBlockBoundsForItemRender() { if (this.field_150004_a) { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } else { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); } } /** * Adds all intersecting collision boxes to a list. (Be sure to only add boxes to the list if they intersect the * mask.) Parameters: World, X, Y, Z, mask, list, colliding entity */ public void addCollisionBoxesToList(World p_149743_1_, int p_149743_2_, int p_149743_3_, int p_149743_4_, AxisAlignedBB p_149743_5_, List p_149743_6_, Entity p_149743_7_) { this.setBlockBoundsBasedOnState(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_); super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); } /** * Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block. */ public boolean isOpaqueCube() { return this.field_150004_a; } /** * Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY, hitZ, block metadata */ public int onBlockPlaced(World p_149660_1_, int p_149660_2_, int p_149660_3_, int p_149660_4_, int p_149660_5_, float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_) { metadata = p_149660_9_; return this.field_150004_a ? p_149660_9_ : (p_149660_5_ != 0 && (p_149660_5_ == 1 || (double)p_149660_7_ <= 0.5D) ? p_149660_9_ : p_149660_9_ | ; } /** * Returns the quantity of items to drop on block destruction. */ public int quantityDropped(Random p_149745_1_) { return this.field_150004_a ? 2 : 1; } /** * Determines the damage on the item the block drops. Used in cloth and wood. */ public int damageDropped(int p_149692_1_) { return p_149692_1_ & 7; } /** * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) */ public boolean renderAsNormalBlock() { return this.field_150004_a; } /** * Returns true if the given side of this block type should be rendered, if the adjacent block is at the given * coordinates. Args: blockAccess, x, y, z, side */ @SideOnly(Side.CLIENT) public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) { if (this.field_150004_a) { return super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_); } else if (p_149646_5_ != 1 && p_149646_5_ != 0 && !super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_)) { return false; } else { int i1 = p_149646_2_ + Facing.offsetsXForSide[Facing.oppositeSide[p_149646_5_]]; int j1 = p_149646_3_ + Facing.offsetsYForSide[Facing.oppositeSide[p_149646_5_]]; int k1 = p_149646_4_ + Facing.offsetsZForSide[Facing.oppositeSide[p_149646_5_]]; boolean flag = (p_149646_1_.getBlockMetadata(i1, j1, k1) & != 0; return flag ? (p_149646_5_ == 0 ? true : (p_149646_5_ == 1 && super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_) ? true : !func_150003_a(p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_)) || (p_149646_1_.getBlockMetadata(p_149646_2_, p_149646_3_, p_149646_4_) & == 0)) : (p_149646_5_ == 1 ? true : (p_149646_5_ == 0 && super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_) ? true : !func_150003_a(p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_)) || (p_149646_1_.getBlockMetadata(p_149646_2_, p_149646_3_, p_149646_4_) & != 0)); } } @SideOnly(Side.CLIENT) private static boolean func_150003_a(Block p_150003_0_) { return p_150003_0_ == mod_ores.ore_single_slab; } public abstract String func_150002_b(int var1); /** * Get the block's damage value (for use with pick block). */ public int getDamageValue(World p_149643_1_, int p_149643_2_, int p_149643_3_, int p_149643_4_) { return super.getDamageValue(p_149643_1_, p_149643_2_, p_149643_3_, p_149643_4_) & 7; } /** * Gets an item for the block being called on. Args: world, x, y, z */ @SideOnly(Side.CLIENT) public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) { return Item.getItemFromBlock(mod_ores.ore_single_slab); } /** * Can this block provide power. Only wire currently seems to have this change based on its state. */ public boolean canProvidePower() { //this.func_150002_b(metadata) gets the full slab name (see BlockHalfSlab) if(this.func_150002_b(metadata).equals("tile.oreSingleSlab.copper")) { power = true; power_level = 10; return power;} else if (this.func_150002_b(metadata).equals("tile.oreSingleSlab.bronze")) {power = true; power_level = 5; return power;} else {power = false; power_level = 0; return power; } } /** * Returns true if the block is emitting indirect/weak redstone power on the specified side. If isBlockNormalCube * returns true, standard redstone propagation rules will apply instead and this will not be called. Args: World, X, * Y, Z, side. Note that the side is reversed - eg it is 1 (up) when checking the bottom of the block. */ @Override public int isProvidingWeakPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) { return power_level; } } BlockHalfSlab package mod.mineworld.blocks.mod_ores; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import java.util.List; import java.util.Random; import mod.mineworld.MineWorld; import mod.mineworld.mod_ores; import mod.mineworld.mod_tabs; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ChatComponentText; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class BlockHalfSlab extends BlockOreSlab { public static final String[] field_150006_b = new String[] {"ruby", "sapphire", "copper", "bronze", "silver", "aluminium", "whiteMarble", "pinkMarble"}; @SideOnly(Side.CLIENT) private IIcon field_150007_M; private static final String __OBFID = "CL_00000320"; private int power; public BlockHalfSlab(boolean p_i45431_1_) { super(p_i45431_1_, Material.rock); this.setCreativeTab(mod_tabs.tabOreBlock); } /** * Gets the block's texture. Args: side, meta */ @SideOnly(Side.CLIENT) public IIcon getIcon(int p_149691_1_, int p_149691_2_) { int k = p_149691_2_ & 7; if (this.field_150004_a && (p_149691_2_ & != 0) { p_149691_1_ = 1; } return k == 0 ? (p_149691_1_ != 1 && p_149691_1_ != 0 ? mod_ores.block_ruby.getBlockTextureFromSide(p_149691_1_) : mod_ores.block_ruby.getBlockTextureFromSide(p_149691_1_)) : (k == 1 ? mod_ores.block_sapphire.getBlockTextureFromSide(p_149691_1_) : (k == 2 ? mod_ores.block_copper.getBlockTextureFromSide(p_149691_1_) : (k == 3 ? mod_ores.block_bronze.getBlockTextureFromSide(p_149691_1_) : (k == 4 ? mod_ores.block_silver.getBlockTextureFromSide(p_149691_1_) : (k == 5 ? mod_ores.block_aluminium.getIcon(p_149691_1_, 0) : (k == 6 ? mod_ores.ore_marble.getBlockTextureFromSide(1) : this.blockIcon)))))); } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister p_149651_1_) { this.blockIcon = p_149651_1_.registerIcon(MineWorld.MODID + ":mod_ores/" + "oreMarble_pink"); this.field_150007_M = p_149651_1_.registerIcon(MineWorld.MODID + ":mod_ores/" + "oreMarble_pink"); } public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { return Item.getItemFromBlock(mod_ores.ore_single_slab); } /** * Returns an item stack containing a single instance of the current block type. 'i' is the block's subtype/damage * and is ignored for blocks which do not support subtypes. Blocks which cannot be harvested should return null. */ protected ItemStack createStackedBlock(int p_149644_1_) { return new ItemStack(Item.getItemFromBlock(mod_ores.ore_single_slab), 2, p_149644_1_ & 7); } public String func_150002_b(int p_150002_1_) { if (p_150002_1_ < 0 || p_150002_1_ >= field_150006_b.length) { p_150002_1_ = 0; } return super.getUnlocalizedName() + "." + field_150006_b[p_150002_1_]; } /** * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) */ @SideOnly(Side.CLIENT) public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_) { if (p_149666_1_ != Item.getItemFromBlock(mod_ores.ore_double_slab)) { for (int i = 0; i <= 7; ++i) { p_149666_3_.add(new ItemStack(p_149666_1_, 1, i)); } } } } Actually it works but if i place another block that is "power-allowed" it gives power to blocks who is not allowed too Here is a video to better explain what i'm saying https://www.youtube.com/watch?v=KZWkWKck-FI&feature=youtu.be Thanks in advice for all who will help me
-
Hi everibody Here is my problem: when i shot a custom arrow and hit a player, on him it doesn't render the custom arrow but the normal one... Here is all the code of my arrow: In the main mod file EntityRegistry.registerModEntity(EntityRubyArrow.class, "RubyArrow", 1, this, 128, 1, true); In the sub mod file public static Item ruby_arrow; ruby_arrow = new Item().setCreativeTab(CreativeTabs.tabCombat).setUnlocalizedName("arrowRuby").setTextureName(MineWorld.MODID + ":mod_ores/" + "rubyArrow"); GameRegistry.registerItem(ruby_arrow, "arrowRuby"); public static DamageSource causeRubyArrowDamage (EntityRubyArrow par0EntityOreArrow, Entity par1Entity) { return (new EntityDamageSourceIndirect("RubyArrow", par0EntityOreArrow, par1Entity)).setProjectile(); } The Entity file package mod.mineworld.items.entity.mod_ores; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import java.util.List; import mod.mineworld.mod_ores; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.IProjectile; import net.minecraft.entity.monster.EntityEnderman; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.play.server.S2BPacketChangeGameState; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.Vec3; import net.minecraft.world.World; public class EntityRubyArrow extends EntityArrow implements IProjectile { private int field_145791_d = -1; private int field_145792_e = -1; private int field_145789_f = -1; private Block field_145790_g; private int inData; private boolean inGround; public int damageIndex = -1; private Item arrows; private int ticksInGround; private int ticksInAir; private double damage = 2.0D; /** * The amount of knockback an arrow applies when it hits a mob. */ private int knockbackStrength; private static final String __OBFID = "CL_00001715"; public EntityRubyArrow(World par1World) { super(par1World); this.renderDistanceWeight = 10.0D; this.setSize(0.5F, 0.5F); } public EntityRubyArrow(World par1World, double par2, double par4, double par6) { super(par1World); this.renderDistanceWeight = 10.0D; this.setSize(0.5F, 0.5F); this.setPosition(par2, par4, par6); this.yOffset = 0.0F; } public EntityRubyArrow(World par1World, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase, float par4, float par5) { super(par1World); this.renderDistanceWeight = 10.0D; this.shootingEntity = par2EntityLivingBase; if (par2EntityLivingBase instanceof EntityPlayer) { this.canBePickedUp = 1; } this.posY = par2EntityLivingBase.posY + (double)par2EntityLivingBase.getEyeHeight() - 0.10000000149011612D; double d0 = par3EntityLivingBase.posX - par2EntityLivingBase.posX; double d1 = par3EntityLivingBase.boundingBox.minY + (double)(par3EntityLivingBase.height / 3.0F) - this.posY; double d2 = par3EntityLivingBase.posZ - par2EntityLivingBase.posZ; double d3 = (double)MathHelper.sqrt_double(d0 * d0 + d2 * d2); if (d3 >= 1.0E-7D) { float f2 = (float)(Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F; float f3 = (float)(-(Math.atan2(d1, d3) * 180.0D / Math.PI)); double d4 = d0 / d3; double d5 = d2 / d3; this.setLocationAndAngles(par2EntityLivingBase.posX + d4, this.posY, par2EntityLivingBase.posZ + d5, f2, f3); this.yOffset = 0.0F; float f4 = (float)d3 * 0.2F; this.setThrowableHeading(d0, d1 + (double)f4, d2, par4, par5); } } public EntityRubyArrow(World par1World, EntityLivingBase par2EntityLivingBase, float par3, int par7, Item par8) { super(par1World); this.renderDistanceWeight = 10.0D; this.shootingEntity = par2EntityLivingBase; this.damageIndex = par7; this.arrows = par8; if (par2EntityLivingBase instanceof EntityPlayer) { this.canBePickedUp = 1; } this.setSize(0.5F, 0.5F); this.setLocationAndAngles(par2EntityLivingBase.posX, par2EntityLivingBase.posY + (double)par2EntityLivingBase.getEyeHeight(), par2EntityLivingBase.posZ, par2EntityLivingBase.rotationYaw, par2EntityLivingBase.rotationPitch); this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F); this.posY -= 0.10000000149011612D; this.posZ -= (double)(MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F); this.setPosition(this.posX, this.posY, this.posZ); this.yOffset = 0.0F; this.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI)); this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI)); this.motionY = (double)(-MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI)); this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, par3 * 1.5F, 1.0F); } protected void entityInit() { this.dataWatcher.addObject(16, Byte.valueOf((byte)0)); } /** * Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction. */ public void setThrowableHeading(double par1, double par3, double par5, float par7, float par8) { float f2 = MathHelper.sqrt_double(par1 * par1 + par3 * par3 + par5 * par5); par1 /= (double)f2; par3 /= (double)f2; par5 /= (double)f2; par1 += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)par8; par3 += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)par8; par5 += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)par8; par1 *= (double)par7; par3 *= (double)par7; par5 *= (double)par7; this.motionX = par1; this.motionY = par3; this.motionZ = par5; float f3 = MathHelper.sqrt_double(par1 * par1 + par5 * par5); this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(par1, par5) * 180.0D / Math.PI); this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(par3, (double)f3) * 180.0D / Math.PI); this.ticksInGround = 0; } /** * Sets the position and rotation. Only difference from the other one is no bounding on the rotation. Args: posX, * posY, posZ, yaw, pitch */ @SideOnly(Side.CLIENT) public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9) { this.setPosition(par1, par3, par5); this.setRotation(par7, par8); } /** * Sets the velocity to the args. Args: x, y, z */ @SideOnly(Side.CLIENT) public void setVelocity(double par1, double par3, double par5) { this.motionX = par1; this.motionY = par3; this.motionZ = par5; if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) { float f = MathHelper.sqrt_double(par1 * par1 + par5 * par5); this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(par1, par5) * 180.0D / Math.PI); this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(par3, (double)f) * 180.0D / Math.PI); this.prevRotationPitch = this.rotationPitch; this.prevRotationYaw = this.rotationYaw; this.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch); this.ticksInGround = 0; } } /** * Called to update the entity's position/logic. */ public void onUpdate() { super.onEntityUpdate(); if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) { float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f) * 180.0D / Math.PI); } Block block = this.worldObj.getBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f); if (block.getMaterial() != Material.air) { block.setBlockBoundsBasedOnState(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f); AxisAlignedBB axisalignedbb = block.getCollisionBoundingBoxFromPool(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f); if (axisalignedbb != null && axisalignedbb.isVecInside(this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ))) { this.inGround = true; } } if (this.arrowShake > 0) { --this.arrowShake; } if (this.inGround) { int j = this.worldObj.getBlockMetadata(this.field_145791_d, this.field_145792_e, this.field_145789_f); if (block == this.field_145790_g && j == this.inData) { ++this.ticksInGround; if (this.ticksInGround == 1200) { this.setDead(); } } else { this.inGround = false; this.motionX *= (double)(this.rand.nextFloat() * 0.2F); this.motionY *= (double)(this.rand.nextFloat() * 0.2F); this.motionZ *= (double)(this.rand.nextFloat() * 0.2F); this.ticksInGround = 0; this.ticksInAir = 0; } } else { ++this.ticksInAir; Vec3 vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ); Vec3 vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); MovingObjectPosition movingobjectposition = this.worldObj.func_147447_a(vec31, vec3, false, true, false); vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ); vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); if (movingobjectposition != null) { vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord); } Entity entity = null; List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D)); double d0 = 0.0D; int i; float f1; for (i = 0; i < list.size(); ++i) { Entity entity1 = (Entity)list.get(i); if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5)) { f1 = 0.3F; AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand((double)f1, (double)f1, (double)f1); MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec31, vec3); if (movingobjectposition1 != null) { double d1 = vec31.distanceTo(movingobjectposition1.hitVec); if (d1 < d0 || d0 == 0.0D) { entity = entity1; d0 = d1; } } } } if (entity != null) { movingobjectposition = new MovingObjectPosition(entity); } if (movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer)movingobjectposition.entityHit; if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer && !((EntityPlayer)this.shootingEntity).canAttackPlayer(entityplayer)) { movingobjectposition = null; } } float f2; float f4; if (movingobjectposition != null) { if (movingobjectposition.entityHit != null) { f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); int k = MathHelper.ceiling_double_int((double)f2 * this.damage); if (this.getIsCritical()) { k += this.rand.nextInt(k / 2 + 2); } DamageSource damagesource = null; if (this.shootingEntity == null) { damagesource = mod_ores.causeRubyArrowDamage(this, this); } else { damagesource = mod_ores.causeRubyArrowDamage(this, this.shootingEntity); } if (this.isBurning() && !(movingobjectposition.entityHit instanceof EntityEnderman)) { movingobjectposition.entityHit.setFire(5); } if (movingobjectposition.entityHit.attackEntityFrom(damagesource, (float)k)) { if (movingobjectposition.entityHit instanceof EntityLivingBase) { EntityLivingBase entitylivingbase = (EntityLivingBase)movingobjectposition.entityHit; if (!this.worldObj.isRemote) { entitylivingbase.setArrowCountInEntity(entitylivingbase.getArrowCountInEntity() + 1); } if (this.knockbackStrength > 0) { f4 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); if (f4 > 0.0F) { movingobjectposition.entityHit.addVelocity(this.motionX * (double)this.knockbackStrength * 0.6000000238418579D / (double)f4, 0.1D, this.motionZ * (double)this.knockbackStrength * 0.6000000238418579D / (double)f4); } } if (this.shootingEntity != null && this.shootingEntity instanceof EntityLivingBase) { EnchantmentHelper.func_151384_a(entitylivingbase, this.shootingEntity); EnchantmentHelper.func_151385_b((EntityLivingBase)this.shootingEntity, entitylivingbase); } if (this.shootingEntity != null && movingobjectposition.entityHit != this.shootingEntity && movingobjectposition.entityHit instanceof EntityPlayer && this.shootingEntity instanceof EntityPlayerMP) { ((EntityPlayerMP)this.shootingEntity).playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(6, 0.0F)); } } this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); if (!(movingobjectposition.entityHit instanceof EntityEnderman)) { this.setDead(); } } else { this.motionX *= -0.10000000149011612D; this.motionY *= -0.10000000149011612D; this.motionZ *= -0.10000000149011612D; this.rotationYaw += 180.0F; this.prevRotationYaw += 180.0F; this.ticksInAir = 0; } } else { this.field_145791_d = movingobjectposition.blockX; this.field_145792_e = movingobjectposition.blockY; this.field_145789_f = movingobjectposition.blockZ; this.field_145790_g = block; this.inData = this.worldObj.getBlockMetadata(this.field_145791_d, this.field_145792_e, this.field_145789_f); this.motionX = (double)((float)(movingobjectposition.hitVec.xCoord - this.posX)); this.motionY = (double)((float)(movingobjectposition.hitVec.yCoord - this.posY)); this.motionZ = (double)((float)(movingobjectposition.hitVec.zCoord - this.posZ)); f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); this.posX -= this.motionX / (double)f2 * 0.05000000074505806D; this.posY -= this.motionY / (double)f2 * 0.05000000074505806D; this.posZ -= this.motionZ / (double)f2 * 0.05000000074505806D; this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); this.inGround = true; this.arrowShake = 7; this.setIsCritical(false); if (this.field_145790_g.getMaterial() != Material.air) { this.field_145790_g.onEntityCollidedWithBlock(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f, this); } } } if (this.getIsCritical()) { for (i = 0; i < 4; ++i) { this.worldObj.spawnParticle("crit", this.posX + this.motionX * (double)i / 4.0D, this.posY + this.motionY * (double)i / 4.0D, this.posZ + this.motionZ * (double)i / 4.0D, -this.motionX, -this.motionY + 0.2D, -this.motionZ); } } this.posX += this.motionX; this.posY += this.motionY; this.posZ += this.motionZ; f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); for (this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f2) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) { ; } while (this.rotationPitch - this.prevRotationPitch >= 180.0F) { this.prevRotationPitch += 360.0F; } while (this.rotationYaw - this.prevRotationYaw < -180.0F) { this.prevRotationYaw -= 360.0F; } while (this.rotationYaw - this.prevRotationYaw >= 180.0F) { this.prevRotationYaw += 360.0F; } this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F; this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F; float f3 = 0.99F; f1 = 0.05F; if (this.isInWater()) { for (int l = 0; l < 4; ++l) { f4 = 0.25F; this.worldObj.spawnParticle("bubble", this.posX - this.motionX * (double)f4, this.posY - this.motionY * (double)f4, this.posZ - this.motionZ * (double)f4, this.motionX, this.motionY, this.motionZ); } f3 = 0.8F; } if (this.isWet()) { this.extinguish(); } this.motionX *= (double)f3; this.motionY *= (double)f3; this.motionZ *= (double)f3; this.motionY -= (double)f1; this.setPosition(this.posX, this.posY, this.posZ); this.func_145775_I(); } } /** * (abstract) Protected helper method to write subclass entity data to NBT. */ public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) { par1NBTTagCompound.setShort("xTile", (short)this.field_145791_d); par1NBTTagCompound.setShort("yTile", (short)this.field_145792_e); par1NBTTagCompound.setShort("zTile", (short)this.field_145789_f); par1NBTTagCompound.setShort("life", (short)this.ticksInGround); par1NBTTagCompound.setByte("inTile", (byte)Block.getIdFromBlock(this.field_145790_g)); par1NBTTagCompound.setByte("inData", (byte)this.inData); par1NBTTagCompound.setByte("shake", (byte)this.arrowShake); par1NBTTagCompound.setByte("inGround", (byte)(this.inGround ? 1 : 0)); par1NBTTagCompound.setByte("pickup", (byte)this.canBePickedUp); par1NBTTagCompound.setDouble("damage", this.damage); } /** * (abstract) Protected helper method to read subclass entity data from NBT. */ public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { this.field_145791_d = par1NBTTagCompound.getShort("xTile"); this.field_145792_e = par1NBTTagCompound.getShort("yTile"); this.field_145789_f = par1NBTTagCompound.getShort("zTile"); this.ticksInGround = par1NBTTagCompound.getShort("life"); this.field_145790_g = Block.getBlockById(par1NBTTagCompound.getByte("inTile") & 255); this.inData = par1NBTTagCompound.getByte("inData") & 255; this.arrowShake = par1NBTTagCompound.getByte("shake") & 255; this.inGround = par1NBTTagCompound.getByte("inGround") == 1; if (par1NBTTagCompound.hasKey("damage", 99)) { this.damage = par1NBTTagCompound.getDouble("damage"); } if (par1NBTTagCompound.hasKey("pickup", 99)) { this.canBePickedUp = par1NBTTagCompound.getByte("pickup"); } else if (par1NBTTagCompound.hasKey("player", 99)) { this.canBePickedUp = par1NBTTagCompound.getBoolean("player") ? 1 : 0; } } /** * Called by a player entity when they collide with an entity */ public void onCollideWithPlayer(EntityPlayer par1EntityPlayer) { if (!this.worldObj.isRemote && this.inGround && this.arrowShake <= 0) { boolean flag = this.canBePickedUp == 1 || this.canBePickedUp == 2 && par1EntityPlayer.capabilities.isCreativeMode; if (this.canBePickedUp == 1 && !par1EntityPlayer.inventory.addItemStackToInventory(new ItemStack(arrows, 1))) { flag = false; } if (flag) { this.playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); par1EntityPlayer.onItemPickup(this, 1); this.setDead(); } } } /** * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to * prevent them from trampling crops */ protected boolean canTriggerWalking() { return false; } @SideOnly(Side.CLIENT) public float getShadowSize() { return 0.0F; } public void setDamage(double par1) { this.damage = par1; } public double getDamage() { return this.damage; } /** * Sets the amount of knockback the arrow applies when it hits a mob. */ public void setKnockbackStrength(int par1) { this.knockbackStrength = par1; } /** * If returns false, the item will not inflict any damage against entities. */ public boolean canAttackWithItem() { return false; } /** * Whether the arrow has a stream of critical hit particles flying behind it. */ public void setIsCritical(boolean par1) { byte b0 = this.dataWatcher.getWatchableObjectByte(16); if (par1) { this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 1))); } else { this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & -2))); } } /** * Whether the arrow has a stream of critical hit particles flying behind it. */ public boolean getIsCritical() { byte b0 = this.dataWatcher.getWatchableObjectByte(16); return (b0 & 1) != 0; } public int getDamageIndex(){ return this.damageIndex; } } The Rendering file package mod.mineworld.items.render; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import mod.mineworld.MineWorld; import mod.mineworld.items.entity.mod_ores.EntityRubyArrow; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.entity.Render; import net.minecraft.entity.Entity; import net.minecraft.util.ChatComponentText; import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; @SideOnly(Side.CLIENT) public class RenderRubyArrow extends Render { private static ResourceLocation arrowTextures = new ResourceLocation(MineWorld.MODID + ":" + "textures/entity/mod_ores/ruby_arrow.png"); private static final String __OBFID = "CL_00000978"; /** * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1, * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that. */ public void doRender(EntityRubyArrow par1EntityArrow, double par2, double par4, double par6, float par8, float par9) { this.bindEntityTexture(par1EntityArrow); GL11.glPushMatrix(); GL11.glTranslatef((float)par2, (float)par4, (float)par6); GL11.glRotatef(par1EntityArrow.prevRotationYaw + (par1EntityArrow.rotationYaw - par1EntityArrow.prevRotationYaw) * par9 - 90.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(par1EntityArrow.prevRotationPitch + (par1EntityArrow.rotationPitch - par1EntityArrow.prevRotationPitch) * par9, 0.0F, 0.0F, 1.0F); Tessellator tessellator = Tessellator.instance; byte b0 = 0; float f2 = 0.0F; float f3 = 0.5F; float f4 = (float)(0 + b0 * 10) / 32.0F; float f5 = (float)(5 + b0 * 10) / 32.0F; float f6 = 0.0F; float f7 = 0.15625F; float f8 = (float)(5 + b0 * 10) / 32.0F; float f9 = (float)(10 + b0 * 10) / 32.0F; float f10 = 0.05625F; GL11.glEnable(GL12.GL_RESCALE_NORMAL); float f11 = (float)par1EntityArrow.arrowShake - par9; if (f11 > 0.0F) { float f12 = -MathHelper.sin(f11 * 3.0F) * f11; GL11.glRotatef(f12, 0.0F, 0.0F, 1.0F); } GL11.glRotatef(45.0F, 1.0F, 0.0F, 0.0F); GL11.glScalef(f10, f10, f10); GL11.glTranslatef(-4.0F, 0.0F, 0.0F); GL11.glNormal3f(f10, 0.0F, 0.0F); tessellator.startDrawingQuads(); tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)f6, (double)f8); tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)f7, (double)f8); tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)f7, (double)f9); tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)f6, (double)f9); tessellator.draw(); GL11.glNormal3f(-f10, 0.0F, 0.0F); tessellator.startDrawingQuads(); tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)f6, (double)f8); tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)f7, (double)f8); tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)f7, (double)f9); tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)f6, (double)f9); tessellator.draw(); for (int i = 0; i < 4; ++i) { GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); GL11.glNormal3f(0.0F, 0.0F, f10); tessellator.startDrawingQuads(); tessellator.addVertexWithUV(-8.0D, -2.0D, 0.0D, (double)f2, (double)f4); tessellator.addVertexWithUV(8.0D, -2.0D, 0.0D, (double)f3, (double)f4); tessellator.addVertexWithUV(8.0D, 2.0D, 0.0D, (double)f3, (double)f5); tessellator.addVertexWithUV(-8.0D, 2.0D, 0.0D, (double)f2, (double)f5); tessellator.draw(); } GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); } /** * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. */ protected ResourceLocation getEntityTexture(EntityRubyArrow par1EntityArrow) { return arrowTextures; } /** * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. */ protected ResourceLocation getEntityTexture(Entity par1Entity) { return this.getEntityTexture((EntityRubyArrow)par1Entity); } /** * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1, * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that. */ public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { this.doRender((EntityRubyArrow)par1Entity, par2, par4, par6, par8, par9); } } and in the ClientProxy file RenderingRegistry.registerEntityRenderingHandler(EntityRubyArrow.class, new RenderRubyArrow()); And here is a video to better explain what is my problem https://www.youtube.com/watch?v=Idh-jZlxXyk&feature=youtu.be Thanks in advice for all who will help me