Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f9cf1b39db | |||
| 3fb3c1c039 | |||
| e8bc6ca725 | |||
| df531d3724 | |||
| 2728012f33 | |||
| 853df2eb42 | |||
| 0cb2165ddf | |||
| ca7e9034ed | |||
| 1322c920f5 | |||
| e5c00e3882 |
+2
-2
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"homepage": "https://www.curseforge.com/minecraft/mc-mods/electroblobs-wizardry",
|
||||
"promos": {
|
||||
"1.12.2-latest": "4.3.12",
|
||||
"1.12.2-recommended": "4.3.12"
|
||||
"1.12.2-latest": "4.3.13",
|
||||
"1.12.2-recommended": "4.3.13"
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ apply plugin: org.ajoberstar.grgit.gradle.GrgitPlugin
|
||||
apply plugin: 'wtf.gofancy.fancygradle'
|
||||
|
||||
|
||||
version = "4.3.12"
|
||||
version = "4.3.13"
|
||||
group= "electroblob.wizardry"// http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = "ElectroblobsWizardry"
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ public class Wizardry {
|
||||
* 1.x.x represents Minecraft 1.7.x versions, 2.x.x represents Minecraft 1.10.x versions, 3.x.x represents Minecraft
|
||||
* 1.11.x versions, and so on.
|
||||
*/
|
||||
public static final String VERSION = "4.3.12";
|
||||
public static final String VERSION = "4.3.13";
|
||||
|
||||
/**
|
||||
* Json file used by Forge's built-in <a href="https://mcforge.readthedocs.io/en/1.12.x/gettingstarted/autoupdate/">update checker</a>.
|
||||
|
||||
@@ -3,10 +3,7 @@ package electroblob.wizardry.client;
|
||||
import electroblob.wizardry.client.renderer.overlay.RenderBlinkEffect;
|
||||
import electroblob.wizardry.data.DispenserCastingData;
|
||||
import electroblob.wizardry.data.SpellEmitterData;
|
||||
import electroblob.wizardry.item.ItemArtefact;
|
||||
import electroblob.wizardry.item.ItemFlamecatcher;
|
||||
import electroblob.wizardry.item.ItemSpectralBow;
|
||||
import electroblob.wizardry.item.ItemWand;
|
||||
import electroblob.wizardry.item.*;
|
||||
import electroblob.wizardry.potion.PotionSlowTime;
|
||||
import electroblob.wizardry.registry.WizardryItems;
|
||||
import electroblob.wizardry.registry.WizardryPotions;
|
||||
@@ -120,6 +117,7 @@ public final class WizardryClientEventHandler {
|
||||
Minecraft.getMinecraft().player.prevRotationPitch = 0;
|
||||
Minecraft.getMinecraft().player.rotationYaw = 0;
|
||||
Minecraft.getMinecraft().player.rotationPitch = 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,10 +131,10 @@ public final class WizardryClientEventHandler {
|
||||
event.getMovementInput().jump = false;
|
||||
event.getMovementInput().sneak = false;
|
||||
}
|
||||
|
||||
|
||||
if(ItemArtefact.isArtefactActive(event.getEntityPlayer(), WizardryItems.charm_move_speed)
|
||||
&& event.getEntityPlayer().isHandActive()
|
||||
&& event.getEntityPlayer().getActiveItemStack().getItem() instanceof ItemWand){
|
||||
&& event.getEntityPlayer().getActiveItemStack().getItem() instanceof ISpellCastingItem){
|
||||
// Normally speed is set to 20% when using items, this makes it 80%
|
||||
event.getMovementInput().moveStrafe *= 4;
|
||||
event.getMovementInput().moveForward *= 4;
|
||||
|
||||
@@ -64,6 +64,11 @@ public interface IStoredVariable<T> extends IVariable<T> {
|
||||
this.ticker = (p, t) -> t; // Initialise this with a do-nothing function, can be overwritten later
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces this variable's update method with the given update function. <i>Beware of auto-unboxing of
|
||||
* primitive types! For lambda expressions, check the second parameter isn't null before operating on it.
|
||||
|
||||
@@ -47,7 +47,10 @@ public interface IVariable<T> {
|
||||
*/
|
||||
void write(ByteBuf buf, T value);
|
||||
|
||||
String getKey();
|
||||
|
||||
/**
|
||||
*
|
||||
* Reads this variable's value from the given {@link ByteBuf}.
|
||||
*/
|
||||
T read(ByteBuf buf);
|
||||
@@ -110,6 +113,11 @@ public interface IVariable<T> {
|
||||
// NYI
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return "none"; // we don't mind as these are never synced (electroblob.wizardry.data.IVariable.Variable.isSynced)
|
||||
}
|
||||
|
||||
@Override
|
||||
public T read(ByteBuf buf){
|
||||
return null; // NYI
|
||||
|
||||
@@ -199,9 +199,14 @@ public class WizardData implements INBTSerializable<NBTTagCompound> {
|
||||
}
|
||||
|
||||
/** Returns a set containing the registered {@link IStoredVariable} objects for which {@link IVariable#isSynced()}
|
||||
* returns true. Used internally for packet reading. */
|
||||
public static Set<IVariable> getSyncedVariables(){
|
||||
return storedVariables.stream().filter(IVariable::isSynced).collect(Collectors.toSet());
|
||||
* returns true, ordered by their keys obtained from {@link IVariable#getKey()}. Used internally for packets. */
|
||||
public static Set<IVariable> getSyncedVariablesOrderedByKey(){
|
||||
Comparator<IVariable> keyComparator = Comparator.comparing(IVariable::getKey);
|
||||
|
||||
return storedVariables.stream()
|
||||
.filter(IVariable::isSynced)
|
||||
.sorted(keyComparator)
|
||||
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,8 +35,8 @@ public class EntityDecay extends EntityMagicConstruct {
|
||||
0.6F + rand.nextFloat() * 0.15F);
|
||||
|
||||
if(!this.world.isRemote){
|
||||
List<EntityLivingBase> targets = EntityUtils.getLivingWithinRadius(1.0d, this.posX, this.posY,
|
||||
this.posZ, this.world);
|
||||
List<EntityLivingBase> targets = EntityUtils.getLivingWithinCylinder(this.width/2f, this.posX, this.posY,
|
||||
this.posZ, this.height, this.world);
|
||||
for(EntityLivingBase target : targets){
|
||||
if(target != this.getCaster()){
|
||||
// If this check wasn't here the potion would be reapplied every tick and hence the entity would be
|
||||
|
||||
@@ -34,7 +34,7 @@ public class EntityFireRing extends EntityScaledConstruct {
|
||||
|
||||
if(this.ticksExisted % 5 == 0 && !this.world.isRemote){
|
||||
|
||||
List<EntityLivingBase> targets = EntityUtils.getLivingWithinRadius(width/2, this.posX, this.posY, this.posZ, this.world);
|
||||
List<EntityLivingBase> targets = EntityUtils.getLivingWithinCylinder(this.width/2, this.posX, this.posY, this.posZ, this.height, this.world);
|
||||
|
||||
for(EntityLivingBase target : targets){
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ public class EntityFireSigil extends EntityScaledConstruct {
|
||||
|
||||
if(!this.world.isRemote){
|
||||
|
||||
List<EntityLivingBase> targets = EntityUtils.getLivingWithinRadius(width/2, posX, posY, posZ, world);
|
||||
List<EntityLivingBase> targets = EntityUtils.getLivingWithinCylinder(this.width/2, this.posX, this.posY, this.posZ, this.height, this.world);
|
||||
|
||||
for(EntityLivingBase target : targets){
|
||||
|
||||
|
||||
@@ -36,8 +36,8 @@ public class EntityFrostSigil extends EntityScaledConstruct {
|
||||
|
||||
if(!this.world.isRemote){
|
||||
|
||||
List<EntityLivingBase> targets = EntityUtils.getLivingWithinRadius(width/2, this.posX, this.posY,
|
||||
this.posZ, this.world);
|
||||
List<EntityLivingBase> targets = EntityUtils.getLivingWithinCylinder(width/2, this.posX, this.posY,
|
||||
this.posZ, this.height, this.world);
|
||||
|
||||
for(EntityLivingBase target : targets){
|
||||
|
||||
|
||||
@@ -33,30 +33,32 @@ public class EntityHealAura extends EntityScaledConstruct {
|
||||
|
||||
if(!this.world.isRemote){
|
||||
|
||||
List<EntityLivingBase> targets = EntityUtils.getLivingWithinRadius(width/2, posX, posY, posZ, world);
|
||||
List<EntityLivingBase> targets = EntityUtils.getLivingWithinCylinder(width/2, posX, posY, posZ, this.height, world);
|
||||
|
||||
for(EntityLivingBase target : targets){
|
||||
|
||||
if(this.isValidTarget(target)){
|
||||
|
||||
if(target.isEntityUndead()){
|
||||
if(target.isEntityUndead()) {
|
||||
|
||||
double velX = target.motionX;
|
||||
double velY = target.motionY;
|
||||
double velZ = target.motionZ;
|
||||
|
||||
if(this.getCaster() != null){
|
||||
target.attackEntityFrom(
|
||||
MagicDamage.causeIndirectMagicDamage(this, getCaster(), DamageType.RADIANT),
|
||||
Spells.healing_aura.getProperty(Spell.DAMAGE).floatValue() * damageMultiplier);
|
||||
}else{
|
||||
target.attackEntityFrom(DamageSource.MAGIC, Spells.healing_aura.getProperty(Spell.DAMAGE).floatValue() * damageMultiplier);
|
||||
}
|
||||
if (this.ticksExisted % 10 == 1) {
|
||||
if (this.getCaster() != null) {
|
||||
target.attackEntityFrom(
|
||||
MagicDamage.causeIndirectMagicDamage(this, getCaster(), DamageType.RADIANT),
|
||||
Spells.healing_aura.getProperty(Spell.DAMAGE).floatValue() * damageMultiplier);
|
||||
} else {
|
||||
target.attackEntityFrom(DamageSource.MAGIC, Spells.healing_aura.getProperty(Spell.DAMAGE).floatValue() * damageMultiplier);
|
||||
}
|
||||
|
||||
// Removes knockback
|
||||
target.motionX = velX;
|
||||
target.motionY = velY;
|
||||
target.motionZ = velZ;
|
||||
// Removes knockback
|
||||
target.motionX = velX;
|
||||
target.motionY = velY;
|
||||
target.motionZ = velZ;
|
||||
}
|
||||
}
|
||||
|
||||
}else if(target.getHealth() < target.getMaxHealth() && target.ticksExisted % 5 == 0){
|
||||
|
||||
@@ -39,8 +39,8 @@ public class EntityLightningSigil extends EntityScaledConstruct {
|
||||
this.setDead();
|
||||
}
|
||||
|
||||
List<EntityLivingBase> targets = EntityUtils.getLivingWithinRadius(width/2, this.posX, this.posY,
|
||||
this.posZ, this.world);
|
||||
List<EntityLivingBase> targets = EntityUtils.getLivingWithinCylinder(this.width/2, this.posX, this.posY,
|
||||
this.posZ, this.height, this.world);
|
||||
|
||||
for(EntityLivingBase target : targets){
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ public class EntityWizard extends EntityCreature implements INpc, IMerchant, ISp
|
||||
protected Predicate<Entity> targetSelector;
|
||||
|
||||
/** The wizard's trades. */
|
||||
private MerchantRecipeList trades;
|
||||
public MerchantRecipeList trades;
|
||||
/** The wizard's current customer. */
|
||||
@Nullable
|
||||
private EntityPlayer customer;
|
||||
@@ -130,8 +130,12 @@ public class EntityWizard extends EntityCreature implements INpc, IMerchant, ISp
|
||||
if(entity != null && !entity.isInvisible()
|
||||
&& AllyDesignationSystem.isValidTarget(EntityWizard.this, entity)){
|
||||
|
||||
// ... and is a mob, a summoned creature ...
|
||||
if((entity instanceof IMob || entity instanceof ISummonedCreature
|
||||
// ... and is a non summoned creature mob ...
|
||||
if((entity instanceof IMob && !(entity instanceof ISummonedCreature)
|
||||
|
||||
// or is a summoned creature with a mob owner or an owner who has attacked the wizard ...
|
||||
|| entity instanceof ISummonedCreature && (((ISummonedCreature)entity).getOwner() instanceof IMob || ((ISummonedCreature)entity).getOwner() == this.getRevengeTarget() || ((ISummonedCreature) entity).getOwner() == this.getAttackTarget())
|
||||
|
||||
// ... or in the whitelist ...
|
||||
|| Arrays.asList(Wizardry.settings.summonedCreatureTargetsWhitelist)
|
||||
.contains(EntityList.getKey(entity.getClass())))
|
||||
|
||||
@@ -193,14 +193,6 @@ public class ItemFlamecatcher extends ItemBow implements IConjuredItem {
|
||||
charge = net.minecraftforge.event.ForgeEventFactory.onArrowLoose(stack, world, (EntityPlayer)entity, charge, true);
|
||||
if(charge < 0) return;
|
||||
|
||||
if(stack.getTagCompound() != null){
|
||||
int shotsLeft = stack.getTagCompound().getInteger(Flamecatcher.SHOTS_REMAINING_NBT_KEY) - 1;
|
||||
stack.getTagCompound().setInteger(Flamecatcher.SHOTS_REMAINING_NBT_KEY, shotsLeft);
|
||||
if(shotsLeft == 0 && !world.isRemote){
|
||||
stack.setItemDamage(getMaxDamage(stack) - getAnimationFrames());
|
||||
}
|
||||
}
|
||||
|
||||
float velocity = (float)charge / DRAW_TIME;
|
||||
velocity = (velocity * velocity + velocity * 2) / 3;
|
||||
|
||||
@@ -208,6 +200,14 @@ public class ItemFlamecatcher extends ItemBow implements IConjuredItem {
|
||||
|
||||
if((double)velocity >= 0.1D){
|
||||
|
||||
if(stack.getTagCompound() != null){
|
||||
int shotsLeft = stack.getTagCompound().getInteger(Flamecatcher.SHOTS_REMAINING_NBT_KEY) - 1;
|
||||
stack.getTagCompound().setInteger(Flamecatcher.SHOTS_REMAINING_NBT_KEY, shotsLeft);
|
||||
if(shotsLeft == 0 && !world.isRemote){
|
||||
stack.setItemDamage(getMaxDamage(stack) - getAnimationFrames());
|
||||
}
|
||||
}
|
||||
|
||||
if(!world.isRemote){
|
||||
EntityFlamecatcherArrow arrow = new EntityFlamecatcherArrow(world);
|
||||
arrow.aim(player, EntityFlamecatcherArrow.SPEED * velocity);
|
||||
|
||||
@@ -864,33 +864,10 @@ public class ItemWand extends Item implements IWorkbenchItem, ISpellCastingItem,
|
||||
WandHelper.setSpells(centre.getStack(), spells);
|
||||
|
||||
// Charges wand by appropriate amount
|
||||
if(crystals.getStack() != ItemStack.EMPTY && !this.isManaFull(centre.getStack())){
|
||||
|
||||
int chargeDepleted = this.getManaCapacity(centre.getStack()) - this.getMana(centre.getStack());
|
||||
|
||||
// Not too pretty but allows addons implementing the IManaStoringItem interface to provide their mana amount for custom crystals,
|
||||
// previously this was defaulted to the regular crystal's amount, allowing players to exploit it if a crystal was worth less mana than that.
|
||||
int manaPerItem = crystals.getStack().getItem() instanceof IManaStoringItem ?
|
||||
((IManaStoringItem) crystals.getStack().getItem()).getMana(crystals.getStack()) :
|
||||
crystals.getStack().getItem() instanceof ItemCrystal ? Constants.MANA_PER_CRYSTAL : Constants.MANA_PER_SHARD;
|
||||
|
||||
if(crystals.getStack().getItem() == WizardryItems.crystal_shard) manaPerItem = Constants.MANA_PER_SHARD;
|
||||
if(crystals.getStack().getItem() == WizardryItems.grand_crystal) manaPerItem = Constants.GRAND_CRYSTAL_MANA;
|
||||
|
||||
if(crystals.getStack().getCount() * manaPerItem < chargeDepleted){
|
||||
// If there aren't enough crystals to fully charge the wand
|
||||
this.rechargeMana(centre.getStack(), crystals.getStack().getCount() * manaPerItem);
|
||||
crystals.decrStackSize(crystals.getStack().getCount());
|
||||
|
||||
}else{
|
||||
// If there are excess crystals (or just enough)
|
||||
this.setMana(centre.getStack(), this.getManaCapacity(centre.getStack()));
|
||||
crystals.decrStackSize((int)Math.ceil(((double)chargeDepleted) / manaPerItem));
|
||||
}
|
||||
|
||||
if (WandHelper.rechargeManaOnApplyButtonPressed(centre, crystals)) {
|
||||
changed = true;
|
||||
}
|
||||
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,11 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* <b>[Server -> Client]</b> This packet is sent to synchronise any fields that need synchronising in
|
||||
@@ -54,9 +58,8 @@ public class PacketPlayerSync implements IMessageHandler<Message, IMessage> {
|
||||
|
||||
this.seed = buf.readLong();
|
||||
this.selectedMinionID = buf.readInt();
|
||||
|
||||
this.spellData = new HashMap<>();
|
||||
WizardData.getSyncedVariables().forEach(v -> spellData.put(v, v.read(buf)));
|
||||
WizardData.getSyncedVariablesOrderedByKey().forEach(v -> spellData.put(v, v.read(buf)));
|
||||
// Have to send empty tags to guarantee correct ByteBuf size/order, but no point keeping the resulting nulls
|
||||
spellData.values().removeIf(Objects::isNull);
|
||||
|
||||
@@ -73,7 +76,7 @@ public class PacketPlayerSync implements IMessageHandler<Message, IMessage> {
|
||||
buf.writeLong(seed);
|
||||
buf.writeInt(selectedMinionID);
|
||||
|
||||
WizardData.getSyncedVariables().forEach(v -> v.write(buf, spellData.get(v)));
|
||||
WizardData.getSyncedVariablesOrderedByKey().forEach(v -> v.write(buf, spellData.get(v)));
|
||||
|
||||
if(this.spellsDiscovered == null) return;
|
||||
for(Spell spell : this.spellsDiscovered){
|
||||
|
||||
@@ -4,7 +4,7 @@ import electroblob.wizardry.item.SpellActions;
|
||||
import electroblob.wizardry.util.ParticleBuilder;
|
||||
import electroblob.wizardry.util.ParticleBuilder.Type;
|
||||
import electroblob.wizardry.util.SpellModifiers;
|
||||
import net.minecraft.entity.EntityCreature;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.tileentity.TileEntityDispenser;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
@@ -29,7 +29,7 @@ public class Enrage extends SpellAreaEffect {
|
||||
@Override
|
||||
protected boolean affectEntity(World world, Vec3d origin, @Nullable EntityLivingBase caster, EntityLivingBase target, int targetCount, int ticksInUse, SpellModifiers modifiers){
|
||||
|
||||
if(caster != null && target instanceof EntityCreature){
|
||||
if(caster != null && target instanceof EntityLiving){
|
||||
target.setRevengeTarget(caster); // Yours truly, angry mobs
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ public class Heal extends SpellBuff {
|
||||
entity.heal(health);
|
||||
|
||||
// If the player is able to heal, they can't possibly have absorption hearts, so no need to check!
|
||||
if(excessHealth > 0 && entity instanceof EntityPlayer
|
||||
if(excessHealth > entity.getAbsorptionAmount() && entity instanceof EntityPlayer
|
||||
&& ItemArtefact.isArtefactActive((EntityPlayer)entity, WizardryItems.amulet_absorption)){
|
||||
entity.setAbsorptionAmount(excessHealth);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package electroblob.wizardry.spell;
|
||||
|
||||
import electroblob.wizardry.Wizardry;
|
||||
import electroblob.wizardry.item.ItemArtefact;
|
||||
import electroblob.wizardry.item.SpellActions;
|
||||
import electroblob.wizardry.registry.WizardryItems;
|
||||
import electroblob.wizardry.util.SpellModifiers;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -34,7 +36,7 @@ public class Telekinesis extends SpellRay {
|
||||
target.motionZ = (origin.z - target.posZ) / 6;
|
||||
return true;
|
||||
|
||||
}else if(target instanceof EntityPlayer && (Wizardry.settings.telekineticDisarmament || !(caster instanceof EntityPlayer))){
|
||||
} else if (target instanceof EntityPlayer && (Wizardry.settings.telekineticDisarmament && !ItemArtefact.isArtefactActive((EntityPlayer) target, WizardryItems.amulet_anchoring)) {
|
||||
|
||||
EntityPlayer player = (EntityPlayer)target;
|
||||
|
||||
|
||||
@@ -141,6 +141,11 @@ public final class AllyDesignationSystem {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Tests whether the target is a creature that was summoned/tamed (or is otherwise owned) by the attacker
|
||||
if(target instanceof IEntityOwnable && attacker instanceof EntityLiving && !(((EntityLiving)attacker).getRevengeTarget() == ((IEntityOwnable)target).getOwner() || ((EntityLiving)attacker).getAttackTarget() == ((IEntityOwnable)target).getOwner())){
|
||||
return false;
|
||||
}
|
||||
|
||||
// Tests whether the target is a creature that was mind controlled by the attacker
|
||||
if(target instanceof EntityLiving && ((EntityLivingBase)target).isPotionActive(WizardryPotions.mind_control)){
|
||||
|
||||
|
||||
@@ -117,6 +117,45 @@ public final class EntityUtils {
|
||||
return entityList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all EntityLivingBase within the cylinder radius of the given coordinates. This should
|
||||
* used by circle effects.
|
||||
*
|
||||
* @param radius The search radius
|
||||
* @param x The x coordinate to search around
|
||||
* @param y The y coordinate to search around
|
||||
* @param z The z coordinate to search around
|
||||
* @param height The height of the cylinder
|
||||
* @param world The world to search in
|
||||
*/
|
||||
public static List<EntityLivingBase> getLivingWithinCylinder(double radius, double x, double y, double z, double height, World world) {
|
||||
return getEntitiesWithinCylinder(radius, x, y, z, height, world, EntityLivingBase.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all entities of the specified type within the cylinder radius of the given coordinates. This should
|
||||
* used by circle effects.
|
||||
*
|
||||
* @param radius The search radius
|
||||
* @param x The x coordinate to search around
|
||||
* @param y The y coordinate to search around
|
||||
* @param z The z coordinate to search around
|
||||
* @param height The height of the cylinder
|
||||
* @param world The world to search in
|
||||
* @param entityType The class of entity to search for; pass in Entity.class for all entities
|
||||
*/
|
||||
public static <T extends Entity> List<T> getEntitiesWithinCylinder(double radius, double x, double y, double z, double height, World world, Class<T> entityType) {
|
||||
AxisAlignedBB aabb = new AxisAlignedBB(x - radius, y, z - radius, x + radius, y + height, z + radius);
|
||||
List<T> entityList = world.getEntitiesWithinAABB(entityType, aabb);
|
||||
for(T entity : entityList) {
|
||||
if (entity.getDistance(x, entity.posY, z) > radius) {
|
||||
entityList.remove(entity);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return entityList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an entity from its UUID. If the UUID is known to belong to an {@code EntityPlayer}, use the more efficient
|
||||
* {@link World#getPlayerEntityByUUID(UUID)} instead.
|
||||
|
||||
@@ -20,8 +20,7 @@ public interface ISpellSortable {
|
||||
|
||||
TIER("tier", Comparator.naturalOrder()),
|
||||
ELEMENT("element", Comparator.comparing(Spell::getElement).thenComparing(Spell::getTier)),
|
||||
ALPHABETICAL("alphabetical", Comparator.comparing(Spell::getUnlocalisedName));
|
||||
|
||||
ALPHABETICAL("alphabetical", Comparator.comparing(s -> s.getRegistryName().getPath().toString()));
|
||||
public String name;
|
||||
public Comparator<? super Spell> comparator;
|
||||
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
package electroblob.wizardry.util;
|
||||
|
||||
import electroblob.wizardry.constants.Constants;
|
||||
import electroblob.wizardry.item.IManaStoringItem;
|
||||
import electroblob.wizardry.item.IWorkbenchItem;
|
||||
import electroblob.wizardry.item.ItemCrystal;
|
||||
import electroblob.wizardry.item.ItemWand;
|
||||
import electroblob.wizardry.registry.Spells;
|
||||
import electroblob.wizardry.registry.WizardryItems;
|
||||
import electroblob.wizardry.spell.Spell;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -494,4 +499,49 @@ public final class WandHelper {
|
||||
setProgression(wand, getProgression(wand) + progression);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recharges the mana of an item when the apply button is pressed in the arcane workbench GUI.
|
||||
* This method requires the central item to implement both the {@link IWorkbenchItem} and {@link IManaStoringItem} interfaces.
|
||||
*
|
||||
* @param centre The slot representing the central item to be recharged.
|
||||
* @param crystals The slot containing mana crystals for recharging.
|
||||
* @return {@code true} if the mana of the central item was successfully recharged, {@code false} otherwise.
|
||||
*/
|
||||
public static boolean rechargeManaOnApplyButtonPressed(Slot centre, Slot crystals) {
|
||||
boolean changed = false;
|
||||
if (!(centre.getStack().getItem() instanceof IWorkbenchItem) || !(centre.getStack().getItem() instanceof IManaStoringItem)) {
|
||||
return false;
|
||||
}
|
||||
IManaStoringItem iManaStoringItem = (IManaStoringItem) centre.getStack().getItem();
|
||||
|
||||
// Charges the item by appropriate amount
|
||||
if (crystals.getStack() != ItemStack.EMPTY && !iManaStoringItem.isManaFull(centre.getStack())) {
|
||||
|
||||
int chargeDepleted = iManaStoringItem.getManaCapacity(centre.getStack()) - iManaStoringItem.getMana(centre.getStack());
|
||||
|
||||
// Not too pretty but allows addons implementing the IManaStoringItem interface to provide their mana amount for custom crystals,
|
||||
// previously this was defaulted to the regular crystal's amount, allowing players to exploit it if a crystal was worth less mana than that.
|
||||
int manaPerItem = crystals.getStack().getItem() instanceof IManaStoringItem ?
|
||||
((IManaStoringItem) crystals.getStack().getItem()).getMana(crystals.getStack()) :
|
||||
crystals.getStack().getItem() instanceof ItemCrystal ? Constants.MANA_PER_CRYSTAL : Constants.MANA_PER_SHARD;
|
||||
|
||||
if (crystals.getStack().getItem() == WizardryItems.crystal_shard) {manaPerItem = Constants.MANA_PER_SHARD;}
|
||||
if (crystals.getStack().getItem() == WizardryItems.grand_crystal) {manaPerItem = Constants.GRAND_CRYSTAL_MANA;}
|
||||
|
||||
if (crystals.getStack().getCount() * manaPerItem < chargeDepleted) {
|
||||
// If there aren't enough crystals to fully charge the item
|
||||
iManaStoringItem.rechargeMana(centre.getStack(), crystals.getStack().getCount() * manaPerItem);
|
||||
crystals.decrStackSize(crystals.getStack().getCount());
|
||||
|
||||
} else {
|
||||
// If there are excess crystals (or just enough)
|
||||
iManaStoringItem.setMana(centre.getStack(), iManaStoringItem.getManaCapacity(centre.getStack()));
|
||||
crystals.decrStackSize((int) Math.ceil(((double) chargeDepleted) / manaPerItem));
|
||||
}
|
||||
|
||||
changed = true;
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"modid" : "ebwizardry",
|
||||
"name" : "Electroblob's Wizardry",
|
||||
"version" : "4.3.12",
|
||||
"version" : "4.3.13",
|
||||
"mcversion" : "1.12.2",
|
||||
"url" : "https://minecraft.curseforge.com/projects/electroblobs-wizardry",
|
||||
"credits" : "\nDesigned, coded and textured by Electroblob.\nDiscord Moderators: FavouriteDragon, WinDanesz\nCode contributed by: Corail31, 12foo, Shadows-of-Fire, Tora-B, Avatair, Aeronica, UltraHex, Azim-Palmer, raoulvdberge, rafasoares, xinyuan-liu, SettingDust, Aralu115, WinDanesz, ZettaSword.\nTranslators: Alsentar (Spanish), MadWrist (Mexican Spanish), VilagVil, kellixon, bigenergy, MugGod2 & DrHesperus (Russian), Hahdrim & Crowller (French), lorrampi (Brazilian Portuguese), ZHENGLOC, dragon-evol, Hokorizero, TUsama & Determancer (Chinese - Simplified), shejery, rewi_wire, 방통 & red1854th (Korean), Trozuu & Olej (Polish), BirdyDragon & Lemopav (German), chesterccj305 (Chinese - Traditional), Bombadil (Hungarian).\nSound Effects: OhhWowProductions, fredzed, deleted_user_3277771, DiscoveryME, OGSoundFX, leosalom, juskiddink",
|
||||
|
||||
Reference in New Issue
Block a user