Jump to content

jackokring

Members
  • Posts

    24
  • Joined

  • Last visited

Everything posted by jackokring

  1. Like from line 92 onward https://github.com/jackokring/ExactFeather396/blob/main/src/main/java/uk/co/kring/ef396/DataGen.java
  2. D-cache/I-cache balance ~?
  3. An excellent class I haven't managed to use yet as it all seems to be about surrounding method calls with some parameter ServerLevel/ClientLevel overloading and not so much in mod code. A free class implies boolean?
  4. An in a real sense @jackokring/ExactFeather396 has few logs and the TensorFlow java/keras looks like an interesting Goal() in the scheme of Java building.
  5. I could do it but then class per mod overheadz might exceed central class speed and size optimization goals. Is there a Forge subpackage name yet?
  6. Any chances of a "item.$x.$y_ore": "$x's $y Ore", "$x.minecraft": "Minecraft", "$y.ruby": "Ruby" Kind of thing in some DataProvider?
  7. The code doesn't even compile under 1.18.2 as "Holder" introduced so warning for later.
  8. I will do. I think it might be a static field CreativeTab in the main mod by static initializer where register is indirect through the instance of the mod. That is to say the ClassLoader thread is not the mod thread. Github @jackokring/ExactFeather396
  9. Seems I can't have a creative tab as it baulks and then complains about things not being defined to load in the Tags. I think the RegistryObject<Item> hasn't been used as it's the first item. The bootstrap process is involved. Is it a new feature?
  10. It seemed to work when I needed an Item as a temptation for a Mob `Animal`. cast `(ItemLike)` ... Ooops seems I forgot to past the actual.
  11. It seemed to work when I needed an Item as a temptation for a Mob `Animal`.
  12. /** * Gets the generation of the book (how many times it has been cloned) */ public static int getGeneration(ItemStack book) { return book.getTag().getInt("generation"); }
  13. itemP = new WrittenBookItem.Properties().group(customItemGroup); //.maxStackSize(BOOK_STACK_SIZE); WrittenBookItem bookItem = new WrittenBookItem(itemP); //the following 2 look like a read and write function pair //bookItem.readShareTag(); //bookItem.getShareTag(); //perhaps it's bool false and a place where tags are for following 2 methods ... //bookItem.shouldSyncTag(); //bookItem.getTags(); bookItem.setRegistryName(Jacko.MOD_ID, "book"); event.getRegistry().register(bookItem); That's it for today as the "source" I've found is of the P_124141413413_?? variety.
  14. data/jacko/tags/items/book.json might be a suitable location for book text? I assume one of those functions loads an NBT and checks for pages ... and https://minecraft.gamepedia.com/Data_Pack seems to have some info but I last coded mods about minecraft 1.7.
  15. Custom tab itemGroup, so all mod items appear, but all potions I just added a PotionItem() with the model having a CustomPotionEffects in the json. The four redstone blocks appear with no functionality yet (will do this later). I'm not sure where to set it's text, it's in the item model at the moment (an assumption). Do I have to sub class WrittenBookItem? Is it possible to make it readable by using a json file or does it need code to load the book content? I managed to fix 1 more error on in achievement recipes as i had a bad item name or 2.
  16. Hi So I managed to build without module errors. In test I found the potion registered custom potion (singular) shows up as a complete set of potions in the creative inventory (on the custom item group). This is unexpected. Did I use the correct parent model? Also I added a written book with text json. I seem to be unable to open it to read it. It displays as the default brown book. No open to open it, but it does destroy blocks. I changed into survival mode too but it operates more like a hammer than a readable book. https://github.com/jackokring/MinecraftMod for source.
  17. Advancements not loading? I'd think the advancements have some kind of data format error. The only thing I can think of is phrases I remember such as "each condition must have a unique name", or maybe "something which is supposed to be a list is not correct json" as maybe one item and a list of items might both be accepted, but are not the same thing implying missing [ and ] somewhere. Perhaps supply the advancements files link?
  18. OK, I got it. It will not however stop me as I am quite prepared to operate within the constraint of making my variants per resource named block occur within a unified tile entity within my mod. As my code stands at the moment I have 4 blocks all using the same class, but each loads a unique tile entity based on resource name. They will all be redstone components, and the only behaviour difference is the output calculation and hence stored data. As the texture is loaded via resource name, this allows individual textures. They have individual block state assets for example. In this sense I already have 4 tile entities fro one block class, but as the variant is based on the resource name, then the right tile entity is used for the right CalculationProvider interface in my tile entities which all extend DelayTileEntity (to prevent update feedback loops) which implements CalculationProvider but abstract so not really and it causes a forced implementation requirement in the sub-class which is itself registered under the resource name. Jacko
  19. More of a not centigrade to kelvin. 🥳 As it's both an associated scale and offset. Likely have to store that just in case it varies with the map co-ordinates.
  20. Hi, I wish to instance a tile entity from a block object (i.e. convert one into the other). This might not exactly imply the finality of this, but when I convert from centigrade to Fahrenheit, I do not alter either). I know I can't assume other people would only have one tile entity, but I can design to the principal and so not be inconsistent in my design. I could handle any situation where I'd need a multiple tile entity (as the function itself (Block.createTileEntity) does not return an array of tile entities) by making a class CompoundTileEntity<A, B> if the need arises.
  21. class Block { ... this ... //turn a block into a new relevant TileEntity ... return new TileEntity(); } So that the following becomes easy to have multiple TileEntity sub-classes without re-classing the basic Block logic, and just using ResourceLocation to change models. @Mod("jacko") public class Jacko { // Directly reference a log4j logger. private static final Logger LOGGER = LogManager.getLogger(); public Jacko() { // Register the setup method for modloading FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); // Register the enqueueIMC method for modloading FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueueIMC); // Register the processIMC method for modloading FMLJavaModLoadingContext.get().getModEventBus().addListener(this::processIMC); // Register the doClientStuff method for modloading FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff); // Register ourselves for server and other game events we are interested in MinecraftForge.EVENT_BUS.register(this); } private void setup(final FMLCommonSetupEvent event) { // some preinit code LOGGER.info("HELLO FROM PREINIT"); LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName()); } private void doClientStuff(final FMLClientSetupEvent event) { // do something that can only be done on the client LOGGER.info("Got game settings {}", event.getMinecraftSupplier().get().gameSettings); //IMC supplier and field } private void enqueueIMC(final InterModEnqueueEvent event) { // some example code to dispatch IMC to another mod InterModComms.sendTo("jacko", "hello_world", () -> { LOGGER.info("Hello world from the MDK"); return "Hello world";}); //binding element manufacture to supply } private void processIMC(final InterModProcessEvent event) { // some example code to receive and process InterModComms from other mods LOGGER.info("Got IMC {}", event.getIMCStream(). map(m -> m.getMessageSupplier().get()). collect(Collectors.toList())); //collect all supplied as a list } // You can use SubscribeEvent and let the Event Bus discover methods to call @SubscribeEvent public void onServerStarting(FMLServerStartingEvent event) { // do something when the server starts LOGGER.info("HELLO from server starting"); event.getCommandDispatcher().register( Commands.literal("foo") .requires(source -> source.hasPermissionLevel(4)) .then( Commands.argument("bar", integer()) .executes(context -> { System.out.println("Bar is " + getInteger(context, "bar")); return 1; }) ) .executes(context -> { System.out.println("Called foo with no arguments"); return 1; }) ); } public static class RangedRocker { public int count, bottomOffset, topOffset, max; public RangedRocker(int countSet, int bottomOffsetSet, int topOffsetSet, int maxSet) { count = countSet; bottomOffset = bottomOffsetSet; topOffset = topOffsetSet; max = maxSet; } } //count = iterative attempts to match random location with that to be replaced for spawn (commonality) //bottomOffset/topOffset = bottom and top offsets. 0 - 255 range squish //max = maximum cascade iterates public static RangedRocker[] ranges = { new RangedRocker(12, 5, 5, 80), new RangedRocker(18, 3, 5, 80), new RangedRocker(15, 8, 5, 50) }; public static class BiomeRocker { Biome biome; OreFeatureConfig.FillerBlockType find; Block replace; RangedRocker range; Biome.Category subFilter; int size; boolean terminal; public BiomeRocker(OreFeatureConfig.FillerBlockType findSet, Block replaceSet, RangedRocker rangeSet, int sizeSet, boolean terminalSet, Biome.Category subFilterSet, Biome biomeSet) { biome = biomeSet; find = findSet; replace = replaceSet; range = rangeSet; subFilter = subFilterSet; size = sizeSet; terminal = terminalSet; } } //Seems to be no End Stone Ore type public static OreFeatureConfig.FillerBlockType END_STONE = OreFeatureConfig.FillerBlockType.create("END_STONE","end_stone", new BlockMatcher(Blocks.END_STONE)); //filters to iterate //more generic later as only applied per biome until terminalSet = true //sizeSet is vein size public static BiomeRocker[] biomes = { new BiomeRocker(OreFeatureConfig.FillerBlockType.NETHERRACK, unlock, ranges[0], 4, true, Biome.Category.NETHER, null), new BiomeRocker(END_STONE, unlock, ranges[1], 12, true, Biome.Category.THEEND, null), new BiomeRocker(OreFeatureConfig.FillerBlockType.NATURAL_STONE, unlock, ranges[2], 6, true, null, null) }; @SubscribeEvent public static void generateOres(FMLLoadCompleteEvent event) { for (Biome biome : ForgeRegistries.BIOMES) { for(BiomeRocker br : biomes) { if(br.biome == null || biome == br.biome) { if(br.subFilter == null || biome.getCategory() == br.subFilter) { RangedRocker rr = br.range; CountRangeConfig range = new CountRangeConfig(rr.count, rr.bottomOffset, rr.topOffset, rr.max); OreFeatureConfig feature = new OreFeatureConfig(br.find, br.replace.getDefaultState(), br.size); ConfiguredPlacement config = Placement.COUNT_RANGE.configure(range); biome.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Feature.ORE. withConfiguration(feature).withPlacement(config)); if(br.terminal) break;//exit all applied per biome } } } } } // You can use EventBusSubscriber to automatically subscribe events on the contained class (this is subscribing to the MOD // Event bus for receiving Registry Events) @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD) public static class RegistryEvents { @SubscribeEvent public static void registerBlocks(RegistryEvent.Register<Block> event) { unlock = new Block(Block.Properties.create(Material.MISCELLANEOUS) //.hardnessAndResistance(3f, 3f) //emerald level .sound(SoundType.SCAFFOLDING) //.slipperiness(0.5f) ); unlock.setRegistryName("jacko", "unlock"); //see @ObjectHolder in uk.co.kring.mc.Blocks field import static event.getRegistry().register(unlock); sigma = new CalculationProviderRedstoneBlock();//needs TileEntity registering with same "name" sigma.setRegistryName("jacko", "sigma"); event.getRegistry().register(sigma); } @SubscribeEvent public static void registerItems(RegistryEvent.Register<Item> event) { final int MAXIMUM_STACK_SIZE = 64; final int POTION_STACK_SIZE = 1; final int BOOK_STACK_SIZE = 16; final ItemGroup customItemGroup = new ItemGroup("jacko_item_group") { @Override public ItemStack createIcon() { return new ItemStack(Items.EMERALD); } }; Item.Properties itemP = new BlockItem.Properties().group(customItemGroup) .maxStackSize(MAXIMUM_STACK_SIZE); BlockItem unlockItem = new BlockItem(unlock, itemP); unlockItem.setRegistryName(unlock.getRegistryName()); event.getRegistry().register(unlockItem); itemP = new BookItem.Properties().group(customItemGroup) .maxStackSize(BOOK_STACK_SIZE); Item bookItem = new Item(itemP); bookItem.setRegistryName("jacko", "book"); event.getRegistry().register(bookItem); itemP = new PotionItem.Properties().group(customItemGroup) .maxStackSize(POTION_STACK_SIZE); Item potionItem = new PotionItem(itemP); potionItem.setRegistryName(zerog.getRegistryName()); event.getRegistry().register(potionItem); itemP = new BlockItem.Properties().group(customItemGroup) .maxStackSize(MAXIMUM_STACK_SIZE); BlockItem sigmaItem = new BlockItem(sigma, itemP); sigmaItem.setRegistryName(sigma.getRegistryName()); event.getRegistry().register(sigmaItem); } @SubscribeEvent public static void registerTE(final RegistryEvent.Register<TileEntityType<?>> event) { tileEntitySigma = TileEntityType.Builder .create(SigmaTileEntity::new, sigma).build(null); //technically type is null and used in constructor before assignment (pokey pointer variant generic?) // you probably don't need a datafixer --> null should be fine tileEntitySigma.setRegistryName(sigma.getRegistryName()); event.getRegistry().register(tileEntitySigma); } @SubscribeEvent public static void registerEffects(final RegistryEvent.Register<Effect> event) { } @SubscribeEvent public static void registerPotions(final RegistryEvent.Register<Potion> event) { zerog = new Potion(); zerog.setRegistryName("jacko", "zerog"); event.getRegistry().register(zerog);//might need registering } } }
  22. Hi, Sorry for the GIGO. I wish to convert the Java "this" (which is a Block in context) into the TileEntity registered against the block with tileEntitySigma = TileEntityType.Builder .create(SigmaTileEntity::new, sigma).build(null); //technically type is null and used in constructor before assignment (pokey pointer variant generic?) // you probably don't need a datafixer --> null should be fine tileEntitySigma.setRegistryName("te_sigma"); event.getRegistry().register(tileEntitySigma); It's not essential, but it would be nicer to not have to edit the method createTileEntity in sub-classes (mainly an automation error reduction process). From this registration I assume (perhaps in error) that an association is made that will be a reference to making a new SigmaTileEntity. return ForgeRegistries.TILE_ENTITIES.getValue(this.getRegistryName()) .create(); I assume this need identical ResourceLocation strings which I could do. Cheers Jacko.
  23. @Nullable @Override public TileEntity createTileEntity(BlockState state, IBlockReader world) { //TODO: behaviour alteration ResourceLocation rl = getRegistryName(); //RegistryManager.ACTIVE.getRegistry(TileEntityType.class) -> return new SigmaTileEntity(); }
  24. I can't seem to find it. I found that handleUpdateTag has an extra parameter too. Also many block methods to do with redstone are deprecated, and instancing blockstate is a factory so not suitable for overrides. Is this "normal"? Is the intent to read via update tags and is a new mechanism for blockstate subclassing available? github: project jackokring/MinecraftMod
×
×
  • Create New...

Important Information

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