Skip to content
This repository has been archived by the owner on May 13, 2023. It is now read-only.

Commit

Permalink
Huge commit for the Pull-Request.
Browse files Browse the repository at this point in the history
Added a lot of things:
- Blood Tank
- Teleposition Sigil
- Transposition Sigil
- Cobblestone/Netherrack/Obisidian generation Ritual
- Tree Cutter Ritual
- Pump Ritual
- Altar Builder Ritual
- Block Placing Ritual
- Portal Ritual
- Teleportation System and API Components
- Cross pattern Area Descriptor
- Two reagents and their textures for the sigils’ crafting

Fixed:
- Teleposer not teleporting entities correctly

And probably other things I forgot!
  • Loading branch information
Tombenpotter committed Feb 18, 2016
1 parent d947f23 commit 7e8aec8
Show file tree
Hide file tree
Showing 53 changed files with 3,034 additions and 375 deletions.
Empty file modified gradlew
100644 → 100755
Empty file.
66 changes: 40 additions & 26 deletions src/main/java/WayofTime/bloodmagic/ConfigHandler.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
package WayofTime.bloodmagic;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import WayofTime.bloodmagic.api.BlockStack;
import WayofTime.bloodmagic.api.BloodMagicAPI;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.util.Utils;
import lombok.Getter;
import net.minecraft.block.Block;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.oredict.OreDictionary;
import WayofTime.bloodmagic.api.BlockStack;
import WayofTime.bloodmagic.api.BloodMagicAPI;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.util.Utils;

import java.io.File;
import java.util.*;

public class ConfigHandler
{
Expand All @@ -26,6 +22,10 @@ public class ConfigHandler
public static String[] teleposerBlacklisting;
public static ArrayList<BlockStack> teleposerBlacklist = new ArrayList<BlockStack>();

// Transposition Sigil
public static String[] transpositionBlacklisting;
public static ArrayList<BlockStack> transpositionBlacklist = new ArrayList<BlockStack>();

// Item/Block Disabling
public static List<String> itemBlacklist;
public static List<String> blockBlacklist;
Expand Down Expand Up @@ -59,6 +59,13 @@ public class ConfigHandler
public static boolean ritualUpgradeRemove;
public static boolean ritualArmourEvolve;

public static boolean cobblestoneRitual;
public static boolean placerRitual;
public static boolean fellingRitual;
public static boolean pumpRitual;
public static boolean altarBuilderRitual;
public static boolean portalRitual;

// Imperfect Rituals
public static boolean imperfectRitualNight;
public static boolean imperfectRitualRain;
Expand Down Expand Up @@ -140,21 +147,26 @@ public static void syncConfig()
category = "Item/Block Blacklisting";
config.addCustomCategoryComment(category, "Allows disabling of specific Blocks/Items.\nNote that using this may result in crashes. Use is not supported.");
config.setCategoryRequiresMcRestart(category, true);
itemBlacklist = Arrays.asList(config.getStringList("itemBlacklist", category, new String[] {}, "Items to not be registered. This requires their mapping name. Usually the same as the class name. Can be found in F3+H mode."));
blockBlacklist = Arrays.asList(config.getStringList("blockBlacklist", category, new String[] {}, "Blocks to not be registered. This requires their mapping name. Usually the same as the class name. Can be found in F3+H mode."));
itemBlacklist = Arrays.asList(config.getStringList("itemBlacklist", category, new String[]{}, "Items to not be registered. This requires their mapping name. Usually the same as the class name. Can be found in F3+H mode."));
blockBlacklist = Arrays.asList(config.getStringList("blockBlacklist", category, new String[]{}, "Blocks to not be registered. This requires their mapping name. Usually the same as the class name. Can be found in F3+H mode."));

category = "Teleposer Blacklist";
config.addCustomCategoryComment(category, "Block blacklisting");
teleposerBlacklisting = config.getStringList("teleposerBlacklist", category, new String[] { "minecraft:bedrock" }, "Stops specified blocks from being teleposed. Put entries on new lines. Valid syntax is:\nmodid:blockname:meta");
buildTeleposerBlacklist();
teleposerBlacklisting = config.getStringList("teleposerBlacklist", category, new String[]{"minecraft:bedrock"}, "Stops specified blocks from being teleposed. Put entries on new lines. Valid syntax is:\nmodid:blockname:meta");
buildBlacklist(teleposerBlacklisting, teleposerBlacklist);

category = "Transposition Sigil Blacklist";
config.addCustomCategoryComment(category, "Block blacklisting");
transpositionBlacklisting = config.getStringList("transpositionBlacklist", category, new String[]{"minecraft:bedrock"}, "Stops specified blocks from being teleposed. Put entries on new lines. Valid syntax is:\nmodid:blockname:meta");
buildBlacklist(transpositionBlacklisting, transpositionBlacklist);

category = "Well of Suffering Blacklist";
config.addCustomCategoryComment(category, "Entity blacklisting from WoS");
wellOfSufferingBlacklist = Arrays.asList(config.getStringList("wellOfSufferingBlacklist", category, new String[] {}, "Use the class name of the Entity to blacklist it from usage.\nIE: EntityWolf, EntityWitch, etc"));
wellOfSufferingBlacklist = Arrays.asList(config.getStringList("wellOfSufferingBlacklist", category, new String[]{}, "Use the class name of the Entity to blacklist it from usage.\nIE: EntityWolf, EntityWitch, etc"));

category = "Blood Altar Sacrificial Values";
config.addCustomCategoryComment(category, "Entity Sacrificial Value Settings");
entitySacrificeValuesList = config.getStringList("entitySacrificeValues", category, new String[] { "EntityVillager;2000", "EntitySlime;150", "EntityEnderman;200", "EntityCow;250", "EntityChicken;250", "EntityHorse;250", "EntitySheep;250", "EntityWolf;250", "EntityOcelot;250", "EntityPig;250", "EntityRabbit;250" }, "Used to edit the amount of LP gained per sacrifice of the given entity.\nSetting an entity to 0 effectively blacklists it.\nIf a mod modifies an entity via the API, it will take precedence over this config.\nSyntax: EntityClassName;LPPerSacrifice");
entitySacrificeValuesList = config.getStringList("entitySacrificeValues", category, new String[]{"EntityVillager;2000", "EntitySlime;150", "EntityEnderman;200", "EntityCow;250", "EntityChicken;250", "EntityHorse;250", "EntitySheep;250", "EntityWolf;250", "EntityOcelot;250", "EntityPig;250", "EntityRabbit;250"}, "Used to edit the amount of LP gained per sacrifice of the given entity.\nSetting an entity to 0 effectively blacklists it.\nIf a mod modifies an entity via the API, it will take precedence over this config.\nSyntax: EntityClassName;LPPerSacrifice");
buildEntitySacrificeValues();

category = "Potions";
Expand Down Expand Up @@ -239,6 +251,13 @@ public static void syncConfig()
ritualUpgradeRemove = config.get(category, "ritualRemove", true).getBoolean();
ritualArmourEvolve = config.get(category, "ritualArmourEvolve", true).getBoolean();

cobblestoneRitual = config.get(category, "ritualCobblestone", true).getBoolean();
placerRitual = config.get(category, "ritualPlacer", true).getBoolean();
fellingRitual = config.get(category, "ritualFelling", true).getBoolean();
pumpRitual = config.get(category, "ritualPump", true).getBoolean();
altarBuilderRitual = config.get(category, "ritualAltarBuilder", true).getBoolean();
portalRitual = config.get(category, "ritualPortal", true).getBoolean();

category = "Rituals.Imperfect";
imperfectRitualNight = config.get(category, "imperfectRitualNight", true).getBoolean();
imperfectRitualRain = config.get(category, "imperfectRitualRain", true).getBoolean();
Expand All @@ -258,22 +277,17 @@ public static void syncConfig()
config.save();
}

private static void buildTeleposerBlacklist()
private static void buildBlacklist(String[] blacklisting, List<BlockStack> blockBlacklist)
{
blockBlacklist.clear();

// Make sure it's empty before setting the blacklist.
// Otherwise, reloading the config while in-game will duplicate the
// list.
teleposerBlacklist.clear();

for (String blockSet : teleposerBlacklisting)
for (String blockSet : blacklisting)
{
String[] blockData = blockSet.split(":");

Block block = GameRegistry.findBlock(blockData[0], blockData[1]);
int meta = 0;

// If the block follows full syntax: modid:blockname:meta
if (blockData.length == 3)
{
// Check if it's an int, if so, parse it. If not, set meta to 0
Expand All @@ -286,7 +300,7 @@ else if (blockData[2].equals("*"))
meta = 0;
}

teleposerBlacklist.add(new BlockStack(block, meta));
blockBlacklist.add(new BlockStack(block, meta));
}
}

Expand Down
8 changes: 7 additions & 1 deletion src/main/java/WayofTime/bloodmagic/api/BlockStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
import lombok.Getter;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.GameData;

@Getter
@EqualsAndHashCode(exclude = { "state" })
@EqualsAndHashCode(exclude = {"state"})
public class BlockStack
{
private final Block block;
Expand All @@ -34,6 +35,11 @@ public static BlockStack getStackFromPos(World world, BlockPos pos)
return new BlockStack(state.getBlock(), state.getBlock().getMetaFromState(state));
}

public ItemStack getItemStack()
{
return new ItemStack(block, 1, meta);
}

@Override
public String toString()
{
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/WayofTime/bloodmagic/api/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public static class NBT
public static final String X_COORD = "xCoord";
public static final String Y_COORD = "yCoord";
public static final String Z_COORD = "zCoord";
public static final String PORTAL_LOCATION ="portalLocation";
public static final String ORB_TIER = "orbTier";
public static final String CURRENT_ESSENCE = "currentEssence";
public static final String CURRENT_RITUAL = "currentRitual";
Expand Down Expand Up @@ -72,6 +73,7 @@ public static class NBT
public static final String TICKS_REMAINING = "ticksRemaining";
public static final String CONTAINED_BLOCK_NAME = "containedBlockName";
public static final String CONTAINED_BLOCK_META = "containedBlockMeta";
public static final String CONTAINED_TILE_ENTITY = "containedTileEntity";

public static final String PREVIOUS_INPUT = "previousInput";

Expand Down Expand Up @@ -198,7 +200,9 @@ public enum BloodMagicItem
SLATE("ItemSlate"),
TELEPOSITION_FOCUS("ItemTelepositionFocus"),
UPGRADE_TOME("ItemUpgradeTome"),
UPGRADE_TRAINER("ItemUpgradeTrainer");
UPGRADE_TRAINER("ItemUpgradeTrainer"),
SIGIL_TELEPOSITION("ItemSigilTeleposition"),
SIGIL_TRANSPOSITION("ItemSigilTransposition");

@Getter
private final String regName;
Expand Down Expand Up @@ -236,7 +240,9 @@ public enum BloodMagicBlock
TELEPOSER("BlockTeleposer"),
INCENSE_ALTAR("BlockIncenseAltar"),
PATH("BlockPath"),
DEMON_CRUCIBLE("BlockDemonCrucible");
DEMON_CRUCIBLE("BlockDemonCrucible"),
DIMENSIONAL_PORTAL("BlockDimensionalPortal"),
BLOOD_TANK("BlockBloodTank");

@Getter
private final String regName;
Expand Down
87 changes: 74 additions & 13 deletions src/main/java/WayofTime/bloodmagic/api/ritual/AreaDescriptor.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package WayofTime.bloodmagic.api.ritual;

import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.function.Consumer;

import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;

public abstract class AreaDescriptor implements Iterator<BlockPos>
{
public List<BlockPos> getContainedPositions(BlockPos pos)
Expand Down Expand Up @@ -40,11 +40,9 @@ public static class Rectangle extends AreaDescriptor
* This constructor takes in the minimum and maximum BlockPos. The
* maximum offset is non-inclusive, meaning if you pass in (0,0,0) and
* (1,1,1), calling getContainedPositions() will only give (0,0,0).
*
* @param minimumOffset
* -
* @param maximumOffset
* -
*
* @param minimumOffset -
* @param maximumOffset -
*/
public Rectangle(BlockPos minimumOffset, BlockPos maximumOffset)
{
Expand Down Expand Up @@ -96,11 +94,9 @@ public AxisAlignedBB getAABB(BlockPos pos)
/**
* Sets the offsets of the AreaDescriptor in a safe way that will make
* minimumOffset the lowest corner
*
* @param offset1
* -
* @param offset2
* -
*
* @param offset1 -
* @param offset2 -
*/
public void setOffsets(BlockPos offset1, BlockPos offset2)
{
Expand Down Expand Up @@ -280,4 +276,69 @@ public void remove()

}
}

public static class Cross extends AreaDescriptor
{

private ArrayList<BlockPos> blockPosCache;
private BlockPos cachedPosition;

private BlockPos centerPos;
private int size;

private boolean cache = true;

public Cross(BlockPos center, int size)
{
this.centerPos = center;
this.size = size;
this.blockPosCache = new ArrayList<BlockPos>();
}

@Override
public List<BlockPos> getContainedPositions(BlockPos pos)
{
if (!cache || !pos.equals(cachedPosition) || blockPosCache.isEmpty())
{
resetCache();

blockPosCache.add(centerPos.add(pos));
for (int i = 1; i <= size; i++)
{
blockPosCache.add(centerPos.add(pos).add(i, 0, 0));
blockPosCache.add(centerPos.add(pos).add(0, 0, i));
blockPosCache.add(centerPos.add(pos).add(-i, 0, 0));
blockPosCache.add(centerPos.add(pos).add(0, 0, -i));
}
}

cachedPosition = pos;

return Collections.unmodifiableList(blockPosCache);
}

@Override
public void resetCache()
{
blockPosCache = new ArrayList<BlockPos>();
}

@Override
public boolean isWithinArea(BlockPos pos)
{
return blockPosCache.contains(pos);
}

@Override
public boolean hasNext()
{
return false;
}

@Override
public BlockPos next()
{
return null;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package WayofTime.bloodmagic.api.teleport;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
import net.minecraft.util.BlockPos;

import java.io.Serializable;

@ToString
@EqualsAndHashCode
public class ChunkPairSerializable implements Serializable
{
@Getter
private int chunkXPos;
@Getter
private int chunkZPos;

public ChunkPairSerializable(int chunkXPos, int chunkZPos)
{
this.chunkXPos = chunkXPos;
this.chunkZPos = chunkZPos;
}

public ChunkPairSerializable(BlockPos blockPos)
{
this(blockPos.getX() >> 4, blockPos.getZ() >> 4);
}

public BlockPos getChunkCenter(int y)
{
return new BlockPos((chunkXPos << 4) + 8, y, (chunkZPos << 4) + 8);
}

public BlockPos getChunkCenter(){
return getChunkCenter(64);
}

@Override
public boolean equals(Object o)
{
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

ChunkPairSerializable that = (ChunkPairSerializable) o;

if (chunkXPos != that.chunkXPos) return false;
return chunkZPos == that.chunkZPos;

}

@Override
public int hashCode()
{
int result = chunkXPos;
result = 31 * result + chunkZPos;
return result;
}

@Override
public String toString()
{
return "ChunkPairSerializable{" +
"chunkXPos=" + chunkXPos +
", chunkZPos=" + chunkZPos +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package WayofTime.bloodmagic.api.teleport;

public interface ITeleport
{
public void teleport();

public int getTeleportCost();
}
Loading

0 comments on commit 7e8aec8

Please sign in to comment.