Tripwire lens

This commit is contained in:
Vasco Lavos committed 2016-10-02 19:27:51 +01:00
1 parent b55f66af8c
commit d84952089f
7 files changed
+86 -3

No files matched your search

@@ -10,6 +10,11 @@
*/
package vazkii.botania.api.mana;
import org.apache.commons.lang3.tuple.Pair;
import net.minecraft.util.math.BlockPos;
import vazkii.botania.api.internal.IManaBurst;
import vazkii.botania.common.entity.EntityManaBurst;
/**
* Any TileEntity that implements this is considered a Mana Spreader,
@@ -26,5 +31,7 @@ public interface IManaSpreader extends IManaBlock, IPingable, IDirectioned {
public int getLastBurstDeathTick();
public void setLastBurstDeathTick(int ticksExisted);
public IManaBurst runBurstSimulation();
}
@@ -484,6 +484,14 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
else this.receiver = null;
lastTentativeBurst = fakeBurst.propsList;
}
@Override
public IManaBurst runBurstSimulation() {
EntityManaBurst fakeBurst = getBurst(true);
fakeBurst.setScanBeam();
fakeBurst.getCollidedTile(true);
return fakeBurst;
}
public EntityManaBurst getBurst(boolean fake) {
EntityManaBurst burst = new EntityManaBurst(this, fake);
@@ -45,7 +45,7 @@ import java.util.List;
public class ItemLens extends ItemMod implements ILensControl, ICompositableLens, ITinyPlanetExcempt {
public static final int SUBTYPES = 23;
public static final int SUBTYPES = 24;
public static final int NORMAL = 0,
SPEED = 1,
@@ -69,7 +69,8 @@ public class ItemLens extends ItemMod implements ILensControl, ICompositableLens
REDIRECT = 19,
FIREWORK = 20,
FLARE = 21,
MESSENGER = 22;
MESSENGER = 22,
TRIPWIRE = 23;
public static final int STORM = 5000;
@@ -110,6 +111,7 @@ public class ItemLens extends ItemMod implements ILensControl, ICompositableLens
setProps(FIREWORK, PROP_TOUCH);
setProps(FLARE, PROP_CONTROL);
setProps(MESSENGER, PROP_POWER);
setProps(TRIPWIRE, PROP_CONTROL);
setLens(NORMAL, fallbackLens);
setLens(SPEED, new LensSpeed());
@@ -134,6 +136,7 @@ public class ItemLens extends ItemMod implements ILensControl, ICompositableLens
setLens(FIREWORK, new LensFirework());
setLens(FLARE, new LensFlare());
setLens(MESSENGER, new LensMessenger());
setLens(TRIPWIRE, new LensTripwire());
}
private static final String TAG_COLOR = "color";
@@ -0,0 +1,55 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [02/10/2016, 18:27:42 (GMT)]
*/
package vazkii.botania.common.item.lens;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.RayTraceResult;
import vazkii.botania.api.internal.IManaBurst;
import vazkii.botania.api.mana.BurstProperties;
import vazkii.botania.api.mana.IManaSpreader;
import vazkii.botania.common.core.helper.ItemNBTHelper;
public class LensTripwire extends Lens {
private static final String TAG_TRIPPED = "botania:triwireLensTripped";
@Override
public boolean allowBurstShooting(ItemStack stack, IManaSpreader spreader, boolean redstone) {
IManaBurst burst = spreader.runBurstSimulation();
Entity e = (Entity) burst;
return e.getEntityData().getBoolean(TAG_TRIPPED);
}
@Override
public void updateBurst(IManaBurst burst, EntityThrowable entity, ItemStack stack) {
if(burst.isFake()) {
if(entity.worldObj.isRemote)
return;
AxisAlignedBB axis = new AxisAlignedBB(entity.posX, entity.posY, entity.posZ, entity.lastTickPosX, entity.lastTickPosY, entity.lastTickPosZ).expand(0.25, 0.25, 0.25);
List<EntityLivingBase> entities = entity.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axis);
if(!entities.isEmpty()) {
Entity e = (Entity) burst;
e.getEntityData().setBoolean(TAG_TRIPPED, true);
}
}
}
}
@@ -184,7 +184,8 @@ public final class LibItemNames {
"lensRedirect",
"lensFirework",
"lensFlare",
"lensMessenger"
"lensMessenger",
"lensTripwire"
};
public static final String[] MANA_RESOURCE_NAMES = new String[] {