mirror of
https://github.com/GTNewHorizons/Gadomancy.git
synced 2026-11-21 20:42:12 +00:00
- Added some aura effects.
This commit is contained in:
1 parent
bb848689f1
commit
2d0f15d0f9
12 files changed
+336
-20
No files matched your search
@@ -1,8 +1,12 @@
|
||||
package makeo.gadomancy.api;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* This class is part of the Gadomancy Mod
|
||||
* Gadomancy is Open Source and distributed under the
|
||||
@@ -13,17 +17,132 @@ import thaumcraft.api.aspects.Aspect;
|
||||
*/
|
||||
public abstract class AuraEffect {
|
||||
|
||||
/**
|
||||
* Return the EffectType you want to use here.
|
||||
*
|
||||
* EffectType.ENTITY_EFFECT selects entities within {@link AuraEffect#getRange()}
|
||||
* range and fires the Entity-related methods
|
||||
*
|
||||
* EffectType.BLOCK_EFFECT selects random locations within {@link #getRange()}
|
||||
* range and fires {@link #doBlockEffect(net.minecraft.util.ChunkCoordinates, net.minecraft.util.ChunkCoordinates, net.minecraft.world.World)}
|
||||
*/
|
||||
public abstract EffectType getEffectType();
|
||||
|
||||
/**
|
||||
* Only fired when {@link #getEffectType()} returns {@link makeo.gadomancy.api.AuraEffect.EffectType#ENTITY_EFFECT}
|
||||
*
|
||||
* @param e an entity to check if it should be handled.
|
||||
* @return if the entity should be handled with {@link #doEntityEffect(net.minecraft.util.ChunkCoordinates, net.minecraft.entity.Entity)}
|
||||
*/
|
||||
public abstract boolean isEntityApplicable(Entity e);
|
||||
|
||||
public abstract void applyEffect(Entity e);
|
||||
/**
|
||||
* Only fired when {@link #getEffectType()} returns {@link makeo.gadomancy.api.AuraEffect.EffectType#ENTITY_EFFECT}
|
||||
* Do the actual effect on the Entity here.
|
||||
*
|
||||
* @param originTile where the master tile of the aura pylon is.
|
||||
* @param e an entity where {@link #isEntityApplicable(net.minecraft.entity.Entity)} returned true
|
||||
*/
|
||||
public abstract void doEntityEffect(ChunkCoordinates originTile, Entity e);
|
||||
|
||||
/**
|
||||
* Only fired when {@link #getEffectType()} returns {@link makeo.gadomancy.api.AuraEffect.EffectType#BLOCK_EFFECT}
|
||||
*
|
||||
* @param random a random to evaluate random numbers. convenience reasons
|
||||
* @return the amount of blocks that should be collected.
|
||||
*/
|
||||
public abstract int getBlockCount(Random random);
|
||||
|
||||
/**
|
||||
* Only fired when {@link #getEffectType()} returns {@link makeo.gadomancy.api.AuraEffect.EffectType#BLOCK_EFFECT}
|
||||
* Do the actual effect on a block here.
|
||||
*
|
||||
* @param originTile where the master tile of the aura pylon is.
|
||||
* @param selectedBlock a selected block
|
||||
* @param world world of the tile and the block
|
||||
*/
|
||||
public abstract void doBlockEffect(ChunkCoordinates originTile, ChunkCoordinates selectedBlock, World world);
|
||||
|
||||
/**
|
||||
* Returns the tick interval how often the aura effect is called
|
||||
*/
|
||||
public int getTickInterval() {
|
||||
return 8;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the range of the aura pylon's effect
|
||||
*
|
||||
* Defines
|
||||
* - the range where entities are collected around the pylon.
|
||||
* - the range where blocks are collected around the pylon.
|
||||
* - how close the player has to be to get the aura's research
|
||||
*/
|
||||
public double getRange() {
|
||||
return 8;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the AuraEffect to the given Aspect.
|
||||
*
|
||||
* @param a to register this to.
|
||||
* @return the current AuraEffect object
|
||||
*/
|
||||
public AuraEffect register(Aspect a) {
|
||||
GadomancyApi.registerAdditionalAuraEffect(a, this);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* A EntityEffect AuraEffect class for convenience
|
||||
*/
|
||||
public static abstract class EntityAuraEffect extends AuraEffect {
|
||||
|
||||
@Override
|
||||
public final EffectType getEffectType() {
|
||||
return EffectType.ENTITY_EFFECT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract boolean isEntityApplicable(Entity e);
|
||||
|
||||
@Override
|
||||
public abstract void doEntityEffect(ChunkCoordinates originTile, Entity e);
|
||||
|
||||
@Override
|
||||
public final int getBlockCount(Random random) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void doBlockEffect(ChunkCoordinates originTile, ChunkCoordinates selectedBlock, World world) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* A BlockEffect AuraEffect class for convenience
|
||||
*/
|
||||
public static abstract class BlockAuraEffect extends AuraEffect {
|
||||
|
||||
@Override
|
||||
public final EffectType getEffectType() {
|
||||
return EffectType.BLOCK_EFFECT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isEntityApplicable(Entity e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void doEntityEffect(ChunkCoordinates originTile, Entity e) {}
|
||||
|
||||
}
|
||||
|
||||
public static enum EffectType {
|
||||
|
||||
ENTITY_EFFECT,
|
||||
BLOCK_EFFECT
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,9 +4,11 @@ import makeo.gadomancy.api.AuraEffect;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@@ -24,11 +26,54 @@ public class AuraEffectHandler {
|
||||
|
||||
public static Map<Aspect, AuraEffect> registeredEffects = new HashMap<Aspect, AuraEffect>();
|
||||
|
||||
public static void distributeEffects(Aspect aspect, World worldObj, double x, double y, double z, double range, int tick) {
|
||||
public static void distributeEffects(Aspect aspect, World worldObj, double x, double y, double z, int tick) {
|
||||
if(!registeredEffects.containsKey(aspect) || worldObj.isRemote) return;
|
||||
AuraEffect effect = registeredEffects.get(aspect);
|
||||
if((tick % effect.getTickInterval()) != 0) return;
|
||||
|
||||
AuraEffect.EffectType type = effect.getEffectType();
|
||||
switch (type) {
|
||||
case ENTITY_EFFECT:
|
||||
doEntityEffects(effect, worldObj, x, y, z);
|
||||
break;
|
||||
case BLOCK_EFFECT:
|
||||
doBlockEffects(effect, worldObj, x, y, z);
|
||||
break;
|
||||
}
|
||||
|
||||
//Distribute research
|
||||
double range = effect.getRange();
|
||||
List players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x - 0.5, y - 0.5, z - 0.5, x + 0.5, y + 0.5, z + 0.5).expand(range, range, range));
|
||||
for(Object p : players) {
|
||||
if(p == null || !(p instanceof EntityPlayer)) continue;
|
||||
EntityPlayer player = (EntityPlayer) p;
|
||||
AuraResearchManager.tryUnlockAuraEffect(player, aspect);
|
||||
}
|
||||
}
|
||||
|
||||
private static void doBlockEffects(AuraEffect effect, World worldObj, double x, double y, double z) {
|
||||
int count = effect.getBlockCount(worldObj.rand);
|
||||
|
||||
ChunkCoordinates origin = new ChunkCoordinates((int) x, (int) y, (int) z);
|
||||
List<ChunkCoordinates> foundBlocks = new ArrayList<ChunkCoordinates>();
|
||||
int intRange = (int) effect.getRange();
|
||||
for (int i = 0; i < count; i++) {
|
||||
int xx = worldObj.rand.nextInt(intRange) - worldObj.rand.nextInt(intRange);
|
||||
int yy = worldObj.rand.nextInt(intRange) - worldObj.rand.nextInt(intRange);
|
||||
int zz = worldObj.rand.nextInt(intRange) - worldObj.rand.nextInt(intRange);
|
||||
|
||||
ChunkCoordinates blockCC = new ChunkCoordinates((int) x + xx, (int) y + yy, (int) z + zz);
|
||||
if(foundBlocks.contains(blockCC)) {
|
||||
count++;
|
||||
} else {
|
||||
foundBlocks.add(blockCC);
|
||||
effect.doBlockEffect(origin, blockCC, worldObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void doEntityEffects(AuraEffect effect, World worldObj, double x, double y, double z) {
|
||||
double range = effect.getRange();
|
||||
List entitiesInRange = worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(x - 0.5, y - 0.5, z - 0.5, x + 0.5, y + 0.5, z + 0.5).expand(range, range, range));
|
||||
Iterator it = entitiesInRange.iterator();
|
||||
while(it.hasNext()) {
|
||||
@@ -39,11 +84,9 @@ public class AuraEffectHandler {
|
||||
}
|
||||
if(!effect.isEntityApplicable(e)) it.remove();
|
||||
}
|
||||
ChunkCoordinates origin = new ChunkCoordinates((int) x, (int) y, (int) z);
|
||||
for(Object e : entitiesInRange) {
|
||||
effect.applyEffect((Entity) e);
|
||||
if(e instanceof EntityPlayer) {
|
||||
AuraResearchManager.tryUnlockAuraEffect((EntityPlayer) e, aspect);
|
||||
}
|
||||
effect.doEntityEffect(origin, (Entity) e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,22 @@
|
||||
package makeo.gadomancy.common.aura;
|
||||
|
||||
import makeo.gadomancy.api.AuraEffect;
|
||||
import makeo.gadomancy.common.events.EventHandlerEntity;
|
||||
import makeo.gadomancy.common.registration.RegisteredPotions;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityAgeable;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.effect.EntityLightningBolt;
|
||||
import net.minecraft.entity.passive.EntitySheep;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import static makeo.gadomancy.common.utils.MiscUtils.*;
|
||||
|
||||
/**
|
||||
@@ -21,6 +31,7 @@ public class AuraEffects {
|
||||
|
||||
//Potion amplifiers start with 0 == lvl 1!
|
||||
|
||||
//Std. potion effects
|
||||
public static final AuraEffect AER = new PotionDistributionEffect(Potion.moveSpeed, 4, 6, ticksForMinutes(6), 1).register(Aspect.AIR);
|
||||
public static final AuraEffect AQUA = new PotionDistributionEffect(Potion.waterBreathing, 4, 10, ticksForMinutes(10), 0).register(Aspect.WATER);
|
||||
public static final AuraEffect TERRA = new PotionDistributionEffect(Potion.resistance, 4, 8, ticksForMinutes(5), 0).register(Aspect.EARTH);
|
||||
@@ -43,7 +54,76 @@ public class AuraEffects {
|
||||
public static final AuraEffect VENENUM = new PotionDistributionEffect(Potion.poison, 2, 6, ticksForMinutes(1), 0).register(Aspect.POISON);
|
||||
public static final AuraEffect VINCULUM = new PotionDistributionEffect(Potion.moveSlowdown, 4, 6, ticksForMinutes(3), 0).register(Aspect.TRAP);
|
||||
|
||||
public static class PotionDistributionEffect extends AuraEffect {
|
||||
//Special effects..
|
||||
public static final AuraEffect LUCRUM = new PotionDistributionEffect(RegisteredPotions.POTION_LUCK, 4, 6, ticksForMinutes(5), 1).register(Aspect.GREED); //Mining luck (Adding fortune)
|
||||
public static final AuraEffect VICTUS = new AuraEffect.EntityAuraEffect() {
|
||||
@Override
|
||||
public boolean isEntityApplicable(Entity e) {
|
||||
return e != null && !e.isDead && ((e instanceof EntityAgeable && ((EntityAgeable) e).getGrowingAge() < 0) || e instanceof EntityPlayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doEntityEffect(ChunkCoordinates originTile, Entity e) {
|
||||
if(e instanceof EntityPlayer) return;
|
||||
EntityAgeable ageable = (EntityAgeable) e;
|
||||
if(ageable.worldObj.rand.nextInt(20) == 0) ageable.setGrowingAge(0); //setAdult
|
||||
}
|
||||
}.register(Aspect.LIFE);
|
||||
public static final AuraEffect PANNUS = new AuraEffect.EntityAuraEffect() {
|
||||
@Override
|
||||
public boolean isEntityApplicable(Entity e) {
|
||||
return e != null && !e.isDead && ((e instanceof EntitySheep && ((EntitySheep) e).getSheared()) || e instanceof EntityPlayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doEntityEffect(ChunkCoordinates originTile, Entity e) {
|
||||
if(e instanceof EntityPlayer) return;
|
||||
EntitySheep sheep = (EntitySheep) e;
|
||||
if(sheep.worldObj.rand.nextInt(20) == 0) sheep.setSheared(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTickInterval() {
|
||||
return 20;
|
||||
}
|
||||
}.register(Aspect.CLOTH);
|
||||
public static final AuraEffect LUX = new AuraEffect.EntityAuraEffect() {
|
||||
@Override
|
||||
public boolean isEntityApplicable(Entity e) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doEntityEffect(ChunkCoordinates originTile, Entity e) {
|
||||
if(!EventHandlerEntity.registeredLuxPylons.contains(originTile))
|
||||
EventHandlerEntity.registeredLuxPylons.add(originTile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTickInterval() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getRange() {
|
||||
return 64;
|
||||
}
|
||||
}.register(Aspect.LIGHT);
|
||||
public static final AuraEffect TEMPESTAS = new AuraEffect.BlockAuraEffect() {
|
||||
@Override
|
||||
public int getBlockCount(Random random) {
|
||||
return random.nextInt(10) == 0 ? 1 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doBlockEffect(ChunkCoordinates originTile, ChunkCoordinates selectedBlock, World world) {
|
||||
int highestY = world.getTopSolidOrLiquidBlock(selectedBlock.posX, selectedBlock.posZ);
|
||||
EntityLightningBolt entityLightning = new EntityLightningBolt(world, selectedBlock.posX + 0.5, highestY, selectedBlock.posZ + 0.5);
|
||||
world.addWeatherEffect(entityLightning);
|
||||
}
|
||||
}.register(Aspect.WEATHER);
|
||||
|
||||
public static class PotionDistributionEffect extends AuraEffect.EntityAuraEffect {
|
||||
|
||||
private Potion potion;
|
||||
private int tickInterval, addedDuration, durationCap, amplifier;
|
||||
@@ -62,7 +142,7 @@ public class AuraEffects {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyEffect(Entity e) {
|
||||
public void doEntityEffect(ChunkCoordinates originTile, Entity e) {
|
||||
if(e == null || !(e instanceof EntityLivingBase)) return;
|
||||
|
||||
EntityLivingBase living = (EntityLivingBase) e;
|
||||
|
||||
@@ -106,7 +106,7 @@ public class TileAuraPylon extends SynchronizedTileEntity implements IAspectCont
|
||||
if(aspect == null) return;
|
||||
if(!isMasterTile()) return;
|
||||
if(worldObj.isRemote) return;
|
||||
AuraEffectHandler.distributeEffects(aspect, worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, 8, ticksExisted);
|
||||
AuraEffectHandler.distributeEffects(aspect, worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, ticksExisted);
|
||||
}
|
||||
|
||||
private void drainEssentia(TileAuraPylon io) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
import thaumcraft.common.entities.EntityPermanentItem;
|
||||
|
||||
@@ -94,6 +95,12 @@ public class EntityPermNoClipItem extends EntityPermanentItem {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean attackEntityFrom(DamageSource ds, float p_70097_2_) {
|
||||
if(ds.equals(DamageSource.inFire) || ds.equals(DamageSource.onFire)) return false;
|
||||
return super.attackEntityFrom(ds, p_70097_2_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPositionAndRotation2(double p_70056_1_, double p_70056_3_, double p_70056_5_, float p_70056_7_, float p_70056_8_, int p_70056_9_) {
|
||||
this.setPosition(p_70056_1_, p_70056_3_, p_70056_5_);
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
package makeo.gadomancy.common.events;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import makeo.gadomancy.common.aura.AuraEffects;
|
||||
import makeo.gadomancy.common.blocks.tiles.TileAuraPylon;
|
||||
import makeo.gadomancy.common.blocks.tiles.TileBlockProtector;
|
||||
import makeo.gadomancy.common.data.ModConfig;
|
||||
import makeo.gadomancy.common.entities.EntityPermNoClipItem;
|
||||
import makeo.gadomancy.common.familiar.FamiliarAIController;
|
||||
import makeo.gadomancy.common.registration.RegisteredPotions;
|
||||
import makeo.gadomancy.common.utils.MiscUtils;
|
||||
import makeo.gadomancy.common.utils.Vector3;
|
||||
import makeo.gadomancy.common.utils.world.TCMazeHandler;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.boss.IBossDisplayData;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -24,9 +27,11 @@ import net.minecraftforge.event.entity.living.EnderTeleportEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingSpawnEvent;
|
||||
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
|
||||
import thaumcraft.common.items.armor.Hover;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -38,6 +43,9 @@ import java.util.List;
|
||||
* Created by HellFirePvP @ 31.10.2015 15:28
|
||||
*/
|
||||
public class EventHandlerEntity {
|
||||
|
||||
public static List<ChunkCoordinates> registeredLuxPylons = new ArrayList<ChunkCoordinates>();
|
||||
|
||||
/*@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||
public void on(EntityEvent.EntityConstructing e) {
|
||||
if (e.entity instanceof EntityPlayer) {
|
||||
@@ -45,21 +53,47 @@ public class EventHandlerEntity {
|
||||
}
|
||||
}*/
|
||||
|
||||
public static int onGetFortuneLevel(EntityLivingBase entity) {
|
||||
return getRealEnchantmentLevel(Enchantment.fortune.effectId, entity.getHeldItem()) + 1000;
|
||||
public static int getFortuneLevel(EntityLivingBase entity) {
|
||||
int fortuneLevel = getRealEnchantmentLevel(Enchantment.fortune.effectId, entity.getHeldItem());
|
||||
if(entity.isPotionActive(RegisteredPotions.POTION_LUCK)) {
|
||||
int lvl = entity.getActivePotionEffect(RegisteredPotions.POTION_LUCK).getAmplifier() + 1; //Amplifier 0-indexed
|
||||
fortuneLevel += lvl;
|
||||
}
|
||||
return fortuneLevel;
|
||||
}
|
||||
|
||||
public static int getLootingLevel(EntityLivingBase entity) {
|
||||
int lootingLevel = getRealEnchantmentLevel(Enchantment.looting.effectId, entity.getHeldItem());
|
||||
if(entity.isPotionActive(RegisteredPotions.POTION_LUCK)) {
|
||||
int lvl = entity.getActivePotionEffect(RegisteredPotions.POTION_LUCK).getAmplifier() + 1; //Amplifier 0-indexed
|
||||
lootingLevel += lvl;
|
||||
}
|
||||
return lootingLevel;
|
||||
}
|
||||
|
||||
public static int onGetEnchantmentLevel(int enchantmentId, ItemStack stack) {
|
||||
if(stack != null && Enchantment.fortune.effectId == enchantmentId) {
|
||||
EntityPlayer possiblePlayer = null;
|
||||
if(stack != null) {
|
||||
MinecraftServer server = MinecraftServer.getServer();
|
||||
if(server != null) {
|
||||
for(EntityPlayer player : (List<EntityPlayer>)server.getConfigurationManager().playerEntityList) {
|
||||
if(player.getHeldItem() == stack) {
|
||||
return onGetFortuneLevel(player);
|
||||
possiblePlayer = player;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(possiblePlayer != null) {
|
||||
|
||||
if(enchantmentId == Enchantment.fortune.effectId) {
|
||||
return getFortuneLevel(possiblePlayer);
|
||||
} else if(enchantmentId == Enchantment.looting.effectId) {
|
||||
return getLootingLevel(possiblePlayer);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return getRealEnchantmentLevel(enchantmentId, stack);
|
||||
}
|
||||
|
||||
@@ -82,6 +116,19 @@ public class EventHandlerEntity {
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void on(LivingSpawnEvent.CheckSpawn event) {
|
||||
double rangeSq = AuraEffects.LUX.getRange() * AuraEffects.LUX.getRange();
|
||||
Vector3 entityPos = MiscUtils.getPositionVector(event.entity);
|
||||
for(ChunkCoordinates luxPylons : registeredLuxPylons) {
|
||||
Vector3 pylon = Vector3.fromCC(luxPylons);
|
||||
if(entityPos.distanceSquared(pylon) <= rangeSq) {
|
||||
event.setCanceled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void on(EnderTeleportEvent e) {
|
||||
if (!(e.entityLiving instanceof EntityPlayer) && !(e.entityLiving instanceof IBossDisplayData)) {
|
||||
|
||||
@@ -47,6 +47,8 @@ import java.util.Map;
|
||||
* Created by makeo @ 05.07.2015 13:20
|
||||
*/
|
||||
public class EventHandlerWorld {
|
||||
|
||||
private int serverTick = 0;
|
||||
private Entity lastUpdated;
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||
@@ -98,6 +100,10 @@ public class EventHandlerWorld {
|
||||
if(event.phase != TickEvent.Phase.END) return;
|
||||
|
||||
TCMazeHandler.scheduleTick();
|
||||
serverTick++;
|
||||
if((serverTick & 15) == 0) {
|
||||
EventHandlerEntity.registeredLuxPylons.clear();
|
||||
}
|
||||
}
|
||||
|
||||
private Map<EntityPlayer, Integer> interacts = null;
|
||||
|
||||
@@ -13,8 +13,8 @@ import thaumcraft.api.aspects.Aspect;
|
||||
public class PotionMiningLuck extends PotionCustomTexture {
|
||||
|
||||
public PotionMiningLuck(int id) {
|
||||
super(id, false, Aspect.MINE.getColor(), Aspect.MINE.getImage());
|
||||
setPotionName("potion.miningluck");
|
||||
super(id, false, Aspect.GREED.getColor(), Aspect.GREED.getImage());
|
||||
setPotionName("potion.luck");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,10 +14,10 @@ import net.minecraft.potion.Potion;
|
||||
*/
|
||||
public class RegisteredPotions {
|
||||
|
||||
public static PotionMiningLuck POTION_MINING_LUCK;
|
||||
public static PotionMiningLuck POTION_LUCK;
|
||||
|
||||
public static void init() {
|
||||
POTION_MINING_LUCK = registerPotion(PotionMiningLuck.class);
|
||||
POTION_LUCK = registerPotion(PotionMiningLuck.class);
|
||||
}
|
||||
|
||||
private static <T extends Potion> T registerPotion(Class<T> potionClass) {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package makeo.gadomancy.common.utils;
|
||||
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
|
||||
import java.util.Formatter;
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
@@ -226,6 +228,18 @@ public class Vector3 {
|
||||
return random().setY(Math.abs(random().getY()));
|
||||
}
|
||||
|
||||
public static Vector3 fromCC(ChunkCoordinates cc) {
|
||||
return new Vector3(cc.posX, cc.posY, cc.posZ);
|
||||
}
|
||||
|
||||
public ChunkCoordinates getAsFloatCC() {
|
||||
return new ChunkCoordinates(Float.floatToIntBits((float) this.x), Float.floatToIntBits((float) this.y), Float.floatToIntBits((float) this.z));
|
||||
}
|
||||
|
||||
public static Vector3 getFromFloatCC(ChunkCoordinates cc) {
|
||||
return new Vector3(Float.intBitsToFloat(cc.posX), Float.intBitsToFloat(cc.posY), Float.intBitsToFloat(cc.posZ));
|
||||
}
|
||||
|
||||
public boolean isInAABB(Vector3 min, Vector3 max) {
|
||||
return (this.x >= min.x) && (this.x <= max.x) && (this.y >= min.y) && (this.y <= max.y) && (this.z >= min.z) && (this.z <= max.z);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class GadomancyTransformer extends AccessTransformer {
|
||||
|
||||
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
|
||||
mn.instructions.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "makeo/gadomancy/common/events/EventHandlerEntity",
|
||||
"onGetFortuneLevel", "(Lnet/minecraft/entity/EntityLivingBase;)I", false));
|
||||
"getFortuneLevel", "(Lnet/minecraft/entity/EntityLivingBase;)I", false));
|
||||
mn.instructions.add(new InsnNode(Opcodes.IRETURN));
|
||||
|
||||
} else if(mn.name.equals("getEnchantmentLevel") || mn.name.equals("func_77506_a")) {
|
||||
|
||||
Reference in new issue
Block a user