Java Code Examples for net.minecraft.world.DimensionType

The following are top voted examples for showing how to use net.minecraft.world.DimensionType. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Etheric   File: EthericWorldGenerator.java   Source Code and License 6 votes vote down vote up
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator,
		IChunkProvider chunkProvider) {
	
	StabilityHandler.addChunkData(world.provider.getDimension(), new ChunkPos(chunkX, chunkZ), StabilityHandler.generateChunkStability(random));

	if (world.provider.getDimensionType() == DimensionType.OVERWORLD) {
		
		WorldGenMinable lodestone = new WorldGenMinable(RegistryManager.lodestone_ore.getDefaultState(), Config.LODESTONE_VEIN_SIZE);
		for (int i = 0; i < Config.LODESTONE_FREQUENCY; i++) {
			int x = chunkX * 16 + random.nextInt(16);
			int y = random.nextInt(Config.LODESTONE_MAX_Y - Config.LODESTONE_MIN_Y) + Config.LODESTONE_MIN_Y;
			int z = chunkZ * 16 + random.nextInt(16);
			lodestone.generate(world, random, new BlockPos(x, y, z));
		}
		
		BlockPos pos = new BlockPos(chunkX * 16, 0, chunkZ * 16);
		
		WorldGenRift rift = new WorldGenRift();
		rift.generate(world, random, pos);
		
	}
	
}
 
Example 2
Project: Adventurers-Toolbox   File: SpecialToolAbilityHandler.java   Source Code and License 6 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onWitherBoneHarvestEvent(BlockEvent.HarvestDropsEvent event) {
	if (event.getHarvester() == null) {
		return;
	}

	EntityPlayer player = event.getHarvester();
	ItemStack stack = player.getHeldItemMainhand();

	boolean flag = false;

	if (stack.getItem() instanceof IHaftTool) {
		if (IHaftTool.getHaftMat(stack) == ModMaterials.HAFT_WITHER_BONE) {
			flag = true;
		}
	}

	if (flag) {
		if (player.dimension != DimensionType.NETHER.getId()) {
			stack.damageItem(7, player);
		}
	}
}
 
Example 3
Project: Adventurers-Toolbox   File: SpecialToolAbilityHandler.java   Source Code and License 6 votes vote down vote up
@SubscribeEvent
public void onWitherBoneAttackEvent(AttackEntityEvent event) {
	
	EntityPlayer player = event.getEntityPlayer();
	ItemStack stack = player.getHeldItemMainhand();
	
	boolean flag = false;
	
	if (stack.getItem() instanceof IHaftTool) {
		if (IHaftTool.getHaftMat(stack) == ModMaterials.HAFT_WITHER_BONE) {
			flag = true;
		}
	}

	if (flag) {
		if (player.dimension != DimensionType.NETHER.getId()) {
			stack.damageItem(7, player);
		}
	}
}
 
Example 4
Project: Backmemed   File: CustomColors.java   Source Code and License 6 votes vote down vote up
public static Vec3d getWorldFogColor(Vec3d p_getWorldFogColor_0_, World p_getWorldFogColor_1_, Entity p_getWorldFogColor_2_, float p_getWorldFogColor_3_)
{
    DimensionType dimensiontype = p_getWorldFogColor_1_.provider.getDimensionType();

    switch (dimensiontype)
    {
        case NETHER:
            p_getWorldFogColor_0_ = getFogColorNether(p_getWorldFogColor_0_);
            break;

        case OVERWORLD:
            Minecraft minecraft = Minecraft.getMinecraft();
            p_getWorldFogColor_0_ = getFogColor(p_getWorldFogColor_0_, minecraft.world, p_getWorldFogColor_2_.posX, p_getWorldFogColor_2_.posY + 1.0D, p_getWorldFogColor_2_.posZ);
            break;

        case THE_END:
            p_getWorldFogColor_0_ = getFogColorEnd(p_getWorldFogColor_0_);
    }

    return p_getWorldFogColor_0_;
}
 
Example 5
Project: Backmemed   File: CustomColors.java   Source Code and License 6 votes vote down vote up
public static Vec3d getWorldSkyColor(Vec3d p_getWorldSkyColor_0_, World p_getWorldSkyColor_1_, Entity p_getWorldSkyColor_2_, float p_getWorldSkyColor_3_)
{
    DimensionType dimensiontype = p_getWorldSkyColor_1_.provider.getDimensionType();

    switch (dimensiontype)
    {
        case OVERWORLD:
            Minecraft minecraft = Minecraft.getMinecraft();
            p_getWorldSkyColor_0_ = getSkyColor(p_getWorldSkyColor_0_, minecraft.world, p_getWorldSkyColor_2_.posX, p_getWorldSkyColor_2_.posY + 1.0D, p_getWorldSkyColor_2_.posZ);
            break;

        case THE_END:
            p_getWorldSkyColor_0_ = getSkyColorEnd(p_getWorldSkyColor_0_);
    }

    return p_getWorldSkyColor_0_;
}
 
Example 6
Project: CrystalMod   File: StringUtils.java   Source Code and License 6 votes vote down vote up
public static final String getDimensionName(UUID requestID, int dimension){
	if(FMLCommonHandler.instance().getSide() == Side.SERVER){
		try{
			DimensionType type = DimensionManager.getProviderType(dimension);
			return type.getName();
		} catch(Exception e){}
	} else {
		if(!DIMENSION_NAMES.containsKey(dimension)){
			CrystalModNetwork.sendToServer(new PacketDimensionNameRequest(requestID, dimension));
		} else {
			return DIMENSION_NAMES.get(dimension);
		}
	}
	
	return ""+dimension;
}
 
Example 7
Project: TechnicalDimensions   File: ModDimensions.java   Source Code and License 6 votes vote down vote up
public static void worldLoad(FMLServerStartedEvent serverStartedEvent) throws IOException {
    File worldFile = new File(FMLCommonHandler.instance().getSavesDirectory(), FMLCommonHandler.instance().getMinecraftServerInstance().getFolderName());
    File dataFile = new File(worldFile, fileName);

    if (!dataFile.exists()) {
        return;
    }

    String json = FileUtils.readFileToString(dataFile);
    Gson gson = new Gson();
    Type typeOfHashMap = new TypeToken<List<DimData>>() {
    }.getType();
    List<DimData> tempDataList = gson.fromJson(json, typeOfHashMap);
    for (DimData data : tempDataList) {
        DimensionType type = DimensionType.register("technicaldimensions", data.name, data.id, CustomWorldProvider.class, false);
        DimensionManager.registerDimension(data.id, type);
        data.type = type;
        dimDataHashMap.put(data.id, data);
        dimDataList.add(data);
    }
}
 
Example 8
Project: nVoid   File: nVoid.java   Source Code and License 6 votes vote down vote up
@Mod.EventHandler
public void load(FMLInitializationEvent event) {
	if (Config.voidNether == true) {
		wtvn = new WorldTypeVoidNether();
		DimensionManager.unregisterDimension(-1);
		DimensionManager.registerDimension(-1,
				DimensionType.register("VoidNether", "_nether", -1, WorldProviderVoidNether.class, false));
	}
	if (Config.voidOverworld == true) {
		wtvo = new WorldTypeVoidOverworld();
		DimensionManager.unregisterDimension(0);
		DimensionManager.registerDimension(0,
				DimensionType.register("VoidOverworld", "overworld", 0, WorldProviderVoidOverworld.class, false));
	}
	if (Config.voidEnd == true) {
		wtve = new WorldTypeVoidEnd();
		DimensionManager.unregisterDimension(1);
		DimensionManager.registerDimension(1,
				DimensionType.register("VoidEnd", "end", 1, WorldProviderVoidEnd.class, false));
	}
}
 
Example 9
Project: Malgra   File: SyncResearchDimensions.java   Source Code and License 6 votes vote down vote up
@Override
public void process(EntityPlayer player, Side side)
{
    if(ResearchDimensions.get(player.world).researchDimIDs.get(this.username) == null) {
        DimensionType researchDim = DimensionType.register("research" + this.username, "", this.dimID, WorldProviderResearch.class, false);

        DimensionManager.registerDimension(this.dimID, researchDim);

        ResearchDimensions.get(player.world).researchDimIDs.put(this.username, this.dimID);
        ResearchDimensions.get(player.world).researchDimTypes.put(this.dimID, researchDim);
    }else{

        ResearchDimensions.get(player.world).researchDimIDs.put(this.username, this.dimID);
        ResearchDimensions.get(player.world).researchDimTypes.put(this.dimID, DimensionType.getById(this.dimID));

    }

}
 
Example 10
Project: MC-Prefab   File: Structure.java   Source Code and License 6 votes vote down vote up
/**
 * Determines if a water block was replaced with cobblestone because this structure was built in the nether or the end.
 * @param configuration The structure configuration.
 * @param block The build block object.
 * @param world The workd object.
 * @param originalPos The original block position this structure was built on.
 * @param assumedNorth The assumed north direction (typically north).
 * @param foundBlock The actual block found at the current location.
 * @param blockState The block state to set for the current block.
 * @param player The player requesting this build.
 * @return Returns true if the water block was replaced by cobblestone, otherwise false.
 */
protected Boolean WaterReplacedWithCobbleStone(StructureConfiguration configuration, BuildBlock block, World world, BlockPos originalPos,
		EnumFacing assumedNorth, Block foundBlock, IBlockState blockState, EntityPlayer player)
{
	// Replace water blocks with cobblestone.
	if (foundBlock instanceof BlockLiquid && blockState.getMaterial() == Material.WATER
			&& (world.provider.getDimensionType() == DimensionType.NETHER))
	{
		block.setBlockDomain(Blocks.COBBLESTONE.getRegistryName().getResourceDomain());
		block.setBlockName(Blocks.COBBLESTONE.getRegistryName().getResourcePath());
		block.setBlockState(Blocks.COBBLESTONE.getDefaultState());
		
		// Add this as a priority 3 block since it should be done at the end.
		this.priorityThreeBlocks.add(block);
		return true;
	}
	
	return false;
}
 
Example 11
Project: justenoughdimensions   File: DimensionSyncPacket.java   Source Code and License 6 votes vote down vote up
private static void registerDimension(int id, DimensionConfigEntry entry)
{
    if (entry.getUnregister() || entry.hasDimensionTypeEntry() == false)
    {
        return;
    }

    if (DimensionManager.isDimensionRegistered(id))
    {
        DimensionType type = DimensionManager.getProviderType(id);

        if (type.createDimension().getClass() != entry.getDimensionTypeEntry().getProviderClass())
        {
            JustEnoughDimensions.logInfo("DimensionSyncPacket.registerDimension: Dimension {} already registered, unregistering the old one", id);
            DimensionManager.unregisterDimension(id);
        }
    }

    if (DimensionManager.isDimensionRegistered(id) == false)
    {
        JustEnoughDimensions.logInfo("DimensionSyncPacket.registerDimension: Registering dimension {}", id);
        DimensionManager.registerDimension(id, entry.getDimensionTypeEntry().registerDimensionType());
    }
}
 
Example 12
Project: Kingdom-Keys-Re-Coded   File: ModDimensions.java   Source Code and License 6 votes vote down vote up
public static void init() {
//Not really working
    //    if(ConfigHandler.StationOfAwakeningID.equals("auto"))
    diveToTheHeartID = DimensionManager.getNextFreeDimId();
    diveToTheHeart = DimensionType.register("Dive to the Heart", "", diveToTheHeartID, WorldProviderDiveToTheHeart.class, false);
    DimensionManager.registerDimension(diveToTheHeartID, diveToTheHeart);
    traverseTownID = DimensionManager.getNextFreeDimId();
    traverseTown = DimensionType.register("Traverse Town", "", traverseTownID, WorldProviderTraverseTown.class, false);
    DimensionManager.registerDimension(traverseTownID, traverseTown);
    destinyIslandsID = DimensionManager.getNextFreeDimId();
    destinyIslands = DimensionType.register("Destiny Islands", "", destinyIslandsID, WorldProviderDestinyIslands.class, false);
    DimensionManager.registerDimension(destinyIslandsID, destinyIslands);
    //else
    //diveToTheHeartID = Integer.parseInt(ConfigHandler.StationOfAwakeningID);

}
 
Example 13
Project: ForgeHax   File: DimensionProperty.java   Source Code and License 5 votes vote down vote up
@Override
public void serialize(JsonWriter writer) throws IOException {
    writer.beginArray();
    for(DimensionType dimension : dimensions) {
        writer.value(dimension.getName());
    }
    writer.endArray();
}
 
Example 14
Project: ForgeHax   File: DimensionProperty.java   Source Code and License 5 votes vote down vote up
@Override
public void deserialize(JsonReader reader) throws IOException {
    reader.beginArray();
    while(reader.hasNext() && reader.peek().equals(JsonToken.STRING)) {
        String dim = reader.nextString();
        for(DimensionType type : DimensionType.values()) if(Objects.equals(type.getName(), dim)) {
            add(type);
            break;
        }
    }
}
 
Example 15
Project: ForgeHax   File: DimensionProperty.java   Source Code and License 5 votes vote down vote up
@Override
public String helpText() {
    final StringBuilder builder = new StringBuilder("{");
    Iterator<DimensionType> it = dimensions.iterator();
    while(it.hasNext()) {
        String name = it.next().getName();
        builder.append(name);
        if(it.hasNext()) builder.append(", ");
    }
    builder.append("}");
    return builder.toString();
}
 
Example 16
Project: Randores2   File: RandoresWorldGenerator.java   Source Code and License 5 votes vote down vote up
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
    if (!world.isRemote) {
        RandoresConfig config = Randores.getConfigObj();
        RandoresModules modules = config.getModules();

        boolean flag = modules.isDimensionLess();
        boolean flag2 = modules.isYoutubeMode();
        int ores = config.getMaxOres();

        if (RandoresWorldData.hasData(world)) {
            RandoresWorldData data = RandoresWorldData.getSimply(world);
            for (OreType oreType : OreTypeRegistry.instance().values()) {
                if (flag || oreType.getIsDimension().apply(world)) {
                    List<MaterialDefinition> target = data.shuffleAndGetDimensionCache(oreType, random);
                    if (!target.isEmpty()) {
                        int count = Math.min(ores, target.size()) * (flag2 ? 2 : 1);
                        for (int i = 0; i < count; i++) {
                            MaterialDefinition element = target.get(i);
                            OreComponent component = element.getOre();
                            this.generateOre(component.getBlock().getDefaultState().withProperty(RandoresOre.HARVEST_LEVEL, component.getHarvestLevel()), element.getData(), world, random, chunkX * 16, chunkZ * 16, component.getVeinSize(), component.getMaxY(), component.getMinY(), component.getMaxOccurrences(), component.getMinOccurrences(), component.getOreType().getGenerateIn());
                        }
                    }
                }
            }
        }

        if (flag || DimensionType.OVERWORLD.getId() == world.provider.getDimension()) {
            this.generateOre(CraftingBlocks.craftiniumOre.getDefaultState(), world, random, chunkX * 16, chunkZ * 16, 6, world.getHeight(), 0, 100, 50, new Block[] {Blocks.STONE});
        }
    }
}
 
Example 17
Project: UniversalRemote   File: WorldProviderProxyClient.java   Source Code and License 5 votes vote down vote up
@Override
public DimensionType getDimensionType() {
	if(m_realProvider != null) {
		return m_realProvider.getDimensionType();
	} else {
		return null;
	}
}
 
Example 18
Project: UniversalRemote   File: WorldProviderProxyServer.java   Source Code and License 5 votes vote down vote up
@Override
public DimensionType getDimensionType() {
	if (m_proxyProvider != null && Util.isPrefixInCallStack(m_modPrefix)) {
		return m_proxyProvider.getDimensionType();
	} else if (m_realProvider != null) {
		return m_realProvider.getDimensionType();
	} else {
		return null;
	}
}
 
Example 19
Project: CustomWorldGen   File: DimensionMessageHandler.java   Source Code and License 5 votes vote down vote up
@Override
protected void channelRead0(ChannelHandlerContext ctx, DimensionRegisterMessage msg) throws Exception
{
    if (!DimensionManager.isDimensionRegistered(msg.dimensionId))
    {
        DimensionManager.registerDimension(msg.dimensionId, DimensionType.valueOf(msg.providerId));
    }
}
 
Example 20
Project: CustomWorldGen   File: DimensionManager.java   Source Code and License 5 votes vote down vote up
/**
 * Returns a list of dimensions associated with this DimensionType.
 */
public static int[] getDimensions(DimensionType type)
{
    int[] ret = new int[dimensions.size()];
    int x = 0;
    for (Map.Entry<Integer, DimensionType> ent : dimensions.entrySet())
    {
        if (ent.getValue() == type)
        {
            ret[x++] = ent.getKey();
        }
    }

    return Arrays.copyOf(ret, x);
}
 
Example 21
Project: CustomWorldGen   File: DimensionManager.java   Source Code and License 5 votes vote down vote up
public static void init()
{
    if (hasInit)
    {
        return;
    }

    hasInit = true;

    registerDimension( 0, DimensionType.OVERWORLD);
    registerDimension(-1, DimensionType.NETHER);
    registerDimension( 1, DimensionType.THE_END);
}
 
Example 22
Project: CustomWorldGen   File: DimensionManager.java   Source Code and License 5 votes vote down vote up
public static void registerDimension(int id, DimensionType type)
{
    DimensionType.getById(type.getId()); //Check if type is invalid {will throw an error} No clue how it would be invalid tho...
    if (dimensions.containsKey(id))
    {
        throw new IllegalArgumentException(String.format("Failed to register dimension for id %d, One is already registered", id));
    }
    dimensions.put(id, type);
    if (id >= 0)
    {
        dimensionMap.set(id);
    }
}
 
Example 23
Project: CustomWorldGen   File: DimensionManager.java   Source Code and License 5 votes vote down vote up
public static DimensionType getProviderType(int dim)
{
    if (!dimensions.containsKey(dim))
    {
        throw new IllegalArgumentException(String.format("Could not get provider type for dimension %d, does not exist", dim));
    }
    return dimensions.get(dim);
}
 
Example 24
Project: VoidUtils   File: VoidUtils.java   Source Code and License 5 votes vote down vote up
@EventHandler
public void init(FMLInitializationEvent event)
{
    DimensionManager.registerDimension(DIM, DimensionType.OVERWORLD); //We need to select a random dim id.
    //We also should look into not doing this but instead adding a config GUI to the TE itself.
    //And being able to select what dim we wanna move over.
    //Would be cool to be like 'I want a chunk of the nether in the overworld!

    // This is where crafting recipes would go IF I HAD ANNY!!!
}
 
Example 25
Project: CrystalMod   File: ItemWirelessPanel.java   Source Code and License 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List<String> list, boolean adv){
	super.addInformation(stack, player, list, adv);
	if(isValid(stack)){
		BlockPos pos = getBlockPos(stack);
		list.add("Panel location {"+pos.getX()+", "+pos.getY()+", "+pos.getZ()+"}");
		
		int dim = ItemNBTHelper.getInteger(stack, "PanelDim", 0);
		String name = ""+dim;
		if (!DimensionManager.isDimensionRegistered(dim)) {
	      name = Integer.toString(dim);
	    }else {
		    DimensionType type = DimensionManager.getProviderType(dim);
		    if (type == null) {
		      name = Integer.toString(dim);
		    }else {
			    name = type.getName();
			    int[] dims = DimensionManager.getDimensions(type);
			    if (dims != null && dims.length > 1) {
			      name += " " + dim;
			    }
		    }
	    }
		
		list.add("Panel Dimension: "+name);
	}
}
 
Example 26
Project: TechnicalDimensions   File: ModDimensions.java   Source Code and License 5 votes vote down vote up
public static int createDim(DimData dimData) {
    int dimId = DimensionManager.getNextFreeDimId();
    DimensionType type = DimensionType.register("technicaldimensions", dimData.name, dimId, CustomWorldProvider.class, false);
    dimData.type = type;
    dimData.id = dimId;
    Random random = new Random();
    dimData.seed = random.nextLong();
    DimensionManager.registerDimension(dimId, type);
    dimDataHashMap.put(dimId, dimData);
    dimDataList.add(dimData);

    return dimId;
}
 
Example 27
Project: nVoid   File: WorldProviderVoidEnd.java   Source Code and License 5 votes vote down vote up
@Override
   public void init()
   {
   	if (Config.voidBiomeEnd) {
   		this.biomeProvider = new BiomeProviderSingle(Biomes.SKY);
	} else {
		this.biomeProvider = new VoidBiomeProvider(world);
	}

       if (Config.endDragonEnabled) {
           NBTTagCompound nbttagcompound = this.world.getWorldInfo().getDimensionData(DimensionType.THE_END.getId());
           this.dragonFightManager = this.world instanceof WorldServer ? new DragonFightVoid((WorldServer)this.world,
				nbttagcompound.getCompoundTag("DragonFight")) : null;
       }
}
 
Example 28
Project: placementpreview   File: PlacementPreview.java   Source Code and License 5 votes vote down vote up
@Mod.EventHandler
public void postInit(FMLPostInitializationEvent event)
{
    //dimId = DimensionManager.getNextFreeDimId();
    dimId = Integer.MIN_VALUE + (int)(3.14159 * 1337);
    DimensionManager.registerDimension(dimId, DimensionType.register("pp_fake", "", dimId, WorldProviderSurface.class, false));
    fakeServer = new FakeServer(Minecraft.getMinecraft(), "saves", "pp_fake", new WorldSettings(new WorldInfo(new NBTTagCompound())), null, null, null, null);
}
 
Example 29
Project: AChunkLoader   File: AChunkLoader.java   Source Code and License 5 votes vote down vote up
@Mod.EventHandler
public void serverStarted(FMLServerStartedEvent e)
{
    World world = DimensionManager.getWorld(DimensionType.OVERWORLD.getId());
    SavedData data = SavedData.get(world);
    ChunkLoaders chunkLoadersModel = data.getChunkLoaders();

    for (ChunkLoaderPos chunkLoaderPos : chunkLoadersModel.getLoaders())
    {
        world = DimensionManager.getWorld(chunkLoaderPos.dimension);
        if (world != null && !world.isRemote)
        {
            ChunkLoaderTileEntity chunkLoader = (ChunkLoaderTileEntity) world.getTileEntity(chunkLoaderPos.pos);
            if (chunkLoader != null
                    && chunkLoader.getEnabled())
            {
                chunkLoader.setWorld(world);
                chunkLoader.validate();
                //FMLLog.log(Level.INFO, "The chunk at " + chunkLoaderPos + " has been loaded.");
            }
            else
            {
                chunkLoadersModel.removeLoader(chunkLoaderPos);
            }
        }
    }
}
 
Example 30
Project: Alchemy   File: AlchemyDimensionType.java   Source Code and License 5 votes vote down vote up
@Nullable
public static DimensionType findDimensionType(Class<?> provider) {
	for (DimensionType type : DimensionType.values())
		if (Tool.isSubclass(type.clazz, provider))
			return type;
	return null;
}
 
Example 31
Project: Alchemy   File: AlchemyDimensionType.java   Source Code and License 5 votes vote down vote up
@Nullable
public static DimensionType findDimensionType(String name) {
	for (DimensionType type : DimensionType.values())
		if (type.getName().equals(name))
			return type;
	return null;
}
 
Example 32
Project: AdventureBags   File: itemEnderBag.java   Source Code and License 5 votes vote down vote up
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) {
    ItemStack itemStackIn = playerIn.getHeldItem(hand);
    if (!worldIn.isRemote) {
        if (!ConfigurationHandler.dimension_Lock) {
            if (!isLocked) {
                Util.openGUI(playerIn,worldIn,EnumIDs.GUI_ENDER_BAG,isLocked);
                return new ActionResult<>(EnumActionResult.SUCCESS, itemStackIn);
            } else {
                return new ActionResult<>(EnumActionResult.FAIL, itemStackIn);
            }
        }
        else {
            if(playerIn.dimension == DimensionType.OVERWORLD.getId())
            {
                if (!isLocked) {
                    Util.openGUI(playerIn,worldIn,EnumIDs.GUI_ENDER_BAG,isLocked);
                    return new ActionResult<>(EnumActionResult.SUCCESS, itemStackIn);
                } else {
                    return new ActionResult<>(EnumActionResult.FAIL, itemStackIn);
                }
            }
            else {
                return new ActionResult<>(EnumActionResult.FAIL, itemStackIn);
            }
        }
    }
    return new ActionResult<>(EnumActionResult.PASS, itemStackIn);
}
 
Example 33
Project: AdventureBags   File: ItemEnderBackpack.java   Source Code and License 5 votes vote down vote up
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand)
{
    ItemStack itemStackIn = playerIn.getHeldItem(hand);

    if(!worldIn.isRemote) {
        if(!ConfigurationHandler.dimension_Lock) {
            if (!isLocked) {
                Util.openGUI(playerIn,worldIn, EnumIDs.GUI_ENDER_BACKPACK,isLocked);
                return new ActionResult<>(EnumActionResult.SUCCESS, itemStackIn);
            }
        }else
        {
            if(playerIn.dimension == DimensionType.OVERWORLD.getId())
            {
                if (!isLocked) {
                    Util.openGUI(playerIn,worldIn,EnumIDs.GUI_ENDER_BACKPACK,isLocked);
                    return new ActionResult<>(EnumActionResult.SUCCESS, itemStackIn);
                }
            }
            else
            {

            }
        }
    }
    return new ActionResult<>(EnumActionResult.PASS, itemStackIn);
}
 
Example 34
Project: justenoughdimensions   File: WorldProviderJED.java   Source Code and License 5 votes vote down vote up
@Override
public DimensionType getDimensionType()
{
    DimensionType type = null;

    try
    {
        type = DimensionManager.getProviderType(this.getDimension());
    }
    catch (IllegalArgumentException e)
    {
    }

    return type != null ? type : DimensionType.OVERWORLD;
}
 
Example 35
Project: justenoughdimensions   File: WorldUtils.java   Source Code and License 5 votes vote down vote up
@Nonnull
public static BlockPos findSuitableSpawnpoint(World world)
{
    WorldProvider provider = world.provider;
    BlockPos pos;

    // Likely end type dimensions
    if (provider.getDimensionType() == DimensionType.THE_END ||
        provider instanceof WorldProviderEnd)
    {
        pos = provider.getSpawnCoordinate();

        if (pos == null)
        {
            pos = getSuitableSpawnBlockInColumn(world, BlockPos.ORIGIN);
        }
    }
    // Likely nether type dimensions
    else if (provider.getDimensionType() == DimensionType.NETHER ||
             provider instanceof WorldProviderHell ||
             provider instanceof WorldProviderHellJED)
    {
        pos = findNetherSpawnpoint(world);
    }
    else if (world.getWorldInfo().getTerrainType() == WorldType.DEBUG_ALL_BLOCK_STATES)
    {
        pos = BlockPos.ORIGIN.up(64);
    }
    // Mostly overworld type dimensions
    else
    {
        pos = findOverworldSpawnpoint(world);
    }

    return pos;
}
 
Example 36
Project: justenoughdimensions   File: WorldProviderEndJED.java   Source Code and License 5 votes vote down vote up
@Override
public DimensionType getDimensionType()
{
    DimensionType type = null;

    try
    {
        type = DimensionManager.getProviderType(this.getDimension());
    }
    catch (IllegalArgumentException e)
    {
    }

    return type != null ? type : super.getDimensionType();
}
 
Example 37
Project: justenoughdimensions   File: DimensionConfig.java   Source Code and License 5 votes vote down vote up
private DimensionType getVanillaDimensionType(int dim)
{
    switch (dim)
    {
        case  1: return DimensionType.THE_END;
        case -1: return DimensionType.NETHER;
        default: return DimensionType.OVERWORLD;
    }
}
 
Example 38
Project: justenoughdimensions   File: DimensionTypeEntry.java   Source Code and License 5 votes vote down vote up
public DimensionType registerDimensionType()
{
    if (this.dimensionTypeName != null)
    {
        DimensionType type = null;
        try
        {
            type = DimensionType.valueOf(this.dimensionTypeName);
            JustEnoughDimensions.logInfo("Using a vanilla DimensionType (or some other existing one) '{}' for dim {}", type, this.id);
        }
        catch (Exception e) { }

        if (type == null)
        {
            type = DimensionType.OVERWORLD;
            JustEnoughDimensions.logger.warn("Failed to get a DimensionType by the name '{}' for dim {}, falling back to DimensionType.OVERWORLD",
                    this.dimensionTypeName, this.id);
        }

        return type;
    }
    else
    {
        JustEnoughDimensions.logInfo("Registering a DimensionType with values: {}", this.getDescription());
        return DimensionType.register(this.name, this.suffix, this.id, this.providerClass, this.keepLoaded);
    }
}
 
Example 39
Project: Kingdom-Keys-Re-Coded   File: MusicHandler.java   Source Code and License 5 votes vote down vote up
@Override
public void update() {
    if (menuMusic());
    else if (dimensionMusic(DimensionType.OVERWORLD.getId(), MusicType.OVERWORLD, mc.player));
    else if (dimensionMusic(DimensionType.NETHER.getId(), MusicType.NETHER, mc.player));
    else if (dimensionMusic(DimensionType.THE_END.getId(), MusicType.END, mc.player));
    else if (dimensionMusic(ModDimensions.diveToTheHeartID, MusicType.SOA, mc.player));
    else if (dimensionMusic(ModDimensions.destinyIslandsID, MusicType.DESTINYISLANDS, mc.player));
    else if (dimensionMusic(ModDimensions.traverseTownID, MusicType.TRAVERSETOWN, mc.player));
    else stopMusic();
}
 
Example 40
Project: Kingdom-Keys-Re-Coded   File: ItemHandHeldGummiShip.java   Source Code and License 5 votes vote down vote up
@SideOnly(Side.CLIENT)
@Override
public void addInformation (ItemStack stack, @Nullable World world, List<String> tooltip, ITooltipFlag flag) {
	if(Minecraft.getMinecraft().player != null)
    tooltip.add("You are in: "+DimensionType.getById(Minecraft.getMinecraft().player.dimension));
    super.addInformation(stack, world, tooltip, flag);
}