Jump to content

kiou.23

Members
  • Posts

    444
  • Joined

  • Last visited

  • Days Won

    5

Everything posted by kiou.23

  1. ohh Okay, when I typed TickEvent, intellisense didn't show the other events, only TickEvent.
  2. where is your texture located? I think the problem may be with a Resource Location in your code, instead of minecraft:textures/gttaa.items/emerald_ingott.png, shouldn't it be gttaa:items/emerald_ingott.png?
  3. The title is very explanatory, I'd like to know if I'm mistaken about the isValidSpawnBiomeForPlayer(), or if there's something wrong with the code: @Mod.EventBusSubscriber(modid = TutorialMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) public class ModBiomes { public static final DeferredRegister<Biome> BIOMES = DeferredRegister.create(ForgeRegistries.BIOMES, TutorialMod.MOD_ID); public static final RegistryObject<Biome> TEST_BIOME = BIOMES.register("test_biome", () -> Maker.TestBiome()); @SubscribeEvent public static void setupBiomes(FMLCommonSetupEvent event) { event.enqueueWork(() -> setupBiome(TEST_BIOME.get(), BiomeManager.BiomeType.WARM, 1500, Type.FOREST, Type.COLD, Type.OVERWORLD, Type.WET) ); } private static void setupBiome(Biome biome, BiomeManager.BiomeType biomeType, int weight, BiomeDictionary.Type... types) { RegistryKey<Biome> key = RegistryKey.getOrCreateKey( ForgeRegistries.Keys.BIOMES, Objects.requireNonNull(ForgeRegistries.BIOMES.getKey(biome), "Biome registry name was null")); BiomeDictionary.addTypes(key, types); BiomeManager.addBiome(biomeType, new BiomeManager.BiomeEntry(key, weight)); } private static class Maker { private static MobSpawnInfo.Builder getStandardMobSpawnBuilder() { MobSpawnInfo.Builder mobspawninfo$builder = new MobSpawnInfo.Builder(); DefaultBiomeFeatures.withPassiveMobs(mobspawninfo$builder); DefaultBiomeFeatures.withBatsAndHostiles(mobspawninfo$builder); return mobspawninfo$builder; } private static Biome TestBiome() { BiomeGenerationSettings genset = new BiomeGenerationSettings.Builder() .withCarver(GenerationStage.Carving.AIR, ConfiguredCarvers.field_243767_a) .withCarver(GenerationStage.Carving.AIR, ConfiguredCarvers.field_243768_b) .withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Features.FANCY_OAK) .withFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Features.ORE_COAL) .withFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Features.ORE_GOLD) .withFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Features.ORE_IRON) .withFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Features.ORE_DIAMOND) .withStructure(StructureFeatures.END_CITY) .withSurfaceBuilder(ConfiguredSurfaceBuilders.field_244178_j) .build(); MobSpawnInfo mobSpawn = getStandardMobSpawnBuilder().copy(); BiomeAmbience ambience = new BiomeAmbience.Builder() .withGrassColor(0xDA67C1) .setFogColor(0xEEEEEE) .setWaterColor(0xCF21B8) .setWaterFogColor(0xCF78C5) .withSkyColor(0xE83452) .withFoliageColor(0xCA57C1) .build(); return new Biome.Builder() .category(Biome.Category.FOREST) .withTemperatureModifier(Biome.TemperatureModifier.NONE) .withGenerationSettings(genset) .withMobSpawnSettings(mobSpawn) .depth(0.123f) .scale(0.4f) .downfall(.4f) .precipitation(Biome.RainType.SNOW) .temperature(.8f) .setEffects(ambience) .build(); } } }
  4. I have some values attached to chunks through capabilities, and I would like to update this values on every tick (if there is a more commom, stantard, efficient way of doing this I'd like to know). I've tried subscribing to the TickEvent, but the event doesn't have a reference to the world, I could use Minecraft.getInstance().world, but I heard that that can break the server. So how should go about implementing this
  5. why is the model bakery trying to load a .png instead of a .json, and why is the file you're looking with the extesnsion .png.json?? and also, is the item/file/whatever that you want really called emerald_ingott? with two t's? could it be a mispelling?
  6. Code Style 5 Don't create an ItemBase class, when registering call new Item, and pass the properties to the constructor. If you want to save a few keystrokes you can write a utility method that simply return the default ItemProperties that you want. Additionally, you should be using Data Generators to generate the ItemModel files, if you want to know more about them, this comment has a few useful links that explain how to use them: https://forums.minecraftforge.net/topic/94402-generated/?tab=comments#comment-432933
  7. You need to set the default state in the constructor, the Block class has the setDefaultState method that you should use @Nullable @Override public BlockState getStateForPlacement(BlockItemUseContext context) { return this.getDefaultState().with(CONTENT, 0).getBlockState(); } Also, calling getBlockState is irrelevant, getDefaultState().with() already return a blockState Also Also, if the State for Placement for the Property CONTENT is always 0, you don't need to set it in the getStateForPlacement method, you can just set it in the constructor like I said before
  8. you can use the collect() method from the stream, and then pass the desired collection type conversion, in this case Collectors.toList()
  9. if I'm not mistaken, you can override hasContainerItem and getContainerTtem. Container items are items that are returned whenever you use them in crafting, like when you craft a cake, the bucket of milk returns a bucket. then in getContainer item you can damage the itemStack and return it (This is a guess, I'm also new to modding)
  10. I totally forgot to look at the link, and yeah, what I needed was there. just for reference here is my code, I'd appreciate if you could check if everything is already, or if there is something I could do to better the code (like for instance, do I need to add every ore manually?) @Mod.EventBusSubscriber(modid = TutorialMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) public class ModBiomes { public static final DeferredRegister<Biome> BIOMES = DeferredRegister.create(ForgeRegistries.BIOMES, TutorialMod.MOD_ID); public static final RegistryObject<Biome> TEST_BIOME = BIOMES.register("test_biome", () -> new Biome.Builder() .category(Biome.Category.FOREST) .withTemperatureModifier(Biome.TemperatureModifier.NONE) .withGenerationSettings(new BiomeGenerationSettings.Builder() .withCarver(GenerationStage.Carving.AIR, ConfiguredCarvers.field_243767_a) .withCarver(GenerationStage.Carving.AIR, ConfiguredCarvers.field_243768_b) .withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Features.FANCY_OAK) .withFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Features.ORE_COAL) .withFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Features.ORE_GOLD) .withFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Features.ORE_IRON) .withFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Features.ORE_DIAMOND) .withStructure(StructureFeatures.RUINED_PORTAL) .withSurfaceBuilder(ConfiguredSurfaceBuilders.field_244178_j) .build() ) .withMobSpawnSettings(new MobSpawnInfo.Builder() .withSpawner(EntityClassification.CREATURE, new MobSpawnInfo.Spawners(EntityType.PIG, 15, 2, 7)) .withSpawner(EntityClassification.CREATURE, new MobSpawnInfo.Spawners(EntityType.COW, 25, 3, 8)) .copy() ) .scale(0.4f) .downfall(.4f) .precipitation(Biome.RainType.SNOW) .temperature(.8f) .depth(0.123f) .setEffects(new BiomeAmbience.Builder() .withGrassColor(0xDA67C1) .setFogColor(0xEEEEEE) .setWaterColor(0xCF21B8) .setWaterFogColor(0xCF78C5) .withSkyColor(0xE83452) .withFoliageColor(0xCA57C1) .build() ) .build() ); @SubscribeEvent public static void setupBiomes(FMLCommonSetupEvent event) { event.enqueueWork(() -> setupBiome(TEST_BIOME.get(), BiomeManager.BiomeType.WARM, 1500, Type.FOREST, Type.COLD, Type.OVERWORLD, Type.WET) ); } private static void setupBiome(Biome biome, BiomeManager.BiomeType biomeType, int weight, BiomeDictionary.Type... types) { RegistryKey<Biome> key = RegistryKey.getOrCreateKey( ForgeRegistries.Keys.BIOMES, Objects.requireNonNull(ForgeRegistries.BIOMES.getKey(biome), "Biome registry name was null")); BiomeDictionary.addTypes(key, types); BiomeManager.addBiome(biomeType, new BiomeManager.BiomeEntry(key, weight)); } }
  11. Something like this? @Mod.EventBusSubscriber(modid = TutorialMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) public class ModBiomes { public static final DeferredRegister<Biome> BIOMES = DeferredRegister.create(ForgeRegistries.BIOMES, TutorialMod.MOD_ID); public static final RegistryObject<Biome> TEST_BIOME = BIOMES.register("test_biome", () -> new Biome.Builder() .category(Biome.Category.FOREST) .withTemperatureModifier(Biome.TemperatureModifier.NONE) .withGenerationSettings(BiomeGenerationSettings.DEFAULT_SETTINGS) .withGenerationSettings(new BiomeGenerationSettings.Builder() .withCarver(GenerationStage.Carving.AIR, ConfiguredCarvers.field_243767_a) .withCarver(GenerationStage.Carving.AIR, ConfiguredCarvers.field_243768_b) .withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Features.FANCY_OAK) .withStructure(StructureFeatures.RUINED_PORTAL) .withSurfaceBuilder(ConfiguredSurfaceBuilders.field_244178_j) .build() ) .withMobSpawnSettings(new MobSpawnInfo.Builder() .withSpawner(EntityClassification.CREATURE, new MobSpawnInfo.Spawners(EntityType.PIG, 15, 2, 7)) .withSpawner(EntityClassification.CREATURE, new MobSpawnInfo.Spawners(EntityType.COW, 25, 3, 8)) .copy() ) .scale(0.8f) .downfall(.4f) .precipitation(Biome.RainType.SNOW) .temperature(.8f) .depth(0.135f) .setEffects(new BiomeAmbience.Builder() .setWaterColor(0xCF21B8) .withGrassColor(0xDA67C1) .build() ) .build() ); @SubscribeEvent public void registerBiomes(FMLCommonSetupEvent event) { BiomeManager.addBiome(); } } And what do I pass to the Biome Manager? how do I get Biome Type and a Biome Entry? And do I need to add it to the BiomeDictionary along with the Types?
  12. kiou.23

    Generated

    I suppose you're talking about the generated folder that's located on the src for your mod. it is like the resources folder, it holds json files for your block and item models, loot tables, recipes and so on. The thing is, that instead of writing the json by hand, you can use a DataProvider, then you can run the Gradle task runData to automatically generate the json files for you. if you wanna know more about how to use Data Generators: the forgedocs has a page about it: https://mcforge.readthedocs.io/en/1.16.x/datagen/intro/ this youtube video by SilentChaos512 is a very good introduction also: https://www.youtube.com/watch?v=YD_ajlZ5TdY and this repository really has alot of really useful examples: https://collaborating.tuhh.de/cev7691/minecraftforge/blob/ebd463e92f86d78fdc3ab1192360fd74850afeba/src/test/java/net/minecraftforge/debug/DataGeneratorTest.java hope I helped!
  13. I took a look at the source for Traverse, but it looked like a hacky way of doing it. I'm gonna look how it was done before, and how other mods do it then thanks
  14. So I know biomes now are registered through json files, but I've found very little information on how to actually implement them. I also know that there is a data generator for biomes, but I also didn't find any resources on it. I'd appreciate if anyone could give me the steps to implementing biomes, or simply point me to a 1.16.3 repo that adds biomes
  15. OHH that is what I was missing, thanks! just a final question tho, why do I need an interface? if it's only going to be implemented once, why can't I just reference the class (in this case, ChunkValue)?
  16. yeah, I did that, but I'm getting a bunch of NullPointerExceptions at this line: @Override public INBT serializeNBT() { return TutorialMod.CHUNK_VALUE_CAPABILITY.writeNBT(getCachedChunkValue(), null); } I'm guessing that it's because I'm defining TutorialMod.CHUNK_VALUE_CAPABILITY as null, but I don't know what to do then @CapabilityInject(IChunkValue.class) public static final Capability<IChunkValue> CHUNK_VALUE_CAPABILITY = null; should I initialise it as something else?
  17. Okay, like this? public interface IChunkValue { int getValue(); void setValue(int value); } public class ChunkValue implements IChunkValue { private int value; public ChunkValue(int value) { this.value = value; } @Override public int getValue() { return value; } @Override public void setValue(int value) { this.value = value; } } public class ChunkValueStorage implements Capability.IStorage<IChunkValue> { @Override public INBT writeNBT(Capability<IChunkValue> capability, IChunkValue instance, Direction side) { CompoundNBT nbt = new CompoundNBT(); nbt.putInt("value", instance.getValue()); return nbt; } @Override public void readNBT(Capability<IChunkValue> capability, IChunkValue instance, Direction side, INBT nbt) { instance.setValue(((CompoundNBT)nbt).getInt("value")); } public class Factory implements Callable<IChunkValue> { @Override public IChunkValue call() throws Exception { return new ChunkValue(0); } } } Now what?... I don't really get where to go after this
  18. Say I simply want to hold a single random Integer in each chunk, I know I can attach Capabilities to Chunks through the AttachcapabilitiesEvent, but then I would need to create my own class that extends Capability<Integer>? Would I need to serialize the data to nbt for it to be saved? any tips on how I should go about doing this?
  19. in your Item class override the OnItemRightClick method, check if the world isn't remote, and then you can call NetworkHooks.openGUI you're also going to need a ContainerProvider and a ContainerScreen for that. I recommend you take a look at this tutorial done by TheGreyGhost: https://github.com/TheGreyGhost/MinecraftByExample/tree/master/src/main/java/minecraftbyexample/mbe32_inventory_item
  20. public class BackpackItem extends Item { public BackpackItem(Properties properties) { super(properties); } @Override public ActionResultType onItemUse(ItemUseContext context) { if (!context.getWorld().isRemote) { } return ActionResultType.SUCCESS; } @Override public ICapabilityProvider initCapabilities(ItemStack stack, CompoundNBT nbt) { return new BackpackCapability(this.getClass()); } } public class BackpackCapability extends CapabilityProvider implements ICapabilitySerializable<CompoundNBT> { public BackpackCapability(Class baseClass) { super(baseClass); } private static final String INVENTORY_TAG = "inventory"; ItemStackHandler inventory = new ItemStackHandler(27) { @Override public boolean isItemValid(int slot, ItemStack stack) { return !(stack.getItem() instanceof BackpackItem); } }; @Override public LazyOptional<ItemStackHandler> getCapability(Capability cap, Direction side) { if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) return LazyOptional.of(() -> this.inventory); return super.getCapability(cap, side); } @Override public CompoundNBT serializeNBT() { CompoundNBT nbt = new CompoundNBT(); nbt.put(INVENTORY_TAG, this.inventory.serializeNBT()); return nbt; } @Override public void deserializeNBT(CompoundNBT nbt) { this.inventory.deserializeNBT(nbt); } }
  21. Yes, I am aware of this. It was when I realized this that I searched and found about Capabilities So I need to create my own class that implements ICapabilitySerializable? and then I can have the ItemStackHandler stored in it? EDIT: and then what? I do still need a Container and a ContainerScreen correct? how do I open the screen and pass the contents of the Capability to it? do I need to implement INamedContainerProvider on the capability class? I'll share my code below
  22. In my current endeavours to learn Forge Modding, I decided to code a simple backpack Item. nothing to special, just an item, that would act like a chest, and whenever used would open it's interface. I had already done some test with Tile Entities and Containers, and I thought I could use a Container to do the job, and implement IContainerProvider in the Item. I had an ItemStackHandler in the BackpackItem class to hold the inventory but I ran into some problems when trying to store it in nbt, as in the Tile Entities they have their own methods I could override to deal with writing and reading nbt. So after some research I came accros Capabilities, I've been trying to understand them for some time now, but I cannot find any examples on how to use the IItemHandler to accomplish my goal. I'd appreciate if someone could tell me how I should go about using capabilities to implement this simples backpack Item. Or just point me to a git repo that does something similiar. EDIT: I have read the forge docs, they haven't helped much EDIT 2: I read TheGreyGhost github repo on making an item that has an inventory and managed to accomplish it the repo is: https://github.com/TheGreyGhost/MinecraftByExample/tree/master/src/main/java/minecraftbyexample/mbe32_inventory_item
  23. Got it, so just to confirm, like this right? @Mod.EventBusSubscriber(modid = TutorialMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) public class ModFeatures { public static ConfiguredFeature<?, ?> ORE_SILVER_CONFIG; @SubscribeEvent public void setup(FMLCommonSetupEvent event) { ORE_SILVER_CONFIG = register("ore_silver", Feature.ORE.withConfiguration( new OreFeatureConfig( OreFeatureConfig.FillerBlockType.BASE_STONE_OVERWORLD, ModBlocks.SILVER_ORE.get().getDefaultState(), 9 ) ).range(64).square().func_242731_b(20)); } private <FC extends IFeatureConfig> ConfiguredFeature<FC, ?> register(String key, ConfiguredFeature<FC, ?> configuredFeature) { return Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, key, configuredFeature); } } What happens if I don't register it tho? because it was generating just fine
  24. So like so? public class ModFeatures { public static ConfiguredFeature<?, ?> ORE_SILVER_CONFIG; @SubscribeEvent public void setup(FMLCommonSetupEvent event) { ORE_SILVER_CONFIG = Feature.ORE.withConfiguration( new OreFeatureConfig( OreFeatureConfig.FillerBlockType.BASE_STONE_OVERWORLD, ModBlocks.SILVER_ORE.get().getDefaultState(), 9 ) ).range(64).square().func_242731_b(20); } } and then adding it to the biomes in the main Class like I was doing before
×
×
  • Create New...

Important Information

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