mirror of
https://github.com/BlazingGames/blazing-games-plugin.git
synced 2025-02-03 21:26:41 -05:00
Slabs finally work (somewhat)
Known Issues: - All directional and orientable blocks are disabled - Blocks with textures on different sides are disabled - Some slabs dont have the correct texture on some sides - You cant rotate slabs anymore These issues, however, arent important enough to delay the update to 1.20.4 in my opinion, so will be fixed later.
This commit is contained in:
parent
4f67487dd4
commit
ffe7be8884
5 changed files with 74 additions and 22 deletions
|
@ -24,11 +24,10 @@ import de.blazemcworld.blazinggames.items.CustomItems;
|
|||
import de.blazemcworld.blazinggames.items.CustomSlabs;
|
||||
import de.blazemcworld.blazinggames.utils.TextLocation;
|
||||
import de.blazemcworld.blazinggames.utils.TomeAltarStorage;
|
||||
import io.papermc.paper.datacomponent.DataComponentTypes;
|
||||
import io.papermc.paper.datacomponent.item.CustomModelData;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.CreatureSpawner;
|
||||
|
@ -38,7 +37,6 @@ import org.bukkit.event.Listener;
|
|||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BlockStateMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.bukkit.util.RayTraceResult;
|
||||
|
@ -217,14 +215,16 @@ public class BlockPlaceEventListener implements Listener {
|
|||
loc.getBlock().setType(Material.MOVING_PISTON);
|
||||
loc.setY(loc.getY() + (isTop ? 0.5 : 0));
|
||||
|
||||
Sound breakSound = item.material.createBlockData().getSoundGroup().getBreakSound();
|
||||
location.getWorld().playSound(loc, breakSound, 1, 1);
|
||||
|
||||
// BlockData blockData = item.material.createBlockData();
|
||||
ItemDisplay itemDisplay = (ItemDisplay) loc.getBlock().getWorld().spawnEntity(loc, EntityType.ITEM_DISPLAY);
|
||||
itemDisplay.setItemStack(item.create());
|
||||
// if (isTop) {
|
||||
ItemMeta meta = itemDisplay.getItemStack().getItemMeta();
|
||||
meta.setCustomModelData(1);
|
||||
itemDisplay.getItemStack().setItemMeta(meta);
|
||||
// }
|
||||
ItemStack itemStack = item.create();
|
||||
if (isTop) {
|
||||
itemStack.setData(DataComponentTypes.CUSTOM_MODEL_DATA, CustomModelData.customModelData().addFlag(true).build());
|
||||
}
|
||||
itemDisplay.setItemStack(itemStack);
|
||||
loc.subtract(0.5, 0.5, 0.5);
|
||||
// if (blockData instanceof Directional || blockData instanceof Orientable) {
|
||||
// double yaw = direction.getYaw();
|
||||
|
|
|
@ -99,6 +99,7 @@ public class EntityDamagedByEventListener implements Listener {
|
|||
|
||||
if (displayBlock == null) return;
|
||||
Location blockLocation = victim.getLocation().toCenterLocation();
|
||||
Sound breakSound = displayBlock.getItemStack().getType().createBlockData().getSoundGroup().getBreakSound();
|
||||
displayBlock.remove();
|
||||
|
||||
double y = victim.getY();
|
||||
|
@ -123,9 +124,8 @@ public class EntityDamagedByEventListener implements Listener {
|
|||
return;
|
||||
}
|
||||
|
||||
// p.getWorld().playSound(blockLocation, breakSound, 1, 1);
|
||||
p.getWorld().playSound(blockLocation, breakSound, 1, 1);
|
||||
|
||||
System.out.println(blockLocation);
|
||||
if (p.getWorld().getNearbyEntitiesByType(Shulker.class, blockLocation, 0.5).isEmpty())
|
||||
Bukkit.getScheduler().runTask(BlazingGames.get(), () -> p.getWorld().getBlockAt(blockLocation).setType(Material.AIR));
|
||||
}
|
||||
|
|
|
@ -380,6 +380,7 @@ public class InteractEventListener implements Listener {
|
|||
}
|
||||
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && block != null && hand != null) {
|
||||
if (player.getTargetEntity(5) != null) return;
|
||||
Vector v = face.getDirection();
|
||||
Location nextBlock = block.getLocation().add(v).toCenterLocation();
|
||||
Collection<Shulker> shulkers = nextBlock.getNearbyEntitiesByType(Shulker.class, 0.5);
|
||||
|
|
|
@ -21,6 +21,9 @@ import de.blazemcworld.blazinggames.packs.HookContext;
|
|||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.Directional;
|
||||
import org.bukkit.block.data.Orientable;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.Recipe;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
|
@ -46,7 +49,36 @@ public class CustomSlabs implements ItemProvider {
|
|||
Material.BEDROCK,
|
||||
Material.SUSPICIOUS_GRAVEL,
|
||||
Material.SUSPICIOUS_SAND,
|
||||
Material.REINFORCED_DEEPSLATE
|
||||
Material.REINFORCED_DEEPSLATE,
|
||||
|
||||
// Temporarily Disabled
|
||||
Material.TARGET,
|
||||
Material.WAXED_EXPOSED_CHISELED_COPPER,
|
||||
Material.SNOW_BLOCK,
|
||||
Material.MANGROVE_ROOTS,
|
||||
Material.INFESTED_CHISELED_STONE_BRICKS,
|
||||
Material.SCULK_CATALYST,
|
||||
Material.WAXED_COPPER_BLOCK,
|
||||
Material.MYCELIUM,
|
||||
Material.WAXED_OXIDIZED_COPPER,
|
||||
Material.WAXED_OXIDIZED_CHISELED_COPPER,
|
||||
Material.INFESTED_MOSSY_STONE_BRICKS,
|
||||
Material.INFESTED_STONE,
|
||||
Material.INFESTED_STONE_BRICKS,
|
||||
Material.INFESTED_CRACKED_STONE_BRICKS,
|
||||
Material.MAGMA_BLOCK,
|
||||
Material.DRIED_KELP_BLOCK,
|
||||
Material.MELON,
|
||||
Material.WAXED_EXPOSED_COPPER,
|
||||
Material.ANCIENT_DEBRIS,
|
||||
Material.GRASS_BLOCK,
|
||||
Material.PODZOL,
|
||||
Material.QUARTZ_BLOCK,
|
||||
Material.WAXED_CHISELED_COPPER,
|
||||
Material.INFESTED_COBBLESTONE,
|
||||
Material.WAXED_WEATHERED_COPPER,
|
||||
Material.WAXED_WEATHERED_CHISELED_COPPER,
|
||||
Material.LODESTONE
|
||||
);
|
||||
|
||||
public final ArrayList<CustomSlab> slabs = new ArrayList<>();
|
||||
|
@ -55,11 +87,16 @@ public class CustomSlabs implements ItemProvider {
|
|||
List<String> materialNames = Arrays.stream(Material.values()).map(Material::name).toList();
|
||||
for (Material material : Material.values()) {
|
||||
if (!blockedMaterials.contains(material) && material.isBlock() && material.isItem() && !material.isInteractable() && material.isOccluding() && material.isCollidable() && material.isSolid() && !material.name().contains("_PLANKS") && !material.name().contains("_SLAB") && !materialNames.contains(material.name() + "_SLAB")) {
|
||||
if (material.name().endsWith("S")) {
|
||||
if (materialNames.contains(material.name().substring(0, material.name().length() - 1) + "_SLAB"))
|
||||
continue;
|
||||
BlockData blockData = material.createBlockData();
|
||||
|
||||
//Temporarily Disabled
|
||||
if (!(blockData instanceof Directional) && !(blockData instanceof Orientable)) {
|
||||
if (material.name().endsWith("S")) {
|
||||
if (materialNames.contains(material.name().substring(0, material.name().length() - 1) + "_SLAB"))
|
||||
continue;
|
||||
}
|
||||
slabs.add(new CustomSlab(material));
|
||||
}
|
||||
slabs.add(new CustomSlab(material));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -191,8 +228,16 @@ public class CustomSlabs implements ItemProvider {
|
|||
JsonObject jsonObject = gson.fromJson(customSlab, JsonObject.class);
|
||||
|
||||
JsonObject model = jsonObject.get("model").getAsJsonObject();
|
||||
model.addProperty("on_true", "blazinggames:models/" + slab.material.name().toLowerCase() + "_slab_top");
|
||||
model.addProperty("on_false", "blazinggames:models/" + slab.material.name().toLowerCase() + "_slab_bottom");
|
||||
|
||||
JsonObject onTrue = new JsonObject();
|
||||
onTrue.addProperty("type", "minecraft:model");
|
||||
onTrue.addProperty("model", "blazinggames:" + slab.material.name().toLowerCase() + "_slab_top");
|
||||
model.add("on_true", onTrue);
|
||||
|
||||
JsonObject onFalse = new JsonObject();
|
||||
onFalse.addProperty("type", "minecraft:model");
|
||||
onFalse.addProperty("model", "blazinggames:" + slab.material.name().toLowerCase() + "_slab_bottom");
|
||||
model.add("on_false", onFalse);
|
||||
|
||||
context.writeFile("/assets/" + item.getKey().getNamespace() + "/items/" + item.getKey().getKey() + ".json", jsonObject);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,13 @@
|
|||
"model": {
|
||||
"type": "condition",
|
||||
"property": "custom_model_data",
|
||||
"on_false": "blazinggames:netherite_block_slab_bottom",
|
||||
"on_true": "blazinggames:netherite_block_slab_top"
|
||||
"on_false": {
|
||||
"type": "minecraft:model",
|
||||
"model": "blazinggames:netherite_block_slab_bottom"
|
||||
},
|
||||
"on_true": {
|
||||
"type": "minecraft:model",
|
||||
"model": "blazinggames:netherite_block_slab_top"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue