6 Commits

9 changed files with 848 additions and 801 deletions

View File

@@ -54,16 +54,3 @@ void CreativeMode::initAbilities( Abilities& abilities ) {
bool CreativeMode::isCreativeType() { bool CreativeMode::isCreativeType() {
return true; return true;
} }
void CreativeMode::releaseUsingItem( Player* player ) {
if(player->getCarriedItem() != NULL) {
int oldItemId = player->getCarriedItem()->id;
int oldAux = player->getAuxData();
super::releaseUsingItem(player);
if(player->getCarriedItem() != NULL && player->getCarriedItem()->id == oldItemId) {
player->getCarriedItem()->setAuxValue(oldAux);
}
} else {
super::releaseUsingItem(player);
}
}

View File

@@ -19,7 +19,6 @@ public:
void initAbilities(Abilities& abilities); void initAbilities(Abilities& abilities);
void releaseUsingItem(Player* player);
private: private:
void creativeDestroyBlock(int x, int y, int z, int face); void creativeDestroyBlock(int x, int y, int z, int face);
}; };

View File

@@ -92,19 +92,6 @@ bool CreatorMode::isCreativeType() {
return true; return true;
} }
void CreatorMode::releaseUsingItem( Player* player ) {
if(player->getCarriedItem() != NULL) {
int oldItemId = player->getCarriedItem()->id;
int oldAux = player->getAuxData();
super::releaseUsingItem(player);
if(player->getCarriedItem() != NULL && player->getCarriedItem()->id == oldItemId) {
player->getCarriedItem()->setAuxValue(oldAux);
}
} else {
super::releaseUsingItem(player);
}
}
ICreator* CreatorMode::getCreator() { ICreator* CreatorMode::getCreator() {
return _creator; return _creator;
} }

View File

@@ -118,7 +118,6 @@ public:
void initAbilities(Abilities& abilities); void initAbilities(Abilities& abilities);
void releaseUsingItem(Player* player);
private: private:
void CreatorDestroyBlock(int x, int y, int z, int face); void CreatorDestroyBlock(int x, int y, int z, int face);

View File

@@ -89,8 +89,8 @@ bool GameMode::useItemOn(Player* player, Level* level, ItemInstance* item, int x
float clickX = hit.x - x; float clickX = hit.x - x;
float clickY = hit.y - y; float clickY = hit.y - y;
float clickZ = hit.z - z; float clickZ = hit.z - z;
if (level->isClientSide) {
item = player->inventory->getSelected(); item = player->inventory->getSelected();
if(level->isClientSide) {
UseItemPacket packet(x, y, z, face, item, player->entityId, clickX, clickY, clickZ); UseItemPacket packet(x, y, z, face, item, player->entityId, clickX, clickY, clickZ);
minecraft->raknetInstance->send(packet); minecraft->raknetInstance->send(packet);
} }
@@ -149,7 +149,7 @@ void GameMode::initPlayer( Player* player ) {
} }
void GameMode::releaseUsingItem(Player* player){ void GameMode::releaseUsingItem(Player* player){
if(minecraft->level->isClientSide) { if (minecraft->level->isClientSide && player->isUsingItem()) {
PlayerActionPacket packet(PlayerActionPacket::RELEASE_USE_ITEM, 0, 0, 0, 0, player->entityId); PlayerActionPacket packet(PlayerActionPacket::RELEASE_USE_ITEM, 0, 0, 0, 0, player->entityId);
minecraft->raknetInstance->send(packet); minecraft->raknetInstance->send(packet);
} }

View File

@@ -20,6 +20,9 @@ static const float kMinimumTrackingForDrag = 5;
static const float kMinIndicatorLength = 34.0f / 3; static const float kMinIndicatorLength = 34.0f / 3;
static const float PKScrollIndicatorEndSize = 3; static const float PKScrollIndicatorEndSize = 3;
static const float PKScrollIndicatorThickness = 7.0f /3; static const float PKScrollIndicatorThickness = 7.0f /3;
static const float kWheelOverscrollMax = 80.0f;
static const float kWheelOverscrollDamping = 0.6f;
static const float kWheelOverscrollRestoreAlpha = 0.18f;
ScrollingPane::ScrollingPane( ScrollingPane::ScrollingPane(
int optionFlags, int optionFlags,
@@ -70,13 +73,19 @@ ScrollingPane::ScrollingPane(
} }
//LOGI("%d, %d :: %d\n", bbox.w, itemBbox.w, this->columns); //LOGI("%d, %d :: %d\n", bbox.w, itemBbox.w, this->columns);
rows = 1 + (numItems-1) / this->columns, rows = 1 + (numItems-1) / this->columns;
/* /*
if (columns * itemBbox.w <= bbox.w) flags |= SF_LockX; if (columns * itemBbox.w <= bbox.w) flags |= SF_LockX;
if (rows * itemBbox.h <= bbox.h) flags |= SF_LockY; if (rows * itemBbox.h <= bbox.h) flags |= SF_LockY;
*/ */
// initialize content bounds immediately
adjustContentSize();
minPoint.set((float)(this->size.w - this->adjustedContentSize.w), (float)(this->size.h - this->adjustedContentSize.h), 0);
this->snapContentOffsetToBounds(false);
dragDeltas.reserve(128); dragDeltas.reserve(128);
te_moved = 0; te_moved = 0;
@@ -114,6 +123,34 @@ void ScrollingPane::tick() {
updateScrollFade(vScroll); updateScrollFade(vScroll);
updateScrollFade(hScroll); updateScrollFade(hScroll);
} }
if (isNotSet(SF_HardLimits) && !Mouse::isButtonDown(MouseAction::ACTION_LEFT) && !dragging && !tracking && !decelerating) {
float targetX = _contentOffset.x;
float targetY = _contentOffset.y;
bool corrected = false;
if (targetX > 0.0f) {
targetX = Mth::lerp(targetX, 0.0f, kWheelOverscrollRestoreAlpha);
corrected = true;
} else if (targetX < minPoint.x) {
targetX = Mth::lerp(targetX, minPoint.x, kWheelOverscrollRestoreAlpha);
corrected = true;
}
if (targetY > 0.0f) {
targetY = Mth::lerp(targetY, 0.0f, kWheelOverscrollRestoreAlpha);
corrected = true;
} else if (targetY < minPoint.y) {
targetY = Mth::lerp(targetY, minPoint.y, kWheelOverscrollRestoreAlpha);
corrected = true;
}
if (corrected) {
if (Mth::abs(targetX - _contentOffset.x) < 0.25f) targetX = (targetX > 0.0f ? 0.0f : (targetX < minPoint.x ? minPoint.x : targetX));
if (Mth::abs(targetY - _contentOffset.y) < 0.25f) targetY = (targetY > 0.0f ? 0.0f : (targetY < minPoint.y ? minPoint.y : targetY));
setContentOffset(Vec3(targetX, targetY, 0));
}
}
} }
bool ScrollingPane::getGridItemFor_slow(int itemIndex, GridItem& out) { bool ScrollingPane::getGridItemFor_slow(int itemIndex, GridItem& out) {
@@ -549,11 +586,39 @@ void ScrollingPane::stepThroughDecelerationAnimation(bool noAnimation) {
} }
void ScrollingPane::scrollBy(float dx, float dy) { void ScrollingPane::scrollBy(float dx, float dy) {
// adjust the translation offsets fpx/fpy by the requested amount // compute target content offset from wheel delta (in screen-space w/ opposite sign)
float nfpx = fpx + dx; float targetX = _contentOffset.x - dx;
float nfpy = fpy + dy; float targetY = _contentOffset.y - dy;
// convert back to content offset (fpx = -contentOffset.x)
setContentOffset(Vec3(-nfpx, -nfpy, 0)); if (isSet(SF_LockX)) targetX = _contentOffset.x;
if (isSet(SF_LockY)) targetY = _contentOffset.y;
if (isSet(SF_HardLimits)) {
targetX = Mth::clamp(targetX, minPoint.x, 0.0f);
targetY = Mth::clamp(targetY, minPoint.y, 0.0f);
} else {
if (targetX > 0.0f) {
float overshoot = targetX;
overshoot = Mth::Min(overshoot, kWheelOverscrollMax);
targetX = overshoot * kWheelOverscrollDamping;
} else if (targetX < minPoint.x) {
float overshoot = targetX - minPoint.x;
overshoot = Mth::Max(overshoot, -kWheelOverscrollMax);
targetX = minPoint.x + overshoot * kWheelOverscrollDamping;
}
if (targetY > 0.0f) {
float overshoot = targetY;
overshoot = Mth::Min(overshoot, kWheelOverscrollMax);
targetY = overshoot * kWheelOverscrollDamping;
} else if (targetY < minPoint.y) {
float overshoot = targetY - minPoint.y;
overshoot = Mth::Max(overshoot, -kWheelOverscrollMax);
targetY = minPoint.y + overshoot * kWheelOverscrollDamping;
}
}
setContentOffset(Vec3(targetX, targetY, 0));
} }
void ScrollingPane::setContentOffset(float x, float y) { void ScrollingPane::setContentOffset(float x, float y) {

View File

@@ -28,6 +28,7 @@ void CreditsScreen::init() {
buttons.push_back(bHeader); buttons.push_back(bHeader);
buttons.push_back(btnBack); buttons.push_back(btnBack);
// TODO: rewrite it
// prepare text lines // prepare text lines
_lines.clear(); _lines.clear();
_lines.push_back("Minecraft: Pocket Edition"); _lines.push_back("Minecraft: Pocket Edition");
@@ -39,6 +40,7 @@ void CreditsScreen::init() {
_lines.push_back("Kolyah35"); _lines.push_back("Kolyah35");
_lines.push_back("karson"); _lines.push_back("karson");
_lines.push_back("deepfriedwaffles"); _lines.push_back("deepfriedwaffles");
_lines.push_back("EpikIzCool");
_lines.push_back(""); _lines.push_back("");
// avoid color tags around the URL so it isn't mangled by the parser please // avoid color tags around the URL so it isn't mangled by the parser please
_lines.push_back("Join our Discord server: https://discord.gg/c58YesBxve"); _lines.push_back("Join our Discord server: https://discord.gg/c58YesBxve");

View File

@@ -91,7 +91,8 @@ void IngameBlockSelectionScreen::init()
//for (int i = 0; i < inventory->getContainerSize(); ++i) //for (int i = 0; i < inventory->getContainerSize(); ++i)
//LOGI("> %d - %s\n", i, inventory->getItem(i)? inventory->getItem(i)->getDescriptionId().c_str() : "<-->\n"); //LOGI("> %d - %s\n", i, inventory->getItem(i)? inventory->getItem(i)->getDescriptionId().c_str() : "<-->\n");
InventorySize = inventory->getContainerSize(); // Grid indices are 0..N-1 for main inventory only; slots 0..MAX_SELECTION_SIZE-1 are hotbar links.
InventorySize = inventory->getContainerSize() - Inventory::MAX_SELECTION_SIZE;
InventoryRows = 1 + (InventorySize-1) / InventoryColumns; InventoryRows = 1 + (InventorySize-1) / InventoryColumns;
// //
@@ -265,7 +266,8 @@ void IngameBlockSelectionScreen::buttonClicked(Button* button) {
bool IngameBlockSelectionScreen::isAllowed( int slot ) bool IngameBlockSelectionScreen::isAllowed( int slot )
{ {
if (slot < 0 || slot >= minecraft->player->inventory->getContainerSize()) const int gridCount = minecraft->player->inventory->getContainerSize() - Inventory::MAX_SELECTION_SIZE;
if (slot < 0 || slot >= gridCount)
return false; return false;
#ifdef DEMO_MODE #ifdef DEMO_MODE

View File

@@ -388,6 +388,12 @@ void LocalPlayer::calculateFlight(float xa, float ya, float za) {
ya = 0; ya = 0;
za = za * flySpeed; za = za * flySpeed;
if (sprinting) {
float sprintBoost = getWalkingSpeedModifier(); // 1.3x
xa *= sprintBoost;
za *= sprintBoost;
}
#ifdef ANDROID #ifdef ANDROID
if (Keyboard::isKeyDown(103)) ya = .2f * flySpeed; if (Keyboard::isKeyDown(103)) ya = .2f * flySpeed;
if (Keyboard::isKeyDown(102)) ya = -.2f * flySpeed; if (Keyboard::isKeyDown(102)) ya = -.2f * flySpeed;
@@ -506,7 +512,7 @@ void LocalPlayer::aiStep() {
if (sprintDoubleTapTimer > 0) sprintDoubleTapTimer--; if (sprintDoubleTapTimer > 0) sprintDoubleTapTimer--;
prevForwardHeld = forwardHeld; prevForwardHeld = forwardHeld;
} }
if (input->sneaking || abilities.flying) if (input->sneaking)
sprinting = false; sprinting = false;
if (input->sneaking) { if (input->sneaking) {