Everything posted by American2050
-
[Solved][1.9.4] PlaySound without world or get world from KeyInputEvent
I'm having a problem, I want to play a sound in Minecraft, each time a Key is pressed. The problem I'm having is that I need access to the world in order to play the sound. Is there either a way to get the world from the KeyInputEvent or to play a sound in a different way? Thanks a lot.
-
Future of Forge 1.9.4 now that 1.10 Forge is out
So you think we will never have a recommended version for 1.9.4 that was the last 1.9.x version, like we had for 1.7.10 or 1.8.9?
-
[1.10]Items duping when i drop them[solved]
Having exact same problem with items I spawn in the World, but not all of them, so not sure what could be going on, In the floor it looks like 1, when I pick up, there are 2, I drop those 2 and pick up 4, I drop those 4 and pick up 8. If I drop only 1 of the 2 I picked up, when I pick that one up, it's only one. So it only doubles when I drop all of them. I'm not sure if the problem could be the way my mod spawns those items in the world or what, they are just vanilla items, with custom names and enchanted. And for some reason, code that worked in 1.9.4 to spawn items in the world, not it spawns 2 items sometimes. This is an example of an item spawning twice if(!world.isRemote){ ItemStack dropX = new ItemStack(ModItems.clover,1,0); dropX.addEnchantment(Enchantment.getEnchantmentByID(35), 1); dropX.setStackDisplayName("Lucky is who Lucky gets"); EntityItem itemDropX = new EntityItem(world, player.posX+.5, player.posY+.5, player.posZ+.5, dropX); world.spawnEntityInWorld(itemDropX); } I added the !world.isRemote just in case, but all this code is already been called within a !world.isRemote PS: Other than that, I believe there is a Vanilla/Forge bug maybe? Whenever I drop all items in X slot in inventory, when I pick them up back, they double. Using forge 1.10-12.18.0.1984-1.10.0
-
News on the forge for MC 1.10 ???
How to know when 1.11 will be out? I really didn't know 1.10 was going to be out that fast after 1.9, I don't remember updates on Minecraft this short in time since 1.5 I remember Minecraft updates been a big thing, but this 1.10 brings almost nothing new or interesting to the game and I didn't notice any excitement on the Minecraft Communities I'm usually around.
-
Future of Forge 1.9.4 now that 1.10 Forge is out
The question is easy, I want to know what's gonna happen with Forge 1.9.4 and when we will get a recommended release, if so. And from now on, that 1.10 Forge is out, what gonna happen with the 1.9.4 Branch?
-
[1.9.4] Problems with GameRegistry.findItem
Whenever I try to use Item finalItem = GameRegistry.findItem(modID, itemSearched); I get an error saying it's deprecated, and to use Item.REGISTRY.getValue() but this last isn't a things. How would I look for an item/block of any mod?
-
[Solved] required-after can be optional?
I'm working on adding compatibility with other mods in my mod, but I need to wait until this mods register their items and blocks so I can interact with them later. Would there be a way to make that using required-after, or I should move and register my items on the init, or post init? PS: The question is, so my mod doesn't say X mod is needed, it's really not, but if X mod is present, then I want to add compatibility for it.
-
[1.9.4] [Solved]How to make a dropped item invisible?
I can think on something, not sure if it would work, or be the best way to do it, but maybe on the .json under display, you can set the scale of the item to 0 when it's on ground view?
-
[1.9.4] Problem playing sound when player dies
Thanks a lot man, it's working perfectly now. Now my question is... Why it's wrong to track when a player dies using the PlayerDropsEvent? Isn't it better to subscribe to an event that will triggers only when a player dies, and not use LivingDeathEvent that gets triggered every time something dies in the game? In my head it makes sense using PlayerDropsEvent better over LivingDeathEvent but dunno...
-
[1.9.4] Problem playing sound when player dies
I'm having problems playing a sound when the player dies. The sound is registered correctly, the event is registered correctly and getting fired, but for some reason, the sound wont play. I'm not sure what the problem could be here. @SubscribeEvent public void onPlayerDie(PlayerDropsEvent event) { World world = event.getEntity().getEntityWorld(); EntityPlayer player = event.getEntityPlayer(); BlockPos pos = player.getPosition(); world.playSound(player, pos, ModSounds.PLAYER_DEAD, SoundCategory.BLOCKS, 1.0F, 1.0F); } I tried the sound firing in on other events and it works ok, but inside the PlayerDropsEvent it wont do anything. PS: Also tried this, with no success @SubscribeEvent public void onPlayerDie(LivingDeathEvent event) { Entity entity = event.getEntity(); if(entity instanceof EntityPlayer){ World world = event.getEntity().getEntityWorld(); BlockPos pos = entity.getPosition(); world.playSound((EntityPlayer)entity, pos, ModSounds.PLAYER_DEAD, SoundCategory.BLOCKS, 1.0F, 1.0F); } }
-
[1.9.4] I can't figure out what could be happening
Thanks, never did that, so not sure what you talking about, but gonna investigate. Hopefully that works outside Eclipse as I have to do that test with Pams Harvestcraft installed. From more testings, clearly something on Pams Harvestcraft is making my part of the code that is on "if(!world.isRemote)" to not execute. Here are the console Logs from Eclipse, and from MultiMC both, with Pams Right Click enabled and disabled.
-
[1.9.4] I can't figure out what could be happening
Yes, this is Pams Harvescraft Mod https://github.com/MatrexsVigil/harvestcraft/tree/master/java/com/pam/harvestcraft I'm also looking around there and see if I find how she handles the Right Click functionality in her mod and see if I can't figure out what's happening. Thanks for the help
-
[1.9.4] I can't figure out what could be happening
Sorry I forgot to add, even when the sound that is present there plays, the item never takes damage, so, I don't know why, but somehow that code is stopped somewhere before it completes running. My guess was that Pams is returning "EnumActionResult.SUCCESS;" at some point and my code stop executing? But I don't know if that even possible.
-
[1.9.4] I can't figure out what could be happening
I don't think I have access to the HarvestDropsEvent maybe I'm wrong, really not sure. All this happens when the player right clicks on a crop and the crop is ready to harvest. I'm still polishing the code and making it better, so I really don't have to check for the type of crop and it's max age, but instead use the isMaxAge present on BlockCrops (On the future for sure I will ask help about how to make it work with crops from other mods, for example Pams) So, the code can be found here http://pastebin.com/j7hHsQNd (Please don't laugh too hard I learn something new every day)
-
[1.9.4] I can't figure out what could be happening
Well, as some of you may know already, I made a tool that when right clicked on crops it will drop the items from that crop and also some extra. Problem now is that when using combined with Pam's Harvescraft and the function that mod has for right click to harvest crops (My mod does it also, but I disabled my right click on this tests) so, problem is, that the effect of my tool gets "nulled" The code gets called but nothing spawns in the world. public void spawnDrops(List<ItemStack> doDrops, World world, BlockPos pos, ItemStack stack, EntityPlayer player){ world.playSound(player, pos, SoundEvents.BLOCK_CLOTH_FALL, SoundCategory.BLOCKS, 1.0F, 1.0F); System.out.println(doDrops); if(!world.isRemote){ System.out.println("REMOTE"); for(ItemStack drop : doDrops){ EntityItem itemDrop = new EntityItem(world, pos.getX()+.5, pos.getY()+.5, pos.getZ()+.5, drop); world.spawnEntityInWorld(itemDrop); System.out.println("DROP"); dropExtra = this.returnToolChances(stack.getItem()); if(dropExtra==0){ EntityItem itemDropExtra = new EntityItem(world, pos.getX()+.5, pos.getY()+.5, pos.getZ()+.5, drop.copy()); world.spawnEntityInWorld(itemDropExtra); System.out.println("EXTRA"); } } stack.damageItem(1, player); } } System.out.println(doDrops); prints in the console, however System.out.println("REMOTE"); never prints. But as soon as I disable the Right click functionality on Pams my code works ok again. Anyone has any clue what could be going on here? I have some guesses, but not sure...
-
[1.7.10/1.8] Baby Mobs Mod
Loving the concept of the Mod, it looks really nice. Any plan on updating to 1.9.4?
-
Any idea yet of how much work will be needed port a 1.9.4 mod to 1.10?
And what you guys think with Minecraft 1.10 been out now, how will this affect 1.9.4 Forge? What do you think modders are going to do? I'm really surprised about how fast with 1.10 update came out, it's a "shitty" update in my opinion, but I don't know why this happened, what was the rush on bringing 1.10 out so fast?
-
[Solved][1.9.x] Problem with items spawned in world
Thanks a lot Ernio. I did suspected that could be the problem, I had no idea how to fix it. Using the .copy for the stack does the trick, I have tried a lot with the Pumpkins and I don't see ghost drops anymore. And as Im using that method for Cocoa, Crops and Melons I bet it fixes problems there also. Thanks once again, I love people trying to help in this forum as always great.
-
[Solved][1.9.x] Problem with items spawned in world
So I cleaned up the code, do some more testing, but still having the same problem (For example, trying it on Pumpkins, that vanilla default only drops 1) Sometimes 2 items spawn and I correctly pick up 2 items, but sometimes 2 spawn and when I pick them up, it's really just 1 item. package com.mramericanmike.mikedongles.items; import java.util.ArrayList; import java.util.List; import net.minecraft.block.Block; import net.minecraft.block.BlockBeetroot; import net.minecraft.block.BlockCocoa; import net.minecraft.block.BlockCrops; import net.minecraft.block.BlockDirt; import net.minecraft.block.BlockMelon; import net.minecraft.block.BlockPumpkin; import net.minecraft.block.properties.PropertyInteger; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.SoundEvents; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.SoundCategory; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import com.mramericanmike.mikedongles.ModInfo; import com.mramericanmike.mikedongles.creativetab.ModCreativeTab; import com.mramericanmike.mikedongles.init.ModItems; import com.mramericanmike.mikedongles.init.ModMaterials.ModToolMaterial; public class CropDongle extends Item { private final float damage; private int dropExtra = 20; private int age = 0; private String cropName = ""; private List<ItemStack> drops = new ArrayList<ItemStack>(); public CropDongle(ModToolMaterial material, String name) { this.maxStackSize = 1; this.setMaxDamage(material.getMaxUses()); this.damage = material.getDamageVsEntity() + 1.0F; this.setUnlocalizedName(ModInfo.MODID.toLowerCase() + ":" + name); this.setCreativeTab(ModCreativeTab.MOD_TAB); } @Override public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { //HOE if (!player.canPlayerEdit(pos.offset(facing), facing, stack)) { return EnumActionResult.FAIL; } else { int hook = net.minecraftforge.event.ForgeEventFactory.onHoeUse(stack, player, world, pos); if (hook != 0) return hook > 0 ? EnumActionResult.SUCCESS : EnumActionResult.FAIL; IBlockState iblockstate = world.getBlockState(pos); Block block = iblockstate.getBlock(); if (facing != EnumFacing.DOWN && world.isAirBlock(pos.up())) { if (block == Blocks.GRASS || block == Blocks.GRASS_PATH) { this.tillDirt(stack, player, world, pos, Blocks.FARMLAND.getDefaultState()); return EnumActionResult.SUCCESS; } if (block == Blocks.DIRT) { switch ((BlockDirt.DirtType)iblockstate.getValue(BlockDirt.VARIANT)) { case DIRT: this.tillDirt(stack, player, world, pos, Blocks.FARMLAND.getDefaultState()); return EnumActionResult.SUCCESS; case COARSE_DIRT: this.tillDirt(stack, player, world, pos, Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT)); return EnumActionResult.SUCCESS; default: return EnumActionResult.PASS; } } } } //END HOE //DONGLE IBlockState checkBlockState = world.getBlockState(pos); Block checkBlock = checkBlockState.getBlock(); if(checkBlock!=null) { if(checkBlock instanceof BlockCrops) { cropName = world.getBlockState(pos).getBlock().getUnlocalizedName().substring(5); //Beetroots if(cropName.equals("beetroots")){ age = world.getBlockState(pos).getValue(BlockBeetroot.BEETROOT_AGE); if(age==3){ drops = world.getBlockState(pos).getBlock().getDrops(world, pos, world.getBlockState(pos), 0); world.setBlockState(pos, world.getBlockState(pos).withProperty(BlockBeetroot.BEETROOT_AGE, Integer.valueOf(0)), 3); this.spawnDrops(drops, world, pos, stack, player); return EnumActionResult.SUCCESS; } return EnumActionResult.PASS; }//End Beetroots //Other crops go with age 7 else { age = world.getBlockState(pos).getValue(BlockCrops.AGE); if(age==7){ drops = world.getBlockState(pos).getBlock().getDrops(world, pos, world.getBlockState(pos), 0); world.setBlockState(pos, world.getBlockState(pos).withProperty(BlockCrops.AGE, Integer.valueOf(0)), 3); this.spawnDrops(drops, world, pos, stack, player); return EnumActionResult.SUCCESS; } return EnumActionResult.PASS; } }//END IF CROPS //COCOA else if (checkBlock instanceof BlockCocoa){ age = world.getBlockState(pos).getValue(BlockCocoa.AGE); if(age==2){ drops = world.getBlockState(pos).getBlock().getDrops(world, pos, world.getBlockState(pos), 0); world.setBlockState(pos, world.getBlockState(pos).withProperty(BlockCocoa.AGE, Integer.valueOf(0)), 3); this.spawnDrops(drops, world, pos, stack, player); return EnumActionResult.SUCCESS; }//END IF AGE 2 return EnumActionResult.PASS; }//END IF COCOA //PUMPKINS AND MELONS else if (checkBlock instanceof BlockPumpkin || checkBlock instanceof BlockMelon){ drops = world.getBlockState(pos).getBlock().getDrops(world, pos, world.getBlockState(pos), 0); world.setBlockToAir(pos); this.spawnDrops(drops, world, pos, stack, player); return EnumActionResult.SUCCESS; }//END IF PUMPKING/MELON }//END IF BLOCK NOT NULL return EnumActionResult.PASS; }//END ONITEMUSE private int returnToolChances(Item item) { int chances = 20; if(item.equals(ModItems.crop_dongle)){ chances=20; } if(item.equals(ModItems.crop_dongle_stone)){ chances=15; } if(item.equals(ModItems.crop_dongle_iron)){ chances=9; } if(item.equals(ModItems.crop_dongle_gold)){ chances=6; } if(item.equals(ModItems.crop_dongle_diamond)){ chances=3; } dropExtra = (int) (Math.random() * chances); return dropExtra; } private void tillDirt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, IBlockState state) { world.playSound(player, pos, SoundEvents.ITEM_HOE_TILL, SoundCategory.BLOCKS, 1.0F, 1.0F); if (!world.isRemote) { world.setBlockState(pos, state, 11); stack.damageItem(1, player); } } private void spawnDrops(List<ItemStack> drops, World world, BlockPos pos, ItemStack stack, EntityPlayer player){ if(!world.isRemote){ for(ItemStack drop : drops){ EntityItem itemDrop = new EntityItem(world, pos.getX()+.5, pos.getY()+.5, pos.getZ()+.5, drop); world.spawnEntityInWorld(itemDrop); dropExtra = this.returnToolChances(stack.getItem()); if(dropExtra==0){ EntityItem itemDropExtra = new EntityItem(world, pos.getX()+.5, pos.getY()+.5, pos.getZ()+.5, drop); world.spawnEntityInWorld(itemDropExtra); } } stack.damageItem(1, player); } } @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { list.add("Can be used as Hoe"); } } Really don't know what I'm doing wrong here. I would understand it better if 100% the time I see this behavior, but not, it only does it sometimes. PS: I checked when the Extra drop gets triggered, and it always happens when that it's triggered, that it spawn the extra drop, but it happens what I described. When the extra drop isn't triggered, 100% of the time, only 1 item spawn and its picked correctly.
-
[Solved][1.9.x] Problem with items spawned in world
Yes, around the item spawning maybe, but you are still doing other stuff (setting blocks) on the client. Don't. Cleanup your code so it's actually readable and remove that copy-pasta mess and we can see what is actually happening. Thanks, gonna do some cleaning. The copy pasta isn't a big deal, it's just recreating what a hoe can do. I'm always confuse with the client/server side or the things, and never sure what goes where. But thinking it again, it makes sense that everything inside the onitemuse should be server side only. PS: Thanks for noticing that the code is a "mess" but maybe some tips on what you think I could do to make it better can help me improve Thanks once again, always helpful
-
[Solved][1.9.x] Problem with items spawned in world
I have the if(!world.isRemote) before spawning the items. So not sure, all the onitemuse should run only on server? Also I noticed when the 2 pumpkins spawn separate, when I pick one, the other also dissapear. Looks like I'm cloning the same item somehow
-
[Solved][1.9.x] Problem with items spawned in world
I have a tool, that when you right click, for example on Pumpkins, it has the chance of dropping extra Pumpkins. However, and even when I see the 2 pumpkins in floor, sometimes on pickup it just pick ups one. But sometimes it does pickup 2 pumpkins and I'm not sure what could be wrong here. else if (checkBlock instanceof BlockPumpkin || checkBlock instanceof BlockMelon){ List<ItemStack> drops = new ArrayList<ItemStack>(); drops = world.getBlockState(pos).getBlock().getDrops(world, pos, world.getBlockState(pos), 0); for(ItemStack drop : drops){ world.setBlockToAir(pos); if(!world.isRemote){ EntityItem itemDrop = new EntityItem(world, pos.getX()+.5, pos.getY()+.5, pos.getZ()+.5, drop); world.spawnEntityInWorld(itemDrop); rand = (int) (Math.random() * chances); if(rand==0){ EntityItem itemDropExtra = new EntityItem(world, pos.getX()+.5, pos.getY()+.5, pos.getZ()+.5, drop); world.spawnEntityInWorld(itemDropExtra); } } } stack.damageItem(1, player); return EnumActionResult.SUCCESS; }//END IF PUMPKING/MELON All this is inside the onItemUse method, where some other stuff happens. (Doing stuff in other crops and acting as a how) Any clue on what I'm doing wrong here? I noticed it on the Pumpkins but I bet it's also happening with the extra drops on the crops for sure.
-
[1.9.4] Items.apple >> Items.APPLE
Working on Notepad++ but it's only replacing the first letter and making it Capital. Gonna check how the expression is built and see if I can figure out how to modify it, to Capitalize the whole word. Thanks a lot.
-
[1.9.4] Items.apple >> Items.APPLE
Thanks, gonna try it
-
[1.9.4] Items.apple >> Items.APPLE
Well, yes I thought of that, the problem is that I use almost all vanilla items/blocks somewhere in my code, so I would have to literally search and replace for all the items/blocks in game. I'm up to 1200 errors found on my project. It was 1500 earlier, so I guess I will slowly go file by file fixing it. Thanks
IPS spam blocked by CleanTalk.