Everything posted by Moritz
- Texture Problem
-
Texture Problem
Hello. I writing on a machine which uses modules to work. The modules will be created by my module maker. Very Easy. Now the problem is i use NBTData to safe most informations for the modules. As the same way as tinkers construct as does. Now the info what tells the problem. I made my system so much compatible that everyone can add their own modules. Without adding any Item/BlockID. And this is the Trouble. How do i get The icons? There is no function which makes Icons without using an Item. or i didn't found one. So how can i add icons without using an Itemclass? I looked at IronChest. And there he uses a for loop with ItemDamage. Will not work in my case! Same as TinkersConstruct. Won't work too. how is that solveable?
-
Custom Food Class
First of all you do not need to extends the Item not ItemFood. Its only need for wolves/Pets. If you want to change the max eating time, how much it heals and which (i know you did not ask for it) potioneffects it adds and how much damage/stacksize it loses than you should look not at Item food. Just create your Item look where the player adds food, what you need for changing eating time, and and and. its kinda hard to explain it. By the way i am involved by the baconMod. And why is it hard to explain? Because i am on my phone. But thats not interesting. Now i give you a view hints how to make it because i cant explain it now. These functions are needed: OnRightClick() onEating() MaxDuration() I think thats it. more you do not need for food. By the way how to use it you have to find out yourself^^" Good night. I hope it helps.
-
[1.6.2] [Solved] Config file doesn't work
I do not declare the items in my config! My classes are like this: Modfile: Loads Config: (ConfigCore) ConfigCore: Loads Items/Blocks: TinyBlocksConfig, TinyItemsConfig TinyItems: LoadItems: TinyItems, TinyIDs TinyBlocks: LoadBlocks: TinyBlocks, TinyIDs I and that is only the config^^"
-
[SOLVED][1.6.2] Armor Render Issue? or Code?
Yeah: The item has to look like this: public static Item creeperArmor = new BaconArmor(500, CreeperArmor, ModLoader.addArmor("Creeper"), 0, "modID:Texture", "Creeper Armor"); You do not need to add a creative tab. The creative tab is inside of the class^^
-
Custom food
I am tired of writing tuts or explain something. nope little joke. But in this case you did a good start and i think you get it from yourself. But here is a little help. You can use the class if you want but let the @author inside. I hope this class helps: package minecraftwero.baconMod.common.items; import minecraftwero.baconMod.Bacon; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemFood; import net.minecraft.item.ItemStack; import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; /** * * @author Speiger * */ public class ItemBaconFood extends ItemFood { private String name; public String texture; private PotionEffect[] potion; public ItemBaconFood(int par1, int par2, boolean par3, String par4, String par5, PotionEffect...par7) { super(par1, par2, par3); this.setCreativeTab(Bacon.baconMod); name = par4; texture = par5; potion = par7; this.func_111206_d(par5); } public ItemBaconFood(int par1, int par2, boolean par3, String par4, String par5) { this(par1, par2, par3, par4, par5, new PotionEffect(0, 0, 0)); } public String getItemDisplayName(ItemStack par1) { return name; } @SideOnly(Side.CLIENT) @Override public void registerIcons(IconRegister par1IconRegister) { this.itemIcon = par1IconRegister.registerIcon(texture); } @Override public ItemStack onEaten(ItemStack par1, World par2, EntityPlayer par3) { --par1.stackSize; par3.getFoodStats().addStats(this); par2.playSoundAtEntity(par3, "random.burp", 0.5F, par2.rand.nextFloat() * 0.1F + 0.9F); addPotions(par1, par2, par3); return par1; } public void addPotions(ItemStack par1, World par2, EntityPlayer par3) { for(int i = 0; i<potion.length;i++) { if(potion[i] != null && potion[i].getPotionID() > 0 && !par2.isRemote) { par3.addPotionEffect(new PotionEffect(potion[i])); } } } } change it like every you want. This class do not need a .setUnlokalizedName(); or something like that: but you have to add the texture manually^^ Also i have a craftable foodclass (craftdamage, Eatdamage). Hope it helps
-
[SOLVED][1.6.2] Armor Render Issue? or Code?
There is a much easier way just say if slotID is 2 then load layer 2. it works fine! package minecraftwero.baconMod.common.items; import java.util.Random; import minecraftwero.baconMod.Bacon; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumArmorMaterial; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; /** * * @author MinecraftWero, Speiger * */ public class BaconArmor extends ItemArmor { public String par10; public String par11; public BaconArmor(int par1, EnumArmorMaterial par2EnumArmorMaterial, int par3, int par4, String texture, String name) { super(par1, par2EnumArmorMaterial, par3, par4); par10 = name; this.setMaxStackSize(1); par11 = texture; this.setCreativeTab(Bacon.baconMod); this.setNoRepair(); this.func_111206_d(texture); } @Override public String getArmorTexture(ItemStack stack, Entity entity, int slot, int layer) { if(slot == 2)return "minecraftwero:textures/models/armor/bacon_layer_2.png"; else return "minecraftwero:textures/models/armor/bacon_layer_1.png"; } public String getItemDisplayName(ItemStack par1) { return par10; } @SideOnly(Side.CLIENT) @Override public void registerIcons(IconRegister par1IconRegister) { this.itemIcon = par1IconRegister.registerIcon(par11); } }
-
[1.6.2] help with textures: armor textures and custom rendered block textures
First when you show code than make [code] [/code] public class PlushRender extends TileEntitySpecialRenderer { private static final ResourceLocation field_110782_f = new ResourceLocation("/ihulm/textures/misc/blockplush.png"); public PlushRender() { aModel = new ModelPlush(); } public void renderAModelAt(TileEntityPlush tileentity1, double d, double d1, double d2, float f) { GL11.glPushMatrix(); GL11.glTranslatef((float)d + 0.5F, (float)d1 + 1.52F, (float)d2 + 0.5F); GL11.glRotatef(180F, 0F, 0F, 1F); GL11.glPushMatrix(); aModel.renderModel(0.0625F); GL11.glPopMatrix(); GL11.glPopMatrix(); } protected ResourceLocation func_110781_a(BlockPlush BlockMirror) { return field_110782_f; } protected ResourceLocation func_110775_a(Block par1Entity) { return this.func_110781_a((BlockPlush)par1Entity); } public void renderTileEntityAt(TileEntity tileentity, double d, double d1, double d2, float f) { renderAModelAt((TileEntityPlush)tileentity, d, d1, d2, f); } private ModelPlush aModel; } first delete this functions, their not needed!: protected ResourceLocation func_110781_a(BlockPlush BlockMirror) { return field_110782_f; } protected ResourceLocation func_110775_a(Block par1Entity) { return this.func_110781_a((BlockPlush)par1Entity); } than change the string of your Texture to this: private static final ResourceLocation field_110782_f = new ResourceLocation("ihulm:textures/misc/blockplush.png"); and finally add this to your renderAModelAt function: this.func_110628_a(field_110782_f); Then everything should work^^ . i hope it helps^^
-
[1.6.2] [Solved] Config file doesn't work
Hmmm cant find the error. Here try my configfile out^^ I know that this works. package SackCastellon.craftablehorsearmor.lib; import java.io.File; import java.util.logging.Level; import net.minecraftforge.common.Configuration; import cpw.mods.fml.common.FMLLog; /** * * @author Speiger * */ public class ConfigHandler { public static final String general = "general"; public static final String items = "items"; public static final String blocks = "blocks"; public static Configuration config; public static Item test; public static void loadConfig(File par1) { config = new Configuration(par1); try { config.load(); test = new Item(getItem(items, "Testing", 10001)); } catch(Exception e) { FMLLog.log(Level.SEVERE, e, "[Craftable Horse Armor] Could not load the Config!"); } finally { Save(); } } public static int getItem(String var0, String var1, int var2) { return config.getItem(var0, var1, var2).getInt(); } public static boolean getBoolean(String var0, String var1, boolean var2) { return Boolean.getBoolean(config.get(var0, var1, var2).getString()); } public static int getBlock(String var0, String var1, int var2) { return config.getBlock(var0, var1, var2).getInt(); } public static void Save() { config.save(); } } And this comes into your preInt. ConfigHandler.loadConfig(new File(par1.getModConfigurationDirectory(), "CraftableHorseArmor.cfg")); i hope that helps^^
-
Machine Bug
A new Problem. I have problems with client and server Side. (I could start to cry. 1 Problem solved 50 new comes) But that is programming. Now my Problem. The basic buttons work. If i say its client side or serverSide. Now the problem is. If i make server side. The start button works. but the creating of the Item does not work. If i make client side. The start button does not work. But the progressing works. F.... Whats now the problem?
-
Machine Bug
If you beleve it or not i wrote on the gui side an extra S on the channel String^^ Now the errors are solved! Thank you very Much!
-
Machine Bug
this function did call the FMLLog which should print a text. By the way i did change it to runTest(int prosition)
-
Machine Bug
Still same result. Creates Ghost items^^
-
Machine Bug
Thanks^^ I only want to go safe!
-
Machine Bug
The problem is i do not know if i am working right^^". The fing is i do not know what i am doing^^. So the question is would this work? This way i am doing it now?
-
Machine Bug
I have tinkers construct installed (source) and because we have a nearly simmilar way of creating items i watched what he did^^. So now i did a view changes. I Did not test really if it is write. But it does crash nothing! Modfile package speiger.src.tinychest; import java.io.File; import java.util.logging.Logger; import net.minecraft.creativetab.CreativeTabs; import speiger.src.api.api.modules.advanced.ModulRecipeRegister; import speiger.src.tinychest.addons.AddonHelper; import speiger.src.tinychest.common.config.TinyConfig; import speiger.src.tinychest.common.config.TinyTileRegistry; import speiger.src.tinychest.common.core.CreativeTapTinyChest; import speiger.src.tinychest.common.core.TinyChestCore; import speiger.src.tinychest.common.core.helpers.RecipeHelper; import speiger.src.tinychest.common.lib.TinyChestRecipes; import speiger.src.tinychest.common.lib.TinyChestReference; import speiger.src.tinychest.common.packet.SpmodPackets; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.Init; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.Mod.PostInit; import cpw.mods.fml.common.Mod.PreInit; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; @Mod(modid = TinyChestReference.TinyID, name = TinyChestReference.TinyName, version = TinyChestReference.TinyVersion, dependencies = "required-after:SpmodAPI") @NetworkMod(clientSideRequired = true, serverSideRequired = false, channels = "TinyChest", packetHandler = SpmodPackets.class) public class TinyChest { @SidedProxy(clientSide = TinyChestReference.TinyClient, serverSide = TinyChestReference.TinyCore) public static TinyChestCore core; @Instance(TinyChestReference.TinyID) public static TinyChest instance; public static Logger tinyLogger = Logger.getLogger("TinyChestReference.TinyName"); public static CreativeTabs tinyChest = new CreativeTapTinyChest(CreativeTabs.getNextID(), TinyChestReference.TinyID); @PreInit public void preInit(FMLPreInitializationEvent par1) { NetworkRegistry.instance().registerGuiHandler(this, core); NetworkRegistry.instance().registerChannel(new SpmodPackets(), "TinyChest", Side.SERVER); instance = this; TinyConfig.loadTinyChests(new File(par1.getModConfigurationDirectory(), "Spmod/TinyChest.cfg")); LanguageRegistry.instance().addStringLocalization("itemGroup."+TinyChestReference.TinyID, "Tiny Chest"); } @Init public void load(FMLInitializationEvent evt) { ModulRecipeRegister.RegisterModulReicpeOutput(new RecipeHelper()); TinyChestRecipes.loadTinyChests(); TinyTileRegistry.registerTiles(); core.registerTileRenders(); core.preloadTexture(); } @PostInit public void modsLoaded(FMLPostInitializationEvent evt) { AddonHelper.loadAddons(); } } Gui package speiger.src.tinychest.client.gui.machines.machine; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.network.packet.Packet250CustomPayload; import net.minecraft.util.StatCollector; import org.lwjgl.opengl.GL11; import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.network.PacketDispatcher; import speiger.src.tinychest.common.container.machines.machine.ContainerModuleMaker; import speiger.src.tinychest.common.tileentity.machines.machine.ModuleMaker; public class GuiModuleMaker extends GuiContainer { private ModuleMaker tile; public GuiModuleMaker(InventoryPlayer par1, ModuleMaker par2) { super(new ContainerModuleMaker(par1, par2)); tile = par2; this.ySize = 232; this.xSize = 211; } protected void drawGuiContainerForegroundLayer(int par1, int par2) { this.fontRenderer.drawString("Fast", 38, 128, 0xffffff); this.fontRenderer.drawString("Work", 78, 106, 0xffffff); this.fontRenderer.drawString("Med", 80, 128, 0xffffff); this.fontRenderer.drawString("Slow", 118, 128, 0xffffff); this.fontRenderer.drawString("Module Maker", 65, 6, 4210752); this.fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 5, 4210752); this.fontRenderer.drawString("Clearing", 153, 10, 0xffffff); this.fontRenderer.drawString("Specify", 155, 30, 0xffffff); this.fontRenderer.drawString("Production", 146, 50, 0xffffff); this.fontRenderer.drawString("AdvProduct", 144, 70, 0xffffff); this.fontRenderer.drawString("Upgrade", 153, 90, 0xffffff); this.fontRenderer.drawString("Fuel", 164, 110, 0xffffff); } protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { int var4 = this.mc.renderEngine.getTexture("/speiger/src/tinychest/textures/ModuleMaker.png"); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.renderEngine.bindTexture(var4); int var5 = (this.width - this.xSize) / 2; int var6 = (this.height - this.ySize) / 2; this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize); int var7; if(tile.CanWork()) { this.drawTexturedModalRect(72 + var5, 81 + var6 + 22, 222, 24, 35, 15); } if(tile.work == 1) { this.drawTexturedModalRect(72 + var5, 81 + var6 + 22, 222, 41, 35, 15); } if(tile.button[0] == 1) { this.drawTexturedModalRect(32 + var5, 81 + var6 + 44, 222, 41, 35, 15); } if(tile.button[1] == 1) { this.drawTexturedModalRect(72 + var5, 81 + var6 + 44, 222, 41, 35, 15); } if(tile.button[2] == 1) { this.drawTexturedModalRect(112 + var5, 81 + var6 + 44, 222, 41, 35, 15); } if(tile.progressButton[0] == 1) { this.drawTexturedModalRect(141 + var5, 6 + var6, 138, 234, 64, 15); } if(tile.progressButton[1] == 1) { this.drawTexturedModalRect(141 + var5, 26 + var6, 138, 234, 64, 15); } if(tile.progressButton[2] == 1) { this.drawTexturedModalRect(141 + var5, 46 + var6, 138, 234, 64, 15); } if(tile.progressButton[3] == 1) { this.drawTexturedModalRect(141 + var5, 66 + var6, 138, 234, 64, 15); } if(tile.progressButton[4] == 1) { this.drawTexturedModalRect(141 + var5, 86 + var6, 138, 234, 64, 15); } if(tile.progressButton[5] == 1) { this.drawTexturedModalRect(141 + var5, 106 + var6, 138, 234, 64, 15); } } public int getButtonprosition(int x, int y) { if(x>=33 && x<=64 && y>=125 && y<=139)return 1; else if(x>=73 && x<=104 && y>=125 && y<=139)return 2; else if(x>=113 && x<=144 && y>=125 && y<=139)return 3; else if(x>=141 && x<=204 && y>=6 && y<=20)return 4; else if(x>=141 && x<=204 && y>=26 && y<=40)return 5; else if(x>=141 && x<=204 && y>=46 && y<=60)return 6; // else if(x>=141 && x<=204 && y>=66 && y<=80)return 7; // else if(x>=141 && x<=204 && y>=86 && y<=100)return 8; // else if(x>=141 && x<=204 && y>=106 && y<=120)return 9; else if(x>=73 && x<=104 && y>=103 && y<=117)return 10; else return 0; } @Override protected void mouseClicked(int par1, int par2, int par3) { super.mouseClicked(par1, par2, par3); int cornerX = (width - xSize) / 2; int cornerY = (height - ySize) / 2; int prosition = getButtonprosition(par1 - cornerX, par2 - cornerY); if(prosition != 0) { tile.progress = 0; tile.canWork = false; tile.work = 0; this.sendPacket(prosition); if(prosition == 1) { tile.button[0] = 1; tile.button[1] = 0; tile.button[2] = 0; } if(prosition == 2) { tile.button[0] = 0; tile.button[1] = 1; tile.button[2] = 0; } if(prosition == 3) { tile.button[0] = 0; tile.button[1] = 0; tile.button[2] = 1; } if(prosition == 4) { tile.progressButton[0] = 1; tile.progressButton[1] = 0; tile.progressButton[2] = 0; tile.progressButton[3] = 0; tile.progressButton[4] = 0; tile.progressButton[5] = 0; } if(prosition == 5) { tile.progressButton[0] = 0; tile.progressButton[1] = 1; tile.progressButton[2] = 0; tile.progressButton[3] = 0; tile.progressButton[4] = 0; tile.progressButton[5] = 0; } if(prosition == 6) { tile.progressButton[0] = 0; tile.progressButton[1] = 0; tile.progressButton[2] = 1; tile.progressButton[3] = 0; tile.progressButton[4] = 0; tile.progressButton[5] = 0; } if(prosition == 7) { tile.progressButton[0] = 0; tile.progressButton[1] = 0; tile.progressButton[2] = 0; tile.progressButton[3] = 1; tile.progressButton[4] = 0; tile.progressButton[5] = 0; } if(prosition == { tile.progressButton[0] = 0; tile.progressButton[1] = 0; tile.progressButton[2] = 0; tile.progressButton[3] = 0; tile.progressButton[4] = 1; tile.progressButton[5] = 0; } if(prosition == 9) { tile.progressButton[0] = 0; tile.progressButton[1] = 0; tile.progressButton[2] = 0; tile.progressButton[3] = 0; tile.progressButton[4] = 0; tile.progressButton[5] = 1; } if(prosition == 10) { if(tile.work == 0 && tile.canWork) { tile.work = 1; } else { if(tile.work == 1) { tile.work = 0; } } } } } public void sendPacket(int prosition) { ByteArrayOutputStream bitout = new ByteArrayOutputStream(; DataOutputStream output = new DataOutputStream(bitout); try { output.writeByte(1); output.writeInt(tile.worldObj.provider.dimensionId); output.writeInt(tile.xCoord); output.writeInt(tile.yCoord); output.writeInt(tile.zCoord); output.writeInt(prosition); FMLLog.getLogger().info("Send Data"); } catch (Exception e) { FMLLog.getLogger().info("Send Data"); e.printStackTrace(); } Packet250CustomPayload packet = new Packet250CustomPayload(); packet.channel = "TinyChests"; packet.data = bitout.toByteArray(); packet.length = bitout.size(); PacketDispatcher.sendPacketToServer(packet); } } PacketHandler package speiger.src.tinychest.common.packet; import java.io.ByteArrayInputStream; import java.io.DataInputStream; import net.minecraft.network.INetworkManager; import net.minecraft.network.packet.Packet250CustomPayload; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.DimensionManager; import speiger.src.tinychest.common.tileentity.machines.machine.ModuleMaker; import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.network.IPacketHandler; import cpw.mods.fml.common.network.Player; public class SpmodPackets implements IPacketHandler { @Override public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) { if(packet.channel.equals("TinyChest")) { handlePacket(packet); } } void handlePacket(Packet250CustomPayload packet) { DataInputStream input = new DataInputStream(new ByteArrayInputStream(packet.data)); byte packetID; int dimID; try { FMLLog.getLogger().info("Test"); packetID = input.readByte(); dimID = input.readInt(); World world = DimensionManager.getWorld(dimID); if(packetID == 1)//ModuleMaker { FMLLog.getLogger().info("Test2"); int x = input.readInt(); int y = input.readInt(); int z = input.readInt(); int prosition = input.readInt(); TileEntity tile = world.getBlockTileEntity(x, y, z); if(tile != null && tile instanceof ModuleMaker) { ModuleMaker mod = (ModuleMaker) tile; mod.runTest(); } } } catch (Exception e) { System.out.println("[TinyChest] Error on Sending Packet"); e.printStackTrace(); return; } } } It does crash nothing and something does he do but what he do i do not know^^
-
Machine Bug
Ok i changed my String to TinyChest (Which was my Old ModName) Now the thing is how can i use the packethandler to send the information to the TileEntity? And yes you can^^
-
Machine Bug
When i do write Test insteadof TinyModularThings then it works.^^ the string was to big^^
-
Machine Bug
Classes: ModClass: package speiger.src.tinychest; import java.io.File; import java.util.logging.Logger; import net.minecraft.creativetab.CreativeTabs; import speiger.src.api.api.modules.advanced.ModulRecipeRegister; import speiger.src.tinychest.addons.AddonHelper; import speiger.src.tinychest.common.config.TinyConfig; import speiger.src.tinychest.common.config.TinyTileRegistry; import speiger.src.tinychest.common.core.CreativeTapTinyChest; import speiger.src.tinychest.common.core.TinyChestCore; import speiger.src.tinychest.common.core.helpers.RecipeHelper; import speiger.src.tinychest.common.lib.TinyChestRecipes; import speiger.src.tinychest.common.lib.TinyChestReference; import speiger.src.tinychest.common.packet.SpmodPackets; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.Init; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.Mod.PostInit; import cpw.mods.fml.common.Mod.PreInit; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; @Mod(modid = TinyChestReference.TinyID, name = TinyChestReference.TinyName, version = TinyChestReference.TinyVersion, dependencies = "required-after:SpmodAPI") @NetworkMod(clientSideRequired = true, serverSideRequired = false, channels = "TinyModularThings", packetHandler = SpmodPackets.class) public class TinyChest { @SidedProxy(clientSide = TinyChestReference.TinyClient, serverSide = TinyChestReference.TinyCore) public static TinyChestCore core; @Instance(TinyChestReference.TinyID) public static TinyChest instance; public static Logger tinyLogger = Logger.getLogger("TinyChestReference.TinyName"); public static CreativeTabs tinyChest = new CreativeTapTinyChest(CreativeTabs.getNextID(), TinyChestReference.TinyID); @PreInit public void preInit(FMLPreInitializationEvent par1) { NetworkRegistry.instance().registerGuiHandler(this, core); NetworkRegistry.instance().registerChannel(new SpmodPackets(), "TinyModularThings"); instance = this; TinyConfig.loadTinyChests(new File(par1.getModConfigurationDirectory(), "Spmod/TinyChest.cfg")); LanguageRegistry.instance().addStringLocalization("itemGroup."+TinyChestReference.TinyID, "Tiny Chest"); } @Init public void load(FMLInitializationEvent evt) { ModulRecipeRegister.RegisterModulReicpeOutput(new RecipeHelper()); TinyChestRecipes.loadTinyChests(); TinyTileRegistry.registerTiles(); core.registerTileRenders(); core.preloadTexture(); } @PostInit public void modsLoaded(FMLPostInitializationEvent evt) { AddonHelper.loadAddons(); } } PacketClass: package speiger.src.tinychest.common.packet; import java.io.ByteArrayInputStream; import java.io.DataInputStream; import net.minecraft.network.INetworkManager; import net.minecraft.network.packet.Packet250CustomPayload; import cpw.mods.fml.common.network.IPacketHandler; import cpw.mods.fml.common.network.Player; public class SpmodPackets implements IPacketHandler { @Override public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) { } }
-
Machine Bug
Yeah that would maybe work but i do not get Anything done with it. I tried to register a packetHandler and if i trie that then the game crashes and the game says Invalid Channel name. My Channel name is: "TinyModularThings" Here are the classes^^. if the forge forum would not block my PrimäryBrowserIP then i could read the answers better but that is not interessting now!
-
Machine Bug
Ok. I did read your text and i can see the differens between datainput/outputstream^^ Now a very important thing. I am still on 1.4.7 so do not forget that. And i tried to implement a packethandler (i do not know if its working but the code is there) But now is the problem how do i sync the Infos between my gui and my tile. Because the SyncTileEntities tutorial on forge is like: yeah you do need to sync sometimes manually but a specail explaining is not there. Sry for saying it like that but i always say what i think! ^^
-
Machine Bug
I do not understand how to implement that! And how to use it^^". I am doing me hard with packetHandling!
-
making block bounds larger than 1x1x1
You can make the colideboundingboxes bigger. that is like a extendet block^^ i do not think that is a perfect result. But its a idea^^
-
Custom furnace not updating front icon
The way that the furnace uses is changing the blockID Block.furnaceIdle.blockID; Block.furnaceActive.blockID; Yeah this is the way the basic furnace it does. I help the baconMod creator a little bit out. And there i did found a way how to fix the problem. Here: BlockBaconMaker: package minecraftwero.baconMod.common.blocks; import java.util.Random; import minecraftwero.baconMod.Bacon; import minecraftwero.baconMod.common.lib.BaconGuiIDs; import minecraftwero.baconMod.common.tile.BaconMaker; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Icon; import net.minecraft.util.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class BlockBaconMaker extends BlockContainer { private String[] texture; private Icon[] icons = new Icon[6]; public BlockBaconMaker(int par1, String name, String...textures) { super(par1, Material.rock); texture = textures; this.setCreativeTab(Bacon.baconMod); } @Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister par1) { for(int i = 0; i<texture.length;i++) { icons[i] = par1.registerIcon(texture[i]); } } @Override @SideOnly(Side.CLIENT) public Icon getIcon(int par1, int par2) { if(par1 == ForgeDirection.NORTH.getOpposite().ordinal())return icons[2]; else if(par1 == ForgeDirection.WEST.ordinal())return icons[3]; else if(par1 == ForgeDirection.UP.ordinal())return icons[1]; else return icons[4]; } @SideOnly(Side.CLIENT) public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { BaconMaker tile = (BaconMaker) par1World.getBlockTileEntity(par2, par3, par4); if(tile != null && tile.fuel > 0) { int l = tile.getFacing(); float f = (float)par2 + 0.5F; float f1 = (float)par3 + 0.0F + par5Random.nextFloat() * 6.0F / 16.0F; float f2 = (float)par4 + 0.5F; float f3 = 0.52F; float f4 = par5Random.nextFloat() * 0.6F - 0.3F; if (l == 4) { par1World.spawnParticle("smoke", (double)(f - f3), (double)f1, (double)(f2 + f4), 0.0D, 0.0D, 0.0D); par1World.spawnParticle("flame", (double)(f - f3), (double)f1, (double)(f2 + f4), 0.0D, 0.0D, 0.0D); } else if (l == 5) { par1World.spawnParticle("smoke", (double)(f + f3), (double)f1, (double)(f2 + f4), 0.0D, 0.0D, 0.0D); par1World.spawnParticle("flame", (double)(f + f3), (double)f1, (double)(f2 + f4), 0.0D, 0.0D, 0.0D); } else if (l == 2) { par1World.spawnParticle("smoke", (double)(f + f4), (double)f1, (double)(f2 - f3), 0.0D, 0.0D, 0.0D); par1World.spawnParticle("flame", (double)(f + f4), (double)f1, (double)(f2 - f3), 0.0D, 0.0D, 0.0D); } else if (l == 3) { par1World.spawnParticle("smoke", (double)(f + f4), (double)f1, (double)(f2 + f3), 0.0D, 0.0D, 0.0D); par1World.spawnParticle("flame", (double)(f + f4), (double)f1, (double)(f2 + f3), 0.0D, 0.0D, 0.0D); } } } @Override public TileEntity createNewTileEntity(World world) { return new BaconMaker(); } @Override @SideOnly(Side.CLIENT) public Icon getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) { int meta = par1IBlockAccess.getBlockMetadata(par2, par3, par4); BaconMaker tile = (BaconMaker) par1IBlockAccess.getBlockTileEntity(par2, par3, par4); if(tile != null) { if(tile.facing == par5) { if(tile.fuel > 0) { return icons[5]; } else { return icons[2]; } } else if(par5 == 0)return icons[0]; else if(par5 == 1)return icons[1]; else if(ForgeDirection.getOrientation(tile.facing).getOpposite().ordinal() == ForgeDirection.SOUTH.ordinal())return icons[3]; else return icons[4]; } else { return null; } } @Override public void breakBlock(World par1, int par2, int par3, int par4, int par5, int par6) { super.breakBlock(par1, par2, par3, par4, par5, par6); } //Start @Override public int quantityDropped(Random par1Random) { return 1; } @Override public int idDropped(int par1, Random par2Random, int par3) { return this.blockID; } @Override public int damageDropped(int par1) { return 0; } //End public boolean onBlockActivated(World par1, int par2, int par3, int par4, EntityPlayer par5, int par6, float par7, float par8, float par9) { if(par5.isSneaking()) { return false; } if(!par1.isRemote) { BaconMaker tile = (BaconMaker) par1.getBlockTileEntity(par2, par3, par4); if(tile != null) { par5.openGui(Bacon.instance, BaconGuiIDs.baconMaker, par1, par2, par3, par4); return true; } } return true; } @Override public void onBlockPlacedBy(World par1, int par2, int par3, int par4, EntityLivingBase par5, ItemStack par6) { TileEntity tile = par1.getBlockTileEntity(par2, par3, par4); int facing = MathHelper.floor_double(par5.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; int rotation = 0; if (facing == 0) { rotation = ForgeDirection.NORTH.ordinal(); } else if (facing == 1) { rotation = ForgeDirection.EAST.ordinal(); } else if (facing == 2) { rotation = ForgeDirection.SOUTH.ordinal(); } else if (facing == 3) { rotation = ForgeDirection.WEST.ordinal(); } else { rotation = ForgeDirection.NORTH.ordinal(); } if(tile != null && tile instanceof BaconMaker) { BaconMaker bot = (BaconMaker) tile; bot.setFacing(rotation); } } public void updateTick(World world, int i, int j, int k, Random random) { super.updateTick(world, i, j, k, random); notifyNeighbors(world, i, j, k); world.scheduleBlockUpdate(i, j, k, blockID, tickRate()); } public void onBlockDestroyedByPlayer(World world, int i, int j, int k, int l) { notifyNeighbors(world, i, j, k); } public void notifyNeighbors(World world, int i, int j, int k) { world.notifyBlocksOfNeighborChange(i, j, k, blockID); world.notifyBlocksOfNeighborChange(i, j - 1, k, blockID); world.notifyBlocksOfNeighborChange(i, j + 1, k, blockID); world.notifyBlocksOfNeighborChange(i - 1, j, k, blockID); world.notifyBlocksOfNeighborChange(i + 1, j, k, blockID); world.notifyBlocksOfNeighborChange(i, j, k - 1, blockID); world.notifyBlocksOfNeighborChange(i, j, k + 1, blockID); } public void onBlockAdded(World world, int i, int j, int k) { world.scheduleBlockUpdate(i, j, k, blockID, tickRate()); } public int tickRate() { return 1; } @Override public int getLightValue(IBlockAccess world, int x, int y, int z) { BaconMaker tile = (BaconMaker) world.getBlockTileEntity(x, y, z); if(tile != null) { if(tile.fuel > 0)return 8; else return 0; } else { return 0; } } } TileEntityBaconMaker: package minecraftwero.baconMod.common.tile; import minecraftwero.baconMod.common.core.handlers.BaconMakerRecipes; import minecraftwero.baconMod.common.items.ItemBlade; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.world.World; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class BaconMaker extends TileEntityBacon implements IInventory, ISidedInventory { ItemStack[] baconInventory = new ItemStack[4]; public int fuel = 0; public int progress = 0; public int workingTime = 0; public boolean update = false; @SideOnly(Side.CLIENT) public int getProgressBar(int i) { return progress * i / 300; } @SideOnly(Side.CLIENT) public int getFuel(int i) { return fuel * i / 1000; } public void updateBlock() { int var1 = this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord); this.worldObj.markBlockForRenderUpdate(this.xCoord, this.yCoord, this.zCoord); markBlockDirty(this.worldObj, this.xCoord, this.yCoord, this.zCoord); } public void markBlockDirty(World var0, int var1, int var2, int var3) { if (var0.blockExists(var1, var2, var3)) { var0.getChunkFromBlockCoords(var1, var3).setChunkModified(); } } public int getSizeInventory() { return this.baconInventory.length; } public ItemStack getStackInSlot(int par1) { return this.baconInventory[par1]; } public ItemStack decrStackSize(int par1, int par2) { if (this.baconInventory[par1] != null) { ItemStack itemstack; if (this.baconInventory[par1].stackSize <= par2) { itemstack = this.baconInventory[par1]; this.baconInventory[par1] = null; return itemstack; } else { itemstack = this.baconInventory[par1].splitStack(par2); if (this.baconInventory[par1].stackSize == 0) { this.baconInventory[par1] = null; } return itemstack; } } else { return null; } } public ItemStack getStackInSlotOnClosing(int par1) { if (this.baconInventory[par1] != null) { ItemStack itemstack = this.baconInventory[par1]; this.baconInventory[par1] = null; return itemstack; } else { return null; } } public void setInventorySlotContents(int par1, ItemStack par2ItemStack) { this.baconInventory[par1] = par2ItemStack; if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit()) { par2ItemStack.stackSize = this.getInventoryStackLimit(); } } public String getInvName() { return null; } public void readFromNBT(NBTTagCompound par1NBTTagCompound) { super.readFromNBT(par1NBTTagCompound); NBTTagList nbttaglist = par1NBTTagCompound.getTagList("Items"); fuel = par1NBTTagCompound.getInteger("fuels"); progress = par1NBTTagCompound.getInteger("progresss"); workingTime = par1NBTTagCompound.getInteger("workingTimes"); this.baconInventory = new ItemStack[this.getSizeInventory()]; for (int i = 0; i < nbttaglist.tagCount(); ++i) { NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttaglist.tagAt(i); byte b0 = nbttagcompound1.getByte("Slot"); if (b0 >= 0 && b0 < this.baconInventory.length) { this.baconInventory[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1); } } } public void writeToNBT(NBTTagCompound par1NBTTagCompound) { super.writeToNBT(par1NBTTagCompound); par1NBTTagCompound.setInteger("fuels", fuel); par1NBTTagCompound.setInteger("progresss", progress); par1NBTTagCompound.setInteger("workingTimes", workingTime); NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < this.baconInventory.length; ++i) { if (this.baconInventory[i] != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("Slot", (byte)i); this.baconInventory[i].writeToNBT(nbttagcompound1); nbttaglist.appendTag(nbttagcompound1); } } par1NBTTagCompound.setTag("Items", nbttaglist); } public int getInventoryStackLimit() { return 64; } @Override public boolean isUseableByPlayer(EntityPlayer entityplayer) { return true; } @Override public void openChest() { } @Override public void closeChest() { } @Override public boolean isInvNameLocalized() { return false; } @Override public void updateEntity() { super.updateEntity(); if(fuel < 10 && canCook() && baconInventory[2] != null && baconInventory[2].getItem() instanceof ItemBlade) { addFuel(); update = true; } cook(); damage(); if(fuel > 0) { fuel--; } if(update) { update = false; this.onInventoryChanged(); updateBlock(); updateLight(); } } void updateLight() { this.worldObj.updateAllLightTypes(this.xCoord, this.yCoord, this.zCoord); } public void damage() { if(workingTime >= 600 && baconInventory[2] != null && baconInventory[2].getItem() instanceof ItemBlade) { workingTime = 0; ItemBlade ib = (ItemBlade) baconInventory[2].getItem(); ib.damageBlade(baconInventory[2]); if(baconInventory[2].getItemDamage() >= baconInventory[2].getMaxDamage()) { baconInventory[2] = null; } } } public void cook() { if(fuel > 0) { if(canCook()) { if(baconInventory[2] != null && baconInventory[2].getItem() instanceof ItemBlade) { ItemBlade ib = (ItemBlade) baconInventory[2].getItem(); progress++; workingTime++; if(progress >= 300) { progress = 0; ItemStack output = BaconMakerRecipes.getRecipes().getRecipeOuput(baconInventory[1]); if (this.baconInventory[3] == null) { this.baconInventory[3] = output.copy(); update = true; } else if (this.baconInventory[3].isItemEqual(output)) { baconInventory[3].stackSize += output.stackSize; update = true; } --this.baconInventory[1].stackSize; if (this.baconInventory[1].stackSize <= 0) { this.baconInventory[1] = null; update = true; } } } } else { progress = 0; } } } public boolean canCook() { if (this.baconInventory[1] == null) { return false; } else { ItemStack itemstack = BaconMakerRecipes.getRecipes().getRecipeOuput(baconInventory[1]); if (itemstack == null) return false; if (this.baconInventory[3] == null) return true; if (!this.baconInventory[3].isItemEqual(itemstack)) return false; int result = baconInventory[3].stackSize + itemstack.stackSize; return (result <= getInventoryStackLimit() && result <= itemstack.getMaxStackSize()); } } public void addFuel() { if(hasFuel(baconInventory[0])) { int fuelbetween = this.getFuel(baconInventory[0]); if(fuelbetween > 0) { fuel += fuelbetween; baconInventory[0].stackSize--; update = true; if(baconInventory[0].stackSize <= 0) { baconInventory[0] = baconInventory[0].getItem().getContainerItemStack(baconInventory[0]); update = true; } } } } public boolean hasFuel(ItemStack par1) { return getFuel(par1) > 0; } public int getFuel(ItemStack par1) { if(par1 != null) { int itemid = par1.getItem().itemID; if(itemid == Item.coal.itemID) { return 1600; } } return 0; } /** * Returns an array containing the indices of the slots that can be accessed by automation on the given side of this * block. */ public int[] getAccessibleSlotsFromSide(int par1) { if(par1 == 0) { return new int[]{0}; } else if(par1 == 1) { return new int[]{1}; } else { return new int[]{3}; } } /** * Returns true if automation can insert the given item in the given slot from the given side. Args: Slot, item, * side */ public boolean canInsertItem(int par1, ItemStack par2ItemStack, int par3) { return this.isItemValidForSlot(par1, par2ItemStack); } /** * Returns true if automation can extract the given item in the given slot from the given side. Args: Slot, item, * side */ public boolean canExtractItem(int par1, ItemStack par2ItemStack, int par3) { return par3 != 1 || par1 != 2 || par2ItemStack.itemID == Item.bucketEmpty.itemID; } @Override public boolean isItemValidForSlot(int i, ItemStack itemstack) { if(i == 0)return this.hasFuel(itemstack); else if(i == 3)return false; else if(i == 1)return true; else return false; } } The updateBlock function updates the function. The updateLight function updates the light^^. i hope it helps^^
-
Getting item's recipe
I only know how to getRecipe^^ but the rest ID not know public static ShapedRecipe getShapedRecipe(ItemStack par1) { List<IRecipe> recipeList = CraftingManager.getInstance().getRecipeList(); for(int i = 0;i<recipeList.size();i++) { IRecipe currentRecipe = recipeList.get(i); if(currentRecipe instanceof ShapedRecipe) { ShapedRecipe yourRecipe = (ShapedRecipe) currentRecipe; if(ItemStacks.areItemStacksEqual(yourRecipe.getRecipeOutput();, par1) { return yourRecipe; } } } } With that you get The shaped Recipe! I hope it helps^^
IPS spam blocked by CleanTalk.