2021-03-24 13:49:21 +01:00
|
|
|
/*
|
|
|
|
This file is a part of the SteamWar software.
|
|
|
|
|
2021-08-31 10:42:42 +02:00
|
|
|
Copyright (C) 2021 SteamWar.de-Serverteam
|
2021-03-24 13:49:21 +01:00
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Affero General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2021-08-31 10:42:42 +02:00
|
|
|
*/
|
2021-03-24 13:49:21 +01:00
|
|
|
|
|
|
|
package de.steamwar.fightsystem.utils;
|
|
|
|
|
2021-08-31 10:42:42 +02:00
|
|
|
import org.bukkit.World;
|
|
|
|
import org.bukkit.block.Block;
|
2021-03-24 13:49:21 +01:00
|
|
|
|
2022-04-09 16:14:03 +02:00
|
|
|
public class BlockIdWrapper8 implements BlockIdWrapper {
|
2021-08-31 10:42:42 +02:00
|
|
|
@Override
|
2021-10-30 14:31:32 +02:00
|
|
|
@SuppressWarnings("deprecation")
|
2021-08-31 10:42:42 +02:00
|
|
|
public int blockToId(Block block) {
|
|
|
|
return block.getTypeId() << 4 + block.getData();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-10-30 14:31:32 +02:00
|
|
|
@SuppressWarnings("deprecation")
|
2021-08-31 10:42:42 +02:00
|
|
|
public void setBlock(World world, int x, int y, int z, int blockState) {
|
2022-10-07 16:58:01 +02:00
|
|
|
if((blockState >> 4) > 256) // Illegal blockstate / corrupted replay
|
|
|
|
blockState = 0;
|
|
|
|
|
2021-08-31 10:42:42 +02:00
|
|
|
world.getBlockAt(x, y, z).setTypeIdAndData(blockState >> 4, (byte)(blockState & 0b1111), false);
|
|
|
|
}
|
2021-03-24 13:49:21 +01:00
|
|
|
|
2021-08-31 10:42:42 +02:00
|
|
|
@Override
|
|
|
|
public Object getPose(boolean sneaking) {
|
2021-09-28 18:25:45 +02:00
|
|
|
return Byte.valueOf((byte)(sneaking ? 2 : 0));
|
2021-08-31 10:42:42 +02:00
|
|
|
}
|
2021-03-24 13:49:21 +01:00
|
|
|
}
|