Следуйте инструкциям в видео ниже, чтобы узнать, как установить наш сайт как веб-приложение на главный экран вашего устройства.
Примечание: Эта функция может быть недоступна в некоторых браузерах.
Пакетами?
public void playChest(Location chestLocation, boolean action) {
WorldServer world = ((CraftWorld)chestLocation.getWorld()).getHandle();
BlockPosition position = new BlockPosition(chestLocation.getX(), chestLocation.getY(), chestLocation.getZ());
if (chestLocation.getBlock().getTypeId() == 54) {
try {
TileEntityChest tileChest = (TileEntityChest)world.getTileEntity(position);
world.playBlockAction(position, tileChest.w(), 1, action ? 1 : 0);
} catch (Exception tileChest) {}
} else if (chestLocation.getBlock().getTypeId() == 130) {
try {
TileEntityEnderChest tileChest = (TileEntityEnderChest)world.getTileEntity(position);
world.playBlockAction(position, tileChest.w(), 1, action ? 1 : 0);
} catch (Exception tileChest) { }
}
}
О, прикольноИмпорты привязываются к версииJavaScript:public void playChest(Location chestLocation, boolean action) { WorldServer world = ((CraftWorld)chestLocation.getWorld()).getHandle(); BlockPosition position = new BlockPosition(chestLocation.getX(), chestLocation.getY(), chestLocation.getZ()); if (chestLocation.getBlock().getTypeId() == 54) { try { TileEntityChest tileChest = (TileEntityChest)world.getTileEntity(position); world.playBlockAction(position, tileChest.w(), 1, action ? 1 : 0); } catch (Exception tileChest) {} } else if (chestLocation.getBlock().getTypeId() == 130) { try { TileEntityEnderChest tileChest = (TileEntityEnderChest)world.getTileEntity(position); world.playBlockAction(position, tileChest.w(), 1, action ? 1 : 0); } catch (Exception tileChest) { // empty catch block } } }
БлагодарюИмпорты привязываются к версииPHP:public void playChest(Location chestLocation, boolean action) { WorldServer world = ((CraftWorld)chestLocation.getWorld()).getHandle(); BlockPosition position = new BlockPosition(chestLocation.getX(), chestLocation.getY(), chestLocation.getZ()); if (chestLocation.getBlock().getTypeId() == 54) { try { TileEntityChest tileChest = (TileEntityChest)world.getTileEntity(position); world.playBlockAction(position, tileChest.w(), 1, action ? 1 : 0); } catch (Exception tileChest) {} } else if (chestLocation.getBlock().getTypeId() == 130) { try { TileEntityEnderChest tileChest = (TileEntityEnderChest)world.getTileEntity(position); world.playBlockAction(position, tileChest.w(), 1, action ? 1 : 0); } catch (Exception tileChest) { } } }
import org.bukkit. Instrument;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Note;
import org.bukkit.block.BlockFace;
@SuppressWarnings("unused")
public class BlockAction {
@SuppressWarnings("deprecation")
public boolean playNoteBlockSound(Location location, Instrument instrument, Note note) {
BlockState state = location.getBlock().getState();
if(!(state instanceof NoteBlock))
return false;
((NoteBlock) state).play(instrument, note);
return true;
/*return playBlockAction(location, instrument.getType(), note.getId(), null,
Material.NOTE_BLOCK);*/
}
public boolean resizePiston(Location location, boolean extend, BlockFace direction) { //for retraction use extend = false
int directionId; //not direction.ordinal()
if (direction == BlockFace.DOWN) directionId = 0;
else if (direction == BlockFace.UP) directionId = 1;
else if (direction == BlockFace.SOUTH) directionId = 2;
else if (direction == BlockFace.WEST) directionId = 3;
else if (direction == BlockFace.NORTH) directionId = 4;
else if (direction == BlockFace.EAST) directionId = 5;
else return false;
return playBlockAction(location, extend ? 0 : 1, directionId, null,
Material.PISTON_BASE); //PISTON_EXTENSION, PISTON_STICKY_BASE, PISTON_MOVING_PIECE?
}
public boolean setChestOpened(Location location, boolean opened) {
return playBlockAction(location, 1, opened ? 1 : 0, null,
Material.CHEST,
Material.TRAPPED_CHEST,
Material.ENDER_CHEST);
}
public boolean recalculateBeaconBeam(Location location) {
return playBlockAction(location, 1, 0, null,
Material.BEACON);
}
public boolean resetSpawnerSpawnDelay(Location location) {
return playBlockAction(location, 1, 0, null,
Material.MOB_SPAWNER);
}
public boolean startEndGatewayBeam(Location location) { //https://minecraft.gamepedia.com/End_Gateway_(block)#Beam
return playBlockAction(location, 1, 0, null,
Material.END_GATEWAY);
}
public boolean setShulkerBoxOpened(Location location, boolean opened) {
return location.getBlock().getState() instanceof ShulkerBox
&& playBlockAction(location, 1, opened ? 1 : 0, null);
}
private boolean playBlockAction(Location location, int actionId, int actionParam, Material newMaterial, Material... allowedMaterials) {
boolean allowed = false;
Material type = location.getBlock().getType();
for (Material material : allowedMaterials) {
if (material != type)
continue;
allowed = true;
break;
}
if (!allowed)
return false;
if (newMaterial == null)
newMaterial = location.getBlock().getType();
((org.bukkit.craftbukkit.v1_12_R1.CraftWorld) location.getWorld()).getHandle()
.playBlockAction(
new net.minecraft.server.v1_12_R1.BlockPosition(
location.getX(),
location.getY(),
location.getZ()),
org.bukkit.craftbukkit.v1_12_R1.util.CraftMagicNumbers.getBlock(newMaterial),
actionId,
actionParam);
return true;
}
}