Jump to content
Search In
  • More options...
Find results that contain...
Find results in...


  • Posts

  • Joined

  • Last visited

Everything posted by FOGC123

  1. 1. how do you open it from a player 2. how do you make one??
  2. trying to override onItemRightClick so i look in the list of overridable functions in Item class and it doesnt exist?
  3. Heres my github link : https://github.com/FOGC123/randomadditions1.15.2
  4. Sorry i wasnt very clear with my question, I have registered the deferred register on my mod event bus but: "TileEntityType.Builder.create(TileEntityWandInfuser::new, ModBlocks.WAND_INFUSER.get())" still returns error Cannot resolve method 'create(<method reference>, net.minecraftforge.registries.IForgeRegistryEntry)'
  5. As i said I would like to register a tile entity using deferred register: Code package com.fogc123.randomadditions.tilentities; import com.fogc123.randomadditions.RandomAdditions; import com.fogc123.randomadditions.blocks.ModBlocks; import net.minecraft.tileentity.TileEntityType; import net.minecraftforge.fml.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; public class ModTileEntities { public static final DeferredRegister<TileEntityType<?>> TILE_ENTITIES = new DeferredRegister<>(ForgeRegistries.TILE_ENTITIES, RandomAdditions.MODID); public static final RegistryObject<TileEntityType<TileEntityWandInfuser>> WAND_INFUSER = TILE_ENTITIES.register("firstblock", () -> TileEntityType.Builder.create(TileEntityWandInfuser::new, ModBlocks.WAND_INFUSER.get()).build(null)); } package com.fogc123.randomadditions.blocks; import com.fogc123.randomadditions.tilentities.ModTileEntities; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.material.Material; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import javax.annotation.Nullable; public class BlockWandInfuser extends Block { public BlockWandInfuser() { super(Block.Properties.create(Material.WOOD)); } @Override public boolean hasTileEntity(final BlockState state) { return true; } @Nullable @Override public TileEntity createTileEntity(final BlockState state, final IBlockReader world) { return ModTileEntities.WAND_INFUSER.get().create(); } } package com.fogc123.randomadditions.tilentities; import com.fogc123.randomadditions.blocks.ModBlocks; import com.fogc123.randomadditions.containers.WandInfuserContainer; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.network.play.server.SUpdateTileEntityPacket; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TranslationTextComponent; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.items.ItemStackHandler; import javax.annotation.Nonnull; import javax.annotation.Nullable; public class TileEntityWandInfuser extends TileEntity implements ITickableTileEntity, INamedContainerProvider { //only one slot for now for testing public static final int BOOK_SLOT = 0; //handles inventory public final ItemStackHandler inventory = new ItemStackHandler(1) { @Override public boolean isItemValid(int slot, @Nonnull ItemStack stack) { // check if item is valid for slot, just return true for now(all items will be valid) return true; } @Override protected void onContentsChanged(int slot) { //callled everytime contents of inventory is changed super.onContentsChanged(slot); //mark entity dirty so game will save chunk to disc TileEntityWandInfuser.this.markDirty(); System.out.println("Tile Entity Inventory Contents Changed!"); } }; //reduces number of objects i create(more efficient) public final LazyOptional<ItemStackHandler> inventoryCapabilityExternal = LazyOptional.of(() -> this.inventory) public TileEntityWandInfuser(TileEntityType<?> tileEntityTypeIn) { super(tileEntityTypeIn); } @Override public void tick() { //called every tick } @Override public void remove() { super.remove(); inventoryCapabilityExternal.invalidate(); } @Nonnull public CompoundNBT getUpdateTag() { return this.write(new CompoundNBT()); } @Override public ITextComponent getDisplayName() { return new TranslationTextComponent(ModBlocks.WAND_INFUSER.get().); } /** * Called from {@link NetworkHooks#openGui} * (which is called from {@link BlockWandInfuser#onBlockActivated} on the logical server) * * @return The logical-server-side Container for this TileEntity */ @Nullable @Override public Container createMenu(int windowId, PlayerInventory inv, PlayerEntity player) { return new WandInfuserContainer(windowId, inv, this); } }
  6. I want to summon a firecharge when you right click with a wand item but i have no idea how i would do that. My code: public class ItemFireballWand extends Item { public ItemFireballWand() { super(new Item.Properties().maxStackSize(1)); } @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { return ActionResult.resultSuccess(new ItemStack(this)); } }
  7. Oh wait no im dumb its just the default use noise, is there anyway to replace that?
  8. Here you go: public class BasicWand extends Item{ public BasicWand(){ super(new Item.Properties().maxStackSize(64).group(ModItemGroups.MOD_ITEM_GROUP)); this.setRegistryName("basic_wand"); } @Override public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) { if (player.isCrouching()) { System.out.println("Wand Inventory opened!"); return ActionResult.resultPass(new ItemStack(ModItems.BASIC_WAND)); } System.out.println("Wand Used!"); return ActionResult.resultPass(new ItemStack(ModItems.BASIC_WAND)); } }
  9. I am creating an item that does something when you right click with it in your hand, but currently it makes a wierd water noise when you use it. How would i go about changing that(I want to change it to a different vanilla sound)
  10. Thanks so much! Are there any significant differences between 1.15.1 and 1.15.2?
  11. I've been following a tutorial(https://cadiboo.github.io/tutorials/1.15.1/forge/) and i was having problems with registering items. The game launches fine, my mod gets loaded, but i can't get my item with the /give command. I see a one possible problem. The tutorial is using 1.15.1 and I am using 1.15.2(but i doubt that would make a big difference). My main mod class: package com.fogc123.randomadditions; import net.minecraftforge.fml.common.Mod; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @Mod(Main.MODID) public final class Main { public static final String MODID = "random_additions"; public static final Logger LOGGER = LogManager.getLogger(); public Main() { LOGGER.debug("HI!"); } } My modeventsubscriber class: package com.fogc123.randomadditions; import net.minecraft.item.Item; import net.minecraft.util.ResourceLocation; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.registries.IForgeRegistry; import net.minecraftforge.registries.IForgeRegistryEntry; @Mod.EventBusSubscriber(modid = Main.MODID, bus = Mod.EventBusSubscriber.Bus.FORGE) public final class ModEventSubscriber { @SubscribeEvent static void onRegisterItems(RegistryEvent.Register<Item> event) { //change this l8r event.getRegistry().registerAll(setup(new Item(new Item.Properties()), "first_item")); } public static <T extends IForgeRegistryEntry<T>> T setup(final T entry, final String name) { return setup(entry, new ResourceLocation(Main.MODID, name)); } public static <T extends IForgeRegistryEntry<T>> T setup(final T entry, final ResourceLocation registryName) { entry.setRegistryName(registryName); return entry; } } And my mods.toml if that is needed # This is an example mods.toml file. It contains the data relating to the loading mods. # There are several mandatory fields (#mandatory), and many more that are optional (#optional). # The overall format is standard TOML format, v0.5.0. # Note that there are a couple of TOML lists in this file. # Find more information on toml format here: https://github.com/toml-lang/toml # The name of the mod loader type to load - for regular FML @Mod mods it should be javafml modLoader="javafml" #mandatory # A version range to match for said mod loader - for regular FML @Mod it will be the forge version loaderVersion="[31,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. # A URL to refer people to when problems occur with this mod issueTrackerURL="http://my.issue.tracker/" #optional # A list of mods - how many allowed here is determined by the individual mod loader [[mods]] #mandatory # The modid of the mod modId="random_additions" #mandatory # The version number of the mod - there's a few well known ${} variables useable here or just hardcode it version="${version}" #mandatory # A display name for the mod displayName="Random Additions" #mandatory # A URL to query for updates for this mod. See the JSON update specification <here> updateJSONURL="http://myurl.me/" #optional # A URL for the "homepage" for this mod, displayed in the mod UI displayURL="http://example.com/" #optional # A file name (in the root of the mod JAR) containing a logo for display logoFile="icon.png" #optional # A text field displayed in the mod UI credits="Random stuff" #optional # A text field displayed in the mod UI authors="FOGC123" #optional # The description text for the mod (multi line!) (#mandatory) description=''' Random stuff i wanted to add. ''' # A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional. [[dependencies.examplemod]] #optional # the modid of the dependency modId="forge" #mandatory # Does this dependency have to exist - if not, ordering below must be specified mandatory=true #mandatory # The version range of the dependency versionRange="[31,)" #mandatory # An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory ordering="NONE" # Side this dependency is applied on - BOTH, CLIENT or SERVER side="BOTH" # Here's another dependency [[dependencies.examplemod]] modId="minecraft" mandatory=true versionRange="[1.15.2]" ordering="NONE" side="BOTH" Thanks!
  12. How would i know if that was one of them(I have just run ./gradlew genEclipseRuns in terminal)
  13. Would it have automatically happened when I imported the grade file?
  14. In eclipse, right click main folder, run as, java application, Start (MCP.start)
  15. I don't understand, what is genEclipseRuns, the way I setup my mod is I imported the grade file into workspace.
  16. As the title says, my mod that i am creating in eclipse crashes before the client opens. My log file: ---- Minecraft Crash Report ---- // There are four lights! Time: 13/03/20 7:38 PM Description: Initializing game java.lang.NullPointerException: Initializing game at net.minecraftforge.fml.loading.progress.EarlyProgressVisualization.join(EarlyProgressVisualization.java:40) ~[forge-1.15.2-31.1.19_mapped_snapshot_20200225-1.15.1-launcher.jar:?] {} at net.minecraft.client.Minecraft.<init>(Minecraft.java:371) [forge-1.15.2-31.1.19_mapped_snapshot_20200225-1.15.1.jar:?] {} at net.minecraft.client.main.Main.main(SourceFile:166) [forge-1.15.2-31.1.19_mapped_snapshot_20200225-1.15.1.jar:?] {} at mcp.client.Start.main(Start.java:17) [forge-1.15.2-31.1.19_mapped_snapshot_20200225-1.15.1.jar:?] {} A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Render thread Stacktrace: at net.minecraftforge.fml.loading.progress.EarlyProgressVisualization.join(EarlyProgressVisualization.java:40) at net.minecraft.client.Minecraft.<init>(Minecraft.java:371) -- Initialization -- Details: Stacktrace: at net.minecraft.client.main.Main.main(SourceFile:166) at mcp.client.Start.main(Start.java:17) -- System Details -- Details: Minecraft Version: 1.15.2 Minecraft Version ID: 1.15.2 Operating System: Mac OS X (x86_64) version 10.15.3 Java Version: 1.8.0_231, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 221078840 bytes (210 MB) / 374865920 bytes (357 MB) up to 1908932608 bytes (1820 MB) CPUs: 4 JVM Flags: 0 total; Launched Version: mcp Backend library: LWJGL version 3.2.1 build 12 Backend API: NO CONTEXT GL Caps: Using VBOs: Yes Is Modded: Definitely; Client brand changed to 'forge' Type: Client (map_client.txt) CPU: <unknown>
  17. I started modding and when i run my mod it presents this menu and i was wondering which was the right one to choose?
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.