Jump to content

Manslaughter777

Members
  • Posts

    99
  • Joined

  • Last visited

Posts posted by Manslaughter777

  1. Some reason i keep crashing when trying to use the event. It was working at some stage but now its not... im pretty sure im doing something wrong but idk what..

     

    The class:

     

     

    package com.manslaughter777.moondimension.event;
    
    import com.manslaughter777.moondimension.Main;
    import com.manslaughter777.moondimension.entity.EntitySpaceman;
    import com.manslaughter777.moondimension.inventory.InventoryTool;
    import com.manslaughter777.moondimension.items.ItemMoonPickaxe;
    import com.manslaughter777.moondimension.items.ItemToolUpgrade;
    
    import net.minecraft.block.Block;
    import net.minecraft.block.BlockOre;
    import net.minecraft.block.BlockSand;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.init.Blocks;
    import net.minecraft.init.Items;
    import net.minecraft.item.ItemStack;
    import net.minecraft.world.World;
    import net.minecraftforge.event.world.BlockEvent;
    import cpw.mods.fml.common.eventhandler.SubscribeEvent;
    
    public class HarvestDropsEvent {
    
    @SubscribeEvent
    public void onBlockBreak(BlockEvent.HarvestDropsEvent event) {
    	EntityPlayer player = event.harvester;
    	World world = event.world;
    	Block block = event.block;
    	int x = event.x;
    	int y = event.y;
    	int z = event.z;	
    
    	//InventoryTool inv = new InventoryTool(player.getHeldItem());
    
    
    	if(player.getHeldItem() != null) { //this is line 34, where the crash report leads to
    		if(player.getHeldItem().getItem() instanceof ItemMoonPickaxe) { //only pickaxes
    			if(new InventoryTool(player.getHeldItem()).upgrade[itemToolUpgrade.oreHarvesterId] == true) {
    
    				if(block instanceof BlockSand) {
    					event.drops.add(new ItemStack(Blocks.anvil));
    					event.drops.remove(new ItemStack(Blocks.sand));
    				}
    			}
    		}
    	}
    
    }
    
    }
    
    

     

     

     

    The crash report:

     

     

    // Sorry 
    
    Time: 2/03/15 4:09 PM
    Description: Exception in server tick loop
    
    java.lang.NullPointerException: Exception in server tick loop
    at com.manslaughter777.moondimension.event.HarvestDropsEvent.onBlockBreak(HarvestDropsEvent.java:34)
    at cpw.mods.fml.common.eventhandler.ASMEventHandler_13_HarvestDropsEvent_onBlockBreak_HarvestDropsEvent.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 net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting(ForgeEventFactory.java:146)
    at net.minecraft.block.Block.dropBlockAsItemWithChance(Block.java:806)
    at net.minecraft.block.Block.dropBlockAsItem(Block.java:795)
    at net.minecraft.block.BlockDynamicLiquid.func_149813_h(BlockDynamicLiquid.java:184)
    at net.minecraft.block.BlockDynamicLiquid.updateTick(BlockDynamicLiquid.java:162)
    at net.minecraft.world.WorldServer.scheduleBlockUpdateWithPriority(WorldServer.java:455)
    at net.minecraft.world.WorldServer.scheduleBlockUpdate(WorldServer.java:432)
    at net.minecraft.block.BlockDynamicLiquid.onBlockAdded(BlockDynamicLiquid.java:352)
    at net.minecraft.world.chunk.Chunk.func_150807_a(Chunk.java:713)
    at net.minecraft.world.World.setBlock(World.java:519)
    at net.minecraft.block.BlockDynamicLiquid.func_149813_h(BlockDynamicLiquid.java:187)
    at net.minecraft.block.BlockDynamicLiquid.updateTick(BlockDynamicLiquid.java:152)
    at net.minecraft.world.WorldServer.scheduleBlockUpdateWithPriority(WorldServer.java:455)
    at net.minecraft.world.WorldServer.scheduleBlockUpdate(WorldServer.java:432)
    at net.minecraft.block.BlockDynamicLiquid.onBlockAdded(BlockDynamicLiquid.java:352)
    at net.minecraft.world.chunk.Chunk.func_150807_a(Chunk.java:713)
    at net.minecraft.world.World.setBlock(World.java:519)
    at net.minecraft.block.BlockDynamicLiquid.func_149813_h(BlockDynamicLiquid.java:187)
    at net.minecraft.block.BlockDynamicLiquid.updateTick(BlockDynamicLiquid.java:132)
    at net.minecraft.world.WorldServer.scheduleBlockUpdateWithPriority(WorldServer.java:455)
    at net.minecraft.world.WorldServer.scheduleBlockUpdate(WorldServer.java:432)
    at net.minecraft.block.BlockDynamicLiquid.onBlockAdded(BlockDynamicLiquid.java:352)
    at net.minecraft.world.chunk.Chunk.func_150807_a(Chunk.java:713)
    at net.minecraft.world.World.setBlock(World.java:519)
    at net.minecraft.block.BlockDynamicLiquid.func_149813_h(BlockDynamicLiquid.java:187)
    at net.minecraft.block.BlockDynamicLiquid.updateTick(BlockDynamicLiquid.java:162)
    at net.minecraft.world.WorldServer.scheduleBlockUpdateWithPriority(WorldServer.java:455)
    at net.minecraft.world.WorldServer.scheduleBlockUpdate(WorldServer.java:432)
    at net.minecraft.block.BlockDynamicLiquid.onBlockAdded(BlockDynamicLiquid.java:352)
    at net.minecraft.world.chunk.Chunk.func_150807_a(Chunk.java:713)
    at net.minecraft.world.World.setBlock(World.java:519)
    at net.minecraft.block.BlockDynamicLiquid.func_149813_h(BlockDynamicLiquid.java:187)
    at net.minecraft.block.BlockDynamicLiquid.updateTick(BlockDynamicLiquid.java:162)
    at net.minecraft.world.WorldServer.scheduleBlockUpdateWithPriority(WorldServer.java:455)
    at net.minecraft.world.WorldServer.scheduleBlockUpdate(WorldServer.java:432)
    at net.minecraft.block.BlockDynamicLiquid.onBlockAdded(BlockDynamicLiquid.java:352)
    at net.minecraft.world.chunk.Chunk.func_150807_a(Chunk.java:713)
    at net.minecraft.world.World.setBlock(World.java:519)
    at net.minecraft.block.BlockDynamicLiquid.func_149813_h(BlockDynamicLiquid.java:187)
    at net.minecraft.block.BlockDynamicLiquid.updateTick(BlockDynamicLiquid.java:162)
    at net.minecraft.world.WorldServer.scheduleBlockUpdateWithPriority(WorldServer.java:455)
    at net.minecraft.world.WorldServer.scheduleBlockUpdate(WorldServer.java:432)
    at net.minecraft.block.BlockDynamicLiquid.onBlockAdded(BlockDynamicLiquid.java:352)
    at net.minecraft.world.chunk.Chunk.func_150807_a(Chunk.java:713)
    at net.minecraft.world.World.setBlock(World.java:519)
    at net.minecraft.block.BlockDynamicLiquid.func_149813_h(BlockDynamicLiquid.java:187)
    at net.minecraft.block.BlockDynamicLiquid.updateTick(BlockDynamicLiquid.java:162)
    at net.minecraft.world.WorldServer.scheduleBlockUpdateWithPriority(WorldServer.java:455)
    at net.minecraft.world.WorldServer.scheduleBlockUpdate(WorldServer.java:432)
    at net.minecraft.block.BlockDynamicLiquid.onBlockAdded(BlockDynamicLiquid.java:352)
    at net.minecraft.world.chunk.Chunk.func_150807_a(Chunk.java:713)
    at net.minecraft.world.World.setBlock(World.java:519)
    at net.minecraft.block.BlockDynamicLiquid.func_149813_h(BlockDynamicLiquid.java:187)
    at net.minecraft.block.BlockDynamicLiquid.updateTick(BlockDynamicLiquid.java:152)
    at net.minecraft.world.WorldServer.scheduleBlockUpdateWithPriority(WorldServer.java:455)
    at net.minecraft.world.WorldServer.scheduleBlockUpdate(WorldServer.java:432)
    at net.minecraft.block.BlockDynamicLiquid.onBlockAdded(BlockDynamicLiquid.java:352)
    at net.minecraft.world.chunk.Chunk.func_150807_a(Chunk.java:713)
    at net.minecraft.world.World.setBlock(World.java:519)
    at net.minecraft.block.BlockDynamicLiquid.func_149813_h(BlockDynamicLiquid.java:187)
    at net.minecraft.block.BlockDynamicLiquid.updateTick(BlockDynamicLiquid.java:132)
    at net.minecraft.world.WorldServer.scheduleBlockUpdateWithPriority(WorldServer.java:455)
    at net.minecraft.world.WorldServer.scheduleBlockUpdate(WorldServer.java:432)
    at net.minecraft.block.BlockDynamicLiquid.onBlockAdded(BlockDynamicLiquid.java:352)
    at net.minecraft.world.chunk.Chunk.func_150807_a(Chunk.java:713)
    at net.minecraft.world.World.setBlock(World.java:519)
    at net.minecraft.block.BlockDynamicLiquid.func_149813_h(BlockDynamicLiquid.java:187)
    at net.minecraft.block.BlockDynamicLiquid.updateTick(BlockDynamicLiquid.java:152)
    at net.minecraft.world.WorldServer.scheduleBlockUpdateWithPriority(WorldServer.java:455)
    at net.minecraft.world.WorldServer.scheduleBlockUpdate(WorldServer.java:432)
    at net.minecraft.block.BlockDynamicLiquid.onBlockAdded(BlockDynamicLiquid.java:352)
    at net.minecraft.world.chunk.Chunk.func_150807_a(Chunk.java:713)
    at net.minecraft.world.World.setBlock(World.java:519)
    at net.minecraft.block.BlockDynamicLiquid.func_149813_h(BlockDynamicLiquid.java:187)
    at net.minecraft.block.BlockDynamicLiquid.updateTick(BlockDynamicLiquid.java:152)
    at net.minecraft.world.WorldServer.scheduleBlockUpdateWithPriority(WorldServer.java:455)
    at net.minecraft.world.WorldServer.scheduleBlockUpdate(WorldServer.java:432)
    at net.minecraft.block.BlockDynamicLiquid.onBlockAdded(BlockDynamicLiquid.java:352)
    at net.minecraft.world.chunk.Chunk.func_150807_a(Chunk.java:713)
    at net.minecraft.world.World.setBlock(World.java:519)
    at net.minecraft.block.BlockDynamicLiquid.func_149813_h(BlockDynamicLiquid.java:187)
    at net.minecraft.block.BlockDynamicLiquid.updateTick(BlockDynamicLiquid.java:132)
    at net.minecraft.world.WorldServer.scheduleBlockUpdateWithPriority(WorldServer.java:455)
    at net.minecraft.world.WorldServer.scheduleBlockUpdate(WorldServer.java:432)
    at net.minecraft.block.BlockDynamicLiquid.onBlockAdded(BlockDynamicLiquid.java:352)
    at net.minecraft.world.chunk.Chunk.func_150807_a(Chunk.java:713)
    at net.minecraft.world.World.setBlock(World.java:519)
    at net.minecraft.block.BlockDynamicLiquid.func_149813_h(BlockDynamicLiquid.java:187)
    at net.minecraft.block.BlockDynamicLiquid.updateTick(BlockDynamicLiquid.java:152)
    at net.minecraft.world.WorldServer.scheduleBlockUpdateWithPriority(WorldServer.java:455)
    at net.minecraft.world.WorldServer.scheduleBlockUpdate(WorldServer.java:432)
    at net.minecraft.block.BlockDynamicLiquid.onBlockAdded(BlockDynamicLiquid.java:352)
    at net.minecraft.world.chunk.Chunk.func_150807_a(Chunk.java:713)
    at net.minecraft.world.World.setBlock(World.java:519)
    at net.minecraft.block.BlockDynamicLiquid.func_149813_h(BlockDynamicLiquid.java:187)
    at net.minecraft.block.BlockDynamicLiquid.updateTick(BlockDynamicLiquid.java:152)
    at net.minecraft.world.WorldServer.scheduleBlockUpdateWithPriority(WorldServer.java:455)
    at net.minecraft.world.WorldServer.scheduleBlockUpdate(WorldServer.java:432)
    at net.minecraft.block.BlockDynamicLiquid.onBlockAdded(BlockDynamicLiquid.java:352)
    at net.minecraft.world.chunk.Chunk.func_150807_a(Chunk.java:713)
    at net.minecraft.world.World.setBlock(World.java:519)
    at net.minecraft.block.BlockDynamicLiquid.func_149813_h(BlockDynamicLiquid.java:187)
    at net.minecraft.block.BlockDynamicLiquid.updateTick(BlockDynamicLiquid.java:132)
    at net.minecraft.world.WorldServer.scheduleBlockUpdateWithPriority(WorldServer.java:455)
    at net.minecraft.world.WorldServer.scheduleBlockUpdate(WorldServer.java:432)
    at net.minecraft.block.BlockDynamicLiquid.onBlockAdded(BlockDynamicLiquid.java:352)
    at net.minecraft.world.chunk.Chunk.func_150807_a(Chunk.java:713)
    at net.minecraft.world.World.setBlock(World.java:519)
    at net.minecraft.block.BlockDynamicLiquid.func_149813_h(BlockDynamicLiquid.java:187)
    at net.minecraft.block.BlockDynamicLiquid.updateTick(BlockDynamicLiquid.java:152)
    at net.minecraft.world.gen.feature.WorldGenLiquids.generate(WorldGenLiquids.java:83)
    at net.minecraft.world.biome.BiomeDecorator.genDecorations(BiomeDecorator.java:344)
    at net.minecraft.world.biome.BiomeDecorator.decorateChunk(BiomeDecorator.java:145)
    at net.minecraft.world.biome.BiomeGenBase.decorate(BiomeGenBase.java:412)
    at net.minecraft.world.biome.BiomeGenForest.decorate(BiomeGenForest.java:198)
    at net.minecraft.world.gen.ChunkProviderGenerate.populate(ChunkProviderGenerate.java:444)
    at net.minecraft.world.gen.ChunkProviderServer.populate(ChunkProviderServer.java:313)
    at net.minecraft.world.chunk.Chunk.populateChunk(Chunk.java:1157)
    at net.minecraft.world.gen.ChunkProviderServer.originalLoadChunk(ChunkProviderServer.java:208)
    at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:149)
    at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:119)
    at net.minecraft.server.MinecraftServer.initialWorldChunkLoad(MinecraftServer.java:305)
    at net.minecraft.server.integrated.IntegratedServer.loadAllWorlds(IntegratedServer.java:79)
    at net.minecraft.server.integrated.IntegratedServer.startServer(IntegratedServer.java:96)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:445)
    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:
    ---------------------------------------------------------------------------------------
    
    -- System Details --
    Details:
    Minecraft Version: 1.7.10
    Operating System: Windows 7 (amd64) version 6.1
    Java Version: 1.7.0_51, Oracle Corporation
    Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    Memory: 844794136 bytes (805 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.85.1230 Minecraft Forge 10.13.2.1230 4 mods loaded, 4 mods active
    mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available
    FML{7.10.85.1230} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.2.1230.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available
    Forge{10.13.2.1230} [Minecraft Forge] (forgeSrc-1.7.10-10.13.2.1230.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available
    moondimension{1.0.0} [The Moon] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available
    Profiler Position: N/A (disabled)
    Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
    Player Count: 0 / 8; []
    Type: Integrated Server (map_client.txt)
    Is Modded: Definitely; Client brand changed to 'fml,forge'
    [16:09:52] [Client thread/INFO] [sTDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:393]: #@!@# Game crashed! Crash report saved to: #@!@# .\crash-reports\crash-2015-03-02_16.09.52-server.txt
    AL lib: (EE) alc_cleanup: 1 device not closed
    
    

     

     

  2. It seems that the methods openInventory() and closeInventory() are not working. I have made it print when i open the inventory but it doesnt print anything....

     

    The IInventory class:

     

     

    package com.manslaughter777.moondimension.inventory;
    
    import com.manslaughter777.moondimension.Main;
    import com.manslaughter777.moondimension.items.ItemToolUpgrade;
    
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.inventory.IInventory;
    import net.minecraft.item.ItemPickaxe;
    import net.minecraft.item.ItemStack;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.nbt.NBTTagList;
    import net.minecraftforge.common.util.Constants;
    
    public class InventoryTool implements IInventory {
    private String name;
    
    public static boolean check;
    
    /** Defining your inventory size this way is handy */
    public static final int INV_SIZE = 4;
    
    /**
     * Inventory's size must be same as number of slots you add to the Container
     * class
     */
    private ItemStack[] slots = new ItemStack[iNV_SIZE];
    
    /** Provides NBT Tag Compound to reference */
    public final ItemStack invItem;
    
    /**
     * @param itemstack
     *            - the ItemStack to which this inventory belongs
     */
    public InventoryTool(ItemStack stack) {
    	this.invItem = stack;
    
    	this.name = stack.getDisplayName();
    
    	if (!stack.hasTagCompound()) {
    		stack.setTagCompound(new NBTTagCompound());
    	}
    
    	readFromNBT(stack.getTagCompound());
    }
    
    public void checkContents() {
    	if(this.getStackInSlot(0) != null && this.getStackInSlot(0).getItem() == Main.autoRepair) {
    		check = true;
    	} else check = false;
    
    	System.out.println("YO");
    }
    
    @Override
    public int getSizeInventory() {
    	return slots.length;
    }
    
    @Override
    public ItemStack getStackInSlot(int slot) {
    	return slots[slot];
    }
    
    @Override
    public ItemStack decrStackSize(int slot, int amount) {
    	ItemStack stack = getStackInSlot(slot);
    	if (stack != null) {
    		if (stack.stackSize > amount) {
    			stack = stack.splitStack(amount);
    
    			markDirty();
    		} else {
    			setInventorySlotContents(slot, null);
    		}
    	}
    	return stack;
    }
    
    @Override
    public ItemStack getStackInSlotOnClosing(int slot) {
    	ItemStack stack = getStackInSlot(slot);
    	if (stack != null) {
    		setInventorySlotContents(slot, null);
    	}
    	return stack;
    }
    
    @Override
    public void setInventorySlotContents(int slot, ItemStack itemstack) {
    	this.slots[slot] = itemstack;
    
    	if (itemstack != null && itemstack.stackSize > this.getInventoryStackLimit()) {
    		itemstack.stackSize = this.getInventoryStackLimit();
    	}
    
    
    	markDirty();
    }
    
    @Override
    public String getInventoryName() {
    	return name;
    }
    
    @Override
    public boolean hasCustomInventoryName() {
    	return name.length() > 0;
    }
    
    @Override
    public int getInventoryStackLimit() {
    	return 1;
    }
    
    @Override
    public void markDirty() {
    	for (int i = 0; i < getSizeInventory(); ++i) {
    		if (getStackInSlot(i) != null && getStackInSlot(i).stackSize == 0)
    			slots[i] = null;
    	}
    
    	writeToNBT(invItem.getTagCompound());
    }
    
    @Override
    public boolean isUseableByPlayer(EntityPlayer player) {
    
    	return player.getHeldItem() == invItem;
    }
    
    @Override
    public void openInventory() {
    	checkContents();
    
    	System.out.println("YEAH");
    }
    
    @Override
    public void closeInventory() {
    	checkContents();
    }
    
    /**
     * This method doesn't seem to do what it claims to do, as items can still
     * be left-clicked and placed in the inventory even when this returns false
     */
    @Override
    public boolean isItemValidForSlot(int slot, ItemStack itemstack) {
    
    	return itemstack.getItem() instanceof ItemToolUpgrade;
    }
    
    /**
     * A custom method to read our inventory from an ItemStack's NBT compound
     */
    public void readFromNBT(NBTTagCompound compound) {
    	NBTTagList items = compound.getTagList("ItemInventory", Constants.NBT.TAG_COMPOUND);
    
    	for (int i = 0; i < items.tagCount(); ++i) {
    		NBTTagCompound item = (NBTTagCompound) items.getCompoundTagAt(i);
    		byte slot = item.getByte("Slot");
    
    		if (slot >= 0 && slot < getSizeInventory()) {
    			slots[slot] = ItemStack.loadItemStackFromNBT(item);
    		}
    	}
    }
    
    /**
     * A custom method to write our inventory to an ItemStack's NBT compound
     */
    public void writeToNBT(NBTTagCompound tagcompound) {
    	NBTTagList items = new NBTTagList();
    
    	for (int i = 0; i < getSizeInventory(); ++i) {
    
    		if (getStackInSlot(i) != null) {
    
    			NBTTagCompound item = new NBTTagCompound();
    			item.setInteger("Slot", i);
    
    			getStackInSlot(i).writeToNBT(item);
    
    			items.appendTag(item);
    		}
    	}
    
    	tagcompound.setTag("ItemInventory", items);
    }
    }
    

     

     

  3. Just in case you have some interest,

     

    I made some system called "ItemEntity" which is TileEntity for Items.

    You don't need it in this case, but if you want some Position-Based Item functionality,

    You would really need something like my "ItemEntity", as ItemStack does not contain any position information.

     

    So.. if you have any interest, PM me.

    Thanks for the side info. If I ever need to use a position based item, i know your the guy to talk to ;)

  4. ItemStacks can hold NBT themselves.

    What I mean is, I want to have like a tile entity but for an item. So when I right click the item i can put stuff in different slots. (Like a backpack sort of). Something similar to the way the villager GUI screen works... (Cause the villager screen doesn't have a tile entity)

  5. So I'm trying to make an item, once you right click it, it opens a GUI & container etc... but I don't think I can use a tile entity to store data for this (cause an item isn't a tile). Is there like an alternate tile entity for items or something? Or a way to store nbt data for the container and add slots? Thnx

  6. That's what I want, I want it to set the spawn point in the dimension. It does do that, but whenever I restart the game or re enter the world it doesn't save the location and it "resets". however... It seems to work on the surface (it saves) but not in my dimension...

     

    Like I said, you need to write your own code for this. Use IExtendedEntityProperties it's called and then use that to save the coordinates.

    Ok got it, thnx

  7. Ive made it so when u right click a sattelite it sets your spawn point in my dimension (not the surface!). This works fine... except after i restart the world or game the spawn point "resets". Yes, i probably need to use nbt data but how would i go about doing that in the block class?

     

    BlockSattelite:

     

     

    package com.manslaughter777.moondimension.blocks;
    
    import com.manslaughter777.moondimension.Main;
    
    import net.minecraft.block.Block;
    import net.minecraft.block.material.Material;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.util.ChatComponentText;
    import net.minecraft.util.IChatComponent;
    import net.minecraft.world.World;
    
    public class BlockSattelite extends Block {
    
    public BlockSattelite() {
    	super(Material.iron);
    
    	this.setBlockName("sattelite");
    	this.setBlockTextureName(Main.MODID + ":sattelite");
    	this.setCreativeTab(Main.moonTab);
    	this.setHardness(4.5F);
    }
    
    public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_)
        {
    	if(world.provider.dimensionId == Main.dimensionId) {
    		world.setSpawnLocation(x, y, z); //BlockBed
    		player.addChatMessage(new ChatComponentText("[sattelite] Activated! Moon Navigator's will now point to this sattelite"));
    	}
            
    	return true;
        }
    
    }
    
    

     

     

     

    Umm.. This world.setSpawnLocation(x, y, z); re-sets it for the entire world. Try to set it for the player specifically. You might have to write your own code for this.

    That's what I want, I want it to set the spawn point in the dimension. It does do that, but whenever I restart the game or re enter the world it doesn't save the location and it "resets". however... It seems to work on the surface (it saves) but not in my dimension...

  8. I am trying to create a flame that lights a portal. It lights the portal in the other dimension it leads to but not the overworld. Can't figure out why

     

    package com.puplet.blocks;
    
    import static net.minecraftforge.common.util.ForgeDirection.DOWN;
    import static net.minecraftforge.common.util.ForgeDirection.EAST;
    import static net.minecraftforge.common.util.ForgeDirection.NORTH;
    import static net.minecraftforge.common.util.ForgeDirection.SOUTH;
    import static net.minecraftforge.common.util.ForgeDirection.UP;
    import static net.minecraftforge.common.util.ForgeDirection.WEST;
    
    import com.puplet.dimension.dimensionRegistry;
    
    import net.minecraft.block.BlockFire;
    import net.minecraft.util.AxisAlignedBB;
    import net.minecraft.world.World;
    
    public class BlockTeleporterFire extends BlockFire{
    
    public BlockTeleporterFire(){
    	super();
    }
    
    public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_)
        {
            return null;
        }
    
     public int getRenderType()
        {
            return 3;
        }
    
    public void onBlockAdded(World par1World, int par2, int par3, int par4)
    {
    	/** Change these to your portal frame and Portal block **/
    	if (par1World.getBlock(par2, par3 - 1, par4) != PupletBlocks.pupletOre || !((BlockTeleporter) PupletBlocks.blockTeleporter).tryToCreatePortal(par1World, par2, par3, par4))
    	{
    		if ((!par1World.doesBlockHaveSolidTopSurface(par1World, par2, par3 - 1, par4)) && (!canNeighborBurn(par1World, par2, par3, par4)))
    		{
    			par1World.setBlockToAir(par2, par3, par4);
    		}
    		else
    		{
    			par1World.scheduleBlockUpdate(par2, par3, par4, this, tickRate(par1World) + par1World.rand.nextInt(10));
    		}
    	}
    }
    
     private boolean canNeighborBurn(World p_149847_1_, int p_149847_2_, int p_149847_3_, int p_149847_4_)
        {
            return this.canCatchFire(p_149847_1_, p_149847_2_ + 1, p_149847_3_, p_149847_4_, WEST ) ||
                   this.canCatchFire(p_149847_1_, p_149847_2_ - 1, p_149847_3_, p_149847_4_, EAST ) ||
                   this.canCatchFire(p_149847_1_, p_149847_2_, p_149847_3_ - 1, p_149847_4_, UP   ) ||
                   this.canCatchFire(p_149847_1_, p_149847_2_, p_149847_3_ + 1, p_149847_4_, DOWN ) ||
                   this.canCatchFire(p_149847_1_, p_149847_2_, p_149847_3_, p_149847_4_ - 1, SOUTH) ||
                   this.canCatchFire(p_149847_1_, p_149847_2_, p_149847_3_, p_149847_4_ + 1, NORTH);
        }
    
    }
    

     

    Instead of saying !((BlockTeleporter) PuppletBlocks. Etc...

    Try !((BlockPortal) PuppletBlock etc...

     

    So pretty much change the cast from BlockTeleporter to BlockPortal

     

    If that doesnt work ill look at my portal code when I get on my pc and see why urs isn't working

  9. Ive made it so when u right click a sattelite it sets your spawn point in my dimension (not the surface!). This works fine... except after i restart the world or game the spawn point "resets". Yes, i probably need to use nbt data but how would i go about doing that in the block class?

     

    BlockSattelite:

     

     

    package com.manslaughter777.moondimension.blocks;
    
    import com.manslaughter777.moondimension.Main;
    
    import net.minecraft.block.Block;
    import net.minecraft.block.material.Material;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.util.ChatComponentText;
    import net.minecraft.util.IChatComponent;
    import net.minecraft.world.World;
    
    public class BlockSattelite extends Block {
    
    public BlockSattelite() {
    	super(Material.iron);
    
    	this.setBlockName("sattelite");
    	this.setBlockTextureName(Main.MODID + ":sattelite");
    	this.setCreativeTab(Main.moonTab);
    	this.setHardness(4.5F);
    }
    
    public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_)
        {
    	if(world.provider.dimensionId == Main.dimensionId) {
    		world.setSpawnLocation(x, y, z); //BlockBed
    		player.addChatMessage(new ChatComponentText("[sattelite] Activated! Moon Navigator's will now point to this sattelite"));
    	}
            
    	return true;
        }
    
    }
    
    

     

     

  10. You could just set the armor in the Constructor, instead of the random method. (Might work might not, might be a better way. Correct me if I;m wrong.)

    Tried that but didnt work :( but here is something I found... I make the entity drop a leather chestplate on death but it sometimes drops 2, which means that it is dropping its "worn" armor aswell. So it seems that the entity HAS armor on but I can't see it. I will try adding diamond armor to it to see if it gets more stronger. Must be some rendering issue though...

  11. All i want is for my entity to always spawn with armor. Tried addRandomArmor but doesnt work.

     

    Entity class:

     

     

    package com.manslaughter777.moondimension.entity;
    
    import java.util.Random;
    
    import com.manslaughter777.moondimension.Main;
    
    import net.minecraft.block.Block;
    import net.minecraft.entity.SharedMonsterAttributes;
    import net.minecraft.entity.ai.EntityAIAttackOnCollide;
    import net.minecraft.entity.ai.EntityAIHurtByTarget;
    import net.minecraft.entity.ai.EntityAILookIdle;
    import net.minecraft.entity.ai.EntityAIMoveThroughVillage;
    import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction;
    import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
    import net.minecraft.entity.ai.EntityAISwimming;
    import net.minecraft.entity.ai.EntityAIWander;
    import net.minecraft.entity.ai.EntityAIWatchClosest;
    import net.minecraft.entity.monster.EntityMob;
    import net.minecraft.entity.monster.EntityZombie;
    import net.minecraft.entity.passive.EntityVillager;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.init.Blocks;
    import net.minecraft.init.Items;
    import net.minecraft.item.Item;
    import net.minecraft.item.ItemStack;
    import net.minecraft.world.EnumDifficulty;
    import net.minecraft.world.World;
    import net.minecraftforge.common.ForgeModContainer;
    
    public class EntitySpaceman extends EntityMob {
    
    public EntitySpaceman(World world) {
    	super(world);
            
         this.getNavigator().setBreakDoors(true);
         this.tasks.addTask(0, new EntityAISwimming(this));
         this.tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.0D, false));
         this.tasks.addTask(4, new EntityAIAttackOnCollide(this, EntityVillager.class, 1.0D, true));
         this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 1.0D));
         this.tasks.addTask(6, new EntityAIMoveThroughVillage(this, 1.0D, false));
         this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
         this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
    
         this.tasks.addTask(8, new EntityAILookIdle(this));
         this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true));
         //this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true));;
         
         this.setSize(0.6F, 1.8F);
         this.setCustomNameTag("Spaceman");
         this.setCanPickUpLoot(true);
         this.setAlwaysRenderNameTag(true);
      
    }
    
    
    @Override
    protected void addRandomArmor()
        {
    	this.setCurrentItemOrArmor(4, new ItemStack(Items.leather_helmet));
    	this.setCurrentItemOrArmor(3, new ItemStack(Items.leather_chestplate));
    	this.setCurrentItemOrArmor(2, new ItemStack(Items.leather_leggings));
    	this.setCurrentItemOrArmor(1, new ItemStack(Items.leather_boots));
        }
        
        protected Item getDropItem()
        {
            return Main.powerstone;
        }
        
        /**
         * Drop 0-2 items of this living's type. @param par1 - Whether this entity has recently been hit by a player. @param
         * par2 - Level of Looting used to kill this mob.
         */
        protected void dropFewItems(boolean recentlyHit, int lootingLevel) {
        	Random ran = new Random();
        	
        	ItemStack ironSword = new ItemStack(Items.iron_sword);
        	ItemStack ironPickaxe = new ItemStack(Items.iron_pickaxe);
        	ItemStack moonHelmet = new ItemStack(Items.leather_helmet);
        	ItemStack moonChestplate = new ItemStack(Items.leather_chestplate);
        	ItemStack moonLeggings = new ItemStack(Items.leather_leggings);
        	ItemStack moonBoots = new ItemStack(Items.leather_boots);
        	
        	ironSword.setItemDamage(165 + ran.nextInt(40));	
        	ironPickaxe.setItemDamage(165 + ran.nextInt(40));
        	moonHelmet.setItemDamage(30 + ran.nextInt(10));
        	moonChestplate.setItemDamage(30 + ran.nextInt(10));
        	moonLeggings.setItemDamage(30 + ran.nextInt(10));
        	moonBoots.setItemDamage(30 + ran.nextInt(10));
        	
        	//drops
        	if(ran.nextInt(2) == 0) entityDropItem(ironSword, 1F);
        	if(ran.nextInt(2) == 0) entityDropItem(ironPickaxe, 1F);
        	if(ran.nextInt(2) == 0) entityDropItem(moonHelmet, 1F);
        	if(ran.nextInt(2) == 0) entityDropItem(moonChestplate, 1F);
        	if(ran.nextInt(2) == 0) entityDropItem(moonLeggings, 1F);
        	if(ran.nextInt(2) == 0) entityDropItem(moonBoots, 1F);
        	dropItem(Item.getItemFromBlock(Blocks.dirt), 10 + ran.nextInt(12));
        	dropItem(Item.getItemFromBlock(Main.regolith), 10 + ran.nextInt(12));
        	dropItem(Item.getItemFromBlock(Blocks.stone), 16 + ran.nextInt(25));
        	dropItem(Item.getItemFromBlock(Main.moonStone), 16 + ran.nextInt(25));
        	dropItem(Item.getItemFromBlock(Blocks.log), 3 + ran.nextInt(3));
        	dropItem(Item.getItemFromBlock(Blocks.planks), 10 + ran.nextInt(12));
        	dropItem(Item.getItemFromBlock(Blocks.crafting_table), ran.nextInt(2));
        	dropItem(Item.getItemFromBlock(Blocks.chest), ran.nextInt(2));
        	
        	dropItem(Items.iron_ingot, 2 + ran.nextInt(3));
        	dropItem(Items.string, 2 + ran.nextInt(3));
        	dropItem(Items.bucket, ran.nextInt(2));
        	dropItem(Items.stick, 3 + ran.nextInt(4));
        	dropItem(Main.powerstone, 2 + ran.nextInt();
        	dropItem(Items.bread, 2 + ran.nextInt(3));
        	dropItem(Items.cooked_porkchop, 2 + ran.nextInt(3));
        	dropItem(Items.potato, ran.nextInt(3));
        	dropItem(Items.carrot, ran.nextInt(3));		  	
        }
        
        protected void dropRareDrop(int p_70600_1_)
        {
            this.entityDropItem(new ItemStack(Main.moonCrystal), 0.0F);
        }
        
        /*
        protected String getLivingSound()
        {
            return "";
        } */
    
        /**
         * Returns the sound this mob makes when it is hurt.
         */
        /*
        protected String getHurtSound()
        {
            return "";
        }
        */
    
        /**
         * Returns the sound this mob makes on death.
         */
        /*
        protected String getDeathSound()
        {
            return "";
        }
        */
    
        protected void func_145780_a(int p_145780_1_, int p_145780_2_, int p_145780_3_, Block p_145780_4_)
        {
            this.playSound("mob.zombie.step", 0.15F, 1.0F);
        }
    
        /*
    protected void applyEntityAttributes()
        {
            super.applyEntityAttributes();
            this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(40.0D);
            this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.23000000417232513D);
            this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(3.0D);
            this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D);
        }
        */
        @Override
        protected void applyEntityAttributes()
        {
            super.applyEntityAttributes();
            this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(40.0D);
            this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.23000000417232513D);
            this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(3.0D);
            
        }
    
    protected boolean isAIEnabled()
        {
            return true;
        }
    
    }
    
    
    

     

     

  12. Calling that function isn't going to do you any good (see below).  As soon as the entity gets another update tick, its air supply will reset.

     

    I told you to use IEEP to track "your" air.  Which means replicating the effects of that private function on "your" data.

     

     if (this.isEntityAlive() && this.isInsideOfMaterial(Material.water)) { //stuff }
    else {
        this.setAir(300);
    }

     

    No matter what you do to the air supply of an entity, if it is not in water, that air supply value will ALWAYS be reset.

    How would I go about tracking "my" air and replicating it? (Sorry for late reply)

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.