use of net.minecraft.server.v1_14_R1.Block in project dynmap by webbukkit.
the class BukkitVersionHelperSpigot116_3 method initializeBlockStates.
/**
* Initialize block states (org.dynmap.blockstate.DynmapBlockState)
*/
@Override
public void initializeBlockStates() {
dataToState = new IdentityHashMap<IBlockData, DynmapBlockState>();
HashMap<String, DynmapBlockState> lastBlockState = new HashMap<String, DynmapBlockState>();
int cnt = Block.REGISTRY_ID.a();
DynmapBlockState.Builder bld = new DynmapBlockState.Builder();
// Loop through block data states
for (int i = 0; i < cnt; i++) {
IBlockData bd = Block.getByCombinedId(i);
Block b = bd.getBlock();
String bname = IRegistry.BLOCK.getKey(bd.getBlock()).toString();
// See if we have seen this one
DynmapBlockState lastbs = lastBlockState.get(bname);
int idx = 0;
if (lastbs != null) {
// Yes
// Get number of states so far, since this is next
idx = lastbs.getStateCount();
}
// Build state name
String sb = "";
String fname = bd.toString();
int off1 = fname.indexOf('[');
if (off1 >= 0) {
int off2 = fname.indexOf(']');
sb = fname.substring(off1 + 1, off2);
}
Material mat = bd.getMaterial();
// getLightBlock
int lightAtten = b.f(bd, BlockAccessAir.INSTANCE, BlockPosition.ZERO);
// Log.info("statename=" + bname + "[" + sb + "], lightAtten=" + lightAtten);
// Fill in base attributes
bld.setBaseState(lastbs).setStateIndex(idx).setBlockName(bname).setStateName(sb).setMaterial(mat.toString()).setAttenuatesLight(lightAtten);
if (mat.isSolid()) {
bld.setSolid();
}
if (mat == Material.AIR) {
bld.setAir();
}
if ((bd.getBlock() instanceof BlockRotatable) && (bd.getMaterial() == Material.WOOD)) {
bld.setLog();
}
if (mat == Material.LEAVES) {
bld.setLeaves();
}
if ((!bd.getFluid().isEmpty()) && ((bd.getBlock() instanceof BlockFluids) == false)) {
// Test if fluid type for block is not empty
bld.setWaterlogged();
}
// Build state
DynmapBlockState dbs = bld.build();
dataToState.put(bd, dbs);
lastBlockState.put(bname, (lastbs == null) ? dbs : lastbs);
Log.verboseinfo("blk=" + bname + ", idx=" + idx + ", state=" + sb + ", waterlogged=" + dbs.isWaterlogged());
}
}
use of net.minecraft.server.v1_14_R1.Block in project MechanicsMain by WeaponMechanics.
the class Block_1_14_R1 method getMultiBlockMaskPacket.
private PacketPlayOutMultiBlockChange getMultiBlockMaskPacket(List<Block> blocks, @Nullable IBlockData mask) {
net.minecraft.server.v1_14_R1.Chunk chunk = ((CraftChunk) blocks.get(0).getChunk()).getHandle();
// Setup default information
PacketPlayOutMultiBlockChange packet = new PacketPlayOutMultiBlockChange(0, new short[0], chunk);
PacketPlayOutMultiBlockChange.MultiBlockChangeInfo[] changes = new PacketPlayOutMultiBlockChange.MultiBlockChangeInfo[blocks.size()];
for (int i = 0; i < blocks.size(); i++) {
Block block = blocks.get(i);
// Where the block is relative to the chunk it is in
int x = block.getX() & 0xF;
int y = block.getY();
int z = block.getZ() & 0xF;
// Setting the (x, y, z) location into VarInt format
short location = (short) (x << 12 | y | z << 8);
// If mask is null, then undo the mask. Otherwise set the mask
if (mask == null) {
changes[i] = packet.new MultiBlockChangeInfo(location, chunk);
} else {
changes[i] = packet.new MultiBlockChangeInfo(location, mask);
}
}
ReflectionUtil.setField(multiBlockChangeB, packet, changes);
return packet;
}
use of net.minecraft.server.v1_14_R1.Block in project MechanicsMain by WeaponMechanics.
the class Block_1_14_R1 method getMultiBlockMaskPacket.
@Override
@NotNull
public List<Object> getMultiBlockMaskPacket(@NotNull List<Block> blocks, @Nullable BlockState mask) {
if (blocks == null || blocks.isEmpty()) {
throw new IllegalArgumentException("No blocks are being changed!");
}
Map<Chunk, List<Block>> sortedBlocks = new HashMap<>();
for (Block block : blocks) {
List<Block> list = sortedBlocks.computeIfAbsent(block.getChunk(), chunk -> new ArrayList<>());
list.add(block);
}
List<Object> packets = new ArrayList<>(sortedBlocks.size());
IBlockData theMask = mask == null ? null : ((CraftBlockState) mask).getHandle();
for (List<Block> entry : sortedBlocks.values()) {
packets.add(getMultiBlockMaskPacket(entry, theMask));
}
return packets;
}
use of net.minecraft.server.v1_14_R1.Block in project MechanicsMain by WeaponMechanics.
the class FakeEntity_1_14_R1 method show.
@Override
public void show(@NotNull Player player) {
PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection;
if (connections.contains(connection))
throw new IllegalArgumentException();
connection.sendPacket(type.isAlive() ? new PacketPlayOutSpawnEntityLiving((EntityLiving) entity) : new PacketPlayOutSpawnEntity(entity, type == EntityType.FALLING_BLOCK ? Block.getCombinedId(block) : 0));
connection.sendPacket(new PacketPlayOutEntityMetadata(cache, entity.getDataWatcher(), true));
connection.sendPacket(new PacketPlayOutEntityLook(cache, convertYaw(getYaw()), convertPitch(getPitch()), false));
connection.sendPacket(new PacketPlayOutEntityVelocity(cache, new Vec3D(motion.getX(), motion.getY(), motion.getZ())));
connection.sendPacket(new PacketPlayOutEntityHeadRotation(entity, convertYaw(getYaw())));
PacketPlayOutEntityEquipment[] equipment = getEquipmentPacket();
if (equipment != null) {
for (PacketPlayOutEntityEquipment packet : equipment) {
connection.sendPacket(packet);
}
}
// Inject the player's packet connection into this listener, so we can
// show the player position/velocity/rotation changes
connections.add(connection);
}
use of net.minecraft.server.v1_14_R1.Block in project Citizens2 by CitizensDev.
the class PlayerPathfinderNormal method getPathTypeBase.
public PathType getPathTypeBase(IBlockAccess paramIBlockAccess, int paramInt1, int paramInt2, int paramInt3) {
BlockPosition localBlockPosition = new BlockPosition(paramInt1, paramInt2, paramInt3);
IBlockData localIBlockData = paramIBlockAccess.getType(localBlockPosition);
Block localBlock1 = localIBlockData.getBlock();
Material localMaterial = localIBlockData.getMaterial();
PathType localPathType1 = PathType.BLOCKED;
if ((localBlock1 == Blocks.TRAPDOOR) || (localBlock1 == Blocks.IRON_TRAPDOOR) || (localBlock1 == Blocks.WATERLILY)) {
return PathType.TRAPDOOR;
}
if (localBlock1 == Blocks.FIRE) {
return PathType.DAMAGE_FIRE;
}
if (localBlock1 == Blocks.CACTUS) {
return PathType.DAMAGE_CACTUS;
}
if (((localBlock1 instanceof BlockDoor)) && (localMaterial == Material.WOOD) && (!localIBlockData.get(BlockDoor.OPEN).booleanValue())) {
return PathType.DOOR_WOOD_CLOSED;
}
if (((localBlock1 instanceof BlockDoor)) && (localMaterial == Material.ORE) && (!localIBlockData.get(BlockDoor.OPEN).booleanValue())) {
return PathType.DOOR_IRON_CLOSED;
}
if (((localBlock1 instanceof BlockDoor)) && (localIBlockData.get(BlockDoor.OPEN).booleanValue())) {
return PathType.DOOR_OPEN;
}
if ((localBlock1 instanceof BlockMinecartTrackAbstract)) {
return PathType.RAIL;
}
if (((localBlock1 instanceof BlockFence)) || ((localBlock1 instanceof BlockCobbleWall)) || (((localBlock1 instanceof BlockFenceGate)) && (!localIBlockData.get(BlockFenceGate.OPEN).booleanValue()))) {
return PathType.FENCE;
}
if (localMaterial == Material.AIR) {
localPathType1 = PathType.OPEN;
} else {
if (localMaterial == Material.WATER) {
return PathType.WATER;
}
if (localMaterial == Material.LAVA) {
return PathType.LAVA;
}
}
if ((localBlock1.b(paramIBlockAccess, localBlockPosition)) && (localPathType1 == PathType.BLOCKED)) {
localPathType1 = PathType.OPEN;
}
return localPathType1;
}
Aggregations