mirror of
https://github.com/GTNewHorizons/Tainted-Magic.git
synced 2026-11-18 03:15:26 +00:00
Lumos changes - closes #74
This commit is contained in:
1 parent
fbe4b73a49
commit
13bfced90b
3 files changed
+35
-75
No files matched your search
@@ -26,6 +26,7 @@ public class BlockLumos extends Block implements ITileEntityProvider {
|
||||
setTickRandomly(false);
|
||||
setLightLevel(1.0F);
|
||||
setBlockTextureName("thaumcraft:blank");
|
||||
setBlockBounds(0.3F, 0.3F, 0.3F, 0.7F, 0.7F, 0.7F);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -52,17 +53,6 @@ public class BlockLumos extends Block implements ITileEntityProvider {
|
||||
ParticleEngine.instance.addEffect(world, fx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState (final IBlockAccess world, final int x, final int y, final int z) {
|
||||
final int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta == 0) {
|
||||
setBlockBounds(0.3F, 0.3F, 0.3F, 0.7F, 0.7F, 0.7F);
|
||||
}
|
||||
else {
|
||||
setBlockBounds(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool (final World world, final int x, final int y, final int z) {
|
||||
return null;
|
||||
|
||||
@@ -17,9 +17,6 @@ import thaumcraft.common.items.wands.ItemWandCasting;
|
||||
|
||||
public class TileLumos extends TileEntity {
|
||||
|
||||
public TileLumos () {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate () {
|
||||
return true;
|
||||
@@ -27,57 +24,15 @@ public class TileLumos extends TileEntity {
|
||||
|
||||
@Override
|
||||
public void updateEntity () {
|
||||
final Block block = worldObj.getBlock(xCoord, yCoord, zCoord);
|
||||
final int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
|
||||
|
||||
if (block instanceof BlockLumos) {
|
||||
final EntityPlayer player = worldObj.getClosestPlayer(xCoord, yCoord, zCoord, 4);
|
||||
|
||||
if (meta == 0 && worldObj.rand.nextInt(15) == 0 && worldObj.isRemote) {
|
||||
if (this.getBlockType() instanceof BlockLumos) {
|
||||
if (worldObj.rand.nextInt(15) == 0 && worldObj.isRemote) {
|
||||
spawnParticles();
|
||||
}
|
||||
if ( (meta == 1 || meta == 2) && player == null) {
|
||||
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
|
||||
}
|
||||
else if (meta == 1 && player != null) {
|
||||
if (player.getHeldItem() == null
|
||||
|| player.getHeldItem() != null && ! (player.getHeldItem().getItem() instanceof ItemWandCasting)) {
|
||||
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
|
||||
}
|
||||
else if (player.getHeldItem() != null && player.getHeldItem().getItem() instanceof ItemWandCasting) {
|
||||
final ItemStack stack = player.getHeldItem();
|
||||
final ItemWandCasting wand = (ItemWandCasting) stack.getItem();
|
||||
|
||||
if (wand.getFocus(stack) == null
|
||||
|| wand.getFocus(stack) != null && wand.getFocus(stack) != ItemRegistry.ItemFocusLumos) {
|
||||
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (meta == 2 && player != null) {
|
||||
final IInventory baub = BaublesApi.getBaubles(player);
|
||||
if (baub.getStackInSlot(1) == null && baub.getStackInSlot(2) == null) {
|
||||
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
|
||||
}
|
||||
else if (baub.getStackInSlot(1) != null && baub.getStackInSlot(2) == null
|
||||
&& ! (baub.getStackInSlot(1).getItem() instanceof ItemLumosRing)) {
|
||||
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
|
||||
}
|
||||
else if (baub.getStackInSlot(1) == null && baub.getStackInSlot(2) != null
|
||||
&& ! (baub.getStackInSlot(2).getItem() instanceof ItemLumosRing)) {
|
||||
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
|
||||
}
|
||||
else if (baub.getStackInSlot(1) != null && baub.getStackInSlot(2) != null
|
||||
&& ! (baub.getStackInSlot(1).getItem() instanceof ItemLumosRing)
|
||||
&& ! (baub.getStackInSlot(2).getItem() instanceof ItemLumosRing)) {
|
||||
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly (Side.CLIENT)
|
||||
void spawnParticles () {
|
||||
private void spawnParticles () {
|
||||
final FXSparkle fx = new FXSparkle(worldObj, xCoord + 0.5D + worldObj.rand.nextGaussian() * 0.1D,
|
||||
yCoord + 0.5D + worldObj.rand.nextGaussian() * 0.1D, zCoord + 0.5D + worldObj.rand.nextGaussian() * 0.1D, 1.75F,
|
||||
6, 3 + worldObj.rand.nextInt(2));
|
||||
|
||||
@@ -25,7 +25,6 @@ import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||
import taintedmagic.common.items.equipment.ItemLumosRing;
|
||||
import taintedmagic.common.items.tools.ItemHollowDagger;
|
||||
import taintedmagic.common.items.wand.foci.ItemFocusMageMace;
|
||||
import taintedmagic.common.registry.BlockRegistry;
|
||||
import taintedmagic.common.registry.ItemRegistry;
|
||||
import thaumcraft.api.ThaumcraftApiHelper;
|
||||
import thaumcraft.api.wands.ItemFocusBasic;
|
||||
@@ -46,7 +45,7 @@ public class TMEventHandler {
|
||||
final EntityPlayer player = (EntityPlayer) event.entity;
|
||||
|
||||
repairItems(player);
|
||||
createLumos(player);
|
||||
applyNightVision(player);
|
||||
modifyAttackDamage(player);
|
||||
}
|
||||
}
|
||||
@@ -65,30 +64,46 @@ public class TMEventHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasNightVision = false;
|
||||
|
||||
/**
|
||||
* Create Lumos lightsource blocks when the player is holding a wand or staff
|
||||
* Apply Night Vision effect when the player is holding a wand or staff
|
||||
* with the Lumos focus equipped or when the Lumos ring is equipped.
|
||||
*/
|
||||
public void createLumos (final EntityPlayer player) {
|
||||
final int x = (int) Math.floor(player.posX);
|
||||
final int y = (int) Math.floor(player.posY) + 1;
|
||||
final int z = (int) Math.floor(player.posZ);
|
||||
public void applyNightVision (final EntityPlayer player) {
|
||||
if (player.worldObj.isRemote)
|
||||
return;
|
||||
|
||||
if (player.getHeldItem() != null && player.getHeldItem().getItem() instanceof ItemWandCasting) {
|
||||
boolean lumos = false;
|
||||
|
||||
final IInventory baub = BaublesApi.getBaubles(player);
|
||||
if ( (baub.getStackInSlot(1) != null && baub.getStackInSlot(1).getItem() instanceof ItemLumosRing)
|
||||
|| (baub.getStackInSlot(2) != null && baub.getStackInSlot(2).getItem() instanceof ItemLumosRing)) {
|
||||
lumos = true;
|
||||
}
|
||||
else if (player.getHeldItem() != null && player.getHeldItem().getItem() instanceof ItemWandCasting) {
|
||||
final ItemStack held = player.getHeldItem();
|
||||
final ItemWandCasting wand = (ItemWandCasting) held.getItem();
|
||||
|
||||
if (wand.getFocus(held) != null && wand.getFocus(held) == ItemRegistry.ItemFocusLumos && !player.worldObj.isRemote
|
||||
&& player.worldObj.isAirBlock(x, y, z)) {
|
||||
player.worldObj.setBlock(x, y, z, BlockRegistry.BlockLumos, 1, 3);
|
||||
if (wand.getFocus(held) != null && wand.getFocus(held) == ItemRegistry.ItemFocusLumos) {
|
||||
lumos = true;
|
||||
}
|
||||
}
|
||||
|
||||
final IInventory baub = BaublesApi.getBaubles(player);
|
||||
if (baub.getStackInSlot(1) != null && baub.getStackInSlot(1).getItem() instanceof ItemLumosRing
|
||||
|| baub.getStackInSlot(2) != null && baub.getStackInSlot(2).getItem() instanceof ItemLumosRing
|
||||
&& !player.worldObj.isRemote && player.worldObj.isAirBlock(x, y, z)) {
|
||||
player.worldObj.setBlock(x, y, z, BlockRegistry.BlockLumos, 2, 3);
|
||||
if (lumos) {
|
||||
if (!hasNightVision) {
|
||||
if (!player.isPotionActive(Potion.nightVision.id)) {
|
||||
player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 260, -1));
|
||||
hasNightVision = true;
|
||||
}
|
||||
}
|
||||
else if (player.ticksExisted % 20 == 0) {
|
||||
player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 260, -1));
|
||||
}
|
||||
}
|
||||
else if (hasNightVision) {
|
||||
player.removePotionEffect(Potion.nightVision.id);
|
||||
hasNightVision = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user