summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--settings.ini4
-rw-r--r--source/BlockID.h5
-rw-r--r--source/cClientHandle.cpp36
-rw-r--r--source/cRedstoneRepeater.h20
4 files changed, 56 insertions, 9 deletions
diff --git a/settings.ini b/settings.ini
index fdf47351f..b30b03958 100644
--- a/settings.ini
+++ b/settings.ini
@@ -15,10 +15,10 @@ Plugin=MagicCarpet
ShowPluginNames=1
[Physics]
-Water=0
+Water=1
[Monsters]
-AnimalsOn=1
+AnimalsOn=0
AnimalSpawnInterval=10
Types=Chicken,Spider
diff --git a/source/BlockID.h b/source/BlockID.h
index 3304e3b99..43451569d 100644
--- a/source/BlockID.h
+++ b/source/BlockID.h
@@ -136,6 +136,8 @@ enum ENUM_ITEM_ID
E_ITEM_GOLDEN_APPLE = 322,
E_ITEM_SIGN = 323,
+ E_ITEM_REDSTONE_DUST = 331,
+
E_ITEM_MILK = 335,
E_ITEM_EGG = 344,
@@ -147,5 +149,6 @@ enum ENUM_ITEM_ID
E_ITEM_COOKED_FISH = 350,
E_ITEM_CAKE = 354,
+ E_ITEM_REDSTONE_REPEATER = 356,
};
-//tolua_end \ No newline at end of file
+//tolua_end
diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp
index f8a9ebd21..222e87497 100644
--- a/source/cClientHandle.cpp
+++ b/source/cClientHandle.cpp
@@ -1,3 +1,4 @@
+
#include "cClientHandle.h"
#include "cServer.h"
#include "cWorld.h"
@@ -16,6 +17,7 @@
#include "cStairs.h"
#include "cLadder.h"
#include "cSign.h"
+#include "cRedstoneRepeater.h"
#include "cBlockToPickup.h"
#include "cMonster.h"
#include "cChatColor.h"
@@ -609,7 +611,7 @@ void cClientHandle::HandlePacket( cPacket* a_Packet )
//LOG("TimeN: %f", cRoot::Get()->GetWorld()->GetTime() );
if ( cRoot::Get()->GetWorld()->GetTime() - m_Player->GetLastBlockActionTime() < 0.1 ) { //only allow block interactions every 0.1 seconds
LOGWARN("Player %s tried to interact with a block too quickly! (could indicate bot)", GetUsername() );
- m_Player->SetLastBlockActionTime(); //Player tried to interact with a block. Reset last block interation time.
+ m_Player->SetLastBlockActionTime(); //Player tried to interact with a block. Reset last block interation time.
break;
}
m_Player->SetLastBlockActionTime(); //Player tried to interact with a block. Reset last block interation time.
@@ -639,21 +641,28 @@ void cClientHandle::HandlePacket( cPacket* a_Packet )
bool bPlaceBlock = true;
if( PacketData->m_Direction >= 0 )
{
+ bool is_redstone_dust = false;
ENUM_BLOCK_ID BlockID = (ENUM_BLOCK_ID)m_Player->GetWorld()->GetBlock( PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ );
switch( BlockID )
{
+ case E_BLOCK_REDSTONE_REPEATER_ON:
+ case E_BLOCK_REDSTONE_REPEATER_OFF:
+ {
+ //todo: Find meta value of repeater and change it to one step more.
+ }
+ break;
case E_BLOCK_WORKBENCH:
{
////////////// For testing V
cPacket_NewInvalidState RainPacket;
RainPacket.m_Reason = 1; //begin rain
- Send( RainPacket );
+ cRoot::Get()->GetServer()->Broadcast( RainPacket );
//also strike table with lightning for test purposes
cPacket_Thunderbolt ThunderboltPacket;
ThunderboltPacket.m_xLBPos = PacketData->m_PosX;
ThunderboltPacket.m_yLBPos = PacketData->m_PosY;
ThunderboltPacket.m_zLBPos = PacketData->m_PosZ;
- Send( ThunderboltPacket );
+ cRoot::Get()->GetServer()->Broadcast( ThunderboltPacket );
////////////// For testing ^
bPlaceBlock = false;
cWindow* Window = new cCraftingWindow( 0, true );
@@ -666,7 +675,7 @@ void cClientHandle::HandlePacket( cPacket* a_Packet )
////////////// For testing V
cPacket_NewInvalidState RainPacket;
RainPacket.m_Reason = 2; //end rain
- Send( RainPacket );
+ cRoot::Get()->GetServer()->Broadcast( RainPacket );
////////////// For testing ^
bPlaceBlock = false;
cBlockEntity* BlockEntity = m_Player->GetWorld()->GetBlockEntity( PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ );
@@ -687,7 +696,7 @@ void cClientHandle::HandlePacket( cPacket* a_Packet )
cItem Item;
Item.m_ItemID = Equipped.m_ItemID;
Item.m_ItemCount = 1;
-
+ LOG("PacketData->m_ItemType: %i", (int)PacketData->m_ItemType);
// Hacked in edible items go!~
bool bEat = false;
switch( Item.m_ItemID )
@@ -738,11 +747,27 @@ void cClientHandle::HandlePacket( cPacket* a_Packet )
break;
char MetaData = (char)Equipped.m_ItemHealth;
+ bool is_redstone_dust = false;
switch( PacketData->m_ItemType ) // Special handling for special items
{
case E_BLOCK_TORCH:
MetaData = cTorch::DirectionToMetaData( PacketData->m_Direction );
break;
+ case E_BLOCK_REDSTONE_TORCH_OFF:
+ MetaData = cTorch::DirectionToMetaData( PacketData->m_Direction );
+ break;
+ case E_BLOCK_REDSTONE_TORCH_ON:
+ MetaData = cTorch::DirectionToMetaData( PacketData->m_Direction );
+ break;
+ case E_ITEM_REDSTONE_DUST:
+ is_redstone_dust = true;
+ PacketData->m_ItemType = E_BLOCK_REDSTONE_WIRE;
+ break;
+ case E_ITEM_REDSTONE_REPEATER:
+ LOG(" m_Player->GetRotation(): %f", m_Player->GetRotation());
+ MetaData = cRedstoneRepeater::RotationToMetaData( m_Player->GetRotation() );
+ PacketData->m_ItemType = E_BLOCK_REDSTONE_REPEATER_OFF;
+ break;
case E_BLOCK_COBBLESTONE_STAIRS:
case E_BLOCK_WOODEN_STAIRS:
MetaData = cStairs::RotationToMetaData( m_Player->GetRotation() );
@@ -768,7 +793,6 @@ void cClientHandle::HandlePacket( cPacket* a_Packet )
default:
break;
};
-
if( IsValidBlock( PacketData->m_ItemType) )
{
if( (m_Player->GetInventory().RemoveItem( Item )) || (m_Player->GetGameMode() == 1) )
diff --git a/source/cRedstoneRepeater.h b/source/cRedstoneRepeater.h
new file mode 100644
index 000000000..d772d6e6f
--- /dev/null
+++ b/source/cRedstoneRepeater.h
@@ -0,0 +1,20 @@
+#pragma once
+
+class cRedstoneRepeater //tolua_export
+{ //tolua_export
+public:
+ static char RotationToMetaData( float a_Rotation ) //tolua_export
+ { //tolua_export
+printf("a_Rotation: %f\n",a_Rotation);
+ a_Rotation += 90 + 45; // So its not aligned with axis
+ if( a_Rotation > 360.f ) a_Rotation -= 360.f;
+ if( a_Rotation >= 0.f && a_Rotation < 90.f )
+ return 0x2;
+ else if( a_Rotation >= 180 && a_Rotation < 270 )
+ return 0x3;
+ else if( a_Rotation >= 90 && a_Rotation < 180 )
+ return 0x0;
+ else
+ return 0x1;
+ } //tolua_export
+}; //tolua_export