Everything posted by TheRealMcrafter
- 
	
		
		How to update an entity's AI
		
		public void setShouldStop(boolean shouldStop){ if (shouldStop){ if (isPlaying){ isPlaying = false; this.shouldStop = true; } } else { this.shouldStop = shouldStop; } } I know I could have just done public void setShouldStop(boolean shouldStop){ this.shouldStop = shouldStop; } but in order for my sirens to work properly, I have to do the above. Everything worked fine until I implemented the AI changes above, then they play for a few seconds and stop.
 - 
	
		
		How to update an entity's AI
		
		I play the sound by sending a packet with the sound name from the tile entity to all nearby players in the same world, and then passing the sound name to my Looping Audio Handler, and then passing that to my Siren Looper class. Tile Entity: if (!isPlaying && shouldStart){ shouldStart = false; shouldStop = false; isPlaying = true; this.updateClientRender(); SirenModPacketDispatcher.sendToAllAround(new SirenModPlayLoopedSoundMessage(xCoord, yCoord, zCoord, "sirenT121"), this.worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 50000000); } Play Sound Message: public IMessage handleClientMessage(EntityPlayer player, SirenModPlayLoopedSoundMessage message, MessageContext ctx) { new LoopingAudioHandler(player.worldObj, message.x, message.y, message.z, message.soundName); Looping Audio Handler: public LoopingAudioHandler(World world, int x, int y, int z, String soundName){ SirenLooper looper = new SirenLooper(world.getTileEntity(x, y, z), soundName); Minecraft.getMinecraft().getSoundHandler().playSound(looper); } Siren Looper: public SirenLooper(TileEntity tile, String soundName){ super(new ResourceLocation("SirenMod:" + soundName)); this.tile = tile; this.repeat = true; if (tile instanceof NuclearSirenTileEntity){ volume = 5.0F; } else if (tile instanceof GeneralSirenTileEntity){ volume = 10.0F; } else if (tile instanceof BurglarSirenTileEntity){ volume = 5.0F; } else if (tile instanceof FireAlarmTileEntity){ volume = 5.0F; } else if (tile instanceof AmericanSignalT121TileEntity){ volume = 20.0F; } else { volume = 5.0F; } this.xPosF = tile.xCoord; this.yPosF = tile.yCoord; this.zPosF = tile.zCoord; } public void update(){ if (tile instanceof GeneralSirenTileEntity){ if (((GeneralSirenTileEntity) tile).isShouldStop() || ((GeneralSirenTileEntity) tile).isInvalid()){ this.donePlaying = true;} } else if (tile instanceof NuclearSirenTileEntity){ if (((NuclearSirenTileEntity) tile).isShouldStop() || ((NuclearSirenTileEntity) tile).isInvalid()){ this.donePlaying = true;} } else if (tile instanceof BurglarSirenTileEntity){ if (((BurglarSirenTileEntity) tile).isShouldStop() || ((BurglarSirenTileEntity) tile).isInvalid()){ this.donePlaying = true;} } else if (tile instanceof FireAlarmTileEntity){ if (((FireAlarmTileEntity) tile).isShouldStop() || ((FireAlarmTileEntity) tile).isInvalid()){ this.donePlaying = true;} } else if (tile instanceof AmericanSignalT121TileEntity){ if (((AmericanSignalT121TileEntity) tile).isShouldStop() || ((AmericanSignalT121TileEntity) tile).isInvalid()){ this.donePlaying = true;} } else { throw new ClassCastException(); } } @Override public boolean isDonePlaying(){ return this.donePlaying;} }
 - 
	
		
		How to update an entity's AI
		
		Okay, I got it to work how I want it. But now, my sirens only play for like a half a second and then they stop. If I remove this code from my tile entity, the sounds play all the way through and continue looping. if (this.isPlaying){ List l = this.worldObj.getEntitiesWithinAABB(EntityVillager.class, AxisAlignedBB.getBoundingBox(this.xCoord - 20, this.yCoord - 20, this.zCoord - 20, this.xCoord + 20, this.yCoord + 20, this.zCoord + 20)); if (!l.isEmpty()){ for (int i = 0; i < l.size(); i++){ EntityVillager villager = (EntityVillager) l.get(i); ExtendedVillager props = ExtendedVillager.get(villager); props.isScared = true; } } } Anyone have an idea what I'm doing wrong?
 - 
	
		
		Modder status/subforum requests
		
		Can I get a sub forum for SirenMod? http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/2253397-therealmcrafters-siren-mod-1-6-4-1-7-10-4247
 - 
	
		
		How to update an entity's AI
		
		Thanks, Ill give this a try.
 - 
	
		
		How to update an entity's AI
		
		So how would I go about doing this? Extend EntityVillager, and set it so when an IExtendedEntityProperty changes to true, I activate the task?
 - 
	
		
		How to update an entity's AI
		
		Tried a few things: if (this.isPlaying){ List l = this.worldObj.getEntitiesWithinAABB(EntityVillager.class, AxisAlignedBB.getBoundingBox(this.xCoord - 20, this.yCoord - 20, this.zCoord - 20, this.xCoord + 20, this.yCoord + 20, this.zCoord + 20)); if (!l.isEmpty()){ for (int i = 0; i < l.size(); i++){ EntityVillager villager = (EntityVillager) l.get(i); ((EntityVillager) villager).tasks.addTask(0, new EntityAIPanic(villager, 0.9D)); //((EntityVillager) villager).targetTasks.addTask(0, new EntityAIPanic(villager, 0.9D)); //((EntityVillager) villager).tasks.onUpdateTasks(); //((EntityVillager) villager).targetTasks.onUpdateTasks(); } } }
 - 
	
		
		How to update an entity's AI
		
		Hey all, I am trying to make a vilager panic when they hear my siren sound. I have it setup to add EntityAIPanic to the tasks list when to the villager, but they dont move until I hit them. How can I push the AI update to them?
 - 
	
		
		Removing item from tileentity
		
		Instead of setting isStriking to true in your GUI class (on the Client), you need to send a packet to the server, and then in your packet handler, you set isStriking to true (on the Server).
 - 
	
		
		[1.7.10] How to detect if an entity is moving?
		
		Yeah, I just quickly did that to show my point. I figured that out when I was testing for motionY, which is about 1.17. Thanks for reminding me though.
 - 
	
		
		[1.7.10] How to detect if an entity is moving?
		
		How would I go about doing this?
 - 
	
		
		[1.7.10] How to detect if an entity is moving?
		
		How could I do this when I have more than one entity to track, and I dont know how many entities that are being tracked? An ArrayList?
 - 
	
		
		[1.7.10] How to detect if an entity is moving?
		
		Does anyone have a workaround for this? It appears coolAlias had troubles with this before, did you ever find a way to do it? http://www.minecraftforge.net/forum/index.php?topic=13721.0
 - 
	
		
		[1.7.10] How to detect if an entity is moving?
		
		I'm checking on the server, and it is not just for the player, it is for any living entity. I am making a motion detector, so if any entity in the list moves, isDetected turns to true. if (!worldObj.isRemote){ List list = this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(this.xCoord - 10, this.yCoord - 10, this.zCoord - 10, this.xCoord + 10, this.yCoord + 10, this.zCoord + 10)); if (list.isEmpty()){ this.isDetecting = false; } else { for (int i = 0; i < list.size(); i ++){ EntityLivingBase entity = (EntityLivingBase) list.get(i); if (entity.motionX != 0){ this.isDetecting = true; } else { this.isDetecting = false; } } } Right now I'm focusing only on motionX, but it doesn't work for Y and Z also. A System.out.println() always prints out 0.0
 - 
	
		
		[1.7.10] How to detect if an entity is moving?
		
		Hey guys, I want to check if an entity is moving from inside my Tile Entity updateEntity method. I have already checked if entity.prevPosX != entity.posX, I've tried using entity.motionX, and I've tried storing the old coordinates in a variable and checking against them. Entity.motion* only works if the player is sprinting, and all of the other methods I've tried don't work. Does anyone know how to do this?
 - 
	
		
		How can i getStackInSlot in a custom IInventory.
		
		I know, I know! I've just been trying everything possible to get this to work. (Even doing things I know I shouldnt) :'( And THATS what I needed, I forgot I had that .get(player) method. Thanks for all your help! Edit: Seriously, thank you so much coolAlias. Your tutorials and explanations are amazing and you dont get enough credit for what you do for the forge community -TheRealMcrafter
 - 
	
		
		How can i getStackInSlot in a custom IInventory.
		
		Welp, that didn't seem to work either. I'm doing this: private final static ExtendedPlayer extendedPlayer = new ExtendedPlayer(Minecraft.getMinecraft().thePlayer); public static boolean tryToHolster(EntityPlayer player){ ItemStack stack = player.inventory.getCurrentItem(); ItemStack holsterSlot = extendedPlayer.inventory.getStackInSlot(0); System.err.println(holsterSlot); System.err.println(extendedPlayer.inventory.getStackInSlot(0)); if (stack != null){ if (stack.getItem() == CitiesMod.M1911){ if (holsterSlot != null){ System.err.println("Reached!"); } } else if (stack.getItem() == CitiesMod.Glock21){ if (holsterSlot != null){ System.err.println("Reached!"); } } } return false; }
 - 
	
		
		How can i getStackInSlot in a custom IInventory.
		
		I'm using it in a custom class, that is called when the server gets a packet from my key handler. I can't believe i missed a solution as simple as that, although I've been at this for a long time now so I probably cant see straight
 - 
	
		
		How can i getStackInSlot in a custom IInventory.
		
		Oh! That makes sense! So where could I put that instance for the extended player then?
 - 
	
		
		How can i getStackInSlot in a custom IInventory.
		
		
- How can i getStackInSlot in a custom IInventory.
 I never said there was an error, it is just always null, even though I can see the item in the slot, and if I put the System.out... statement in InventoryCustomPlayer#getStackInSlot, and I open up my custom inventory GUI, it prints out the correct item.- How can i getStackInSlot in a custom IInventory.
 Hey, I have created a custom player inventory, with one extra slot. When I try to get the ItemStack in that slot, it always returns null, even if I do something like setInventorySlotContents(0, new ItemStack(Blocks.dirt)); before a System.out.println(getStackInSlot(0)) I have tried the following ways of getting the itemstack: ExtendedPlayer extendedPlayer = new ExtendedPlayer(getPlayer()); ItemStack holsterSlot = extendedPlayer.inventory.getStackInSlot(0); InventoryCustomPlayer inventory = new InventoryCustomPlayer(); ItemStack holsterSlow = inventory.getStackInSlot(0); but nothing seems to work, it always prints null. I have tried checking the slot on the Client Side, and also sending a packet to the server side, and checking it there. Nothing seems to work. Is this the correct way to get an ItemStack in a custom player inventory slot? Thanks for your time, -TheRealMcrafter- Wondering how to detect what item is in my Container.
 Can't, onUpdate is only called when the item is in a Players inventory. EDIT: Figured it out, a bit "hackishly"- Wondering how to detect what item is in my Container.
 Hey everyone, I have a custom GUI and Container (opened with an item) that I use to store one ItemStack. Is there any kind of onUpdate() method that I can use to get the ItemStack in that slot each tick, since I'm not using a TileEntity. Thanks, -TheRealMcrafter- Best way to compare items in a container?
 Ah! Thats exactly what I was looking for. I actually did this before in my mod but when I changed some stuff i accidentally deleted the code for it, thanks so much! - How can i getStackInSlot in a custom IInventory.
 
IPS spam blocked by CleanTalk.
									
    
    
								
								
							Important Information
By using this site, you agree to our Terms of Use.