
xilef11
Members-
Posts
83 -
Joined
-
Last visited
Everything posted by xilef11
-
But can I replace an existing TileEntityFurnace by something that extends TileEntityFurnace without changing the block at that position (i.e using world.setTileEntity)?
-
Can't I just replace the TE in the world (without changing the blockstate)?
-
The problem is that the TileEntity for my block isn't updating/ticking, and I don't want it to be because it can be used for decoration, and there may be a lot of them around that may not be "active". Also, wouldn't that reduce flexibility compared to a TE (unless the interface defines all functions of a TE)?
-
I see that a TileEntity is the most appropriate thing to use, but it leaves two issues: a) having more than one TE at a single BlockPos dosen't seem practical b) creating a TE (is it always necessary to register them) without an associated Block
-
Thing is, I would like to keep the "logic" object as flexible as possible, which is why I thought of a TileEntity, leading to the problem that I already have a TE at the position where that object would need to exist, and I can't think of a reasonably simple way of making them coexist. I currently have an interface which supplies the pattern to check for in the container, as well as the class (currently an abstract TE, this is the one I'm thinking of changing to an Entity) of the "logic" object. I'd like to know a few things about the differences... [*]Is it possible for an Entity to do all the things a TileEntity can do (I'm guessing yes) [*]What are the things an Entity can do that a TileEntity can't (other than moving ) [*]What things must be considered when making an Entity but not a TileEntity (the "unnecessarily complex" part) [*]Same as previous, but specifically for making an Entity that dosen't move or despawn [*]Is an Entity (much) slower than a TileEntity [*]What about rendering (or lack thereof)
-
The original TE/Block is added by my mod, but the "new" entity may be defined by my mod or by addons (it will have a known interface) That is pretty much what I was talking about with the parent/child TE. I want to keep the "logic" (ticking/new) TE as simple as possible, which would be hard in this case. Of course, I could replace it by a third TE that does the work of both the old one and the one I want to add, but that sounds like a bad idea. Basically, I have an inventory and want to create an object that does "stuff" when the container is activated with a certain pattern of items inside. Note that the container TE is provided by my mod, but the "object that does stuff" may be implemented by something else, extending an abstract class I define. Also that object may or may not be visible. Is there something wrong with using an Entity (and making it invulnerable, unmovable and never despawn on its own) instead of a TE?
-
Hello I need to create a TileEntity in a block that already contains one. I've seen a SuperTile/subtile approach in some mods, but it wouldn't work for me since the parent tile is not ticking while the child tile is. A solution I came up with would be creating a normal entity and making it completely unmovable and indestructible, but I'm not sure how to do that (or if it would work). Any advice?
-
[Solved] - Detecting asymmetrical multiblock pattern
xilef11 replied to xilef11's topic in Modder Support
Got it! I just find the largest connected pattern around the block clicked, convert it to an array and compare that to the stored patterns. The finding and comparing code is indeed surprisingly clean, although I might have to switch my recursive function to a loop if patterns get too large, and it would have been easier if ItemStack had a useful equals() implementation (because Arrays.deepequals could have worked). The conversion to a flat array is much less nice looking (4 nested for loops ), but I guess I'll live with it. Here is my code if anyone finds this useful in the future Pattern finding pattern matching -
[Solved] - Detecting asymmetrical multiblock pattern
xilef11 replied to xilef11's topic in Modder Support
I planned to check that on right-click with an Item, so that shouldn't be a concern Since all the blocks in the patterns will be specific blocks from my mod, I was thinking I could define the patterns in a way that all blocks in it need to be "connected", and using some sort of search algorithm (breadth-first seems logical?) around the clicked block. Not sure how well taht would work though. I guess I'll have to do it that way then hoped there was a better way Do you think storing the patterns as a 2d array would work or is there a nicer way? Also, my "blocks" are technically ItemStacks in a TileEntity, but I think the logic should be the same (contents of the TE can be returned as a 2D array of ItemStacks), I just have to "flatten" the array in some way, i.e go from a 2D array of 2D arrays of ItemStacks to a 2D array of ItemStacks. -
[Solved] - Detecting asymmetrical multiblock pattern
xilef11 replied to xilef11's topic in Modder Support
I think you misunderstood the question... I'm not trying to detect if an arbitrary structure is symmetrical. I need to detect when a specific pattern of blocks (out of many predefined ones) is created (think railcraft tank). The problem is mostly around the fact that this pattern will not be symmetrical, i.e. the top left corner is not the same block as the top right corner, but I need to detect it if the "top" edge is in any orientation (NESW). As I described in my earlier post, my current algorithm would be the following: For each possible pattern, check if it matches with what's in the world. If it dosen't match, rotate it 90° and check again. When all 4 possible rotations have been checked, try the next pattern. Of course, if there are many defined patterns, this could take a while even if it's fail-fast. Also, the code for "rotate 90°" and check again could be a hassle. Since many mods already have multiblock structures/"machines", I was wondering if there was a known "good" implementation for this. -
[Solved] - Detecting asymmetrical multiblock pattern
xilef11 replied to xilef11's topic in Modder Support
Is there no better way of doing this? -
That folder seems to contain the .csv files needed, but CCC complains about some missing .srg files I can't find (packaged.srg or joined.srg)
-
Hello I am looking for an efficient way to detect asymmetrical multi-block structures in the world, while keeping them orientation-independent. For instance, take the following structure defined as a 2d array of blocks (where X is a specific block): x x x x x I want the structure to be detected with the "top" X in any of the 4 directions. One could think of a "brute-force" algorithm as follows: (note that this is inside the block class X, but it could be in an Item) onBlockActivated(BlockPos pos){ Block[][] pattern = findPatternAroundBlock(pos); for(Block[][] multi : allPatternsInMyMod){ if(patternsMatch(pattern,multi){ foundPattern=multi; break; }else{ //rotate pattern 90 degrees and check again. do this for all directions } } activateStructure(foundPattern,pos,pattern); } This implementation has a few problems: it is necessary to iterate through all defined patterns (this could probably be reduced to a subset based on the number of blocks) we have to check if the pattern is matched 4 times before we know we don't have the right one rotating a large array 90 degrees could be slow/complicated Is there a more efficient algorithm (or way to store the patterns) for this task? Also, is there a way other than a double for loop for patternsMatch()? (I doubt it) I am also unsure of a good implementation for findPatternAroundBlock(BlockPos). Thanks
-
I managed to fix the color, turns out I had to modify TGG's vertexToInts, since my color was in the 0x00RRGGBB format, while the int[] expected 0x00BBGGRR ( so I used Integer.reverseBytes(color)>>8 ). I still have a few issues though, the transparent pixels in the foreground layer are rendered as black instead of transparent - solved by setting my block to render in the CUTOUT layer and adding 0xFF000000 to my colors my block extends BlockFalling, but when it falls it becomes invisible instead of using my model - working now, don't know why In the inventory, the texture returned from MyModel#gettexture() is used instead of the quads I made - fixed by using ColoredBakedQuad instead of BakedQuad The console still gets spammed with model not found messages
-
So I managed to get the models to load (they render as dirt when returning the sane thing as dirt in all methods), but when I try to make the BakedQuads I get an IndexOutOfBoundsException Model class: /** Runes of Wizardry Mod for Minecraft * Licensed under the GNU GPL version 3 * * this file was created by Xilef11 on 2015-09-06 */ package com.zpig333.runesofwizardry.client.model; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import javafx.scene.shape.VertexFormat; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.FaceBakery; import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.model.IBakedModel; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import org.apache.commons.lang3.ArrayUtils; import com.zpig333.runesofwizardry.api.IDustStorageBlock; import com.zpig333.runesofwizardry.client.TextureStitchEventHandler; import com.zpig333.runesofwizardry.core.References; import com.zpig333.runesofwizardry.core.WizardryLogger; /** * @author Xilef11 * */ public class ModelDustStorage implements IBakedModel { private static Map<String,ModelResourceLocation> resourceMap = new HashMap<String, ModelResourceLocation>(); private IDustStorageBlock block; private int meta; private int bgColor,fgColor; // create a tag (ModelResourceLocation) for our model. public final ModelResourceLocation modelResourceLocation; public ModelDustStorage(IDustStorageBlock block, int meta) { WizardryLogger.logInfo("Creating model for block: "+block.getName()+" "+meta); this.block=block; this.meta=meta; this.modelResourceLocation = new ModelResourceLocation(getModelResourceLocationPath(block,meta)); this.bgColor = block.getIDust().getPrimaryColor(new ItemStack(block.getIDust(),1,meta)); this.fgColor = block.getIDust().getSecondaryColor(new ItemStack(block.getIDust(),1,meta)); } public static String getModelResourceLocationPath(IDustStorageBlock block, int meta){ return References.texture_path+block.getName()+"_"+meta; } public static ModelResourceLocation getModelResourceLocation(String path){ ModelResourceLocation current = resourceMap.get(path); if(current==null){ current=new ModelResourceLocation(path); resourceMap.put(path, current); } return current; } public static ModelResourceLocation getModelResourceLocation(IDustStorageBlock block, int meta){ return getModelResourceLocation(getModelResourceLocationPath(block, meta)); } /* (non-Javadoc) * @see net.minecraft.client.resources.model.IBakedModel#getFaceQuads(net.minecraft.util.EnumFacing) */ @Override public List getFaceQuads(EnumFacing face) { List r = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelForState(Blocks.dirt.getDefaultState()).getFaceQuads(face); List<BakedQuad> result = new LinkedList<BakedQuad>(); int[] bg =null; int[] fg = null; TextureAtlasSprite bgTex = TextureStitchEventHandler.getDustStorageBG(); TextureAtlasSprite fgTex = TextureStitchEventHandler.getDustStorageFG(); //looks like a bakedquad is a full square, and we have to pass it all its vertices in the int array... //also, tintindex should be -1 //FIXME no more crash, but rendering is broken again //Feels like the ints are not in the right order... if(face==EnumFacing.EAST){ //BG color bg = ArrayUtils.addAll(bg, vertexToInts(1, 0, 0, bgColor, bgTex, 16, 16)); bg = ArrayUtils.addAll(bg, vertexToInts(1, 1, 0, bgColor, bgTex, 16, 0)); bg = ArrayUtils.addAll(bg, vertexToInts(1, 1, 1, bgColor, bgTex, 0, 0)); bg = ArrayUtils.addAll(bg, vertexToInts(1, 0, 1, bgColor, bgTex, 0, 16)); //fg fg = ArrayUtils.addAll(fg, vertexToInts(1.001F, 0, 0, fgColor, fgTex, 16, 16)); fg = ArrayUtils.addAll(fg, vertexToInts(1.001F, 1, 0, fgColor, fgTex, 16, 0)); fg = ArrayUtils.addAll(fg, vertexToInts(1.001F, 1, 1, fgColor, fgTex, 0, 0)); fg = ArrayUtils.addAll(fg, vertexToInts(1.001F, 0, 1, fgColor, fgTex, 0, 16)); }else if(face==EnumFacing.WEST){ //BG color bg = ArrayUtils.addAll(bg, vertexToInts(0, 0, 1, bgColor, bgTex, 16, 16)); bg = ArrayUtils.addAll(bg, vertexToInts(0, 1, 1, bgColor, bgTex, 16, 0)); bg = ArrayUtils.addAll(bg, vertexToInts(0, 1, 0, bgColor, bgTex, 0, 0)); bg = ArrayUtils.addAll(bg, vertexToInts(0, 0, 0, bgColor, bgTex, 0, 16)); //fg fg = ArrayUtils.addAll(fg, vertexToInts(-0.001F, 0, 1, fgColor, fgTex, 16, 16)); fg = ArrayUtils.addAll(fg, vertexToInts(-0.001F, 1, 1, fgColor, fgTex, 16, 0)); fg = ArrayUtils.addAll(fg, vertexToInts(-0.001F, 1, 0, fgColor, fgTex, 0, 0)); fg = ArrayUtils.addAll(fg, vertexToInts(-0.001F, 0, 0, fgColor, fgTex, 0, 16)); }else if(face==EnumFacing.NORTH){ //BG color bg = ArrayUtils.addAll(bg, vertexToInts(0, 0, 0, bgColor, bgTex, 16, 16)); bg = ArrayUtils.addAll(bg, vertexToInts(0, 1, 0, bgColor, bgTex, 16, 0)); bg = ArrayUtils.addAll(bg, vertexToInts(1, 1, 0, bgColor, bgTex, 0, 0)); bg = ArrayUtils.addAll(bg, vertexToInts(1, 0, 0, bgColor, bgTex, 0, 16)); //fg fg = ArrayUtils.addAll(fg, vertexToInts(0, 0, -0.001F, fgColor, fgTex, 16, 16)); fg = ArrayUtils.addAll(fg, vertexToInts(0, 1, -0.001F, fgColor, fgTex, 16, 0)); fg = ArrayUtils.addAll(fg, vertexToInts(1, 1, -0.001F, fgColor, fgTex, 0, 0)); fg = ArrayUtils.addAll(fg, vertexToInts(1, 0, -0.001F, fgColor, fgTex, 0, 16)); }else if(face==EnumFacing.SOUTH){ //BG color bg = ArrayUtils.addAll(bg, vertexToInts(1, 0, 1, bgColor, bgTex, 16, 16)); bg = ArrayUtils.addAll(bg, vertexToInts(1, 1, 1, bgColor, bgTex, 16, 0)); bg = ArrayUtils.addAll(bg, vertexToInts(0, 1, 1, bgColor, bgTex, 0, 0)); bg = ArrayUtils.addAll(bg, vertexToInts(0, 0, 1, bgColor, bgTex, 0, 16)); //fg fg = ArrayUtils.addAll(fg, vertexToInts(1, 0, 1.001F, fgColor, fgTex, 16, 16)); fg = ArrayUtils.addAll(fg, vertexToInts(1, 1, 1.001F, fgColor, fgTex, 16, 0)); fg = ArrayUtils.addAll(fg, vertexToInts(0, 1, 1.001F, fgColor, fgTex, 0, 0)); fg = ArrayUtils.addAll(fg, vertexToInts(0, 0, 1.001F, fgColor, fgTex, 0, 16)); }else if(face==EnumFacing.DOWN){ //BG color bg = ArrayUtils.addAll(bg, vertexToInts(1, 0, 0, bgColor, bgTex, 16, 16)); bg = ArrayUtils.addAll(bg, vertexToInts(1, 0, 1, bgColor, bgTex, 16, 0)); bg = ArrayUtils.addAll(bg, vertexToInts(0, 0, 1, bgColor, bgTex, 0, 0)); bg = ArrayUtils.addAll(bg, vertexToInts(0, 0, 0, bgColor, bgTex, 0, 16)); //fg fg = ArrayUtils.addAll(fg, vertexToInts(1,-0.001F,0, fgColor, fgTex, 16, 16)); fg = ArrayUtils.addAll(fg, vertexToInts(1,-0.001F,1, fgColor, fgTex, 16, 0)); fg = ArrayUtils.addAll(fg, vertexToInts(0, -0.001F,1, fgColor, fgTex, 0, 0)); fg = ArrayUtils.addAll(fg, vertexToInts(0, -0.001F,0, fgColor, fgTex, 0, 16)); }else if(face==EnumFacing.UP){ //BG color bg = ArrayUtils.addAll(bg, vertexToInts(1, 1, 1, bgColor, bgTex, 16, 16)); bg = ArrayUtils.addAll(bg, vertexToInts(1, 1, 0, bgColor, bgTex, 16, 0)); bg = ArrayUtils.addAll(bg, vertexToInts(0, 1, 0, bgColor, bgTex, 0, 0)); bg = ArrayUtils.addAll(bg, vertexToInts(0, 1, 1, bgColor, bgTex, 0, 16)); //fg fg = ArrayUtils.addAll(fg, vertexToInts(1,1.001F,1, fgColor, fgTex, 16, 16)); fg = ArrayUtils.addAll(fg, vertexToInts(1,1.001F,0, fgColor, fgTex, 16, 0)); fg = ArrayUtils.addAll(fg, vertexToInts(0, 1.001F,0, fgColor, fgTex, 0, 0)); fg = ArrayUtils.addAll(fg, vertexToInts(0, 1.001F,1, fgColor, fgTex, 0, 16)); }else{ throw new IllegalArgumentException("Wrong EnumFacing: "+face);//is that even possible... } //int[] test = ArrayUtils.addAll(new int[]{1,2,3,4},new int[]{5,6,7,8}); result.add(new BakedQuad(bg, -1, face)); result.add(new BakedQuad(fg, -1, face)); return result; // TODO Auto-generated method stub } /* (non-Javadoc) * @see net.minecraft.client.resources.model.IBakedModel#getGeneralQuads() */ @Override public List getGeneralQuads() { List<BakedQuad> res = new LinkedList<BakedQuad>(); for(EnumFacing face : EnumFacing.VALUES){ res.addAll(getFaceQuads(face)); } //return res; // TODO Auto-generated method stub List r = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelForState(Blocks.dirt.getDefaultState()).getGeneralQuads(); return r; } /* (non-Javadoc) * @see net.minecraft.client.resources.model.IBakedModel#isAmbientOcclusion() */ @Override public boolean isAmbientOcclusion() { //return true; return false; } /* (non-Javadoc) * @see net.minecraft.client.resources.model.IBakedModel#isGui3d() */ @Override public boolean isGui3d() { return true; } /* (non-Javadoc) * @see net.minecraft.client.resources.model.IBakedModel#isBuiltInRenderer() */ @Override public boolean isBuiltInRenderer() { return false; } /* (non-Javadoc) * @see net.minecraft.client.resources.model.IBakedModel#getTexture() */ @Override public TextureAtlasSprite getTexture() { //TODO getTexture might need to get tweaked return TextureStitchEventHandler.getDustStorageBG(); } /* (non-Javadoc) * @see net.minecraft.client.resources.model.IBakedModel#getItemCameraTransforms() */ @Override public ItemCameraTransforms getItemCameraTransforms() { return ItemCameraTransforms.DEFAULT; } /** * Converts the vertex information to the int array format expected by BakedQuads. * @param x x coordinate * @param y y coordinate * @param z z coordinate * @param color RGBA colour format - white for no effect, non-white to tint the face with the specified colour * @param texture the texture to use for the face * @param u u-coordinate of the texture (0 - 16) corresponding to [x,y,z] * @param v v-coordinate of the texture (0 - 16) corresponding to [x,y,z] * @return */ private static int[] vertexToInts(float x, float y, float z, int color, TextureAtlasSprite texture, float u, float v) { return new int[] { Float.floatToRawIntBits(x), Float.floatToRawIntBits(y), Float.floatToRawIntBits(z), color, Float.floatToRawIntBits(texture.getInterpolatedU(u)), Float.floatToRawIntBits(texture.getInterpolatedV(v)), 0 }; } } ModelBake Event Handler /** Runes of Wizardry Mod for Minecraft * Licensed under the GNU GPL version 3 * * this file was created by Xilef11 on 2015-09-06 */ package com.zpig333.runesofwizardry.client; import com.zpig333.runesofwizardry.api.DustRegistry; import com.zpig333.runesofwizardry.api.IDustStorageBlock; import com.zpig333.runesofwizardry.client.model.ModelDustStorage; import com.zpig333.runesofwizardry.core.WizardryLogger; import net.minecraft.client.resources.model.IBakedModel; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraftforge.client.event.ModelBakeEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; /** * @author Xilef11 * */ public class ModelBakeEventHandler { public static final ModelBakeEventHandler instance=new ModelBakeEventHandler(); private ModelBakeEventHandler() {}; @SubscribeEvent public void onModelBake(ModelBakeEvent event){ WizardryLogger.logInfo("Registering models on ModelBakeEvent"); // Find the existing mapping for the block - it will have been added automatically because // we registered a custom BlockStateMapper for it (using ModelLoader.setCustomStateMapper) // Replace the mapping with our ISmartBlockModel. for(IDustStorageBlock block: DustRegistry.getAllBlocks()){ WizardryLogger.logInfo("ModelBake: processing "+block.getName());//XXX this happens for(int meta : block.getIDust().getMetaValues()){ WizardryLogger.logInfo("meta is "+meta);//XXX this happens ModelResourceLocation location = ModelDustStorage.getModelResourceLocation(block, meta); Object object = event.modelRegistry.getObject(location); WizardryLogger.logInfo("object is "+object); if (object instanceof IBakedModel) {//FIXME object is null IBakedModel existingModel = (IBakedModel)object; ModelDustStorage customModel = new ModelDustStorage(block, meta); event.modelRegistry.putObject(location, customModel); }else if(object==null){ ModelDustStorage model = new ModelDustStorage(block, meta); event.modelRegistry.putObject(location, model); } } } } } Methods (in client proxy) that load the stuff... /* (non-Javadoc) * @see com.zpig333.runesofwizardry.proxy.CommonProxy#registerDustStorageRendering() */ @Override public void registerDustStorageRendering() { WizardryLogger.logInfo("Registering Dust Storage rendering"); // We need to tell Forge how to map our BlockCamouflage's IBlockState to a ModelResourceLocation. // For example, the BlockStone granite variant has a BlockStateMap entry that looks like // "stone[variant=granite]" (iBlockState) -> "minecraft:granite#normal" (ModelResourceLocation) // For the camouflage block, we ignore the iBlockState completely and always return the same ModelResourceLocation, // which is done using the anonymous class below for(final IDustStorageBlock block : DustRegistry.getAllBlocks()){ WizardryLogger.logInfo("Creating StateMapper for "+block.getName());//XXX This happens StateMapperBase mapper = new StateMapperBase() { @Override protected ModelResourceLocation getModelResourceLocation(IBlockState iBlockState) { int meta = (Integer) iBlockState.getValue(IDustStorageBlock.PROPERTYMETA); return ModelDustStorage.getModelResourceLocation(block, meta); } }; ModelLoader.setCustomStateMapper(block, mapper); } // ModelBakeEvent will be used to add our ISmartBlockModel to the ModelManager's registry (the // registry used to map all the ModelResourceLocations to IBlockModels). For the stone example there is a map from // ModelResourceLocation("minecraft:granite#normal") to an IBakedModel created from models/block/granite.json. // For the camouflage block, it will map from // CamouflageISmartBlockModelFactory.modelResourceLocation to our CamouflageISmartBlockModelFactory instance MinecraftForge.EVENT_BUS.register(ModelBakeEventHandler.instance); //register the handler to create the textures MinecraftForge.EVENT_BUS.register(new TextureStitchEventHandler()); } public void registerDustStorageItemRendering() { WizardryLogger.logInfo("Registering dust storage item rendering"); // This is currently necessary in order to make your block render properly when it is an item (i.e. in the inventory // or in your hand or thrown on the ground). // Minecraft knows to look for the item model based on the GameRegistry.registerBlock. However the registration of // the model for each item is normally done by RenderItem.registerItems(), and this is not currently aware // of any extra items you have created. Hence you have to do it manually. This will probably change in future. // It must be done in the init phase, not preinit, and must be done on client only. for(IDustStorageBlock b:DustRegistry.getAllBlocks()){ WizardryLogger.logInfo("Processing item: "+b.getName()); Item itemBlockDustStorage = GameRegistry.findItem(References.modid, b.getName()); for(int meta: b.getIDust().getMetaValues()){ WizardryLogger.logInfo("meta: "+meta); //ModelResourceLocation itemModelResourceLocation = new ModelResourceLocation(ModelDustStorage.getModelResourceLocationPath(b, meta), "inventory"); ModelResourceLocation itemModelResourceLocation = ModelDustStorage.getModelResourceLocation(b, meta); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(itemBlockDustStorage, meta, itemModelResourceLocation); } } } TextureStitch Event Handler package com.zpig333.runesofwizardry.client; import com.zpig333.runesofwizardry.core.References; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class TextureStitchEventHandler { private static TextureAtlasSprite dust_storage_bg, dust_storage_fg; public static TextureAtlasSprite getDustStorageBG(){ return dust_storage_bg; } public static TextureAtlasSprite getDustStorageFG(){ return dust_storage_fg; } @SubscribeEvent public void onTextureStitch(TextureStitchEvent.pre event){ dust_storage_bg = event.map.registerSprite(new ResourceLocation(References.texture_path+"blocks/dustStorage_bg")); dust_storage_fg = event.map.registerSprite(new ResourceLocation(References.texture_path+"blocks/dustStorage_fg")); } } EDIT: Turns out I derped and didn't notice the int[] was supposed to contian the data for all four vertices of the quad... I no longer crash, but the blocks get rendered in dark colors with no texture EDIT2: textures were fixed, I had to register for TextureStitchEvent.pre . However, the two layers don't blend (alpha in the foreground renders as black) and the colors are off.
-
I think I'm starting to understand, but I'm having trouble figuring out how to get a TextureAtlasSprite from an image in my resource folder
-
thing is, I don't have an existing modelfor this block...
-
I've been messing around with this again, but I still can't get my blocks to render... The code I've tried most recently is in this commit (note that i'm trying to get them to render as dirt to test that stuff is working)
-
Do I need to generate the quads myself? it's just a cube...
-
Thanks, I had seen those already (and the example on the TESR has been quite useful), but I don't seem to be able to understand how to put it together to do what I want... My biggest issue is probably because my models don't need to be "smart" (they're static for each block), they just need to be generated on startup
-
No answer in a while, so I guess I'll clarify the question: what would be the best (easiest) way to do this, and how would I go about implementing it? Thanks
-
Hello I have blocks with a texture composed of a background and a foreground layer, both of which can be of any color. The colors are static for each block, but they are "discovered" on initialisation (i.e in preInit()), and unknown at compile time. I have been told this could be achieved with either the "tintindex" field of the json models, or with a custom baked model, however, I can't figure out how to use either of those I also thought I could generate and save the textures to disk on the first run, but I'm not too sure how to integrate the external folder in the json models
-
I see... is there a non snapshot version that could be used? I managed to get things to work without that ForgeGradle jar, but it requires manual editing of the .classpath file for the eclipse project, as well as setting eclipse run configurations to use the proper assetsdir, and mapping the lwjgl natives in the classpath, every time the computer is changed.
-
I'll post the full (with --debug) output when I get home, but the actual error message is as follows: Could not resolve all dependencies for configuration ':classpath'. >Could not download artifact 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT:ForgeGradle.jar': No cached version avaliable for offline mode (there is a ForgeGradle-1.2-SNAPSHOT.jar file in GRADLE_USER_HOME/caches/modules-2/files-2.1/net.minecraftforge.gradle/ForgeGradle/1.2-SNAPSHOT/[some hash]. maybe that's what its looking for?) I also tried relative vs absolute parth for GRADLE_USER_HOME, it dosen't help.
-
well, it worked with an Internet connection (and with --offline on the computer where the files were downloaded), but it didn't work when the files were moved to a different computer with no Internet. would that mean the ForgeGradle file is not downloaded to the GRADLE_USER_HOME dir? (or maybe it uses an absolute path and therefore can't find it)