Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.7.10] [Solved] usePortal does not work in this version.


Recommended Posts

I have not found someone to help me really. :'(

To solve this topic I decompiled the Aether mod 1.2.5 using the MCP, but only 90% of my poblema was completed.

http://www.minecraftforge.net/forum/index.php/topic,31521.0.html

 

The public void usePortal(int par1, Teleporter teleporter) it does not exist anymore.

 

I need something to replace it:

minecraft.usePortal(((BlockAetherPortal)AetherBlocks.Portal).getDimNumber(minecraft.thePlayer), teleporter);

 

The code adapted to 1.7.10:

 

public class TickHandler 
{
    private int tickCounter;

    @SubscribeEvent
    public void onTick(TickEvent.ServerTickEvent event)
    {
        if (event.side == Side.SERVER && event.phase == TickEvent.Phase.START)
        {
            this.onTickInGame(event.type);
        }
    }

    public void onTickInGame(TickEvent.Type type)
    {    	
        if (Minecraft.getMinecraft().thePlayer != null)
        {
            EntityClientPlayerMP entityplayersp = Minecraft.getMinecraft().thePlayer;

            if (((EntityPlayer)(entityplayersp)).dimension == mcreator_aether.DIMID && ((EntityPlayer)(entityplayersp)).posY < -2D)
            {
                Class class1 = null;
                NBTTagCompound nbttagcompound = new NBTTagCompound();

                if (((EntityPlayer)(entityplayersp)).ridingEntity != null)
                {
                    class1 = ((EntityPlayer)(entityplayersp)).ridingEntity.getClass();
                    ((EntityPlayer)(entityplayersp)).ridingEntity.writeToNBT(nbttagcompound);
                    ((EntityPlayer)(entityplayersp)).ridingEntity.setDead();
                }

                double d = ((EntityPlayer)(entityplayersp)).motionY;
                minecraft.usePortal(((BlockAetherPortal)AetherBlocks.Portal).getDimNumber(minecraft.thePlayer), teleporter);
                Minecraft.getMinecraft().thePlayer.setLocationAndAngles(((EntityPlayer)(entityplayersp)).posX, 256D, ((EntityPlayer)(entityplayersp)).posZ, ((EntityPlayer)(entityplayersp)).rotationYaw, 0.0F);

                if (class1 != null && !Minecraft.getMinecraft().theWorld.isRemote)
                {
                    Object obj = null;

                    try
                    {
                        Entity entity1 = (Entity)class1.getDeclaredConstructor(new Class[]
                                {
                                    net.minecraft.world.World.class
                                }).newInstance(new Object[]
                                        {
                                		Minecraft.getMinecraft().theWorld
                                        });
                        entity1.readFromNBT(nbttagcompound);
                        entity1.setLocationAndAngles(((EntityPlayer)(entityplayersp)).posX, 256D, ((EntityPlayer)(entityplayersp)).posZ, ((EntityPlayer)(entityplayersp)).rotationYaw, 0.0F);
                        Minecraft.getMinecraft().theWorld.spawnEntityInWorld(entity1);
                        entityplayersp.mountEntity(entity1);
                    }
                    catch (Exception exception)
                    {
                        System.out.println("Failed to transfer mount.");
                    }
                }
                
                if (Minecraft.getMinecraft().gameSettings.difficulty == EnumDifficulty.PEACEFUL)
                {
                    entityplayersp.fallDistance = -64F;
                }
                
            }
        }
    }
}

 

Who can help me, please write in java, but do not try to explain why I learned Java alone. :'(

 

This is very important for me because I'm developing a dimension at the sky with my ideas and how the sky is necessary that there is a teleport if a Player fall out of the island. ;D

 

The code is almost perfect even though the minecraft 1.2.5.

 

Please help me. ;) :'( :'( :'(

Link to post
Share on other sites

This check is pointless:

event.side == Side.SERVER

You are alredy on server.

 

ServerTickEvent runs for WHOLE server, twice per tick (phases).

1. You cant use Minecraft.class for server tick event. Minecraft.class in client-side.

2. If you want to check all players - use world#playerList or something (look into world class, there is list of all online players in given world).

Overally - you are missing the point of sided methods.

world/player in Minecraft is the object of CLIENT, not server.

 

E.g: this check;

!Minecraft.getMinecraft().theWorld.isRemote

Is literally stupid.

 

Please read more about logical sides and tick events.

 

Also: consider using WorldTickEvent - it runs like server tick, but per-world.

1.7.10 is no longer supported by forge, you are on your own.

Link to post
Share on other sites

My code does not work when I set for EntityPlayerMP.

There is no teleport to one player.

What I missed?

 


import mod.mcreator.mcreator_sky;
import mod.mcreator.mcreator_sky.TeleporterDimensionMod;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.relauncher.Side;

public class TickInGame
{
    private int tickCounter;

    @SubscribeEvent
    public void onTick(TickEvent.ServerTickEvent event)
    {
        if (event.side == Side.SERVER && event.phase == TickEvent.Phase.START)
        {
            this.tick(event.type);
        }
    }

    public Entity p_149670_5_;
    
    public void tick(TickEvent.Type type)
    {
        if ((p_149670_5_ instanceof EntityPlayerMP))
        {
		EntityPlayerMP thePlayer = (EntityPlayerMP)p_149670_5_;

            if (((EntityPlayer)(thePlayer)).dimension == mcreator_sky.DIMID && ((EntityPlayer)(thePlayer)).posY < -2D)
            {
                Class class1 = null;
                NBTTagCompound nbttagcompound = new NBTTagCompound();

                if (((EntityPlayer)(thePlayer)).ridingEntity != null)
                {
                    class1 = ((EntityPlayer)(thePlayer)).ridingEntity.getClass();
                    ((EntityPlayer)(thePlayer)).ridingEntity.writeToNBT(nbttagcompound);
                    ((EntityPlayer)(thePlayer)).ridingEntity.setDead();
                }

                double d = ((EntityPlayer)(thePlayer)).motionY;
                
                thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, mcreator_sky.DIMID, new TeleporterDimensionMod(thePlayer.mcServer.worldServerForDimension(mcreator_sky.DIMID)));
                ((EntityPlayer)(thePlayer)).setLocationAndAngles(((EntityPlayer)(thePlayer)).posX, 127D, ((EntityPlayer)(thePlayer)).posZ, ((EntityPlayer)(thePlayer)).rotationYaw, 0.0F);

                if (class1 != null && !thePlayer.worldObj.isRemote)
                {
                    Object obj = null;

                    try
                    {
                        Entity entity1 = (Entity)class1.getDeclaredConstructor(new Class[]
                                {
                                    net.minecraft.world.World.class
                                }).newInstance(new Object[]
                                        {
                                		thePlayer.worldObj
                                        });
                        entity1.readFromNBT(nbttagcompound);
                        entity1.setLocationAndAngles(((EntityPlayer)(thePlayer)).posX, 127D, ((EntityPlayer)(thePlayer)).posZ, ((EntityPlayer)(thePlayer)).rotationYaw, 0.0F);
                        thePlayer.worldObj.spawnEntityInWorld(entity1);
                        thePlayer.mountEntity(entity1);
                    }
                    catch (Exception exception)
                    {
                        System.out.println("Failed to transfer mount.");
                    }
                }

                thePlayer.motionX = thePlayer.motionZ = 0.0D;
                thePlayer.motionY = d;
            }
        }
    }
}

 

Please help me!

And thank you!

Link to post
Share on other sites

You have no clue about what are you doing, do you?

 

Please learn basic java (or logic), because if you can't see the the fact that you are using nulls, then I really can't help you, even if I tried REALLY hard, sorry.

 

public Entity p_149670_5_;

 

Also: "decode" your code (names).

1.7.10 is no longer supported by forge, you are on your own.

Link to post
Share on other sites
  • 2 weeks later...

I managed to do my work event.

It works with many things, but does not work with teleport.

 

Event:

public class mcreator_tickHandler
{
    @SubscribeEvent
    public void tick(PlayerTickEvent event)
    {    	
        if (event.player.dimension == mcreator_sky.DIMID && event.player.posY < -2.0D)
        {
        	TestEnvironmentMod.teleportPlayerTosky(event.player, true);
        }
}
}

Teleport:

public static TeleporterDimensionMod skyTeleporter;

private static void transferPlayer(EntityPlayer player, int dimID, TeleporterDimensionMod tele, boolean aboveWorld)
{
    double posX = player.posX;
    double posZ = player.posZ;
    Entity mount = null;
    Entity mountedBy = null;

    if (player.worldObj.isRemote)
    {
    	mcreator_skyOverlays.displayFakeDownload(true);
    }
    else
    {
        Entity transferMount = player.ridingEntity;
        Entity transferMountedBy = player.riddenByEntity;

        if (player.ridingEntity != null)
        {
            player.ridingEntity.riddenByEntity = null;
        }

        if (player.riddenByEntity != null)
        {
            player.riddenByEntity.ridingEntity = null;
        }

        player.mountEntity((Entity)null);

        if (transferMount != null)
        {
            mount = teleportEntityTosky(transferMount, aboveWorld);
        }

        if (transferMountedBy != null)
        {
            transferMountedBy.mountEntity((Entity)null);
            mountedBy = teleportEntityTosky(transferMountedBy, aboveWorld);
        }

        ServerConfigurationManager scm = MinecraftServer.getServer().getConfigurationManager();
        scm.transferPlayerToDimension((EntityPlayerMP)player, dimID, tele);

        if (aboveWorld)
        {
            if (mount != null)
            {
                mount.setPosition(posX, 256.0D, posZ);
            }

            if (mountedBy != null)
            {
                mountedBy.setPosition(posX, 256.0D, posZ);
            }

            player.setPositionAndUpdate(posX, 256.0D, posZ);
        }

        if (mount != null)
        {
            player.mountEntity(mount);
        }

        if (mountedBy != null)
        {
            mountedBy.mountEntity(player);
        }
    }
}

public static void teleportPlayerTosky(EntityPlayer player, boolean aboveWorld)
{
    if (player.dimension == 0)
    {
        transferPlayer(player, mcreator_sky.DIMID, skyTeleporter, aboveWorld);
    }
    else if (player.dimension == mcreator_sky.DIMID)
    {
        transferPlayer(player, 0, skyTeleporter, aboveWorld);
    }
    else
    {
        transferPlayer(player, mcreator_sky.DIMID, skyTeleporter, aboveWorld);
    }
    player.timeUntilPortal = player.getPortalCooldown();
}

public static Entity teleportEntityTosky(Entity entity, boolean aboveWorld)
{
    if (!entity.isDead)
    {
        boolean newDim = false;
        int oldDim = entity.dimension;
        double oldX = entity.posX;
        double oldZ = entity.posZ;
        int newDim1;

        if (oldDim == 0)
        {
            newDim1 = mcreator_sky.DIMID;
        }
        else if (oldDim == mcreator_sky.DIMID)
        {
            newDim1 = 0;
        }
        else
        {
            newDim1 = mcreator_sky.DIMID;
        }

        entity.worldObj.theProfiler.startSection("changeDimension");
        MinecraftServer minecraftserver = MinecraftServer.getServer();
        WorldServer oldServer = minecraftserver.worldServerForDimension(oldDim);
        WorldServer newServer = minecraftserver.worldServerForDimension(newDim1);
        entity.dimension = newDim1;
        entity.worldObj.removeEntity(entity);
        entity.worldObj.theProfiler.startSection("reposition");
        entity.isDead = false;
        minecraftserver.getConfigurationManager().transferEntityToWorld(entity, oldDim, oldServer, newServer, skyTeleporter);
        entity.worldObj.theProfiler.endStartSection("reloading");
        Entity entity1 = EntityList.createEntityByName(EntityList.getEntityString(entity), newServer);

        if (entity1 != null)
        {
            entity1.copyDataFrom(entity, true);
            entity1.timeUntilPortal = entity.getPortalCooldown();

            if (aboveWorld)
            {
                entity1.setPosition(oldX, 256.0D, oldZ);
            }

            entity1.forceSpawn = true;
            newServer.spawnEntityInWorld(entity1);
        }

        entity.isDead = true;
        entity.worldObj.theProfiler.endSection();
        oldServer.resetUpdateEntityTick();
        newServer.resetUpdateEntityTick();
        entity.worldObj.theProfiler.endSection();
        return entity1;
    }
    else
    {
        return null;
    }
}

 

Crash Report :( :

 

 

Description: Ticking player

 

java.lang.NullPointerException: Ticking player

at net.minecraft.server.management.ServerConfigurationManager.transferEntityToWorld(ServerConfigurationManager.java:638)

at net.minecraft.server.management.ServerConfigurationManager.transferPlayerToDimension(ServerConfigurationManager.java:542)

at mod.mcreator.TestEnvironmentMod.transferPlayer(TestEnvironmentMod.java:208)

at mod.mcreator.TestEnvironmentMod.teleportPlayerTosky(TestEnvironmentMod.java:245)

at mod.mcreator.mcreator_tickHandler.tick(mcreator_tickHandler.java:15)

at cpw.mods.fml.common.eventhandler.ASMEventHandler_6_mcreator_tickHandler_tick_PlayerTickEvent.invoke(.dynamic)

at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54)

at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:138)

at cpw.mods.fml.common.FMLCommonHandler.onPlayerPreTick(FMLCommonHandler.java:345)

at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:259)

at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:330)

at net.minecraft.network.NetHandlerPlayServer.processPlayer(NetHandlerPlayServer.java:329)

at net.minecraft.network.play.client.C03PacketPlayer.processPacket(C03PacketPlayer.java:37)

at net.minecraft.network.play.client.C03PacketPlayer$C06PacketPlayerPosLook.processPacket(C03PacketPlayer.java:271)

at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241)

at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182)

at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726)

at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614)

at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)

at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485)

at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)

 

 

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

---------------------------------------------------------------------------------------

 

-- Head --

Stacktrace:

at net.minecraft.server.management.ServerConfigurationManager.transferEntityToWorld(ServerConfigurationManager.java:638)

at net.minecraft.server.management.ServerConfigurationManager.transferPlayerToDimension(ServerConfigurationManager.java:542)

at mod.mcreator.TestEnvironmentMod.transferPlayer(TestEnvironmentMod.java:208)

at mod.mcreator.TestEnvironmentMod.teleportPlayerTosky(TestEnvironmentMod.java:245)

at mod.mcreator.mcreator_tickHandler.tick(mcreator_tickHandler.java:15)

at cpw.mods.fml.common.eventhandler.ASMEventHandler_6_mcreator_tickHandler_tick_PlayerTickEvent.invoke(.dynamic)

at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54)

at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:138)

at cpw.mods.fml.common.FMLCommonHandler.onPlayerPreTick(FMLCommonHandler.java:345)

at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:259)

 

-- Player being ticked --

Details:

Entity Type: null (net.minecraft.entity.player.EntityPlayerMP)

Entity ID: 340

Entity Name: Player703

Entity's Exact location: -176,00, -2,38, 233,00

Entity's Block location: World: (-176,-3,233), Chunk: (at 0,-1,9 in -11,14; contains blocks -176,0,224 to -161,255,239), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)

Entity's Momentum: 0,00, -2,49, 0,00

Stacktrace:

at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:330)

at net.minecraft.network.NetHandlerPlayServer.processPlayer(NetHandlerPlayServer.java:329)

at net.minecraft.network.play.client.C03PacketPlayer.processPacket(C03PacketPlayer.java:37)

at net.minecraft.network.play.client.C03PacketPlayer$C06PacketPlayerPosLook.processPacket(C03PacketPlayer.java:271)

at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241)

 

-- Ticking connection --

Details:

Connection: net.minecraft.network.NetworkManager@48bf980f

Stacktrace:

at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182)

at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726)

at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614)

at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)

at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485)

at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)

 

-- System Details --

Details:

Minecraft Version: 1.7.10

Operating System: Windows 8.1 (amd64) version 6.3

Java Version: 1.8.0_25, Oracle Corporation

Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation

Memory: 858295464 bytes (818 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: 12, tallocated: 94

FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1481 4 mods loaded, 4 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.1481-1.7.10.jar)

UCHIJAAAA Forge{10.13.4.1481} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1481-1.7.10.jar)

UCHIJAAAA TestEnvironmentMod{1.0} [TestEnvironmentMod] (bin)

GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread.

Profiler Position: N/A (disabled)

Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used

Player Count: 1 / 8; [EntityPlayerMP['Player703'/340, l='New World', x=-176,00, y=-2,38, z=233,00]]

Type: Integrated Server (map_client.txt)

Is Modded: Definitely; Client brand changed to 'fml,forge'

 

 

What did I go wrong again?

 

You have no clue about what are you doing, do you?

 

Please learn basic java (or logic), because if you can't see the the fact that you are using nulls, then I really can't help you, even if I tried REALLY hard, sorry.

 

public Entity p_149670_5_;

 

Also: "decode" your code (names).

 

In the basic course of java I did, I just learned to do a calculator. :P

Link to post
Share on other sites

Solved:

public class mcreator_tickHandler

{

    @SubscribeEvent

    public void tick(PlayerTickEvent event)

    {

        double posX = event.player.posX;

        double posZ = event.player.posZ;

        if (event.player.dimension == mcreator_aether.DIMID && event.player.posY < -2.0D && event.player.ridingEntity == null && event.player.riddenByEntity == null && !event.player.worldObj.isRemote)

        {

        event.player.travelToDimension(0);

        event.player.setPositionAndUpdate(posX, 256.0D, posZ);

        }

}

}

Link to post
Share on other sites
Guest
This topic is now closed to further replies.


  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • So I thought that I had gotten pretty far on my own but now apparently my code crashes the game. I am new to using the forge API and modding in general and some help on why this crashes the game and how to fix it would be greatly appreciated:   public class SpecialItem extends ShootableItem {      public SpecialItem(Properties properties){ super(properties); }      @Override      public Predicate<ItemStack> getInventoryAmmoPredicate() { return null; }      @Override      public int func_230305_d_() { return 15; }      public int tcount=0;      @SubscribeEvent public void ontick(TickEvent.ClientTickEvent event){            tcount++;      }      @Override      public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) {      if (!playerIn.getCooldownTracker().hasCooldown(this)) {           playerIn.getCooldownTracker().setCooldown(this, 40);           Vector3d v3 = playerIn.getLook(1);           for (tcount = 0; tcount <= 40;) {                if (tcount%10 == 0 && tcount!= 40) {                     final SmallFireballEntity entitysmallfireball = new SmallFireballEntity(playerIn.getEntityWorld(), playerIn.getPosX(), playerIn.getPosY() + playerIn.getEyeHeight() - 0.4, playerIn.getPosZ(), v3.x + playerIn.getRNG().nextGaussian() * 0.05, v3.y, v3.z);                     entitysmallfireball./* shoot */func_234612_a_(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0f, 1.5f, 1.0f); worldIn.addEntity(entitysmallfireball); } } tcount = 0;                     return ActionResult.resultSuccess(playerIn.getHeldItem(handIn));            } return ActionResult.resultFail(playerIn.getHeldItem(handIn));      } }
    • I found a way to handle this, using javapoet as you suggested. For those who are interested in how it works, you can take a look at my sample here: https://github.com/DarkShadow44/compatibilitymod/tree/sourcegen Might not work with eclipse yet, but it builds properly.
    • It's fired on the logical client and logical server. Most likely you'll only need to execute the logic on the server.
    • If you're translating individual files, there's not much you can do about it. You could use the updateMappings gradlew task, but that's better for large batches of code. As for JSON item models, that is a much more complicated issue that involves layers and custom transform types. While still possible, the tradeoff isn't really worth it.
    • it keeps saying when i i try to install it, it says These libraries failed to download. Try again   
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.