Added the Warp Lens.

This commit is contained in:
Lizbeth Rika committed 2015-02-08 16:23:08 +00:00
1 parent b718a13561
commit c620405bf6
10 files changed
+79 -8

No files matched your search

@@ -56,6 +56,8 @@ public interface IManaBurst {
public boolean hasAlreadyCollidedAt(int x, int y, int z);
public void setCollidedAt(int x, int y, int z);
public int getTicksExisted();
}
@@ -1,4 +1,4 @@
@API(owner = "Botania", apiVersion = "30", provides = "BotaniaAPI")
@API(owner = "Botania", apiVersion = "31", provides = "BotaniaAPI")
package vazkii.botania.api;
import cpw.mods.fml.common.API;
@@ -756,6 +756,12 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst {
return alreadyCollidedAt.contains(getCollisionLocString(x, y, z));
}
@Override
public void setCollidedAt(int x, int y, int z) {
if(!hasAlreadyCollidedAt(x, y, z))
alreadyCollidedAt.add(getCollisionLocString(x, y, z));
}
private String getCollisionLocString(int x, int y, int z) {
return x + ":" + y + ":" + z;
}
@@ -40,9 +40,9 @@ import cpw.mods.fml.common.registry.GameRegistry;
public class ItemLens extends ItemMod implements ILens {
public static final int SUBTYPES = 18;
public static final int SUBTYPES = 19;
private static final int NORMAL = 0,
public static final int NORMAL = 0,
SPEED = 1,
POWER = 2,
TIME = 3,
@@ -59,7 +59,8 @@ public class ItemLens extends ItemMod implements ILens {
PAINT = 14,
FIRE = 15,
PISTON = 16,
LIGHT = 17;
LIGHT = 17,
WARP = 18;
private static final int PROP_NONE = 0,
PROP_POWER = 1,
@@ -91,6 +92,7 @@ public class ItemLens extends ItemMod implements ILens {
setProps(FIRE, PROP_DAMAGE | PROP_TOUCH | PROP_INTERACTION);
setProps(PISTON, PROP_TOUCH | PROP_INTERACTION);
setProps(LIGHT, PROP_TOUCH | PROP_INTERACTION);
setProps(WARP, PROP_NONE);
setLens(NORMAL, fallbackLens);
setLens(SPEED, new LensSpeed());
@@ -110,6 +112,7 @@ public class ItemLens extends ItemMod implements ILens {
setLens(FIRE, new LensFire());
setLens(PISTON, new LensPiston());
setLens(LIGHT, new LensLight());
setLens(WARP, new LensWarp());
}
private static final String TAG_COLOR = "color";
@@ -17,7 +17,7 @@ import vazkii.botania.api.internal.IManaBurst;
import vazkii.botania.api.mana.BurstProperties;
public class Lens {
public void apply(ItemStack stack, BurstProperties props) {
// NO-OP
}
@@ -29,5 +29,5 @@ public class Lens {
public void updateBurst(IManaBurst burst, EntityThrowable entity, ItemStack stack) {
// NO-OP
}
}
@@ -16,6 +16,7 @@ import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChunkCoordinates;
@@ -23,7 +24,9 @@ import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import vazkii.botania.api.internal.IManaBurst;
import vazkii.botania.api.mana.IManaBlock;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.core.handler.ConfigHandler;
import vazkii.botania.common.item.ModItems;
public class LensMine extends Lens {
@@ -34,6 +37,13 @@ public class LensMine extends Lens {
int y = pos.blockY;
int z = pos.blockZ;
Block block = world.getBlock(x, y, z);
ItemStack composite = ((ItemLens) ModItems.lens).getCompositeLens(stack);
boolean warp = composite != null && composite.getItem() == ModItems.lens && composite.getItemDamage() == ItemLens.WARP;
if(warp && (block == ModBlocks.pistonRelay || block == Blocks.piston || block == Blocks.piston_extension || block == Blocks.piston_head))
return false;
TileEntity tile = world.getTileEntity(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
@@ -52,8 +62,13 @@ public class LensMine extends Lens {
if(ConfigHandler.blockBreakParticles)
entity.worldObj.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12));
int dropX = warp ? coords.posX : x;
int dropY = warp ? coords.posY : y;
int dropZ = warp ? coords.posZ : z;
for(ItemStack stack_ : items)
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, stack_));
world.spawnEntityInWorld(new EntityItem(world, dropX + 0.5, dropY + 0.5, dropZ + 0.5, stack_));
burst.setMana(mana - 24);
}
}
@@ -0,0 +1,42 @@
/**
* 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 @ [Feb 8, 2015, 2:17:01 PM (GMT)]
*/
package vazkii.botania.common.item.lens;
import net.minecraft.block.Block;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import vazkii.botania.api.internal.IManaBurst;
import vazkii.botania.common.block.BlockPistonRelay;
import vazkii.botania.common.block.ModBlocks;
public class LensWarp extends Lens {
@Override
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) {
if(burst.isFake())
return dead;
Block block = entity.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ);
if(block == ModBlocks.pistonRelay) {
String key = BlockPistonRelay.mappedPositions.get(BlockPistonRelay.getCoordsAsString(entity.worldObj.provider.dimensionId, pos.blockX, pos.blockY, pos.blockZ));
String[] tokens = key.split(":");
int worldId = Integer.parseInt(tokens[0]), x = Integer.parseInt(tokens[1]), y = Integer.parseInt(tokens[2]), z = Integer.parseInt(tokens[3]);
if(worldId == entity.worldObj.provider.dimensionId) {
entity.setPosition(x + 0.5, y + 0.5, z + 0.5);
burst.setCollidedAt(x, y, z);
return false;
}
}
return dead;
}
}
@@ -139,7 +139,8 @@ public final class LibItemNames {
"lensPaint",
"lensFire",
"lensPiston",
"lensLight"
"lensLight",
"lensWarp"
};
public static final String[] MANA_RESOURCE_NAMES = new String[] {