Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

xTekBlue

Members
  • Joined

  • Last visited

Everything posted by xTekBlue

  1. package xtekblue.mod.objects.items; import java.util.Set; import com.google.common.collect.Sets; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemTool; import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.ItemShears; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import xtekblue.mod.Main; import xtekblue.mod.init.ItemInit; import xtekblue.mod.util.IHasModel; public class SawBase extends ItemTool implements IHasModel { private static final Set<Block> EFFECTIVE_ON = Sets.newHashSet(Blocks.PLANKS, Blocks.BOOKSHELF, Blocks.LOG, Blocks.LOG2, Blocks.CHEST, Blocks.PUMPKIN, Blocks.LIT_PUMPKIN, Blocks.MELON_BLOCK, Blocks.LADDER, Blocks.WOODEN_BUTTON, Blocks.WOODEN_PRESSURE_PLATE); public SawBase(String name, ToolMaterial materialIn) { super(materialIn, EFFECTIVE_ON); setUnlocalizedName(name); setRegistryName(name); setCreativeTab(CreativeTabs.TOOLS); ItemInit.ITEMS.add(this); } @Override public void registerModels() { Main.proxy.registerItemRenderer(this, 0, "inventory"); } @Override public ItemStack getContainerItem(ItemStack itemStack) { if (!hasContainerItem(itemStack)) { return ItemStack.EMPTY; } return new ItemStack(getContainerItem()); } @Override public boolean hasContainerItem(ItemStack stack) { return hasContainerItem(); } } but that's not the problem now. I am not using container item anymore, i am attempting to allow a items damage to go down per use in crafting table and allow damage values in the recipes.
  2. i have changed the code a bit, and what i'm making in all. I'm now attempting to not have a "Broken_Saw" but instead have a durability on the saw itself and when it breaks its gone. Do you have any idea what i should do to make durability go down per use in crafting table? Also allowing the crafting of a item to be made with a item with durability?
  3. My saw class is a base for both "Broken_Saw" and "Ingot_Saw". So wont this make both items a container item, something im trying to prevent right?
  4. It worked on one recipes, sorry. This is my code for another, I'm trying to make it check the container item to see if its a "Ingot_Saw" and if so give the player a "Broken_Saw" package xtekblue.mod.objects.items; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import xtekblue.mod.init.ItemInit; public class OIBase extends ItemBase { public Boolean hasContainerNow = this.hasContainerItem(new ItemStack(ItemInit.INGOT_SAW)); public OIBase(String name) { super(name); setCreativeTab(CreativeTabs.MATERIALS); } @Override public void onCreated(ItemStack stack, World worldIn, EntityPlayer playerIn) { if(hasContainerNow == true) { playerIn.inventory.add(1, new ItemStack(ItemInit.BROKEN_SAW)); } } } Should this not work?
  5. Thank you. Worked Perfectly!
  6. xTekBlue posted a topic in Modder Support
    I am attempting to make a recipe with 2 outputs, kind of like cake. (Bucket and Cake). I have no idea where to start. I am using json format, and i want it to be a shapeless recipe.
  7. Title kinda says it all but i am trying to make it where when you place dirt inside a water source block, it replaces the dirt block with a block i call "BlockInit.MUD_BLOCK". I don't see a method that easily makes this possible so i am coming here for some help in finding one. The closest methods i can find is farmland methods but that only detects if farmland is next to water, i am trying to detect when dirt is INSIDE water or when dirt Replaces water. Anyone who helps me find a method that can easily do this, thank you in advance.
  8. There will be a lot of code shown here because my mod is very spread out. I have been making this fairly small mod and i was trying to mess with item records which i am unfamiliar with, my code will be shown below for just about every bit of code belonging to this item. I have seem to get everything working except the sound that i am trying to play, does not seem to play, in-fact it doesn't even show "Now Play ____ Music Disc". If anyone see's the problem please help me solve it. Thank you in advance. ItemInit.class package xtekblue.mod.init; import java.util.ArrayList; import java.util.List; import net.minecraft.init.SoundEvents; import net.minecraft.item.Item; import xtekblue.mod.objects.items.ItemBase; import xtekblue.mod.objects.items.ItemRecord; import xtekblue.mod.util.handlers.SoundsHandler; public class ItemInit { public static final List<Item> ITEMS = new ArrayList<Item>(); public static final Item MUD_BALL = new ItemBase("mud_ball"); public static final Item RECORD_SAD = new ItemRecord("sad", SoundsHandler.RECORD_SAD); //public static final Item MIX_REDSTONE_GLOWSTONE = new ItemBase("mix_redstone_glowstone"); //public static final Item EMERALD_SWORD = new ItemSwordBase("emerald_sword", ItemBase.ToolMaterialFXI.EMERALD); } ItemRecord.class package xtekblue.mod.objects.items; import java.util.List; import java.util.Map; import javax.annotation.Nullable; import com.google.common.collect.Maps; import net.minecraft.block.BlockJukebox; import net.minecraft.block.state.IBlockState; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.stats.StatList; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.SoundEvent; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.translation.I18n; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class ItemRecord extends ItemBase { private static final Map<SoundEvent, ItemRecord> RECORDS = Maps.<SoundEvent, ItemRecord>newHashMap(); private final SoundEvent sound; private final String displayName; public ItemRecord(String name, SoundEvent soundIn) { super(name); this.displayName = "XXX - SAD"; this.sound = soundIn; this.maxStackSize = 1; this.setCreativeTab(CreativeTabs.MISC); RECORDS.put(this.sound, this); } /** * Called when a Block is right-clicked with this Item */ public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { IBlockState iblockstate = worldIn.getBlockState(pos); if (iblockstate.getBlock() == Blocks.JUKEBOX && !((Boolean)iblockstate.getValue(BlockJukebox.HAS_RECORD)).booleanValue()) { if (!worldIn.isRemote) { ItemStack itemstack = player.getHeldItem(hand); ((BlockJukebox)Blocks.JUKEBOX).insertRecord(worldIn, pos, iblockstate, itemstack); worldIn.playEvent((EntityPlayer)null, 1010, pos, Item.getIdFromItem(this)); itemstack.shrink(1); player.addStat(StatList.RECORD_PLAYED); } return EnumActionResult.SUCCESS; } else { return EnumActionResult.PASS; } } /** * allows items to add custom lines of information to the mouseover description */ @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) { tooltip.add(this.getRecordNameLocal()); } @SideOnly(Side.CLIENT) public String getRecordNameLocal() { return I18n.translateToLocal(this.displayName); } /** * Return an item rarity from EnumRarity */ public EnumRarity getRarity(ItemStack stack) { return EnumRarity.RARE; } @Nullable @SideOnly(Side.CLIENT) public static ItemRecord getBySound(SoundEvent soundIn) { return RECORDS.get(soundIn); } @SideOnly(Side.CLIENT) public SoundEvent getSound() { return this.sound; } } SoundsHandler.class package xtekblue.mod.util.handlers; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundEvent; import net.minecraftforge.fml.common.registry.ForgeRegistries; import xtekblue.mod.util.Reference; public class SoundsHandler { public static SoundEvent RECORD_SAD; public static void registerSounds() { RECORD_SAD = registerSound("record.sad"); } private static SoundEvent registerSound(String name) { ResourceLocation location = new ResourceLocation(Reference.MODID, name); SoundEvent event = new SoundEvent(location); event.setRegistryName(name); ForgeRegistries.SOUND_EVENTS.register(event); return event; } } My .ogg file is saved in "assets.bx.sounds.record" and my sounds.json is saved in "assets.bx". Here is my sounds.json { "record.sad": { "category": "record", "subtitle": "record.sad", "sounds": [{ "name": "bx:record/sad", "stream": true}] } }
  9. hmm, I have tried setting hardness and such, maybe its because of the Material.REDSTONE_LIGHT Because i have made another block the exact same but set Material to IRON and efficiency works on it. I'm going to do further testing.
  10. Got it, but how would i allow efficiency or set a hardness for efficiency levels on pickaxes. I removed the setHarvestLevel("pickaxe", 0); because it made pickaxes break it instantly just about. I'm trying to make the Pickaxe mine the block just as slow but when the Pickaxe has efficiency then it can mine it a tiny bit quicker.
  11. I am posting this before i sleep so i will not be responding back for a while. Other news, i can not figure out where the method is for allowing efficiency on my block and where to add fortune to my block. Here is my code that I've been messing with. package xtekblue.mod.objects.blocks; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import xtekblue.mod.Main; import xtekblue.mod.init.ItemInit; import xtekblue.mod.util.IHasExtra; import xtekblue.mod.util.IHasModel; public class BlockRGLit extends BlockBase { public BlockRGLit(String name) { super(name, Material.REDSTONE_LIGHT); setSoundType(SoundType.GLASS); setHardness(0.5F); setLightLevel(8.0F); setResistance(1.5F); setHarvestLevel("pickaxe", 0); } /** * Returns the quantity of items to drop on block destruction. */ public int quantityDropped(Random rand) { return rand.nextInt(4) + 1; } @Override public Item getItemDropped(IBlockState state, Random rand, int fortune) { return ItemInit.MIX_REDSTONE_GLOWSTONE; } @Override protected ItemStack getSilkTouchDrop(IBlockState state) { Item item = Item.getItemFromBlock(this); int i = 0; if (item.getHasSubtypes()) { i = this.getMetaFromState(state); } return new ItemStack(item, 1, i); } }
  12. I am so bad at this xD. Figured it out and from this i will learn. Thank you so much with struggling to help me do this. Especially without just saying the right code. <3 @Override public Item getItemDropped(IBlockState state, Random rand, int fortune) { return ItemInit.MIX_REDSTONE_GLOWSTONE; }
  13. Okay so i changed a few things and i have no idea what i'm doing so bare with me package xtekblue.mod.objects.blocks; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import xtekblue.mod.Main; import xtekblue.mod.init.ItemInit; import xtekblue.mod.util.IHasExtra; import xtekblue.mod.util.IHasModel; public class BlockRGLit extends BlockBase implements IHasExtra{ public BlockRGLit(String name) { super(name, Material.REDSTONE_LIGHT); setSoundType(SoundType.GLASS); setHardness(0.5F); setLightLevel(8.0F); setResistance(1.5F); } /** * Returns the quantity of items to drop on block destruction. */ public int quantityDropped(Random p_149745_1_) { return 4; } @Override public Item getItemDropped(int par1, Random rand, int par2) { return ItemInit.MIX_REDSTONE_GLOWSTONE; } } So i implemented IHasExtra (Interface) which looks like this to remove the @Override ERROR package xtekblue.mod.util; import java.util.Random; import net.minecraft.item.Item; public interface IHasExtra { Item getItemDropped(int par1, Random rand, int par2); } Still does not seem to work. I have tried about 100 different combinations of moving stuff to different places, i'm new with java and used to doing Lua. I am trying to learn java the same way i learned Java (Self taught with help of the internet) Thanks for helping me thus far.
  14. That's just it, when i @override on the method i'm using it doesn't say "this isn't overriding anything" it says to add it to my blockbase class. but if i do this, it will drop that item for all the blocks i have created. Correct? Should i be overriding this? //This says to override this method you need to implement a supertype @Override public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { return ItemInit.MIX_REDSTONE_GLOWSTONE; }
  15. package xtekblue.mod.objects.blocks; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import xtekblue.mod.init.ItemInit; public class BlockRGLit extends BlockBase { public BlockRGLit(String name) { super(name, Material.REDSTONE_LIGHT); setSoundType(SoundType.GLASS); setHardness(0.5F); setLightLevel(8.0F); setResistance(1.5F); } /** * Returns the quantity of items to drop on block destruction. */ public int quantityDropped(Random p_149745_1_) { return 4; } public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { return Item.getItemFromBlock(this); } } This is the code i am currently testing but i have noticed that the quantityDropped is working but the getItemDropped is not exactly. I have tried setting the Item.getItemFromBlock() to ItemInit.MIX_REDSTONE_GLOWSTONE but that doesnt seem to change the item being dropped.
  16. I've tried that but i've seen in other posts that override does not work and is actually recommended to no do it.
  17. I have been working on a glowstone like block but i cant seem to get the block to drop the item i want it to when its broken. Also i cant seem to control the amount of that item to be dropped when its broken. I would like for the block to drop 2-4 of the item when broken randomly. package xtekblue.mod.objects.blocks; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import xtekblue.mod.init.ItemInit; public class BlockRGLit extends BlockBase { private final int dropAmount = 1; public BlockRGLit(String name) { super(name, Material.REDSTONE_LIGHT); setSoundType(SoundType.GLASS); setHardness(0.5F); setLightLevel(8.0F); setResistance(1.5F); } //No idea if these even works because i haven't seemed to figure out how to get the items to be dropped when the block is broken. public int quantityDropped(Random random) { return dropAmount; } }
  18. Sorry, I sent that in school and I’m in school still. I’ll be home in a few hours. I’ll send the errors then
  19. That's the exact stuff i've found looking on the web for like an hours. I've extended ItemRecord on line 61 but it caused errors. That's just where i'm assuming it goes by the way. I am not only here to help my own code out, id like to let others figure this out as well. I have small experience with java but enough to create my own Spigot plugins. This is the first time i'm messing with actual Minecraft files creating a mod of my own, so sorry if i'm speaking crazy.
  20. I am currently making a random mod with, well, random things and i'm having big problems creating this music disc. I have the model, song/ogg file, and have all the code for the item as a static, well, item. Ill link the code of the item at the bottom of this topic but i came here because i can not figure out for the life of me, how to make this item a "Record". Everywhere i look, i cannot find any help. The most i can do on my own is simply make the song play after i right click a jukebox (Doesn't use the disc, song doesn't stop after jukebox is broken). Please help, thank you! import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.common.registry.ForgeRegistries; import net.minecraftforge.fml.common.event.FMLServerStartingEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraft.world.World; import net.minecraft.item.ItemStack; import net.minecraft.item.Item; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.Minecraft; import net.minecraft.block.state.IBlockState; import net.minecraft.block.Block; import java.util.Random; import java.util.List; @SuppressWarnings("unchecked") public class mcreator_record1 { public mcreator_record1() { } public static Item block; public static Object instance; public void load(FMLInitializationEvent event) { if (event.getSide() == Side.CLIENT) Minecraft.getMinecraft().getRenderItem().getItemModelMesher() .register(block, 0, new ModelResourceLocation("%MAINMODNAME%:Record1", "inventory")); GameRegistry.addSmelting(mcreator_sapphireBlock.block, new ItemStack(block), 1.0f); } public void generateNether(World world, Random random, int chunkX, int chunkZ) { } public void generateSurface(World world, Random random, int chunkX, int chunkZ) { } public int addFuel(ItemStack fuel) { return 0; } public void serverLoad(FMLServerStartingEvent event) { } public void preInit(FMLPreInitializationEvent event) { } public void registerRenderers() { } static { block = (new Itemrecord1()); } static class Itemrecord1 extends Item { public Itemrecord1() { setMaxDamage(0); maxStackSize = 1; setUnlocalizedName("record1"); setRegistryName("record1"); ForgeRegistries.ITEMS.register(this); setCreativeTab(mcreator_mourItems.tab); } @Override public int getItemEnchantability() { return 0; } @Override public int getMaxItemUseDuration(ItemStack par1ItemStack) { return 0; } @Override public float getDestroySpeed(ItemStack par1ItemStack, IBlockState par2Block) { return 1.0F; } @Override public void addInformation(ItemStack itemstack, World world, List<String> list, ITooltipFlag flag) { list.add("XXXTentation - Skin"); } } } Although this is made with MCreator, I use the code portion of the program often. So if someone would like to just link me a updated copy of this item with record functionality, feel free

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.