Skip to content

Commit

Permalink
Fix bow direction (follow head).
Browse files Browse the repository at this point in the history
New property in config.
Add redstone item (not implemented).
  • Loading branch information
NiclasOlofsson committed Jul 22, 2016
1 parent 91cc2d2 commit a723864
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/MiNET/MiNET/Items/ItemBow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public override void Release(Level world, Player player, BlockCoordinates blockC
arrow.KnownPosition = (PlayerLocation) player.KnownPosition.Clone();
arrow.KnownPosition.Y += 1.62f;

arrow.Velocity = arrow.KnownPosition.GetDirection()*(force*2.0f*1.5f);
arrow.Velocity = arrow.KnownPosition.GetHeadDirection()*(force*2.0f*1.5f);
arrow.KnownPosition.Yaw = (float) arrow.Velocity.GetYaw();
arrow.KnownPosition.Pitch = (float) arrow.Velocity.GetPitch();
arrow.BroadcastMovement = false;
Expand Down
1 change: 1 addition & 0 deletions src/MiNET/MiNET/Items/ItemFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public static Item GetItem(short id, short metadata = 0, byte count = 1)
else if (id == 323) item = new ItemSign();
else if (id == 324) item = new ItemDoor();
else if (id == 325) item = new ItemBucket(metadata);
else if (id == 331) item = new ItemRedstone();
else if (id == 332) item = new ItemSnowball();
else if (id == 344) item = new ItemEgg();
else if (id == 345) item = new ItemCompass();
Expand Down
9 changes: 9 additions & 0 deletions src/MiNET/MiNET/Items/ItemRedstone.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace MiNET.Items
{
public class ItemRedstone : Item
{
public ItemRedstone() : base(331)
{
}
}
}
1 change: 1 addition & 0 deletions src/MiNET/MiNET/MiNET.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@
<Compile Include="Items\ItemPotato.cs" />
<Compile Include="Items\ItemPotion.cs" />
<Compile Include="Items\ItemPumpkinPie.cs" />
<Compile Include="Items\ItemRedstone.cs" />
<Compile Include="Items\ItemSign.cs" />
<Compile Include="Items\ItemShovel.cs" />
<Compile Include="Items\ItemSlab.cs" />
Expand Down
6 changes: 3 additions & 3 deletions src/MiNET/MiNET/MiNetServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ public class MiNetServer

public MiNetServer()
{
ServerRole = Config.GetProperty("ServerRole", ServerRole.Full);
InacvitityTimeout = Config.GetProperty("InactivityTimeout", 8500);
}

public MiNetServer(IPEndPoint endpoint)
public MiNetServer(IPEndPoint endpoint): base()
{
Endpoint = endpoint;
}
Expand Down Expand Up @@ -96,8 +98,6 @@ public bool StartServer()
{
Log.Info("Initializing...");

InacvitityTimeout = Config.GetProperty("InactivityTimeout", 8500);

if (ServerRole == ServerRole.Full || ServerRole == ServerRole.Proxy)
{
if (Endpoint == null)
Expand Down
21 changes: 21 additions & 0 deletions src/MiNET/MiNET/Utils/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,27 @@ static Config()
}
}

public static ServerRole GetProperty(string property, ServerRole defaultValue)
{
string value = ReadString(property);
if (value == null) return defaultValue;

switch (value.ToLower())
{
case "1":
case "node":
return ServerRole.Node;
case "0":
case "proxy":
return ServerRole.Proxy;
case "2":
case "full":
return ServerRole.Full;
default:
return defaultValue;
}
}

public static GameMode GetProperty(string property, GameMode defaultValue)
{
string value = ReadString(property);
Expand Down
8 changes: 4 additions & 4 deletions src/MiNET/MiNET/Utils/Vector3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ public static double GetPitch(this Vector3 vector)
return ToDegrees(Math.Atan2(vector.Y, distance));
}

public static float ToRadians(this float angle)
public static double ToRadians(this float angle)
{
return (float) ((Math.PI/180)*angle);
return (Math.PI/180.0f)*angle;
}

public static float ToDegrees(this double angle)
public static double ToDegrees(this double angle)
{
return (float) (angle*(180.0/Math.PI));
return angle*(180.0f/Math.PI);
}
}

Expand Down

0 comments on commit a723864

Please sign in to comment.