Skip to content

Commit

Permalink
artifact weapons
Browse files Browse the repository at this point in the history
  • Loading branch information
Uraneptus committed Aug 28, 2024
1 parent eb64ff6 commit b31282e
Show file tree
Hide file tree
Showing 11 changed files with 189 additions and 20 deletions.
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ dependencies {
//runtimeOnly fg.deobf("curse.maven:configured-457570:4011355")
runtimeOnly fg.deobf("curse.maven:config-menus-forge-544048:4672356")
runtimeOnly fg.deobf("curse.maven:neat-238372:4580940")
runtimeOnly fg.deobf("curse.maven:advanced-xray-256256:4840340")

//runtimeOnly fg.deobf("curse.maven:advanced-xray-256256:4840340") Use this for worldgen tests
}

mixin {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,75 @@
{
"parent": "minecraft:item/generated",
"parent": "minecraft:item/handheld",
"display": {
"firstperson_lefthand": {
"rotation": [
-180,
90,
0
],
"scale": [
0.68,
0.68,
0.68
],
"translation": [
1.13,
3.2,
1.13
]
},
"firstperson_righthand": {
"rotation": [
180,
-90,
0
],
"scale": [
0.68,
0.68,
0.68
],
"translation": [
1.13,
3.2,
1.13
]
},
"thirdperson_lefthand": {
"rotation": [
-180,
90,
0
],
"scale": [
0.85,
0.85,
0.85
],
"translation": [
0,
4,
0.5
]
},
"thirdperson_righthand": {
"rotation": [
180,
-90,
0
],
"scale": [
0.85,
0.85,
0.85
],
"translation": [
0,
4,
0.5
]
}
},
"textures": {
"layer0": "sullysmod:item/broken_bottle"
}
Expand Down
17 changes: 17 additions & 0 deletions src/generated/resources/assets/sullysmod/sounds.json
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,23 @@
],
"subtitle": "subtitles.entity.tortoise_shell.place"
},
"item.broken_bottle.shatter": {
"sounds": [
{
"name": "random/glass1",
"pitch": 1.3
},
{
"name": "random/glass2",
"pitch": 1.3
},
{
"name": "random/glass3",
"pitch": 1.3
}
],
"subtitle": "subtitles.item.broken_bottle.shatter"
},
"item.throwing_knife.hit": {
"sounds": [
"sullysmod:item/throwing_knife/hit1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"minecraft:campfire",
"minecraft:soul_campfire",
"minecraft:lava",
"sullysmod:amber_lantern"
"sullysmod:molten_amber_block"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.uraneptus.sullysmod.common.items;

import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Multimap;
import com.uraneptus.sullysmod.core.registry.SMSounds;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.ai.attributes.Attribute;
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.function.Supplier;

public class ArtifactWeaponItem extends Item {
@Nullable
private final Supplier<SoundEvent> customBreakSound;
private final Multimap<Attribute, AttributeModifier> defaultModifiers;

public ArtifactWeaponItem(int damage, float speed, @Nullable Supplier<SoundEvent> customBreakSound, Properties pProperties) {
super(pProperties);
this.customBreakSound = customBreakSound;
ImmutableMultimap.Builder<Attribute, AttributeModifier> builder = ImmutableMultimap.builder();
builder.put(Attributes.ATTACK_DAMAGE, new AttributeModifier(BASE_ATTACK_DAMAGE_UUID, "Weapon modifier", damage, AttributeModifier.Operation.ADDITION));
builder.put(Attributes.ATTACK_SPEED, new AttributeModifier(BASE_ATTACK_SPEED_UUID, "Weapon modifier", speed, AttributeModifier.Operation.ADDITION));
this.defaultModifiers = builder.build();
}

@Override
public boolean hurtEnemy(ItemStack pStack, LivingEntity pTarget, LivingEntity pAttacker) {
pStack.hurtAndBreak(1, pAttacker, (entity) -> {
if (customBreakSound == null) {
entity.broadcastBreakEvent(EquipmentSlot.MAINHAND);
} else {
pAttacker.level().playSound(null, pAttacker.getOnPos(), customBreakSound.get(), SoundSource.NEUTRAL, 1.0F, 1.0F);
}
});
return true;
}

@NotNull
@Override
public Multimap<Attribute, AttributeModifier> getAttributeModifiers(EquipmentSlot slot, ItemStack stack) {
return slot == EquipmentSlot.MAINHAND ? this.defaultModifiers : super.getAttributeModifiers(slot, stack);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.google.common.collect.ImmutableList;
import com.google.common.collect.Maps;
import com.mojang.blaze3d.platform.Window;
import com.mojang.blaze3d.systems.RenderSystem;
import com.uraneptus.sullysmod.SullysMod;
import com.uraneptus.sullysmod.client.model.*;
import com.uraneptus.sullysmod.client.model.ancient_skulls.*;
Expand All @@ -13,13 +15,15 @@
import com.uraneptus.sullysmod.client.renderer.entities.*;
import com.uraneptus.sullysmod.client.renderer.entities.layer.StuckInAmberLayer;
import com.uraneptus.sullysmod.common.blocks.AncientSkullBlock;
import com.uraneptus.sullysmod.common.caps.SMEntityCap;
import com.uraneptus.sullysmod.common.items.VenomVialItem;
import com.uraneptus.sullysmod.core.registry.SMBlockEntityTypes;
import com.uraneptus.sullysmod.core.registry.SMEntityTypes;
import com.uraneptus.sullysmod.core.registry.SMItems;
import com.uraneptus.sullysmod.core.registry.SMParticleTypes;
import net.minecraft.Util;
import net.minecraft.client.particle.DripParticle;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.renderer.blockentity.SkullBlockRenderer;
import net.minecraft.client.renderer.entity.LivingEntityRenderer;
import net.minecraft.client.renderer.item.ItemProperties;
Expand All @@ -31,6 +35,7 @@
import net.minecraftforge.client.event.EntityRenderersEvent;
import net.minecraftforge.client.event.RegisterColorHandlersEvent;
import net.minecraftforge.client.event.RegisterParticleProvidersEvent;
import net.minecraftforge.client.event.RenderGuiEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
Expand All @@ -41,7 +46,7 @@

@Mod.EventBusSubscriber(modid = SullysMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
@SuppressWarnings("unused")
public class SMClientEvents {
public class SMClientModEvents {

@SubscribeEvent
public static void registerEntityRenderer(EntityRenderersEvent.RegisterRenderers event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.uraneptus.sullysmod.core.registry.SMParticleTypes;
import com.uraneptus.sullysmod.core.registry.SMSounds;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.particles.ItemParticleOption;
Expand Down Expand Up @@ -46,6 +47,7 @@
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.loading.FMLEnvironment;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -165,8 +167,10 @@ public static void onItemTooltip(ItemTooltipEvent event) {
}
});

if (itemstack.is(SMItems.JADE_SHIELD.get()) || itemstack.is(SMItemTags.ARTIFACTS)) {
itemstack.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
if (itemstack.is(SMItems.JADE_SHIELD.get()) || (itemstack.is(SMItemTags.ARTIFACTS) && !itemstack.is(SMItems.BROKEN_BOTTLE.get()) && !itemstack.is(SMItems.PRIMITIVE_KNIFE.get()))) { //This also hides damage values of artifacts
if (FMLEnvironment.production) {
itemstack.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
}
}

if (player != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import net.minecraftforge.registries.RegistryObject;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Supplier;

Expand Down Expand Up @@ -69,7 +68,7 @@ public class SMItems {
public static Map<Supplier<Item>, Integer> TRADES = new HashMap<>();

public static final RegistryObject<Item> BROKEN_VASE = registerArtifact("broken_vase", "A large piece of the side is missing", 10);
public static final RegistryObject<Item> PRIMITIVE_KNIFE = registerArtifact("primitive_knife", "A small knife made from obsidian", 15);
public static final RegistryObject<Item> PRIMITIVE_KNIFE = registerArtifact("primitive_knife", "A small knife made from obsidian", () -> new ArtifactWeaponItem(5, -2.5F, null, SMProperties.Items.artifacts().durability(20)), 15);
public static final RegistryObject<Item> MINERS_HELMET = registerArtifact("miners_helmet", "Looks like it’s previous owner couldn’t get the candle lit anymore",
() -> new ArtifactHelmetItem(SMArmorMaterials.MINERS_HELMET, SMProperties.Items.artifacts(), MinersHelmetModel.INSTANCE), 15);
public static final RegistryObject<Item> SMALL_DENTED_HELMET = registerArtifact("small_dented_helmet", "A small rusty helmet. Barely fits",
Expand Down Expand Up @@ -109,7 +108,7 @@ public class SMItems {
public static final RegistryObject<Item> TORN_CLOTH = registerArtifact("torn_cloth", "A dirty torn off piece of clothing", 6);
public static final RegistryObject<Item> GOLDEN_GOBLET = registerArtifact("golden_goblet", "An old but beautiful chalice made by a skilled goldsmith", 29);
public static final RegistryObject<Item> EMERALD_EARRING = registerArtifact("emerald_earring", "Besides the beautiful emerald, it looks sloppily put together", 17);
public static final RegistryObject<Item> BROKEN_BOTTLE = registerArtifact("broken_bottle", "The top half of a bottle", 5);
public static final RegistryObject<Item> BROKEN_BOTTLE = registerArtifact("broken_bottle", "The top half of a bottle", () -> new ArtifactWeaponItem(4, -1.2F, SMSounds.BROKEN_BOTTLE_SHATTERS, SMProperties.Items.artifacts().durability(1)), 5);
public static final RegistryObject<Item> FROG_IDOL = registerArtifact("frog_idol", "Everybody likes frogs", 29);

public static RegistryObject<Item> registerArtifact(String name, String description, int price) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class SMSounds {
public static final RegistryObject<SoundEvent> THROWING_KNIFE_HIT = HELPER.createSoundEvent("item.throwing_knife.hit");
public static final RegistryObject<SoundEvent> THROWING_KNIFE_HIT_GROUND = HELPER.createSoundEvent("item.throwing_knife.hit_ground");
public static final RegistryObject<SoundEvent> THROWING_KNIFE_THROW = HELPER.createSoundEvent("item.throwing_knife.throw");
public static final RegistryObject<SoundEvent> BROKEN_BOTTLE_SHATTERS = HELPER.createSoundEvent("item.broken_bottle.shatter");

//Block Sounds
public static final RegistryObject<SoundEvent> JADE_RICOCHET = HELPER.createSoundEvent("block.jade.ricochet");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraftforge.client.model.generators.ItemModelProvider;
Expand Down Expand Up @@ -66,12 +67,10 @@ protected void registerModels() {
basicBlockItem(SMBlocks.ROUGH_JADE_BRICK_SLAB);
basicItem(SMItems.MUSIC_DISC_SCOUR);
basicItem(SMItems.MUSIC_DISC_SUNKEN_PAST);
jadeShieldItem(SMItems.JADE_SHIELD);
basicItem(SMItems.TORTOISE_SCUTE);
basicItem(SMItems.TORTOISE_SHELL);
basicItem(SMItems.JADE_UPGRADE_SMITHING_TEMPLATE);
basicItem(SMItems.GLASS_VIAL);
venomVialItem(SMItems.VENOM_VIAL);
basicItem(SMItems.JADE_HORSE_ARMOR);
basicItemHandheld(SMItems.THROWING_KNIFE);
basicBlockItem(SMBlocks.AMBER);
Expand Down Expand Up @@ -141,7 +140,7 @@ protected void registerModels() {
basicItem(SMItems.TORN_CLOTH);
basicItem(SMItems.GOLDEN_GOBLET);
basicItem(SMItems.EMERALD_EARRING);
basicItem(SMItems.BROKEN_BOTTLE);
basicItemHandheld(SMItems.BROKEN_BOTTLE);
basicItem(SMItems.FROG_IDOL);
ancientSkull(SMBlocks.CRACKED_ANCIENT_SKULL.getFirst());
ancientSkull(SMBlocks.CRESTED_ANCIENT_SKULL.getFirst());
Expand All @@ -151,6 +150,10 @@ protected void registerModels() {
ancientSkull(SMBlocks.LONG_ANCIENT_SKULL.getFirst());
ancientSkull(SMBlocks.TINY_ANCIENT_SKULL.getFirst());
ancientSkull(SMBlocks.WIDE_ANCIENT_SKULL.getFirst());
//Single use methods
brokenBottle();
venomVialItem();
jadeShieldItem();
}

private void basicBlockItem(Supplier<? extends Block> blockForItem) {
Expand Down Expand Up @@ -201,8 +204,9 @@ private void basicSpawnEggItem(Supplier<? extends Item> item) {
withExistingParent(name(item.get()), SPAWN_EGG);
}

private void jadeShieldItem(Supplier<? extends Item> item) {
getBuilder(name(item.get()) + "_blocking")
private void jadeShieldItem() {
Item item = SMItems.JADE_SHIELD.get();
getBuilder(name(item) + "_blocking")
.parent(new ModelFile.UncheckedModelFile(ENTITY))
.guiLight(BlockModel.GuiLight.FRONT)
.texture("particle", vanillaBlockLocation(name(Blocks.DARK_OAK_PLANKS)))
Expand All @@ -214,7 +218,7 @@ private void jadeShieldItem(Supplier<? extends Item> item) {
.transform(ItemDisplayContext.GUI).rotation(15, -25, -5).translation(2, 2.5F, 0).scale(0.65F, 0.65F, 0.65F).end()
.end();

getBuilder(name(item.get()))
getBuilder(name(item))
.parent(new ModelFile.UncheckedModelFile(ENTITY))
.guiLight(BlockModel.GuiLight.FRONT)
.texture("particle", vanillaBlockLocation(name(Blocks.DARK_OAK_PLANKS)))
Expand All @@ -227,11 +231,12 @@ private void jadeShieldItem(Supplier<? extends Item> item) {
.transform(ItemDisplayContext.FIXED).rotation(0, 180, 0).translation(-4.5F, 4.5F, -5).scale(0.55F, 0.55F, 0.55F).end()
.transform(ItemDisplayContext.GROUND).rotation(0, 0, 0).translation(2, 4, 2).scale(0.25F, 0.25F, 0.25F).end()
.end()
.override().predicate(new ResourceLocation("blocking"), 1).model(new ModelFile.UncheckedModelFile(modItemLocation(name(item.get()) + "_blocking")));
.override().predicate(new ResourceLocation("blocking"), 1).model(new ModelFile.UncheckedModelFile(modItemLocation(name(item) + "_blocking")));
}

private void venomVialItem(Supplier<? extends Item> item) {
withExistingParent(name(item.get()), GENERATED)
private void venomVialItem() {
Item vial = SMItems.VENOM_VIAL.get();
withExistingParent(name(vial), GENERATED)
.texture("layer0", modItemLocation("glass_vial"))
.texture("layer1", modItemLocation("venom_vial_1"))
.texture("layer2", modItemLocation("venom_vial_2"));
Expand All @@ -249,4 +254,17 @@ private void ancientSkull(Supplier<? extends Block> skull) {
.end();

}

private void brokenBottle() {
Item bottle = SMItems.BROKEN_BOTTLE.get();
getBuilder(name(bottle))
.parent(getExistingFile(HANDHELD))
.texture("layer0", modItemLocation(name(bottle)))
.transforms()
.transform(ItemDisplayContext.THIRD_PERSON_RIGHT_HAND).rotation(180, -90, 0).translation(0, 4, 0.5F).scale(0.85F, 0.85F, 0.85F).end()
.transform(ItemDisplayContext.THIRD_PERSON_LEFT_HAND).rotation(-180, 90, 0).translation(0, 4, 0.5F).scale(0.85F, 0.85F, 0.85F).end()
.transform(ItemDisplayContext.FIRST_PERSON_RIGHT_HAND).rotation(180, -90, 0).translation(1.13F, 3.2F, 1.13F).scale(0.68F, 0.68F, 0.68F).end()
.transform(ItemDisplayContext.FIRST_PERSON_LEFT_HAND).rotation(-180, 90, 0).translation(1.13F, 3.2F, 1.13F).scale(0.68F, 0.68F, 0.68F).end()
.end();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ public void registerSounds() {
sound(SullysMod.modPrefix("item/throwing_knife/throw1")),
sound(SullysMod.modPrefix("item/throwing_knife/throw2"))
);
this.addBasicSound(SMSounds.BROKEN_BOTTLE_SHATTERS,
sound("random/glass1").pitch(1.3F),
sound("random/glass2").pitch(1.3F),
sound("random/glass3").pitch(1.3F)
);

//Block Sounds
this.addBasicSound(SMSounds.POLISH_JADE,
Expand Down

0 comments on commit b31282e

Please sign in to comment.