Merge pull request #330 from Project-Cepi/no-compile-error-demo

Fix entity compile error in Demo package
This commit is contained in:
TheMode 2021-06-16 21:57:03 +02:00 committed by GitHub
commit 3076a06dbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,9 +1,11 @@
package net.minestom.demo.largeframebuffers;
import net.kyori.adventure.text.Component;
import net.minestom.server.MinecraftServer;
import net.minestom.server.chat.ColoredText;
import net.minestom.server.entity.Entity;
import net.minestom.server.entity.EntityType;
import net.minestom.server.entity.GameMode;
import net.minestom.server.entity.type.decoration.EntityItemFrame;
import net.minestom.server.entity.metadata.other.ItemFrameMeta;
import net.minestom.server.instance.Instance;
import net.minestom.server.instance.InstanceManager;
import net.minestom.server.item.ItemStack;
@ -66,15 +68,26 @@ public class Demo {
}
private static void createFrame(Instance instance, int id, int x, int y, int z) {
EntityItemFrame itemFrame = new EntityItemFrame(new Position(x, y, z), EntityItemFrame.ItemFrameOrientation.NORTH);
itemFrame.getPosition().setYaw(180f);
Entity itemFrame = new Entity(EntityType.ITEM_FRAME);
ItemFrameMeta itemFrameMeta = (ItemFrameMeta) itemFrame.getEntityMeta();
itemFrameMeta.setNotifyAboutChanges(false);
itemFrameMeta.setOrientation(ItemFrameMeta.Orientation.NORTH);
ItemStack map = ItemStack.builder(Material.FILLED_MAP)
.meta(new MapMeta.Builder().mapId(id).build())
.build();
itemFrame.setItemStack(map);
itemFrame.setInstance(instance);
itemFrame.setCustomNameVisible(true);
itemFrame.setCustomName(ColoredText.of("MapID: " + id));
itemFrameMeta.setItem(map);
itemFrameMeta.setCustomNameVisible(true);
itemFrameMeta.setCustomName(Component.text("MapID: " + id));
itemFrameMeta.setNotifyAboutChanges(true);
itemFrame.setInstance(instance, new Position(x, y, z));
itemFrame.getPosition().setYaw(180f);
}
private static void setupMaps(Instance instance, int mapIDStart, int zCoordinate) {