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

Drachenbauer

Members
  • Posts

    724
  • Joined

  • Last visited

Everything posted by Drachenbauer

  1. I know about the for-loop, but i just don´t know, if there is aný way to use it to generate the names of the registry-objects for the deferred register..
  2. Is there no way to reduce this code while still using deferred register? actually i have about 400 RegistryObject-fields in this class, to have all combinations of plants and potcolors. I just heared, that for-loops are often used to shorten code without changing what it should do.
  3. Now i have a huge stack of RegistryObjects in my blocks class. Every possible combination of plant-type (25 different plants) and pot-color (16 color) appears as it´s own registered block. The same for the method-calls for adding the plants to the pots and render them in cutout-style (the render-thing is not needed for the cactus) in their handler-classes. Is there any way to shorten the code, maybe with this for-loop: ArrayList<String> colors = new ArrayList<String>(Arrays.asList(black, blue, brown, cyan, gray, green, light_blue, light_gray, lime, magenta, orange, pink, purple, red, white, yellow)); for (String color : colors) { //do stuff } But i don´t know how to create RegistryObjects in a for-loop...
  4. While i collected the different plants, that can be placed in a flowerpot, i saw, that the model of the cactus is made a very complicated way. I think, to make it look like it looks ingame, just two model-boxes are needed: a 6x6x6 cube for the pot and a taller 4x4 base box for the cactus itself, And a dirt-texture is not needed here, because the cactus fills the whoole hole of the pot. Why did they make it so complicated? Now i made separeted handler-classes for the addPlant-lines and the cutout-rendering of the plant-textures. So the main-mod-class is short and clean. In the handler-classes i simply placed all theese method-calls in a method, that i now call in the main-class.
  5. Now, with some more google, i found it. at first, i had the simpler constructor-call, so i wonder, why it used the correct variant of the potted sapling in this case. In my case, i think, it should look like this: BLACK_FLOWER_POT.get().addPlant(Blocks.ACACIA_SAPLING.getRegistryName(), BLACK_POTTED_ACACIA_SAPLING_SUPPLIER); but where in my mod should i place this line. Edit: Now i made it so: DeferredWorkQueue.runLater(() -> { ColoredFlowerPotsBlocks.BLACK_FLOWER_POT.get().addPlant(Blocks.ACACIA_SAPLING.getRegistryName(), ColoredFlowerPotsBlocks.BLACK_POTTED_ACACIA_SAPLING_SUPPLIER); } ); In the common setup like the biome-stuff in the tulips-mod. This works. Other things i tryed before, made "object not present" errors. Now i think, i should collect all theese calls for the different plants and pot-colors here.
  6. Hello I decided to play around with colors for flowerpots. So i opened a new mod-project and added two new mlocks: black_flower_pot (an empty flowerpot with black concrete-texture and it´s BlockItem) black_potted_acacia_sapling (an acatia-sapling, placed in a black flowerpot) Than i made a testrun and i was surprised: If i place my modded black pot and then put the acacia-sapling, it correctly appears in the black pot. that means it uses my modded one here. How does the FlowerPotBlock-class know, that it has to place my modded acacia in the black pot here instead of the the vanilla one in the brown terracotta-pot? I want to add more flowerpot colors (to compleete the 16 minecraft colors). Does it still choose the plants in the matching colored pots then?
  7. This is now my custom bonemeal class: How can i make the vanilla BoneMealItem-class use my custom methods and the custom added part of the applyBonemeal-method here after it´s normal rightclick-behavior?
  8. I already used that backtracing and found, what you say, but i cannot find, where DECORATED_FLOWER get´s the flowers from, and i found nothing there, where code in my own classes can access. so i now create my own bonemeal, that manually adds my tulips, if the clicked grass-block is in one of the three vanilla-biomes with tulips. I make it the way, how my bick blocks in the other mod add their invisible part-blocks to the world, if placed. At first i let it find random positions in a 9x9 square around the clicked grass-blocks and find te surface of the ground there and then it should place random tulips there, if a grassblock is below and the position, itself has just air or a plant (but not a tree or a tulip). It just needs a little bugfix and i think, i find the solution. Edit: I fixed it. My custom bonemeal now makes alot of colorful tulips grow. now i think, i can pack my mod. But i have one last question: How can i make the vanilla bonemeal use this behavior?
  9. Hello I have registered a Tileentity: public static final DeferredRegister<TileEntityType<?>> TILE_ENTITY_TYPES = new DeferredRegister<>(ForgeRegistries.TILE_ENTITIES, Reference.MOD_ID); public static final RegistryObject<TileEntityType<BlockColorsTileEntity>> BLOCK_COLORS = TILE_ENTITY_TYPES.register("block_colors", () -> TileEntityType.Builder.create(BlockColorsTileEntity::new, AngryBirdsBlocks.SLINGSHOT_BIRCH.get(), AngryBirdsBlocks.SLINGSHOT_BIRCH_2.get(), AngryBirdsBlocks.SLINGSHOT_BIRCH.get(), AngryBirdsBlocks.SLINGSHOT_BIRCH_2.get(), AngryBirdsBlocks.SLINGSHOT_DARK_OAK.get(), AngryBirdsBlocks.SLINGSHOT_DARK_OAK_2.get(), AngryBirdsBlocks.SLINGSHOT_JUNGLE.get(), AngryBirdsBlocks.SLINGSHOT_JUNGLE_2.get(), AngryBirdsBlocks.SLINGSHOT_OAK.get(), AngryBirdsBlocks.SLINGSHOT_OAK_2.get(), AngryBirdsBlocks.SLINGSHOT_SPRUCE.get(), AngryBirdsBlocks.SLINGSHOT_SPRUCE_2.get()).build(null)); Here is the class ot the TileEntity: package drachenbauer32.angrybirdsmod.entities.tile_entities; import drachenbauer32.angrybirdsmod.init.AngryBirdsTileEntities; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntity; public class BlockColorsTileEntity extends TileEntity { public BlockColorsTileEntity() { super(AngryBirdsTileEntities.BLOCK_COLORS.get()); } @Override public void read(CompoundNBT compound) { super.read(compound); } @Override public CompoundNBT write(CompoundNBT compound) { return super.write(compound); } } I also registered Blockcolors and ItemColors: @SubscribeEvent public static void registerBlockColors(final ColorHandlerEvent.Block event) { event.getBlockColors().register(blockColor, AngryBirdsBlocks.SLINGSHOT_BIRCH.get(), AngryBirdsBlocks.SLINGSHOT_BIRCH_2.get(), AngryBirdsBlocks.SLINGSHOT_BIRCH.get(), AngryBirdsBlocks.SLINGSHOT_BIRCH_2.get(), AngryBirdsBlocks.SLINGSHOT_DARK_OAK.get(), AngryBirdsBlocks.SLINGSHOT_DARK_OAK_2.get(), AngryBirdsBlocks.SLINGSHOT_JUNGLE.get(), AngryBirdsBlocks.SLINGSHOT_JUNGLE_2.get(), AngryBirdsBlocks.SLINGSHOT_OAK.get(), AngryBirdsBlocks.SLINGSHOT_OAK_2.get(), AngryBirdsBlocks.SLINGSHOT_SPRUCE.get(), AngryBirdsBlocks.SLINGSHOT_SPRUCE_2.get()); } @SubscribeEvent public static void registerItemColors(final ColorHandlerEvent.Item event) { event.getItemColors().register(itemColor, AngryBirdsItems.SLINGSHOT_BIRCH.get(), AngryBirdsItems.SLINGSHOT_BIRCH_2.get(), AngryBirdsItems.SLINGSHOT_BIRCH.get(), AngryBirdsItems.SLINGSHOT_BIRCH_2.get(), AngryBirdsItems.SLINGSHOT_DARK_OAK.get(), AngryBirdsItems.SLINGSHOT_DARK_OAK_2.get(), AngryBirdsItems.SLINGSHOT_JUNGLE.get(), AngryBirdsItems.SLINGSHOT_JUNGLE_2.get(), AngryBirdsItems.SLINGSHOT_OAK.get(), AngryBirdsItems.SLINGSHOT_OAK_2.get(), AngryBirdsItems.SLINGSHOT_SPRUCE.get(), AngryBirdsItems.SLINGSHOT_SPRUCE_2.get()); } And in the SlingshotBlock-class, connected the TileEntity: @Override public boolean hasTileEntity(BlockState state) { return true; } @Override public TileEntity createTileEntity(BlockState state, IBlockReader world) { return new BlockColorsTileEntity(); } How do i now store color-values in the TileEntity and how do i apply them to the textures of the Block and it´s BlockItem? The Item uses a 3d block-model and and not a simple flat item-model. How do i apply the color just to a part of the model (i use separate textures)
  10. I still don´t know, why it does not find the file... I tested to put a copy of the file into the folder, it tells about in the message, but i still get that message and the mod still does not load into the test-client. I also cannot find any mistakes in the file itself. It looks very similar to the ones of my other mods..
  11. I noticed, often, after a while using the same thread, i got no more answers there
  12. I found out the following: The GrassBlock tells, wich flowers can spawn. This is controlled bi the flowers-list in the Biome-class. Only instances of the DecoratedFlowerFeature are added to this list and the list is protected, that i cannot add stuff from somewhere else. Tulips are provided by the BlockClusterFeatureConfig PLAINS_FLOWER_CONFIG and the BlockClusterFeatureConfig FOREST_FLOWER_CONFIG. wich get their flowers via PlainFlowerBlockStateProvider and ForestFlowerBlockStateProvider, wich hold BlockState-lists with the tulips and other flowers. DecoratedFlowerFeature cannot use blockstates. How does DecoratedFlowerFeature get infos about the flowers?
  13. Hello I noticed, that the PlainFlowerBlockStateProvider and the ForestFlowerBlockStateProvider add the vanilla-tulips to the biomes and make the bonemeal able to spawn them. I don´t know, how to add my tulips to the BlockState-lists in theese BlockStateProviders. So maybe I can create my own BlockStateProvider. Does anyone know, how i can add my tulips to the BlockState-lists of existing BlockStateProviders, or register a custom BlockStateProvider for them?
  14. Is there any way to regiser a BlockStateProvider with DeferredRegister?
  15. As i now tested my mod, i saw this effect: The square-part of this block uses the official minecraft white concrete texture. Why it appears with this weird gradient effect? The block-class: and the properties in the registry-line: AngryBirdsBlocks.slingshot_birch_2 = new SlingshotBlock(Block.Properties.create( Material.WOOD, MaterialColor.ADOBE).notSolid().sound(SoundType.WOOD).lightValue(0). hardnessAndResistance(2.0f, 3.0f).variableOpacity()).setRegistryName("slingshot_birch_2"), Can anyone find out, why it get´s this effect?
  16. My much slimmer code, that i posted above, can do that too. Ad cadiboo´s version: is there something about using spawneggs in a redstone-dispenser? I just wonder, about this part: public static void initUnaddedEggs() { final Map<EntityType<?>, SpawnEggItem> EGGS = ObfuscationReflectionHelper.getPrivateValue(SpawnEggItem.class, null, "field_195987_b"); DefaultDispenseItemBehavior defaultDispenseItemBehavior = new DefaultDispenseItemBehavior() { public ItemStack dispenseStack(IBlockSource source, ItemStack stack) { Direction direction = source.getBlockState().get(DispenserBlock.FACING); EntityType<?> entitytype = ((SpawnEggItem) stack.getItem()).getType(stack.getTag()); entitytype.spawn(source.getWorld(), stack, null, source.getBlockPos().offset(direction), SpawnReason.DISPENSER, direction != Direction.UP, false); stack.shrink(1); return stack; } }; for (final SpawnEggItem egg : UNADDED_EGGS) { EGGS.put(egg.getType(null), egg); DispenserBlock.registerDispenseBehavior(egg, defaultDispenseItemBehavior); // ItemColors for each spawn egg don't need to be registered because this method is called before ItemColors is created } UNADDED_EGGS.clear(); } I tested to put my egg into the dispenser, but only the egg came out. But this happens with all my mod-ones, also the ones, that still are registered the old way, too... Edit: Now i got the new one to work in a dispenser. Now i know, this method makes it able to spawn the entity out of the disbenser. And for the two constructors: When do you get an Entity type in a NonNullSupplier? With DeferredRegister, you put them always into a RegistryObject. And instead of using this thing called "Lazy", you also can put them into separate fields and use a boolean to choose one in the getType method. The boolean is set to true in one constructor and false in the other. Another question: Why do the creators of minecraft never change the order of register entity and item? Edit: Now i modifyed the constructors a bit: I removed the EntityType parameters from the constructor-headers and pass directly "null" to the superconstructor. So i could remove the "null" from my registry lines for the eggs.
  17. i´m not sure, what the additional code in yous does... What more than placing eitities by hand in creative should it do?
  18. I saw, that someone talked about this git, but i saw no links to it.
  19. If you still have problems with your SparnEgg, try this: public class SupplierSpawnEggItem extends SpawnEggItem { private RegistryObject<?> supplier; public SupplierSpawnEggItem(EntityType<?> typeIn, RegistryObject<?> supplierIn, int primaryColorIn, int secondaryColorIn, Properties builder) { super(typeIn, primaryColorIn, secondaryColorIn, builder); supplier = supplierIn; } @Override public EntityType<?> getType(CompoundNBT p_208076_1_) { return (EntityType<?>) supplier.get(); } } This custom SpawnEgg-class works fine for me. Textures and colors work too.
  20. public class SupplierSpawnEggItem extends SpawnEggItem { private RegistryObject<?> supplier; public SupplierSpawnEggItem(EntityType<?> typeIn, RegistryObject<?> supplierIn, int primaryColorIn, int secondaryColorIn, Properties builder) { super(typeIn, primaryColorIn, secondaryColorIn, builder); supplier = supplierIn; } @Override public EntityType<?> getType(CompoundNBT p_208076_1_) { return (EntityType<?>) supplier.get(); } } This works now. In my inventory i have a normal looking spawn-egg, and i can plce the entity in the world with it.
  21. Now i have this: package drachenbauer32.angrybirdsmod.items; import drachenbauer32.angrybirdsmod.entities.RedEntity; import net.minecraft.entity.EntityType; import net.minecraft.item.SpawnEggItem; import net.minecraft.nbt.CompoundNBT; import net.minecraftforge.fml.RegistryObject; public class SupplierSpawnEggItem extends SpawnEggItem { private RegistryObject<EntityType<?>> supplier; public SupplierSpawnEggItem(EntityType<?> typeIn, RegistryObject<EntityType<?>> supplierIn, int primaryColorIn, int secondaryColorIn, Properties builder) { super(typeIn, primaryColorIn, secondaryColorIn, builder); supplier = supplierIn; } @Override public EntityType<?> getType(CompoundNBT p_208076_1_) { return supplier.get(); } } But i still don´t know how to change the RegistryObject-thing in the constructor to be able to pass RegistryObjets like public static final RegistryObject<EntityType<RedEntity>> RED = ENTITY_TYPES.register("red", () -> EntityType.Builder.create(RedEntity::new, EntityClassification.AMBIENT).size(0.5F, 0.5F).build(null)); or public static final RegistryObject<EntityType<ChuckEntity>> RED = ENTITY_TYPES.register("chuck", () -> EntityType.Builder.create(ChuckEntity::new, EntityClassification.AMBIENT).size(0.5F, 0.5F).build(null)); Wich have a specific entity-class in the inner "<>" instead of a "?" ? They all have different Entity-classes there, and i need a solution, that allows them all to pass into this constructor.
  22. Iow i found out, that ForestFlowerBlockStateProvider and PlainFlowerBlockStateProvider use blockstate-lists, wich include the vanilla-tulips. Is there any way to pass my own list: private static final BlockState[] TULIPS_BLOCKSTATES = new BlockState[] { Blocks.RED_TULIP.getDefaultState(), Blocks.ORANGE_TULIP.getDefaultState(), Blocks.WHITE_TULIP.getDefaultState(), Blocks.PINK_TULIP.getDefaultState(), MoreTulipsBlocks.BLACK_TULIP.get().getDefaultState(), MoreTulipsBlocks.BLUE_TULIP.get().getDefaultState(), MoreTulipsBlocks.BROWN_TULIP.get().getDefaultState(), MoreTulipsBlocks.CYAN_TULIP.get().getDefaultState(), MoreTulipsBlocks.GRAY_TULIP.get().getDefaultState(), MoreTulipsBlocks.GREEN_TULIP.get().getDefaultState(), MoreTulipsBlocks.LIGHT_BLUE_TULIP.get().getDefaultState(), MoreTulipsBlocks.LIGHT_GRAY_TULIP.get().getDefaultState(), MoreTulipsBlocks.LIME_TULIP.get().getDefaultState(), MoreTulipsBlocks.MAGENTA_TULIP.get().getDefaultState(), MoreTulipsBlocks.PURPLE_TULIP.get().getDefaultState(), MoreTulipsBlocks.YELLOW_TULIP.get().getDefaultState(), }; into theese providers or should i register my own BlockStateProvider
  23. Hello Since someone told me, thar DeferredRegister is the best way to register mod-stuff, i want to register all my stuff tkis way. Now i have a problem with SpawnEggs for Entities. I registered an entity this way: public static final RegistryObject<EntityType<RedEntity>> RED = ENTITY_TYPES.register("red", () -> EntityType.Builder.create(RedEntity::new, EntityClassification.AMBIENT).size(0.5F, 0.5F).build(null)); Someone sayd, to register the SpawnEgg also this way, a custom spawnegg-class, that accepts a supplyer, is needed. I now tried it this way: package drachenbauer32.angrybirdsmod.items; import net.minecraft.entity.EntityType; import net.minecraft.item.SpawnEggItem; import net.minecraftforge.fml.RegistryObject; public class SupplierSpawnEggItem extends SpawnEggItem { public SupplierSpawnEggItem(RegistryObject<EntityType<?>> supplierIn, int primaryColorIn, int secondaryColorIn, Properties builder) { super(supplierIn.get(), primaryColorIn, secondaryColorIn, builder); } } But now i get a n error about the constructor, that says: I cannot remove the name of the Entity-class here: RegistryObject<EntityType<RedEntity>> in the entity registerer, because this will cause some more errors, if i put a "?" instead. How must i change the constructor, that it accepts theese suppliers, no matter, wich entity-class they contain?
×
×
  • Create New...

Important Information

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