1
0

Added some redstone items.

git-svn-id: http://mc-server.googlecode.com/svn/trunk@49 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
admin@omencraft.com 2011-11-03 05:53:54 +00:00
parent 39fd1697e4
commit 301569a6c9
4 changed files with 56 additions and 9 deletions

View File

@ -15,10 +15,10 @@ Plugin=MagicCarpet
ShowPluginNames=1 ShowPluginNames=1
[Physics] [Physics]
Water=0 Water=1
[Monsters] [Monsters]
AnimalsOn=1 AnimalsOn=0
AnimalSpawnInterval=10 AnimalSpawnInterval=10
Types=Chicken,Spider Types=Chicken,Spider

View File

@ -136,6 +136,8 @@ enum ENUM_ITEM_ID
E_ITEM_GOLDEN_APPLE = 322, E_ITEM_GOLDEN_APPLE = 322,
E_ITEM_SIGN = 323, E_ITEM_SIGN = 323,
E_ITEM_REDSTONE_DUST = 331,
E_ITEM_MILK = 335, E_ITEM_MILK = 335,
E_ITEM_EGG = 344, E_ITEM_EGG = 344,
@ -147,5 +149,6 @@ enum ENUM_ITEM_ID
E_ITEM_COOKED_FISH = 350, E_ITEM_COOKED_FISH = 350,
E_ITEM_CAKE = 354, E_ITEM_CAKE = 354,
E_ITEM_REDSTONE_REPEATER = 356,
}; };
//tolua_end //tolua_end

View File

@ -1,3 +1,4 @@
#include "cClientHandle.h" #include "cClientHandle.h"
#include "cServer.h" #include "cServer.h"
#include "cWorld.h" #include "cWorld.h"
@ -16,6 +17,7 @@
#include "cStairs.h" #include "cStairs.h"
#include "cLadder.h" #include "cLadder.h"
#include "cSign.h" #include "cSign.h"
#include "cRedstoneRepeater.h"
#include "cBlockToPickup.h" #include "cBlockToPickup.h"
#include "cMonster.h" #include "cMonster.h"
#include "cChatColor.h" #include "cChatColor.h"
@ -609,7 +611,7 @@ void cClientHandle::HandlePacket( cPacket* a_Packet )
//LOG("TimeN: %f", cRoot::Get()->GetWorld()->GetTime() ); //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 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() ); 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; break;
} }
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.
@ -639,21 +641,28 @@ void cClientHandle::HandlePacket( cPacket* a_Packet )
bool bPlaceBlock = true; bool bPlaceBlock = true;
if( PacketData->m_Direction >= 0 ) 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 ); ENUM_BLOCK_ID BlockID = (ENUM_BLOCK_ID)m_Player->GetWorld()->GetBlock( PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ );
switch( BlockID ) 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: case E_BLOCK_WORKBENCH:
{ {
////////////// For testing V ////////////// For testing V
cPacket_NewInvalidState RainPacket; cPacket_NewInvalidState RainPacket;
RainPacket.m_Reason = 1; //begin rain RainPacket.m_Reason = 1; //begin rain
Send( RainPacket ); cRoot::Get()->GetServer()->Broadcast( RainPacket );
//also strike table with lightning for test purposes //also strike table with lightning for test purposes
cPacket_Thunderbolt ThunderboltPacket; cPacket_Thunderbolt ThunderboltPacket;
ThunderboltPacket.m_xLBPos = PacketData->m_PosX; ThunderboltPacket.m_xLBPos = PacketData->m_PosX;
ThunderboltPacket.m_yLBPos = PacketData->m_PosY; ThunderboltPacket.m_yLBPos = PacketData->m_PosY;
ThunderboltPacket.m_zLBPos = PacketData->m_PosZ; ThunderboltPacket.m_zLBPos = PacketData->m_PosZ;
Send( ThunderboltPacket ); cRoot::Get()->GetServer()->Broadcast( ThunderboltPacket );
////////////// For testing ^ ////////////// For testing ^
bPlaceBlock = false; bPlaceBlock = false;
cWindow* Window = new cCraftingWindow( 0, true ); cWindow* Window = new cCraftingWindow( 0, true );
@ -666,7 +675,7 @@ void cClientHandle::HandlePacket( cPacket* a_Packet )
////////////// For testing V ////////////// For testing V
cPacket_NewInvalidState RainPacket; cPacket_NewInvalidState RainPacket;
RainPacket.m_Reason = 2; //end rain RainPacket.m_Reason = 2; //end rain
Send( RainPacket ); cRoot::Get()->GetServer()->Broadcast( RainPacket );
////////////// For testing ^ ////////////// For testing ^
bPlaceBlock = false; bPlaceBlock = false;
cBlockEntity* BlockEntity = m_Player->GetWorld()->GetBlockEntity( PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ ); 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; cItem Item;
Item.m_ItemID = Equipped.m_ItemID; Item.m_ItemID = Equipped.m_ItemID;
Item.m_ItemCount = 1; Item.m_ItemCount = 1;
LOG("PacketData->m_ItemType: %i", (int)PacketData->m_ItemType);
// Hacked in edible items go!~ // Hacked in edible items go!~
bool bEat = false; bool bEat = false;
switch( Item.m_ItemID ) switch( Item.m_ItemID )
@ -738,11 +747,27 @@ void cClientHandle::HandlePacket( cPacket* a_Packet )
break; break;
char MetaData = (char)Equipped.m_ItemHealth; char MetaData = (char)Equipped.m_ItemHealth;
bool is_redstone_dust = false;
switch( PacketData->m_ItemType ) // Special handling for special items switch( PacketData->m_ItemType ) // Special handling for special items
{ {
case E_BLOCK_TORCH: case E_BLOCK_TORCH:
MetaData = cTorch::DirectionToMetaData( PacketData->m_Direction ); MetaData = cTorch::DirectionToMetaData( PacketData->m_Direction );
break; 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_COBBLESTONE_STAIRS:
case E_BLOCK_WOODEN_STAIRS: case E_BLOCK_WOODEN_STAIRS:
MetaData = cStairs::RotationToMetaData( m_Player->GetRotation() ); MetaData = cStairs::RotationToMetaData( m_Player->GetRotation() );
@ -768,7 +793,6 @@ void cClientHandle::HandlePacket( cPacket* a_Packet )
default: default:
break; break;
}; };
if( IsValidBlock( PacketData->m_ItemType) ) if( IsValidBlock( PacketData->m_ItemType) )
{ {
if( (m_Player->GetInventory().RemoveItem( Item )) || (m_Player->GetGameMode() == 1) ) if( (m_Player->GetInventory().RemoveItem( Item )) || (m_Player->GetGameMode() == 1) )

View File

@ -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