Jump to content

TheThorneCorporation

Members
  • Posts

    65
  • Joined

  • Last visited

Posts posted by TheThorneCorporation

  1. debug.logBumping because I can't figure out how to register the Recipe/RecipeSerializer.

    I have this class to store the advanced crafting recipe type:

    public interface IThorneRecipeType<T extends IRecipe<?>> extends IRecipeType<T> {
       IRecipeType<IAdvancedCraftingRecipe> ADVANCED_CRAFTING = register("advanced_crafting");
    
       static <T extends IRecipe<?>> IThorneRecipeType<T> register(final String key) {
          return Registry.register(Registry.RECIPE_TYPE, new ResourceLocation(key), new IThorneRecipeType<T>() {
             public String toString() {
                return key;
             }
          });
       }
    
       default <C extends IInventory> Optional<T> matches(IRecipe<C> recipe, World worldIn, C inv) {
          return recipe.matches(inv, worldIn) ? Optional.of((T)recipe) : Optional.empty();
       }
    }

    which should have registered the recipe type. (I'm doing both shapeless and shaped advanced crafting recipes.)

    I also have this class which should have registered the advanced recipe type serializers:

    public interface IThorneRecipeSerializer<T extends IRecipe<?>> extends IRecipeSerializer<T> {
    
    	IRecipeSerializer<ShapelessAdvancedRecipe> ADVANCED_CRAFTING_SHAPELESS = register("advanced_crafting_shapeless", new ShapelessAdvancedRecipe.Serializer());
    	IRecipeSerializer<ShapedAdvancedRecipe> ADVANCED_CRAFTING_SHAPED = register("advanced_crafting_shaped", new ShapedAdvancedRecipe.Serializer());
    
    	static <S extends IRecipeSerializer<T>, T extends IRecipe<?>> S register(String key, S recipeSerializer) {
    		return IRecipeSerializer.register(key, recipeSerializer);
    	}
    }

    The recipe still isn't registering, though. Am I supposed to use a RegistryEvent or something?

     

  2. It seems that either fluids or lambdas will be my number one enemy in my modding journey. In my class BlockList, I have my DeferredRegister<Block> named BLOCKS, and I'm trying to register the Sap block with this expression:

    public static final RegistryObject<Block> SAP = BLOCKS.register("sap", () -> new FlowingFluidBlock(() -> (FlowingFluid)FluidList.SAP.get(), Block.Properties.create(Material.WATER).doesNotBlockMovement().noDrops()));

     

    but it's not working, saying that the "Constructor FlowingFluidBlock(() -> {}, Block.Properties) is undefined" even though I checked and there is a constructor that takes a Supplier<? extends FlowingFluid> and a Block.Properties. (SAP is a RegistryObject<Fluid> in FluidList, that returns an instance of my FluidSap.Source fluid source block class when get() is called on it.)

     

    I have tried casting SAP.get() to a Fluid. I have tried casting it to a FluidSap. I have tried using a return statement in a block instead of just putting the return value. I have trued so many things and cannot for the life of me figure out what is going on with the supplier. Could someone please help me?

     

    Edit: Right after posting this, I tried casting it to a FluidSap.Source and it worked. Well, that was embarrassing...

  3. It's me again. I got the custom crafting table to work – it appears in the world, I can open it, and it doesn't close right away, which is always a plus. However, it doesn't seem my new recipe type has registered. Here is a picture of my directory to see which classes I copied over.

    How am I supposed to register a new recipe type?

    Screen Shot 2020-05-14 at 7.45.10 PM.png

    • Thanks 1
  4. 5 minutes ago, TheRedWaffle said:

     

    Sweet thanks for the help.
    Do I need to make my own 'shouldRemove()' method?
    I have this right now but shouldRemove isn't a real method :/
     

    
            if (!worldIn.isRemote) {
                if (!entityLiving.getActivePotionEffects().isEmpty()) {
                    Iterator<EffectInstance> itr = entityLiving.getActivePotionEffects().iterator();
                    do {
                        EffectInstance effectInstance = itr.next();
    
                        int duration = effectInstance.getDuration();
                        int amplifier = effectInstance.getAmplifier();
                        duration -= 600;
                        Effect effectPotion = effectInstance.getPotion();
    
                        if(shouldRemove(effectInstance)) {
                            entityLiving.removeActivePotionEffect(effectPotion);
                            entityLiving.addPotionEffect(new EffectInstance(effectPotion, duration, amplifier));
                        }
    
                    } while (itr.hasNext());
                }
            }

    Let me know if I have something wrong.

    Vinyarion doesn't actually mean "make a method called shouldRemove(EffectInstance e) that returns a boolean". the shouldRemove(object) expression is a stand in for whatever expression you want to use to determine if an object should be removed.

  5. Okay, so close Minecraft completely. Then open the Minecraft launcher and go to the Installations tab. Click on the "New" button and click on the "Version" bar to open the dropdown to select a version. If you scroll allllll the way down, you should find a version named "release-[mcversion]-Forge-[forgeversion]-[mcversion]", where [mcversion] is the version of Minecraft you're playing on and [forgeversion] is the version of Forge you're using. Select it in the dropdown, then give your profile a name and click, "Create."

    The reason for doing this is that Forge adds something that essentially functions like a new version of Minecraft, but with all the Forge capabilities. This is done to allow you to play on vanilla even if you have Forge installed (most servers are vanilla and will not accept a connection to anything running Forge, and you might also want to play regular Minecraft). So you'll need to create a new launcher profile with the Forge "version" of Minecraft to play with your mods loaded.

  6. I want to create an alternate crafting table for my mod that's identical to the vanilla one, but accesses different recipes (the recipe type might be thorneislearningmods:upgraded_crafting_[shapeless/shaped]). I looked at the vanilla code, but it's indecipherable. Could someone please explain to me how I might handle this?

  7. Cheating in Minecraft multiplayer is deplorable. Giving yourself an unfair advantage ruins the fun for everyone, and I am not doing it nor do I intend to do it. That being said, it might be useful to use certain "cheats" to debug your mod. (I'm thinking X-ray to test ore generation – while you can go into spectator and use /fill to clear out large swaths of stone, /fill has a limit on the blocks that can be removed and getting the coordinates is tedious.) Does anyone know of anything that might allow me to do that on the Forge debug Minecraft launcher?

  8. I don't know about the Minecraft code specifics, but assuming handIn is a valid Hand object and OFF_HAND is actually in the Hand enum class, then you're trying to use a Hand object as an if condition. All if conditions must be booleans. You might be able to do it like this, if Hand is an enum:
     

    if(handIn == OFF_HAND)

    or if Hand isn't an enum, but overrides equals():
     

    if(handIn.equals(OFF_HAND)

     

  9. I want to make my FluidSap slow down player movement, but I don't know how. Invoking doesNotBlockMovement on the Block.Properties() objects in the fluid block declarations doesn't do it for me. Here's my repo, so you can see what's going on:

    ...wait a minute. There's nothing here! Where are all my project files? I tried pushing to the origin in Eclipse, pushing to master, all of it! Yet nothing's happening. Could someone please help me with that, too?

    And for now, my Sap code:

    public abstract class FluidSap extends FlowingFluid{
    
    	@Override
    	public Fluid getStillFluid() {
    		//get sap source block
    		return FluidList.sap;
    	}
    
    	@Override
    	public Fluid getFlowingFluid() {
    		//get flowing sap fluid
    		return FluidList.flowing_sap;
    	}
    
    	@Override
    	protected boolean canSourcesMultiply() {
    		//you cannot make an infinite sap source
    		return false;
    	}
    
    	@Override
    	protected void beforeReplacingBlock(IWorld worldIn, BlockPos pos, BlockState state) {
    		// TODO I don't know how to use this yet
    		
    	}
    
    	@Override
    	protected int getSlopeFindDistance(IWorldReader worldIn) {
    		// TODO it flows the same slope as water
    		return 8;
    	}
    
    	@Override
    	protected int getLevelDecreasePerBlock(IWorldReader worldIn) {
    		// TODO Auto-generated method stub
    		return 2;
    	}
    
    	@Override
    	public Item getFilledBucket() {
    		// TODO Auto-generated method stub
    		return ItemList.sap_bucket;
    	}
    
    	@Override
    	protected boolean func_215665_a(IFluidState state, IBlockReader world, BlockPos pos,
    			Fluid fluid, Direction direction) {
    		// TODO Auto-generated method stub
    		return direction == Direction.DOWN && !fluid.isIn(FluidList.Tags.SAP);
    	}
    
    	@Override
    	public int getTickRate(IWorldReader p_205569_1_) {
    		// TODO Auto-generated method stub
    		return 20;
    	}
    
    	@Override
    	protected float getExplosionResistance() {
    		// TODO Auto-generated method stub
    		return 100.0f;
    	}
    
    	@Override
    	protected BlockState getBlockState(IFluidState state) {
    		// TODO Auto-generated method stub
    		return BlockList.sap.getDefaultState().with(FlowingFluidBlock.LEVEL, Integer.valueOf(getLevelFromState(state)));
    	}
    	
    	@Override
    	public boolean isEquivalentTo(Fluid fluidIn)
    	{
    		return fluidIn == FluidList.sap || fluidIn == FluidList.flowing_sap;
    	}
    	
    	@Override
    	protected FluidAttributes createAttributes()
    	{
    		return FluidAttributes
    			.builder(RegistryEvents.location("blocks/sap_still"), RegistryEvents.location("blocks/sap_flow"))
    			.translationKey("block.thorneislearningmods.sap")
    			.build(this);
    	}
    	
    	public static class Source extends FluidSap
    	{
    		
    		
    		@Override
    		public boolean isSource(IFluidState state) {
    			// TODO Auto-generated method stub
    			return true;
    		}
    
    		@Override
    		public int getLevel(IFluidState state) {
    			// TODO Auto-generated method stub
    			return 8;
    		}
    		
    		
    	}
    	
    	public static class Flowing extends FluidSap
    	{
    		@Override
    		protected void fillStateContainer(Builder<Fluid, IFluidState> builder)
    		{
    			super.fillStateContainer(builder);
    			builder.add(LEVEL_1_8);
    		}
    		
    		@Override
    		public boolean isSource(IFluidState state) {
    			return false;
    		}
    
    		@Override
    		public int getLevel(IFluidState state) {
    			// TODO Auto-generated method stub
    			return state.get(FluidSap.LEVEL_1_8);
    		}
    		
    	}
    }

     

    @SubscribeEvent
    public static void registerBlocks(final RegistryEvent.Register<Block> event)
    {
    	event.getRegistry().registerAll
    	(
    		BlockList.mod_gem_block = new Block(Block.Properties.create(Material.IRON).hardnessAndResistance(5).sound(SoundType.METAL).harvestTool(ToolType.PICKAXE).harvestLevel(3)).setRegistryName(location("mod_gem_block")),
    		BlockList.sap = new FlowingFluidBlock(() -> FluidList.sap, Block.Properties.create(Material.WATER).doesNotBlockMovement().noDrops()).setRegistryName(location("sap"))
    	);
    }
    
    @SubscribeEvent
    public static void registerFluids(final RegistryEvent.Register<Fluid> event)
    {
    	event.getRegistry().registerAll
    	(
    		FluidList.sap = (Source) new FluidSap.Source().setRegistryName(location("sap")),
    		FluidList.flowing_sap = (Flowing) new FluidSap.Flowing().setRegistryName(location("flowing_sap"))
    	);
    }

     

  10. 12 minutes ago, ChampionAsh5357 said:

    If you can find the folder where you extracted the forge contents into, you are going to open up a command window (Command Prompt, Powershell, Terminal, etc.) and then type 'git init'. From there, its the same setup as you would a normal git repo for whatever website you are uploading to.

    ...I don't know how to set up a git repo. Could you please tell me?

  11. I finished implementing my Sap in a way that's functional, but the fluid is opaque, which I don't want. How do I not make it opaque?

    My registry line for sap block:

    BlockList.sap = new FlowingFluidBlock(() -> FluidList.sap, Block.Properties.create(Material.WATER).doesNotBlockMovement().noDrops()).setRegistryName(location("sap"))

    and the fluid:

    FluidList.sap = (Source) new FluidSap.Source().setRegistryName(location("sap")),
    FluidList.flowing_sap = (Flowing) new FluidSap.Flowing().setRegistryName(location("flowing_sap"))

     

    (On another note, how do I create a Git repo from an Eclipse project?)

  12. Hey all,

     

    So, I have added shapeless crafting recipes for a Mod Gem Block as well as recipes for a set of trusty Mod Gem tools. Problem is, none of the shaped crafting recipes are loading in Minecraft when I run it, only the shapeless one. I can't see the shaped recipes in the recipe book, nor can they be crafted. Any idea why this is?

     

    My recipes are all .json files, located in src/main/resources/data.thorneislearningmods.recipes.

     

  13. ...does anyone know of any good programs for creating textures for Minecraft mods? I tried using GIMP, but their brush tools are just too unintuitive for me to work with. At the extremely small (16 pixel by 16 pixel) scales item textures operate on, any amount of blurriness and unpredictability is too much. Sketchbook by Autodesk doesn't work, either, because when I try to zoom in, it blurs the pixels of the asset I'm working on, because it doesn't recognize the context of a game asset. I need something that allows me to pick a color and, when I click on a pixel, it becomes that color. No fancy mixing, no partial transformations, no alpha channel shenanigans (well, an option for alpha channel shenanigans, but not by default). Just pure control.

     

    And if anyone knows of an automatic generator for model JSON files, that'd also be nice.

  14. So, I was following Mr. Pineapple's Fluids tutorial, and he said to create a new method in my FluidSap.Flowing class: fillStateContainer(Builder<Fluid, IFluidState> builder). Problem is, I don't know which Builder class to import, and Eclipse is giving me a lot of options for its Quick Fix. For context, here's an image of the Quick Fix menu after I right-click on the Builder error:

    tumblr_m6a8ayWCtK1rput01o2_500.jpg&f=1&n

     

    Help would be appreciated in picking out the right one.

     

  15. Alright, found the problem. I didn't realize I had to import java.util.function.Supplier.

    ...it's still saying that the constructors for BucketItem(lambda expression here, Item.Properties) and FlowingFluidBlock(() -> {}, Block.Properties) are undefined. It looks like both the constructors take suppliers.

    Wait, no, now it's working. I don't know why. Maybe it's because I imported the relevant classes? Oh well, at least I learned about lambdas. Thank you!

  16. On 4/8/2020 at 10:41 AM, Animefan8888 said:

    Post your updated code.

    ItemList.sap_bucket = new BucketItem(() -> FluidList.sap, new Item.Properties().group(ItemGroup.MISC).maxStackSize(1)).setRegistryName("sap_bucket")

    and the block:

    BlockList.sap = new FlowingFluidBlock(() -> FluidList.sap, Block.Properties.create(Material.WATER).doesNotBlockMovement().noDrops()).setRegistryName(location("sap"))

    Also, should I be using Java 12 or 8?

×
×
  • Create New...

Important Information

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