Jump to content

Recommended Posts

Posted

So as kinda given by the title, I'm trying to create a custom machine. To be more specific, a machine like a furnace but instead of cooking items, it combines 2 items into one - includes 2 of the same item (actually would like this to be more prioritised over 2 different items). It will also has 1 fuel slot where redstone dust/blocks are used to power it. I have looked up tutorials on custom machines; but they all pretty much involve smelting like a furnace, which I'm not trying to do. I feel like before I finish, I must mention that this is a custom block model machine and not one like a furnace where it just has different textures on the sides. I would also ideally like the fire cooking animation to be different. I believe I have most of the code done for the block itself; but I really need help on the actual functionality of this block. Detailed instructions on what each method would be highly appreciated, as I don't want just code that I don't understand and have no idea how to customise to make different machines.

Here's my code:

(Block Machine class)

package com.distinctsoul.soulforgery.blocks.machines;

import java.util.Random;

import com.distinctsoul.soulforgery.Main;
import com.distinctsoul.soulforgery.blocks.BlockBase;
import com.distinctsoul.soulforgery.init.ModBlocks;
import com.distinctsoul.soulforgery.util.Reference;

import net.minecraft.block.BlockHorizontal;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.InventoryHelper;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandler;

public class BlockShardFuser extends BlockBase implements ITileEntityProvider {
	
	public static final PropertyDirection FACING = BlockHorizontal.FACING;
	
	public BlockShardFuser(String name, Material material) {
		super(name, material);
		this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
		setSoundType(SoundType.STONE);
		setHardness(3.0F);
		setResistance(20.0F);
		setHarvestLevel("pickaxe", 2);
		// setLightLevel(0.1F);
		// setLightOpacity(1);
		// setBlockUnbreakable();
	}
	
	@Override
	public Item getItemDropped(IBlockState state, Random rand, int fortune) {
		return Item.getItemFromBlock(ModBlocks.SHARD_FUSER);
	}
	
	@Override
	public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state) {
		return new ItemStack(ModBlocks.SHARD_FUSER);
	}
	
	public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
		worldIn.setBlockState(pos, this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing()), 2);
	}
	
	public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY,
			float hitZ, int meta, EntityLivingBase placer) {
		return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
	}
	
	public static final AxisAlignedBB SHARD_FUSER_AABB = new AxisAlignedBB(0, 0, 0, 1, 1, 1);
	
	@Override
	public boolean isOpaqueCube(IBlockState state) {
		return false;
	}
	
	@Override
	public boolean isFullCube(IBlockState state) {
		return true;
	}
	
	@Override
	public EnumBlockRenderType getRenderType(IBlockState iBlockState) {
		return EnumBlockRenderType.MODEL;
	}
	
	@Override
	public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
		return SHARD_FUSER_AABB;
	}
	
	public IBlockState getStateFromMeta(int meta) {
		EnumFacing facing = EnumFacing.getHorizontal(meta);
		return this.getDefaultState().withProperty(FACING, facing);
	}
	
	public int getMetaFromState(IBlockState state) {
		EnumFacing facing = (EnumFacing)state.getValue(FACING);
		
		int facingbits = facing.getHorizontalIndex();
		return facingbits;
	}
	
	@Override
	protected BlockStateContainer createBlockState() {
		return new BlockStateContainer(this, new IProperty[] { FACING });
	}

	@Override
	public TileEntity createNewTileEntity(World worldIn, int meta) {
		return null;
	}
	
}

 

(BlockState json)

{
    "variants": {
        "facing=north": { "model": "soulforgery:shard_fuser" },
        "facing=south": { "model": "soulforgery:shard_fuser", "y": 180 },
        "facing=east": { "model": "soulforgery:shard_fuser", "y": 90 },
        "facing=west": { "model": "soulforgery:shard_fuser", "y": 270 }
    }
}

 

Any help would be very appreciated.

Posted

Instead of quoting everything that’s wrong, I’m just going to link https://gist.github.com/Cadiboo/fbea89dc95ebbdc58d118f5350b7ba93. Please read it. Descriptions of most of the methods can be found in their javadocs. If those are lacking, you can find out what the method does by finding the usages of it.

 

Im not sure if it’s mentioned in the file I linked, but don’t use ITileEntityProvider, it’s legacy vanilla code and Forge has a better replacement. Simply override hasTileEntity(IBlockState) and createTileEntity(IBlockState) in your block class. To answer your question, all functionality outside of your block just sitting there is implemented through a TileEntity (usually a Tickable one)

About Me

  Reveal hidden contents

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted (edited)

Loop over all your items and call the same code you would have in IHasModel. You subscribe to the registry event in the relevant EventSubscriber. Models should go in the client-only event subscriber, Object registration should go in the common/normal event subscriber.

Extract to a helper method means moving the same code that you call a lot into 1 helper method

Edited by Cadiboo

About Me

  Reveal hidden contents

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted

Short version:

@SubscribeEvent
public void registerModelsWithoutIHasModelLikeAGoodBoi(ModelRegistryEvent event) {
	modItems.forEach(item -> {
		ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));
	});
}

Something like that.

Basically loop through all your items and do what you normally do with IHasModel.

 

Cadiboo's example mod shows how to register stuff with good practices (the complete version); you might want to check that out.

The link is probably somewhere in his signature.

Some tips:

  Reveal hidden contents

 

  • 3 weeks later...
Posted
  On 4/30/2019 at 9:56 PM, Distinct Soul said:

I now get an error for 'ForgeRegistries', an error for the 'getNameSpace' on the 'onTextureStitchEvent' constructor, and an error for 'getPath' right after that.

Expand  

What are the errors exactly? You are probably using outdated mappings as my mod was built for the latest mappings.

getResourceDomain -> getNameSpace

getResourcePath -> getPath

onTextureStitchEvent isn’t a class, it’s a method so it can’t have a constructor.

About Me

  Reveal hidden contents

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted

Ah. I should probably update the forge that I'm using thinking about it. But also, are these new mappings still found on the most recommended release for Forge on 1.12? Or only later versions?

Not to mention, 'ForgeDirectories' comes up with an error stating to import it. But when I do, I then get an error for MOD_ID.

Posted
  On 4/30/2019 at 10:09 PM, Distinct Soul said:

But also, are these new mappings still found on the most recommended release for Forge on 1.12? Or only later versions?

Expand  

Mappings are separate from Forge

 

MCP (Mod Coder Pack) Mappings are what Forge uses to deobfuscate minecraft’s code and turn it into something human-readable.

These mapping names are provided by the community and can change, so it’s relatively important to keep them up to date. You can find a list of mappings here. Simply copy the name/date of the release and put it into your build.gradle file in the minecraftblock.

About Me

  Reveal hidden contents

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted

You’ll need to run setupDecompWorkspace again (only on 1.12.2 & below) and then refresh the Gradle Project

About Me

  Reveal hidden contents

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted

Under gradle tasks

About Me

  Reveal hidden contents

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted

What IDE do you use? In IntelliJ the gradle tasks and the refresh Gradle Project button are in the gradle pane in the right sidebar. In eclipse I have no idea where it is, but you can use the command line to run gradlew setupDecompWorkspace

About Me

  Reveal hidden contents

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted
  On 5/1/2019 at 9:55 PM, Cadiboo said:

What IDE do you use?

Expand  

Did you rerun the appropriate setup tasks for your IDE & refresh the Gradle Project?

About Me

  Reveal hidden contents

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted
  On 5/2/2019 at 3:09 PM, Distinct Soul said:

CreativeTabs

Expand  

ItemGroup

About Me

  Reveal hidden contents

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted

1. Show your code.

2. Use your IDE to figure out what methods changed and the replacement for them.

3. Do you know Java?

Some tips:

  Reveal hidden contents

 

Posted
  On 5/2/2019 at 3:09 PM, Distinct Soul said:

Well I now got that working; but now almost all my classes have errors. Probably because of the outdated things I'm using. For example: CreativeTabs has an error.

Expand  

 

  On 5/4/2019 at 4:10 AM, Cadiboo said:

ItemGroup

Expand  

I was assuming that you had updated to 1.13. CreativeTabs were renamed to ItemGroups in 1.13.

 

  On 5/5/2019 at 5:27 PM, Distinct Soul said:

I also now have an error for setUnlocalizedName after the mappings update.

 MOD_ID also still has an error.

Expand  

Saying “an error” doesn’t really give us any information that we can use to help you.

*UnlocalisedName -> *TranslationKey

MOD_ID should be replaced by an import of your modid from your main class or constants class.

I think that I use static imports in my 1.12.2 example mod which is apparently hard for many people so I’ve stopped using them on the 1.13 branch

About Me

  Reveal hidden contents

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted
  On 5/7/2019 at 3:07 AM, Distinct Soul said:

Also, by import of your modid, do you mean like Reference.MOD_ID?

Expand  

yes

About Me

  Reveal hidden contents

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements




  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Without Network protocol fix mod, I get kicked with a Network Protocol error when on LAN. Also, both of these issues are caused by a Null Pointer Exception/Screen cannot be null in a "Client Bound Player Combat Kill Packet".
    • You need a new "items" folder at  resources/assets/yourmodid/ there you add for every item model a .json file with the exact item/block name and fill it like this if it's an item: { "model": { "type": "minecraft:model", "model": "yourmodid:item/youritem" } } and so if its a block: { "model": { "type": "minecraft:model", "model": "yourmodid:block/youritem" } } There is also a generator for it you can do namy crazy things with it which replaces the previous hard coded Item Properties implementaion method (Bow pulling animation for example). https://misode.github.io/assets/item/
    • Hello! I'm playing a modpack (custom made) with some friends, and we have the server running on BisectHosting. We encountered a bug with an entity from The Box Of Horrors mod, that would crash the game whenever someone nearby it would log in. We tried to fix it by: 1) Editing the player.dat files to change the location of the affected players (something I had done successfully previously) 2) Updating the version of the mod we had (0.0.8.2) to the latest alpha version (0.0.8.3 However, after doing both of those, none of us are able to join the server, and we get the following errors: Server side: https://pastebin.com/J5sc3VQN Client side: Internal Server Error (that's basically all I've gotten) Please help! I've tried restoring the player data to how it was before I made the changes (Bisect allows you to restore deleted files) and deleting all of my player data files and I still get the same error. Deleting Box Of Horrors causes the error: Failed to load datapacks, cannot continue with server load.
    • Hey there! I'm trying to create a simple mod for Forge 1.21.1 that adds a few custom banner patterns that don't require any banner pattern items. To be completely honest, this is my first time modding for Minecraft, so after setting up the project in Intellij, I copied the parts of the source code from this mod on CurseForge that dealt with adding and registering banner patterns, including the lang and banner_pattern .json files. From what I understand, to add a banner pattern that doesn't require a banner pattern item, I only needed to create the registries for each pattern like in here and then register it in the main java class like here on Line 54. Additionally, in the lang/en_us.json file, add in the names for each respective banner color, and in the data/minecraft/tags/banner_pattern/no_items_required.json file, add each banner pattern that does not require a banner pattern item to make a banner. The project is able to compile when loading in Forge which makes me assume that the file structure I have is correct, but on loading a Minecraft world, this error appears in console and the loom is subsequently blank. [Worker-Main-1/ERROR] [minecraft/TagLoader]: Couldn't load tag minecraft:no_item_required as it is missing following references: *lists every added entry in no_item_required.json* The message clearly states something went wrong regarding when trying to load in the registries from the mod, but I have no clue what could be wrong with the code I have. Attached below are screenshots of what I currently have. Java Main Class Banner Registry Class File Structure Error in Console upon loading a Minecraft world What the loom shows without minecraft:no_item_required    The original mod I copied still functions completely, so if anyone can figure out why the registries for the mod I'm making isn't working, that would be greatly appreciated!    
    • Please someone help me to know how can I fix this generation error in the trees! I already uninstalled and reinstalled several mods in my modpack and can't figure out what is causing it.    
  • Topics

×
×
  • Create New...

Important Information

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