本文整理汇总了Java中org.spongepowered.api.entity.living.ArmorStand类的典型用法代码示例。如果您正苦于以下问题:Java ArmorStand类的具体用法?Java ArmorStand怎么用?Java ArmorStand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ArmorStand类属于org.spongepowered.api.entity.living包,在下文中一共展示了ArmorStand类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDummyArmorStand
import org.spongepowered.api.entity.living.ArmorStand; //导入依赖的package包/类
static ArmorStand createDummyArmorStand(Block block) {
World world = block.getWorld()
.orElseThrow(() -> new IllegalStateException("Could not access the world this block resides in."));
Vector3d armorStandPosition = block.getPosition().toDouble().add(Vector3d.ONE.mul(0.5));
ArmorStand armorStand = (ArmorStand) world.createEntity(EntityTypes.ARMOR_STAND, armorStandPosition);
armorStand.offer(Keys.IS_SILENT, true);
armorStand.offer(Keys.INVISIBLE, true);
armorStand.offer(Keys.ARMOR_STAND_MARKER, true);
armorStand.offer(Keys.HAS_GRAVITY, false);
armorStand.offer(Keys.PERSISTS, true);
armorStand.offer(Keys.IS_SILENT, true);
armorStand.setHeadRotation(Vector3d.ZERO);
armorStand.setRotation(Vector3d.ZERO);
return armorStand;
}
示例2: readFrom
import org.spongepowered.api.entity.living.ArmorStand; //导入依赖的package包/类
@Override
public void readFrom(DataView data) {
super.readFrom(data);
this.tracker.readFrom(this.world, data);
this.pickaxeStand = (ArmorStand) this.tracker.get("toolStand");
this.block.setStand((ArmorStand) this.tracker.get("blockStand"));
FallingBlock falling = (FallingBlock) this.tracker.get("blockEntity");
this.block.setEntity(falling, false);
if (falling != null) {
// Vanilla serializes this as a byte so we need to set it back to Integer.MIN_VALUE
falling.offer(Keys.FALL_TIME, Integer.MIN_VALUE);
}
this.task.readFrom(data.getView(of("task")).get());
}
示例3: create
import org.spongepowered.api.entity.living.ArmorStand; //导入依赖的package包/类
private boolean create() {
if (this.entity == null) {
return false;
}
if (this.stand != null) {
// For some reason setPassenger behaves differently
return this.entity.setVehicle(this.stand);
}
this.stand = (ArmorStand) this.entity.getWorld().createEntity(EntityTypes.ARMOR_STAND,
this.entity.getLocation().getPosition());
if (!this.stand.offer(Keys.HAS_GRAVITY, false).isSuccessful()) {
return false;
}
ArmorStandData data = this.stand.getOrCreate(ArmorStandData.class).get();
data.set(data.basePlate().set(false));
data.set(data.small().set(true));
data.set(data.marker().set(true));
if (!this.stand.offer(data).isSuccessful()) {
return false;
}
this.stand.tryOffer(Keys.INVISIBLE, true);
if (!this.stand.addPassenger(this.entity)) {
return false;
}
return true;
}
示例4: spawnItem
import org.spongepowered.api.entity.living.ArmorStand; //导入依赖的package包/类
private void spawnItem(World world) {
if (this.entityRef != null) {
this.itemStand = (ArmorStand) world.getEntity(this.entityRef).orElse(null);
this.entityRef = null;
if (this.itemStand != null) {
return;
}
}
this.itemStand = createStand(world, this.pos);
Item itemEntity = createItem(world, this.pos, this.stack, true);
if (!this.itemStand.addPassenger(itemEntity)) {
this.itemStand = null;
return; // Attach passenger failed
}
if (!world.spawnEntity(this.itemStand, WorldManager.SPAWN_CAUSE)) {
this.itemStand = null;
return; // Spawn stand failed
}
if (!world.spawnEntity(itemEntity, WorldManager.SPAWN_CAUSE)) {
this.itemStand = null;
return; // Spawn item failed
}
}
示例5: setupArmorStand
import org.spongepowered.api.entity.living.ArmorStand; //导入依赖的package包/类
private void setupArmorStand(ArmorStand stand, Vector3d rotation) {
ArmorStandData data = stand.getOrCreate(ArmorStandData.class).get();
data.set(data.basePlate().set(false));
data.set(data.marker().set(true));
stand.offer(data);
stand.offer(Keys.HAS_GRAVITY, false);
if (rotation != null) {
stand.offer(Keys.HEAD_ROTATION, rotation);
}
stand.setRotation(Vector3d.ZERO);
stand.setHelmet(this.pane);
// EntityArmorStand entStand = (EntityArmorStand) stand;
// entStand.preventEntitySpawning = false;
// entStand.width = 0.5F;
// entStand.height = 1.1F;
// entStand.noClip = true;
// AxisAlignedBB bb = entStand.getEntityBoundingBox();
// entStand.setEntityBoundingBox(new AxisAlignedBB(bb.minX, bb.minY, bb.minZ,
// bb.minX + 0.5, bb.minY + 0.5, bb.minZ + 0.5));
stand.tryOffer(Keys.INVISIBLE, true);
}
示例6: PipeBlock
import org.spongepowered.api.entity.living.ArmorStand; //导入依赖的package包/类
public PipeBlock() {
this.pane = ItemStack.of(ItemTypes.STAINED_GLASS_PANE, 1);
Vector3d rotX = new Vector3d(90, 0, 0);
Vector3d rotY = new Vector3d(0, 90, 0);
this.entityStruct = new MultiEntityStructure.Builder()
.define(Direction.DOWN.name(), EntityTypes.ARMOR_STAND,
armorStandOffset(true, Axis.Z, new Vector3f(0.5, 0.2, 0.5)),
ArmorStand.class, stand -> setupArmorStand(stand, rotX))
.define(Direction.UP.name(), EntityTypes.ARMOR_STAND,
armorStandOffset(true, Axis.Z, new Vector3f(0.5, 0.7375, 0.5)),
ArmorStand.class, stand -> setupArmorStand(stand, rotX))
.define(Direction.NORTH.name(), EntityTypes.ARMOR_STAND,
armorStandOffset(false, Axis.Z, new Vector3f(0.5, 0.2, 0.2)),
ArmorStand.class, stand -> setupArmorStand(stand, null))
.define(Direction.SOUTH.name(), EntityTypes.ARMOR_STAND,
armorStandOffset(false, Axis.Z, new Vector3f(0.5, 0.2, 0.8)),
ArmorStand.class, stand -> setupArmorStand(stand, null))
.define(Direction.EAST.name(), EntityTypes.ARMOR_STAND,
armorStandOffset(false, Axis.X, new Vector3f(0.8, 0.2, 0.5)),
ArmorStand.class, stand -> setupArmorStand(stand, rotY))
.define(Direction.WEST.name(), EntityTypes.ARMOR_STAND,
armorStandOffset(false, Axis.X, new Vector3f(0.2, 0.2, 0.5)),
ArmorStand.class, stand -> setupArmorStand(stand, rotY))
.build();
}
示例7: removeArmorstands
import org.spongepowered.api.entity.living.ArmorStand; //导入依赖的package包/类
public void removeArmorstands() {
for(World bit: Sponge.getServer().getWorlds()) {
for (Entity ent : bit.getEntities()) {
if (ent instanceof ArmorStand) {
ArmorStand arm = (ArmorStand) ent;
if (arm.getCreator().isPresent()) {
if (arm.getCreator().get().equals(UUID.fromString(armorStandIdentifier))) {
arm.remove();
}
}
}
}
}
}
示例8: onArmorStand
import org.spongepowered.api.entity.living.ArmorStand; //导入依赖的package包/类
@Listener
public void onArmorStand(SpawnEntityEvent.ChunkLoad event){
for(Entity e : event.getEntities()){
if(!(e instanceof ArmorStand))
continue;
ArmorStand as = (ArmorStand) e;
if (as.getCreator().isPresent()) {
if (as.getCreator().get().equals(UUID.fromString(armorStandIdentifier))) {
as.remove();
}
}
}
}
示例9: onInteract
import org.spongepowered.api.entity.living.ArmorStand; //导入依赖的package包/类
@Listener(order=Order.FIRST, beforeModifications = true)
public void onInteract(InteractEntityEvent event, @First Player player)
{
if (!ConfigHandler.getNode("worlds").getNode(player.getWorld().getName()).getNode("enabled").getBoolean())
{
return;
}
if (player.hasPermission("nations.admin.bypass.perm.interact"))
{
return;
}
Entity target = event.getTargetEntity();
if (target instanceof Player || target instanceof Monster)
{
return;
}
if (target instanceof ItemFrame || target instanceof ArmorStand)
{
if (player.hasPermission("nations.admin.bypass.perm.build"))
{
return;
}
if (!DataHandler.getPerm("build", player.getUniqueId(), event.getTargetEntity().getLocation()))
{
event.setCancelled(true);
player.sendMessage(Text.of(TextColors.RED, LanguageHandler.ERROR_PERM_BUILD));
}
return;
}
if (!DataHandler.getPerm("interact", player.getUniqueId(), event.getTargetEntity().getLocation()))
{
event.setCancelled(true);
player.sendMessage(Text.of(TextColors.RED, LanguageHandler.ERROR_PERM_INTERACT));
}
}
示例10: getDataHolder
import org.spongepowered.api.entity.living.ArmorStand; //导入依赖的package包/类
@Override
default ArmorStand getDataHolder() {
Entity entity = getExtent().getEntity(getArmorStandId())
.orElseThrow(() -> new IllegalStateException("Could not find the armor stand entity."));
if(!(entity instanceof ArmorStand))
throw new IllegalStateException("The data holder entity assigned to this custom block is not an armor stand.");
return (ArmorStand) entity;
}
示例11: resolveCurrentModel
import org.spongepowered.api.entity.living.ArmorStand; //导入依赖的package包/类
@Override
protected Optional<String> resolveCurrentModel() {
ArmorStand armorStand = getDataHolder();
PluginContainer pluginContainer = getDefinition().getPluginContainer();
return armorStand.getHelmet()
.flatMap(itemStack -> DurabilityRegistry.resolveCurrentModel(itemStack, pluginContainer));
}
示例12: applyModel
import org.spongepowered.api.entity.living.ArmorStand; //导入依赖的package包/类
@Override
protected void applyModel(String model) {
ArmorStand armorStand = getDataHolder();
ItemStack itemStack = createHelmet(model);
armorStand.setHelmet(itemStack);
}
示例13: AbstractCustomBlock
import org.spongepowered.api.entity.living.ArmorStand; //导入依赖的package包/类
public AbstractCustomBlock(T definition, Block block, UUID armorStandId) {
super(definition);
Preconditions.checkArgument(block.getWorld().isPresent(), "Invalid extent.");
this.block = block;
Preconditions.checkArgument(getExtent().getEntity(armorStandId)
.filter(ArmorStand.class::isInstance).isPresent(), "The armor stand is not accessible.");
this.armorStandId = armorStandId;
}
示例14: getBlock
import org.spongepowered.api.entity.living.ArmorStand; //导入依赖的package包/类
public Optional<? extends CustomBlock<? extends CustomBlockDefinition>> getBlock(ArmorStand armorStand) {
return getBlockDefinition(armorStand).flatMap(definition -> {
Block block = Block.of(armorStand.getLocation());
blockToArmorStand.put(block, Optional.of(armorStand.getUniqueId()));
return definition.wrapIfPossible(block);
});
}
示例15: findArmorStandAt
import org.spongepowered.api.entity.living.ArmorStand; //导入依赖的package包/类
public Optional<ArmorStand> findArmorStandAt(Block block) {
Set<ArmorStand> armorStands = findArmorStandsAt(block);
if (armorStands.isEmpty())
return Optional.empty();
Iterator<ArmorStand> armorStandIterator = armorStands.iterator();
ArmorStand armorStand = armorStandIterator.next();
while (armorStandIterator.hasNext()) {
armorStandIterator.next().remove();
}
return Optional.of(armorStand);
}