• 0

    posted a message on WarpDrive: custom ships, laser cannons and modular force fields!

    Can you please update the Wiki with the API changes to the ship controller?

    Posted in: Minecraft Mods
  • 0

    posted a message on WarpDrive: custom ships, laser cannons and modular force fields!

    I understand that I have posted this suggestion before, but I wanted to make sure it was not forgotten. A very convenient addition to the ship controller's API would be a method that took a set of world coordinates and attempted to jump as far towards those coordinates as possible. This could be accomplished relatively easily, and would make navigation much easier.

    Posted in: Minecraft Mods
  • 0

    posted a message on WarpDrive: custom ships, laser cannons and modular force fields!

    Are there any plans to add a function to the warp controller that will either take in a direction Vector or coordinates, and warp the ship in that direction?

    Posted in: Minecraft Mods
  • 0

    posted a message on WarpDrive: custom ships, laser cannons and modular force fields!

    It may be a good idea to pick apart the existing program, its a great example of how the controller interface works.

    Posted in: Minecraft Mods
  • 0

    posted a message on Issue with getting world from DimensionManager

    It seems that sometimes when I use DimensionManager.getWorld(), it returns Null. This only happens after the world has been loaded for a few minutes.


    EDIT: It also appears that the data is not saving when Minecraft is reloaded.


    Relavent Code:



    package com.Spector19.Tardismod;
    
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    import java.util.Map.Entry;
    import java.util.Random;
    
    import com.Spector19.Tardismod.dimension.CapsuleWorldProvider;
    import com.Spector19.Tardismod.dimension.DimensionRegistry;
    
    import net.minecraft.block.Block;
    import net.minecraft.init.Blocks;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.nbt.NBTTagList;
    import net.minecraft.world.World;
    import net.minecraft.world.WorldSavedData;
    import net.minecraftforge.common.DimensionManager;
    import net.minecraftforge.common.util.Constants;
    
    public class CapsuleRegister extends WorldSavedData {
    
    	Map<String, int[]> CapsuleInteriors = new HashMap<String, int[]>();
    	Map<String, int[]> CapsuleExteriorsPos = new HashMap<String, int[]>();
    	Map<String, Integer> CapsuleExtDims = new HashMap<String, Integer>();
    	Map<String, String[]> CapsuleExtReplacedBlocks = new HashMap<String, String[]>();
    	
    	
    	public int MaxIntPos = 50000;
    	public int MinIntPos = -50000;
    	public int YIntPos = 30;
    	
    	public int IntHeight = 60;
    	public int IntLength = 100;
    	public Block IntBlock = Blocks.bedrock;
    	
    	Random rand = new Random();
    	
    	public Util Util = new Util();
    	
    	public CapsuleRegister(String id) {
    		super(id);
    		
    	}
    	
    	public int[] GetOkInteriorCoords() {
    	boolean Done = false;
    	int Tries = 0;
    	while (!Done) {
    	if (Tries > 200) break;
    	boolean Ok = true;
    	int randomX = rand.nextInt((MaxIntPos - MinIntPos) + 1) + MinIntPos;
    	int randomZ = rand.nextInt((MaxIntPos - MinIntPos) + 1) + MinIntPos;
    	//Check Other Interiors
    	for (Entry<String, int[]> entry : CapsuleInteriors.entrySet()) {
    		int[] IntPos = entry.getValue();
    		int Distance = Util.Distance(randomX, YIntPos, randomZ, IntPos[1], IntPos[2], IntPos[3]);
    		if (Distance < 300) {
    		Ok = false;
    		}
    	}
    	if (Ok) {
    	return new int[] {randomX, YIntPos, randomZ};
    	}
    	Tries++;
    	}
    	return null;
    	}
    	
    	public void NewCapsule(String Name, int[] ExtPos, int DimID){
    		System.out.println("Genning new capsule");
    		if (CapsuleInteriors.get(Name) == null){
    		System.out.println("Attempting to get new interior coordinates");
    		int[] IntPos = GetOkInteriorCoords();
    		if (IntPos.length > 2) {
    		System.out.println("Genning New Capsule Interior At Coords: "+IntPos[0]+" "+IntPos[1]+" "+IntPos[2]);
    		Util.GenInteriorBox(DimensionManager.getWorld(DimensionRegistry.CapDimID), IntPos[0], IntPos[1], IntPos[2], IntHeight, IntLength, IntBlock);
    		int[] DoorPos = Util.GenerateInteriorDoor(DimensionManager.getWorld(DimensionRegistry.CapDimID), IntPos[0], IntPos[1], IntPos[2], IntHeight, IntLength, "Blue");
    		System.out.println("Genning new capsule: Interior Genned");
    		Util.PlaceExterior(ExtPos[0], ExtPos[1], ExtPos[2], DimensionManager.getWorld(DimID), "Blue", 0, "North");
    		Util.PlaceTeleporter(ExtPos[0], ExtPos[1], ExtPos[2], DimensionManager.getWorld(DimID), DoorPos[0], DoorPos[1]+1, DoorPos[2]+2, DimensionManager.getWorld(DimensionRegistry.CapDimID));
    		Util.PlaceTeleporter(DoorPos[0], DoorPos[1]+1, DoorPos[2], DimensionManager.getWorld(DimensionRegistry.CapDimID), ExtPos[0], ExtPos[1]+1, ExtPos[2], DimensionManager.getWorld(DimID));
    		CapsuleInteriors.put(Name, DoorPos);
    		CapsuleExteriorsPos.put(Name, ExtPos);
    		CapsuleExtDims.put(Name, DimID);
    		} else System.out.println("Unable to gen new capsule, cound not get interior position");
    		} else System.out.println("Unable to gen new capsule, capsule "+Name+" already exists");
    		this.markDirty();
    	}
    	
    	public int[] GetCapsuleInteriorPos (String Name) {
    		for (Entry<String, int[]> entry : CapsuleInteriors.entrySet()) {
    		if (entry.getKey() == Name) {
    		return entry.getValue();
    		}
    		}
    		return null;
    	}
    	
    	public int[] GetCapsuleExteriorPos (String Name) {
    		for (Entry<String, int[]> entry : CapsuleExteriorsPos.entrySet()) {
    		if (entry.getKey() == Name) {
    		return entry.getValue();
    		}
    		}
    		return null;
    	}
    	
    	public void UpdateCapsuleExterior(String Name, int[] ExtPos, int DimID, String Direction) {
    		if (CapsuleExteriorsPos.get(Name) != null){
    			int[] DoorPos = CapsuleInteriors.get(Name);
    			int[] OldExtPos = CapsuleExteriorsPos.get(Name);
    			World OldDimWorld = DimensionManager.getWorld(CapsuleExtDims.get(Name));
    			//Clear Old Stuff
    			Util.ClearExterior(OldExtPos[0], OldExtPos[1], OldExtPos[2], OldDimWorld);
    			DimensionManager.getWorld(DimensionRegistry.CapDimID).setBlockToAir(DoorPos[0], DoorPos[1]+1, DoorPos[2]);
    			//Put New Stuff
    			Util.PlaceExterior(ExtPos[0], ExtPos[1], ExtPos[2], DimensionManager.getWorld(DimID), "Blue", 0, Direction);
    			Util.PlaceTeleporter(ExtPos[0], ExtPos[1], ExtPos[2], DimensionManager.getWorld(DimID), DoorPos[0], DoorPos[1]+1, DoorPos[2]+2, DimensionManager.getWorld(DimensionRegistry.CapDimID));
    			Util.PlaceTeleporter(DoorPos[0], DoorPos[1]+1, DoorPos[2], DimensionManager.getWorld(DimensionRegistry.CapDimID), ExtPos[0], ExtPos[1]+1, ExtPos[2], DimensionManager.getWorld(DimID));
    			CapsuleExteriorsPos.put(Name, ExtPos);
    			CapsuleExtDims.put(Name, DimID);
    		}
    		this.markDirty();
    	}
    
    	@Override
    	public void readFromNBT(NBTTagCompound tag) {
    		System.out.println("Loading Capsule Data");
    		CapsuleInteriors.clear();
    		CapsuleExteriorsPos.clear();
    		CapsuleExtDims.clear();
    		NBTTagList lst = tag.getTagList("capsules", Constants.NBT.TAG_COMPOUND);
    		for (int i = 0 ; i < lst.tagCount() ; i++) {
            NBTTagCompound cr = lst.getCompoundTagAt(i);
            String CID = cr.getString("name");
            int[] IntPos = cr.getIntArray("intpos");
    		int[] ExtPos = cr.getIntArray("extpos");
    		int ExtDim = cr.getInteger("extdim");
    		
    		CapsuleInteriors.put(CID, IntPos);
    		CapsuleExteriorsPos.put(CID, ExtPos);
    		CapsuleExtDims.put(CID, ExtDim);
    		
    		System.out.println("Loaded Capsule: " + CID + ", Landed At: " + ExtDim + "," + ExtPos[1] + "," + ExtPos[2] + "," + ExtPos[3] + ", Interior: " + IntPos[1] + "," + IntPos[2] + "," + IntPos[3]);
                
    		}
    		
    	}
    
    	@Override
    	public void writeToNBT(NBTTagCompound tag) {
    		System.out.println("Saving Capsule Data");
    		NBTTagList list = new NBTTagList();
    		for (Entry<String, int[]> entry : CapsuleInteriors.entrySet()) {
    			NBTTagCompound cr = new NBTTagCompound();
    			 String CID = entry.getKey();
    			 int[] IntPos = CapsuleInteriors.get(CID);
    			 int[] ExtPos = CapsuleExteriorsPos.get(CID);
    			 int ExtDim = CapsuleExtDims.get(CID);
    			 cr.setString("name", CID);
    			 cr.setIntArray("intpos", IntPos);
    			 cr.setIntArray("extpos", ExtPos);
    			 cr.setInteger("extdim", ExtDim);
    			 list.appendTag(cr);
    		}
    		tag.setTag("capsules", list);
    		
    		
    	}
    
    
    
    
    
    }



    Posted in: Modification Development
  • 0

    posted a message on Update Blocks MetaData from TileEntity not working

    I need this TileEntity to update the blocks above it, if they are the right kind of block. When I use the code below in the TileEntity's UpdateEntity method, the blocks above do not appear to have updated. However, when i rejoin, the block's Metadata appears to have been changed, but when i update the main block they all are reset back to their original state. I can verify that the SetTubeState() method is being called correctly.


    I am using the Industrialcraft 2 API.


    TileEntityMatterInjectorBase:


    package com.Spector19.Tardismod.tileentity;
    
    import com.Spector19.Tardismod.blocks.ModBlocks;
    
    import ic2.api.energy.prefab.BasicSink;
    import net.minecraft.block.Block;
    import net.minecraft.init.Blocks;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.tileentity.TileEntity;
     
    public class TileEntityMatterInjectorBase extends TileEntity {
    
    	private BasicSink ic2EnergySink = new BasicSink(this, 100000, 3);
    	
    	private Boolean Active = true;
    	
    	public TileEntityMatterInjectorBase(){}
    	
    	
    	 @Override
         public void readFromNBT(NBTTagCompound tag) {
             super.readFromNBT(tag);
             ic2EnergySink.readFromNBT(tag);
             NBTTagCompound Data = tag.getCompoundTag("MITEntity");
             this.Active = Data.getBoolean("active");
         }
     
         @Override
         public void writeToNBT(NBTTagCompound tag) {
             super.writeToNBT(tag);
             ic2EnergySink.writeToNBT(tag);
             NBTTagCompound Data = new NBTTagCompound();
             Data.setBoolean("active", this.Active);
             tag.setTag("MITEntity", Data);
         }
    	
         @Override
         public void updateEntity() {
        	ic2EnergySink.updateEntity();
        	if (this.Active){
        	if (ic2EnergySink.useEnergy(32)) {
        		SetTubeState(true);
        	} else {
        		SetTubeState(false);
        	}
        	}
        	
         }
         
         @Override
         public void invalidate() {
        	 ic2EnergySink.invalidate();
             super.invalidate();
          }
         
         public void onChunkUnload() {
    	        ic2EnergySink.onChunkUnload();
    	  }
         
         
         public void SetTubeState(Boolean tbo) {
        	 for(int y=1; y<6; y++){
        	 Block GottenBlock = this.worldObj.getBlock(this.xCoord, this.yCoord+y, this.zCoord);
        	 if (GottenBlock == ModBlocks.MatterInjectorTubeBlock){
        	 if (tbo) {
        	 if (this.worldObj.getBlockMetadata(this.xCoord, this.yCoord+y, this.zCoord) != 1){
        	 this.worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord+y, this.zCoord, 1, 3);
        	 }
        	 } else {
        	 if (this.worldObj.getBlockMetadata(this.xCoord, this.yCoord+y, this.zCoord) != 0){
        	 this.worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord+y, this.zCoord, 0, 3);
        	 }
        	 }
        	 } else {
        	 break;
        	 }
        	 }
         }
         
         
         
         
         
         
         
         
         
         
         
         
         
         
         
         
         
         
         
    }



    BlockMatterInjectorTube:


    package com.Spector19.Tardismod.blocks;
    
    import com.Spector19.Tardismod.Main;
    
    import net.minecraft.block.Block;
    import net.minecraft.block.BlockContainer;
    import net.minecraft.block.material.Material;
    import net.minecraft.client.renderer.texture.IIconRegister;
    import net.minecraft.creativetab.CreativeTabs;
    import net.minecraft.tileentity.TileEntity;
    import net.minecraft.util.IIcon;
    import net.minecraft.world.World;
    
    public class blockMatterInjectorTube extends Block {
    	private IIcon[] iconBuffer;
    	
    	
    	protected blockMatterInjectorTube(String unlocalizedName, Material mat) {
    		super(mat);
    		this.setBlockName(unlocalizedName);
            this.setCreativeTab(CreativeTabs.tabBlock);
            this.setHardness(2.0F);
            this.setResistance(1000000F);
            this.setLightLevel(1.0F);
            this.setHarvestLevel("pickaxe", 3);
            this.setStepSound(soundTypeMetal);
    
    	}
    	
    	@Override
    	public void registerBlockIcons(IIconRegister par1IconRegister) {
    		iconBuffer = new IIcon[10];
    		iconBuffer[0] = par1IconRegister.registerIcon("tardismod:MatterInjectorTubeTopBottom");
    		iconBuffer[1] = par1IconRegister.registerIcon("tardismod:MatterInjectorTubeOff");
    		iconBuffer[2] = par1IconRegister.registerIcon("tardismod:MatterInjectorTubeAnimation");
    	}
    	
    	@Override
    	public IIcon getIcon(int side, int metadata) {
    		if (side == 0 || side == 1) {
    			return iconBuffer[0];
    		} else {
    			if (metadata == 0){
    			return iconBuffer[1];
    			} else {
    				return iconBuffer[2];
    			}
    		}
    	}
    	
    	
    
    }


    Posted in: Modification Development
  • 0

    posted a message on Pause code inside a TileEntity

    Thank you, I now have it working perfectly.

    Posted in: Modification Development
  • 0

    posted a message on Pause code inside a TileEntity

    I have tried this:


    @Override
    public void updateEntity() {
    if (this.CurrentState > 0){
    if (this.CurrentState == 9) {
    this.worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord, this.zCoord, 9, 3);
    this.CurrentState = 1;
    } else {
    this.CurrentState++;
    this.worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord, this.zCoord, this.CurrentState, 3);

    }

    }

    }


    but it does not seem to be consistent. The reason i am not using the conventional way of animating textures is because i need to have it preform the animation, then execute some code after it is finished.

    Posted in: Modification Development
  • 0

    posted a message on Pause code inside a TileEntity

    How would I cause code running inside a TileEntity to wait? Thread.Sleep() just pauses the entire game (I assume this is because the game is run on a single thread).

    Posted in: Modification Development
  • 0

    posted a message on Tile Entity throws error on world load, does not save NBT data

    Thank you. None of the tutorials stated that the TileEntity's constructor needed to have a set number of arguments.

    Posted in: Modification Development
  • 0

    posted a message on Interdimensional Teleport always sends players to the nether

    Thank you for your reply, but I figured out what i did wrong. I was not getting the dimension names correctly (the method i was using always returns the SERVER name, not the dimension name), and when i attempted to get the ID back from that it just returned the nether's dimension ID.

    Posted in: Modification Development
  • 0

    posted a message on Tile Entity throws error on world load, does not save NBT data

    My Tile entity is throwing an error when the game loads. The Entity is being registered, so i don't understand what the issue is.


    Error:


    [07:22:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: java.lang.InstantiationException: com.Spector19.Tardismod.tileentity.tileentityExteriorTeleporter
    [07:22:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at java.lang.Class.newInstance(Unknown Source)
    [07:22:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.tileentity.TileEntity.createAndLoadEntity(TileEntity.java:123)
    [07:22:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.world.chunk.storage.AnvilChunkLoader.loadEntities(AnvilChunkLoader.java:525)
    [07:22:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraftforge.common.chunkio.ChunkIOProvider.callStage2(ChunkIOProvider.java:41)
    [07:22:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraftforge.common.chunkio.ChunkIOProvider.callStage2(ChunkIOProvider.java:12)
    [07:22:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraftforge.common.util.AsynchronousExecutor.skipQueue(AsynchronousExecutor.java:344)
    [07:22:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraftforge.common.util.AsynchronousExecutor.getSkipQueue(AsynchronousExecutor.java:302)
    [07:22:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraftforge.common.chunkio.ChunkIOExecutor.syncChunkLoad(ChunkIOExecutor.java:12)
    [07:22:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:144)
    [07:22:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:119)
    [07:22:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.server.MinecraftServer.initialWorldChunkLoad(MinecraftServer.java:305)
    [07:22:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.server.integrated.IntegratedServer.loadAllWorlds(IntegratedServer.java:79)
    [07:22:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.server.integrated.IntegratedServer.startServer(IntegratedServer.java:96)
    [07:22:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:445)
    [07:22:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)
    [07:22:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: Caused by: java.lang.NoSuchMethodException: com.Spector19.Tardismod.tileentity.tileentityExteriorTeleporter.<init>()
    [07:22:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at java.lang.Class.getConstructor0(Unknown Source)
    [07:22:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: ... 15 more
    [07:22:14] [Server thread/WARN]: Skipping BlockEntity with id TCapsule_ExteriorTeleporter

    Posted in: Modification Development
  • 0

    posted a message on WarpDrive: custom ships, laser cannons and modular force fields!

    Im pretty sure that if you use GetBlock() anywhere in a dimension it will load it for a short time.

    Posted in: Minecraft Mods
  • 0

    posted a message on Get world name from dimension ID

    From what i have seen of mods like RFTools and Mystcraft, dimension IDs can change when a world is reloaded. Correct me if am wrong, but i believe that dimension names do NOT change when worlds are reloaded (the names of the dimension folders remain constant). Is there any way to get a dimension's name from its ID? I know that you can get the ID from the dimension name (code below), but how do you get the ID back from that string?


    public World GetWorldFromName(String s){
    	WorldServer[] Worlds = DimensionManager.getWorlds();
    	for (WorldServer world : Worlds) {
    	if (world.getWorldInfo().getWorldName() == s){
    	return world;
    	}
    	}
    	return null;
    	}
    Posted in: Modification Development
  • To post a comment, please .