Jump to content

[1.12.2] Putting item in a chest every tick


James (MSTUDIO)

Recommended Posts

If you mean once every block update tick (about the time it takes wheat to grow a stage, iirc), override the block's updateTick() function with your code to put the item in the chest. If you mean once every game tick, I don't know an easy way to do that. You can call this.worldIn.getBlockState(pos.down(3)).getBlock() where 'this' is the block class to get the chest three blocks down. I don't know how to put items in a chest, but you if you look through the minecraft source code, you should be able to at least figure out which functions to use. Good luck!

Link to comment
Share on other sites

2 hours ago, felinoid said:

If you mean once every block update tick (about the time it takes wheat to grow a stage, iirc), override the block's updateTick() function with your code to put the item in the chest. If you mean once every game tick, I don't know an easy way to do that. You can call this.worldIn.getBlockState(pos.down(3)).getBlock() where 'this' is the block class to get the chest three blocks down. I don't know how to put items in a chest, but you if you look through the minecraft source code, you should be able to at least figure out which functions to use. Good luck!

so how would i be able to check if that block is a chest?

Edited by James (MSTUDIO)
Link to comment
Share on other sites

check if the block has an ItemHandler capability (it means its any type of item-storage TE) with tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing) or tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing)!=null

 

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

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)

Link to comment
Share on other sites

so where would i put that code?

 

Code :

public class FoodSpawner extends BlockBase{

	private World worldIn;

	public FoodSpawner(String name, Material material) {
		super(name, material);
		setSoundType(SoundType.METAL);
		setHardness(3.0F);
		setResistance(17.0F);
		setHarvestLevel("pickaxe", 1);
	}
	
	public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random ran) {
		
	}
	
	public int tickRate(World worldIn)
	{
		return 10;
	}
	
}

 

Edited by James (MSTUDIO)
Link to comment
Share on other sites

You'll want to make a ticking TileEntity for it

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

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)

Link to comment
Share on other sites

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

    • Crypto Recovery Expert with Trustwizardhackworld Trustwizards Hackworld is Russia American Millennial Finance and Crypto Recovery Expert® and America’s Student School upgrade and Mobile spy™, and the founder of The Trustwizards Hackworld Crypto Recovery, a personal finance and recovery web-site dedicated to helping individuals and businesses escape from online investment and crypto perils and to start legitimate investing and building wealth for the future. You can learn more about him on the About Page, or on his personal web-site Trustwizardhackworld {.} com . He has been quoted in major publications including the New York Times, Washington Post, Fox, ABC, NBC, and more. He is also a regular contributor to Forbes. and Google search for Trustwizards Hackworld online for comments and reviews. I wholeheartedly recommend to anyone in need of digital asset recovery services. Their demonstrated ability to overcome seemingly impossible challenges, coupled with their unwavering commitment to their clients, makes them a trusted and reliable partner in the realm of digital asset recovery.
    • I tried this version, but it solved a part of my problem, there are still mods with this bug.    
    • I finally got to the server but when i got loaded in the game crashed https://pastebin.com/ADqmtkfR
    • Hi! I'm following Kaupenjoe's guide and making an entity, and I get a problem where two animations mix into one when my entity walks - idle  anim plays together with walking. As I'm pretty new into coding and modding, I don't know everything about what I do following his guide and I'd like to set up animations in specific way: 1. When entity is doing nothing, idle animation plays; 2. When entity is walking, only walk animation is playing Here's the code for this entity's animations, it only has 2 at the moment. What should I fix here to get the result I need? public final AnimationState idleAnimationState = new AnimationState(); private int idleAnimationTimeout = 0; @Override public void tick() { super.tick(); if(this.level().isClientSide()){ setupAnimationStates(); } } private void setupAnimationStates() { if(this.idleAnimationTimeout <= 0) { this.idleAnimationTimeout = this.random.nextInt(40) + 80; this.idleAnimationState.start(this.tickCount); } else { --this.idleAnimationTimeout; } } @Override protected void updateWalkAnimation(float pPartialTick) { float f; if(this.getPose() == Pose.STANDING) { f = Math.min(pPartialTick * 6F, 1f); } else { f = 0f; } this.walkAnimation.update(f, 0.2f); } Hopefully I got into right forum topic, I'm not very used to forum posting xDD  
    • DAFTAR WSOSLOT88 KLIK DISINI ATAU KETIK GOOGLE >> WSOSLOT88.COM       Slot Freebet Terbaru tanpa deposit dan tanpa syarat telah mengubah paradigma perjudian daring dengan memberikan kesempatan yang luar biasa bagi para pemain untuk menikmati permainan Slot tanpa tekanan finansial atau kendala persyaratan. Ini adalah langkah revolusioner dalam industri perjudian online yang mengutamakan pengalaman pemain. Dengan menawarkan kesempatan untuk mencoba berbagai permainan dan peluang menang tanpa modal, Slot freebet ini menjadi pilihan yang sangat menarik bagi para pecinta Slot di seluruh dunia. Jadi, jangan lewatkan kesempatan emas ini untuk merasakan sensasi keseruan permainan Slot tanpa harus membayar sepeser pun! Keyword terkait : Slot Freebet Slot Freebet Tanpa Deposit Slot Freebet Tanpa Syarat Slot Freebet Terbaru Slot Freebet Gratis Slot Freebet Tanpa Deposit 2024 Slot Freebet Tanpa Deposit Tanpa Syarat 2024 Slot Freebet 15k Tanpa Deposit Tanpa Syarat 2024 Slot Freebet 25k Tanpa Deposit Tanpa Syarat 2024 Slot Freebet 50k Tanpa Deposit Tanpa Syarat
  • Topics

×
×
  • Create New...

Important Information

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