Compare commits
4 Commits
0.6.1-alph
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| a7c75d2ad2 | |||
| 468ae4a211 | |||
| 9405e8daad | |||
| bef09a3305 |
@@ -54,16 +54,3 @@ void CreativeMode::initAbilities( Abilities& abilities ) {
|
||||
bool CreativeMode::isCreativeType() {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ public:
|
||||
|
||||
void initAbilities(Abilities& abilities);
|
||||
|
||||
void releaseUsingItem(Player* player);
|
||||
private:
|
||||
void creativeDestroyBlock(int x, int y, int z, int face);
|
||||
};
|
||||
|
||||
@@ -92,19 +92,6 @@ bool CreatorMode::isCreativeType() {
|
||||
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() {
|
||||
return _creator;
|
||||
}
|
||||
|
||||
@@ -118,7 +118,6 @@ public:
|
||||
|
||||
void initAbilities(Abilities& abilities);
|
||||
|
||||
void releaseUsingItem(Player* player);
|
||||
private:
|
||||
void CreatorDestroyBlock(int x, int y, int z, int face);
|
||||
|
||||
|
||||
@@ -89,8 +89,8 @@ bool GameMode::useItemOn(Player* player, Level* level, ItemInstance* item, int x
|
||||
float clickX = hit.x - x;
|
||||
float clickY = hit.y - y;
|
||||
float clickZ = hit.z - z;
|
||||
item = player->inventory->getSelected();
|
||||
if(level->isClientSide) {
|
||||
if (level->isClientSide) {
|
||||
item = player->inventory->getSelected();
|
||||
UseItemPacket packet(x, y, z, face, item, player->entityId, clickX, clickY, clickZ);
|
||||
minecraft->raknetInstance->send(packet);
|
||||
}
|
||||
@@ -149,7 +149,7 @@ void GameMode::initPlayer( 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);
|
||||
minecraft->raknetInstance->send(packet);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,9 @@ static const float kMinimumTrackingForDrag = 5;
|
||||
static const float kMinIndicatorLength = 34.0f / 3;
|
||||
static const float PKScrollIndicatorEndSize = 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(
|
||||
int optionFlags,
|
||||
@@ -70,13 +73,19 @@ ScrollingPane::ScrollingPane(
|
||||
}
|
||||
//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 (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);
|
||||
|
||||
te_moved = 0;
|
||||
@@ -114,6 +123,34 @@ void ScrollingPane::tick() {
|
||||
updateScrollFade(vScroll);
|
||||
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) {
|
||||
@@ -549,11 +586,39 @@ void ScrollingPane::stepThroughDecelerationAnimation(bool noAnimation) {
|
||||
}
|
||||
|
||||
void ScrollingPane::scrollBy(float dx, float dy) {
|
||||
// adjust the translation offsets fpx/fpy by the requested amount
|
||||
float nfpx = fpx + dx;
|
||||
float nfpy = fpy + dy;
|
||||
// convert back to content offset (fpx = -contentOffset.x)
|
||||
setContentOffset(Vec3(-nfpx, -nfpy, 0));
|
||||
// compute target content offset from wheel delta (in screen-space w/ opposite sign)
|
||||
float targetX = _contentOffset.x - dx;
|
||||
float targetY = _contentOffset.y - dy;
|
||||
|
||||
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) {
|
||||
|
||||
@@ -91,7 +91,8 @@ void IngameBlockSelectionScreen::init()
|
||||
//for (int i = 0; i < inventory->getContainerSize(); ++i)
|
||||
//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;
|
||||
|
||||
//
|
||||
@@ -265,7 +266,8 @@ void IngameBlockSelectionScreen::buttonClicked(Button* button) {
|
||||
|
||||
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;
|
||||
|
||||
#ifdef DEMO_MODE
|
||||
|
||||
@@ -388,6 +388,12 @@ void LocalPlayer::calculateFlight(float xa, float ya, float za) {
|
||||
ya = 0;
|
||||
za = za * flySpeed;
|
||||
|
||||
if (sprinting) {
|
||||
float sprintBoost = getWalkingSpeedModifier(); // 1.3x
|
||||
xa *= sprintBoost;
|
||||
za *= sprintBoost;
|
||||
}
|
||||
|
||||
#ifdef ANDROID
|
||||
if (Keyboard::isKeyDown(103)) ya = .2f * flySpeed;
|
||||
if (Keyboard::isKeyDown(102)) ya = -.2f * flySpeed;
|
||||
@@ -506,7 +512,7 @@ void LocalPlayer::aiStep() {
|
||||
if (sprintDoubleTapTimer > 0) sprintDoubleTapTimer--;
|
||||
prevForwardHeld = forwardHeld;
|
||||
}
|
||||
if (input->sneaking || abilities.flying)
|
||||
if (input->sneaking)
|
||||
sprinting = false;
|
||||
|
||||
if (input->sneaking) {
|
||||
|
||||
Reference in New Issue
Block a user