Jump to content

Moritz

Forge Modder
  • Posts

    512
  • Joined

  • Last visited

Everything posted by Moritz

  1. Question: Is it possible to send a packet from a container to a container? And if yes! how do i make it?
  2. Found the Trouble. The ICrafting function is using the Packet105UpdateProgressBar when the server is used. And that sends infos only via Shorts instead of The integer. So how can i fix this now?
  3. My trouble. When i upgrade my Chest over a short value then my Integer say, i am now a short. Now i am do not know what the bug is. so to see my bug here a video: and here is my code. https://www.dropbox.com/sh/idhacqfywayzlck/0YViVpNdFQ So how can i fix this?
  4. Why? when you really want something then you find a way. That was always my case .
  5. I started as noob with no clue about coding. And now i have made a lot of Cool technic stuff that helps people a lot out. and a lot of more things are planned! here my mod: speiger.jimdo.com
  6. You missunderstood me. I meant with if you know where to search not google. I meant a source. Any source you can find. ^^"
  7. gellegbs you do not have to use metadata for food. its a great way to save itemids but its much more work to install them (my thinking) here is a universal class i made for the baconMod. Its handel the food and crafing in it^^" A thing before! Do not tell: this is wrong or something! Everything in this code i post now is working correct: Normal Food: package minecraftwero.baconMod.common.items; import java.util.List; import minecraftwero.baconMod.Bacon; import minecraftwero.baconMod.common.config.BaconItems; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemFood; import net.minecraft.item.ItemStack; import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; /** * * @author Speiger * */ public class ItemBaconFood extends ItemFood { private String name; public String texture; private PotionEffect[] potion; public ItemBaconFood(int par1, int par2, boolean par3, String par4, String par5, PotionEffect...par7) { super(par1, par2, par3); this.setCreativeTab(Bacon.baconMod); name = par4; texture = par5; potion = par7; this.setTextureName(par5); } public ItemBaconFood(int par1, int par2, boolean par3, String par4, String par5) { this(par1, par2, par3, par4, par5, new PotionEffect(0, 0, 0)); } public String getItemDisplayName(ItemStack par1) { return name; } @SideOnly(Side.CLIENT) @Override public void registerIcons(IconRegister par1IconRegister) { this.itemIcon = par1IconRegister.registerIcon(texture); } @Override public ItemStack onEaten(ItemStack par1, World par2, EntityPlayer par3) { --par1.stackSize; par3.getFoodStats().addStats(this); par2.playSoundAtEntity(par3, "random.burp", 0.5F, par2.rand.nextFloat() * 0.1F + 0.9F); addPotions(par1, par2, par3); return par1; } public void addPotions(ItemStack par1, World par2, EntityPlayer par3) { for(int i = 0; i<potion.length;i++) { if(potion[i] != null && potion[i].getPotionID() > 0 && !par2.isRemote) { par3.addPotionEffect(new PotionEffect(potion[i])); } } } } This FoodClass handel also LanguageRegisty.addName so that is no longer needed Now to the Crafting Food class: It handels a damagecrafting. you can choose how much damage the food after eating gets (more than 1 time eatable) and also (when its a container item) how much damage it gets when you use it at crafting. Crafting Food: package minecraftwero.baconMod.common.items; import java.util.List; import minecraftwero.baconMod.Bacon; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumAction; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class CraftingFood extends Item { private String var1; private String var2; private int var3; private boolean var4; private int var5; private int var6; private PotionEffect[] var7; public CraftingFood(int par1, int damage, int damageonCraft, int damageonEat, int extrafood, boolean alwaysEatable, String name, String texture, PotionEffect...effect) { super(par1); this.setCreativeTab(Bacon.baconMod); this.setNoRepair(); this.var5 = damageonCraft; var6 = damageonEat; this.setMaxDamage(damage); this.setMaxStackSize(1); var1 = name; var2 = texture; var3 = extrafood; var4 = alwaysEatable; var7 = effect; this.setTextureName(texture); } public CraftingFood(int par1, int damage, int extrafood, boolean alwaysEatable, String name, String texture) { this(par1, damage, 1, 1, extrafood, alwaysEatable, name, texture); } @Override public boolean doesContainerItemLeaveCraftingGrid(ItemStack par1ItemStack) { return false; } @Override public String getItemDisplayName(ItemStack par1ItemStack) { return var1; } public int getMaxItemUseDuration(ItemStack par1ItemStack) { return 32; } public EnumAction getItemUseAction(ItemStack par1ItemStack) { return EnumAction.eat; } @Override public ItemStack onItemRightClick(ItemStack par1, World par2, EntityPlayer par3) { if(par3.canEat(var4)) { par3.setItemInUse(par1, this.getMaxItemUseDuration(par1)); } return par1; } @Override public ItemStack onEaten(ItemStack par1, World par2, EntityPlayer par3) { par1.damageItem(var6, par3); par3.getFoodStats().addStats(var3, 0.6F); par2.playSoundAtEntity(par3, "random.burp", 0.5F, par2.rand.nextFloat() * 0.1F + 0.9F); addPotionEffect(par1, par2, par3); return par1; } public void addPotionEffect(ItemStack par1, World par2, EntityPlayer par3) { for(int i = 0; i<var7.length;i++) { if(var7[i].getPotionID() > 0 && var7[i] != null) { par3.addPotionEffect(var7[i]); } } } @SideOnly(Side.CLIENT) @Override public void registerIcons(IconRegister par1IconRegister) { this.itemIcon = par1IconRegister.registerIcon(var2); } @Override public ItemStack getContainerItemStack(ItemStack itemStack) { itemStack.setItemDamage(itemStack.getItemDamage()+var5); return itemStack; } } I hope these examples help you out^^"
  8. Yeah you are right people should learn java. But and that i think is interesting. I had just readed 1 book of java (which did not really help me) and i have not much problems with coding. When i have a problem then i solve it very fast. I think people can learn as much java if they want, but when they do not know how to search for something what they need, like: how do i make a tool that does not extends the vanilla codes. then they do not need to learn anything. Also i think just give people a chance and give him little hints instead of telling them: What are you doing with that and that. I mean when they still asking the same question then you can say it or in another stiuation: give hints but remeber them you should learn java. I myself use minecraft to understand how to programm, i mean to get the thinking how to solve something, or how to start with something. Also when i have a error that i know where i can search. i only ask about things i never coded before But enought about my self^^" But you get the point?
  9. A question why don't you use HashMaps which are a little bit shorter code and also easier to extend when you do it write^^"
  10. But their right. When you do not know how to handel a problem then you should learn. I give you just a hint how it should look like when you get everything done than its good. This way i explained to you is ok but when you extend it to much then it could lag.
  11. A thing before you can not load tile entities on your way (or i am wrong) you have to add a new form of block placing for that. And textures for that you can use extended item. public class yourTile extends TileEntity { public int facing = 0; public int extendedMeta = 0; public int getExtendedMeta() { return extendedMeta; } public void setExtendedMeta(int i) { extendedMeta = i; } public int getFacing() { return facing; } public void setFacing(int i) { facing = i; } } this should stay at your tile entity. And when you place the itemBlock you say place your normal block with meta 0 and set the extended meta in the tile like you want. And when you want to know which name it has and which texture then you look at the extended meta id. By the way with names and creative tab i would use itemNBTData. is a lot easier^^".
  12. That do not help. I register the fluid and then the block. like bc. But i have no Textures and no name.
  13. Yeah i have problems with the fulids^^" Now the flowing part and the pumping in a tank works fine. But the fluid is not registered in the fluid dictionary and the name will be showen as: Fluid.Animal Gas Also the texture does not work! ConfigClass (Registerring) package speiger.src.api.common.config; import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.src.ModLoader; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import speiger.src.api.common.blocks.BlockGas; import speiger.src.api.common.functions.PathProxy; import speiger.src.api.common.functions.TextureRegister; import speiger.src.api.common.items.ItemGasAbsorber; import speiger.src.api.common.items.ItemGasBucket; import speiger.src.api.common.items.LiquidContainer; import speiger.src.api.common.items.itemblocks.ItemBlockGas; import speiger.src.api.common.lib.APIIDs; import speiger.src.api.common.lib.APIStrings; public class APIItemBlockConfig { public static ConfigCore cc; public static APIItems ai; public static APIIDs ids; public static APIStrings as; public static TextureRegister at; public static boolean isBetas = true; public static void initialisiereItemBlocks() { ai.animalGas = new Fluid("Animal Gas").setGaseous(true).setDensity(1000); FluidRegistry.registerFluid(ai.animalGas); ai.gas = new BlockGas(cc.getBlock("block", "Gas Block", 802)); PathProxy.registBlock(ai.gas, ItemBlockGas.class, "Schweine Furze"); ai.animalGas.setBlockID(ai.gas); ai.gasBucket = new ItemGasBucket(cc.getItem("items", "Gas Bucket", 26041)); FluidContainerRegistry.registerFluidContainer(new FluidContainerData(new FluidStack(ai.animalGas, 1000), new ItemStack(APIItems.gasBucket), new ItemStack(Item.bucketEmpty))); ai.gasAbsorber = new ItemGasAbsorber(cc.getItem("items", "Vacum Pump", 26042)); PathProxy.registItem(ai.gasAbsorber, "Gas Pumpe"); ai.gasCell = new LiquidContainer(cc.getItem("items", "Gas Cell", 26043), "Gas Cell", at.gasZelle, 64, "Animal Gas", 1000); PathProxy.registItem(ai.gasCell, "Gas Zelle"); ai.compressedGasCell = new LiquidContainer(cc.getItem("items", "Compressed Gas Cell", 26044), "Compressed Gas Cell", at.bigGasCell, 64, "Animal Gas", 5000); PathProxy.registItem(ai.compressedGasCell, "Komprimierte Gas Celle"); ai.gasCan = new LiquidContainer(cc.getItem("items", "Gas Can", 26045), "Gas Can", at.gasCan, 64, "Animal Gas", 1000); PathProxy.registItem(ai.gasCan, "Gas Kanne"); ai.compressedGasCan = new LiquidContainer(cc.getItem("items", "Compressed Gas Can", 26046), "Compressed Gas Can", at.bigGasCan, 64, "Animal Gas", 5000); PathProxy.registItem(ai.compressedGasCan, "Komprimierte Gas Kanne"); } } Block Class package speiger.src.api.common.blocks; import java.util.Collection; import java.util.Iterator; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.Icon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidBlock; import speiger.src.api.common.config.APIItems; import speiger.src.api.common.functions.TextureRegister; import speiger.src.api.common.functions.WorldReading; import cpw.mods.fml.common.Loader; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class BlockGas extends Block implements IFluidBlock { public Random rand = new Random(); public BlockGas(int par1) { super(par1, APIItems.GasMaterial); this.setTickRandomly(true); this.disableStats(); this.setHardness(100F); this.setLightOpacity(3); } @Override public boolean canCollideCheck(int par1, boolean par2) { return false; } public void setBlockBoundsForItemRender() { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } public boolean isBlockSolid(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) { return false; } @Override public boolean isBlockReplaceable(World world, int x, int y, int z) { return true; } @Override public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) { super.updateTick(par1World, par2, par3, par4, par5Random); this.notifyNeighbors(par1World, par2, par3, par4); if(!par1World.isRemote) { flowing(par1World, par2, par3, par4); removeBlock(par1World, par2, par3, par4); } par1World.scheduleBlockUpdate(par2, par3, par4, blockID, tickRate(par1World)); } private void removeBlock(World par1, int par2, int par3, int par4) { if(par3 >= 149) { if(par1.getRainStrength(1.0F) > 0.2D) { par1.setBlock(par2, par3, par4, 0); } } } @Override public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity) { super.onEntityCollidedWithBlock(par1World, par2, par3, par4, par5Entity); if(par5Entity instanceof EntityLiving) { EntityLiving el = (EntityLiving) par5Entity; Collection<PotionEffect> potion = el.getActivePotionEffects(); int i = 0; if(!potion.isEmpty()) { Iterator between = potion.iterator(); while(between.hasNext()) { PotionEffect current = (PotionEffect) between.next(); if(current.getPotionID() == Potion.confusion.id) { i = current.getDuration(); } } } if(rand.nextInt(20) == 0) { el.addPotionEffect(new PotionEffect(Potion.confusion.id, i+10, 3)); } } } public void flowing(World par0, int par1, int par2, int par3) { } public void onBlockAdded(World world, int i, int j, int k) { world.scheduleBlockUpdate(i, j, k, blockID, tickRate(world)); } @Override public int tickRate(World par1World) { return 5; } public void notifyNeighbors(World world, int i, int j, int k) { world.notifyBlocksOfNeighborChange(i, j, k, blockID); world.notifyBlocksOfNeighborChange(i, j - 1, k, blockID); world.notifyBlocksOfNeighborChange(i, j + 1, k, blockID); world.notifyBlocksOfNeighborChange(i - 1, j, k, blockID); world.notifyBlocksOfNeighborChange(i + 1, j, k, blockID); world.notifyBlocksOfNeighborChange(i, j, k - 1, blockID); world.notifyBlocksOfNeighborChange(i, j, k + 1, blockID); } @Override public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) { return null; } public boolean renderAsNormalBlock() { return false; } public boolean isOpaqueCube() { return false; } // @Override // public AxisAlignedBB getSelectedBoundingBoxFromPool(World par1, int par2, int par3, int par4) // { // return null; // } float[] biggnis = new float[]{0.0F, 0.1F, 0.2F, 0.3F, 0.4F, 0.5F, 0.6F, 0.7F, 0.8F, 0.9F, 0.95F, 0.96F}; public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) { int var5 = par1IBlockAccess.getBlockMetadata(par2, par3, par4); float var8 = 1.0F; if(var5 == 0) { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, var8, 1.0F); } else { this.setBlockBounds(0.0F, biggnis[var5], 0.0F, 1.0F, var8, 1.0F); } } private Icon[] gas = new Icon[6]; @Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister par1IconRegister) { for(int i = 0;i<gas.length;i++) { gas[i] = par1IconRegister.registerIcon(TextureRegister.gasTextures[i]); } } @Override @SideOnly(Side.CLIENT) public Icon getBlockTexture(IBlockAccess par1iBlockAccess, int par2, int par3, int par4, int par5) { return gas[par5]; } @Override @SideOnly(Side.CLIENT) public Icon getIcon(int par1, int par2) { return gas[par1]; } @Override public Fluid getFluid() { return APIItems.animalGas; } @Override public FluidStack drain(World world, int x, int y, int z, boolean doDrain) { int meta = world.getBlockMetadata(x, y, z); int backMeta = 10 - meta; FluidStack gas = new FluidStack(APIItems.animalGas, 100*backMeta); if(doDrain) { world.setBlockToAir(x, y, z); } return gas.copy(); } @Override public boolean canDrain(World world, int x, int y, int z) { return true; } } So what i am doing wrong? a view things before! i need this block class for my fluid because its my custom movement^^" Thanks for reading and i hope you have a solve/idea.
  14. I think you can detect how much per chunk was generated or how big the configuration is. at the moment i have no clue how to make it^^" But i was brainstorming.^^"
  15. @Diesieben i understand it like this: ModA & ModB again: ModA Generates 2 copper per chunk. ModB generates 3 Copper per chunk. Now ModA thinks ModB generates to much copper so my balance gets distroyed. Then ModA says ok i only accept only other copper from other mods if the Generation is lower or the same as my one. Am i right Mazetar?
  16. You use the function wrong. Its just a fuel register function like Modloader.addFuel.
  17. Make your custom food class and instead of calling the foodstats of the player you call the heal funtion at the entityplayer. Hope that helps
  18. i have also a feature bug . I made wireless redstone and you can choose is it a private reciver or a public reciver. (Private means only you can access it) And when you set it to private (only on server) and the wireless frequenz. Then the texture won't update . Only in this case. In all other cases it works . So i use it as feature.
  19. Forge has a EntityInteractEvent. So you can use that. That should work^^"
  20. Did you solve the problem with the itemframe alread? If not there should be a function which is called onInteractWithEntity(ItemStack par1, EntityPlayer player, EntityLivingBase par3) {}
  21. The last modjam was in the summer. I do not know when the next is. And gotoLink you did not read every post. Then you should know my plans. First we do not override any Vanilla class. We just exchange the inventory when someone join the dimenion. Another thing is we make the core mod at the modjam. And after the modjam we make the addons for it. And these addons override other mods.
  22. You can not access always accsses functions from a class like this: int time = World.getWorldTime(); that would not work because from where should he get the time. its like you want to know how much is in a cup, but you do not tell which cup. You had everything what you need. But the thing is you only can access the client side (on a server would it not work) make this instead of your old code: long clientTime; public boolean onTickInGame(float time, Minecraft instances) { clientTime = instances.theWorld.getWorldTime(); return false; } But this only works on client time^^"
  23. You can use the onItemUseFunction, or onRightclick function for that. That will be triggered before the block trigger the putItemin function^^"
×
×
  • Create New...

Important Information

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