Everything posted by TheRealMcrafter
-
[1.7.10] Changing block metadata on rightclick
What about a Tick Handler?
-
Version checker?
Dont you need an @SidedProxy annotation in your main class?
-
[1.7.10] Changing block metadata on rightclick
Probably a better way, but I would create a TileEntity for the block, and then in the updateEntity() method you can time it. updateEntity() is called every tick, and there are 20 ticks in a second.
-
Version checker?
Actually, that tutorial is the best. You put the client code in the wrong event. Jabelar said FMLPostInitializationevent. You put it in FMLInitializationEvent
-
1.7.10 How would I save an arraylist of tile entities to NBT?
Am I on the right track here? @Override public void writeToNBT(NBTTagCompound nbt){ super.writeToNBT(nbt); nbt.setByte("renderValue", this.renderValue); nbt.setString("state", this.state); NBTTagCompound siren = new NBTTagCompound(); for (int i = 0; i < sirens.size(); i++){ siren.setInteger("x" + i, sirens.get(i).xCoord); siren.setInteger("y" + i, sirens.get(i).yCoord); siren.setInteger("z" + i, sirens.get(i).zCoord); siren.setInteger("listSize", i); } NBTTagList list = new NBTTagList(); list.appendTag(siren); nbt.setTag("sirens", list); } @Override public void readFromNBT(NBTTagCompound nbt){ super.readFromNBT(nbt); this.renderValue = nbt.getByte("renderValue"); this.state = nbt.getString("state"); NBTTagList list = (NBTTagList) nbt.getTag("sirens"); NBTTagCompound siren = list.getCompoundTagAt(0); for (int i = 0; i < siren.getInteger("listSize"); i ++){ TileEntity tile = new TileEntity(); //tile.xCoord is (siren.getInteger("x" + i); this.sirens.add(tile); } }
-
1.7.10 How would I save an arraylist of tile entities to NBT?
Wow, I didnt think it would be that easy. Thanks.
-
1.7.10 How would I save an arraylist of tile entities to NBT?
Title says it all. How would I go about saving ArrayList<TileEntity> to NBT in my tile entity class?
-
How to update an entity's AI
Okay, thanks for your help.
-
How to update an entity's AI
If you go into an MC world and spawn about 15 - 20 mobs in an enclosed space, they start to spam that weird footstep sound. And that makes sense now, because killing off one villager will allow the sound to play a bit longer than before.
-
How to update an entity's AI
Well that stinks. What about canceling the footstep sounds?
-
How to update an entity's AI
Hmm, any way to change the priority of my sound in some way?
-
How to update an entity's AI
So can I put my sound on a separate thread? Or is that just not possible. I thought I saw something about this before.
-
How to update an entity's AI
Neither do I. You know the sound that plays when you spawn a ton of mobs in a limited space? It sounds sorta like footsteps running. If i have a few villagers, and I activate the sound and they panic, the siren keeps playing. If there are closer to 20 or so villagers, and I activate the siren and they panic, as soon as that strange footstep sound starts playing, the siren cuts out. Its like Minecraft is stopping my sound based on priority or something like that. Can you think of a workaround for this?
-
How to update an entity's AI
See post #9 of this thread.
-
How to update an entity's AI
https://gist.github.com/TheRealMcrafter/9f460f45db6b094097b3
-
How to update an entity's AI
Okay, so then what can I do about my sirens cutting out?
-
Forge Build error: java.lang.ClassNotFoundException: com.google.common.io.Files
Try without --refresh dependencies. Thats worked for me before.
-
How to update an entity's AI
Do I actually need packets, or can I just mark the block for update? Edit: Marking the block for update seems to work fine, it pushes the correct shouldStop value to the client, and then the client retrieves that and uses it.
-
[1.7.10][Solved] Replace item with another
playerIn is a name Ernio assigned to EntityLivingBase. Basically you want to check if EntityLivingBase is an instance of EntityPlayer. In java its a simple as this: public boolean onEntitySwing(EntityLivingBase theEntityYoureChecking, ItemStack theItemStackTheEntityIsHolding){ if (theEntityYoureChecking instanceof EntityPlayer){ //The Entity Is A Player. } return false; } If the Entity is a player, then we want to replace the item. If it is a zombie, or a chicken, we don't. So we can add an else statement. public boolean onEntitySwing(EntityLivingBase theEntityYoureChecking, ItemStack theItemStackTheEntityIsHolding){ if (theEntityYoureChecking instanceof EntityPlayer){ //The Entity Is A Player. return true; } else { //The Entity Is Not A Player. return false; } } Since the entity is a player, we want to get the current stack theyre holding, and then replace it with your own. You can do this by casting the Entity to EntityPlayer: EntityPlayer player = (EntityPlayer) theEntityYoureChecking; ^ That is called "Casting" and then getting the slot theyre currently using, like this: public boolean onEntitySwing(EntityLivingBase theEntityYoureChecking, ItemStack theItemStackTheEntityIsHolding){ if (theEntityYoureChecking instanceof EntityPlayer){ EntityPlayer player = (EntityPlayer) theEntityYoureChecking; Int slot= player.inventory.currentItem; //The Entity Is A Player. return true; } else { //The Entity Is Not A Player. return false; } } To replace it with your own items, you need to create a new ItemStack() with the items you want. It is done like this: ItemStack stack = new ItemStack(ItemYouWantHere, AmountOfItems); an example: ItemStack stack = new ItemStack(Items.egg, 5); This would make a new ItemStack with 5 eggs in it. You can add that to your method. public boolean onEntitySwing(EntityLivingBase theEntityYoureChecking, ItemStack theItemStackTheEntityIsHolding){ if (theEntityYoureChecking instanceof EntityPlayer){ //The Entity Is A Player. EntityPlayer player = (EntityPlayer) theEntityYoureChecking; Int slot = player.inventory.currentItem; ItemStack stack = new ItemStack(Items.egg, 5); return true; } else { //The Entity Is Not A Player. return false; } } Now, it is very simple. Just replace the players current held ItemStack with the one you created. That is done like this: player.inventory.setInventorySlotContents(slotToPutItIn, itemStackToPut); Since we already have the slot the player is currently using, and we have out stack to put in it, we can add the final part to our method: public boolean onEntitySwing(EntityLivingBase theEntityYoureChecking, ItemStack theItemStackTheEntityIsHolding){ if (theEntityYoureChecking instanceof EntityPlayer){ //The Entity Is A Player. EntityPlayer player = (EntityPlayer) theEntityYoureChecking; Int slot = player.inventory.currentItem; ItemStack stack = new ItemStack(Items.egg, 5); player.inventory.setInventorySlotContents(slot, stack); return true; } else { //The Entity Is Not A Player. return false; } } Hope I helped!
-
How to update an entity's AI
Nothing has changed, except for me updating the shouldStop field to the client. It only stops when you can start to hear the villagers footsteps running, at about 20 or so villagers spawned.
-
How to update an entity's AI
Do I have to put my sound on a separate thread? I think I saw something like this before.
-
How to update an entity's AI
Well I figured it out. It only happens when I have around 20 villagers near the siren. I think the sound of the villagers running is stopping my sound. Any way to fix this? It doesnt happen when theres only a few villagers.
-
How to update an entity's AI
So I can just mark the block for update? EDIT: I put a System.out.println(); in the shouldStop method. It isn't called, but the sound still stops. The siren doesnt stop until props.isScared = true; is called.
-
How to update an entity's AI
It seems to work fine, even on a dedicated server. Any idea why my sirens stop when I implement that AI?
-
[1.7.10] How to perform an action only if a block is shift+right clicked on.
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float f, float g, float t){ if (!world.isRemote && player.isSneaking()){ //Player is Sneak + Right Clicking } else { //Player is just clicking } return true; }
IPS spam blocked by CleanTalk.