Attempt to fix 1.16.3 branch's issues on the repository
Added the original 'wayoftime' folder back, so see if that fixed the multiple folder issue.
This commit is contained in:
parent
6b4145a67c
commit
9fa68e86ae
224 changed files with 24047 additions and 0 deletions
|
@ -0,0 +1,30 @@
|
|||
package wayoftime.bloodmagic.core;
|
||||
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = BloodMagic.MODID)
|
||||
public class RegistrarBloodMagic
|
||||
{
|
||||
private RegistrarBloodMagic()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// public static final BloodOrbDeferredRegister BLOOD_ORBS = new BloodOrbDeferredRegister(BloodMagic.MODID);
|
||||
//
|
||||
// public static final BloodOrbRegistryObject<BloodOrb> ORB_WEAK = BLOOD_ORBS.register("weakbloodorb", () -> new BloodOrb(new ResourceLocation(BloodMagic.MODID, "weakbloodorb"), 0, 5000, 10));
|
||||
|
||||
// public static IForgeRegistry<BloodOrb> BLOOD_ORBS = new RegistryBuilder<BloodOrb>().setName(new ResourceLocation(BloodMagic.MODID, "blood_orb")).setIDRange(0, Short.MAX_VALUE).setType(BloodOrb.class).addCallback((IForgeRegistry.AddCallback<BloodOrb>) (
|
||||
// owner, stage, id, obj,
|
||||
// oldObj) -> OrbRegistry.tierMap.put(obj.getTier(), OrbRegistry.getOrbStack(obj))).create();
|
||||
|
||||
// @SubscribeEvent
|
||||
// public static void onRegistryCreation(RegistryEvent.NewRegistry event)
|
||||
// {
|
||||
// System.out.println("Testification3");
|
||||
// BLOOD_ORBS = new RegistryBuilder<BloodOrb>().setName(new ResourceLocation(BloodMagic.MODID, "blood_orb")).setIDRange(0, Short.MAX_VALUE).setType(BloodOrb.class).addCallback((IForgeRegistry.AddCallback<BloodOrb>) (
|
||||
// owner, stage, id, obj,
|
||||
// oldObj) -> OrbRegistry.tierMap.put(obj.getTier(), OrbRegistry.getOrbStack(obj))).create();
|
||||
// }
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package wayoftime.bloodmagic.core;
|
||||
|
||||
import wayoftime.bloodmagic.api.impl.BloodMagicRecipeRegistrar;
|
||||
|
||||
public class RegistrarBloodMagicRecipes
|
||||
{
|
||||
|
||||
// @SubscribeEvent
|
||||
// public static void registerRecipes(RegistryEvent.Register<IRecipe> event) {
|
||||
// for (int i = 0; i < ItemSoulGem.names.length; i++) {
|
||||
// for (EnumDemonWillType willType : EnumDemonWillType.values()) {
|
||||
// ItemStack baseGemStack = new ItemStack(RegistrarBloodMagicItems.SOUL_GEM, 1, i);
|
||||
// ItemStack newGemStack = new ItemStack(RegistrarBloodMagicItems.SOUL_GEM, 1, i);
|
||||
//
|
||||
// ((ItemSoulGem) RegistrarBloodMagicItems.SOUL_GEM).setCurrentType(willType, newGemStack);
|
||||
// ShapelessOreRecipe shapeless = new ShapelessOreRecipe(new ResourceLocation(BloodMagic.MODID, "soul_gem"), newGemStack, baseGemStack, willType.getStack());
|
||||
// event.getRegistry().register(shapeless.setRegistryName("soul_gem_" + willType.getName()));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// OreDictionary.registerOre("dustIron", ComponentTypes.SAND_IRON.getStack());
|
||||
// OreDictionary.registerOre("dustGold", ComponentTypes.SAND_GOLD.getStack());
|
||||
// OreDictionary.registerOre("dustCoal", ComponentTypes.SAND_COAL.getStack());
|
||||
//
|
||||
// PluginUtil.handlePluginStep(PluginUtil.RegistrationStep.RECIPE_REGISTER);
|
||||
//
|
||||
// RegistrarBloodMagicItems.SOUL_TOOL_MATERIAL.setRepairItem(EnumDemonWillType.DEFAULT.getStack());
|
||||
// }
|
||||
|
||||
public static void registerAltarRecipes(BloodMagicRecipeRegistrar registrar)
|
||||
{
|
||||
// Ingredient d;
|
||||
// ONE
|
||||
// registrar.addBloodAltar(new OreIngredient("gemDiamond"), OrbRegistry.getOrbStack(RegistrarBloodMagic.ORB_WEAK), AltarTier.ONE.ordinal(), 2000, 2, 1);
|
||||
// registrar.addBloodAltar(new OreIngredient("stone"), ItemSlate.SlateType.BLANK.getStack(), AltarTier.ONE.ordinal(), 1000, 5, 5);
|
||||
// registrar.addBloodAltar(Ingredient.fromItem(Items.BUCKET), FluidUtil.getFilledBucket(new FluidStack(BlockLifeEssence.getLifeEssence(), Fluid.BUCKET_VOLUME)), AltarTier.ONE.ordinal(), 1000, 5, 0);
|
||||
// registrar.addBloodAltar(Ingredient.fromItem(Items.BOOK), new ItemStack(RegistrarBloodMagicItems.SANGUINE_BOOK), AltarTier.ONE.ordinal(), 1000, 20, 0);
|
||||
//
|
||||
// // TWO
|
||||
// registrar.addBloodAltar(new OreIngredient("blockRedstone"), OrbRegistry.getOrbStack(RegistrarBloodMagic.ORB_APPRENTICE), AltarTier.TWO.ordinal(), 5000, 5, 5);
|
||||
// registrar.addBloodAltar(Ingredient.fromStacks(ItemSlate.SlateType.BLANK.getStack()), ItemSlate.SlateType.REINFORCED.getStack(), AltarTier.TWO.ordinal(), 2000, 5, 5);
|
||||
// registrar.addBloodAltar(Ingredient.fromItem(Items.IRON_SWORD), new ItemStack(RegistrarBloodMagicItems.DAGGER_OF_SACRIFICE), AltarTier.TWO.ordinal(), 3000, 5, 5);
|
||||
//
|
||||
// // THREE
|
||||
// registrar.addBloodAltar(new OreIngredient("blockGold"), OrbRegistry.getOrbStack(RegistrarBloodMagic.ORB_MAGICIAN), AltarTier.THREE.ordinal(), 25000, 20, 20);
|
||||
// registrar.addBloodAltar(Ingredient.fromStacks(ItemSlate.SlateType.REINFORCED.getStack()), ItemSlate.SlateType.IMBUED.getStack(), AltarTier.THREE.ordinal(), 5000, 15, 10);
|
||||
// registrar.addBloodAltar(new OreIngredient("obsidian"), EnumRuneType.EARTH.getStack(), AltarTier.THREE.ordinal(), 1000, 5, 5);
|
||||
// registrar.addBloodAltar(new OreIngredient("blockLapis"), EnumRuneType.WATER.getStack(), AltarTier.THREE.ordinal(), 1000, 5, 5);
|
||||
// registrar.addBloodAltar(Ingredient.fromItem(Items.MAGMA_CREAM), EnumRuneType.FIRE.getStack(), AltarTier.THREE.ordinal(), 1000, 5, 5);
|
||||
// registrar.addBloodAltar(Ingredient.fromItem(Items.GHAST_TEAR), EnumRuneType.AIR.getStack(), AltarTier.THREE.ordinal(), 1000, 5, 5);
|
||||
// registrar.addBloodAltar(Ingredient.fromItem(RegistrarBloodMagicItems.LAVA_CRYSTAL), new ItemStack(RegistrarBloodMagicItems.ACTIVATION_CRYSTAL), AltarTier.THREE.ordinal(), 10000, 20, 10);
|
||||
//
|
||||
// // FOUR
|
||||
// registrar.addBloodAltar(Ingredient.fromStacks(new ItemStack(RegistrarBloodMagicItems.BLOOD_SHARD)), OrbRegistry.getOrbStack(RegistrarBloodMagic.ORB_MASTER), AltarTier.FOUR.ordinal(), 40000, 30, 50);
|
||||
// registrar.addBloodAltar(Ingredient.fromStacks(ItemSlate.SlateType.IMBUED.getStack()), ItemSlate.SlateType.DEMONIC.getStack(), AltarTier.FOUR.ordinal(), 15000, 20, 20);
|
||||
// registrar.addBloodAltar(new OreIngredient("blockCoal"), EnumRuneType.DUSK.getStack(), AltarTier.FOUR.ordinal(), 2000, 20, 10);
|
||||
// registrar.addBloodAltar(new OreIngredient("enderpearl"), new ItemStack(RegistrarBloodMagicItems.TELEPOSITION_FOCUS), AltarTier.FOUR.ordinal(), 2000, 10, 10);
|
||||
// registrar.addBloodAltar(Ingredient.fromStacks(new ItemStack(RegistrarBloodMagicItems.TELEPOSITION_FOCUS)), new ItemStack(RegistrarBloodMagicItems.TELEPOSITION_FOCUS, 1, 1), AltarTier.FOUR.ordinal(), 10000, 20, 10);
|
||||
//
|
||||
// // FIVE
|
||||
// registrar.addBloodAltar(new OreIngredient("netherStar"), OrbRegistry.getOrbStack(RegistrarBloodMagic.ORB_ARCHMAGE), AltarTier.FIVE.ordinal(), 80000, 50, 100);
|
||||
// registrar.addBloodAltar(Ingredient.fromStacks(ItemSlate.SlateType.DEMONIC.getStack()), ItemSlate.SlateType.ETHEREAL.getStack(), AltarTier.FIVE.ordinal(), 30000, 40, 100);
|
||||
|
||||
// // SIX
|
||||
// if (ConfigHandler.general.enableTierSixEvenThoughThereIsNoContent)
|
||||
// {
|
||||
// registrar.addBloodAltar(Ingredient.fromStacks(new ItemStack(RegistrarBloodMagicBlocks.DECORATIVE_BRICK, 1, 2)), OrbRegistry.getOrbStack(RegistrarBloodMagic.ORB_TRANSCENDENT), AltarTier.SIX.ordinal(), 200000, 100, 200);
|
||||
// registrar.addBloodAltar(new OreIngredient("glowstone"), EnumRuneType.DAWN.getStack(), AltarTier.SIX.ordinal(), 200000, 100, 200);
|
||||
// }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package wayoftime.bloodmagic.core.data;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.world.storage.WorldSavedData;
|
||||
import wayoftime.bloodmagic.util.helper.PlayerHelper;
|
||||
|
||||
public class BMWorldSavedData extends WorldSavedData
|
||||
{
|
||||
public static final String ID = "BloodMagic-SoulNetworks";
|
||||
|
||||
private Map<UUID, SoulNetwork> soulNetworks = new HashMap<>();
|
||||
|
||||
public BMWorldSavedData(String id)
|
||||
{
|
||||
super(id);
|
||||
}
|
||||
|
||||
public BMWorldSavedData()
|
||||
{
|
||||
this(ID);
|
||||
}
|
||||
|
||||
public SoulNetwork getNetwork(PlayerEntity player)
|
||||
{
|
||||
return getNetwork(PlayerHelper.getUUIDFromPlayer(player));
|
||||
}
|
||||
|
||||
public SoulNetwork getNetwork(UUID playerId)
|
||||
{
|
||||
if (!soulNetworks.containsKey(playerId))
|
||||
soulNetworks.put(playerId, SoulNetwork.newEmpty(playerId).setParent(this));
|
||||
return soulNetworks.get(playerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(CompoundNBT tagCompound)
|
||||
{
|
||||
ListNBT networkData = tagCompound.getList("networkData", 10);
|
||||
|
||||
for (int i = 0; i < networkData.size(); i++)
|
||||
{
|
||||
CompoundNBT data = networkData.getCompound(i);
|
||||
SoulNetwork network = SoulNetwork.fromNBT(data);
|
||||
network.setParent(this);
|
||||
soulNetworks.put(network.getPlayerId(), network);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT write(CompoundNBT tagCompound)
|
||||
{
|
||||
ListNBT networkData = new ListNBT();
|
||||
for (SoulNetwork soulNetwork : soulNetworks.values())
|
||||
networkData.add(soulNetwork.serializeNBT());
|
||||
|
||||
tagCompound.put("networkData", networkData);
|
||||
|
||||
return tagCompound;
|
||||
}
|
||||
}
|
89
src/main/java/wayoftime/bloodmagic/core/data/Binding.java
Normal file
89
src/main/java/wayoftime/bloodmagic/core/data/Binding.java
Normal file
|
@ -0,0 +1,89 @@
|
|||
package wayoftime.bloodmagic.core.data;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.INBT;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraftforge.common.util.INBTSerializable;
|
||||
|
||||
public class Binding implements INBTSerializable<CompoundNBT>
|
||||
{
|
||||
private UUID uuid;
|
||||
private String name;
|
||||
|
||||
public Binding(UUID uuid, String name)
|
||||
{
|
||||
this.uuid = uuid;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
private Binding()
|
||||
{
|
||||
// No-op
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT serializeNBT()
|
||||
{
|
||||
CompoundNBT tag = new CompoundNBT();
|
||||
// tag.put("id", NBTUtil.writeUniqueId(uuid));
|
||||
tag.put("id", NBTUtil.func_240626_a_(uuid));
|
||||
tag.putString("name", name);
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserializeNBT(CompoundNBT nbt)
|
||||
{
|
||||
this.uuid = NBTUtil.readUniqueId(nbt.get("id"));
|
||||
this.name = nbt.getString("name");
|
||||
}
|
||||
|
||||
public UUID getOwnerId()
|
||||
{
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public Binding setOwnerId(UUID uuid)
|
||||
{
|
||||
this.uuid = uuid;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getOwnerName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public Binding setOwnerName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Binding fromStack(ItemStack stack)
|
||||
{
|
||||
if (!stack.hasTag()) // Definitely hasn't been bound yet.
|
||||
return null;
|
||||
|
||||
INBT bindingTag = stack.getTag().get("binding");
|
||||
if (bindingTag == null || bindingTag.getId() != 10) // Make sure it's both a tag compound and that it has actual
|
||||
// data.
|
||||
return null;
|
||||
|
||||
Binding binding = new Binding();
|
||||
binding.deserializeNBT((CompoundNBT) bindingTag);
|
||||
return binding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "Binding{" + "uuid=" + uuid + ", name='" + name + '\'' + '}';
|
||||
}
|
||||
}
|
293
src/main/java/wayoftime/bloodmagic/core/data/SoulNetwork.java
Normal file
293
src/main/java/wayoftime/bloodmagic/core/data/SoulNetwork.java
Normal file
|
@ -0,0 +1,293 @@
|
|||
package wayoftime.bloodmagic.core.data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.EvictingQueue;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.potion.EffectInstance;
|
||||
import net.minecraft.potion.Effects;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.INBTSerializable;
|
||||
import wayoftime.bloodmagic.event.SoulNetworkEvent;
|
||||
import wayoftime.bloodmagic.util.BMLog;
|
||||
import wayoftime.bloodmagic.util.BooleanResult;
|
||||
import wayoftime.bloodmagic.util.DamageSourceBloodMagic;
|
||||
import wayoftime.bloodmagic.util.helper.PlayerHelper;
|
||||
|
||||
public class SoulNetwork implements INBTSerializable<CompoundNBT>
|
||||
{
|
||||
|
||||
private final Queue<SoulTicket> ticketHistory;
|
||||
private BMWorldSavedData parent;
|
||||
private PlayerEntity cachedPlayer;
|
||||
private UUID playerId;
|
||||
private int currentEssence;
|
||||
private int orbTier;
|
||||
|
||||
private SoulNetwork()
|
||||
{
|
||||
// No-op - For creation via NBT only
|
||||
ticketHistory = EvictingQueue.create(16);
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
ticketHistory.clear();
|
||||
}
|
||||
|
||||
public int add(SoulTicket ticket, int maximum)
|
||||
{
|
||||
SoulNetworkEvent.Fill event = new SoulNetworkEvent.Fill(this, ticket, maximum);
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
return 0;
|
||||
|
||||
int currEss = getCurrentEssence();
|
||||
|
||||
if (currEss >= event.getMaximum())
|
||||
return 0;
|
||||
|
||||
int newEss = Math.min(event.getMaximum(), currEss + event.getTicket().getAmount());
|
||||
setCurrentEssence(newEss);
|
||||
|
||||
if (ticketHistory.contains(ticket))
|
||||
ticketHistory.remove(ticket); // "Pops" the existing ticket to the top of the queue
|
||||
|
||||
ticketHistory.add(ticket);
|
||||
|
||||
return newEss - currEss;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated For future proofing, use {@link #add(SoulTicket, int)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public int add(int toAdd, int maximum)
|
||||
{
|
||||
return add(new SoulTicket(toAdd), maximum);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #add(SoulTicket, int)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public int addLifeEssence(int toAdd, int maximum)
|
||||
{
|
||||
return add(toAdd, maximum);
|
||||
}
|
||||
|
||||
public int syphon(SoulTicket ticket)
|
||||
{
|
||||
return syphon(ticket, false);
|
||||
}
|
||||
|
||||
public int syphon(SoulTicket ticket, boolean skipEvent)
|
||||
{
|
||||
SoulNetworkEvent.Syphon event = new SoulNetworkEvent.Syphon(this, ticket);
|
||||
if (!skipEvent && MinecraftForge.EVENT_BUS.post(event))
|
||||
return 0;
|
||||
|
||||
int syphon = event.getTicket().getAmount();
|
||||
if (getCurrentEssence() >= syphon)
|
||||
{
|
||||
setCurrentEssence(getCurrentEssence() - syphon);
|
||||
if (ticketHistory.contains(ticket))
|
||||
ticketHistory.remove(ticket);
|
||||
|
||||
ticketHistory.add(ticket);
|
||||
return syphon;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated For future proofing, use {@link #syphon(SoulTicket)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public int syphon(int amount)
|
||||
{
|
||||
return syphon(new SoulTicket(amount));
|
||||
}
|
||||
|
||||
public BooleanResult<Integer> syphonAndDamage(PlayerEntity user, SoulTicket ticket)
|
||||
{
|
||||
if (user.getEntityWorld().isRemote)
|
||||
return BooleanResult.newResult(false, 0);
|
||||
|
||||
SoulNetworkEvent.Syphon.User event = new SoulNetworkEvent.Syphon.User(this, ticket, user);
|
||||
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
return BooleanResult.newResult(false, 0);
|
||||
|
||||
int drainAmount = syphon(event.getTicket(), true);
|
||||
|
||||
if (drainAmount <= 0 || event.shouldDamage())
|
||||
hurtPlayer(user, event.getTicket().getAmount());
|
||||
|
||||
if (ticketHistory.contains(ticket))
|
||||
ticketHistory.remove(ticket);
|
||||
|
||||
ticketHistory.add(ticket);
|
||||
|
||||
return BooleanResult.newResult(true, event.getTicket().getAmount());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #syphonAndDamage(PlayerEntity, SoulTicket)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean syphonAndDamage(PlayerEntity user, int amount)
|
||||
{
|
||||
return syphonAndDamage(user, new SoulTicket(amount)).isSuccess();
|
||||
}
|
||||
|
||||
public void causeNausea()
|
||||
{
|
||||
if (getPlayer() != null)
|
||||
getPlayer().addPotionEffect(new EffectInstance(Effects.NAUSEA, 99));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated - Please use {@link #causeNausea()}
|
||||
*/
|
||||
@Deprecated
|
||||
public void causeNauseaToPlayer()
|
||||
{
|
||||
causeNausea();
|
||||
}
|
||||
|
||||
public void hurtPlayer(PlayerEntity user, float syphon)
|
||||
{
|
||||
if (user != null)
|
||||
{
|
||||
if (syphon < 100 && syphon > 0)
|
||||
{
|
||||
if (!user.isCreative())
|
||||
{
|
||||
user.hurtResistantTime = 0;
|
||||
user.attackEntityFrom(DamageSourceBloodMagic.INSTANCE, 1.0F);
|
||||
}
|
||||
|
||||
} else if (syphon >= 100)
|
||||
{
|
||||
if (!user.isCreative())
|
||||
{
|
||||
for (int i = 0; i < ((syphon + 99) / 100); i++)
|
||||
{
|
||||
user.hurtResistantTime = 0;
|
||||
user.attackEntityFrom(DamageSourceBloodMagic.INSTANCE, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void markDirty()
|
||||
{
|
||||
if (getParent() != null)
|
||||
getParent().markDirty();
|
||||
else
|
||||
BMLog.DEFAULT.error("A SoulNetwork was created, but a parent was not set to allow saving.");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PlayerEntity getPlayer()
|
||||
{
|
||||
if (cachedPlayer == null)
|
||||
cachedPlayer = PlayerHelper.getPlayerFromUUID(playerId);
|
||||
|
||||
return cachedPlayer;
|
||||
}
|
||||
|
||||
public BMWorldSavedData getParent()
|
||||
{
|
||||
return parent;
|
||||
}
|
||||
|
||||
public SoulNetwork setParent(BMWorldSavedData parent)
|
||||
{
|
||||
this.parent = parent;
|
||||
markDirty();
|
||||
return this;
|
||||
}
|
||||
|
||||
public PlayerEntity getCachedPlayer()
|
||||
{
|
||||
return cachedPlayer;
|
||||
}
|
||||
|
||||
public UUID getPlayerId()
|
||||
{
|
||||
return playerId;
|
||||
}
|
||||
|
||||
public int getCurrentEssence()
|
||||
{
|
||||
return currentEssence;
|
||||
}
|
||||
|
||||
public SoulNetwork setCurrentEssence(int currentEssence)
|
||||
{
|
||||
this.currentEssence = currentEssence;
|
||||
markDirty();
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getOrbTier()
|
||||
{
|
||||
return orbTier;
|
||||
}
|
||||
|
||||
public SoulNetwork setOrbTier(int orbTier)
|
||||
{
|
||||
this.orbTier = orbTier;
|
||||
markDirty();
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<SoulTicket> getTicketHistory()
|
||||
{
|
||||
return ImmutableList.copyOf(ticketHistory);
|
||||
}
|
||||
|
||||
// INBTSerializable
|
||||
|
||||
@Override
|
||||
public CompoundNBT serializeNBT()
|
||||
{
|
||||
CompoundNBT tagCompound = new CompoundNBT();
|
||||
tagCompound.putString("playerId", getPlayerId().toString());
|
||||
tagCompound.putInt("currentEssence", getCurrentEssence());
|
||||
tagCompound.putInt("orbTier", getOrbTier());
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserializeNBT(CompoundNBT nbt)
|
||||
{
|
||||
this.playerId = UUID.fromString(nbt.getString("playerId"));
|
||||
this.currentEssence = nbt.getInt("currentEssence");
|
||||
this.orbTier = nbt.getInt("orbTier");
|
||||
}
|
||||
|
||||
public static SoulNetwork fromNBT(CompoundNBT tagCompound)
|
||||
{
|
||||
SoulNetwork soulNetwork = new SoulNetwork();
|
||||
soulNetwork.deserializeNBT(tagCompound);
|
||||
return soulNetwork;
|
||||
}
|
||||
|
||||
public static SoulNetwork newEmpty(UUID uuid)
|
||||
{
|
||||
SoulNetwork network = new SoulNetwork();
|
||||
network.playerId = uuid;
|
||||
return network;
|
||||
}
|
||||
}
|
104
src/main/java/wayoftime/bloodmagic/core/data/SoulTicket.java
Normal file
104
src/main/java/wayoftime/bloodmagic/core/data/SoulTicket.java
Normal file
|
@ -0,0 +1,104 @@
|
|||
package wayoftime.bloodmagic.core.data;
|
||||
|
||||
import net.minecraft.command.ICommandSource;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class SoulTicket
|
||||
{
|
||||
|
||||
private static final ITextComponent EMPTY = new StringTextComponent("");
|
||||
|
||||
private final ITextComponent description;
|
||||
private final int amount;
|
||||
|
||||
public SoulTicket(ITextComponent description, int amount)
|
||||
{
|
||||
this.description = description;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public SoulTicket(int amount)
|
||||
{
|
||||
this(EMPTY, amount);
|
||||
}
|
||||
|
||||
public boolean isSyphon()
|
||||
{
|
||||
return amount < 0;
|
||||
}
|
||||
|
||||
public ITextComponent getDescription()
|
||||
{
|
||||
return description;
|
||||
}
|
||||
|
||||
public int getAmount()
|
||||
{
|
||||
return amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A description in the format block|dimensionID|pos
|
||||
*/
|
||||
public static SoulTicket block(World world, BlockPos pos, int amount)
|
||||
{
|
||||
// func_234923_W_() = getDimension
|
||||
return new SoulTicket(new StringTextComponent("block|" + world.getDimensionKey().getRegistryName() + "|"
|
||||
+ pos.toLong()), amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A description in the format item|item registry
|
||||
* name|dimensionID|entityName|entityPos
|
||||
*/
|
||||
public static SoulTicket item(ItemStack itemStack, World world, Entity entity, int amount)
|
||||
{
|
||||
return new SoulTicket(new StringTextComponent("item|" + itemStack.getItem().getRegistryName() + "|"
|
||||
+ world.getDimensionKey().getRegistryName() + "|" + entity.getCachedUniqueIdString()), amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A description in the format item|item registry name|dimensionID|pos
|
||||
*/
|
||||
public static SoulTicket item(ItemStack itemStack, World world, BlockPos pos, int amount)
|
||||
{
|
||||
return new SoulTicket(new StringTextComponent("item|" + itemStack.getItem().getRegistryName() + "|"
|
||||
+ world.getDimensionKey().getRegistryName() + "|" + pos.toLong()), amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A description in the format item|item registry name|dimensionID
|
||||
*/
|
||||
public static SoulTicket item(ItemStack itemStack, int amount)
|
||||
{
|
||||
return new SoulTicket(new StringTextComponent("item|" + itemStack.getItem().getRegistryName()), amount);
|
||||
}
|
||||
|
||||
public static SoulTicket command(ICommandSource sender, String command, int amount)
|
||||
{
|
||||
return new SoulTicket(new StringTextComponent("command|" + command + "|" + sender.toString()), amount);
|
||||
}
|
||||
|
||||
// TODO maybe make it check the amount??
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o instanceof SoulTicket)
|
||||
return ((SoulTicket) o).getDescription().equals(description);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return description.hashCode();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package wayoftime.bloodmagic.core.recipe;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.JSONUtils;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.crafting.IIngredientSerializer;
|
||||
import net.minecraftforge.common.crafting.VanillaIngredientSerializer;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.core.registry.OrbRegistry;
|
||||
import wayoftime.bloodmagic.orb.BloodOrb;
|
||||
|
||||
public class IngredientBloodOrb extends Ingredient
|
||||
{
|
||||
public static final ResourceLocation NAME = new ResourceLocation(BloodMagic.MODID, "bloodorb");
|
||||
|
||||
public final int orbTier;
|
||||
|
||||
public static IngredientBloodOrb fromTier(int orbTier)
|
||||
{
|
||||
return new IngredientBloodOrb(orbTier);
|
||||
}
|
||||
|
||||
public static IngredientBloodOrb fromOrb(BloodOrb orb)
|
||||
{
|
||||
return new IngredientBloodOrb(orb.getTier());
|
||||
}
|
||||
|
||||
protected IngredientBloodOrb(int orbTier)
|
||||
{
|
||||
super(Stream.of(new ItemList(orbTier)));
|
||||
this.orbTier = orbTier;
|
||||
}
|
||||
|
||||
public net.minecraftforge.common.crafting.IIngredientSerializer<? extends Ingredient> getSerializer()
|
||||
{
|
||||
return Serializer.INSTANCE;
|
||||
}
|
||||
|
||||
private static class ItemList implements IItemList
|
||||
{
|
||||
private final int orbTier;
|
||||
|
||||
public ItemList(int orbTier)
|
||||
{
|
||||
this.orbTier = orbTier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ItemStack> getStacks()
|
||||
{
|
||||
List<ItemStack> orbGet = OrbRegistry.getOrbsDownToTier(orbTier);
|
||||
|
||||
return orbGet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonObject serialize()
|
||||
{
|
||||
JsonObject object = new JsonObject();
|
||||
object.addProperty("type", NAME.toString());
|
||||
object.addProperty("orb_tier", orbTier);
|
||||
return object;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Serializer extends VanillaIngredientSerializer
|
||||
{
|
||||
public static final IIngredientSerializer<? extends Ingredient> INSTANCE = new Serializer();
|
||||
|
||||
@Override
|
||||
public Ingredient parse(JsonObject json)
|
||||
{
|
||||
return new IngredientBloodOrb(JSONUtils.getInt(json, "orb_tier"));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package wayoftime.bloodmagic.core.registry;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import wayoftime.bloodmagic.api.impl.BloodMagicAPI;
|
||||
import wayoftime.bloodmagic.api.impl.recipe.RecipeAlchemyArray;
|
||||
import wayoftime.bloodmagic.common.alchemyarray.AlchemyArrayEffect;
|
||||
import wayoftime.bloodmagic.common.alchemyarray.AlchemyArrayEffectCrafting;
|
||||
|
||||
public class AlchemyArrayRegistry
|
||||
{
|
||||
public static Map<ResourceLocation, AlchemyArrayEffect> effectMap = new HashMap<ResourceLocation, AlchemyArrayEffect>();
|
||||
|
||||
public static boolean registerEffect(ResourceLocation rl, AlchemyArrayEffect effect)
|
||||
{
|
||||
boolean hadKey = effectMap.containsKey(rl);
|
||||
|
||||
effectMap.put(rl, effect);
|
||||
|
||||
return hadKey;
|
||||
}
|
||||
|
||||
public static AlchemyArrayEffect getEffect(World world, ResourceLocation rl, RecipeAlchemyArray recipe)
|
||||
{
|
||||
if (effectMap.containsKey(rl))
|
||||
{
|
||||
return effectMap.get(rl).getNewCopy();
|
||||
}
|
||||
|
||||
if (!recipe.getOutput().isEmpty())
|
||||
{
|
||||
// Return a new instance of AlchemyEffectCrafting
|
||||
return new AlchemyArrayEffectCrafting(recipe.getOutput());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static AlchemyArrayEffect getEffect(World world, ItemStack input, ItemStack catalyst)
|
||||
{
|
||||
Pair<Boolean, RecipeAlchemyArray> array = BloodMagicAPI.INSTANCE.getRecipeRegistrar().getAlchemyArray(world, input, catalyst);
|
||||
if (array == null || array.getRight() == null || !array.getLeft())
|
||||
return null;
|
||||
|
||||
return getEffect(world, array.getRight().getId(), array.getRight());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package wayoftime.bloodmagic.core.registry;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import wayoftime.bloodmagic.api.impl.BloodMagicAPI;
|
||||
import wayoftime.bloodmagic.api.impl.recipe.RecipeAlchemyArray;
|
||||
import wayoftime.bloodmagic.client.render.alchemyarray.AlchemyArrayRenderer;
|
||||
|
||||
public class AlchemyArrayRendererRegistry
|
||||
{
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static final AlchemyArrayRenderer DEFAULT_RENDERER = new AlchemyArrayRenderer(new ResourceLocation("bloodmagic", "textures/models/alchemyarrays/basearray.png"));
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static Map<ResourceLocation, AlchemyArrayRenderer> rendererMap = new HashMap<ResourceLocation, AlchemyArrayRenderer>();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param rl
|
||||
* @param renderer
|
||||
* @return True if there was already a renderer registered for this rl.
|
||||
*/
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static boolean registerRenderer(ResourceLocation rl, AlchemyArrayRenderer renderer)
|
||||
{
|
||||
boolean hadKey = rendererMap.containsKey(rl);
|
||||
|
||||
rendererMap.put(rl, renderer);
|
||||
|
||||
return hadKey;
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static AlchemyArrayRenderer getRenderer(World world, ResourceLocation rl, RecipeAlchemyArray recipe)
|
||||
{
|
||||
if (rendererMap.containsKey(rl))
|
||||
{
|
||||
return rendererMap.get(rl);
|
||||
}
|
||||
|
||||
ResourceLocation texture = recipe.getTexture();
|
||||
if (texture != null)
|
||||
return new AlchemyArrayRenderer(texture);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static AlchemyArrayRenderer getRenderer(World world, ItemStack input, ItemStack catalyst)
|
||||
{
|
||||
Pair<Boolean, RecipeAlchemyArray> array = BloodMagicAPI.INSTANCE.getRecipeRegistrar().getAlchemyArray(world, input, catalyst);
|
||||
if (array == null || array.getRight() == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return getRenderer(world, array.getRight().getId(), array.getRight());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package wayoftime.bloodmagic.core.registry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import wayoftime.bloodmagic.altar.AltarTier;
|
||||
import wayoftime.bloodmagic.orb.BloodOrb;
|
||||
|
||||
/**
|
||||
* This is only for those who wish to add a basic {@link BloodOrb}. If you need
|
||||
* custom handling, you will need your own item class.
|
||||
*/
|
||||
public class OrbRegistry
|
||||
{
|
||||
public static ArrayListMultimap<Integer, ItemStack> tierMap = ArrayListMultimap.create();
|
||||
private static List<BloodOrb> orbs = new ArrayList<>();
|
||||
|
||||
public static List<ItemStack> getOrbsForTier(int tier)
|
||||
{
|
||||
if (getTierMap().containsKey(tier))
|
||||
return getTierMap().get(tier);
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public static List<ItemStack> getOrbsUpToTier(int tier)
|
||||
{
|
||||
List<ItemStack> ret = new ArrayList<>();
|
||||
|
||||
for (int i = 1; i <= tier; i++) ret.addAll(getOrbsForTier(i));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static List<ItemStack> getOrbsDownToTier(int tier)
|
||||
{
|
||||
List<ItemStack> ret = new ArrayList<>();
|
||||
|
||||
for (int i = AltarTier.MAXTIERS; i >= tier; i--) ret.addAll(getOrbsForTier(i));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static ItemStack getOrbStack(BloodOrb orb)
|
||||
{
|
||||
Item orbItem = ForgeRegistries.ITEMS.getValue(orb.getResourceLocation());
|
||||
if (orbItem == null)
|
||||
return null;
|
||||
|
||||
return new ItemStack(orbItem);
|
||||
}
|
||||
|
||||
public static ArrayListMultimap<Integer, ItemStack> getTierMap()
|
||||
{
|
||||
return ArrayListMultimap.create(tierMap);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue