![](https://forums.minecraftforge.net/uploads/set_resources_2/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
paradoxbomb
Members-
Posts
30 -
Joined
-
Last visited
Everything posted by paradoxbomb
-
[1.8.9] When does ModelbakeEvent happen?
paradoxbomb replied to paradoxbomb's topic in Modder Support
Why? You're just telling me no without saying why. -
[1.8.9] When does ModelbakeEvent happen?
paradoxbomb replied to paradoxbomb's topic in Modder Support
I thought that if I'm implementing ITileEntityProvider I don't need to do that. -
[1.8.9] When does ModelbakeEvent happen?
paradoxbomb replied to paradoxbomb's topic in Modder Support
I'm sorry for being such a noob, but could you possibly explain how to do that? I've tried looking up how to add data to a tile entitiy but I just can't seem to wrap my head around it. I tried [spoiler=TECanvas.java] package com.paradoxbomb.inkcannon.common.tileEntities.canvasBlock; import com.paradoxbomb.inkcannon.LogHelper; import com.paradoxbomb.inkcannon.NBTHelper; import net.minecraft.block.state.IBlockState; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; public class TECanvas extends TileEntity { private IBlockState disguisedBlock; public void setDisguiseState(IBlockState newState) { this.disguisedBlock = newState; } public IBlockState getDisguisedState() { return this.disguisedBlock; } @Override public void writeToNBT(NBTTagCompound compound) { LogHelper.info("Saving data to NBT"); super.writeToNBT(compound); NBTTagCompound blockState = new NBTTagCompound(); ((TileEntity) this.disguisedBlock).writeToNBT(blockState); compound.setTag("PAINTED_BLOCK", blockState); LogHelper.info(compound.toString()); } @Override public void readFromNBT(NBTTagCompound compound) { } } but writeToNBT never seems to get called. -
[1.8.9] When does ModelbakeEvent happen?
paradoxbomb replied to paradoxbomb's topic in Modder Support
-
[1.8.9] When does ModelbakeEvent happen?
paradoxbomb replied to paradoxbomb's topic in Modder Support
I'm very confused then, because when I test the code that I have, it creates canvas blocks that are untextured. [spoiler=ClientProxy.java] /* * File to hold commands that need to be run only on the client side (rendering, UI, etc) */ package com.paradoxbomb.inkcannon; import com.paradoxbomb.inkcannon.client.render.BlockRenderRegister; import com.paradoxbomb.inkcannon.client.render.ItemRenderRegister; import com.paradoxbomb.inkcannon.client.render.ModelBakeEventHandler; import com.paradoxbomb.inkcannon.common.blocks.ModBlocks; import com.paradoxbomb.inkcannon.common.tileEntities.canvasBlock.BlockCanvas; import com.paradoxbomb.inkcannon.common.tileEntities.canvasBlock.CanvasBlockModelFactory; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.block.statemap.StateMapperBase; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.item.Item; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.registry.GameRegistry; public class ClientProxy extends CommonProxy { @Override public void preinit(FMLPreInitializationEvent event) { super.preinit(event); //tells Forge how to map BlockCanvas's IBlockState onto ModelResourceLocation //since this block is special, an anonymous class is used instead of the normal methos StateMapperBase ignoreState = new StateMapperBase() { @Override protected ModelResourceLocation getModelResourceLocation(IBlockState blockState) { return CanvasBlockModelFactory.modelResourceLocation; } }; ModelLoader.setCustomStateMapper((BlockCanvas)ModBlocks.blockCanvas, ignoreState); //register the custom event handler MinecraftForge.EVENT_BUS.register(ModelBakeEventHandler.instance); //make canvas block render properly while an item Item itemBlockCanvas = GameRegistry.findItem(StringLib.MODID, StringLib.CANVAS_BLOCK); ModelResourceLocation itemModelResourceLoaction = new ModelResourceLocation(StringLib.MODID+":"+StringLib.CANVAS_BLOCK, "inventory"); final int DEFAULT_ITEM_SUBTYPE = 0; ModelLoader.setCustomModelResourceLocation(itemBlockCanvas, DEFAULT_ITEM_SUBTYPE, itemModelResourceLoaction); } @Override public void init(FMLInitializationEvent event) { super.init(event); //register items and block to be rendered ItemRenderRegister.registerItemRenderer(); BlockRenderRegister.registerBlockRenderer(); } @Override public void postInit(FMLPostInitializationEvent event) { super.postInit(event); } } [spoiler=CommonProxy.java] /* * File to hold commands that need to be run through both the server and client proxies */ package com.paradoxbomb.inkcannon; import com.paradoxbomb.inkcannon.common.blocks.ModBlocks; import com.paradoxbomb.inkcannon.common.items.ModItems; import com.paradoxbomb.inkcannon.common.misc.Crafting; import com.paradoxbomb.inkcannon.common.tileEntities.ModTileEntities; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; public class CommonProxy { public void preinit(FMLPreInitializationEvent event) { ModItems.createItems(); //initialize mod items ModBlocks.createBlocks(); //initialize mod blocks ModTileEntities.init(); //initialize tile entities } public void init(FMLInitializationEvent event) { Crafting.initCrafting(); //initialize crafting recipes } public void postInit(FMLPostInitializationEvent event) { } } Is the problem somewhere in my proxies? edit: or could it be in here? [spoiler=placement code on projectile] //checking for material rather than using isAirBlock() allows for mod blocks to not interfere with the flight path if (block.getMaterial() != Material.air) { LogHelper.info("Collided successfully!"); LogHelper.info("Collided with:" + block.toString()); this.worldObj.destroyBlock(blockpos, false); this.worldObj.setBlockState(blockpos, ModBlocks.blockCanvas.getDefaultState()); this.setDead(); } -
[1.8.9] When does ModelbakeEvent happen?
paradoxbomb replied to paradoxbomb's topic in Modder Support
I assume that I need to pass the IBlockState from the in-world block into the CanvasBlockModelFactory before it gets placed, but I'm stuck on how to do that. I've tried looking up topics that I think might be useful for figuring this out, but I am completely lost. -
[1.8.9] When does ModelbakeEvent happen?
paradoxbomb replied to paradoxbomb's topic in Modder Support
Okay, but how would I dynamically set the default state of the canvas block to allow it to have more than one possible texture? -
[1.8.9] When does ModelbakeEvent happen?
paradoxbomb replied to paradoxbomb's topic in Modder Support
if I have one set default state, though, that seems like it would defeat the purpose of the block: to have a dynamic texture. As it stands, the block works in three parts: [spoiler="BlockCanvas.java] //block that will replace a block in the world with a copy of its texture that can be tinted package com.paradoxbomb.inkcannon.common.tileEntities.canvasBlock; import com.paradoxbomb.inkcannon.StringLib; import com.paradoxbomb.inkcannon.common.items.ModItems; import net.minecraft.block.Block; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.state.BlockState; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumWorldBlockLayer; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.common.property.IUnlistedProperty; import net.minecraftforge.common.property.ExtendedBlockState; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class BlockCanvas extends Block implements ITileEntityProvider { public static final UnlistedPropertyPaintedBlock PAINTED_BLOCK = new UnlistedPropertyPaintedBlock(); public BlockCanvas (String unlocalizedName) { super(Material.cloth); this.setUnlocalizedName(StringLib.CANVAS_BLOCK); this.setCreativeTab(ModItems.tabInkCannon); } public BlockCanvas (Block disguiseBlock, World worldIn, BlockPos pos) { super(disguiseBlock.getMaterial()); this.setUnlocalizedName(StringLib.CANVAS_BLOCK); this.setHarvestLevel(disguiseBlock.getHarvestTool((IBlockState)disguiseBlock.getBlockState()),disguiseBlock.getHarvestLevel((IBlockState)disguiseBlock.getBlockState())); this.setHardness(disguiseBlock.getBlockHardness(worldIn, pos)); this.setResistance(5.0f); this.isBlockContainer = true; this.setDefaultState((IBlockState)disguiseBlock.getDefaultState()); } public TileEntity createNewTileEntity(World worldIn, int meta) { return new TECanvas(); } @Override protected BlockState createBlockState() { IProperty [] listedProperties = new IProperty[0]; //no listed properties IUnlistedProperty [] unlistedProperties = new IUnlistedProperty [] {PAINTED_BLOCK}; return new ExtendedBlockState (this, listedProperties, unlistedProperties); } @Override public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { super.onBlockPlacedBy(worldIn, pos, state, placer, stack); TileEntity canvasEntity = worldIn.getTileEntity(pos); if (canvasEntity instanceof TECanvas) { //initialize TE data } } @SideOnly(Side.CLIENT) public EnumWorldBlockLayer getBlockLayer() { return EnumWorldBlockLayer.SOLID; } @Override public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) { if (state instanceof IExtendedBlockState) { IExtendedBlockState returnState = (IExtendedBlockState)state; returnState = returnState.withProperty(PAINTED_BLOCK, state); return returnState; } return state; } @Override public boolean isOpaqueCube() { return true; } @Override public boolean isFullCube() { return true; } @Override public int getRenderType() { return 3; } } (There are some things in there regarding TileEntities but they don't do anything at the moment; I plan on using the TE data to allow the block to be shaded) [spoiler=CanvasBlockModelFactory.java] //class to assist in creating the model for canvas blocks //code based on http://bit.ly/1R1SbXO package com.paradoxbomb.inkcannon.common.tileEntities.canvasBlock; import java.util.List; import com.paradoxbomb.inkcannon.LogHelper; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.BlockModelShapes; import net.minecraft.client.renderer.BlockRendererDispatcher; import net.minecraft.client.renderer.block.model.BakedQuad; 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.util.EnumFacing; import net.minecraftforge.client.model.ISmartBlockModel; import net.minecraftforge.common.property.IExtendedBlockState; @SuppressWarnings("deprecation") public class CanvasBlockModelFactory implements ISmartBlockModel { private IBakedModel modelWhenNotPainted; public CanvasBlockModelFactory (IBakedModel unPaintedBlock) { modelWhenNotPainted = unPaintedBlock; } //creates model resource location for canvas block public static final ModelResourceLocation modelResourceLocation = new ModelResourceLocation("inkcannon:blockCanvas"); // creates an IBakedModel based on the IBlockState of the block state that is passed @Override public IBakedModel handleBlockState(IBlockState state) { IBakedModel returnModel = modelWhenNotPainted; //default IBlockState unPaintedBlock = Blocks.air.getDefaultState(); if (state instanceof IExtendedBlockState) { IExtendedBlockState extendedState = (IExtendedBlockState)state; IBlockState paintedBlockIBlockState = extendedState.getValue(BlockCanvas.PAINTED_BLOCK); if (paintedBlockIBlockState != unPaintedBlock) { Minecraft mc = Minecraft.getMinecraft(); BlockRendererDispatcher blockRendererDispatcher = mc.getBlockRendererDispatcher(); BlockModelShapes blockModelShapes = blockRendererDispatcher.getBlockModelShapes(); IBakedModel copiedBlockModel = blockModelShapes.getModelForState(paintedBlockIBlockState); if(copiedBlockModel instanceof ISmartBlockModel) { copiedBlockModel = ((ISmartBlockModel)copiedBlockModel).handleBlockState(paintedBlockIBlockState); } returnModel = copiedBlockModel; } } return returnModel; } //used in case of a player being inside a block; game will crash unless something meaningful is used here @Override public TextureAtlasSprite getParticleTexture() { return modelWhenNotPainted.getParticleTexture(); } //unused methods; would only be used in case of other mod blocks @Override public List<BakedQuad> getFaceQuads(EnumFacing p_177551_1_) { LogHelper.error("Unsupported render method getFaceQuads accessed from mod Ink Cannon!\nPlease contact the mod developer!"); throw new UnsupportedOperationException(); } @Override public List<BakedQuad> getGeneralQuads() { LogHelper.error("Unsupported render method getgeneralQuads accessed from mod Ink Cannon!\nPlease contact the mod developer!"); throw new UnsupportedOperationException(); } @Override public boolean isAmbientOcclusion() { LogHelper.error("Unsuppoerted method isAmbientOcclusion accessed from mod Ink Cannon!\nPlease contact the mod developer!"); throw new UnsupportedOperationException(); } @Override public boolean isGui3d() { LogHelper.error("Unsuppoerted method isGui3d accessed from mod Ink Cannon!\nPlease contact the mod developer!"); return false; } @Override public boolean isBuiltInRenderer() { LogHelper.error("Unsuppoerted method isBuiltInRenderer accessed from mod Ink Cannon!\nPlease contact the mod developer!"); throw new UnsupportedOperationException(); } @Override public ItemCameraTransforms getItemCameraTransforms() { LogHelper.error("Unsuppoerted method getItemCameraTransform accessed from mod Ink Cannon!\nPlease contact the mod developer!"); throw new UnsupportedOperationException(); } } [spoiler="ModelBakeEventHandler.java] //class to allow dynamically altering Moderlmanager's registry package com.paradoxbomb.inkcannon.client.render; import com.paradoxbomb.inkcannon.common.tileEntities.canvasBlock.CanvasBlockModelFactory; import net.minecraft.client.resources.model.IBakedModel; import net.minecraftforge.client.event.ModelBakeEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class ModelBakeEventHandler { public static final ModelBakeEventHandler instance = new ModelBakeEventHandler(); private ModelBakeEventHandler() {}; @SubscribeEvent public void onModelBakeEvent(ModelBakeEvent e) { Object object = e.modelRegistry.getObject(CanvasBlockModelFactory.modelResourceLocation); if (object instanceof IBakedModel) { IBakedModel existingModel = (IBakedModel)object; CanvasBlockModelFactory customModel = new CanvasBlockModelFactory(existingModel); e.modelRegistry.putObject(CanvasBlockModelFactory.modelResourceLocation, customModel); } } } I think what I need to do is related to the ModelBake event so that I can pass the IBlockState into the factory, but I have no idea when that happens. -
[1.8.9] When does ModelbakeEvent happen?
paradoxbomb replied to paradoxbomb's topic in Modder Support
Oh, my bad. What should I be calling, then? -
[1.8.9] When does ModelbakeEvent happen?
paradoxbomb replied to paradoxbomb's topic in Modder Support
After derping around with stuff, I managed to come up with this.worldObj.setBlockState(blockpos, ModBlocks.blockCanvas.getExtendedState(iblockstate, this.worldObj, blockpos)); on my projectile (the thing that will actually be placing the block) code. However, it seems to just break a block and then immediately replace it with the vanilla version of itself, as determined by a simple item that prints out what block it was used on to the console. I don't actually have a TE for my block, but it sounds like I should look into it. I assume you were referencing the TE in the canvas (camouflage) block? -
I'm following GreyGhost's MinecraftByExample example project on ISBMs, and I can't for the life of me figure out when ModelBakeEventHandler "catches" events. My intent is to have a mechanic to replace existing blocks with TEs that I can then perform rendering on, but I don't know how to tell the model factory what type of block to paint itself as. double edit for additional information: I know that GG has a method of choosing a random nearby block and then clones that, but I want to only copy the block it is replacing. edited for clarity of version
-
[1.8.9] Rendering an Entity that implements IProjectile?
paradoxbomb replied to paradoxbomb's topic in Modder Support
That code snippet will definitely be invaluable once I actually get the thing working, but I was referring to the obfuscated fields in the RenderSnowball.java file. -
[1.8.9] Rendering an Entity that implements IProjectile?
paradoxbomb replied to paradoxbomb's topic in Modder Support
They might be obvious to a vet like you, but I have no idea. Help a newbie out? -
[1.8.9] Rendering an Entity that implements IProjectile?
paradoxbomb replied to paradoxbomb's topic in Modder Support
All right, now I'm running into the problem that RenderSnowball 's constructor takes three arguments, the last two of which are obfuscated for some reason: public RenderSnowball(RenderManager renderManagerIn, Item p_i46137_2_, RenderItem p_i46137_3_) { super(renderManagerIn); this.field_177084_a = p_i46137_2_; this.field_177083_e = p_i46137_3_; } Also when trying to add my projectile to my EntityRenderer class, it says that the current method is deprecated and that the version that will be around in 1.9 needs a renderFactory. What the heck is that and how do I pass it correctly? -
I'm not really sure where to go for questions like this... I have a custom projectile that I've made, and it works, but it's currently invisible as I don't know how to actually tell Minecraft what to render. I tried Googling, but apparently everyone already knows how or something. Is there a tutorial somewhere I'm missing?
-
Hmmm.... I assume that you're referring to OpenBlocks when you mention the "other mod?" I tied to take a look at their code for the canvas, but I was really confused by it... I don't know where to look for information on rendering things. I think I might have bitten off more than I can chew for a "first mod" idea. It seemed so simple on paper... Edit: spelling Double edit: Thinking about OpenBlocks, would it be possible for me to do a similar thing with my item where I take the block that I hit with my projectile and replace it with a custom one that I can tint at will? If so, how do I grab the texture?
-
Well dang, then how do I do what I'm trying to do? Edit for details: if it helps, the item I have is a projectile "weapon" that shoots a custom projectile that extends Entity.Arrow, so I can get the block that it hits easily.
-
The latter; ideally when the item is used on the block, it should tint that specific face dependent on what dye item is loaded in it, with more uses of the item applying a heavier shade. As an example, if the method were simply shadeSide(r,g,b), then one use with a blue dye would add, say, five to the blue value.
-
I'm trying to dynamically add tint to a block with an item - make it more red/green/blue/whatever while keeping the same texture. I assumed the TintIndex would be the way to do it.
-
I'm not sure what that is. Could you elaborate?
-
I'm trying to figure out how to add colored tint to a block (or better still, just one face of it) that exists in the world. I imagine I would have to somehow access the block's TintIndex, but I have no idea how to do that or if that's even possible.
-
[1.8-11.14.4.1563] How do I implement logging?
paradoxbomb replied to paradoxbomb's topic in Modder Support
Sorry for the double-post bit I had a thought: could the problem be related to the fact that I'm using Eclipse EE? -
[1.8-11.14.4.1563] How do I implement logging?
paradoxbomb replied to paradoxbomb's topic in Modder Support
Nothing seems to have changed; I can see log4l-api-2.0-beta9.jar and log4j-core-2.0-beta9.jar in Forge's Referenced Libraries folder, but the import in my project still has the same error. I also noticed that there is a second error message at the top of the file saying " The type org.apache.log4j.Logger cannot be resolved. It is indirectly referenced from required .class files " Do I need to do something with my build path? -
[1.8-11.14.4.1563] How do I implement logging?
paradoxbomb replied to paradoxbomb's topic in Modder Support
Run it in the folder where I have my Eclipse workspace, right? -
[1.8-11.14.4.1563] How do I implement logging?
paradoxbomb replied to paradoxbomb's topic in Modder Support
I thought I did, but it doesn't seem to be a valid import; Eclips says that " The import org.apache cannot be resolved "