Added block black list for teleporting using staff / travel upgrade

This commit is contained in:
CrazyPants committed 2014-09-16 17:54:48 +08:00
1 parent 5e3c3d58a6
commit e33bcf8499
3 files changed
+29 -5

No files matched your search

@@ -121,6 +121,9 @@ public final class Config {
public static boolean travelStaffBlinkEnabled = true;
public static boolean travelStaffBlinkThroughSolidBlocksEnabled = true;
public static boolean travelStaffBlinkThroughClearBlocksEnabled = true;
public static String[] travelStaffBlinkBlackList = new String[] {
"minecraft:bedrock"
};
public static int enderIoRange = 8;
public static boolean enderIoMeAccessEnabled = true;
@@ -316,7 +319,7 @@ public final class Config {
public static int spawnGuardPowerPerTickLevelTwo = 300;
public static int spawnGuardRangeLevelThree = 128;
public static int spawnGuardPowerPerTickLevelThree = 1000;
public static void load(FMLPreInitializationEvent event) {
FMLCommonHandler.instance().bus().register(new Config());
@@ -507,11 +510,11 @@ public final class Config {
travelStaffBlinkPauseTicks = config.get(sectionStaff.name, "travelStaffBlinkPauseTicks", travelStaffBlinkPauseTicks,
"Minimum number of ticks between 'blinks'. Values of 10 or less allow a limited sort of flight.").getInt(travelStaffBlinkPauseTicks);
travelStaffEnabled = config.get(sectionItems.name, "travelStaffEnabled", travelAnchorEnabled,
travelStaffEnabled = config.get(sectionStaff.name, "travelStaffEnabled", travelAnchorEnabled,
"If set to false: the travel staff will not be craftable.").getBoolean(travelStaffEnabled);
travelStaffBlinkEnabled = config.get(sectionItems.name, "travelStaffBlinkEnabled", travelStaffBlinkEnabled,
travelStaffBlinkEnabled = config.get(sectionStaff.name, "travelStaffBlinkEnabled", travelStaffBlinkEnabled,
"If set to false: the travel staff can not be used to shift-right click teleport, or blink.").getBoolean(travelStaffBlinkEnabled);
travelStaffBlinkThroughSolidBlocksEnabled = config.get(sectionItems.name, "travelStaffBlinkThroughSolidBlocksEnabled",
travelStaffBlinkThroughSolidBlocksEnabled = config.get(sectionStaff.name, "travelStaffBlinkThroughSolidBlocksEnabled",
travelStaffBlinkThroughSolidBlocksEnabled,
"If set to false: the travel staff can be used to blink through any block.").getBoolean(travelStaffBlinkThroughSolidBlocksEnabled);
travelStaffBlinkThroughClearBlocksEnabled = config
@@ -520,6 +523,8 @@ public final class Config {
"staff can only be used to blink through transparent or partial blocks (e.g. torches). " +
"If both are false: only air blocks may be teleported through.")
.getBoolean(travelStaffBlinkThroughClearBlocksEnabled);
travelStaffBlinkBlackList = config.getStringList("travelStaffBlinkBlackList", sectionStaff.name, travelStaffBlinkBlackList,
"Lists the blocks that cannot be teleported through in the form 'modID:blockName'");
enderIoRange = config.get(sectionEfficiency.name, "enderIoRange", enderIoRange,
"Range accessable (in blocks) when using the Ender IO.").getInt(enderIoRange);
@@ -1,5 +1,6 @@
package crazypants.enderio.teleport;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Random;
@@ -22,6 +23,8 @@ import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.EnderIO;
@@ -66,8 +69,14 @@ public class TravelController {
private double tanFovRad;
private Minecraft mc = Minecraft.getMinecraft();
private final List<UniqueIdentifier> blackList = new ArrayList<GameRegistry.UniqueIdentifier>();
private TravelController() {
String[] blackListNames = Config.travelStaffBlinkBlackList;
for(String name : blackListNames) {
blackList.add(new UniqueIdentifier(name));
}
}
public boolean activateTravelAccessable(ItemStack equipped, World world, EntityPlayer player, TravelSource source) {
@@ -129,7 +138,7 @@ public class TravelController {
for (MovingObjectPosition pos : res) {
if(pos != null) {
Block hitBlock = player.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ);
if(hitBlock.getBlockHardness(player.worldObj, pos.blockX, pos.blockY, pos.blockZ) < 0) {
if(isBlackListedBlock(player, pos, hitBlock)) {
maxDistance = Math.min(maxDistance, VecmathUtil.distance(eye, new Vector3d(pos.blockX + 0.5, pos.blockY + 0.5, pos.blockZ + 0.5)) - 1.5 - lookComp);
}
}
@@ -173,6 +182,15 @@ public class TravelController {
return false;
}
private boolean isBlackListedBlock(EntityPlayer player, MovingObjectPosition pos, Block hitBlock) {
UniqueIdentifier ui = GameRegistry.findUniqueIdentifierFor(hitBlock);
if(ui == null) {
return false;
}
//hitBlock.getBlockHardness(player.worldObj, pos.blockX, pos.blockY, pos.blockZ) < 0;
return blackList.contains(ui);
}
private boolean doBlinkAround(EntityPlayer player, Vector3d sample) {
if(doBlink(player, new BlockCoord((int) Math.round(sample.x), (int) Math.round(sample.y) - 1, (int) Math.round(sample.z)))) {
return true;