Jump to content

SeKtOR

Members
  • Posts

    26
  • Joined

  • Last visited

Everything posted by SeKtOR

  1. Currently i have my own custom demension and everything works fine(portal, etc..). I wan't to make custom world generation not like surface, etc.. So i need explain how that works? public void generateNetherTerrain(int x, int y, byte[] par3ArrayOfByte) { byte var4 = 4; byte var5 = 32; int var6 = var4 + 1; byte var7 = 17; int var8 = var4 + 1; this.noiseField = this.initializeNoiseField(this.noiseField, x * var4, 0, y * var4, var6, var7, var8); for (int var9 = 0; var9 < var4; ++var9) { for (int var10 = 0; var10 < var4; ++var10) { for (int var11 = 0; var11 < 16; ++var11) { double var12 = 0.125D; double var14 = this.noiseField[((var9 + 0) * var8 + var10 + 0) * var7 + var11 + 0]; double var16 = this.noiseField[((var9 + 0) * var8 + var10 + 1) * var7 + var11 + 0]; double var18 = this.noiseField[((var9 + 1) * var8 + var10 + 0) * var7 + var11 + 0]; double var20 = this.noiseField[((var9 + 1) * var8 + var10 + 1) * var7 + var11 + 0]; double var22 = (this.noiseField[((var9 + 0) * var8 + var10 + 0) * var7 + var11 + 1] - var14) * var12; double var24 = (this.noiseField[((var9 + 0) * var8 + var10 + 1) * var7 + var11 + 1] - var16) * var12; double var26 = (this.noiseField[((var9 + 1) * var8 + var10 + 0) * var7 + var11 + 1] - var18) * var12; double var28 = (this.noiseField[((var9 + 1) * var8 + var10 + 1) * var7 + var11 + 1] - var20) * var12; for (int var30 = 0; var30 < 8; ++var30) { double var31 = 0.25D; double var33 = var14; double var35 = var16; double var37 = (var18 - var14) * var31; double var39 = (var20 - var16) * var31; for (int var41 = 0; var41 < 4; ++var41) { int var42 = var41 + var9 * 4 << 11 | 0 + var10 * 4 << 7 | var11 * 8 + var30; short var43 = 128; double var44 = 0.25D; double var46 = var33; double var48 = (var35 - var33) * var44; for (int var50 = 0; var50 < 4; ++var50) { int var51 = 0; if (var11 * 8 + var30 < var5) { var51 = Block.lavaStill.blockID; } if (var46 > 0.0D) { var51 = Block.netherrack.blockID; } par3ArrayOfByte[var42] = (byte)var51; var42 += var43; var46 += var48; } var33 += var37; var35 += var39; } var14 += var22; var16 += var24; var18 += var26; var20 += var28; } } } } } /** * name based on ChunkProviderGenerate */ public void replaceBlocksForBiome(int par1, int par2, byte[] par3ArrayOfByte) { ChunkProviderEvent.ReplaceBiomeBlocks event = new ChunkProviderEvent.ReplaceBiomeBlocks(this, par1, par2, par3ArrayOfByte, null); MinecraftForge.EVENT_BUS.post(event); if (event.getResult() == Result.DENY) return; byte var4 = 64; double var5 = 0.03125D; this.slowsandNoise = this.slowsandGravelNoiseGen.generateNoiseOctaves(this.slowsandNoise, par1 * 16, par2 * 16, 0, 16, 16, 1, var5, var5, 1.0D); this.gravelNoise = this.slowsandGravelNoiseGen.generateNoiseOctaves(this.gravelNoise, par1 * 16, 109, par2 * 16, 16, 1, 16, var5, 1.0D, var5); this.netherrackExclusivityNoise = this.netherrackExculsivityNoiseGen.generateNoiseOctaves(this.netherrackExclusivityNoise, par1 * 16, par2 * 16, 0, 16, 16, 1, var5 * 2.0D, var5 * 2.0D, var5 * 2.0D); for (int var7 = 0; var7 < 16; ++var7) { for (int var8 = 0; var8 < 16; ++var8) { boolean var9 = this.slowsandNoise[var7 + var8 * 16] + this.hellRNG.nextDouble() * 0.2D > 0.0D; boolean var10 = this.gravelNoise[var7 + var8 * 16] + this.hellRNG.nextDouble() * 0.2D > 0.0D; int var11 = (int)(this.netherrackExclusivityNoise[var7 + var8 * 16] / 3.0D + 3.0D + this.hellRNG.nextDouble() * 0.25D); int var12 = -1; byte var13 = (byte)Block.netherrack.blockID; byte var14 = (byte)Block.netherrack.blockID; for (int var15 = 127; var15 >= 0; --var15) { int var16 = (var8 * 16 + var7) * 128 + var15; if (var15 < 127 - this.hellRNG.nextInt(5) && var15 > 0 + this.hellRNG.nextInt(5)) { byte var17 = par3ArrayOfByte[var16]; if (var17 == 0) { var12 = -1; } else if (var17 == Block.netherrack.blockID) { if (var12 == -1) { if (var11 <= 0) { var13 = 0; var14 = (byte)Block.netherrack.blockID; } else if (var15 >= var4 - 4 && var15 <= var4 + 1) { var13 = (byte)Block.netherrack.blockID; var14 = (byte)Block.netherrack.blockID; if (var10) { var13 = (byte)Block.gravel.blockID; } if (var10) { var14 = (byte)Block.netherrack.blockID; } if (var9) { var13 = (byte)Block.slowSand.blockID; } if (var9) { var14 = (byte)Block.slowSand.blockID; } } if (var15 < var4 && var13 == 0) { var13 = (byte)Block.lavaStill.blockID; } var12 = var11; if (var15 >= var4 - 1) { par3ArrayOfByte[var16] = var13; } else { par3ArrayOfByte[var16] = var14; } } else if (var12 > 0) { --var12; par3ArrayOfByte[var16] = var14; } } } else { par3ArrayOfByte[var16] = (byte)Block.bedrock.blockID; } } } } } P.S. Sorry for bad english
  2. I can only make without losing metadata(for detect bounds) old style half-slabs. I want make vanilla like custom half slabs with metadata(x:0, x:1, etc...). So i need help! Current code(doesn't work properly): package mypackage; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import java.util.List; import java.util.Random; import net.minecraft.block.*; import net.minecraft.item.*; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.block.material.Material; import net.minecraft.entity.Entity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.Facing; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class BlockHalfSlabs extends BlockContainer { private boolean isDoubleSlabs = false; private boolean isDownSlab = false; public BlockHalfSlabs(int par1, Material par2, boolean par3, int par4) { super(par1, par4, par2); this.setRequiresSelfNotify(); this.blockIndexInTexture = par4; this.setLightOpacity(0); this.isDoubleSlabs = par3; if (isDoubleSlabs) { opaqueCubeLookup[par1] = true; } else { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); } } public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int x, int y, int z) { if (this.isDoubleSlabs) { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } else { TileEntityHalfSlab t = (TileEntityHalfSlab) par1IBlockAccess.getBlockTileEntity(x, y, z); if (t.isDownSlab) { 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); } } } public void setBlockBoundsForItemRender() { if (this.isDoubleSlabs) { 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); } } public int getBlockTextureFromSide(int par1) { return this.getBlockTextureFromSideAndMetadata(par1, 0); } @SideOnly(Side.CLIENT) public void getSubBlocks(int par1, CreativeTabs tab, List subItems) { for (int ix = 0; ix < 16; ix++) { subItems.add(new ItemStack(this, 1, ix)); } } /** * if the specified block is in the given AABB, add its collision bounding box to the given list /** * Returns the block texture based on the side being looked at. Args: side */ @Override public int getBlockTextureFromSideAndMetadata (int side, int metadata) { return this.blockIndexInTexture + metadata; } public String getTextureFile () { return ClientProxy.BLOCK_PNG; } /** * Returns the quantity of items to drop on block destruction. */ @Override public int damageDropped (int metadata) { return metadata; } @Override public int onBlockPlaced(World par1World, int x, int y, int z, int par5, float par6, float par7, float par8, int par9) { if(par7 <= 0.5F) { isDownSlab = true; } else { isDownSlab = false; } par1World.scheduleBlockUpdate(x, y, z, blockID, 1); System.out.println(isDownSlab); return par9; } public void updateTick(World par1World, int x, int y, int z, Random par5Random) { TileEntityHalfSlab t = (TileEntityHalfSlab) par1World.getBlockTileEntity(x, y, z); t.isDownSlab = this.isDownSlab; System.out.println(t.isDownSlab); } public void addCollidingBlockToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity) { this.setBlockBoundsBasedOnState(par1World, par2, par3, par4); super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); } /** * 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.isDoubleSlabs; } /** * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) */ public boolean renderAsNormalBlock() { return this.isDoubleSlabs; } @SideOnly(Side.CLIENT) /** * 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 */ public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) { if (this.isDoubleSlabs) { return super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, par5); } else if (par5 != 1 && par5 != 0 && !super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, par5)) { return false; } else { TileEntityHalfSlab t = (TileEntityHalfSlab) par1IBlockAccess.getBlockTileEntity(par2, par3, par4); return t.isDownSlab ? (par5 == 0 ? true : (par5 == 1 && super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, par5) ? true : !isBlockSingleSlab(par1IBlockAccess.getBlockId(par2, par3, par4)) || (par1IBlockAccess.getBlockMetadata(par2, par3, par4) & == 0)) : (par5 == 1 ? true : (par5 == 0 && super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, par5) ? true : !isBlockSingleSlab(par1IBlockAccess.getBlockId(par2, par3, par4)) || (par1IBlockAccess.getBlockMetadata(par2, par3, par4) & != 0)); } } @SideOnly(Side.CLIENT) /** * Takes a block ID, returns true if it's the same as the ID for a stone or wooden single slab. */ private static boolean isBlockSingleSlab(int par0) { return par0 == my_mod_file.blockLimestoneStoneHalfSlab.blockID || par0 == my_mod_file.blockLimestoneBrickHalfSlab.blockID; } /** * Get the block's damage value (for use with pick block). */ public int getDamageValue(World par1World, int par2, int par3, int par4) { return super.getDamageValue(par1World, par2, par3, par4) & 7; } @SideOnly(Side.CLIENT) /** * only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative) */ public int idPicked(World par1World, int par2, int par3, int par4) { return isBlockSingleSlab(this.blockID) ? this.blockID : (this.blockID == my_mod_file.blockLimestoneStoneHalfSlabDouble.blockID ? my_mod_file.blockLimestoneStoneHalfSlab.blockID : (this.blockID == my_mod_file.blockLimestoneBrickHalfSlabDouble.blockID ? my_mod_file.blockLimestoneBrickHalfSlab.blockID : my_mod_file.blockLimestoneBrickHalfSlab.blockID)); } /** * Returns the quantity of items to drop on block destruction. */ public int quantityDropped(Random par1Random) { return this.isDoubleSlabs ? 2 : 1; } /** * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) */ public boolean hasTileEntity(int metadata) { return true; } public TileEntity createNewTileEntity(World par1World) { try { return new TileEntityHalfSlab(); } catch (Exception var3) { throw new RuntimeException(var3); } } } P.S. Sorry for ban eglish P.S.S. Thanks in advance!
  3. I need explain how to make updateTick work properly in smp(server). Current bug: when all players left chunk block forget about "updateTick". Off course i found solution is "Packets", but i don't know how(i need example of properly server and client sync). Current code: package my_epic_package; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraft.world.IBlockAccess; public class BlockSomething extends Block { private int index = 0; public BlockSomething(int par1, int par2, boolean par3) { super(par1, par2, Material.rock); if(!par3) { this.index = 16; } else { this.index = 0; } } public void onBlockAdded(World par1World, int x, int y, int z) { par1World.scheduleBlockUpdateFromLoad(x, y, z, blockID, 20); par1World.scheduleBlockUpdate(x, y, z, blockID, 20); } public void updateTick(World par1World, int x, int y, int z, Random par5Random) { super.updateTick(par1World, x, y, z, par5Random); // I don't know why... if(!par1World.isRemote) { // My epic code } } public int getBlockTextureFromSide(int i) { switch(i) { case 0: return 82 - this.index; case 1: return 80 - this.index; default: return 81 - this.index; } } public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) { return true; } public boolean renderAsNormalBlock() { return false; } public String getTextureFile () { return ClientProxy.BLOCK_PNG; } } P.S. Sorry for bad english
  4. I succesfully make something like "Drop Collector", but i need code to kill items(instanly) on collussion. P.S. Collusion works fine, but before items killed(code stolen from cactus) it collide over 90 times...
  5. For ore generation: 1. Register you world generator in main mod class(@Init) GameRegistry.registerWorldGenerator(new MyReallyCoolAndEpicWorldGenerator()); 2. Create himself... package <you mod package>; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenMinable; // Import earth generator import cpw.mods.fml.common.IWorldGenerator; public class MyReallyCoolAndEpicWorldGenerator implements IWorldGenerator { @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { switch(world.provider.dimensionId) { // Checking world case -1: generateNether(world, random, chunkX*16, chunkZ*16); // Nether break; case 0: generateSurface(world, random, chunkX*16, chunkZ*16); // Earth(normal world) break; case 1: generateEnd(world, random, chunkX*16, chunkZ*16); // End(with dragon) break; } } public void generateNether(World par1World, Random rand, int par3, int par5) {} // Nether public void generateSurface() { // Earth for(int i = 0; i < 7; i++) // "7" max ore per chunk { int randPosX = par3 + rand.nextInt(16); int randPosY = rand.nextInt(128); // Ore generation up to 128 layer(y coordinate) int randPosZ = par5 + rand.nextInt(16); (new WorldGenMinable(<you block>.blockID, 10)).generate(par1World, rand, randPosX, randPosY, randPosZ); // "10" is max ore per correct place } // Finally we have 70(7*10) ore per chunk } public void generateEnd() {} // End generation } P.S. Sorry for bad english
  6. Maybe you based on 1.4.6 tutorial and something changed in 1.4.7(like shiftedIndex -> itemID)?
  7. 1. Setup "TickHandler" read in wiki about "Ticking" 2. Check player armor and do you "special effects" Example: For air(infinite bubble bar): thePlayer.air = 1; // Change to max air number, i forgot it
  8. You can't make something like "Speed Boots" because motionX, motionY, motionZ wont work in TickHandler...
  9. Maybe something like this? EntityYourName var14 = new EntityYourName(par1World, x, y, z) par1World.spawnEntityInWorld(var14);
  10. I find something strange: if enable fall damage and get it "motionY" will triggered and player make high jump...
  11. It's called "TextureFX", look at buildcraft sources or lava and water...
  12. I think this ticker dont work on server side because: @Override public EnumSet<TickType> ticks() { return EnumSet.of(TickType.PLAYER, TickType.CLIENT); }
  13. TickHandler(server) package (mod package); import java.util.EnumSet; import java.util.ArrayList; import java.util.Iterator; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.server.MinecraftServer; import net.minecraft.network.packet.Packet3Chat; // Will removed import net.minecraft.item.ItemStack; import cpw.mods.fml.common.ITickHandler; import cpw.mods.fml.common.TickType; import cpw.mods.fml.server.FMLServerHandler; import (mod package).*; public class TickHandler implements ITickHandler { @Override public void tickStart(EnumSet<TickType> type, Object... tickData) { if(type.equals(EnumSet.of(TickType.PLAYER))) { ArrayList players = (ArrayList) MinecraftServer.getServer().getConfigurationManager().playerEntityList; // Wlll replace with FMLServerHandler Iterator parray = players.iterator(); // Players armor check! while(parray.hasNext()) { EntityPlayerMP thePlayer = (EntityPlayerMP) parray.next(); ItemStack helmet = thePlayer.inventory.armorItemInSlot(3); ItemStack body = thePlayer.inventory.armorItemInSlot(2); ItemStack legs = thePlayer.inventory.armorItemInSlot(1); ItemStack boots = thePlayer.inventory.armorItemInSlot(0); if(helmet != null) { // do something... } if(body != null) { // do something... } if(legs != null) { // do something... } if(boots != null) { if(boots.itemID == (main mod class).bootsPremium.shiftedIndex) { System.out.println("Player has boots"); thePlayer.capabilities.allowFlying = true; thePlayer.capabilities.isFlying = true; thePlayer.motionY = 10.0; // Only for test thePlayer.fallDistance = 0; //System.out.println(thePlayer.motionY); } } } } // End Players armor check! } @Override public void tickEnd(EnumSet<TickType> type, Object... tickData) { } @Override public EnumSet<TickType> ticks() { return EnumSet.of(TickType.PLAYER); } @Override public String getLabel() { return null; } } Also in main mod class TickRegistry.registerTickHandler(new TickHandler(), Side.SERVER);
  14. I want make something like "Hugh Jump Boots". After some studying i can really understand java code and want code
  15. I tried "System.out.println(thePlayer.motionY)" it's print "-0.078.....". Also if i run across world nothing changed motionY ignored... P.S. Changed motionY *= 3.0 to motionY += 3.0. Nothing changed... Current code: thePlayer.capabilities.allowFlying = true; thePlayer.capabilities.isFlying = true; thePlayer.motionY += 3.0; // Only for test thePlayer.fallDistance = 0;
  16. I solved my issue with "CommonTickHandler" big thanks to guy, who help me... Current issue with thePlayer.motionY(it's not working or i do something wrong) My code //thePlayer - instance of EntityPlayerMP thePlayer.capabilities.allowFlying = true; thePlayer.motionY *= 3.0; // Only for test thePlayer.capabilities.isFlying = true; thePlayer.fallDistance = 0; Player motionY doent's changed, but fallDistance work... P.S. Sorry for bad english...
  17. Sorry about this, but can you fix my code? Forge tick system, much harder than modloader... public class TickHandler implements ITickHandler { @Override public void tickStart(EnumSet<TickType> type, Object... tickData) { if(type.equals(EnumSet.of(TickType.PLAYER))) { onServerTick(MinecraftServer.getServer()); } } public void onServerTick(MinecraftServer server) { if(*** Player armor check ***) { // do something } System.out.println("Tick"); } @Override public void tickEnd(EnumSet<TickType> type, Object... tickData) { } @Override public EnumSet<TickType> ticks() { return EnumSet.of(TickType.SERVER, TickType.PLAYER); } @Override public String getLabel() { return null; } }
  18. ITickingArmor doesn't include in forge 1.4.6. Any other solutions to check player amor? P.S. My ticker public class TickHandler implements ITickHandler { @Override public void tickStart(EnumSet<TickType> type, Object... tickData) { if(type.equals(EnumSet.of(TickType.SERVER))) { onServerTick(MinecraftServer.getServer()); } } public void onServerTick(MinecraftServer server) { System.out.println("Tick"); } @Override public void tickEnd(EnumSet<TickType> type, Object... tickData) { } @Override public EnumSet<TickType> ticks() { return EnumSet.of(TickType.WORLD, TickType.SERVER, TickType.PLAYER); } @Override public String getLabel() { return null; } }
×
×
  • Create New...

Important Information

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