Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ gson = { group = "com.google.code.gson", name = "gson", version = "2.10.1" }
snakeyaml = { group = "org.yaml", name = "snakeyaml", version = "1.33" }
leveldb = { group = "org.iq80.leveldb", name = "leveldb", version = "0.11.1-SNAPSHOT" }
leveldbjni = { group = "net.daporkchop", name = "leveldb-mcpe-jni", version = "0.0.10-SNAPSHOT" }
snappy = { group = "org.xerial.snappy", name = "snappy-java", version = "1.1.10.7" }
snappy = { group = "org.xerial.snappy", name = "snappy-java", version = "1.1.10.8" }
jwt = { group = "com.nimbusds", name = "nimbus-jose-jwt", version = "10.3.1" }
jopt-simple = { group = "net.sf.jopt-simple", name = "jopt-simple", version = "5.0.4" }
blockstateupdater = { group = "org.cloudburstmc", name = "block-state-updater", version = "1.21.40-SNAPSHOT" }
Expand Down
16 changes: 10 additions & 6 deletions src/main/java/cn/nukkit/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public class Player extends EntityHuman implements CommandSender, InventoryHolde
protected Position spawnPosition;

protected int inAirTicks;
protected int startAirTicks = 10;
protected int startAirTicks = 5;

protected AdventureSettings adventureSettings;
protected Color locatorBarColor;
Expand Down Expand Up @@ -501,7 +501,7 @@ public void setAdventureSettings(AdventureSettings adventureSettings) {
*/
public void resetInAirTicks() {
if (this.inAirTicks != 0) {
this.startAirTicks = 10;
this.startAirTicks = 5;
}
this.inAirTicks = 0;
}
Expand Down Expand Up @@ -1649,10 +1649,14 @@ public boolean setGamemode(int gamemode, boolean clientSide, AdventureSettings n
this.dataPacket(pk);
}

if (this.isSpectator()) {
// Tp not on ground to not fly slowly
this.teleport(this.add(0, 0.0001, 0), null);
}

this.setAdventureSettings(ev.getNewAdventureSettings());

if (this.isSpectator()) {
this.teleport(this, null);
this.setDataFlag(DATA_FLAGS, DATA_FLAG_SILENT, true, false);
this.setDataFlag(DATA_FLAGS, DATA_FLAG_HAS_COLLISION, false); // Sends both
} else {
Expand Down Expand Up @@ -2359,7 +2363,7 @@ public boolean onUpdate(int currentTick) {
PlayerInvalidMoveEvent ev = new PlayerInvalidMoveEvent(this, true);
this.getServer().getPluginManager().callEvent(ev);
if (!ev.isCancelled()) {
this.startAirTicks = this.inAirTicks - 10;
this.startAirTicks = this.inAirTicks - 5;
this.setMotion(new Vector3(0, expectedVelocity, 0));
}
} else if (this.kick(PlayerKickEvent.Reason.FLYING_DISABLED, MSG_FLYING_NOT_ENABLED, true)) {
Expand Down Expand Up @@ -4160,8 +4164,8 @@ public void onCompletion(Server server) {
if (this.loomTransaction.execute()) {
level.addLevelSoundEvent(this, LevelSoundEventPacket.SOUND_BLOCK_LOOM_USE);
}
this.loomTransaction = null;
}
this.loomTransaction = null; // Must be here or stuff will break
return;
}

Expand Down Expand Up @@ -5349,7 +5353,7 @@ public void close(TextContainer message, String reason, boolean notify) {
if (notify && !reason.isEmpty()) {
DisconnectPacket pk = new DisconnectPacket();
// New disconnection screen doesn't support colors :(
pk.message = reason = TextFormat.clean(reason);
pk.message = TextFormat.clean(reason);
this.forceDataPacket(pk, null);
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/cn/nukkit/block/Block.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package cn.nukkit.block;

import cn.nukkit.AdventureSettings;
import cn.nukkit.Player;
import cn.nukkit.Server;
import cn.nukkit.entity.Entity;
Expand Down Expand Up @@ -566,7 +567,7 @@ public double getBreakTime(Item item, Player player) {
boolean insideOfWaterWithoutAquaAffinity = player.isInsideOfWater() &&
Optional.ofNullable(player.getInventory().getHelmet().getEnchantment(Enchantment.ID_WATER_WORKER))
.map(Enchantment::getLevel).map(l -> l >= 1).orElse(false);
boolean outOfWaterButNotOnGround = (!player.isInsideOfWater()) && (!player.isOnGround());
boolean outOfWaterButNotOnGround = !player.isOnGround() && !player.getAdventureSettings().get(AdventureSettings.Type.FLYING) && !player.isInsideOfWater();
return breakTime0(blockHardness, correctTool, canHarvestWithHand, blockId, itemToolType, itemTier,
efficiencyLoreLevel, hasteEffectLevel, insideOfWaterWithoutAquaAffinity, outOfWaterButNotOnGround);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/cn/nukkit/block/BlockButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public boolean onActivate(Item item, Player player) {

this.level.getServer().getPluginManager().callEvent(new BlockRedstoneEvent(this, 0, 15));
this.setDamage(this.getDamage() ^ 0x08);
this.level.setBlock(this, this, true, false);
this.level.setBlock(this, this, true, true);
this.level.addLevelSoundEvent(this, LevelSoundEventPacket.SOUND_POWER_ON);
this.level.scheduleUpdate(this, 30);

Expand All @@ -77,7 +77,7 @@ public int onUpdate(int type) {
this.level.getServer().getPluginManager().callEvent(new BlockRedstoneEvent(this, 15, 0));

this.setDamage(this.getDamage() ^ 0x08);
this.level.setBlock(this, this, true, false);
this.level.setBlock(this, this, true, true);
this.level.addLevelSoundEvent(this, LevelSoundEventPacket.SOUND_POWER_OFF);

level.updateAroundRedstone(this, null);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/block/BlockChain.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public BlockChain(int meta) {

@Override
public String getName() {
return "Chain";
return "Iron Chain";
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/block/BlockFenceGate.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public boolean toggle(Player player) {
}

this.setDamage(direction | ((~this.getDamage()) & 0x04));
this.level.setBlock(this, this, true, false);
this.level.setBlock(this, this, true, true);
if (this.isOpen()) {
this.level.addSound(this, Sound.RANDOM_DOOR_OPEN);
} else {
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/cn/nukkit/block/BlockHoneyBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,9 @@ public void onEntityCollide(Entity entity) {
}
}
}

@Override
public double getFrictionFactor() {
return 0.8;
}
}
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/block/BlockLava.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void onEntityCollide(Entity entity) {

@Override
public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
boolean ret = this.getLevel().setBlock(this, this, true, false);
boolean ret = this.getLevel().setBlock(this, this, true, true);
this.getLevel().scheduleUpdate(this, this.tickRate());

return ret;
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/cn/nukkit/block/BlockLightBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,9 @@ public Item toItem() {
public boolean canBePushed() {
return false;
}

@Override
public double getFrictionFactor() {
return 0.9;
}
}
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/block/BlockMushroom.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public boolean onActivate(Item item, Player player) {
}

public boolean grow() {
this.level.setBlock(this, Block.get(BlockID.AIR), true, false);
this.level.setBlock(this, Block.get(BlockID.AIR), true, true);

BigMushroom generator = new BigMushroom(getType());

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/block/BlockOreRedstone.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected int getRawMaterial() {
@Override
public int onUpdate(int type) {
if (type == Level.BLOCK_UPDATE_TOUCH) {
this.getLevel().setBlock(this, Block.get(GLOWING_REDSTONE_ORE), false, false);
this.getLevel().setBlock(this, Block.get(GLOWING_REDSTONE_ORE), false, true);
this.getLevel().scheduleUpdate(this, 600);

return Level.BLOCK_UPDATE_WEAK;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public BlockOreRedstoneDeepslate() {
@Override
public int onUpdate(int type) {
if (type == Level.BLOCK_UPDATE_TOUCH) {
this.getLevel().setBlock(this, Block.get(LIT_DEEPSLATE_REDSTONE_ORE), false, false);
this.getLevel().setBlock(this, Block.get(LIT_DEEPSLATE_REDSTONE_ORE), false, true);
this.getLevel().scheduleUpdate(this, 600);

return Level.BLOCK_UPDATE_WEAK;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public int onUpdate(int type) {
BlockFadeEvent event = new BlockFadeEvent(this, Block.get(DEEPSLATE_REDSTONE_ORE));
level.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
level.setBlock(this, event.getNewState(), false, false);
level.setBlock(this, event.getNewState(), false, true);
}

return Level.BLOCK_UPDATE_WEAK;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/block/BlockOreRedstoneGlowing.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public int onUpdate(int type) {
BlockFadeEvent event = new BlockFadeEvent(this, get(REDSTONE_ORE));
level.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
level.setBlock(this, event.getNewState(), false, false);
level.setBlock(this, event.getNewState(), false, true);
}

return Level.BLOCK_UPDATE_WEAK;
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/cn/nukkit/block/BlockPistonBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public boolean place(Item item, Block block, Block target, BlockFace face, doubl
} else {
this.setDamage(player.getHorizontalFacing().getIndex());
}
this.getLevel().setBlock(this, this, true, false);
this.getLevel().setBlock(this, this, true, true);

BlockEntityPistonArm be = (BlockEntityPistonArm) BlockEntity.createBlockEntity(BlockEntity.PISTON_ARM, this.getChunk(), new CompoundTag("")
.putString("id", BlockEntity.PISTON_ARM)
Expand Down Expand Up @@ -200,7 +200,7 @@ private boolean doMove(boolean extending, BlocksCalculator calculator) {
BlockFace direction = getFacing();

if (!extending) {
this.level.setBlock(this.getSideVec(direction), Block.get(BlockID.AIR), true, false);
this.level.setBlock(this.getSideVec(direction), Block.get(BlockID.AIR), true, true);
}
if (calculator == null) {
calculator = new BlocksCalculator(this, direction, extending);
Expand Down Expand Up @@ -239,12 +239,12 @@ private boolean doMove(boolean extending, BlocksCalculator calculator) {

for (int i = blocks.size() - 1; i >= 0; --i) {
Block block = blocks.get(i);
this.level.setBlock(block, Block.get(BlockID.AIR), true, false);
this.level.setBlock(block, Block.get(BlockID.AIR), true, true);
Vector3 newPos = block.getSideVec(side);
Block newBlock = newBlocks.get(i);

// TODO: Change this to block entity
this.level.setBlock(newPos, newBlock, true, false);
this.level.setBlock(newPos, newBlock, true, true);

if (newBlock instanceof BlockPistonBase) {
BlockEntityPistonArm be = (BlockEntityPistonArm) BlockEntity.createBlockEntity(BlockEntity.PISTON_ARM, newBlock.getChunk(), new CompoundTag("")
Expand All @@ -258,7 +258,7 @@ private boolean doMove(boolean extending, BlocksCalculator calculator) {
}

if (pistonHead != null) {
this.level.setBlock(pistonHead, Block.get(this.getPistonHeadBlockId(), this.getDamage()), true, false);
this.level.setBlock(pistonHead, Block.get(this.getPistonHeadBlockId(), this.getDamage()), true, true);
}
return true;
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/block/BlockPressurePlateBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ protected void updateState(int oldStrength) {

if (oldStrength != strength) {
this.setRedstonePower(strength);
this.level.setBlock(this, this, false, false);
this.level.setBlock(this, this, false, true);

this.level.updateAroundRedstone(this, null);
this.level.updateAroundRedstone(this.getSideVec(BlockFace.DOWN), null);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/cn/nukkit/block/BlockRedstoneComparator.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public boolean onActivate(Item item, Player player) {
} else {
this.level.addLevelSoundEvent(this, LevelSoundEventPacket.SOUND_POWER_OFF);
}
this.level.setBlock(this, this, true, false);
this.level.setBlock(this, this, true, true);

this.onChange();
return true;
Expand Down Expand Up @@ -154,9 +154,9 @@ private void onChange() {
boolean isPowered = this.isPowered();

if (isPowered && !shouldBePowered) {
this.level.setBlock(this, getUnpowered(), true, false);
this.level.setBlock(this, getUnpowered(), true, true);
} else if (!isPowered && shouldBePowered) {
this.level.setBlock(this, getPowered(), true, false);
this.level.setBlock(this, getPowered(), true, true);
}

this.level.updateAroundRedstone(this, null); //TODO: remove
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/block/BlockRedstoneLampLit.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public int onUpdate(int type) {
}

if (type == Level.BLOCK_UPDATE_SCHEDULED && !this.level.isBlockPowered(this)) {
this.level.setBlock(this, Block.get(REDSTONE_LAMP), false, false);
this.level.setBlock(this, Block.get(REDSTONE_LAMP), false, true);
}
return 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public boolean onActivate(Item item, Player player) {
this.setDamage(this.getDamage() + 4);
if (this.getDamage() > 15) this.setDamage(this.getDamage() % 4);

this.level.setBlock(this, this, true, false);
this.level.setBlock(this, this, true, true);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public boolean onActivate(Item item, Player player) {
this.setDamage(this.getDamage() + 4);
if (this.getDamage() > 15) this.setDamage(this.getDamage() % 4);

this.level.setBlock(this, this, true, false);
this.level.setBlock(this, this, true, true);
return true;
}

Expand Down
10 changes: 5 additions & 5 deletions src/main/java/cn/nukkit/block/BlockSapling.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,12 @@ public boolean generate(ChunkManager level, NukkitRandom rand, Vector3 position)
}

if (bigTree) {
this.level.setBlock(vector3, Block.get(AIR), true, false);
this.level.setBlock(vector3.add(1, 0, 0), Block.get(AIR), true, false);
this.level.setBlock(vector3.add(0, 0, 1), Block.get(AIR), true, false);
this.level.setBlock(vector3.add(1, 0, 1), Block.get(AIR), true, false);
this.level.setBlock(vector3, Block.get(AIR), true, true);
this.level.setBlock(vector3.add(1, 0, 0), Block.get(AIR), true, true);
this.level.setBlock(vector3.add(0, 0, 1), Block.get(AIR), true, true);
this.level.setBlock(vector3.add(1, 0, 1), Block.get(AIR), true, true);
} else {
this.level.setBlock(this, Block.get(AIR), true, false);
this.level.setBlock(this, Block.get(AIR), true, true);
}

ListChunkManager chunkManager = new ListChunkManager(this.level);
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/cn/nukkit/block/BlockSlime.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package cn.nukkit.block;

import cn.nukkit.entity.Entity;
import cn.nukkit.entity.EntityLiving;
import cn.nukkit.math.Vector3;
import cn.nukkit.utils.BlockColor;

/**
Expand Down Expand Up @@ -31,4 +34,22 @@ public double getResistance() {
public BlockColor getColor() {
return BlockColor.GRASS_BLOCK_COLOR;
}

@Override
public boolean hasEntityCollision() {
return true;
}

@Override
public void onEntityCollide(Entity entity) {
if (entity.motionY < 0.0) {
double d = entity instanceof EntityLiving ? 1.0 : 0.8;
entity.setMotion(new Vector3(entity.motionX, -entity.motionY * d, entity.motionZ));
}
}

@Override
public double getFrictionFactor() {
return 0.8;
}
}
6 changes: 3 additions & 3 deletions src/main/java/cn/nukkit/block/BlockTripWire.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void onEntityCollide(Entity entity) {

if (!powered) {
this.setPowered(true);
this.level.setBlock(this, this, true, false);
this.level.setBlock(this, this, true, true);
this.updateHook(false);

this.level.scheduleUpdate(this, 10);
Expand Down Expand Up @@ -133,7 +133,7 @@ public int onUpdate(int type) {
this.level.scheduleUpdate(this, 10);
} else {
this.setPowered(false);
this.level.setBlock(this, this, true, false);
this.level.setBlock(this, this, true, true);
this.updateHook(false);
}
return type;
Expand All @@ -154,7 +154,7 @@ public boolean place(Item item, Block block, Block target, BlockFace face, doubl
public boolean onBreak(Item item) {
if (item.getId() == Item.SHEARS) {
this.setDisarmed(true);
this.level.setBlock(this, this, true, false);
this.level.setBlock(this, this, true, true);
this.updateHook(false);
this.getLevel().setBlock(this, Block.get(BlockID.AIR), true, true);
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/cn/nukkit/block/BlockTripWireHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public void calculateState(boolean onBreak, boolean updateAround, int pos, Block
Vector3 vec = this.getSideVec(facing, distance);
BlockFace face = facing.getOpposite();
hook.setFace(face);
this.level.setBlock(vec, hook, true, false);
this.level.setBlock(vec, hook, true, true);
this.level.updateAroundRedstone(vec, null);
this.level.updateAroundRedstone(vec.getSideVec(face.getOpposite()), null);
this.addSound(vec, canConnect, nextPowered, attached, powered);
Expand All @@ -158,7 +158,7 @@ public void calculateState(boolean onBreak, boolean updateAround, int pos, Block

if (!onBreak) {
hook.setFace(facing);
this.level.setBlock(this, hook, true, false);
this.level.setBlock(this, hook, true, true);

if (updateAround) {
this.level.updateAroundRedstone(this, null);
Expand All @@ -176,7 +176,7 @@ public void calculateState(boolean onBreak, boolean updateAround, int pos, Block
block.setDamage(block.getDamage() ^ 0x04);
}

this.level.setBlock(vc, block, true, false);
this.level.setBlock(vc, block, true, true);
}
}
}
Expand Down
Loading
Loading