Made beds placeable
Android: Updated some stuff and set default view distance lower git-svn-id: http://mc-server.googlecode.com/svn/trunk@900 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
cead22a206
commit
fe61687b97
@ -14,11 +14,12 @@ public final class R {
|
||||
public static final int ic_launcher=0x7f020000;
|
||||
}
|
||||
public static final class id {
|
||||
public static final int ip_address=0x7f050004;
|
||||
public static final int listView1=0x7f050005;
|
||||
public static final int server_status_text=0x7f050003;
|
||||
public static final int start_server=0x7f050001;
|
||||
public static final int stop_server=0x7f050002;
|
||||
public static final int configure_server=0x7f050003;
|
||||
public static final int ip_address=0x7f050005;
|
||||
public static final int listView1=0x7f050006;
|
||||
public static final int server_status_text=0x7f050004;
|
||||
public static final int start_server=0x7f050002;
|
||||
public static final int stop_server=0x7f050001;
|
||||
public static final int textView2=0x7f050000;
|
||||
}
|
||||
public static final class layout {
|
||||
@ -27,6 +28,7 @@ public final class R {
|
||||
}
|
||||
public static final class string {
|
||||
public static final int app_name=0x7f040001;
|
||||
public static final int configure=0x7f040007;
|
||||
public static final int hello=0x7f040000;
|
||||
public static final int mcserver_is_not_running=0x7f040005;
|
||||
public static final int mcserver_is_running=0x7f040004;
|
||||
|
@ -17,7 +17,6 @@ LOCAL_CFLAGS := -DANDROID_NDK \
|
||||
-funroll-loops \
|
||||
-mfloat-abi=softfp -mfpu=neon \
|
||||
-fexceptions \
|
||||
-D_DEBUG \
|
||||
|
||||
|
||||
LOCAL_STATIC_LIBRARIES := cpufeatures
|
||||
|
@ -12,19 +12,34 @@
|
||||
android:text="@string/app_name"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/start_server"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/start" />
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/stop_server"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:enabled="true"
|
||||
android:text="@string/stop" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/start_server"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/start" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/configure_server"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/configure" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/server_status_text"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -8,5 +8,6 @@
|
||||
<string name="mcserver_is_running">MCServer is running</string>
|
||||
<string name="mcserver_is_not_running">MCServer is not running</string>
|
||||
<string name="your_ip">Your IP …</string>
|
||||
<string name="configure">Configure</string>
|
||||
|
||||
</resources>
|
@ -10,7 +10,9 @@ import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
@ -55,6 +57,13 @@ public class MCServerActivity extends Activity {
|
||||
}
|
||||
});
|
||||
|
||||
((Button)findViewById(R.id.configure_server)).setOnClickListener( new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://localhost:8081/webadmin/"));
|
||||
startActivity( myIntent );
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
ListView lv = (ListView)this.findViewById(R.id.listView1);
|
||||
@ -162,11 +171,13 @@ public class MCServerActivity extends Activity {
|
||||
((TextView)findViewById(R.id.server_status_text)).setTextColor(Color.GREEN);
|
||||
((Button)findViewById(R.id.stop_server)).setEnabled(true);
|
||||
((Button)findViewById(R.id.start_server)).setEnabled(false);
|
||||
((Button)findViewById(R.id.configure_server)).setEnabled(true);
|
||||
} else {
|
||||
((TextView)findViewById(R.id.server_status_text)).setText(R.string.mcserver_is_not_running);
|
||||
((TextView)findViewById(R.id.server_status_text)).setTextColor(Color.RED);
|
||||
((Button)findViewById(R.id.stop_server)).setEnabled(false);
|
||||
((Button)findViewById(R.id.start_server)).setEnabled(true);
|
||||
((Button)findViewById(R.id.configure_server)).setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,20 +1,20 @@
|
||||
[Server]
|
||||
Port=25565
|
||||
MaxPlayers=10000
|
||||
Description=MCServer - Slightly more custom!
|
||||
MaxPlayers=100
|
||||
Description=MCServer - asdf
|
||||
|
||||
[Worlds]
|
||||
;World=world_sexy
|
||||
DefaultWorld=world
|
||||
World=hello
|
||||
|
||||
[Plugins]
|
||||
;NewPlugin=Protect
|
||||
;NewPlugin=MagicCarpet
|
||||
;NewPlugin=ChatLog
|
||||
;NewPlugin=BlockInfo
|
||||
NewPlugin=CuboidPlus
|
||||
;NewPlugin=ChunkWorx
|
||||
NewPlugin=Core
|
||||
NewPlugin=ChunkWorx
|
||||
|
||||
[HelpPlugin]
|
||||
ShowPluginNames=1
|
||||
|
@ -1690,6 +1690,10 @@
|
||||
<Filter
|
||||
Name="Blocks"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\source\blocks\BlockBed.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\source\blocks\BlockCactus.h"
|
||||
>
|
||||
@ -1878,6 +1882,10 @@
|
||||
<Filter
|
||||
Name="Items"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\source\items\ItemBed.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\source\items\ItemBucket.h"
|
||||
>
|
||||
|
@ -46,7 +46,11 @@ public:
|
||||
|
||||
static const int MAXBLOCKCHANGEINTERACTIONS = 20; // 5 didn't help, 10 still doesn't work in Creative, 20 seems to have done the trick
|
||||
|
||||
static const int DEFAULT_VIEW_DISTANCE = 9; // The default ViewDistance (used when no value is set in Settings.ini)
|
||||
#if defined(ANDROID_NDK)
|
||||
static const int DEFAULT_VIEW_DISTANCE = 4; // The default ViewDistance (used when no value is set in Settings.ini)
|
||||
#else
|
||||
static const int DEFAULT_VIEW_DISTANCE = 9;
|
||||
#endif
|
||||
static const int MAX_VIEW_DISTANCE = 10;
|
||||
static const int MIN_VIEW_DISTANCE = 4;
|
||||
|
||||
|
@ -240,6 +240,7 @@ public:
|
||||
|
||||
void SetBlock (int a_X, int a_Y, int a_Z, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ); //tolua_export
|
||||
void FastSetBlock (int a_X, int a_Y, int a_Z, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ); //tolua_export
|
||||
void FastSetBlock (const Vector3i & a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ) { FastSetBlock( a_Pos.x, a_Pos.y, a_Pos.z, a_BlockType, a_BlockMeta ); } // tolua_export
|
||||
BLOCKTYPE GetBlock(int a_X, int a_Y, int a_Z ); //tolua_export
|
||||
BLOCKTYPE GetBlock(const Vector3i & a_Pos ) { return GetBlock( a_Pos.x, a_Pos.y, a_Pos.z ); } //tolua_export
|
||||
NIBBLETYPE GetBlockMeta(int a_X, int a_Y, int a_Z ); //tolua_export
|
||||
|
123
source/blocks/BlockBed.h
Normal file
123
source/blocks/BlockBed.h
Normal file
@ -0,0 +1,123 @@
|
||||
#pragma once
|
||||
#include "BlockHandler.h"
|
||||
#include "../World.h"
|
||||
#include "../Sign.h"
|
||||
#include "../Player.h"
|
||||
|
||||
class cBlockBedHandler : public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockBedHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockHandler(a_BlockID)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
virtual void PlaceBlock(cWorld *a_World, cPlayer *a_Player, NIBBLETYPE a_BlockMeta, int a_X, int a_Y, int a_Z, char a_Dir) override
|
||||
{
|
||||
if( a_Dir != 1 ) // Can only be placed on the floor
|
||||
return;
|
||||
|
||||
NIBBLETYPE Meta = RotationToMetaData( a_Player->GetRotation() );
|
||||
Vector3i Direction = MetaDataToDirection( Meta );
|
||||
|
||||
if (a_World->GetBlock(a_X+Direction.x, a_Y, a_Z+Direction.z) != E_BLOCK_AIR)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
a_World->SetBlock(a_X, a_Y, a_Z, E_BLOCK_BED, Meta);
|
||||
a_World->SetBlock(a_X + Direction.x, a_Y, a_Z + Direction.z, E_BLOCK_BED, Meta | 0x8);
|
||||
|
||||
OnPlacedByPlayer(a_World, a_Player, a_X, a_Y, a_Z, a_Dir);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
virtual void OnDestroyed(cWorld *a_World, int a_X, int a_Y, int a_Z) override
|
||||
{
|
||||
char OldMeta = a_World->GetBlockMeta(a_X, a_Y, a_Z);
|
||||
|
||||
Vector3i ThisPos( a_X, a_Y, a_Z );
|
||||
Vector3i Direction = MetaDataToDirection( OldMeta & 0x7 );
|
||||
if (OldMeta & 0x8)
|
||||
{
|
||||
// Was pillow
|
||||
if (a_World->GetBlock(ThisPos - Direction) == E_BLOCK_BED)
|
||||
{
|
||||
a_World->FastSetBlock(ThisPos - Direction, E_BLOCK_AIR, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Was foot end
|
||||
if (a_World->GetBlock(ThisPos + Direction) == E_BLOCK_BED)
|
||||
{
|
||||
a_World->FastSetBlock(ThisPos + Direction, E_BLOCK_AIR, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
virtual int GetDropID() override
|
||||
{
|
||||
return E_ITEM_BED;
|
||||
}
|
||||
|
||||
virtual NIBBLETYPE GetDropMeta(NIBBLETYPE a_BlockMeta) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
virtual bool AllowBlockOnTop() override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static NIBBLETYPE RotationToMetaData( float a_Rotation )
|
||||
{
|
||||
a_Rotation += 180 + (180/4); // So its not aligned with axis
|
||||
if( a_Rotation > 360.f ) a_Rotation -= 360.f;
|
||||
|
||||
a_Rotation = (a_Rotation/360) * 4;
|
||||
|
||||
return ((char)a_Rotation+2) % 4;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static Vector3i MetaDataToDirection( NIBBLETYPE a_MetaData )
|
||||
{
|
||||
switch( a_MetaData )
|
||||
{
|
||||
case 0: // south +z
|
||||
return Vector3i(0, 0, 1);
|
||||
case 1: // west -x
|
||||
return Vector3i(-1, 0, 0);
|
||||
case 2: // north -z
|
||||
return Vector3i(0, 0, -1);
|
||||
case 3: // east +x
|
||||
return Vector3i(1, 0, 0);
|
||||
};
|
||||
return Vector3i();
|
||||
}
|
||||
};
|
@ -41,6 +41,7 @@
|
||||
#include "BlockIce.h"
|
||||
#include "BlockOre.h"
|
||||
#include "BlockNote.h"
|
||||
#include "BlockBed.h"
|
||||
|
||||
|
||||
|
||||
@ -182,6 +183,8 @@ cBlockHandler *cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockID)
|
||||
return new cBlockMelonHandler(a_BlockID);
|
||||
case E_BLOCK_NOTE_BLOCK:
|
||||
return new cBlockNoteHandler(a_BlockID);
|
||||
case E_BLOCK_BED:
|
||||
return new cBlockBedHandler(a_BlockID);
|
||||
default:
|
||||
return new cBlockHandler(a_BlockID);
|
||||
break;
|
||||
|
25
source/items/ItemBed.h
Normal file
25
source/items/ItemBed.h
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ItemHandler.h"
|
||||
#include "../World.h"
|
||||
|
||||
class cItemBedHandler : public cItemHandler
|
||||
{
|
||||
public:
|
||||
cItemBedHandler(int a_ItemID)
|
||||
: cItemHandler(a_ItemID)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
virtual bool IsPlaceable() override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual BLOCKTYPE GetBlockType() override
|
||||
{
|
||||
return E_BLOCK_BED;
|
||||
}
|
||||
};
|
@ -26,6 +26,7 @@
|
||||
#include "ItemDoor.h"
|
||||
#include "ItemFood.h"
|
||||
#include "ItemSign.h"
|
||||
#include "ItemBed.h"
|
||||
|
||||
#include "../blocks/BlockHandler.h"
|
||||
|
||||
@ -166,6 +167,9 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemID)
|
||||
|
||||
case E_ITEM_SIGN:
|
||||
return new cItemSignHandler(a_ItemID);
|
||||
|
||||
case E_ITEM_BED:
|
||||
return new cItemBedHandler(a_ItemID);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user