Jump to content

Drachenbauer

Members
  • Posts

    727
  • Joined

  • Last visited

Everything posted by Drachenbauer

  1. My bottom part extends this, because i also try to make different colord possible: package drachenbauer32.angrybirdsmod.blocks; import javax.annotation.Nullable; import drachenbauer32.angrybirdsmod.entities.tile_entity.TileEntityBlockColors; import net.minecraft.block.BlockState; import net.minecraft.block.ContainerBlock; import net.minecraft.entity.LivingEntity; import net.minecraft.item.DyeColor; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; public class AbstractColorBlock extends ContainerBlock { private final DyeColor color; protected AbstractColorBlock(DyeColor p_i48453_1_ , Properties builder) { super(builder); color = p_i48453_1_; } @Override public TileEntity createNewTileEntity(IBlockReader worldIn) { return null; //return new TileEntityBlockColors(); } public void onBlockPlacedBy(World worldIn, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityBlockColors) { ((TileEntityBlockColors)tileentity).loadFromItemStack(stack, this.color); } } public DyeColor getColor() { return this.color; } } And this is the bottom-class itself: package drachenbauer32.angrybirdsmod.blocks; import java.util.Map; import com.google.common.collect.Maps; import drachenbauer32.angrybirdsmod.init.AngryBirdsBlocks; import drachenbauer32.angrybirdsmod.util.Reference; import net.minecraft.block.Block; import net.minecraft.block.HorizontalBlock; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.BlockItemUseContext; import net.minecraft.item.DyeColor; import net.minecraft.item.ItemStack; import net.minecraft.state.DirectionProperty; import net.minecraft.state.StateContainer; import net.minecraft.util.Direction; import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; public class BalloonBlock extends AbstractColorBlock { protected static final VoxelShape BALLOON_BLOCK_AABB = Block.makeCuboidShape(5.0D, 0.0D, 5.0D, 11.0D, 16.0D, 11.0D); public static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING; private static final Map<DyeColor, Block> BALLOONS_BY_COLOR = Maps.newHashMap(); public BalloonBlock(String name, DyeColor p_i48448_1_, Block.Properties builder) { super(p_i48448_1_, builder); setRegistryName(Reference.MOD_ID, name); this.setDefaultState(this.stateContainer.getBaseState().with(FACING, Direction.NORTH)); BALLOONS_BY_COLOR.put(p_i48448_1_, this); } @Override public boolean isSolid(BlockState state) { return false; } @Override public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { return BALLOON_BLOCK_AABB; } @Override public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { return BALLOON_BLOCK_AABB; } @Override public VoxelShape getRenderShape(BlockState state, IBlockReader worldIn, BlockPos pos) { return BALLOON_BLOCK_AABB; } @Override protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) { builder.add(FACING); } @Override public BlockState getStateForPlacement(BlockItemUseContext context) { return this.getDefaultState().with(FACING, context.getPlacementHorizontalFacing().getOpposite()); } @Override public BlockState rotate(BlockState state, Rotation rot) { return state.with(FACING, rot.rotate(state.get(FACING))); } @Override public void onBlockPlacedBy(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) { worldIn.setBlockState(pos.up(), AngryBirdsBlocks.balloon_block_top.getDefaultState()); super.onBlockPlacedBy(worldIn, pos, state, placer, stack); } @Override public void onBlockHarvested(World worldIn, BlockPos pos, BlockState state, PlayerEntity player) { worldIn.setBlockState(pos.up(), Blocks.AIR.getDefaultState()); super.onBlockHarvested(worldIn, pos, state, player); } public static Block forColor(DyeColor p_196287_0_) { return BALLOONS_BY_COLOR.getOrDefault(p_196287_0_, Blocks.WHITE_BANNER); } } It seams like something in the class, it extends, makes it unable to render it´s model. I know, that it get´s it´s model by it´s registryname. And it worked fine, bevore i made it extend this color-block.
  2. now i noticed, that i had te wrong model-name in the blockstates for the top one. Fixing this may remove the too high placed model. But i still don´t know, why the bottom part does not render it´s model.
  3. This is in the bottom part of the block: @Override public void onBlockPlacedBy(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) { worldIn.setBlockState(pos.up(), AngryBirdsBlocks.balloon_block_top.getDefaultState()); super.onBlockPlacedBy(worldIn, pos, state, placer, stack); } @Override public void onBlockHarvested(World worldIn, BlockPos pos, BlockState state, PlayerEntity player) { worldIn.setBlockState(pos.up(), Blocks.AIR.getDefaultState()); super.onBlockHarvested(worldIn, pos, state, player); } It´s just, what you told, i should use.
  4. I still have no clue, why the model appears one block to high...
  5. Thry out: @Override public boolean isSolid(BlockState state) { return false; } my custom shaped blocks have no transparent holes in the ground below them with it. And in my block registry, my blocks have ".variableOpacity()" in their registry-lines. so maybe try around with it.
  6. Now i fixed the error, The error was very weird. It told about the minecraft air-block, but it appeared, because the top-block for my tall block had no registery name. And the BlockItem-thing works too. So there are no more conflicts at trying to place it under a too low ceiling. I made an if-else-thing, that makes the common stuff of that method, if the top block is air and returns false (= no blockplacing at all), if it´s not air. But now i get the model one block too high. The collision-boxes show the right order (the whider one for the ballon ontop of the narrow one for the string). How to fix this
  7. I´m now in 1.14 too. now i got an error about the minecraft-block air... Why this happens? I just use the air-block to delete the top block on harvesting. I don´t change anything at it´s registration.
  8. This i already have in my class and i created my own item group tag with json file, that i use there. I declared a Predicate for ItemStack (like i found in the ShootebleItem-class) and placed the created item group tag in it: public static final Predicate<ItemStack> BIRD_SHOTS = (p_220002_0_) -> { return p_220002_0_.getItem().isIn(AngryBirdsItems.BIRD_SHOTS); } ; And then i used it for the method, you sayd: public Predicate<ItemStack> getInventoryAmmoPredicate() { return BIRD_SHOTS; } But i still don´t understand, how this should be able to work, if i remove my modifications in the "onPlayerStoppedUsing"-method. As i sayd, it uses "ArrowItem" in muptiple positions in this method (where i have placed my own munition-item), and my munition-item does not extend ArrowItem. I already noticed any time earlyer any where, that a java-code can only use a specific java-class, if it asks for the name of a class in the direct extension-line of the class to use.
  9. Now i have this: @Override public void onBlockPlacedBy(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) { worldIn.setBlockState(pos.up(), AngryBirdsBlocks.balloon_block_top.getDefaultState()); super.onBlockPlacedBy(worldIn, pos, state, placer, stack); } @Override public void onBlockHarvested(World worldIn, BlockPos pos, BlockState state, PlayerEntity player) { worldIn.setBlockState(pos.up(), Blocks.AIR.getDefaultState()); super.onBlockHarvested(worldIn, pos, state, player); } But i ned a third method, one, that is called bevore i cam place the bottom half and if i try to place it ina just one block tall gap (where the player is unable to enter), it should not be placed (like try to place a bed, where it has not enough room).
  10. How do i check, if there is enough space (one block of air above the choosen position) for the model, bevor placing? And how exactly do i use World#setBlockState (and how do i find the position above the first block)?
  11. Hello Most of my Angry Birds entities are smaller than one block. But i noticed, that i cannot place a Block directly above them (to create an one block high hone around them) It seams like they cannot enter an one block high hole in a wall. How can i change the size of their collision-box to fit their body-size?
  12. I cannot understend, how this will make it use my munition, if it still uses "ArrowItem" in it´s "onPlayerStoppedUsing"-method. And i cannot find this method in the list, that i open with Strg + Space (what´s my common way to override stuff). And i also cannot find this method in the classes "BowItem" and "ShootableItem" Are you sure, that this is the way to do it in 1.14.3?
  13. OK crash fixed: Now i have placed theese registry-events in my main-class, where i already had some of theese events in a sub-class, So all registry events are located together at one spot.. And now i can spawn this entity again with the egg. And so i keep my old entity-registering event, because it still needs only the all-capitals-entity-type-names, like i already use them there. Another question: How can i register my munitions this way? If i try to make theese lines exactly the same: RED_SHOT = EntityType.Builder.<RedShotEntity>create(RedShotEntity::new, EntityClassification.MISC).size(0.5F, 0.5F); It says, that the constructor of my munition mismatches... But one of it´s three constructors is similar to the ones of the other entities.
  14. Now my code for this looks like this: @SubscribeEvent public static void registerEntitySpawnEggs(Register<Item>event) { RED = EntityType.Builder.create(RedEntity::new, EntityClassification.CREATURE).build(Reference.MOD_ID + ".red").setRegistryName("red"); event.getRegistry().registerAll(AngryBirdsItems.red_egg = registerEntitySpawnEgg(RED, 0xdf0000, 0xdfbf9f, "red_egg"), AngryBirdsItems.chuck_egg = registerEntitySpawnEgg(CHUCK, 0xffff00, 0xffffff, "chuck_egg"), AngryBirdsItems.blues_egg = registerEntitySpawnEgg(BLUES, 0x007fff, 0xff0000, "blues_egg"), AngryBirdsItems.bomb_egg = registerEntitySpawnEgg(BOMB, 0x3f3f3f, 0x7f7f7f, "bomb_egg"), AngryBirdsItems.mathilda_egg = registerEntitySpawnEgg(MATHILDA, 0xffffff, 0xffbfbf, "mathilda_egg"), AngryBirdsItems.terence_egg = registerEntitySpawnEgg(TERENCE, 0xbf002f, 0xbf9f7f, "terence_egg"), AngryBirdsItems.silver_egg = registerEntitySpawnEgg(SILVER, 0xbfbfbf, 0xffffff, "silver_egg"), AngryBirdsItems.bubbles_egg = registerEntitySpawnEgg(BUBBLES, 0xff7f00, 0x000000, "bubbles_egg"), AngryBirdsItems.hal_egg = registerEntitySpawnEgg(HAL, 0x00bf00, 0xffffff, "hal_egg"), AngryBirdsItems.stella_egg = registerEntitySpawnEgg(STELLA, 0xffadb7, 0xffd7dc, "stella_egg"), AngryBirdsItems.poppy_egg = registerEntitySpawnEgg(POPPY, 0xffff3f, 0xffffbf, "poppy_egg"), AngryBirdsItems.willow_egg = registerEntitySpawnEgg(WILLOW, 0x3f9fff, 0x7fbfff, "willow_egg"), AngryBirdsItems.dahlia_egg = registerEntitySpawnEgg(DAHLIA, 0xbf7f3f, 0xffdfbf, "dahlia_egg"), AngryBirdsItems.luca_egg = registerEntitySpawnEgg(LUCA, 0x7fbfff, 0xffffbf, "luca_egg"), AngryBirdsItems.ice_bird_egg = registerEntitySpawnEgg(ICE_BIRD, 0x7fbfff, 0x007fff, "ice_bird_egg")); } @SubscribeEvent public static void registerEntities(Register<EntityType<?>> event) { event.getRegistry().registerAll(RED); //event.getRegistry().registerAll(EntityType.Builder.<RedShotEntity>create(RedShotEntity::new, EntityClassification.MISC).size(0.5F, 0.5F)); } public static Item registerEntitySpawnEgg(EntityType<?> type, int color1, int color2, String name) { SpawnEggItem item = new SpawnEggItem(type, color1, color2, new Item.Properties().group(AngryBirds.ANGRY_BIRDS)); item.setRegistryName(name); return item; } But it crashes, bevore the red loading bar is full. I create the entity in the item register method and then register it in the registerEntity-method, like you say. What did i understand wrong in your last code-template? It says this errors: for the seccond part of the error, i cannot find out, wich entry value it means... it didn´t write it into the lines below and i also cannot find it in the logs.
  15. The entity-classes of my birds want an EntityType named in theri constructor. So i think, i need theese fields for all of them to put theese all-capitals-names into the constructors.. in my main-class i have this: @SubscribeEvent public static void registerEntities(final RegistryEvent.Register<EntityType<?>> event) { event.getRegistry().registerAll(AngryBirdsEntities.RED, AngryBirdsEntities.CHUCK, AngryBirdsEntities.BLUES, AngryBirdsEntities.BOMB, AngryBirdsEntities.MATHILDA, AngryBirdsEntities.TERENCE, AngryBirdsEntities.SILVER, AngryBirdsEntities.BUBBLES, AngryBirdsEntities.HAL, AngryBirdsEntities.STELLA, AngryBirdsEntities.POPPY, AngryBirdsEntities.WILLOW, AngryBirdsEntities.DAHLIA, AngryBirdsEntities.LUCA, AngryBirdsEntities.ICE_BIRD); } Can i delete this, if i change all my birds to how you make it? And in the headline of your method, i think, it should be "Register<EntityType<?>> event" instead of "Register<EntityTypes> event". It seams like you forgot to tell me something. I cannot spwn them with a spawn-egg now. This i how i actually made my SpawnEggs: public static void registerEntitySpawnEggs(final RegistryEvent.Register<Item>event) { event.getRegistry().registerAll(AngryBirdsItems.red_egg = registerEntitySpawnEgg(RED, 0xdf0000, 0xdfbf9f, "red_egg"), AngryBirdsItems.chuck_egg = registerEntitySpawnEgg(CHUCK, 0xffff00, 0xffffff, "chuck_egg"), AngryBirdsItems.blues_egg = registerEntitySpawnEgg(BLUES, 0x007fff, 0xff0000, "blues_egg"), AngryBirdsItems.bomb_egg = registerEntitySpawnEgg(BOMB, 0x3f3f3f, 0x7f7f7f, "bomb_egg"), AngryBirdsItems.mathilda_egg = registerEntitySpawnEgg(MATHILDA, 0xffffff, 0xffbfbf, "mathilda_egg"), AngryBirdsItems.terence_egg = registerEntitySpawnEgg(TERENCE, 0xbf002f, 0xbf9f7f, "terence_egg"), AngryBirdsItems.silver_egg = registerEntitySpawnEgg(SILVER, 0xbfbfbf, 0xffffff, "silver_egg"), AngryBirdsItems.bubbles_egg = registerEntitySpawnEgg(BUBBLES, 0xff7f00, 0x000000, "bubbles_egg"), AngryBirdsItems.hal_egg = registerEntitySpawnEgg(HAL, 0x00bf00, 0xffffff, "hal_egg"), AngryBirdsItems.stella_egg = registerEntitySpawnEgg(STELLA, 0xffadb7, 0xffd7dc, "stella_egg"), AngryBirdsItems.poppy_egg = registerEntitySpawnEgg(POPPY, 0xffff3f, 0xffffbf, "poppy_egg"), AngryBirdsItems.willow_egg = registerEntitySpawnEgg(WILLOW, 0x3f9fff, 0x7fbfff, "willow_egg"), AngryBirdsItems.dahlia_egg = registerEntitySpawnEgg(DAHLIA, 0xbf7f3f, 0xffdfbf, "dahlia_egg"), AngryBirdsItems.luca_egg = registerEntitySpawnEgg(LUCA, 0x7fbfff, 0xffffbf, "luca_egg"), AngryBirdsItems.ice_bird_egg = registerEntitySpawnEgg(ICE_BIRD, 0x7fbfff, 0x007fff, "ice_bird_egg")); } public static Item registerEntitySpawnEgg(EntityType<?> type, int color1, int color2, String name) { SpawnEggItem item = new SpawnEggItem(type, color1, color2, new Item.Properties().group(AngryBirds.ANGRY_BIRDS)); item.setRegistryName(name); return item; } If i try to use a spawn egg, i get this: It shows no class of my mod. So i don´t know, what exactly i have to change to fix this eror.
  16. I have lot´s of different birds. Should i give each one such an objectholder with their names? I connected ti the modid-string in my Reference-Class, where you say "modid" i think, so it keeps working, if i think about changing the modid later in the reference-class. your empty Entitytype-thing gives me a raw type warning.should i better add "<?>" behind "EntityType"?
  17. If you say, tha way, Harry Talks registers entities, is not good, then i need a tutorial-video, that shows it a better way. Tutorial-videos work the best for me to make stuff in a mod working. And Harry Talks was the only one, i found so far, who shows registering entities in 1.14.3
  18. my munition does not extend ArrowItem. So it cannot find it, if it still uses ArrowItem in it´s onPlayerStoppedUsing method. And i think, if my munition-item extends ArrowItem, the bow will be able to shoot it too. But i looked for a way to make this unable, too
  19. This is now the actual state of my mod: AngryBirdsMod Github My sligshot extends the bow now, but i override the method onPlayerStoppedUsing and still use it´s whoole content, where i replaced "ArrowItem" with my own munition item-class. I see no other way to make it use onmy my own stuff I wonder, why my slingshot doesn´t shoot any more (makes the pose, but doesn´t change it´s testure to the pulled state.)... Is anything at the munition not registered correct? Another question: The common arrows get different colored arrow-heads, if enchanted. How do i make my birds get that magic glow of other enchanted items instead?
  20. but how do i separate the munitions then to make it unable to use arrows? About Static initializers for entities: The EntityTypes - class in the minecraft-source also has such static fields (with all capital entity-names) for all entities. Here is a sample for one of theese lines: public static final EntityType<ArrowEntity> ARROW = register("arrow", EntityType.Builder.<ArrowEntity>create(ArrowEntity::new, EntityClassification.MISC).size(0.5F, 0.5F));
  21. my slingshot does not extend the bow. I used the code from the bow, and where the bow uses ArrowItem, i replaced this with my own munition-item class. And inside the munition-item-class I have got a connection to my own munition-entity-class, that extends AbstractArrowEntity. Where do i find better video tutorials for 1.14.3? Is this better: Jorrit Tyberghein modding tutorials
  22. this can be closed now, the problem isn´t there any more.
  23. now my munition-class extends AbstactArrowEntity. I have got a generic entity-class for my bird munitions, that´extends AbstactArrowEntity, and than i create specific entity-classes for each bird, wich extend my generic class for this. So each bird get´s it´s own entity-, renderer- and model-class. What must i do to use Red (the leader of the Angry Birds-flock) as the main munition, that can be used unlimited (much like the common arrow for the bow), and the others, if I hold them as an item in the other hand (item-stack, that decreases by one each shot, until empty)?
  24. I have got an idea: I can create the inflated version as an own entity without living animations. And in the original entity of the bird, it should spawn the inflated version at it´s position, if i collide with him and despawn it after the four secconds, i declared in the living-tick. And while theese four secconds, the normal one should do no living animations to stay hidden inside the inflated model. My code in the entity-class for this so far: @Override public void livingTick() { if (timeUntilDeflating > 0) { timeUntilDeflating--; if (timeUntilDeflating == 0) { //command for deflating here } } else { super.livingTick(); } } @Override public void onCollideWithPlayer(PlayerEntity entityIn) { if (timeUntilDeflating == 0) { timeUntilDeflating = 80; //command for inflating here } } It actually makes the entity stop it´s whoole movement and animations for four secconds after a collision with the player. I´ll use this effect to keep the normal model hidden inside the inflated one. I´m still working on an abstract renderer, that uses a model-class and scalefactor, but no living-animations (for the inflated variant). How do i write a command, that spawns the inflated entity and fits in here? And one that despawns it? It should be spawned in the actual position of the normal one (to encase it) and with it´s rotation-angle around the vertical axis.
×
×
  • Create New...

Important Information

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