mirror of
https://github.com/Ste3et/furniture.git
synced 2024-11-25 12:06:22 +01:00
Add 1.16.x Camera Utils
This commit is contained in:
parent
b74e779087
commit
1ce07b9b4d
@ -0,0 +1,35 @@
|
|||||||
|
package de.Ste3et_C0st.Furniture.Camera.Utils.v1_16;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.reflect.MethodUtils;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
|
||||||
|
import de.Ste3et_C0st.Furniture.Camera.Utils.MinecraftBlockColor;
|
||||||
|
|
||||||
|
public class BlockColor extends MinecraftBlockColor{
|
||||||
|
|
||||||
|
private static Class<?> CraftMagicNumbersClass;
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
CraftMagicNumbersClass = Class.forName("org.bukkit.craftbukkit." + getBukkitVersion() + ".util.CraftMagicNumbers");
|
||||||
|
}catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Byte getBlockColor(Block b) {
|
||||||
|
try {
|
||||||
|
Object nmsBlock = CraftMagicNumbersClass.getMethod("getBlock", org.bukkit.Material.class).invoke(null, b.getType());
|
||||||
|
Object iBlockData = nmsBlock.getClass().getMethod("getBlockData").invoke(nmsBlock);
|
||||||
|
Object Material = MethodUtils.invokeMethod(iBlockData, "getMaterial", null);
|
||||||
|
Object MaterialMapColor = MethodUtils.invokeMethod(Material, "h", null);
|
||||||
|
int color = MaterialMapColor.getClass().getField("aj").getInt(MaterialMapColor) * 4;
|
||||||
|
return (byte) color;
|
||||||
|
}catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -43,7 +43,7 @@ public class sunshade extends Furniture{
|
|||||||
if(player == null) return;
|
if(player == null) return;
|
||||||
ItemStack is = player.getInventory().getItemInMainHand();
|
ItemStack is = player.getInventory().getItemInMainHand();
|
||||||
if(is.getType().name().contains("BANNER")){
|
if(is.getType().name().contains("BANNER")){
|
||||||
if(canBuild(player, false)) {
|
if(canBuild(player)) {
|
||||||
for(fEntity packet : getfAsList()){
|
for(fEntity packet : getfAsList()){
|
||||||
if(packet.getInventory().getHelmet()!=null&&packet.getInventory().getHelmet().getType().name().contains("BANNER")){
|
if(packet.getInventory().getHelmet()!=null&&packet.getInventory().getHelmet().getType().name().contains("BANNER")){
|
||||||
packet.getInventory().setHelmet(is.clone());
|
packet.getInventory().setHelmet(is.clone());
|
||||||
@ -54,12 +54,16 @@ public class sunshade extends Furniture{
|
|||||||
}
|
}
|
||||||
update();
|
update();
|
||||||
consumeItem(player);
|
consumeItem(player);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}else if(!isOpen()){
|
return;
|
||||||
open();
|
}else {
|
||||||
}else{
|
if(canInteract(player)){
|
||||||
close();
|
if(!isOpen()){
|
||||||
|
open();
|
||||||
|
}else{
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user