Added Locate abilities

This commit is contained in:
Timo Ley 2020-04-30 13:18:06 +02:00
parent 98ac438a98
commit 7e22d8beea
6 changed files with 98 additions and 1 deletions

View File

@ -0,0 +1,16 @@
package anvil.infinity.abilities;
import lucraft.mods.lucraftcore.superpowers.abilities.AbilityConstant;
import net.minecraft.entity.EntityLivingBase;
public class AbilityLocate extends AbilityConstant {
public AbilityLocate(EntityLivingBase entity) {
super(entity);
}
@Override
public void updateTick() {
}
}

View File

@ -1,9 +1,16 @@
package anvil.infinity.command;
import anvil.infinity.abilities.AbilityLocate;
import anvil.infinity.compat.CompatHandler;
import anvil.infinity.config.ModConfig;
import anvil.infinity.worldgen.WorldData;
import lucraft.mods.heroesexpansion.superpowers.HESuperpowers;
import lucraft.mods.lucraftcore.superpowers.SuperpowerHandler;
import lucraft.mods.lucraftcore.superpowers.abilities.Ability;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
@ -21,14 +28,33 @@ public class GeneratedCommand extends CommandBase {
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
boolean locate = false;
if (sender instanceof EntityLivingBase) {
locate = Ability.hasAbility((EntityLivingBase) sender, AbilityLocate.class);
if (CompatHandler.isHeroesExpansion) {
locate = locate || SuperpowerHandler.hasSuperpower((EntityLivingBase) sender, HESuperpowers.GOD_OF_THUNDER);
}
}
WorldData data = WorldData.get(server.getWorld(0));
ITextComponent msg = new TextComponentString("Generated: ");
msg.appendText("\n Space Stone: " + data.space);
if (locate)
msg.appendText("\n X: " + data.spacex + "\n Z: " + data.spacez + "\n Dim: " + ModConfig.Worldgen.spaceDim);
msg.appendText("\n Power Stone: " + data.power);
if (locate)
msg.appendText("\n X: " + data.powerx + "\n Z: " + data.powerz + "\n Dim: " + ModConfig.Worldgen.powerDim);
msg.appendText("\n Mind Stone: " + data.mind);
if (locate)
msg.appendText("\n X: " + data.mindx + "\n Z: " + data.mindz + "\n Dim: " + ModConfig.Worldgen.mindDim);
msg.appendText("\n Soul Stone: " + data.soul);
if (locate)
msg.appendText("\n X: " + data.soulx + "\n Z: " + data.soulz + "\n Dim: " + ModConfig.Worldgen.soulDim);
msg.appendText("\n Time Stone: " + data.time);
if (locate)
msg.appendText("\n X: " + data.timex + "\n Z: " + data.timez + "\n Dim: " + ModConfig.Worldgen.timeDim);
msg.appendText("\n Reality Stone: " + data.reality);
if (locate)
msg.appendText("\n X: " + data.realityx + "\n Z: " + data.realityz + "\n Dim: " + ModConfig.Worldgen.realityDim);
sender.sendMessage(msg);
}
}

View File

@ -1,5 +1,6 @@
package anvil.infinity.items;
import anvil.infinity.abilities.AbilityLocate;
import anvil.infinity.api.AbilityAdderHandler;
import anvil.infinity.compat.CompatHandler;
import anvil.infinity.helpers.GauntelHelper;
@ -36,6 +37,7 @@ public class ItemSpaceStone extends ItemInfinityStone {
abilities.put("portal", CompatHandler.HeroesExpension.getAbilityPortal(entity).setDataValue(Ability.BAR_COLOR, EnumAbilityBarColor.LIGHT_BLUE));
abilities.put("grab_entity", CompatHandler.HeroesExpension.getAbilityGrabEntity(entity).setDataValue(Ability.BAR_COLOR, EnumAbilityBarColor.LIGHT_BLUE));
abilities.put("forcefield", CompatHandler.HeroesExpension.getAbilityForcefield(entity).setMaxCooldown(60).setDataValue(Ability.BAR_COLOR, EnumAbilityBarColor.LIGHT_BLUE));
abilities.put("locate", new AbilityLocate(entity));
if (GauntelHelper.hasPowerStone(entity)) {
abilities.put("blackhole", CompatHandler.HeroesExpension.getAbilityBlackhole(entity).setMaxCooldown(6000).setDataValue(Ability.BAR_COLOR, EnumAbilityBarColor.LIGHT_BLUE));

View File

@ -19,6 +19,7 @@ public class Abilities {
e.getRegistry().register(new AbilityEntry(AbilitySaturation.class, new ResourceLocation(Infinity.MOD_ID, "saturation")));
e.getRegistry().register(new AbilityEntry(AbilityFastForward.class, new ResourceLocation(Infinity.MOD_ID, "fast_forward")));
e.getRegistry().register(new AbilityEntry(AbilityStopTime.class, new ResourceLocation(Infinity.MOD_ID, "stop_time")));
e.getRegistry().register(new AbilityEntry(AbilityLocate.class, new ResourceLocation(Infinity.MOD_ID, "locate")));
}

View File

@ -17,7 +17,6 @@ import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
@ -38,6 +37,8 @@ public class StoneTempleGen extends WorldGenerator {
gen(world, position, Items.MIND_STONE);
WorldData data = WorldData.get(world);
data.mind = true;
data.mindx = position.getX();
data.mindz = position.getZ();
data.markDirty();
sendMessage("Mind", world);
return true;
@ -45,6 +46,8 @@ public class StoneTempleGen extends WorldGenerator {
gen(world, position, Items.SPACE_STONE);
WorldData data = WorldData.get(world);
data.space = true;
data.spacex = position.getX();
data.spacez = position.getZ();
data.markDirty();
sendMessage("Space", world);
return true;
@ -52,6 +55,8 @@ public class StoneTempleGen extends WorldGenerator {
gen(world, position, Items.REALITY_STONE);
WorldData data = WorldData.get(world);
data.reality = true;
data.realityx = position.getX();
data.realityz = position.getZ();
data.markDirty();
sendMessage("Reality", world);
return true;
@ -59,6 +64,8 @@ public class StoneTempleGen extends WorldGenerator {
gen(world, position, Items.TIME_STONE);
WorldData data = WorldData.get(world);
data.time = true;
data.timex = position.getX();
data.timez = position.getZ();
data.markDirty();
sendMessage("Time", world);
return true;
@ -66,6 +73,8 @@ public class StoneTempleGen extends WorldGenerator {
gen(world, position, Items.SOUL_STONE);
WorldData data = WorldData.get(world);
data.soul = true;
data.soulx = position.getX();
data.soulz = position.getZ();
data.markDirty();
sendMessage("Soul", world);
return true;
@ -73,6 +82,8 @@ public class StoneTempleGen extends WorldGenerator {
gen(world, position, Items.POWER_STONE);
WorldData data = WorldData.get(world);
data.power = true;
data.powerx = position.getX();
data.powerz = position.getZ();
data.markDirty();
sendMessage("Power", world);
return true;

View File

@ -24,6 +24,20 @@ public class WorldData extends WorldSavedData {
public boolean time;
public boolean mind;
public int powerx;
public int spacex;
public int realityx;
public int soulx;
public int timex;
public int mindx;
public int powerz;
public int spacez;
public int realityz;
public int soulz;
public int timez;
public int mindz;
@Override
public void readFromNBT(NBTTagCompound nbt) {
power = nbt.getBoolean("power");
@ -33,6 +47,19 @@ public class WorldData extends WorldSavedData {
time = nbt.getBoolean("time");
mind = nbt.getBoolean("mind");
powerx = nbt.getInteger("powerX");
spacex = nbt.getInteger("spaceX");
realityx = nbt.getInteger("realityX");
soulx = nbt.getInteger("soulX");
timex = nbt.getInteger("timeX");
mindx = nbt.getInteger("mindX");
powerz = nbt.getInteger("powerZ");
spacez = nbt.getInteger("spaceZ");
realityz = nbt.getInteger("realityZ");
soulz = nbt.getInteger("soulZ");
timez = nbt.getInteger("timeZ");
mindz = nbt.getInteger("mindZ");
}
@Override
@ -44,6 +71,20 @@ public class WorldData extends WorldSavedData {
compound.setBoolean("time", time);
compound.setBoolean("mind", mind);
compound.setInteger("powerX", powerx);
compound.setInteger("spaceX", spacex);
compound.setInteger("realityX", realityx);
compound.setInteger("soulX", soulx);
compound.setInteger("timeX", timex);
compound.setInteger("mindX", mindx);
compound.setInteger("powerZ", powerz);
compound.setInteger("spaceZ", spacez);
compound.setInteger("realityZ", realityz);
compound.setInteger("soulZ", soulz);
compound.setInteger("timeZ", timez);
compound.setInteger("mindZ", mindz);
return compound;
}