Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #1088

Merged
merged 7 commits into from
Jul 30, 2019
Merged

Fixes #1088

Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/main/java/com/flansmod/common/guns/ItemGun.java
Original file line number Diff line number Diff line change
Expand Up @@ -540,8 +540,6 @@ public void shoot(EnumHand hand, EntityPlayer player, ItemStack gunstack, Player
FlansModClient.playerRecoil += recoil;
animations.recoil += recoil;

boolean silenced = type.getBarrel(gunstack) != null && type.getBarrel(gunstack).silencer;
playShotSound(world, rayTraceOrigin, silenced);
} else
{
Vector3f rayTraceDirection = new Vector3f(player.getLookVec());
Expand All @@ -562,7 +560,8 @@ else if (shootableType instanceof GrenadeType)
handler.shooting(false);
}

//TODO make server based sound
boolean silenced = type.getBarrel(gunstack) != null && type.getBarrel(gunstack).silencer;
playShotSound(world, rayTraceOrigin, silenced);
}
int gunSlot = player.inventory.currentItem;
if(type.consumeGunUponUse)
Expand Down
13 changes: 8 additions & 5 deletions src/main/java/com/flansmod/common/guns/ShotHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.flansmod.common.network.PacketPlaySound;
import com.flansmod.common.teams.Team;
import com.flansmod.common.teams.TeamsManager;
import com.flansmod.common.teams.TeamsRound;
import com.flansmod.common.types.InfoType;
import com.flansmod.common.vector.Vector3f;

Expand Down Expand Up @@ -189,11 +190,13 @@ else if(bulletHit instanceof PlayerBulletHit)
{
EntityPlayerMP player = optionalPlayer.get();

if(FlansModClient.teamInfo != null)
if(TeamsManager.getInstance() != null)
{
Team shooterTeam = FlansModClient.teamInfo.getTeam(player);
Team victimTeam = FlansModClient.teamInfo.getTeam(playerHit.hitbox.player);
if(shooterTeam == null || shooterTeam != victimTeam)
TeamsRound round = TeamsManager.getInstance().currentRound;

Team shooterTeam = round.getTeam(player);
Team victimTeam = round.getTeam(playerHit.hitbox.player);

{
FlansMod.getPacketHandler().sendTo(new PacketHitMarker(), player);
}
Expand Down Expand Up @@ -264,7 +267,7 @@ else if(bulletHit instanceof BlockHit)

for (EntityPlayer player : world.playerEntities)
{
//Checks if the player is in a radius of 300 Blocks (300² = 90000)
//Checks if the player is in a radius of 300 Blocks (300 squared = 90000)
if (player.getDistanceSq(pos) < 90000)
{
FlansMod.getPacketHandler().sendTo(new PacketBlockHitEffect(hit, bulletDir, pos, faceing), (EntityPlayerMP) player);
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/com/flansmod/common/teams/TeamsRound.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.flansmod.common.teams;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;

/**
Expand Down Expand Up @@ -113,6 +114,22 @@ public Team getOtherTeam(Team team)
return teams[0];
}

public Team getTeam(EntityPlayer player)
ChrisLane marked this conversation as resolved.
Show resolved Hide resolved
{
String username = player.getName();
for(Team team : teams)
{
for (String name : team.members)
{
if (username.equals(name))
{
return team;
}
}
}
return null;
}

public float getWeight()
{
return popularity * 4F + roundsSincePlayed;
Expand Down