Skip to content

Commit

Permalink
为新内容做准备
Browse files Browse the repository at this point in the history
  • Loading branch information
wode490390 committed Oct 20, 2024
1 parent 0df2d39 commit 0f34cbb
Show file tree
Hide file tree
Showing 43 changed files with 107 additions and 47 deletions.
11 changes: 8 additions & 3 deletions src/main/java/cn/nukkit/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -2330,12 +2330,12 @@ protected void processLogin() {
for (Player p : new ObjectArrayList<>(this.server.getOnlinePlayers().values())) {
if (p != this && p.getName() != null && p.getName().equalsIgnoreCase(this.getName())) {
if (!p.kick(PlayerKickEvent.Reason.NEW_CONNECTION, "logged in from another location")) {
this.close(this.getLeaveMessage(), "Already connected");
this.close(this.getLeaveMessage(), "disconnectionScreen.loggedinOtherLocation");
return;
}
} else if (p.loggedIn && this.getUniqueId().equals(p.getUniqueId())) {
if (!p.kick(PlayerKickEvent.Reason.NEW_CONNECTION, "logged in from another location")) {
this.close(this.getLeaveMessage(), "Already connected");
this.close(this.getLeaveMessage(), "disconnectionScreen.loggedinOtherLocation");
return;
}
}
Expand Down Expand Up @@ -3034,7 +3034,12 @@ public void onCompletion(Server server) {
if (this.isBreakingBlock()) {
block = this.level.getBlock(pos, false);
face = BlockFace.fromIndex(playerActionPacket.data);
this.level.addParticle(new PunchBlockParticle(pos, block, face));
Vector3 blockCenter = pos.blockCenter();
this.level.addParticle(new PunchBlockParticle(blockCenter, block, face));
level.addLevelEvent(blockCenter, LevelEventPacket.EVENT_PARTICLE_PUNCH_BLOCK_DOWN + face.getIndex(), block.getFullId());

int breakTime = Mth.ceil(block.getBreakTime(inventory.getItemInHand(), this) * 20);
level.addLevelEvent(pos, LevelEventPacket.EVENT_BLOCK_UPDATE_BREAK, breakTime <= 0 ? 0 : 65535 / breakTime);
}
break;
}
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/cn/nukkit/block/Block.java
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ private float getDestroySpeed(Item item, boolean correctTool) {
if (is(WEB) || isLeaves()) {
return 15;
}
if (is(WOOL)) {
if (isWool()) {
return 5;
}
if (is(VINE) || is(GLOW_LICHEN)) {
Expand Down Expand Up @@ -1414,6 +1414,10 @@ public boolean isCauldron() {
return false;
}

public boolean isWool() {
return false;
}

public boolean isWaxed() {
return false;
}
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/cn/nukkit/block/BlockNoteblock.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,17 @@ public void increaseStrength() {
}

public Instrument getInstrument() {
switch (this.down().getId()) {
Block below = this.down();
if (below.isWool()) {
return Instrument.GUITAR;
}
switch (below.getId()) {
case GOLD_BLOCK:
return Instrument.GLOCKENSPIEL;
case CLAY:
return Instrument.FLUTE;
case PACKED_ICE:
return Instrument.CHIME;
case WOOL:
return Instrument.GUITAR;
case BONE_BLOCK:
return Instrument.XYLOPHONE;
case IRON_BLOCK:
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/cn/nukkit/block/BlockWool.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,9 @@ public BlockColor getColor() {
public DyeColor getDyeColor() {
return DyeColor.getByWoolData(getDamage());
}

@Override
public boolean isWool() {
return true;
}
}
4 changes: 2 additions & 2 deletions src/main/java/cn/nukkit/command/CommandParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ public Vector2 senderAsVector2() {
public Block parseBlock() throws CommandSyntaxException {
String arg = this.next();
try {
Block block = Block.fromStringNullable(arg, true);
Block block = Block.fromStringNullable(arg.toLowerCase(), true);
if (block == null) {
throw CommandExceptions.COMMAND_SYNTAX_EXCEPTION;
}
Expand All @@ -901,7 +901,7 @@ public Block parseBlockOrDefault(Supplier<Block> defaultValue) throws CommandSyn
public Item parseItem() throws CommandSyntaxException {
String arg = this.next();
try {
Item item = Item.fromStringNullable(arg, true);
Item item = Item.fromStringNullable(arg.toLowerCase(), true);
if (item == null) {
throw CommandExceptions.COMMAND_SYNTAX_EXCEPTION;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/item/ItemArmor.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected ItemArmor(int id, Integer meta, int count) {
}

protected ItemArmor(int id, Integer meta, int count, String name) {
super(id, meta, 1, name);
super(id, meta, count, name);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/item/ItemBannerPattern.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public ItemBannerPattern(Integer meta) {
}

public ItemBannerPattern(Integer meta, int count) {
super(BANNER_PATTERN, meta, 1, getName(meta != null ? meta : 0));
super(BANNER_PATTERN, meta, count, getName(meta != null ? meta : 0));
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/item/ItemBed.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public ItemBed(Integer meta) {
}

public ItemBed(Integer meta, int count) {
super(BED, meta, 1, DyeColor.getByWoolData(meta != null ? meta : 0).getName() + " Bed");
super(BED, meta, count, DyeColor.getByWoolData(meta != null ? meta : 0).getName() + " Bed");
this.block = Block.get(BlockID.BLOCK_BED);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/item/ItemBeetrootSoup.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public ItemBeetrootSoup(Integer meta) {
}

public ItemBeetrootSoup(Integer meta, int count) {
super(BEETROOT_SOUP, 0, 1, "Beetroot Soup");
super(BEETROOT_SOUP, 0, count, "Beetroot Soup");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/item/ItemBoat.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public ItemBoat(Integer meta) {
}

public ItemBoat(Integer meta, int count) {
super(BOAT, meta, 1, "Boat");
super(BOAT, meta, count, "Boat");
}

protected ItemBoat(int id, Integer meta, int count, String name) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/item/ItemBookAndQuill.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public ItemBookAndQuill(Integer meta) {
}

public ItemBookAndQuill(Integer meta, int count) {
super(Item.WRITABLE_BOOK, meta, 1, "Book and Quill");
super(Item.WRITABLE_BOOK, meta, count, "Book and Quill");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/item/ItemBookEnchanted.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public ItemBookEnchanted(Integer meta) {
}

public ItemBookEnchanted(Integer meta, int count) {
super(ENCHANTED_BOOK, meta, 1, "Enchanted Book");
super(ENCHANTED_BOOK, meta, count, "Enchanted Book");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/item/ItemCompassLodestone.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public ItemCompassLodestone(Integer meta) {
}

public ItemCompassLodestone(Integer meta, int count) {
super(LODESTONE_COMPASS, meta, 1, "Lodestone Compass");
super(LODESTONE_COMPASS, meta, count, "Lodestone Compass");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/item/ItemGoatHorn.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public ItemGoatHorn(Integer meta) {
}

public ItemGoatHorn(Integer meta, int count) {
super(GOAT_HORN, meta, 1, "Goat Horn");
super(GOAT_HORN, meta, count, "Goat Horn");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/item/ItemHorseArmorDiamond.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public ItemHorseArmorDiamond(Integer meta) {
}

public ItemHorseArmorDiamond(Integer meta, int count) {
super(DIAMOND_HORSE_ARMOR, meta, 1, "Diamond Horse Armor");
super(DIAMOND_HORSE_ARMOR, meta, count, "Diamond Horse Armor");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/item/ItemHorseArmorGold.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public ItemHorseArmorGold(Integer meta) {
}

public ItemHorseArmorGold(Integer meta, int count) {
super(GOLDEN_HORSE_ARMOR, meta, 1, "Gold Horse Armor");
super(GOLDEN_HORSE_ARMOR, meta, count, "Gold Horse Armor");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/item/ItemHorseArmorIron.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public ItemHorseArmorIron(Integer meta) {
}

public ItemHorseArmorIron(Integer meta, int count) {
super(IRON_HORSE_ARMOR, meta, 1, "Iron Horse Armor");
super(IRON_HORSE_ARMOR, meta, count, "Iron Horse Armor");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/item/ItemHorseArmorLeather.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public ItemHorseArmorLeather(Integer meta) {
}

public ItemHorseArmorLeather(Integer meta, int count) {
super(LEATHER_HORSE_ARMOR, meta, 1, "Leather Horse Armor");
super(LEATHER_HORSE_ARMOR, meta, count, "Leather Horse Armor");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/item/ItemMace.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public ItemMace(Integer meta) {
}

public ItemMace(Integer meta, int count) {
super(MACE, meta, 1, "Mace");
super(MACE, meta, count, "Mace");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/item/ItemMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public ItemMap(Integer meta) {
}

public ItemMap(Integer meta, int count) {
super(FILLED_MAP, meta, 1, "Map");
super(FILLED_MAP, meta, count, "Map");

if (!hasCompoundTag() || !getNamedTag().contains("map_uuid")) {
CompoundTag tag = new CompoundTag();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/item/ItemMinecart.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public ItemMinecart(Integer meta) {
}

public ItemMinecart(Integer meta, int count) {
super(MINECART, meta, 1, "Minecart");
super(MINECART, meta, count, "Minecart");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/item/ItemMinecartChest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public ItemMinecartChest(Integer meta) {
}

public ItemMinecartChest(Integer meta, int count) {
super(CHEST_MINECART, meta, 1, "Minecart with Chest");
super(CHEST_MINECART, meta, count, "Minecart with Chest");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/item/ItemMinecartCommandBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public ItemMinecartCommandBlock(Integer meta) {
}

public ItemMinecartCommandBlock(Integer meta, int count) {
super(COMMAND_BLOCK_MINECART, meta, 1, "Minecart with Command Block");
super(COMMAND_BLOCK_MINECART, meta, count, "Minecart with Command Block");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/item/ItemMinecartHopper.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public ItemMinecartHopper(Integer meta) {
}

public ItemMinecartHopper(Integer meta, int count) {
super(HOPPER_MINECART, meta, 1, "Minecart with Hopper");
super(HOPPER_MINECART, meta, count, "Minecart with Hopper");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/item/ItemMinecartTNT.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public ItemMinecartTNT(Integer meta) {
}

public ItemMinecartTNT(Integer meta, int count) {
super(TNT_MINECART, meta, 1, "Minecart with TNT");
super(TNT_MINECART, meta, count, "Minecart with TNT");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/item/ItemMushroomStew.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public ItemMushroomStew(Integer meta) {
}

public ItemMushroomStew(Integer meta, int count) {
super(MUSHROOM_STEW, meta, 1, "Mushroom Stew");
super(MUSHROOM_STEW, meta, count, "Mushroom Stew");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/item/ItemPotion.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public ItemPotion(Integer meta) {
}

public ItemPotion(Integer meta, int count) {
super(POTION, meta, 1, "Potion");
super(POTION, meta, count, "Potion");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/item/ItemPotionLingering.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public ItemPotionLingering(Integer meta) {
}

public ItemPotionLingering(Integer meta, int count) {
super(LINGERING_POTION, meta, 1, "Lingering Potion");
super(LINGERING_POTION, meta, count, "Lingering Potion");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/item/ItemPotionSplash.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public ItemPotionSplash(Integer meta) {
}

public ItemPotionSplash(Integer meta, int count) {
super(SPLASH_POTION, meta, 1, "Splash Potion");
super(SPLASH_POTION, meta, count, "Splash Potion");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/item/ItemRabbitStew.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public ItemRabbitStew(Integer meta) {
}

public ItemRabbitStew(Integer meta, int count) {
super(RABBIT_STEW, meta, 1, "Rabbit Stew");
super(RABBIT_STEW, meta, count, "Rabbit Stew");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/item/ItemRecord.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
public abstract class ItemRecord extends Item {

protected ItemRecord(int id, Integer meta, int count) {
super(id, meta, 1, "Music Disc");
super(id, meta, count, "Music Disc");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/item/ItemSaddle.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public ItemSaddle(Integer meta) {
}

public ItemSaddle(Integer meta, int count) {
super(SADDLE, meta, 1, "Saddle");
super(SADDLE, meta, count, "Saddle");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/item/ItemSpyglass.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public ItemSpyglass(Integer meta) {
}

public ItemSpyglass(Integer meta, int count) {
super(SPYGLASS, meta, 1, "Spyglass");
super(SPYGLASS, meta, count, "Spyglass");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/item/ItemSuspiciousStew.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public ItemSuspiciousStew(Integer meta) {
}

public ItemSuspiciousStew(Integer meta, int count) {
super(SUSPICIOUS_STEW, meta, 1, "Suspicious Stew");
super(SUSPICIOUS_STEW, meta, count, "Suspicious Stew");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/item/ItemTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected ItemTool(int id, Integer meta, int count) {
}

protected ItemTool(int id, Integer meta, int count, String name) {
super(id, meta, 1, name);
super(id, meta, count, name);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/item/ItemTotem.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public ItemTotem(Integer meta) {
}

public ItemTotem(Integer meta, int count) {
super(TOTEM_OF_UNDYING, meta, 1, "Totem of Undying");
super(TOTEM_OF_UNDYING, meta, count, "Totem of Undying");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/item/ItemWolfArmor.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public ItemWolfArmor(Integer meta) {
}

public ItemWolfArmor(Integer meta, int count) {
super(WOLF_ARMOR, meta, 1, "Wolf Armor");
super(WOLF_ARMOR, meta, count, "Wolf Armor");
}

@Override
Expand Down
Loading

0 comments on commit 0f34cbb

Please sign in to comment.