Run formatter
This commit is contained in:
parent
61c44a831b
commit
08258fd6ef
606 changed files with 13464 additions and 22975 deletions
|
@ -1,10 +1,9 @@
|
|||
package WayofTime.bloodmagic.ritual;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.BlockStack;
|
||||
import WayofTime.bloodmagic.api.ritual.*;
|
||||
import WayofTime.bloodmagic.util.Utils;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockOre;
|
||||
import net.minecraft.block.BlockRedstoneOre;
|
||||
|
@ -16,81 +15,29 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import WayofTime.bloodmagic.api.BlockStack;
|
||||
import WayofTime.bloodmagic.api.ritual.AreaDescriptor;
|
||||
import WayofTime.bloodmagic.api.ritual.EnumRuneType;
|
||||
import WayofTime.bloodmagic.api.ritual.IMasterRitualStone;
|
||||
import WayofTime.bloodmagic.api.ritual.Ritual;
|
||||
import WayofTime.bloodmagic.api.ritual.RitualComponent;
|
||||
import WayofTime.bloodmagic.util.Utils;
|
||||
|
||||
public class RitualMagnetic extends Ritual
|
||||
{
|
||||
private static final Map<BlockStack, Boolean> oreBlockCache = new HashMap<BlockStack, Boolean>();
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class RitualMagnetic extends Ritual {
|
||||
public static final String PLACEMENT_RANGE = "placementRange";
|
||||
private static final Map<BlockStack, Boolean> oreBlockCache = new HashMap<BlockStack, Boolean>();
|
||||
// public static final String SEARCH_RANGE = "searchRange";
|
||||
|
||||
public BlockPos lastPos; // An offset
|
||||
|
||||
public RitualMagnetic()
|
||||
{
|
||||
public RitualMagnetic() {
|
||||
super("ritualMagnetic", 0, 5000, "ritual." + BloodMagic.MODID + ".magneticRitual");
|
||||
addBlockRange(PLACEMENT_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-1, 1, -1), 3));
|
||||
setMaximumVolumeAndDistanceOfRange(PLACEMENT_RANGE, 50, 4, 4);
|
||||
}
|
||||
|
||||
public static boolean isBlockOre(Block block, int meta)
|
||||
{
|
||||
if (block == null)
|
||||
return false;
|
||||
|
||||
if (block instanceof BlockOre || block instanceof BlockRedstoneOre)
|
||||
return true;
|
||||
|
||||
if (Item.getItemFromBlock(block) == Items.AIR)
|
||||
return false;
|
||||
|
||||
BlockStack type = new BlockStack(block, meta);
|
||||
Boolean result = oreBlockCache.get(type);
|
||||
if (result == null)
|
||||
{
|
||||
result = computeIsItemOre(type);
|
||||
oreBlockCache.put(type, result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static boolean computeIsItemOre(BlockStack type)
|
||||
{
|
||||
ItemStack stack = new ItemStack(type.getBlock(), type.getMeta());
|
||||
return isBlockOre(stack);
|
||||
}
|
||||
|
||||
public static boolean isBlockOre(ItemStack stack)
|
||||
{
|
||||
if (stack.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int id : OreDictionary.getOreIDs(stack))
|
||||
{
|
||||
String oreName = OreDictionary.getOreName(id);
|
||||
if (oreName.contains("ore"))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performRitual(IMasterRitualStone masterRitualStone)
|
||||
{
|
||||
public void performRitual(IMasterRitualStone masterRitualStone) {
|
||||
World world = masterRitualStone.getWorldObj();
|
||||
int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence();
|
||||
|
||||
if (currentEssence < getRefreshCost())
|
||||
{
|
||||
if (currentEssence < getRefreshCost()) {
|
||||
masterRitualStone.getOwnerNetwork().causeNausea();
|
||||
return;
|
||||
}
|
||||
|
@ -102,10 +49,8 @@ public class RitualMagnetic extends Ritual
|
|||
BlockPos replacement = pos;
|
||||
boolean replace = false;
|
||||
|
||||
for (BlockPos offset : placementRange.getContainedPositions(pos))
|
||||
{
|
||||
if (world.isAirBlock(offset))
|
||||
{
|
||||
for (BlockPos offset : placementRange.getContainedPositions(pos)) {
|
||||
if (world.isAirBlock(offset)) {
|
||||
replacement = offset;
|
||||
replace = true;
|
||||
break;
|
||||
|
@ -117,40 +62,33 @@ public class RitualMagnetic extends Ritual
|
|||
|
||||
int radius = getRadius(downBlock);
|
||||
|
||||
if (replace)
|
||||
{
|
||||
if (replace) {
|
||||
int j = -1;
|
||||
int i = -radius;
|
||||
int k = -radius;
|
||||
|
||||
if (lastPos != null)
|
||||
{
|
||||
if (lastPos != null) {
|
||||
j = lastPos.getY();
|
||||
i = Math.min(radius, Math.max(-radius, lastPos.getX()));
|
||||
k = Math.min(radius, Math.max(-radius, lastPos.getZ()));
|
||||
}
|
||||
|
||||
while (j + pos.getY() >= 0)
|
||||
{
|
||||
while (i <= radius)
|
||||
{
|
||||
while (k <= radius)
|
||||
{
|
||||
while (j + pos.getY() >= 0) {
|
||||
while (i <= radius) {
|
||||
while (k <= radius) {
|
||||
BlockPos newPos = pos.add(i, j, k);
|
||||
IBlockState state = world.getBlockState(newPos);
|
||||
Block block = state.getBlock();
|
||||
ItemStack checkStack = block.getItem(world, newPos, state);
|
||||
// int meta = block.getMetaFromState(state);
|
||||
|
||||
if (isBlockOre(checkStack))
|
||||
{
|
||||
if (isBlockOre(checkStack)) {
|
||||
Utils.swapLocations(world, newPos, world, replacement);
|
||||
masterRitualStone.getOwnerNetwork().syphon(getRefreshCost());
|
||||
k++;
|
||||
this.lastPos = new BlockPos(i, j, k);
|
||||
return;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
k++;
|
||||
}
|
||||
}
|
||||
|
@ -170,20 +108,16 @@ public class RitualMagnetic extends Ritual
|
|||
|
||||
}
|
||||
|
||||
public int getRadius(Block block)
|
||||
{
|
||||
if (block == Blocks.IRON_BLOCK)
|
||||
{
|
||||
public int getRadius(Block block) {
|
||||
if (block == Blocks.IRON_BLOCK) {
|
||||
return 7;
|
||||
}
|
||||
|
||||
if (block == Blocks.GOLD_BLOCK)
|
||||
{
|
||||
if (block == Blocks.GOLD_BLOCK) {
|
||||
return 15;
|
||||
}
|
||||
|
||||
if (block == Blocks.DIAMOND_BLOCK)
|
||||
{
|
||||
if (block == Blocks.DIAMOND_BLOCK) {
|
||||
return 31;
|
||||
}
|
||||
|
||||
|
@ -191,20 +125,17 @@ public class RitualMagnetic extends Ritual
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getRefreshTime()
|
||||
{
|
||||
public int getRefreshTime() {
|
||||
return 40;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRefreshCost()
|
||||
{
|
||||
public int getRefreshCost() {
|
||||
return 50;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<RitualComponent> getComponents()
|
||||
{
|
||||
public ArrayList<RitualComponent> getComponents() {
|
||||
ArrayList<RitualComponent> components = new ArrayList<RitualComponent>();
|
||||
|
||||
this.addCornerRunes(components, 1, 0, EnumRuneType.EARTH);
|
||||
|
@ -216,8 +147,44 @@ public class RitualMagnetic extends Ritual
|
|||
}
|
||||
|
||||
@Override
|
||||
public Ritual getNewCopy()
|
||||
{
|
||||
public Ritual getNewCopy() {
|
||||
return new RitualMagnetic();
|
||||
}
|
||||
|
||||
public static boolean isBlockOre(Block block, int meta) {
|
||||
if (block == null)
|
||||
return false;
|
||||
|
||||
if (block instanceof BlockOre || block instanceof BlockRedstoneOre)
|
||||
return true;
|
||||
|
||||
if (Item.getItemFromBlock(block) == Items.AIR)
|
||||
return false;
|
||||
|
||||
BlockStack type = new BlockStack(block, meta);
|
||||
Boolean result = oreBlockCache.get(type);
|
||||
if (result == null) {
|
||||
result = computeIsItemOre(type);
|
||||
oreBlockCache.put(type, result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static boolean computeIsItemOre(BlockStack type) {
|
||||
ItemStack stack = new ItemStack(type.getBlock(), type.getMeta());
|
||||
return isBlockOre(stack);
|
||||
}
|
||||
|
||||
public static boolean isBlockOre(ItemStack stack) {
|
||||
if (stack.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int id : OreDictionary.getOreIDs(stack)) {
|
||||
String oreName = OreDictionary.getOreName(id);
|
||||
if (oreName.contains("ore"))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue