use of com.denizenscript.denizen.objects.MaterialTag in project Denizen-For-Bukkit by DenizenScript.
the class ItemCanPlaceOn method adjust.
@Override
public void adjust(Mechanism mechanism) {
// -->
if (mechanism.matches("can_place_on")) {
if (item.getMaterial().getMaterial() == Material.AIR) {
mechanism.echoError("Cannot apply NBT to AIR!");
return;
}
ItemStack itemStack = item.getItemStack();
if (mechanism.hasValue()) {
List<Material> materials = mechanism.valueAsType(ListTag.class).filter(MaterialTag.class, mechanism.context).stream().map(MaterialTag::getMaterial).collect(Collectors.toList());
itemStack = CustomNBT.setNBTMaterials(itemStack, CustomNBT.KEY_CAN_PLACE_ON, materials);
} else {
itemStack = CustomNBT.clearNBT(itemStack, CustomNBT.KEY_CAN_PLACE_ON);
}
item.setItemStack(itemStack);
}
}
use of com.denizenscript.denizen.objects.MaterialTag in project Denizen-For-Bukkit by DenizenScript.
the class ItemCanDestroy method getMaterials.
private ListTag getMaterials() {
ItemStack itemStack = item.getItemStack();
List<Material> materials = CustomNBT.getNBTMaterials(itemStack, CustomNBT.KEY_CAN_DESTROY);
if (materials != null && !materials.isEmpty()) {
ListTag list = new ListTag();
for (Material material : materials) {
list.addObject(new MaterialTag(material));
}
return list;
}
return null;
}
use of com.denizenscript.denizen.objects.MaterialTag in project Denizen-For-Bukkit by DenizenScript.
the class EntityFormsBlockScriptEvent method onEntityFormsBlock.
@EventHandler
public void onEntityFormsBlock(EntityBlockFormEvent event) {
location = new LocationTag(event.getBlock().getLocation());
material = new MaterialTag(event.getBlock());
entity = new EntityTag(event.getEntity());
this.event = event;
fire(event);
}
use of com.denizenscript.denizen.objects.MaterialTag in project Denizen-For-Bukkit by DenizenScript.
the class LiquidLevelChangeScriptEvent method onLiquidLevelChange.
@EventHandler
public void onLiquidLevelChange(FluidLevelChangeEvent event) {
location = new LocationTag(event.getBlock().getLocation());
old_material = new MaterialTag(event.getBlock());
this.event = event;
fire(event);
}
use of com.denizenscript.denizen.objects.MaterialTag in project Denizen-For-Bukkit by DenizenScript.
the class BlockGrowsScriptEvent method onBlockGrows.
@EventHandler
public void onBlockGrows(BlockGrowEvent event) {
location = new LocationTag(event.getBlock().getLocation());
material = new MaterialTag(event.getNewState());
if (material.isStructure()) {
return;
}
this.event = event;
fire(event);
}
Aggregations