SeKtOR
-
Posts
26 -
Joined
-
Last visited
Posts posted by SeKtOR
-
-
-
Thanks! I think this working...
-
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!
-
-
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
-
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...
-
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
-
P.S. It really works!
-
Maybe you based on 1.4.6 tutorial and something changed in 1.4.7(like shiftedIndex -> itemID)?
-
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
-
java.lang.ArrayIndexOutOfBoundsException: 31541
Block id must be(in forge) < 4096
-
I' making an armor mod
but i like to put some effects on my armor.
for that i need you'r help
helmet - allows breathing underwater
plate- heals you while in water *subject to change*
Leggings - allows you to "float" in water when your not moving.
boots - Allows you to move faster when your in water but move slower on land.
how i need to to that plzz help me
You can't make something like "Speed Boots" because motionX, motionY, motionZ wont work in TickHandler...
-
Maybe something like this?
EntityYourName var14 = new EntityYourName(par1World, x, y, z) par1World.spawnEntityInWorld(var14);
-
I find something strange: if enable fall damage and get it "motionY" will triggered and player make high jump...
-
-
It's called "TextureFX", look at buildcraft sources or lava and water...
-
I'm guessing this is in a tick handler, i'm having the same problem, it will update the velocity if the player takes damage it seems, so it could be that the velocity isn't updated through this method without something else happening to the player. Not sure how to do this
Here is the tick handler as i have it (i'm guessing his is similar)
import java.util.EnumSet; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.player.EntityPlayer; import cpw.mods.fml.common.ITickHandler; import cpw.mods.fml.common.TickType; public class ServerTickHandler implements ITickHandler { public static EntityPlayer thePlayer; @Override public void tickStart(EnumSet<TickType> type, Object... tickData) { if (type.equals(EnumSet.of(TickType.PLAYER))) { onPlayerTick((EntityPlayer)tickData[0]); } } @Override public void tickEnd(EnumSet<TickType> type, Object... tickData) { } @Override public EnumSet<TickType> ticks() { return EnumSet.of(TickType.PLAYER, TickType.CLIENT); } @Override public String getLabel() { return "My Tick"; } private void onPlayerTick(EntityPlayer player) { player.motionY = 1; } }
[edit]
whoops looks like he updated the thread whilst i was typing this
I think this ticker dont work on server side because:
@Override public EnumSet<TickType> ticks() { return EnumSet.of(TickType.PLAYER, TickType.CLIENT); }
-
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);
-
I want make something like "Hugh Jump Boots". After some studying i can really understand java code and want code
-
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;
-
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...
-
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; } }
-
Up...
-
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; } }
ChunkProvider explain...
in Modder Support
Posted
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?
P.S. Sorry for bad english