use of net.minecraft.world.DimensionType in project Cavern2 by kegare.
the class MagicWarp method fireMagic.
@Override
public ActionResult<ITextComponent> fireMagic() {
if (!world.isRemote) {
ItemStack stack = getHeldItem();
DimensionType type = world.provider.getDimensionType();
Pair<BlockPos, DimensionType> warpPoint = getWarpPoint(stack);
if (warpPoint == null) {
setWarpPoint(stack, player.getPosition(), type);
return new ActionResult<>(EnumActionResult.SUCCESS, new TextComponentTranslation("item.magicBook.warp.set"));
}
BlockPos pos = warpPoint.getLeft();
if (type != warpPoint.getRight()) {
return new ActionResult<>(EnumActionResult.FAIL, new TextComponentTranslation("item.magicBook.warp.far"));
}
distance = Math.sqrt(player.getDistanceSqToCenter(pos));
int mana = getMana();
if (mana < 5 && distance > 100.0D * mana) {
return new ActionResult<>(EnumActionResult.FAIL, new TextComponentTranslation("item.magicBook.warp.far"));
}
if (!player.attemptTeleport(pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D)) {
return new ActionResult<>(EnumActionResult.FAIL, null);
}
warp = true;
setWarpPoint(stack, null, type);
return new ActionResult<>(EnumActionResult.SUCCESS, null);
}
return new ActionResult<>(EnumActionResult.PASS, null);
}
use of net.minecraft.world.DimensionType in project Cavern2 by kegare.
the class CaveEventHooks method onPlayerChangedDimension.
@SubscribeEvent
public void onPlayerChangedDimension(PlayerChangedDimensionEvent event) {
if (!(event.player instanceof EntityPlayerMP)) {
return;
}
EntityPlayerMP player = (EntityPlayerMP) event.player;
if (CavernAPI.dimension.isInCaves(player)) {
WorldServer world = player.getServerWorld();
DimensionType type = world.provider.getDimensionType();
if (type != CaveDimensions.CAVERN) {
String name = type.getName();
PlayerHelper.grantCriterion(player, "enter_the_" + name, "entered_" + name);
}
}
MinerStats.adjustData(player);
}
use of net.minecraft.world.DimensionType in project Cavern2 by kegare.
the class ItemMirageBook method attemptToLastPos.
protected boolean attemptToLastPos(World world, Entity entity) {
IPortalCache cache = PortalCache.get(entity);
ResourceLocation key = CaveUtils.getKey("mirage_worlds");
DimensionType type = world.provider.getDimensionType();
if (cache.hasLastPos(key, type)) {
BlockPos pos = cache.getLastPos(key, type);
if (world.getBlockState(pos.down()).getMaterial().isSolid() && world.getBlockState(pos).getBlock().canSpawnInBlock() && world.getBlockState(pos.up()).getBlock().canSpawnInBlock()) {
entity.moveToBlockPosAndAngles(pos, entity.rotationYaw, entity.rotationPitch);
return true;
}
cache.setLastPos(key, type, null);
}
return false;
}
use of net.minecraft.world.DimensionType in project Cavern2 by kegare.
the class ItemMirageBook method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
DimensionType type = EnumType.byItemStack(stack).getDimension();
if (type == null) {
return new ActionResult<>(EnumActionResult.PASS, stack);
}
if (world.provider.getDimensionType() == type) {
if (!world.isRemote) {
PlayerData.get(player).setLastTeleportTime(type, world.getTotalWorldTime());
transferTo(null, player);
}
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}
if (world.isRemote) {
if (CavernAPI.dimension.isInMirageWorlds(player)) {
player.sendStatusMessage(new TextComponentTranslation(getUnlocalizedName() + ".fail"), true);
} else {
player.sendStatusMessage(new TextComponentTranslation(getUnlocalizedName() + ".portal"), true);
}
}
return new ActionResult<>(EnumActionResult.PASS, stack);
}
use of net.minecraft.world.DimensionType in project Cavern2 by kegare.
the class BlockPortalMirageWorlds method openRegeneration.
@SideOnly(Side.CLIENT)
@Override
public void openRegeneration(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side) {
GuiRegeneration regeneration = new GuiRegeneration();
DimensionType type = getDimension(player.getHeldItem(hand));
if (type != null) {
regeneration.dimensions.add(type);
}
FMLClientHandler.instance().showGuiScreen(regeneration);
}
Aggregations