Hey,
I want to run a method every second and use something like the bukkit scheduler for this.
I tried it with the ServerTickEvent but nothing happens with it:
int tick = 0;
@SubscribeEvent
public void scheduler(ServerTickEvent e){
if(tick != 20){
tick++;
return;
}
tick = 0;
//do stuff
Also tried with @EventHandler (idk the difference^^)
Hope for a good reply
Thanks - but still doesn't work. Code is now:
double x = attacker.posX;
double y = attacker.posY;
double z = attacker.posZ;
World w = attacker.worldObj;
w.playSoundEffect(x, y, z, "Sound.ANVIL_BREAK", 1, 1);
I tried...
int x = player.chunkCoordX;
int y = player.chunkCoordY;
int z = player.chunkCoordZ;
World w = DimensionManager.getWorld(0);
w.playSoundEffect((double) x, (double) y, (double) z, "SOUND.RANDOM.WOOD_CLICK", 1F, 1F);
but it doesnt work. Where is the problem?
Hello,
(((I am looking for a way to make a mod server-side only so Forge allows players to join without the mod installed.)))
Also I want to play a sound for a player with this (serverside) mod. (How) is this possible? I tried player.playSound("SOUND.RANDOM.ANVIL_BREAK", 1, 1) but nothing happens.
I would very much appreciate your help
Thanks, seems helpful but I tried it and it crashes with the same error when casting it.
if(source != null){
if (((source instanceof EntityDamageSource))){
Entity sourceentity = ((EntityDamageSource)source).getEntity();
Where is the problem?
Its also pretty weird because I as a player am an entity and a player, so there should be no error
Hey,
I am working on a method that returns the attacker of an entity. I tried:
DamageSource source = event.source;
if(source != null){
if (((source instanceof EntityDamageSource))){
if(source.getEntity() != null){
if(source.getEntity() instanceof EntityPlayerMP){
EntityPlayerMP attacker = (EntityPlayerMP)source.getEntity();
System.out.println(attacker.toString() + " is the attacker");
}
}
}
}
These if-functions should prevent the case to go on if there is no attacker but the game crashes as soon as I hit an animal.
Here is the error:
Line 61 is: " if(source.getEntity() != null){"
I am using the recommended Forge 1.7.10 version.
I hope someone can help.