This commit is contained in:
parent
bb17cf86fc
commit
1ebd1341b0
@ -2,6 +2,8 @@ package net.voltexstudios;
|
||||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
|
||||
import net.voltexstudios.entity.ModEntities;
|
||||
import net.voltexstudios.item.ModItems;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -13,10 +15,10 @@ public class VoltexDesertUpdate implements ModInitializer {
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
// This code runs as soon as Minecraft is in a mod-load-ready state.
|
||||
// However, some things (like resources) may still be uninitialized.
|
||||
// Proceed with mild caution.
|
||||
|
||||
LOGGER.info("Hello Fabric world!");
|
||||
|
||||
ModItems.registerModItems();
|
||||
|
||||
ModEntities.registerModEntities();
|
||||
}
|
||||
}
|
@ -2,12 +2,12 @@ package net.voltexstudios;
|
||||
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
|
||||
import static com.mojang.text2speech.Narrator.LOGGER;
|
||||
|
||||
|
||||
public class VoltexDesertUpdateClient implements ClientModInitializer {
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
LOGGER.info("Initializing Desert Update Client");
|
||||
VoltexDesertUpdate.LOGGER.info("Initializing Desert Update Client");
|
||||
|
||||
|
||||
}
|
||||
|
21
src/main/java/net/voltexstudios/entity/ModEntities.java
Normal file
21
src/main/java/net/voltexstudios/entity/ModEntities.java
Normal file
@ -0,0 +1,21 @@
|
||||
package net.voltexstudios.entity;
|
||||
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.SpawnGroup;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.voltexstudios.VoltexDesertUpdate;
|
||||
import net.voltexstudios.entity.custom.DuneProjectileEntity;
|
||||
|
||||
public class ModEntities {
|
||||
|
||||
public static final EntityType<DuneProjectileEntity> DUNE_PROJECTILE_ENTITY = Registry.register(Registries.ENTITY_TYPE,
|
||||
Identifier.of(VoltexDesertUpdate.MOD_ID, "dune_projectile_entity"),
|
||||
EntityType.Builder.<DuneProjectileEntity>create(DuneProjectileEntity::new, SpawnGroup.MISC)
|
||||
.dimensions(0.25f, 0.25f).build());
|
||||
|
||||
public static void registerModEntities() {
|
||||
VoltexDesertUpdate.LOGGER.info("Registering Mod Entities for " + VoltexDesertUpdate.MOD_ID);
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package net.voltexstudios.entity.custom;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.projectile.thrown.ThrownItemEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.util.hit.EntityHitResult;
|
||||
import net.minecraft.util.hit.HitResult;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class DuneProjectileEntity extends ThrownItemEntity {
|
||||
|
||||
private static final float DAMAGE = 4F;
|
||||
|
||||
public DuneProjectileEntity(EntityType<DuneProjectileEntity> duneProjectileEntityEntityType, World world) {
|
||||
super(duneProjectileEntityEntityType, world);
|
||||
}
|
||||
|
||||
public DuneProjectileEntity(LivingEntity livingEntity, World world) {
|
||||
super(EntityType.EGG, livingEntity, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCollision(HitResult hitResult) {
|
||||
super.onCollision(hitResult);
|
||||
if (!this.getWorld().isClient) {
|
||||
this.getWorld().createExplosion(this, this.getX(), this.getBodyY(0.0625D), this.getZ(), 1.0F, false, World.ExplosionSourceType.TRIGGER);
|
||||
this.discard();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onEntityHit(EntityHitResult entityHitResult) {
|
||||
super.onEntityHit(entityHitResult);
|
||||
Entity entity = entityHitResult.getEntity();
|
||||
entity.damage(this.getDamageSources().thrown(this, this.getOwner()), DAMAGE);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Item getDefaultItem() {
|
||||
return Items.EGG;
|
||||
}
|
||||
|
||||
}
|
33
src/main/java/net/voltexstudios/item/ModItems.java
Normal file
33
src/main/java/net/voltexstudios/item/ModItems.java
Normal file
@ -0,0 +1,33 @@
|
||||
package net.voltexstudios.item;
|
||||
|
||||
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroups;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.Rarity;
|
||||
import net.voltexstudios.VoltexDesertUpdate;
|
||||
import net.voltexstudios.item.custom.DuneStaffItem;
|
||||
|
||||
public class ModItems {
|
||||
|
||||
public static final Item DUNE_STAFF = registerItem("dune_staff", new DuneStaffItem(new Item.Settings()
|
||||
.rarity(Rarity.EPIC)
|
||||
.maxDamage(100)
|
||||
.fireproof()
|
||||
));
|
||||
|
||||
private static Item registerItem(String name, Item item) {
|
||||
return Registry.register(Registries.ITEM, Identifier.of(VoltexDesertUpdate.MOD_ID, name), item);
|
||||
}
|
||||
|
||||
public static void registerModItems() {
|
||||
VoltexDesertUpdate.LOGGER.info("Registering Mod Items for " + VoltexDesertUpdate.MOD_ID);
|
||||
|
||||
ItemGroupEvents.modifyEntriesEvent(ItemGroups.TOOLS).register(entries -> {
|
||||
// add items to the ingredients tab
|
||||
entries.add(DUNE_STAFF);
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package net.voltexstudios.item.custom;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.stat.Stats;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
import net.minecraft.world.World;
|
||||
import net.voltexstudios.VoltexDesertUpdate;
|
||||
import net.voltexstudios.entity.custom.DuneProjectileEntity;
|
||||
|
||||
public class DuneStaffItem extends Item {
|
||||
|
||||
private static final int useDuration = 7 * 20; // 7 seconds
|
||||
|
||||
public DuneStaffItem(Settings settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
|
||||
|
||||
ItemStack itemStack = user.getStackInHand(hand);
|
||||
|
||||
if (!world.isClient) {
|
||||
|
||||
VoltexDesertUpdate.LOGGER.info("DuneStaffItem used");
|
||||
|
||||
DuneProjectileEntity duneProjectileEntity = new DuneProjectileEntity(user, world);
|
||||
duneProjectileEntity.setVelocity(user, user.getPitch(), user.getYaw(), 0.0f, 1.5f, 0f);
|
||||
world.spawnEntity(duneProjectileEntity);
|
||||
|
||||
/*
|
||||
TridentEntity tridentEntity = new TridentEntity(world, user, Items.TRIDENT.getDefaultStack());
|
||||
tridentEntity.setVelocity(user, user.getPitch(), user.getYaw(), 0.0f, 1.5f, 0f);
|
||||
world.spawnEntity(tridentEntity);
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
user.getItemCooldownManager().set(this, useDuration);
|
||||
user.incrementStat(Stats.USED.getOrCreateStat(this));
|
||||
|
||||
return TypedActionResult.success(itemStack);
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"item.voltexdesertupdate.dune_staff": "Staff of the Dunes"
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "voltexdesertupdate:item/dune_staff"
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
Loading…
Reference in New Issue
Block a user