Jump to content

Dank3yKang

Members
  • Posts

    9
  • Joined

  • Last visited

Everything posted by Dank3yKang

  1. lol forgot to add question, I don't know how to change the position of the lightning strike to be a number of blocks away from the player in the direction they are looking, so how would I go around doing that?
  2. I am making an item that when used, lightning strikes down the direction the player is looking and at a distance. Code I have so far: import net.minecraft.core.BlockPos; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.MobSpawnType; import net.minecraft.world.item.ItemStack; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class CreateLightningC2SPacket { public CreateLightningC2SPacket() { } public CreateLightningC2SPacket(FriendlyByteBuf buf) { } public void toBytes(FriendlyByteBuf buf) { } public boolean handle(Supplier<NetworkEvent.Context> supplier) { NetworkEvent.Context context = supplier.get(); context.enqueueWork(() -> { // HERE WE ARE ON THE SERVER! ServerPlayer player = context.getSender(); ServerLevel level = player.getLevel(); EntityType.LIGHTNING_BOLT.spawn(level, (ItemStack) null, null, new BlockPos(player.getX(), player.getY(), player.getZ()), MobSpawnType.COMMAND, true, false); }); return true; } }
  3. I fixed it, i compared my door to a vanilla door and it was missing a few json files so all goods now.
  4. public static final RegistryObject<Block> ELDENWOOD_DOOR = registerBlock("eldenwood_door", () -> new DoorBlock(BlockBehaviour.Properties.of(Material.WOOD) .strength(5f).noOcclusion()), ModCreativeModeTab.MCRPGMOD_DECORATION); resources.assets.mcrpgmod.models.block.eldenwood_door_bottom resources.assets.mcrpgmod.models.block.eldenwood_door_bottom_hinge resources.assets.mcrpgmod.models.block.eldenwood_door_top resources.assets.mcrpgmod.models.block.eldenwood_door_top_hinge
  5. No matter what I do the textures of my door aren't appearing, everything is named correctly and everything's there, but it's not showing the textures in game. I deleted all the textures and json files and redid it but to no avail please can I get some help.
  6. Ty, I just changed the speed in the tier
  7. Hi, so I am having trouble with some code. I made a custom pickaxe which extends off the pickaxe class, and I want it to give the player haste while they hold it. There is no obvious override methods that I can find and I need some help thank you. Here is the code I have so far: import net.minecraft.ChatFormatting; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; import net.minecraft.world.item.*; import net.minecraft.world.level.Level; import org.jetbrains.annotations.Nullable; import java.util.List; public class DwarvenPickaxeItem extends PickaxeItem { public DwarvenPickaxeItem(Tier tier, int attackmodifier, float speed, Properties properties) { super(tier, attackmodifier, speed, properties); } @Override public void appendHoverText(ItemStack stack, @Nullable Level level, List<Component> components, TooltipFlag flag) { if(Screen.hasShiftDown()) { components.add(Component.literal("A pickaxe which has been masterfully crafted by the hands of a Dwarf, making it especially good at mining with speed").withStyle(ChatFormatting.YELLOW).withStyle(ChatFormatting.ITALIC)); } else { components.add(Component.literal("Hold SHIFT for more info.").withStyle(ChatFormatting.YELLOW).withStyle(ChatFormatting.ITALIC)); } super.appendHoverText(stack, level, components, flag); } }
  8. Ty that really helped
  9. Hi, I wanted to make an item that when you use it, it gives you XP levels and then consumes the item. I have gotten to the point where it gives you the XP levels but can't figure out how to get rid of the item from a the inventory. (I have tried searching it up online but I can't figure it out) so I could use some help This is the code for the item: import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; public class KnowledgeScrollItem extends Item { public KnowledgeScrollItem(Properties properties) { super(properties); } @Override public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand hand) { if(!level.isClientSide() && hand == InteractionHand.MAIN_HAND) { player.giveExperienceLevels(2); } return super.use(level, player, hand); } }
×
×
  • Create New...

Important Information

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