1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 03:35:51 +00:00

More dough implementations

This commit is contained in:
TheBusyBiscuit 2021-07-14 17:14:55 +02:00
parent 6de1fe821c
commit 5abab2ef7a
10 changed files with 33 additions and 18 deletions

View File

@ -24,7 +24,8 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import io.github.bakedlibs.dough.items.ItemMetaSnapshot;
import io.github.thebusybiscuit.cscorelib2.skull.SkullItem;
import io.github.bakedlibs.dough.skins.PlayerHead;
import io.github.bakedlibs.dough.skins.PlayerSkin;
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
import io.github.thebusybiscuit.slimefun4.api.exceptions.PrematureCodeException;
import io.github.thebusybiscuit.slimefun4.api.exceptions.WrongItemStackException;
@ -286,7 +287,8 @@ public class SlimefunItemStack extends ItemStack {
return new ItemStack(Material.PLAYER_HEAD);
}
return SkullItem.fromBase64(getTexture(id, texture));
PlayerSkin skin = PlayerSkin.fromBase64(getTexture(id, texture));
return PlayerHead.getItemStack(skin);
}
private static @Nonnull String getTexture(@Nonnull String id, @Nonnull String texture) {

View File

@ -19,8 +19,8 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.inventory.InvUtils;
import io.github.thebusybiscuit.cscorelib2.protection.Interaction;
import io.github.bakedlibs.dough.inventory.InvUtils;
import io.github.bakedlibs.dough.protection.Interaction;
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;

View File

@ -31,12 +31,12 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import com.sk89q.worldedit.blocks.SkullBlock;
import io.github.bakedlibs.dough.chat.ChatInput;
import io.github.bakedlibs.dough.common.ChatColors;
import io.github.bakedlibs.dough.items.CustomItemStack;
import io.github.bakedlibs.dough.items.ItemUtils;
import io.github.bakedlibs.dough.skins.PlayerHead;
import io.github.bakedlibs.dough.skins.PlayerSkin;
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
@ -898,7 +898,11 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock,
});
block.setBlockData(blockData);
Slimefun.runSync(() -> SkullBlock.setFromBase64(block, texture));
Slimefun.runSync(() -> {
PlayerSkin skin = PlayerSkin.fromBase64(texture);
PlayerHead.setSkin(block, skin, true);
});
b.setType(Material.AIR);
BlockStorage.moveBlockInfo(b.getLocation(), block.getLocation());

View File

@ -14,7 +14,7 @@ import org.bukkit.block.Chest;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.inventory.InvUtils;
import io.github.bakedlibs.dough.inventory.InvUtils;
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;

View File

@ -21,8 +21,8 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.MushroomCow;
import org.bukkit.inventory.ItemStack;
import io.github.bakedlibs.dough.inventory.InvUtils;
import io.github.bakedlibs.dough.items.CustomItemStack;
import io.github.thebusybiscuit.cscorelib2.inventory.InvUtils;
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;

View File

@ -24,10 +24,10 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import io.github.bakedlibs.dough.blocks.BlockPosition;
import io.github.bakedlibs.dough.inventory.InvUtils;
import io.github.bakedlibs.dough.items.ItemUtils;
import io.github.bakedlibs.dough.protection.Interaction;
import io.github.bakedlibs.dough.scheduling.TaskQueue;
import io.github.thebusybiscuit.cscorelib2.inventory.InvUtils;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.utils.WorldUtils;
import io.papermc.lib.PaperLib;

View File

@ -21,9 +21,8 @@ import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.EquipmentSlot;
import com.sk89q.worldedit.blocks.SkullBlock;
import io.github.bakedlibs.dough.common.ChatColors;
import io.github.bakedlibs.dough.skins.PlayerHead;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent;
import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetProvider;
@ -95,8 +94,8 @@ public class DebugFishListener implements Listener {
Slimefun.runSync(() -> {
Block block = b.getRelative(face);
block.setType(Material.PLAYER_HEAD);
SkullBlock.setFromHash(block, HeadTexture.MISSING_TEXTURE.getTexture());
PlayerHead.setSkin(block, HeadTexture.MISSING_TEXTURE.getAsSkin(), true);
p.playSound(block.getLocation(), Sound.BLOCK_BAMBOO_PLACE, 1, 1);
}, 2L);
} else if (BlockStorage.hasBlockInfo(b)) {

View File

@ -8,8 +8,8 @@ import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.block.Block;
import com.sk89q.worldedit.blocks.SkullBlock;
import io.github.bakedlibs.dough.skins.PlayerHead;
import io.github.bakedlibs.dough.skins.PlayerSkin;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.Capacitor;
import io.github.thebusybiscuit.slimefun4.utils.HeadTexture;
import io.papermc.lib.PaperLib;
@ -75,7 +75,9 @@ public class CapacitorTextureUpdateTask implements Runnable {
}
private void setTexture(@Nonnull Block b, @Nonnull HeadTexture texture) {
SkullBlock.setFromHash(b, texture.getUniqueId(), texture.getTexture(), false);
PlayerSkin skin = PlayerSkin.fromHashCode(texture.getUniqueId(), texture.getTexture());
PlayerHead.setSkin(b, skin, false);
PaperLib.getBlockState(b, false).getState().update(true, false);
}

View File

@ -8,6 +8,8 @@ import javax.annotation.Nonnull;
import org.apache.commons.lang.Validate;
import org.bukkit.inventory.ItemStack;
import io.github.bakedlibs.dough.skins.PlayerSkin;
/**
* This enum holds all currently used Head textures in Slimefun.
* Credit for most of these goes to our main head designer "AquaLazuryt".
@ -160,4 +162,8 @@ public enum HeadTexture {
return SlimefunUtils.getCustomHead(getTexture());
}
public @Nonnull PlayerSkin getAsSkin() {
return PlayerSkin.fromHashCode(texture);
}
}

View File

@ -26,7 +26,8 @@ import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.persistence.PersistentDataType;
import io.github.bakedlibs.dough.items.ItemMetaSnapshot;
import io.github.thebusybiscuit.cscorelib2.skull.SkullItem;
import io.github.bakedlibs.dough.skins.PlayerHead;
import io.github.bakedlibs.dough.skins.PlayerSkin;
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
import io.github.thebusybiscuit.slimefun4.api.events.SlimefunItemSpawnEvent;
import io.github.thebusybiscuit.slimefun4.api.exceptions.PrematureCodeException;
@ -225,7 +226,8 @@ public final class SlimefunUtils {
base64 = Base64.getEncoder().encodeToString(("{\"textures\":{\"SKIN\":{\"url\":\"http://textures.minecraft.net/texture/" + texture + "\"}}}").getBytes(StandardCharsets.UTF_8));
}
return SkullItem.fromBase64(base64);
PlayerSkin skin = PlayerSkin.fromBase64(base64);
return PlayerHead.getItemStack(skin);
}
public static boolean containsSimilarItem(Inventory inventory, ItemStack item, boolean checkLore) {