本文整理匯總了Java中org.bukkit.entity.ItemFrame.setRotation方法的典型用法代碼示例。如果您正苦於以下問題:Java ItemFrame.setRotation方法的具體用法?Java ItemFrame.setRotation怎麽用?Java ItemFrame.setRotation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.entity.ItemFrame
的用法示例。
在下文中一共展示了ItemFrame.setRotation方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onEntityInteractEntity
import org.bukkit.entity.ItemFrame; //導入方法依賴的package包/類
@EventHandler
public void onEntityInteractEntity(PlayerInteractEntityEvent event) {
if (event.getRightClicked().getType() == EntityType.ITEM_FRAME) {
event.setCancelled(true);
ItemFrame frame = (ItemFrame) event.getRightClicked();
frame.setRotation(Rotation.NONE);
}
}
示例2: attachItemFrame
import org.bukkit.entity.ItemFrame; //導入方法依賴的package包/類
public static void attachItemFrame(Block block, ItemStack map, BlockFace face) {
ItemFrame frame = block.getWorld().spawn(block.getRelative(face).getLocation(), ItemFrame.class);
Block frameBlock = block.getRelative(face);
frameBlock.setType(Material.AIR);
frame.teleport(frameBlock.getLocation());
frame.setFacingDirection(face, true);
frame.setItem(map);
frame.setRotation(Rotation.NONE);
}
示例3: find
import org.bukkit.entity.ItemFrame; //導入方法依賴的package包/類
private ItemFrame[][] find(Location pos1, Location pos2, BlockFace facing) {
try {
Location distance = pos2.clone().subtract(pos1).add(1, 1, 1);
int width = Math.max(distance.getBlockX(), distance.getBlockZ());
ItemFrame[][] frames = new ItemFrame[width][distance.getBlockY()];
World world = pos1.getWorld();
this.reverse = (facing == BlockFace.NORTH || facing == BlockFace.EAST);
int v = 0;
for (double y = pos1.getY(); y <= pos2.getY(); y++, v++) {
int h = 0;
for (double z = pos1.getZ(); z <= pos2.getZ(); z++) {
for (double x = pos1.getX(); x <= pos2.getX(); x++, h++) {
Location pos = new Location(world, x, y, z);
Collection<Entity> entities = world.getNearbyEntities(pos, 0.1, 0.1, 0.1);
boolean contains = false;
for (Entity ent : entities) {
if (ent instanceof ItemFrame && ((ItemFrame) ent).getFacing() == facing) {
ItemFrame itemFrame = (ItemFrame) ent;
itemFrame.setRotation(Rotation.NONE);
contains = true;
frames[reverse ? width - 1 - h : h][v] = (ItemFrame) ent;
break;
}
}
if (!contains) return null;
}
}
}
return frames;
} catch (Throwable e) {
e.printStackTrace();
}
return null;
}
示例4: onFrameDestroy
import org.bukkit.entity.ItemFrame; //導入方法依賴的package包/類
@EventHandler
public void onFrameDestroy(FrameDestroyEvent e){
if(e.getAction().equals(FrameAction.LeftClick)){
e.setCancelled(true);
ItemFrame frame = e.getItemFrame();
frame.setRotation(frame.getRotation().rotateCounterClockwise());
}
}
示例5: onEntityDamageByEntity
import org.bukkit.entity.ItemFrame; //導入方法依賴的package包/類
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent e) {
if (e.getEntityType().equals(EntityType.ITEM_FRAME)) {
ItemFrame itemFrame = (ItemFrame) e.getEntity();
if (e.getDamager() instanceof Player) {
Player player = (Player) e.getDamager();
if(player.isSneaking()){
itemFrame.setRotation(itemFrame.getRotation().rotateCounterClockwise());
e.setCancelled(true);
}
}
}
}
示例6: execute
import org.bukkit.entity.ItemFrame; //導入方法依賴的package包/類
@Override
public void execute(BlockPlacer blockPlacer, BlockLoger loger) {
Chunk chunk = m_location.getChunk();
if (!chunk.isLoaded()) {
if (!chunk.load()) {
return;
}
}
World w = m_location.getWorld();
Block block = w.getBlockAt(m_location);
Material material = block.getType();
if (!isSolid(material)) {
m_oldMaterial = material;
block.setType(Material.BARRIER);
} else {
m_oldMaterial = null;
}
m_frame = (ItemFrame) w.spawn(block.getRelative(m_rotation).getLocation(), ItemFrame.class);
m_frame.setFacingDirection(m_rotation, true);
m_frame.setRotation(Rotation.NONE);
m_mapView = Bukkit.createMap(w);
m_mapHelper.storeMap(m_mapView, m_img);
m_mapHelper.drawImage(m_mapView, m_img);
m_frame.setItem(new ItemStack(Material.MAP, 1, m_mapView.getId()));
}
示例7: rotate
import org.bukkit.entity.ItemFrame; //導入方法依賴的package包/類
private void rotate() {
Craftomat.debug("rotate", "Called! ("+Craftomat.DELAY_BETWEEN_ROTATIONS.toTicks() + ", " +(System.currentTimeMillis() - this.rotationStart) + ", " + this.isRotating + ")");
if (!this.isRotating) {
if (this.rotationTask != null && this.rotationTask.isEnabled()) { this.rotationTask.disable(); }
Craftomat.debug("rotate", "Method still called even though craftomat has finished rotation?!");
return;
}
// Check if the craftomat is still valid
if (!this.isValid()) { this.finish(); return; }
final ItemFrame frame = this.getItemFrame().get();
// Check if the item is still in the frame
final ItemStack itemStack = frame.getItem();
if (itemStack == null || itemStack.getType().equals(Material.AIR)) { this.finish(); return; }
// Rotate the itemframe
switch (frame.getRotation()) {
case NONE: frame.setRotation(Rotation.CLOCKWISE_45); break;
case CLOCKWISE_45: frame.setRotation(Rotation.CLOCKWISE); break;
case CLOCKWISE: frame.setRotation(Rotation.CLOCKWISE_135); break;
case CLOCKWISE_135: frame.setRotation(Rotation.FLIPPED); break;
case FLIPPED: frame.setRotation(Rotation.FLIPPED_45); break;
case FLIPPED_45: frame.setRotation(Rotation.COUNTER_CLOCKWISE); break;
case COUNTER_CLOCKWISE: frame.setRotation(Rotation.COUNTER_CLOCKWISE_45); break;
case COUNTER_CLOCKWISE_45: frame.setRotation(Rotation.NONE); break;
default: CraftoMessenger.warnStaff("Got unknown itemframe rotation '" + frame.getRotation() + "' in Craftomat#rotate()!"); break;
}
// Update the sign
final Sign sign = this.getSign().get();
if (sign.getLine(0).length() < 1) {
sign.setLine(0, ChatColor.BOLD + "#");
sign.setLine(3, ChatColor.BOLD + "#");
}
else {
sign.setLine(0, sign.getLine(0) + "#");
sign.setLine(3, sign.getLine(3) + "#");
}
sign.update(true, false);
// Play sound
frame.getLocation().getWorld().playSound(frame.getLocation(), Sound.BLOCK_WOOD_BUTTON_CLICK_ON, 0.75f, 0.4f);
// Check if this is the last run
if (System.currentTimeMillis() - this.rotationStart > Craftomat.COMPLETE_ROTATION_DURATION.toMillis()) {
this.finish();
}
}
示例8: applyToEntity
import org.bukkit.entity.ItemFrame; //導入方法依賴的package包/類
private boolean applyToEntity(Entity entity) {
entity.teleport(_location);
if (entity instanceof Directional && _facing != null) {
Directional directional = (Directional)entity;
directional.setFacingDirection(_facing);
}
if (entity instanceof Painting && _art != null) {
Painting painting = (Painting)entity;
painting.setArt(_art);
}
if (entity instanceof ItemFrame && _frameItem != null) {
ItemFrame frame = (ItemFrame)entity;
frame.setItem(_frameItem);
frame.setRotation(_frameRotation);
}
if (entity instanceof ArmorStand && _hasArmorStand) {
ArmorStand stand = (ArmorStand)entity;
stand.setItemInHand(_itemInHand);
stand.setHelmet(_helmet);
stand.setChestplate(_chestplate);
stand.setLeggings(_leggings);
stand.setBoots(_boots);
stand.setHeadPose(_headPose);
stand.setBodyPose(_bodyPose);
stand.setLeftArmPose(_leftArmPose);
stand.setRightArmPose(_rightArmPose);
stand.setLeftLegPose(_leftLegPose);
stand.setRightLegPose(_rightLegPose);
stand.setBasePlate(_hasArmorBasePlate);
stand.setGravity(_hasArmorGravity);
stand.setVisible(_isArmorVisible);
stand.setArms(_hasArmorArms);
stand.setSmall(_isArmorSmall);
}
if (_facing == null)
return false;
return true;
}