Jump to content

[1.7.10]Freeze when using custom container without any console output


SuperKael

Recommended Posts

I am working on a mod for this youtuber named CrinkleCraft's modpack, and it's primary purpose is it adds a block called the "blood bottler." for a while, it has contained blood based on a simple integer, but I wanted to make it use an actual tank. I set it up to use a FluidTankAdv from CoFHCore, and I had a couple issues. first of all, the tank is missing a texture. Although I can probably work that issue out. that problem I came here for is that, when I put in some glass bottles to be filled, the game froze. It froze so badly, I need to reboot my computer to get Minecraft to close. Now, freezes of this nature aren't particularly rare, I blame it on my terrible graphics card, but It has never frozen for any known reason before. As it said in the Subject, there was no console output of any kind. Here is all of my potentialy relevant code:

 

EDIT: Since apparently it wasn't clear, there IS NO CRASH REPORT. Technicaly, it never crashed. it just froze, it never shut down because I had to forcibly reboot my computer.

 

BottleOBlood

package bottleoblood;

import java.util.List;

import bottleoblood.block.*;
import bottleoblood.event.BucketHandler;
import bottleoblood.fluid.*;
import bottleoblood.item.*;
import bottleoblood.tileentity.*;
import bottleoblood.client.gui.*;
import net.minecraft.block.*;
import net.minecraft.block.material.Material;
import net.minecraft.init.Items;
import net.minecraft.item.*;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import cpw.mods.fml.common.*;
import cpw.mods.fml.common.Mod.*;
import cpw.mods.fml.common.event.*;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;

@Mod(modid = ModInfo.MODID, version = ModInfo.VERSION, name = ModInfo.MODNAME, dependencies = ModInfo.DEPENDENCIES)
public class BottleOBlood{

@Instance("BottleOBlood")
public static BottleOBlood instance;
    public static Item itemBottleBlood;
    public static Item itemCorruptBottleBlood;
    public static Item itemVampiricBottleBlood;
    public static Item itemBucketBlood;
    public static Item itemCorruptBucketBlood;
    public static Item itemVampiricBucketBlood;
    public static BlockContainer blockBloodBottler;
    public static Block bloodNormal;
    public static Block bloodCorrupt;
    public static Block bloodVampiric;
    public static Fluid bloodNormalFluid;
    public static Fluid bloodCorruptFluid;
    public static Fluid bloodVampiricFluid;
    public boolean isVampZInstalled;
    public boolean isEvilCraftInstalled;
    public boolean isBloodMagicInstalled;
    public boolean isNecromancyInstalled;
    public boolean isBiomesOPlentyInstalled;
    public boolean isCannibalismInstalled;
    public boolean isVampiricBloodEnabled;
    public boolean isCorruptBloodEnabled;
    public boolean isVampiricBloodExtractable;
    public boolean isCorruptBloodExtractable;
    
    @EventHandler
    public void preinit(FMLPreInitializationEvent event){
    	Configuration config = new Configuration(event.getSuggestedConfigurationFile());

    	config.load();

    	Property isVampiricBloodEnabledProperty = config.get(Configuration.CATEGORY_GENERAL, "enableVampiricBlood", false);
    	Property isCorruptBloodEnabledProperty = config.get(Configuration.CATEGORY_GENERAL, "enableCorruptBlood", true);
    	Property isVampiricBloodExtractableProperty = config.get(Configuration.CATEGORY_GENERAL, "enableVampiricBloodExtraction", true);
    	Property isCorruptBloodExtractableProperty = config.get(Configuration.CATEGORY_GENERAL, "enableCorruptBloodExtraction", true);
    	
    	isVampiricBloodEnabledProperty.comment = "Setting this to true will enable extraction of vampiric blood. if set to false, you will only be able to get normal blood. Default: false";
    	isCorruptBloodEnabledProperty.comment = "Setting this to true will enable extraction of corrupt blood. if set to false, you will only be able to get normal blood. Default: true";
    	isVampiricBloodExtractableProperty.comment = "Sets if it is possible to extract blood from items containing vampiric blood. the previous setting does not affect this. Default: true";
    	isCorruptBloodExtractableProperty.comment = "Sets if it is possible to extract blood from items containing corrupt blood. the previous setting does not affect this. Default: true";
    	
    	isVampiricBloodEnabled = isVampiricBloodEnabledProperty.getBoolean(false);
    	isCorruptBloodEnabled = isCorruptBloodEnabledProperty.getBoolean(true);
    	isVampiricBloodExtractable = isVampiricBloodExtractableProperty.getBoolean(true);
    	isCorruptBloodExtractable = isCorruptBloodExtractableProperty.getBoolean(true);
    	
    	config.save();
    	
    	MinecraftForge.EVENT_BUS.register(BucketHandler.INSTANCE);
    }

    @EventHandler
public void init(FMLInitializationEvent event){
    	itemBottleBlood = new ItemBottleBlood();
    	itemCorruptBottleBlood = new ItemCorruptBottleBlood();
    	itemVampiricBottleBlood = new ItemVampiricBottleBlood();
    	itemBucketBlood = new ItemBucketBlood();
    	itemCorruptBucketBlood = new ItemCorruptBucketBlood();
    	itemVampiricBucketBlood = new ItemVampiricBucketBlood();
    	
    	blockBloodBottler = new BlockBloodBottler();
    	
    	bloodNormalFluid = new Fluid("blood");
    	bloodVampiricFluid = new Fluid("bloodVampiric");
    	bloodCorruptFluid = new Fluid("bloodCorrupt");
    	
    	FluidRegistry.registerFluid(bloodNormalFluid);
    	FluidRegistry.registerFluid(bloodVampiricFluid);
    	FluidRegistry.registerFluid(bloodCorruptFluid);
    	
    	bloodNormal = new BlockBloodNormal(bloodNormalFluid, Material.water).setBlockName("blood");
    	bloodVampiric = new BlockBloodVampiric(bloodVampiricFluid, Material.water).setBlockName("bloodVampiric");
    	bloodCorrupt = new BlockBloodCorrupt(bloodCorruptFluid, Material.water).setBlockName("bloodNormal");
    	
    	GameRegistry.registerBlock(blockBloodBottler, "blockBloodBottler");
    	
    	GameRegistry.registerBlock(bloodNormal, "blood");
    	GameRegistry.registerBlock(bloodVampiric, "bloodVampiric");
    	GameRegistry.registerBlock(bloodCorrupt, "bloodCorrupt");
    	
    	GameRegistry.registerItem(itemBottleBlood, "itemBottleBlood");
    	GameRegistry.registerItem(itemCorruptBottleBlood, "itemCorruptBottleBlood");
    	GameRegistry.registerItem(itemVampiricBottleBlood, "itemVampiricBottleBlood");
    	GameRegistry.registerItem(itemBucketBlood, "itemBucketBlood");
    	GameRegistry.registerItem(itemCorruptBucketBlood, "itemBucketCorruptBlood");
    	GameRegistry.registerItem(itemVampiricBucketBlood, "itemBucketVampiricBlood");
    	
    	FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluidStack(bloodNormalFluid.getName(), FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(itemBucketBlood,1), new ItemStack(Items.bucket,1));
    	FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluidStack(bloodCorruptFluid.getName(), FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(itemCorruptBucketBlood,1), new ItemStack(Items.bucket,1));
    	FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluidStack(bloodVampiricFluid.getName(), FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(itemVampiricBucketBlood,1), new ItemStack(Items.bucket,1));
    	
    	BucketHandler.INSTANCE.buckets.put(bloodNormal, itemBucketBlood);
    	BucketHandler.INSTANCE.buckets.put(bloodCorrupt, itemCorruptBucketBlood);
    	BucketHandler.INSTANCE.buckets.put(bloodVampiric, itemVampiricBucketBlood);
    	
    	GameRegistry.registerTileEntity(BloodBottlerEntity.class, "entityBloodBottler");
    	
    	NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler());
}
    
    @EventHandler
    public void postinit(FMLPostInitializationEvent event){
    	if(Loader.isModLoaded("vampz") && Loader.isModLoaded("evilcraft")){
    		GameRegistry.addShapedRecipe(new ItemStack(blockBloodBottler), "###", "#$#", "###", '#', GameRegistry.findBlock("vampz", "Bloodycobblestone"), '$', GameRegistry.findItem("evilcraft", "bloodInfusionCore"));
        }
    	if(Loader.isModLoaded("vampz")){
    		isVampZInstalled = true;
    		try{
    			GameRegistry.addShapelessRecipe(new ItemStack(itemCorruptBottleBlood), GameRegistry.findItem("vampz", "CorruptedBlood"), Items.glass_bottle);
    			GameRegistry.addShapelessRecipe(new ItemStack(itemBottleBlood), GameRegistry.findItem("vampz", "Blood"), Items.glass_bottle);
    			GameRegistry.addShapelessRecipe(new ItemStack(itemBottleBlood), GameRegistry.findItem("vampz", "CowBlood"), Items.glass_bottle);
    			GameRegistry.addShapelessRecipe(new ItemStack(itemBottleBlood), GameRegistry.findItem("vampz", "SheepBlood"), Items.glass_bottle);
    			GameRegistry.addShapelessRecipe(new ItemStack(itemBottleBlood), GameRegistry.findItem("vampz", "ChickenBlood"), Items.glass_bottle);
    		}catch(Exception e){}
    		@SuppressWarnings("unchecked")
		List<IRecipe> Recipes = (List<IRecipe>)CraftingManager.getInstance().getRecipeList();
    		try{
    			for(int i = 0;i < Recipes.size();i++){
    				if(Recipes.get(i).getRecipeOutput().equals(new ItemStack(GameRegistry.findItem("vampz", "BottleOfBlood")))){
    					Recipes.remove(i);
    				}
    			}
    		}catch(Exception e){}
    		System.out.println("Successfuly loaded mod VampZ");
    	}else{
    		isVampZInstalled = false;
    		System.err.println("Unable to load mod VampZ! It is recomended that you install this! If you have and are getting this message, please contact SuperKael.");
    	}
    	if(Loader.isModLoaded("evilcraft")){
    		isEvilCraftInstalled = true;
    		System.out.println("Successfuly loaded mod EvilCraft");
    	}else{
    		isEvilCraftInstalled = false;
    		System.err.println("Unable to load mod EvilCraft! It is recomended that you install this! If you have and are getting this message, please contact SuperKael.");
    	}
    	if(Loader.isModLoaded("AWWayofTime")){
    		isBloodMagicInstalled = true;
    		System.out.println("Successfuly loaded mod Blood Magic");
    	}else{
    		isBloodMagicInstalled = false;
    		System.out.println("Didn't load mod Blood Magic because it is not present.");
    	}
    	if(Loader.isModLoaded("necromancy")){
    		isNecromancyInstalled = true;
    		System.out.println("Successfuly loaded mod Necromancy");
    	}else{
    		isNecromancyInstalled = false;
    		System.out.println("Didn't load mod Necromancy because it is not present.");
    	}
    	if(Loader.isModLoaded("BiomesOPlenty")){
    		isBiomesOPlentyInstalled = true;
    		System.out.println("Successfuly loaded mod Biomes O Plenty");
    	}else{
    		isBiomesOPlentyInstalled = false;
    		System.out.println("Didn't load mod Biomes O Plenty because it is not present.");
    	}
    	if(Loader.isModLoaded("cannibalism")){
    		isCannibalismInstalled = true;
    		System.out.println("Successfuly loaded mod Cannibalism");
    	}else{
    		isCannibalismInstalled = false;
    		System.out.println("Didn't load mod Cannibalism because it is not present.");
    	}
    }
}

 

BloodBottlerEntity (Warning, a bit larger than it probably realy needs to be)

EDIT: Removed large portions of the code that you don't need to see, with a basic explanation of what the method does.

package bottleoblood.tileentity;

import cofh.core.util.fluid.FluidTankAdv;
import cpw.mods.fml.common.registry.GameRegistry;
import bottleoblood.BottleOBlood;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidContainerItem;
import net.minecraftforge.fluids.IFluidHandler;
import net.minecraftforge.fluids.ItemFluidContainer;

public class BloodBottlerEntity extends TileEntity implements IFluidHandler, ISidedInventory{
    public ItemStack[] inv;
    FluidTankAdv tank = new FluidTankAdv(10000);

    public BloodBottlerEntity(){
        inv = new ItemStack[4];
        
    }
   
    @Override
    public int getSizeInventory(){
        return inv.length;
    }

    @Override
    public ItemStack getStackInSlot(int slot){
        return inv[slot];
    }
   
    @Override
    public void setInventorySlotContents(int slot, ItemStack stack){
        inv[slot] = stack;
        if(stack != null && stack.stackSize > getInventoryStackLimit()){
            stack.stackSize = getInventoryStackLimit();
        }              
    }

    @Override
    public ItemStack decrStackSize(int slot, int amt) {
        ItemStack stack = getStackInSlot(slot);
        if (stack != null) {
            if (stack.stackSize <= amt) {
                setInventorySlotContents(slot, null);
            } else {
                stack = stack.splitStack(amt);
                if (stack.stackSize == 0) {
                    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 int getInventoryStackLimit() {
        return 64;
    }

    @Override
    public boolean isUseableByPlayer(EntityPlayer player) {
        return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this &&
        player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64;
    }
   
    @Override
    public void readFromNBT(NBTTagCompound tagCompound){
    	super.readFromNBT(tagCompound);
        NBTTagList nbttaglist = tagCompound.getTagList("Items", 10);
        this.inv = new ItemStack[this.getSizeInventory()];
        for (int i = 0; i < nbttaglist.tagCount(); ++i){
            NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
            int j = nbttagcompound.getByte("Slot") & 255;
            if (j >= 0 && j < this.inv.length){
                this.inv[j] = ItemStack.loadItemStackFromNBT(nbttagcompound);
            }
        }
        readFromSyncableNBT(tagCompound);
    }

    @Override
    public void writeToNBT(NBTTagCompound tagCompound){
    	super.writeToNBT(tagCompound);
        NBTTagList nbttaglist = new NBTTagList();
        for(int i = 0; i < this.inv.length; ++i){
            if(this.inv[i] != null){
                NBTTagCompound nbttagcompound = new NBTTagCompound();
                nbttagcompound.setByte("Slot", (byte)i);
                this.inv[i].writeToNBT(nbttagcompound);
                nbttaglist.appendTag(nbttagcompound);
            }
        }
        tagCompound.setTag("Items", nbttaglist);
        writeToSyncableNBT(tagCompound);
    }
    
    public void readFromSyncableNBT(NBTTagCompound tagCompound){
    	tank.readFromNBT(tagCompound);
    }
    public void writeToSyncableNBT(NBTTagCompound tagCompound){
    	tank.writeToNBT(tagCompound);
    }

@Override
public String getInventoryName(){
	return "bottleoblood.bloodBottlerEntity";
}

@Override
public boolean hasCustomInventoryName(){
	return false;
}

@Override
public void openInventory(){

}

@Override
public void closeInventory(){
}

@Override
public boolean isItemValidForSlot(int slot, ItemStack item){
	switch(slot){
		case 0:
			if(isItemBlood(item) || isItemBloodContainer(item)){
				return true;
			}
		case 2:
			if(item.getItem() == Items.glass_bottle || isItemBloodContainer(item)){
				return true;
			}else{
				return false;
			}
	}
	return false;
}

public static boolean isItemBlood(ItemStack item){
	// SNIP - Returns true if item has a blood value.
       }

public static int getItemBloodValue(ItemStack item){
	// SNIP - Returns how much blood, in mBs, an item contains.
        }

public static ItemStack getBloodItemReturn(ItemStack item){
	// SNIP - Returns, as an ItemStack, what should be returned after extracting blood from an item. returns null if should return nothing.
}

public static Fluid getItemBloodType(ItemStack item){
	// SNIP - Returns, as a Fluid, what type of blood is produced by an item (BottleOBLood.bloodNormalFluid,BottleOBlood.bloodCorruptFluid, or BottleOBlood.bloodVampiricFluid)
}

@Override
public void updateEntity(){
	if(!worldObj.isRemote){
		if(inv[0] != null && inv[0].stackSize > 0){
			if(tank.getFluidAmount() < 10000){
				if(isItemBloodContainer(inv[0])){
					IFluidContainerItem fluidContainer = (IFluidContainerItem)inv[0].getItem();
					if(fluidContainer.getFluid(inv[0]) != null && (fluidContainer.getFluid(inv[0]).amount > 0 && fluidContainer.getFluid(inv[0]).getFluid().equals(FluidRegistry.getFluid("evilcraftblood")))){
						int bloodToDrain = Math.min(fluidContainer.getFluid(inv[0]).amount, 100);
						tank.fill(fluidContainer.drain(inv[0], bloodToDrain, true),true);
						worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
						markDirty();
					}
				}else{
					if(isItemBlood(inv[0])){
						if(!BottleOBlood.instance.isCorruptBloodExtractable && getItemBloodType(inv[0]) == BottleOBlood.bloodCorruptFluid)return;
						if(!BottleOBlood.instance.isVampiricBloodExtractable && getItemBloodType(inv[0]) == BottleOBlood.bloodVampiricFluid)return;
						tank.fill(new FluidStack(getItemBloodType(inv[0]),getItemBloodValue(inv[0])),true);
						ItemStack outputStack = getBloodItemReturn(inv[0]);
						if(outputStack != null){
							if(inv[1] == null){
								inv[1] = outputStack;
							}else if(inv[1].getItem() == outputStack.getItem() && inv[1].stackSize < 64){
								inv[1].stackSize++;
							}
						}
						if(getItemBloodType(inv[0]) != BottleOBlood.bloodNormalFluid){
							if(BottleOBlood.instance.isCorruptBloodEnabled && getItemBloodType(inv[0]) == BottleOBlood.bloodCorruptFluid){
								tank.setFluid(new FluidStack(BottleOBlood.bloodCorruptFluid,tank.getFluidAmount()));
							}
							if(BottleOBlood.instance.isVampiricBloodEnabled && (getItemBloodType(inv[0]) == BottleOBlood.bloodVampiricFluid && tank.getFluid().getFluid() == BottleOBlood.bloodNormalFluid)){
								tank.setFluid(new FluidStack(BottleOBlood.bloodVampiricFluid,tank.getFluidAmount()));
							}
						}
						inv[0].stackSize--;
						if(inv[0].stackSize < 1)inv[0] = null;
						worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
						markDirty();
					}
				}
			}
		}
		if(inv[2] != null && inv[2].stackSize > 0){
			if(inv[2].getItem() == Items.glass_bottle){
				if(tank.getFluidAmount() >= 1000){
					if(tank.getFluid().getFluid() == BottleOBlood.bloodNormalFluid){
						if(inv[3] != null && inv[3].getItem().equals(BottleOBlood.itemBottleBlood)){
							if(inv[3].stackSize < 64){
								inv[3].stackSize += 1;
							}else{
								return;
							}
						}else{
							inv[3] = new ItemStack(BottleOBlood.itemBottleBlood,1);
						}
					}
					if(tank.getFluid().getFluid() == BottleOBlood.bloodCorruptFluid){
						if(inv[3] != null && inv[3].getItem().equals(BottleOBlood.itemCorruptBottleBlood)){
							if(inv[3].stackSize < 64){
								inv[3].stackSize += 1;
							}else{
								return;
							}
						}else{
							inv[3] = new ItemStack(BottleOBlood.itemCorruptBottleBlood,1);
						}
					}
					if(tank.getFluid().getFluid() == BottleOBlood.bloodVampiricFluid){
						if(inv[3] != null && inv[3].getItem().equals(BottleOBlood.itemVampiricBottleBlood)){
							if(inv[3].stackSize < 64){
								inv[3].stackSize += 1;
							}else{
								return;
							}
						}else{
							inv[3] = new ItemStack(BottleOBlood.itemVampiricBottleBlood,1);
						}
					}
					tank.drain(1000, true);
					inv[2].stackSize--;
					if(inv[2].stackSize < 1)inv[2] = null;
					worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
					markDirty();
				}
			}
			if(inv[2].getItem() == Items.bucket){
				if(tank.getFluidAmount() >= 1000 && inv[3] == null){
					if(tank.getFluid().getFluid() == BottleOBlood.bloodNormalFluid){
						if(inv[3] == null){
							inv[3] = new ItemStack(BottleOBlood.itemBucketBlood,1);
						}
					}
					if(tank.getFluid().getFluid() == BottleOBlood.bloodCorruptFluid){
						if(inv[3] == null){
							inv[3] = new ItemStack(BottleOBlood.itemCorruptBucketBlood,1);
						}
					}
					if(tank.getFluid().getFluid() == BottleOBlood.bloodVampiricFluid){
						if(inv[3] == null){
							inv[3] = new ItemStack(BottleOBlood.itemVampiricBucketBlood,1);
						}
					}
					tank.drain(1000, true);
					inv[2].stackSize--;
					if(inv[2].stackSize < 1)inv[2] = null;
					worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
					markDirty();
				}
			}
			if(isItemBloodContainer(inv[2]) && tank.getFluid().getFluid() == BottleOBlood.bloodNormalFluid){
				IFluidContainerItem fluidContainer = (IFluidContainerItem)inv[2].getItem();
				int bloodToDrain = 0;
				if((fluidContainer.getFluid(inv[2]) != null && fluidContainer.getFluid(inv[2]).amount < fluidContainer.getCapacity(inv[2])) && fluidContainer.getFluid(inv[2]).getFluid().equals(FluidRegistry.getFluid("evilcraftblood"))){
					int spaceInContainer = fluidContainer.getCapacity(inv[2]) - fluidContainer.getFluid(inv[2]).amount;
					bloodToDrain = Math.min(tank.getFluidAmount(), spaceInContainer);
					bloodToDrain = Math.min(bloodToDrain, 100);
				}else if(fluidContainer.getFluid(inv[2]) == null){
					bloodToDrain = Math.min(tank.getFluidAmount(), 100);
				};
				fluidContainer.fill(inv[2], tank.drain(bloodToDrain, true), true);
				worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
				markDirty();
			}
		}
	}
}

public int getBloodStoredScaled(float scale){
	return Math.round((float)tank.getFluidAmount() * (scale / 10000f));
}

@Override
public Packet getDescriptionPacket(){
    NBTTagCompound syncData = new NBTTagCompound();
    writeToSyncableNBT(syncData);
    return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, syncData);
}

@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt){
    readFromSyncableNBT(pkt.func_148857_g());
}

@Override
public int[] getAccessibleSlotsFromSide(int side){
	if(side == 0){
		return new int[]{1};
	}else if(side == 1){
		return new int[]{0};
	}else if(side == getWorldObj().getBlockMetadata(xCoord, yCoord, zCoord)){
		return new int[]{3};
	}else{
		return new int[]{2};
	}
}

@Override
public boolean canInsertItem(int par1, ItemStack par2, int par3) {
	return true;
}

@Override
public boolean canExtractItem(int par1, ItemStack par2, int par3) {
	return true;
}

public FluidTankAdv getTank(){
    return this.tank;
}

public int fill(ForgeDirection paramForgeDirection, FluidStack paramFluidStack, boolean paramBoolean){
    return 0;
}
  
public FluidStack drain(ForgeDirection paramForgeDirection, FluidStack paramFluidStack, boolean paramBoolean){
    return this.tank.drain(paramFluidStack.amount, paramBoolean);
}
  
public FluidStack drain(ForgeDirection paramForgeDirection, int paramInt, boolean paramBoolean){
    return this.tank.drain(paramInt, paramBoolean);
}
  
public boolean canFill(ForgeDirection paramForgeDirection, Fluid paramFluid){
    return false;
}
  
public boolean canDrain(ForgeDirection paramForgeDirection, Fluid paramFluid){
    return true;
}
  
public FluidTankInfo[] getTankInfo(ForgeDirection paramForgeDirection){
    return new FluidTankInfo[] { this.tank.getInfo() };
}
}

 

BloodBottlerGui

package bottleoblood.client.gui.tileentity;

//import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;

import org.lwjgl.opengl.GL11;

import cofh.core.gui.GuiBaseAdv;
import cofh.lib.gui.element.ElementFluidTank;
import bottleoblood.container.BloodBottlerContainer;
import bottleoblood.tileentity.BloodBottlerEntity;

public class BloodBottlerGui extends GuiBaseAdv{
BloodBottlerEntity tileEntity;
public BloodBottlerGui(InventoryPlayer inventoryPlayer, BloodBottlerEntity tileEntity) {
	//the container is instantiated and passed to the superclass for handling
	super(new BloodBottlerContainer(inventoryPlayer, tileEntity));
	this.tileEntity = tileEntity;
}

    @Override
    protected void drawGuiContainerForegroundLayer(int param1, int param2){
        //draw text and stuff here
        //the parameters for drawString are: string, x, y, color
        mc.fontRenderer.drawString("Blood Bottler", 5, 3, 4210752);
        //draws "Inventory" or your regional equivalent
        mc.fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 5, ySize - 94, 4210752);
    }
    
    @Override
    protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3){
    	super.func_73866_w_();
        addElement(new ElementFluidTank(this, 43, 13, tileEntity.getTank()));
        //draw your Gui here, only thing you need to change is the path
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        mc.getTextureManager().bindTexture(new ResourceLocation("bottleoblood", "textures/gui/BloodBottlerGui.png"));
        int x = (width - xSize) / 2;
        int y = (height - ySize) / 2;
        drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
        drawTexturedModalRect(x + 43, y + 14, 176, 58, 16, 58);
    }
}

 

GuiHandler

package bottleoblood.client.gui;

import bottleoblood.container.*;
import bottleoblood.client.gui.tileentity.*;
import bottleoblood.tileentity.*;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import cpw.mods.fml.common.network.IGuiHandler;

public class GuiHandler implements IGuiHandler {
        @Override
        public Object getServerGuiElement(int id, EntityPlayer player, World world,
                        int x, int y, int z) {
                TileEntity tileEntity = world.getTileEntity(x, y, z);
                if(tileEntity instanceof BloodBottlerEntity){
                        return new BloodBottlerContainer(player.inventory, (BloodBottlerEntity) tileEntity);
                }
                return null;
        }
        @Override
        public Object getClientGuiElement(int id, EntityPlayer player, World world,
                        int x, int y, int z) {
                TileEntity tileEntity = world.getTileEntity(x, y, z);
                if(tileEntity instanceof BloodBottlerEntity){
                        return new BloodBottlerGui(player.inventory, (BloodBottlerEntity) tileEntity);
                }
                return null;

        }
}

If I ever say something stupid, or simply incorrect, please excuse me. I don't know anything about 1.8 modding, and I don't know much about entities either, But I try to help when I can.

Link to comment
Share on other sites

Um, I told you, A: there was no console output and B: Minecraft never closed, I had to reboot my computer. So basicaly, no crash report at all.

 

EDIT: The last line in the console before the freeze:

 

[14:49:08] [server thread/INFO]: [<USERNAME>: Set own game mode to Creative Mode]

 

That is the very last entry in the log. nothing after that.

If I ever say something stupid, or simply incorrect, please excuse me. I don't know anything about 1.8 modding, and I don't know much about entities either, But I try to help when I can.

Link to comment
Share on other sites

I really hope you are familliar with breakpoints?

 

Anyway, best way to find error is to place breakpoints in all important places and make deeper and deeper search, you should find the line that will actually stop game from working at some point.

I suggest starting with constructors and main MC calls (like mc.displayGuiScreen)

 

If you'll find something, share if there still be a problem.

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

Link to comment
Share on other sites

Yeah, that's my issue. for unknown reasons, I can't run my mod in my workspace. my mods relies on multiple other mods as dependencies, and running it in the workspace results in a crash about 10 seconds after start. so in order to test, I have to export the mod then run it in MultiMC.

 

EDIT: OMG I'VE DONE IT! with the help of CodeChickenCore, and downloading the dev edition of CoFHCore, I got minecraft to run in my dev environment! I will return with results from breakpoints.

 

EDIT 2: Um, hm. apparently I havn't done it. I actually need the source code of CoFHCore :/

If I ever say something stupid, or simply incorrect, please excuse me. I don't know anything about 1.8 modding, and I don't know much about entities either, But I try to help when I can.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

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