Skip to content

Commit

Permalink
兼容Nukkit-MOT
Browse files Browse the repository at this point in the history
  • Loading branch information
lt-name committed Jun 4, 2023
1 parent c73ba21 commit 11eb0d3
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 14 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# ImageNK
Show images in your pnx server!
Show images in your server!
Modified version of Nukkit-MOT supported
35 changes: 31 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,46 @@

<groupId>cn.daoge</groupId>
<artifactId>ImageNK</artifactId>
<version>1.0.3</version>
<version>1.0.3-MOT</version>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<repositories>
<repository>
<id>opencollab-repo-release</id>
<url>https://repo.opencollab.dev/maven-releases/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>opencollab-repo-snapshot</id>
<url>https://repo.opencollab.dev/maven-snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>repo-lanink-cn</id>
<url>https://repo.lanink.cn/</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>cn.powernukkitx</groupId>
<artifactId>powernukkitx</artifactId>
<version>1.19.30-r2</version>
<groupId>cn.nukkit</groupId>
<artifactId>Nukkit</artifactId>
<version>MOT-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
27 changes: 20 additions & 7 deletions src/main/java/cn/daoge/imagenk/manager/SimpleImageMapManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
import cn.daoge.imagenk.imagemapstorage.ImageMapStorage;
import cn.daoge.imagenk.imageprovider.ImageProvider;
import cn.nukkit.block.Block;
import cn.nukkit.block.BlockEntityHolder;
import cn.nukkit.block.BlockID;
import cn.nukkit.block.BlockItemFrame;
import cn.nukkit.blockentity.BlockEntity;
import cn.nukkit.blockentity.BlockEntityItemFrame;
import cn.nukkit.item.ItemMap;
import cn.nukkit.level.Position;
import cn.nukkit.math.BlockFace;
import cn.nukkit.math.SimpleAxisAlignedBB;
import cn.nukkit.nbt.tag.CompoundTag;
import cn.nukkit.nbt.tag.Tag;
import lombok.Getter;
import net.coobird.thumbnailator.Thumbnails;

Expand Down Expand Up @@ -275,16 +278,26 @@ protected void placeImageMap(Position pos, BufferedImage subImage, BlockFace fac
//获得地图
var itemMap = new ItemMap();
itemMap.setImage(subImage);

//放置方块
var frame = new BlockItemFrame();
frame.position(pos);
frame.setBlockFace(face);
frame.setStoringMap(true);
//设置显示地图
//这里我们不更新方块防止展示框掉落
var blockEntity = BlockEntityHolder.setBlockAndCreateEntity(frame, true, false);
blockEntity.setItem(itemMap);
if (rotation != null) blockEntity.setItemRotation(getMapFrameRotationByFace(rotation, down));
level.setBlock(pos, frame);
//生成并设置实体
CompoundTag nbt = new CompoundTag()
.putString("id", BlockEntity.ITEM_FRAME)
.putInt("x", (int) frame.x)
.putInt("y", (int) frame.y)
.putInt("z", (int) frame.z)
.putByte("ItemRotation", 0)
.putFloat("ItemDropChance", 1.0f);
if (BlockEntity.createBlockEntity(BlockEntity.ITEM_FRAME, frame.getChunk(), nbt) instanceof BlockEntityItemFrame blockEntity) {
blockEntity.setItem(itemMap);
if (rotation != null) {
blockEntity.setItemRotation(getMapFrameRotationByFace(rotation, down));
}
}
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: ImageNK
main: cn.daoge.imagenk.ImageNK
version: "1.0.3"
api: ["1.0.13"]
version: "1.0.3-MOT"
api: ["Nukkit-MOT"]
load: POSTWORLD
authors:
- "daoge_cmd"
Expand Down

0 comments on commit 11eb0d3

Please sign in to comment.