Merge pull request #348 from ljfa-ag/magnetism
Change ore block detection for Ritual of Magnetism
This commit is contained in:
commit
6ef59dcb27
1 changed files with 41 additions and 33 deletions
|
@ -4,6 +4,8 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockOre;
|
||||||
|
import net.minecraft.block.BlockRedstoneOre;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
@ -22,6 +24,24 @@ public class RitualEffectMagnetic extends RitualEffect
|
||||||
private static final int terraeDrain = 10;
|
private static final int terraeDrain = 10;
|
||||||
private static final int orbisTerraeDrain = 10;
|
private static final int orbisTerraeDrain = 10;
|
||||||
|
|
||||||
|
public static boolean isBlockOre(Block block, int meta)
|
||||||
|
{
|
||||||
|
if (block == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (block instanceof BlockOre || block instanceof BlockRedstoneOre)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
ItemStack itemStack = new ItemStack(block, 1, meta);
|
||||||
|
for (int id : OreDictionary.getOreIDs(itemStack))
|
||||||
|
{
|
||||||
|
String oreName = OreDictionary.getOreName(id);
|
||||||
|
if (oreName.contains("ore"))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void performEffect(IMasterRitualStone ritualStone)
|
public void performEffect(IMasterRitualStone ritualStone)
|
||||||
{
|
{
|
||||||
|
@ -67,6 +87,7 @@ public class RitualEffectMagnetic extends RitualEffect
|
||||||
yRep = y + j;
|
yRep = y + j;
|
||||||
zRep = z + k;
|
zRep = z + k;
|
||||||
replace = true;
|
replace = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,19 +117,7 @@ public class RitualEffectMagnetic extends RitualEffect
|
||||||
Block block = world.getBlock(x + i, j, z + k);
|
Block block = world.getBlock(x + i, j, z + k);
|
||||||
int meta = world.getBlockMetadata(x + i, j, z + k);
|
int meta = world.getBlockMetadata(x + i, j, z + k);
|
||||||
|
|
||||||
if (block == null)
|
if (isBlockOre(block, meta))
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack itemStack = new ItemStack(block, 1, meta);
|
|
||||||
int id = OreDictionary.getOreID(itemStack);
|
|
||||||
|
|
||||||
if (id != -1)
|
|
||||||
{
|
|
||||||
String oreName = OreDictionary.getOreName(id);
|
|
||||||
|
|
||||||
if (oreName.contains("ore"))
|
|
||||||
{
|
{
|
||||||
//Allow swapping code. This means the searched block is an ore.
|
//Allow swapping code. This means the searched block is an ore.
|
||||||
BlockTeleposer.swapBlocks(this, world, world, x + i, j, z + k, xRep, yRep, zRep);
|
BlockTeleposer.swapBlocks(this, world, world, x + i, j, z + k, xRep, yRep, zRep);
|
||||||
|
@ -133,7 +142,6 @@ public class RitualEffectMagnetic extends RitualEffect
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
k = -radius;
|
k = -radius;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue