当前位置: 首页 > 知识库问答 >
问题:

Minecraft维度修改崩溃

盖泽宇
2023-03-14

我在我的mod中创建了一个维度,一个当右键点击时应该将你传送到所述维度的物品,但是当我右键点击该物品时我崩溃了。代码中没有错误,我也不清楚是什么造成了日志中的问题。我使用内置的平面块提供程序生成维度。我可以提供你需要的任何文件。很抱歉有任何奇怪的格式设置,我不太习惯。

日志:

---- Minecraft Crash Report ----
// This doesn't make any sense!

Time: 6/10/18 11:26 AM
Description: Unexpected error

java.lang.ClassCastException: net.minecraft.client.multiplayer.WorldClient cannot be cast to net.minecraft.world.WorldServer
at com.killer.sheerpig.ItemSheerTP.onItemRightClick(ItemSheerTP.java:42)
at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:164)
at net.minecraft.client.multiplayer.PlayerControllerMP.sendUseItem(PlayerControllerMP.java:430)
at net.minecraft.client.Minecraft.func_147121_ag(Minecraft.java:1558)
at net.minecraft.client.Minecraft.runTick(Minecraft.java:2045)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1040)
at net.minecraft.client.Minecraft.run(Minecraft.java:962)
at net.minecraft.client.main.Main.main(Main.java:164)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
at GradleStart.main(Unknown Source)

A detailed walkthrough of the error, its code path and all known details is as follows:

-- Head --
Stacktrace:
at com.killer.sheerpig.ItemSheerTP.onItemRightClick(ItemSheerTP.java:42)
at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:164)
at net.minecraft.client.multiplayer.PlayerControllerMP.sendUseItem(PlayerControllerMP.java:430)
at net.minecraft.client.Minecraft.func_147121_ag(Minecraft.java:1558)

-- Affected level --
Details:
Level name: MpServer
All players: 1 total; [EntityClientPlayerMP['Player629'/142, l='MpServer', x=-210.65, y=73.62, z=-229.70]]
Chunk stats: MultiplayerChunkCache: 289, 289
Level seed: 0
Level generator: ID 00 - default, ver 1. Features enabled: false
Level generator options: 
Level spawn location: World: (-207,64,-241), Chunk: (at 1,4,15 in -13,-16; contains blocks -208,0,-256 to -193,255,-241), Region: (-1,-1; contains chunks -32,-32 to -1,-1, blocks -512,0,-512 to -1,255,-1)
Level time: 6986 game time, 6986 day time
Level dimension: 0
Level storage version: 0x00000 - Unknown?
Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)
Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false
Forced entities: 97 total; [EntityBat['Bat'/522, l='MpServer', x=-277.94, y=17.33, z=-158.72], EntityZombie['Zombie'/11, l='MpServer', x=-284.91, y=21.00, z=-257.53], EntityZombie['Zombie'/12, l='MpServer', x=-288.50, y=20.00, z=-260.50], EntitySkeleton['Skeleton'/13, l='MpServer', x=-287.63, y=20.00, z=-259.69], EntityZombie['Zombie'/15, l='MpServer', x=-274.00, y=11.00, z=-288.44], EntitySkeleton['Skeleton'/16, l='MpServer', x=-283.88, y=19.00, z=-277.50], EntityZombie['Zombie'/17, l='MpServer', x=-278.03, y=21.00, z=-268.31], EntityBat['Bat'/18, l='MpServer', x=-273.16, y=50.17, z=-234.47], EntityZombie['Zombie'/19, l='MpServer', x=-278.06, y=19.00, z=-155.63], EntityBat['Bat'/278, l='MpServer', x=-284.24, y=21.07, z=-259.23], EntityZombie['Zombie'/24, l='MpServer', x=-271.31, y=49.00, z=-308.59], EntityCreeper['Creeper'/25, l='MpServer', x=-272.00, y=50.00, z=-309.47], EntityHorse['Donkey'/26, l='MpServer', x=-267.88, y=67.00, z=-306.97], EntityPig['Pig'/28, l='MpServer', x=-257.88, y=67.00, z=-290.09], EntityPig['Pig'/29, l='MpServer', x=-265.47, y=67.00, z=-290.31], EntityPig['Pig'/30, l='MpServer', x=-257.81, y=67.00, z=-294.78], EntitySkeleton['Skeleton'/31, l='MpServer', x=-266.13, y=25.00, z=-280.56], EntitySkeleton['Skeleton'/32, l='MpServer', x=-261.50, y=26.00, z=-277.50], EntityCreeper['Creeper'/33, l='MpServer', x=-256.03, y=21.00, z=-286.34], EntityEnderman['Enderman'/34, l='MpServer', x=-257.88, y=22.00, z=-246.50], EntityChicken['Chicken'/35, l='MpServer', x=-260.44, y=81.00, z=-253.53], EntityEnderman['Enderman'/36, l='MpServer', x=-262.69, y=13.00, z=-210.25], EntityCreeper['Creeper'/37, l='MpServer', x=-253.19, y=17.69, z=-210.63], EntitySkeleton['Skeleton'/38, l='MpServer', x=-264.13, y=40.00, z=-222.41], EntitySkeleton['Skeleton'/39, l='MpServer', x=-268.69, y=14.00, z=-196.78], EntitySkeleton['Skeleton'/40, l='MpServer', x=-267.34, y=18.00, z=-205.03], EntitySkeleton['Skeleton'/41, l='MpServer', x=-268.38, y=17.00, z=-204.22], EntityWitch['Witch'/42, l='MpServer', x=-270.84, y=17.00, z=-169.50], EntitySkeleton['Skeleton'/43, l='MpServer', x=-261.94, y=18.00, z=-171.50], EntitySkeleton['Skeleton'/44, l='MpServer', x=-257.50, y=18.00, z=-165.50], EntityZombie['Zombie'/45, l='MpServer', x=-260.50, y=17.00, z=-167.50], EntityPig['Pig'/49, l='MpServer', x=-246.19, y=67.00, z=-289.78], EntityHorse['Donkey'/50, l='MpServer', x=-255.88, y=67.00, z=-289.97], EntityCreeper['Creeper'/51, l='MpServer', x=-255.63, y=21.00, z=-287.22], EntityCreeper['Creeper'/52, l='MpServer', x=-255.69, y=21.00, z=-284.41], EntityWolf['Wolf'/53, l='MpServer', x=-254.84, y=67.00, z=-287.56], EntityBat['Bat'/54, l='MpServer', x=-247.66, y=22.70, z=-262.75], EntityBat['Bat'/55, l='MpServer', x=-248.41, y=24.00, z=-268.13], EntityBat['Bat'/56, l='MpServer', x=-246.72, y=22.95, z=-259.47], EntityWolf['Wolf'/57, l='MpServer', x=-255.47, y=67.00, z=-274.22], EntitySheep['Sheep'/58, l='MpServer', x=-252.16, y=78.00, z=-248.78], EntityChicken['Chicken'/59, l='MpServer', x=-255.44, y=78.00, z=-250.44], EntityChicken['Chicken'/60, l='MpServer', x=-248.16, y=78.00, z=-243.66], EntitySpider['Spider'/61, l='MpServer', x=-244.47, y=16.00, z=-235.72], EntityCreeper['Creeper'/62, l='MpServer', x=-254.47, y=17.00, z=-207.97], EntityCreeper['Creeper'/63, l='MpServer', x=-255.72, y=18.00, z=-208.44], EntitySkeleton['Skeleton'/64, l='MpServer', x=-253.53, y=16.00, z=-207.72], EntityBat['Bat'/65, l='MpServer', x=-253.94, y=14.00, z=-206.63], EntitySkeleton['Skeleton'/74, l='MpServer', x=-222.50, y=27.00, z=-273.50], EntityBat['Bat'/75, l='MpServer', x=-212.25, y=14.10, z=-260.50], EntitySkeleton['Skeleton'/76, l='MpServer', x=-214.09, y=25.00, z=-266.66], EntitySkeleton['Skeleton'/78, l='MpServer', x=-211.54, y=26.02, z=-222.71], EntitySheep['Sheep'/79, l='MpServer', x=-212.19, y=62.09, z=-224.53], EntitySquid['Squid'/80, l='MpServer', x=-224.84, y=38.34, z=-198.50], EntityChicken['Chicken'/81, l='MpServer', x=-195.56, y=61.90, z=-303.44], EntityBat['Bat'/82, l='MpServer', x=-199.56, y=41.23, z=-274.25], EntityZombie['Zombie'/83, l='MpServer', x=-208.47, y=18.06, z=-267.16], EntitySpider['Spider'/84, l='MpServer', x=-200.72, y=16.00, z=-269.28], EntitySkeleton['Skeleton'/85, l='MpServer', x=-206.50, y=22.00, z=-273.09], EntityZombie['Zombie'/86, l='MpServer', x=-194.47, y=18.00, z=-268.97], EntityBat['Bat'/87, l='MpServer', x=-202.41, y=15.10, z=-255.78], EntityCreeper['Creeper'/88, l='MpServer', x=-203.50, y=16.00, z=-244.69], EntityCreeper['Creeper'/89, l='MpServer', x=-206.34, y=21.00, z=-229.00], EntityZombie['Zombie'/90, l='MpServer', x=-204.50, y=25.00, z=-211.06], EntityBat['Bat'/91, l='MpServer', x=-202.69, y=23.10, z=-221.31], EntityCreeper['Creeper'/92, l='MpServer', x=-191.88, y=20.00, z=-217.75], EntityBat['Bat'/96, l='MpServer', x=-186.44, y=17.10, z=-274.25], EntityZombie['Zombie'/97, l='MpServer', x=-187.88, y=17.00, z=-270.38], EntityCreeper['Creeper'/98, l='MpServer', x=-181.03, y=13.00, z=-225.53], EntitySkeleton['Skeleton'/99, l='MpServer', x=-189.50, y=33.00, z=-239.50], EntitySkeleton['Skeleton'/100, l='MpServer', x=-186.03, y=22.00, z=-216.56], EntityBat['Bat'/106, l='MpServer', x=-162.59, y=19.10, z=-264.75], EntityBat['Bat'/107, l='MpServer', x=-165.75, y=20.23, z=-261.47], EntitySquid['Squid'/108, l='MpServer', x=-166.19, y=50.81, z=-245.97], EntitySkeleton['Skeleton'/109, l='MpServer', x=-167.09, y=13.00, z=-235.63], EntitySquid['Squid'/112, l='MpServer', x=-156.94, y=49.34, z=-277.22], EntityEnderman['Enderman'/113, l='MpServer', x=-156.69, y=16.00, z=-249.25], EntityZombie['Zombie'/114, l='MpServer', x=-147.56, y=32.00, z=-254.75], EntityCreeper['Creeper'/115, l='MpServer', x=-154.50, y=34.00, z=-255.50], EntityCreeper['Creeper'/116, l='MpServer', x=-159.50, y=14.00, z=-219.50], EntitySkeleton['Skeleton'/117, l='MpServer', x=-146.50, y=12.00, z=-204.94], EntityZombie['Zombie'/118, l='MpServer', x=-146.31, y=14.00, z=-187.06], EntityZombie['Zombie'/119, l='MpServer', x=-144.44, y=17.00, z=-171.56], EntityZombie['Zombie'/120, l='MpServer', x=-144.50, y=17.00, z=-172.50], EntityCreeper['Creeper'/121, l='MpServer', x=-144.53, y=19.00, z=-167.97], EntitySkeleton['Skeleton'/122, l='MpServer', x=-147.06, y=22.00, z=-150.53], EntityZombie['Zombie'/123, l='MpServer', x=-144.50, y=21.00, z=-159.50], EntityBat['Bat'/125, l='MpServer', x=-138.56, y=31.10, z=-251.72], EntityZombie['Zombie'/126, l='MpServer', x=-137.27, y=26.00, z=-246.47], EntityCreeper['Creeper'/127, l='MpServer', x=-142.50, y=28.00, z=-243.50], EntityCreeper['Creeper'/128, l='MpServer', x=-141.50, y=31.00, z=-254.50], EntitySkeleton['Skeleton'/129, l='MpServer', x=-132.84, y=24.00, z=-247.78], EntityBat['Bat'/130, l='MpServer', x=-141.22, y=26.45, z=-257.66], EntityZombie['Zombie'/134, l='MpServer', x=-143.50, y=17.00, z=-172.50], EntityBat['Bat'/135, l='MpServer', x=-145.88, y=22.73, z=-149.25], EntityZombie['Zombie'/136, l='MpServer', x=-142.53, y=22.00, z=-153.94], EntityClientPlayerMP['Player629'/142, l='MpServer', x=-210.65, y=73.62, z=-229.70]]
Retry entities: 0 total; []
Server brand: fml,forge
Server type: Integrated singleplayer server
Stacktrace:
at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:415)
at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2567)
at net.minecraft.client.Minecraft.run(Minecraft.java:991)
at net.minecraft.client.main.Main.main(Main.java:164)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
at GradleStart.main(Unknown Source)

-- System Details --
Details:
Minecraft Version: 1.7.10
Operating System: Windows 10 (amd64) version 10.0
Java Version: 1.8.0_161, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 864018640 bytes (823 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 95
FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1558 6 mods loaded, 6 mods active
States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
UCHIJAAAA   mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) 
UCHIJAAAA   FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar) 
UCHIJAAAA   Forge{10.13.4.1558} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar) 
UCHIJAAAA   examplemod{1.0} [Example Mod] (bin) 
UCHIJAAAA   killer_galacticmod{1.0} [killer_galacticmod] (bin) 
UCHIJAAAA   sheerpig{1.0} [sheerpig] (bin) 
GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.6.0 NVIDIA 397.64' Renderer: 'GeForce GTX 1080/PCIe/SSE2'
Launched Version: 1.7.10
LWJGL: 2.9.1
OpenGL: GeForce GTX 1080/PCIe/SSE2 GL version 4.6.0 NVIDIA 397.64, NVIDIA Corporation
GL Caps: Using GL 1.3 multitexturing.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Anisotropic filtering is supported and maximum anisotropy is 16.
Shaders are available because OpenGL 2.1 is supported.

Is Modded: Definitely; Client brand changed to 'fml,forge'
Type: Client (map_client.txt)
Resource Packs: []
Current Language: English (US)
Profiler Position: N/A (disabled)
Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
Anisotropic Filtering: Off (1)



世界提供程序:

package com.killer.sheerpig;

import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.WorldProvider;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.biome.WorldChunkManagerHell;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunkProvider;

public class WorldProviderSheer extends WorldProvider
{
public void registerWorldChunkManager()
{
    this.worldChunkMgr = new WorldChunkManagerHell(BiomeGenBase.desert/*change*/, 0.1F);
    this.dimensionId = SheerPig.sheerdimension;
}

@Override
public String getSaveFolder()
{
    return "DIM-Sheer";
}

@Override
public String getWelcomeMessage()
{
    return "Entering Pig Land";
}

@Override
public String getDepartMessage()
{
    return "Leaving Pig Land";
}

@Override
public boolean canRespawnHere()
{
    return true;
}

@Override
public IChunkProvider createChunkGenerator()
{
    return new ChunkProviderSheer(worldObj, worldObj.getSeed(), true, field_82913_c);
}

@Override
public String getDimensionName()
{
    return "Sheer";
}

//@Override
public ChunkCoordinates getEnterancePortalLocation()
{
    return null;
}

@Override
public boolean canDoLightning(Chunk chunk)
{
    return true;
}

@Override
public boolean canDoRainSnowIce(Chunk chunk)
{
    return false;
}
}



块提供程序:

package com.killer.sheerpig;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.init.Blocks;
import net.minecraft.util.IProgressUpdate;
import net.minecraft.world.ChunkPosition;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
import net.minecraft.world.gen.FlatGeneratorInfo;
import net.minecraft.world.gen.FlatLayerInfo;
import net.minecraft.world.gen.MapGenBase;
import net.minecraft.world.gen.feature.WorldGenDungeons;
import net.minecraft.world.gen.feature.WorldGenLakes;
import net.minecraft.world.gen.structure.MapGenMineshaft;
import net.minecraft.world.gen.structure.MapGenScatteredFeature;
import net.minecraft.world.gen.structure.MapGenStronghold;
import net.minecraft.world.gen.structure.MapGenStructure;
import net.minecraft.world.gen.structure.MapGenVillage;

public class ChunkProviderSheer implements IChunkProvider
{
private World worldObj;
private Random random;
private final Block[] cachedBlockIDs = new Block[256];
private final byte[] cachedBlockMetadata = new byte[256];
private final FlatGeneratorInfo flatWorldGenInfo;
private final List structureGenerators = new ArrayList();
private final boolean hasDecoration;
private final boolean hasDungeons;
private WorldGenLakes waterLakeGenerator;
private WorldGenLakes lavaLakeGenerator;
private static final String __OBFID = "CL_00000391";

public ChunkProviderSheer(World p_i2004_1_, long p_i2004_2_, boolean p_i2004_4_, String p_i2004_5_)
{
    this.worldObj = p_i2004_1_;
    this.random = new Random(p_i2004_2_);
    this.flatWorldGenInfo = FlatGeneratorInfo.createFlatGeneratorFromString(p_i2004_5_);

    if (p_i2004_4_)
    {
        Map map = this.flatWorldGenInfo.getWorldFeatures();

        if (map.containsKey("village"))
        {
            Map map1 = (Map)map.get("village");

            if (!map1.containsKey("size"))
            {
                map1.put("size", "1");
            }

            this.structureGenerators.add(new MapGenVillage(map1));
        }

        if (map.containsKey("biome_1"))
        {
            this.structureGenerators.add(new MapGenScatteredFeature((Map)map.get("biome_1")));
        }

        if (map.containsKey("mineshaft"))
        {
            this.structureGenerators.add(new MapGenMineshaft((Map)map.get("mineshaft")));
        }

        if (map.containsKey("stronghold"))
        {
            this.structureGenerators.add(new MapGenStronghold((Map)map.get("stronghold")));
        }
    }

    this.hasDecoration = this.flatWorldGenInfo.getWorldFeatures().containsKey("decoration");

    if (this.flatWorldGenInfo.getWorldFeatures().containsKey("lake"))
    {
        this.waterLakeGenerator = new WorldGenLakes(Blocks.water);
    }

    if (this.flatWorldGenInfo.getWorldFeatures().containsKey("lava_lake"))
    {
        this.lavaLakeGenerator = new WorldGenLakes(Blocks.lava);
    }

    this.hasDungeons = this.flatWorldGenInfo.getWorldFeatures().containsKey("dungeon");
    Iterator iterator = this.flatWorldGenInfo.getFlatLayers().iterator();

    while (iterator.hasNext())
    {
        FlatLayerInfo flatlayerinfo = (FlatLayerInfo)iterator.next();

        for (int j = flatlayerinfo.getMinY(); j < flatlayerinfo.getMinY() + flatlayerinfo.getLayerCount(); ++j)
        {
            this.cachedBlockIDs[j] = flatlayerinfo.func_151536_b();
            this.cachedBlockMetadata[j] = (byte)flatlayerinfo.getFillBlockMeta();
        }
    }
}

/**
 * loads or generates the chunk at the chunk location specified
 */
public Chunk loadChunk(int p_73158_1_, int p_73158_2_)
{
    return this.provideChunk(p_73158_1_, p_73158_2_);
}

/**
 * Will return back a chunk, if it doesn't exist and its not a MP client it will generates all the blocks for the
 * specified chunk from the map seed and chunk seed
 */
public Chunk provideChunk(int p_73154_1_, int p_73154_2_)
{
    Chunk chunk = new Chunk(this.worldObj, p_73154_1_, p_73154_2_);
    int l;

    for (int k = 0; k < this.cachedBlockIDs.length; ++k)
    {
        Block block = this.cachedBlockIDs[k];

        if (block != null)
        {
            l = k >> 4;
            ExtendedBlockStorage extendedblockstorage = chunk.getBlockStorageArray()[l];

            if (extendedblockstorage == null)
            {
                extendedblockstorage = new ExtendedBlockStorage(k, !this.worldObj.provider.hasNoSky);
                chunk.getBlockStorageArray()[l] = extendedblockstorage;
            }

            for (int i1 = 0; i1 < 16; ++i1)
            {
                for (int j1 = 0; j1 < 16; ++j1)
                {
                    extendedblockstorage.func_150818_a(i1, k & 15, j1, block);
                    extendedblockstorage.setExtBlockMetadata(i1, k & 15, j1, this.cachedBlockMetadata[k]);
                }
            }
        }
    }

    chunk.generateSkylightMap();
    BiomeGenBase[] abiomegenbase = this.worldObj.getWorldChunkManager().loadBlockGeneratorData((BiomeGenBase[])null, p_73154_1_ * 16, p_73154_2_ * 16, 16, 16);
    byte[] abyte = chunk.getBiomeArray();

    for (l = 0; l < abyte.length; ++l)
    {
        abyte[l] = (byte)abiomegenbase[l].biomeID;
    }

    Iterator iterator = this.structureGenerators.iterator();

    while (iterator.hasNext())
    {
        MapGenBase mapgenbase = (MapGenBase)iterator.next();
        mapgenbase.func_151539_a(this, this.worldObj, p_73154_1_, p_73154_2_, (Block[])null);
    }

    chunk.generateSkylightMap();
    return chunk;
}

/**
 * Checks to see if a chunk exists at x, y
 */
public boolean chunkExists(int p_73149_1_, int p_73149_2_)
{
    return true;
}

/**
 * Populates chunk with ores etc etc
 */
public void populate(IChunkProvider p_73153_1_, int p_73153_2_, int p_73153_3_)
{
    int k = p_73153_2_ * 16;
    int l = p_73153_3_ * 16;
    BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(k + 16, l + 16);
    boolean flag = false;
    this.random.setSeed(this.worldObj.getSeed());
    long i1 = this.random.nextLong() / 2L * 2L + 1L;
    long j1 = this.random.nextLong() / 2L * 2L + 1L;
    this.random.setSeed((long)p_73153_2_ * i1 + (long)p_73153_3_ * j1 ^ this.worldObj.getSeed());
    Iterator iterator = this.structureGenerators.iterator();

    while (iterator.hasNext())
    {
        MapGenStructure mapgenstructure = (MapGenStructure)iterator.next();
        boolean flag1 = mapgenstructure.generateStructuresInChunk(this.worldObj, this.random, p_73153_2_, p_73153_3_);

        if (mapgenstructure instanceof MapGenVillage)
        {
            flag |= flag1;
        }
    }

    int l1;
    int i2;
    int j2;

    if (this.waterLakeGenerator != null && !flag && this.random.nextInt(4) == 0)
    {
        l1 = k + this.random.nextInt(16) + 8;
        i2 = this.random.nextInt(256);
        j2 = l + this.random.nextInt(16) + 8;
        this.waterLakeGenerator.generate(this.worldObj, this.random, l1, i2, j2);
    }

    if (this.lavaLakeGenerator != null && !flag && this.random.nextInt(8) == 0)
    {
        l1 = k + this.random.nextInt(16) + 8;
        i2 = this.random.nextInt(this.random.nextInt(248) + 8);
        j2 = l + this.random.nextInt(16) + 8;

        if (i2 < 63 || this.random.nextInt(10) == 0)
        {
            this.lavaLakeGenerator.generate(this.worldObj, this.random, l1, i2, j2);
        }
    }

    if (this.hasDungeons)
    {
        for (l1 = 0; l1 < 8; ++l1)
        {
            i2 = k + this.random.nextInt(16) + 8;
            j2 = this.random.nextInt(256);
            int k1 = l + this.random.nextInt(16) + 8;
            (new WorldGenDungeons()).generate(this.worldObj, this.random, i2, j2, k1);
        }
    }

    if (this.hasDecoration)
    {
        biomegenbase.decorate(this.worldObj, this.random, k, l);
    }
}

/**
 * Two modes of operation: if passed true, save all Chunks in one go.  If passed false, save up to two chunks.
 * Return true if all chunks have been saved.
 */
public boolean saveChunks(boolean p_73151_1_, IProgressUpdate p_73151_2_)
{
    return true;
}

/**
 * Save extra data not associated with any Chunk.  Not saved during autosave, only during world unload.  Currently
 * unimplemented.
 */
public void saveExtraData() {}

/**
 * Unloads chunks that are marked to be unloaded. This is not guaranteed to unload every such chunk.
 */
public boolean unloadQueuedChunks()
{
    return false;
}

/**
 * Returns if the IChunkProvider supports saving.
 */
public boolean canSave()
{
    return true;
}

/**
 * Converts the instance data to a readable string.
 */
public String makeString()
{
    return "FlatLevelSource";
}

/**
 * Returns a list of creatures of the specified type that can spawn at the given location.
 */
public List getPossibleCreatures(EnumCreatureType p_73155_1_, int p_73155_2_, int p_73155_3_, int p_73155_4_)
{
    BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(p_73155_2_, p_73155_4_);
    return biomegenbase.getSpawnableList(p_73155_1_);
}

public ChunkPosition func_147416_a(World p_147416_1_, String p_147416_2_, int p_147416_3_, int p_147416_4_, int p_147416_5_)
{
    if ("Stronghold".equals(p_147416_2_))
    {
        Iterator iterator = this.structureGenerators.iterator();

        while (iterator.hasNext())
        {
            MapGenStructure mapgenstructure = (MapGenStructure)iterator.next();

            if (mapgenstructure instanceof MapGenStronghold)
            {
                return mapgenstructure.func_151545_a(p_147416_1_, p_147416_3_, p_147416_4_, p_147416_5_);
            }
        }
    }

    return null;
}

public int getLoadedChunkCount()
{
    return 0;
}

public void recreateStructures(int p_82695_1_, int p_82695_2_)
{
    Iterator iterator = this.structureGenerators.iterator();

    while (iterator.hasNext())
    {
        MapGenStructure mapgenstructure = (MapGenStructure)iterator.next();
        mapgenstructure.func_151539_a(this, this.worldObj, p_82695_1_, p_82695_2_, (Block[])null);
    }
}
}



传送器项目:

package com.killer.sheerpig;

import net.minecraft.item.Item;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.DimensionManager;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;

import com.killer.sheerpig.WorldProviderSheer;

public class ItemSheerTP extends Item
{
public static int SheerDimensionId = DimensionManager.getNextFreeDimId();
public String name = "SheerTP";

public ItemSheerTP()
{
    setUnlocalizedName(SheerPig.MODID + "_" + name);
    setCreativeTab(SheerPig.sheerTab);
    setTextureName(SheerPig.MODID + ":" + name);
    maxStackSize = 1;
}

@Override
public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player)
{
    if (player.dimension == SheerDimensionId)
    {

    }
    else
    {
        WorldServer worldserver = (WorldServer) world;
        EntityPlayerMP playerMP = (EntityPlayerMP) player;
        playerMP.mcServer.getConfigurationManager().transferPlayerToDimension(playerMP, 229, new SheerTeleporter(worldserver));
    }
return item;
}
}

共有1个答案

申屠喜
2023-03-14
java.lang.ClassCastException: 
net.minecraft.client.multiplayer.WorldClient cannot be cast to
net.minecraft.world.WorldServer
at com.killer.sheerpig.ItemSheerTP.onItemRightClick(ItemSheerTP.java:42)

再次阅读错误消息,您将看到问题出在onitemrightclick的else块的第一个命令处的最后一个代码段中。

问题是,通过强制转换,您在该行中明确地声明worldWorldServer”。但它显然不是--而是WorldClient类型。

您可能更喜欢这样的内容,尤其是这个片段:

Minecraft mc = Minecraft.getMinecraft();
if (mc.getIntegratedServer())
{
    worldServer = mc.getIntegratedServer().worldServerForDimension(mc.thePlayer.dimension);
}
else if (MinecraftServer.getServer())
{
    worldServer = MinecraftServer.getServer().worldServerForDimension(mc.thePlayer.dimension);
}
 类似资料:
  • 我试图添加我自己的维度到Minecraft只使用它的代码(没有外部程序,mod,插件等),我有困难这样做。我已经创建了我的维度,它工作得很好,我可以通过替换现有的维度来达到它(用nether测试,工作得很好),但是我似乎无法找到如何在不替换现有维度的情况下添加维度。经过一些测试,我相信在某个地方有3个维度的极限,这些维度是世界的,结束的,和阴间的。我无法想象没有办法添加另一个维度,因为如果决定添加

  • 我在1.12.2上有一个minecraft Moded服务器,它在大多数情况下都能工作,但它给了我一个错误。 minecraft服务器是,我在lubuntu上,使用OpenJDK10。 我有这些mod: GalacticraftCore-4.0.2.236,GalacticraftPlanets-4.0.2.236,MicdoodleCore-4.0.2.236,和漏斗1.5 我的系统是: 分发服

  • 问题内容: 我有一个meta标签(苹果智能横幅),我想即时修改参数。但是,目前无法正常工作: 我假设在创建头部之前调用了ng-init?如果可以,我可以通过加载方法修改meta吗? 这是HTML: 部分: 控制器: 问题答案: 尝试服务和指令 http://jsfiddle.net/VnXYB/

  • 我在前端有一个应用程序,我使用角,后端我使用Spring Boot。在我的前端,我必须上传一个CSV文件,在表中插入数据。所以我将数据发送到保存它的后端。我的问题:我有一个类个人与关系@OneTo很多到其他类像comtes。所以当我尝试使用此Rest服务获取所有个人:http://localhost:8080/api/individus时,我有一个解析json数据错误。 这是我的班级个人: 公共类

  • 修改绘图曲线精度 默认的,Open-Falcon只保存最近12小时的原始监控数据,12小时之后的数据被降低精度、采样存储。 如果默认的精度不能满足你的需求,可以按照如下步骤,修改绘图曲线的存储精度。 第一步,修改graph组件的RRA,并重新编译graph组件 graph组件的RRA,定义在文件 graph/rrdtool/rrdtool.go中,默认如下: // RRA.Point.Size c

  • 每次启动Farming Valley服务器时,都会出现以下错误: 我基本上没有这方面的经验,我不明白这是怎么回事。如有任何帮助,我们将不胜感激!提前道谢。知道我从OVH那里买了一台服务器可能会很好