Jump to content

Recommended Posts

Posted

How do I make a block with metadata and how do I have that block make a new block with metadata? For an example I want to have a block and that block will get an input, north, for example and then create a new block in the north direction. Then it would send that metadata of north to the next block. In the end it would make a line of blocks going north.

I don't optimize my code before it works.

Posted

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Hi

 

If you want the line of blocks to spread itself slowly, you could use

 

BLock.updateTick()

with

worldIn.scheduleUpdate();

 

Look in BlockFire.updateTick() for more clues - the fire spreads itself in a very similar way to what you want.

 

-TGG

Posted

Important caveat (something I just ran into): Vanilla Minecraft won't process updates for blocks with material AIR (it explicitly tests for them and aborts processing). So if you're spreading something like smoke (some variation of air), then scheduled (and random tick) updates will be ignored  :(

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

I've tried to read the minecraft forge documentation for block states but it's such a mess I can't make any sense out of it. Could someone help me with the actual code? Help is greatly appriciated.

I don't optimize my code before it works.

Posted
  On 11/28/2016 at 3:22 AM, Durtle02 said:

I've tried to read the minecraft forge documentation for block states but it's such a mess I can't make any sense out of it. Could someone help me with the actual code? Help is greatly appriciated.

Blockstates are created when you apply a property to them in this case you will want to use PropertyInteger. Code wise you will need to override

getMetaFromState(IBlockState), getStateFromMeta(int meta), and createBlockState(). For an example look at BlockFurnace, BlockWool, BlockPiston. Those all have BlockStates although I don't think any use PropertyInteger, but they are applied the same way.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

BlockCrops and BlockReeds both use integers.

 

By the way, be aware of the BlockEvent.CropGrowEvent and its two sub events.  You should fire these at the appropriate times if you are not using subclassing a class that does, or not calling super.updateTick().  Look at BlockCrops, Reeds, Cactus, Netherwart, CocoPods, and a couple others for examples of useage.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
  On 11/28/2016 at 4:20 AM, Draco18s said:

BlockCrops and BlockReeds both use integers.

 

By the way, be aware of the BlockEvent.CropGrowEvent and its two sub events.  You should fire these at the appropriate times if you are not using subclassing a class that does, or not calling super.updateTick().  Look at BlockCrops, Reeds, Cactus, Netherwart, CocoPods, and a couple others for examples of useage.

Good point lol, I always forget that those use BlockStates...., but he isn't making a crop so he shouldn't have to worry about that event.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
  On 11/28/2016 at 4:26 AM, Animefan8888 said:

Good point lol, I always forget that those use BlockStates...., but he isn't making a crop so he shouldn't have to worry about that event.

 

One of his other threads is about is.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
  On 11/28/2016 at 5:20 AM, Durtle02 said:

I am not making crops.

 

Hmm, thought one of your other threads was....never mind :x

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Okay so I've tried a few things and I can't get blockstates to work for me. The premise of this block is

  On 11/26/2016 at 3:51 AM, Durtle02 said:

...I want to have a block and that block will get an input, north, for example and then create a new block in the north direction. Then it would send that metadata of north to the next block. In the end it would make a line of blocks going north.

I wrote out my code and it doesn't work. Could someone tell me how to operate this code? The block state code was originally from net.minecraft.block.BlockCrops.class.

 

package TestMod.tutorial.block;

import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

public class OrangeGoo extends BlockBase{
    public static final PropertyInteger SDIR = PropertyInteger.create("sdir", 0, 6);
    public OrangeGoo(String name){
        super(Material.ROCK, name);
        setTickRandomly(true);
        setHardness(0.1f);
        setResistance(1f);
    }
    //metadata 
    protected PropertyInteger getSDirProperty(){return SDIR;}
    protected int getSDir(IBlockState state){return (state.getValue(this.getSDirProperty()));}
    public IBlockState withSDir(int sdir){return this.getDefaultState().withProperty(this.getSDirProperty(), sdir);}
    @Override
    public IBlockState getStateFromMeta(int meta){return this.withSDir(meta);}
    @Override
    public int getMetaFromState(IBlockState state){return this.getSDir(state);}
    @Override
    protected BlockStateContainer createBlockState(){return new BlockStateContainer(this, new IProperty[] {SDIR});}
    
    //creative tab
    @Override
    public OrangeGoo setCreativeTab(CreativeTabs tab){
        super.setCreativeTab(tab);
        return this;
    }
    int direction;
    //spreading block
    public void blockSpread(World world, IBlockState state, BlockPos posNumber, BlockPos inversePos,int direction,int j){
        if(world.getBlockState(inversePos).getBlock() == ModBlocks.greengoo && world.getBlockState(posNumber).getBlock() != ModBlocks.redgoo){
            if(j==direction){
                world.setBlockState(posNumber, ModBlocks.orangegoo.getDefaultState());
                world.setBlockState(posNumber, state.withProperty(SDIR, direction), 6);
                // Alternative - (SDIR, Integer.valueOf(direction)), 6);
            }
        }

    }
    
    @Override
    public void updateTick(World world, BlockPos pos, IBlockState state, Random rand){
        int j = (state.getValue(SDIR));
        BlockPos pos0 = new BlockPos((pos.getX()), (pos.getY()) , pos.getZ());
        BlockPos xplus = new BlockPos((pos.getX()+1), (pos.getY()) , pos.getZ());//1
        BlockPos xminus = new BlockPos((pos.getX()-1), (pos.getY()) , pos.getZ());//2
        BlockPos yplus = new BlockPos((pos.getX()), (pos.getY()+1) , pos.getZ());//3
        BlockPos yminus = new BlockPos((pos.getX()), (pos.getY()-1) , pos.getZ());//4
        BlockPos zplus = new BlockPos((pos.getX()), (pos.getY()) , pos.getZ()+1);//5
        BlockPos zminus = new BlockPos((pos.getX()), (pos.getY()) , pos.getZ()-1);//6
        blockSpread(world, state, xplus, xminus,1,j);
        blockSpread(world, state, xminus, xplus,2,j);
        blockSpread(world, state, yplus, yminus,3,j);
        blockSpread(world, state, yminus, yplus,4,j);
        blockSpread(world, state, zplus, zminus,5,j);
        blockSpread(world, state, zminus, zplus,6,j);
    }
    @Override
    public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing heldItem, float side, float hitX, float hitY){
        int j = (state.getValue(SDIR));
        BlockPos pos0 = new BlockPos((pos.getX()), (pos.getY()) , pos.getZ());
        BlockPos xplus = new BlockPos((pos.getX()+1), (pos.getY()) , pos.getZ());//1
        BlockPos xminus = new BlockPos((pos.getX()-1), (pos.getY()) , pos.getZ());//2
        BlockPos yplus = new BlockPos((pos.getX()), (pos.getY()+1) , pos.getZ());//3
        BlockPos yminus = new BlockPos((pos.getX()), (pos.getY()-1) , pos.getZ());//4
        BlockPos zplus = new BlockPos((pos.getX()), (pos.getY()) , pos.getZ()+1);//5
        BlockPos zminus = new BlockPos((pos.getX()), (pos.getY()) , pos.getZ()-1);//6
        blockSpread(world, state, xplus, xminus,1,j);
        blockSpread(world, state, xminus, xplus,2,j);
        blockSpread(world, state, yplus, yminus,3,j);
        blockSpread(world, state, yminus, yplus,4,j);
        blockSpread(world, state, zplus, zminus,5,j);
        blockSpread(world, state, zminus, zplus,6,j);
        return false;}
}

I don't optimize my code before it works.

Posted

#1 your formatting in a couple of places is awful.

#2 you do not need a getter method for your static property

#3 why are you using an integer to represent direction? Why not use BlockDirectional.FACING?

#4 why are you setting the block twice?

                world.setBlockState(posNumber, ModBlocks.orangegoo.getDefaultState());
                world.setBlockState(posNumber, state.withProperty(SDIR, direction), 6);

 

You should only need the second line, but why are you using flags 2,4 and not 1,2?

#5 your updateTick method is garbage.  EnumFacing.values and pos.offset(facing) exist, not to mention EnumFacing#getOpposite().

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

#1 I forgot to mention that my code was a mess.

#2 I copied it from the vanilla MC code.

#3 I didn't know much of it or how to use it.

#4 I didn't know if I had to place the block before setting the data and didn't realize that the second line would also place the block.

#5 Didn't know that those were things, once again, my code is awful and I want it to work before I optimize it.

 

Thanks for the help ;D

I don't optimize my code before it works.

Posted

#1 The previous reply still didn't answer how to use block states. I know my code is messy and the block placement works for now. I just need to no how to use the block states to do what I want it to do.

 

#2 Also how do I code it in so the block has the same textures in game for each block state. Right now I'm getting the error texture when it's placed but the actual texture when in hand.

I don't optimize my code before it works.

Posted
  On 11/29/2016 at 5:29 AM, Durtle02 said:

#1 The previous reply still didn't answer how to use block states. I know my code is messy and the block placement works for now. I just need to no how to use the block states to do what I want it to do.

 

IBlockState state = someBlock.getDefaultState().withProperty(FACING,EnumFacing.WEST).withProperty(SomeOtherProp, Value);

world.setBlockState(pos, state, 3);

 

  Quote
#2 Also how do I code it in so the block has the same textures in game for each block state. Right now I'm getting the error texture when it's placed but the actual texture when in hand.

 

That's up to your blockstate.json file.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

For the spreading you can also do this:

 

  Reveal hidden contents

 

 

And I hope this solve your block texture problem:

 

  Reveal hidden contents

 

 

I don't if just writing this instead the property name is enough.

The code above works for me.

  "variants": {
        "normal":[{}],
"inventory":[{}]
  }

 

 

Posted

Are UP and DOWN valid directions for your spreading? If not, then you want to use the BlockHorizontal extension of BlockDirectional. It limits its property to the four compass points, and they're separately indexed 0..3.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

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

    • Maximize Savings With [acu639380] T e m u Promo Code $100 Off 2025 brings you unbeatable savings on T e m u , one of the most popular online shopping destinations. With the exclusive T e m u  Promo code (acu639380), you can unlock incredible discounts, including $100 off for new and existing users. Whether you’re a first-time shopper or a loyal customer, T e m u  ensures a seamless shopping experience with fast delivery, free shipping in 67 countries, and up to 90% off on a wide range of products. Why Choose T e m u ? T e m u  is a treasure trove of trending items at unbeatable prices. From fashion and beauty to electronics and home essentials, T e m u ’s vast collection caters to all your shopping needs. Here are some key features that make T e m u  stand out: Free shipping: Available in 67 countries. Unbeatable prices: Discounts up to 90% off. Fast delivery: Ensures your items arrive promptly. Exclusive Benefits of T e m u  Promo Code (acu639380) Using the T e m u  Promo code (acu639380) in 2025 can help you save more than ever before. Here’s a breakdown of the benefits: $100 Off for New Users: New shoppers can enjoy a flat $100 discount with the T e m u  first-time user Promo. $100 Off for Existing Users: Loyal customers can also take advantage of this substantial discount with the same code. 40% Extra Off: Apply the T e m u  Promo code (acu639380) to receive an additional 40% discount on selected products. $100 Promo Bundle: Get a $100 Promo bundle to maximize savings across multiple purchases. Free Gifts for New Users: First-time shoppers are rewarded with exclusive gifts. How to Redeem T e m u  Promo Code (acu639380) Redeeming your T e m u  Promo code (acu639380) is simple and straightforward: Visit the T e m u  website or app. Add your favorite items to your shopping cart. Enter the promo code (acu639380) at checkout. Watch the savings apply instantly! T e m u  Promos for 2025 This month is packed with incredible offers tailored for both new and existing users: For New Users: T e m u  Promo code (acu639380) $100 off: Enjoy a significant discount on your first order. T e m u  first-time user Promo: Unlock exclusive savings and free gifts. T e m u  discount code (acu639380) for 2025: Enhance your shopping experience with additional discounts. For Existing Users: T e m u  Promo code (acu639380) $100 off: Loyal customers can continue to enjoy massive savings. T e m u  Promo code (acu639380) 40% off: Apply this code for extra discounts on selected items. T e m u  Promo bundle: A $100 Promo bundle available for repeated use. Country-Specific T e m u  Promo Codes T e m u  offers regional discounts to ensure everyone can benefit from their amazing deals. Here’s how the T e m u  Promo code (acu639380) can be used worldwide: North America USA: $100 off your next purchase with T e m u  Promo code (acu639380). Canada: Enjoy a $100 discount using the same code. South America Mexico: Save 40% on selected items with T e m u  Promo code (acu639380). Brazil: Get exclusive 40% discounts on your shopping. Europe UK: Apply the T e m u  Promo code (acu639380) for $100 off. Germany: Take advantage of the $100 Promo bundle. Asia Japan: First-time users can use T e m u  new user Promo for $100 off. India: Use the Promo bundle for multiple savings. T e m u ’s New Offers in 2025 This month, T e m u  has introduced fresh deals to elevate your shopping experience. Enjoy free shipping, trending items at up to 90% off, and exclusive discounts with the T e m u  promo code (acu639380). Benefits of T e m u  Promos T e m u  Promos are designed to enhance your shopping experience. Here are the standout advantages: $100 Off: Ideal for significant savings, whether you’re a new or existing user. 40% Extra Discount: Perfect for those looking to stock up on essentials. Free Gifts: Specially curated for first-time shoppers. $100 Promo Bundle: Offers flexibility across multiple purchases. How T e m u  Makes Shopping Easy T e m u ’s user-friendly platform ensures a hassle-free shopping experience. With options like fast delivery, detailed product descriptions, and seamless payment methods, T e m u  is a one-stop shop for all your needs. FAQs about T e m u  Promo Code (acu639380) Can I combine multiple T e m u  Promo codes? No, only one Promo code can be used per transaction. However, the $100 Promo bundle can be split across multiple orders.  Is the T e m u  Promo code (acu639380) valid on all items? The code applies to a wide range of products but July exclude certain categories.  How often can I use the T e m u  Promo code (acu639380)? The usage frequency depends on the specific terms and conditions of each code. Final Thoughts T e m u  is setting new standards in online shopping with its incredible deals and discounts. With the T e m u  Promo code (acu639380), you can maximize your savings and enjoy a premium shopping experience. Whether you’re new to T e m u  or a returning customer, these offers ensure that every purchase is a win. Don’t wait—use the T e m u  promo code (acu639380) today and start saving big!
    • Typically—at least in my case—the broken datapack thing always turns out to be a broken mod. Someone else here might have a better answer for you than I do, but when that happens, I go through all my mods, disabling them one by one until I locate the culprit. It’s a headache, but it’s the only way I know how to do it.
    • Is there any mod for creating world templates for 1.20.1 forge, I found a fabric mod for such as purpose but can't seem to find one for forge. I know connector and forgeified fabric api exist but i'd prefer a forge mod to adding like 50 mods to my 200 mod modpack. Does anyone know of such a mod or is my only option using the fabric mod with connector?  
    • Please read the FAQ (https://forums.minecraftforge.net/topic/125488-rules-and-frequently-asked-questions-faq/) and post logs as described there to a site such as https://mclo.gs and post the link here.
    • I'm trying to play with the origins mod but even after adding it to the mod folder it doesn't show up in minecraft forge. I'm using 1.20.2 because that is the last update from the origins and I'm using the same version of forge.
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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