Jump to content

ehbean

Members
  • Posts

    21
  • Joined

  • Last visited

Posts posted by ehbean

  1. 25 minutes ago, kiou.23 said:

    in your own IDE you can search for the blocks.

    in IntelliJ you can use Ctrl + N, and type the name of the class you're looking for (RotatedPillarBlock, it's the class the logs use)

    in Eclipse I think it is Ctrl + Shift + T, but I'm not sure

     

    note that the vanilla and forge classes we'll be read-only, you can't edit them

    I'm using Eclipse, and that is the right key shortcut. Just gotta figure out how to get this to work now. Copy pasting the variables, and methods doesn't' seem to work outright so I'll need to do some tweaking. 

  2. 5 minutes ago, kiou.23 said:

    you can look at how vanilla blocks that can be oriented implement that, I've looked at the furnace implementation when I learned it. in this case you should look at the quartz pillar block, or any log block

    I feel like looking at those files would be greatly beneficial. Where would I find those?

  3. 31 minutes ago, Luis_ST said:

    the method is correct but you never set the default state in the block constructor

    you have to add:

    
    this.setDefaultState(this.stateContainer.getBaseState().with(FACING, Direction.NORTH));

    and if you want to create a block that works like the quartz pillar,

    then change the class that your block extends to RotatedPillarBlock so you don't have to overwrite the methods for the rotation

    So adding that line "this.setDefaultState...." to the public BlockState rotate method doesn't seem to get ride of that error there, but I can avoid even needing to override those four methods by changing "CoralPillar extends Blocks" to "CoralPillar extends RotatedPillarBlock"? Wouldn't I need to change how that is loaded during registry so it doesn't crash?

  4. I've been making some blocks in my mod, and I need the blocks to face a certain direction when placed, in a similar way to how a column/pillar will allow you to place it sideways so its top is facing the player. I've found some tutorials online, but they either don't work, or I'm given errors that I can't resolve. I'll post the code of what I've got so far.

     

    import net.minecraft.block.Block;
    import net.minecraft.block.BlockState;
    import net.minecraft.block.HorizontalBlock;
    import net.minecraft.block.SoundType;
    import net.minecraft.block.material.Material;
    import net.minecraft.data.BlockModelFields.Rotation;
    import net.minecraft.item.BlockItemUseContext;
    import net.minecraft.state.DirectionProperty;
    import net.minecraft.state.StateContainer;
    import net.minecraft.util.Mirror;
    import net.minecraftforge.common.ToolType;
    
    public class CoralPillar extends Block {
    	
    	private static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING;
    	
    	public CoralPillar() {
    		super(Block.Properties.create(Material.CORAL)
    				.hardnessAndResistance(1.0f, 6.0f)
    				.sound(SoundType.STONE)
    				.harvestLevel(1)
    				.harvestTool(ToolType.PICKAXE));
    	}
    	
    	@Override
    	public BlockState getStateForPlacement(BlockItemUseContext context) {
    		return this.getDefaultState().with(FACING, context.getPlacementHorizontalFacing().getOpposite());
    	}
    	
    	public BlockState rotate(BlockState state, Rotation rot) {
    		return state.with(FACING, rot.rotate(state.get(FACING)));
    	}
    	
    	@Override
    	public BlockState mirror(BlockState state, Mirror mirrorIn) {
    		return state.rotate(mirrorIn.toRotation(state.get(FACING)));
    	}
    	
    	@Override
    	protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
    		builder.add(FACING);
    	}
    }

     

    The error I'm getting is on line 34, reading "The method rotate(state.get(FACING)) is undefined for the type BlockModelFields.Rotation". I feel like the solution is simple, but I can't figure it out,

  5. 4 hours ago, diesieben07 said:

    Override isItemValid in your IItemHandler, it is respected by the slots. If you want different behavior for automation and the GUI you could also make a custom SlotItemHandler subclass and override isItemValid there.

    I'll make sure to try that when I get there. I still need to create the actual crafting station/furnace. What would you recommend I do or look at to figure that out?

  6. It's been a while since I've worked on a mod of mine, but I want to start again, and I need to make a few different custom crafting stations that act in similar way to brewing stands and furnaces. I've done some digging and I can't seem to find a straight forward example of doing so in 1.16.x. How would I go about making something like that? Is there any way to force slots inside the gui to only take certain items?

  7. 23 hours ago, Draco18s said:

    That's what container items are for. Vanilla does this with buckets of milk, for example. This is not handled by the crafting recipe json, but the item's class.

    You need slots that only accept specific items.

    As an example:
    https://github.com/Draco18s/ReasonableRealism/blob/1.14.4/src/main/java/com/draco18s/harderfarming/inventory/SaltSlotHandler.java

    Used:

    https://github.com/Draco18s/ReasonableRealism/blob/1.14.4/src/main/java/com/draco18s/harderfarming/entity/TannerTileEntity.java#L56

    Where would I find an example of the class that handles the buckets of items? Also, thank you for the GitHub links. Very useful.

  8. Hey there. I've got a quick 2 part question about crafting recipes.

    1. I have a Json file set up that returns and item whenever you craft with it, but I would like it to return two different items. (The recipe has you using a mortar and pestle to grind something). So if at all possible I'd like to return both the mortar, and the other item that is made in the process.

     

    2. How do I go about making a custom crafting station that accepts only certain items, uses a blaze powder as fuel. It would act similarly to a brewing stand, but I'd like to be able to add a new more crafting "options" going into it for later in this mod I'm working on.

     

    Thank you

  9. Ultimate goal here is to just make an item that on a right click, is shrunk from the inventory (which I've got down), and then give another, different, item to the player. I'm still learning all the different bits of modding using forge and Minecraft in general, so I apologize if these questions are simple. I am able to give the player an item from the vanilla game, but I can't seem to get it to work with the mod item I've made.

     

    So in summary the plan is: Right click empty syringe -> empty syringe is taken from inventory -> blood syringe is given to inventory.

  10. 1 hour ago, poopoodice said:

    The constructor of ItemStack is looking for an Item, but you has passed in an Item Supplier.

    You need to use RegistryObject#get to get the Item from the supplier, for example

    RegistryObject<Item> MY_ITEM = .....

    new ItemStack(MY_ITEM.get());

    I apologize if this is a dumb question, but would that look like this?

    public static final RegistryObject<Item> EMPTY_SYRINGE = RegistryHandler.ITEMS.register("empty_syringe", () -> new EmptySyringe(), new ItemStack(EMPTY_SYRINGE.get()));

    I get an error on the .register, the "new EmptySyringe()" and the "EMPTY_SYRINGE" inside of the new ItemStack.

    Here are the error messages

    - The method register(String, Supplier<? extends I>) in the type DeferredRegister<Item> is not applicable for the arguments (String, () -> {}, ItemStack)

    - Type mismatch: cannot convert from EmptySyringe to I

    - Cannot reference a field before it is defined

     

    I first and second errors are throwing me a bit. The third one, I'm assuming is because its looking for an ItemStack, but there is no ItemStack by the name of EmptySyringe that I've properly defined?

     

    Once again, Thank you for your time.

     

     

  11. 13 hours ago, poopoodice said:

    RegistryObject is a type supplier, use RegistryObject#get to get the item

    I've looked at the documentation for the method you suggested. I can't seem to find something that exactly matches that. Would it be event.getRegistry() or is that something else? Thank you.

  12. I know I've asked a lot of questions recently, but I hit another wall recently.

     

    I've been trying something with

    ItemHandHelper.giveItemToPlayer();

    that is triggered whenever an Item is right clicked.

    As it stand I can give players an item from the vanilla game, but I can't seem to give any items from my mod. I suspect that it has to do with how I'm registering all the mod items, which looks like this

    public static final RegistryObject<Item> EMPTY_SYRINGE = RegistryHandler.ITEMS.register("empty_syringe", () -> new EmptySyringe());

    Whenever I try to add the argument for a mod item to be given to the player I get the follow error "The constructor ItemStack(RegistryObject<Item>) is undefined".

     

    I'm assuming that I need to change the way I'm registering the items or do I need to add another line or two to make it work?

     

    Thank you

  13. 14 minutes ago, Beethoven92 said:

    The code is pretty short and straightforward...What don't you understand of the code inside the PotionItem#onItemUseFinish method?

    I see the method there, I just don't know who to have to item that is used back to the player as an empty version. It's not something in a glass bottle as potions are in vanilla. Is there some way to specify that after the use of the item it then takes the item that was used away, then gives its empty counterpart? Sorry if this is vauge.

  14. I can't seem to find anything about this on the form for 1.16.3 nor can I find anything about it on the documentation. I've got an item once the player uses I need to behave in a similar way to potions, where once its used it is removed from the inventory, then gives you an empty glass bottle for that item. How would I go about doing that?

     

    Thank you

     

    I was able to find a solution a few days ago. Figured I should update that here.

  15. This is my first post here so I apologize if I missed a posting rule, but I've got a question about making a custom potion-like effect. I've got an item in mind, that when used, will give a buff to the player (all vanilla effects). Instead of handing multiple effects to the player at the same time I was wondering if it was possible to make a custom effect that granted multiple vanilla potion effects at the same time? In addition to this, how would I return the empty item to the player in the same way that drinking a potion gives you an empty bottle?

     

    Thank you for your time.

×
×
  • Create New...

Important Information

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