Jump to content

LoreSchaeffer

Forge Modder
  • Posts

    12
  • Joined

  • Last visited

Converted

  • Gender
    Male
  • URL
    http://www.youtube.com/LorenzoSchaeffer
  • Location
    Italy
  • Personal Text
    Set the power inside a single block free!

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

LoreSchaeffer's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Hi, I'm trying to fix an annoying bug of the observer in 1.12.2 pointing a water source that give a signal every 5 ticks. So i made a copy of the original observer class and I'm trying to edit a bit the code to detect only when a water source is placed and when is taken. I'm working on this method: public void observedNeighborChanged(IBlockState state, World world, BlockPos pos, Block block, BlockPos fromPos) { if (!world.isRemote && pos.offset(state.getValue(FACING)).equals(fromPos)) { if(block.equals(Blocks.WATER)) { //More checks to do here return; } startSignal(state, world, pos); } } but i don't see any difference that should trigger the observer. Do you guys have any idea about? Do you know any better solution? Any help is welcome, thanks
  2. Ok, I corrected it to "planks oak" but that's not the thing that cause the crash, it should load without loading that texture, the problem is in TextureAtlas class
  3. Ok, I've finished my ideas :'( Please Help me :'( :'( :'( Crash Report Block Class package com.lsmod.CompactStorage.Blocks; import java.util.ArrayList; import java.util.List; import java.util.Random; import com.lsmod.CompactStorage.client.TextureAtlasDynamic; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.World; public class test2Block extends Block { String name = "endOre"; // Indicates the number of metadata -> Number of blocks int metadata = 8; @SideOnly(Side.CLIENT) private IIcon[] icons; public test2Block() { super(Material.rock); setBlockName(name); setCreativeTab(CreativeTabs.tabBlock); setHardness(3F); setResistance(15F); setStepSound(soundTypeStone); setHarvestLevel("pickaxe", 2); } @Override @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister par1IconRegister) { icons = new IIcon[metadata]; if (par1IconRegister instanceof TextureMap) { TextureMap map = (TextureMap) par1IconRegister; for (int i = 0; i < icons.length; i++) { String overlayName = "tier"+i; String baseName = "plank_oak"; String regname = this.getUnlocalizedName()+"_"+i; map.setTextureEntry(regname, new TextureAtlasDynamic(regname, baseName, overlayName)); icons[i] = map.getTextureExtry(regname); //icons[i] = par1IconRegister.registerIcon("CompactStorage" + ":" + "plank_oak" + i); } } } @Override @SideOnly(Side.CLIENT) public IIcon getIcon(int par1, int par2) { return icons[par2]; } @SuppressWarnings({ "unchecked", "rawtypes" }) @SideOnly(Side.CLIENT) @Override public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { for (int var4 = 0; var4 < metadata; ++var4) { par3List.add(new ItemStack(par1, 1, var4)); } } } ItemBlock Class package com.lsmod.CompactStorage.Blocks; import net.minecraft.block.Block; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; public class test2Item extends ItemBlock { public test2Item(Block block) { super(block); } @Override public int getMetadata(int par1) { return par1; } @Override public String getUnlocalizedName(ItemStack itemstack) { String name = ""; switch (itemstack.getItemDamage()) { case 0: name = "tier0"; break; case 1: name = "tier1"; break; case 2: name = "tier2"; break; case 3: name = "tier3"; break; case 4: name = "tier4"; break; case 5: name = "tier5"; break; case 6: name = "tier6"; break; case 7: name = "tier7"; break; default: System.out.println("Invalid metadata for Block EndOre"); name = "broken"; break; } return getUnlocalizedName() + "." + name; } } TextureAtlas package com.lsmod.CompactStorage.client; import java.awt.image.BufferedImage; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import javax.imageio.ImageIO; import com.lsmod.CompactStorage.CompactStorage; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.texture.TextureUtil; import net.minecraft.client.resources.IResourceManager; import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; public class TextureAtlasDynamic extends TextureAtlasSprite { protected String textureBase; protected String textureOverlay; public TextureAtlasDynamic(String string, String base, String overlay) { super(string); textureBase = base; textureOverlay = overlay; } @Override public void updateAnimation() { TextureUtil.uploadTextureMipmap((int[][]) this.framesTextureData.get(0), this.width, this.height, this.originX, this.originY, false, false); } @Override public boolean hasCustomLoader(IResourceManager manager, ResourceLocation location) { return true; } @Override public boolean load(IResourceManager manager, ResourceLocation location) { framesTextureData.clear(); this.frameCounter = 0; this.tickCounter = 0; ResourceLocation resource1 = new ResourceLocation(textureBase); ResourceLocation resource2 = new ResourceLocation(textureOverlay); try { TextureMap map = Minecraft.getMinecraft().getTextureMapBlocks(); resource1 = this.completeResourceLocation(map, resource1, 0); resource2 = this.completeResourceLocation(map, resource2, 0); BufferedImage buff = ImageIO.read(manager.getResource(resource1).getInputStream()); BufferedImage buff2 = ImageIO.read(manager.getResource(resource2).getInputStream()); int[] rawBase = new int[buff.getWidth()*buff.getHeight()]; int[] rawOverlay = new int[buff2.getWidth()*buff2.getHeight()]; buff.getRGB(0, 0, buff.getWidth(), buff.getHeight(), rawBase, 0, buff.getWidth()); buff2.getRGB(0, 0, buff2.getWidth(), buff2.getHeight(), rawOverlay, 0, buff2.getWidth()); int min = Math.min(buff.getWidth(),buff2.getWidth()); rawBase = scaleToSmaller(rawBase, buff.getWidth(), min); rawOverlay = scaleToSmaller(rawOverlay, buff2.getWidth(), min); width = min; height = min; int[][] aint = new int[1 + MathHelper.calculateLogBaseTwo(min)][]; for (int k = 0; k < aint.length; ++k) { aint[k] = rawBase; } this.framesTextureData.add(aint); } catch (IOException e) { e.printStackTrace(); int[][] aint = new int[1][]; for (int k = 0; k < 1; ++k) { aint[k] = new int[16*16]; for(int l=0; l<aint[k].length;l++) { aint[k][l] = 0xFFFFFFFF; } } width = 16; height = 16; this.framesTextureData.add(aint); } return false; } private static int[] scaleToSmaller(int[] data, int width, int min) { if(width == min) { return data; } int scale = width / min; int[] output = new int[min*min]; int j = 0; for(int i = 0; i < output.length; i++) { if(i%min == 0) { j += width; } output[i] = data[i*scale+j]; } return output; } private static ResourceLocation completeResourceLocation(TextureMap map, ResourceLocation loc, int c) { try { return (ResourceLocation)CompactStorage.proxy.resourceLocation.invoke(map, c); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } return null; } } I don't really know what to do, please be good with me, can you make me a simple example of a block using TextureAtlas?
  4. This is ma test Block class, I don't know if it's correct, probabily no Which are the resources folder for the textures? minecraft default for base and src\main\resources\assets\modid\textures\blocks for overlay? package com.lsmod.CompactStorage.Blocks; import com.lsmod.CompactStorage.CompactStorage; import com.lsmod.CompactStorage.client.TextureAtlasDynamic; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.creativetab.CreativeTabs; public class testBlock extends Block { public testBlock(String name) { super(Material.wood); setBlockName(name); setCreativeTab(CreativeTabs.tabBlock); setHardness(3F); setResistance(15F); setStepSound(soundTypeWood); setHarvestLevel("axe", 1); } @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister iconRegister) { if (iconRegister instanceof TextureMap) { TextureMap map = (TextureMap) iconRegister; String overlayName = "tier0"; String baseName = "planks_oak"; String regname = "planks_oak"; map.setTextureEntry(regname, new TextureAtlasDynamic(regname, baseName, overlayName)); } } }
  5. Ok, now the game loads correctly but in the console I've the missing texture error with another error that i haven't never seen [21:35:20] [Client thread/ERROR] [TEXTURE ERRORS]: +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= [21:35:20] [Client thread/ERROR] [TEXTURE ERRORS]: The following texture errors were found. [21:35:20] [Client thread/ERROR] [TEXTURE ERRORS]: ================================================== [21:35:20] [Client thread/ERROR] [TEXTURE ERRORS]: DOMAIN minecraft [21:35:20] [Client thread/ERROR] [TEXTURE ERRORS]: -------------------------------------------------- [21:35:20] [Client thread/ERROR] [TEXTURE ERRORS]: domain minecraft is missing 1 texture [21:35:20] [Client thread/ERROR] [TEXTURE ERRORS]: domain minecraft has 3 locations: [21:35:20] [Client thread/ERROR] [TEXTURE ERRORS]: unknown resourcepack type net.minecraft.client.resources.DefaultResourcePack : Default [21:35:20] [Client thread/ERROR] [TEXTURE ERRORS]: mod FML resources at C:\Users\lmlor\.gradle\caches\minecraft\net\minecraftforge\forge\1.7.10-10.13.4.1558-1.7.10\forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar [21:35:20] [Client thread/ERROR] [TEXTURE ERRORS]: mod Forge resources at C:\Users\lmlor\.gradle\caches\minecraft\net\minecraftforge\forge\1.7.10-10.13.4.1558-1.7.10\forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar [21:35:20] [Client thread/ERROR] [TEXTURE ERRORS]: ------------------------- [21:35:20] [Client thread/ERROR] [TEXTURE ERRORS]: The missing resources for domain minecraft are: [21:35:20] [Client thread/ERROR] [TEXTURE ERRORS]: textures/blocks/MISSING_ICON_BLOCK_165_testBlock.png [21:35:20] [Client thread/ERROR] [TEXTURE ERRORS]: ------------------------- [21:35:20] [Client thread/ERROR] [TEXTURE ERRORS]: No other errors exist for domain minecraft [21:35:20] [Client thread/ERROR] [TEXTURE ERRORS]: ================================================== [21:35:20] [Client thread/ERROR] [TEXTURE ERRORS]: +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
  6. Ok, thanks. I'm trying your code and trying to fit it with mine ...
  7. First of all, THANK YOU. Second: I've tried your code but I've a problem at this point: private static ResourceLocation completeResourceLocation(TextureMap map, ResourceLocation loc, int c) { try { return (ResourceLocation) HardLib.proxy.resourceLocation.invoke(map, loc, c); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } return null; } It need HardLib proxy that's from your library/api (I found it on github ) so I've changed it to refer to my ClientProxy Class but it sais that i've not decleared resourceLocation as a variable. My ClientProxy Class is: package com.lsmod.compactstorage; import java.lang.reflect.Method; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.util.ResourceLocation; public class ClientProxy { public void preInit(FMLPreInitializationEvent e) { } public void init() { Class clz = TextureMap.class; Method[] meths = clz.getDeclaredMethods(); for (Method m : meths) { if (m.getReturnType() == ResourceLocation.class) { m.setAccessible(true); resourceLocation = m; } } } public void postInit(FMLPostInitializationEvent e) { } } Oh, if it could help I followed this guide to learn basics for modding and my classes looks very similar to the author's ones https://play.google.com/store/books/details?id=KE2EBAAAQBAJ&source=ge-web-app
  8. Hi, I'm developing a mod for minecraft 1.7.10 and I'm trying to get the texture of some blocks and adding to them an overlay to make something like this that is the texture of the oak planks plus the black cage with the red dots, is there a way to do this without making every single texture? Thanks in advance
  9. First of all thanks for the reply. Can you suggest me a better solution?
  10. Hi, I'm trying to make some crafting using oredictionary names; this is my code: GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ItemManager.pickaxeRexalite, 1), "ZXX"," Y ","HYK", 'X', "ingotRexalite", 'Y', Items.stick, 'Z', ( new ItemStack (ItemManager.plate, 1, 3)), 'H', "hammer", 'K', "file")); The problems stay in the fact that hammers and files get damage during crafting and the crafting works only the first time. I Used to use OreDictionary.WILDCARD_VALUE but now I don't know how to use it. Can someone help me?
×
×
  • Create New...

Important Information

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