switch (action)
{
case IGNORE:
return null;
case ABORT:
break;
case INCREMENT:
default:
blocksInTheWay++;
if (blocksInTheWay > Config.elevatorMaxBlockPassCount) {
break label269;
}
null
какой-то объект. -> Ты пытаешься из ничего достать переменную(массив).package render;
import com.google.common.base.Preconditions;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import openmods.movement.PlayerMovementEvent;
import openmods.utils.EnchantmentUtils;
public class ElevatorActionHandler
{
private static class SearchResult
{
public final int level;
public final IElevatorBlock.PlayerRotation rotation;
public SearchResult(int level, IElevatorBlock.PlayerRotation rotation)
{
this.level = level;
this.rotation = rotation;
}
}
private static boolean canTeleportPlayer(World world, int x, int y, int z)
{
Block block = world.getBlock(x, y, z);
if ((block == null) || (block.isAir(world, x, y, z))) {
return true;
}
if (!Config.irregularBlocksArePassable) {
return false;
}
AxisAlignedBB aabb = block.getCollisionBoundingBoxFromPool(world, x, y, z);
return (aabb == null) || (aabb.getAverageEdgeLength() < 0.7D);
}
private static boolean canTeleportPlayer(EntityPlayer entity, World world, int x, int y, int z)
{
AxisAlignedBB aabb = entity.boundingBox;
double height = Math.abs(aabb.maxY - aabb.minY);
int blockHeight = Math.max(1, MathHelper.ceiling_double_int(height));
for (int dy = 0; dy < blockHeight; dy++) {
if (!canTeleportPlayer(world, x, y + dy, z)) {
return false;
}
}
return true;
}
private static SearchResult findLevel(EntityPlayer player, World world, int x, int y, int z, ForgeDirection direction)
{
Preconditions.checkArgument((direction == ForgeDirection.UP) || (direction == ForgeDirection.DOWN), "Must be either up or down... for now");
IElevatorBlock thisElevatorBlock = (IElevatorBlock)world.getBlock(x, y, z);
int thisColor = thisElevatorBlock.getColor(world, x, y, z);
int blocksInTheWay = 0;
int delta = direction.offsetY;
for (int i = 0; i < Config.elevatorTravelDistance; i++)
{
y += delta;
if (!world.blockExists(x, y, z)) {
break;
}
if (!world.isAirBlock(x, y, z))
{
Block block = world.getBlock(x, y, z);
if ((block instanceof IElevatorBlock))
{
IElevatorBlock otherElevatorBlock = (IElevatorBlock)block;
int otherColor = otherElevatorBlock.getColor(world, x, y, z);
if ((otherColor == thisColor) && (canTeleportPlayer(player, world, x, y + 1, z)))
{
IElevatorBlock.PlayerRotation rotation = otherElevatorBlock.getRotation(world, x, y, z);
return new SearchResult(y, rotation);
}
}
if (!Config.elevatorIgnoreBlocks)
{
ElevatorBlockRules.Action action = ElevatorBlockRules.instance.getActionForBlock(block);
switch (1.$SwitchMap$render$ElevatorBlockRules$Action[action.ordinal()])
{
case 1:
return null;
case 2:
break;
case 3:
default:
blocksInTheWay++;
if (blocksInTheWay > Config.elevatorMaxBlockPassCount) {
break label269;
}
}
}
}
}
label269:
return null;
}
private static void activate(EntityPlayer player, World world, int x, int y, int z, ForgeDirection dir)
{
SearchResult result = findLevel(player, world, x, y, z, dir);
if (result != null)
{
boolean doTeleport = checkXpCost(player, result);
if (doTeleport)
{
if (result.rotation != IElevatorBlock.PlayerRotation.NONE) {
player.rotationYaw = getYaw(result.rotation);
}
if (Config.elevatorCenter) {
player.setPositionAndUpdate(x + 0.5D, result.level + 1.1D, z + 0.5D);
} else {
player.setPositionAndUpdate(player.posX, result.level + 1.1D, player.posZ);
}
world.playSoundAtEntity(player, "openblocks:elevator.activate", 1.0F, 1.0F);
}
}
}
private static float getYaw(IElevatorBlock.PlayerRotation rotation)
{
switch (1.$SwitchMap$render$IElevatorBlock$PlayerRotation[rotation.ordinal()])
{
case 1:
return 90.0F;
case 2:
return 0.0F;
case 3:
return 180.0F;
case 4:
return -90.0F;
}
return 0.0F;
}
protected static boolean checkXpCost(EntityPlayer player, SearchResult result)
{
int distance = (int)Math.abs(player.posY - result.level);
if ((Config.elevatorXpDrainRatio == 0.0F) || (player.capabilities.isCreativeMode)) {
return true;
}
int playerXP = EnchantmentUtils.getPlayerXP(player);
int neededXP = MathHelper.ceiling_double_int(Config.elevatorXpDrainRatio * distance);
if (playerXP >= neededXP)
{
EnchantmentUtils.addPlayerXP(player, -neededXP);
return true;
}
return false;
}
@SubscribeEvent
public void onElevatorEvent(ElevatorActionEvent evt)
{
World world = evt.getWorld();
int x = evt.xCoord;
int y = evt.yCoord;
int z = evt.zCoord;
if (!(world.getBlock(x, y, z) instanceof IElevatorBlock)) {
return;
}
if (evt.sender != null)
{
if (evt.sender.ridingEntity != null) {
return;
}
switch (evt.type)
{
case JUMP:
activate(evt.sender, world, x, y, z, ForgeDirection.UP);
break;
case SNEAK:
activate(evt.sender, world, x, y, z, ForgeDirection.DOWN);
}
}
}
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onPlayerMovement(PlayerMovementEvent evt)
{
EntityPlayer player = evt.entityPlayer;
if (player == null) {
return;
}
World world = player.worldObj;
if (world == null) {
return;
}
int x = MathHelper.floor_double(player.posX);
int y = MathHelper.floor_double(player.boundingBox.minY) - 1;
int z = MathHelper.floor_double(player.posZ);
Block block = world.getBlock(x, y, z);
if ((block instanceof IElevatorBlock)) {
new ElevatorActionEvent(world.provider.dimensionId, x, y, z, evt.type).sendToServer();
}
}
}
package render;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import com.google.common.collect.ImmutableMap.Builder;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import java.util.Locale;
import java.util.Map;
import net.minecraft.block.Block;
import openmods.Log;
import openmods.config.properties.ConfigurationChange;
import openmods.config.properties.ConfigurationChange.Post;
public class ElevatorBlockRules
{
public static final ElevatorBlockRules instance = new ElevatorBlockRules();
private static final Map<String, Action> ACTIONS;
private Map<Block, Action> rules;
public static enum Action
{
IGNORE, ABORT, INCREMENT;
private Action() {}
}
static
{
ImmutableMap.Builder<String, Action> builder = ImmutableMap.builder();
for (Action a : Action.values()) {
builder.put(a.name().toLowerCase(Locale.ENGLISH), a);
}
ACTIONS = builder.build();
}
private Map<Block, Action> getRules()
{
if (this.rules == null)
{
this.rules = Maps.newIdentityHashMap();
for (String entry : Config.elevatorRules) {
try
{
tryAddRule(this.rules, entry);
}
catch (Throwable t)
{
Log.warn(t, "Invalid entry in map blacklist: %s", new Object[] { entry });
}
}
}
return this.rules;
}
private static void tryAddRule(Map<Block, Action> rules, String entry)
{
String[] parts = entry.split(":");
if (parts.length == 0) {
return;
}
Preconditions.checkState(parts.length == 3, "Each entry must have exactly 3 colon-separated fields");
String modId = parts[0];
String blockName = parts[1];
String actionName = parts[2].toLowerCase(Locale.ENGLISH);
Action action = (Action)ACTIONS.get(actionName);
Preconditions.checkNotNull(action, "Unknown action: %s", new Object[] { actionName });
Block block = GameRegistry.findBlock(modId, blockName);
if (block != null) {
rules.put(block, action);
} else {
Log.warn("Can't find block %s", new Object[] { entry });
}
}
@SubscribeEvent
public void onReconfig(ConfigurationChange.Post evt)
{
if (evt.check("dropblock", "specialBlockRules")) {
this.rules = null;
}
}
private static boolean isPassable(Block block)
{
return (Config.elevatorIgnoreHalfBlocks) && (!block.isNormalCube());
}
public Action getActionForBlock(Block block)
{
if (block == null) {
return Action.IGNORE;
}
Action action = (Action)getRules().get(block);
if (action != null) {
return action;
}
return isPassable(block) ? Action.IGNORE : Action.INCREMENT;
}
}
package render;
import net.minecraft.world.World;
public interface IElevatorBlock{
int getColor(World var1, int var2, int var3, int var4);
IElevatorBlock.PlayerRotation getRotation(World var1, int var2, int var3, int var4);
public static enum PlayerRotation {
NONE("NONE", 0),
NORTH("NORTH", 1),
SOUTH("SOUTH", 2),
EAST("EAST", 3),
WEST("WEST", 4);
// $FF: synthetic field
private static final IElevatorBlock.PlayerRotation[] $VALUES = new IElevatorBlock.PlayerRotation[]{NONE, NORTH, SOUTH, EAST, WEST};
private PlayerRotation(String var1, int var2) {}
}
}
switch (1.$SwitchMap$render$ElevatorBlockRules$Action[action.ordinal()])
switch (action.ordinal())
switch (action)
{
case IGNORE:
return null;
case ABORT:
break;
case INCREMENT:
default:
blocksInTheWay++;
if (blocksInTheWay > Config.elevatorMaxBlockPassCount) {
break label269;
}