Skip to content

Commit

Permalink
feat: add experimental thorn shield
Browse files Browse the repository at this point in the history
  • Loading branch information
Elenterius committed Mar 25, 2024
1 parent bb654bd commit 17f7be5
Show file tree
Hide file tree
Showing 16 changed files with 1,442 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,8 @@ private void addItemTranslations() {
addItem(ModItems.OVERSEER_ARMOR_LEGGINGS, "Overseer Leggings");
addItem(ModItems.OVERSEER_ARMOR_BOOTS, "Overseer Boots");

addItem(ModItems.THORN_SHIELD, "The Thorn");

addItem(ModItems.BIO_EXTRACTOR, "[PH] Bio-Extractor", EMPTY_STRING);
addItem(ModItems.ESSENCE, "[PH] Essence", EMPTY_STRING);

Expand Down
1 change: 1 addition & 0 deletions src/generated/resources/assets/biomancy/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
"item.biomancy.overseer_armor_chestplate": "Overseer Chestplate",
"item.biomancy.overseer_armor_leggings": "Overseer Leggings",
"item.biomancy.overseer_armor_boots": "Overseer Boots",
"item.biomancy.thorn_shield": "The Thorn",
"item.biomancy.bio_extractor": "[PH] Bio-Extractor",
"item.biomancy.bio_extractor.tooltip": "",
"item.biomancy.essence": "[PH] Essence",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package com.github.elenterius.biomancy.client.render.item.armor;

import net.minecraft.MethodsReturnNonnullByDefault;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.github.elenterius.biomancy.client.render.item.shield;

import com.github.elenterius.biomancy.BiomancyMod;
import com.github.elenterius.biomancy.item.shield.ThornShieldItem;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.resources.ResourceLocation;
import software.bernie.geckolib.model.DefaultedItemGeoModel;

public class ThornShieldModel extends DefaultedItemGeoModel<ThornShieldItem> {

public ThornShieldModel() {
super(BiomancyMod.createRL("shield/thorn_shield"));
}

@Override
public RenderType getRenderType(ThornShieldItem animatable, ResourceLocation texture) {
return RenderType.entityCutout(texture);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.github.elenterius.biomancy.client.render.item.shield;

import com.github.elenterius.biomancy.item.shield.ThornShieldItem;
import software.bernie.geckolib.renderer.GeoItemRenderer;

public class ThornShieldRenderer extends GeoItemRenderer<ThornShieldItem> {

public ThornShieldRenderer() {
super(new ThornShieldModel());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package com.github.elenterius.biomancy.client.render.item.shield;

import net.minecraft.MethodsReturnNonnullByDefault;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.github.elenterius.biomancy.item.armor.AcolyteArmorItem;
import com.github.elenterius.biomancy.item.armor.OverseerArmorItem;
import com.github.elenterius.biomancy.item.injector.InjectorItem;
import com.github.elenterius.biomancy.item.shield.ThornShieldItem;
import com.github.elenterius.biomancy.item.weapon.*;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.EntityType;
Expand Down Expand Up @@ -114,6 +115,9 @@ public final class ModItems {
public static final RegistryObject<OverseerArmorItem> OVERSEER_ARMOR_LEGGINGS = registerArmorLeggings("overseer_armor", ModArmorMaterials.OVERSEER, OverseerArmorItem::new);
public static final RegistryObject<OverseerArmorItem> OVERSEER_ARMOR_BOOTS = registerArmorBoots("overseer_armor", ModArmorMaterials.OVERSEER, OverseerArmorItem::new);

//# Shield
public static final RegistryObject<ThornShieldItem> THORN_SHIELD = registerItem("thorn_shield", props -> new ThornShieldItem(props.stacksTo(1)));

//# Food/Fuel
public static final RegistryObject<EffectCureItem> NUTRIENT_PASTE = registerItem("nutrient_paste", props -> new EffectCureItem(props.food(ModFoods.NUTRIENT_PASTE)));
public static final RegistryObject<EffectCureItem> NUTRIENT_BAR = registerItem("nutrient_bar", props -> new EffectCureItem(props.food(ModFoods.NUTRIENT_BAR)));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package com.github.elenterius.biomancy.item.shield;

import com.github.elenterius.biomancy.client.render.item.shield.ThornShieldRenderer;
import com.github.elenterius.biomancy.item.SimpleItem;
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ArmorItem;
import net.minecraft.world.item.Equipable;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.UseAnim;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.DispenserBlock;
import net.minecraftforge.client.extensions.common.IClientItemExtensions;
import net.minecraftforge.common.ToolAction;
import net.minecraftforge.common.ToolActions;
import software.bernie.geckolib.animatable.GeoItem;
import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache;
import software.bernie.geckolib.core.animation.AnimatableManager;
import software.bernie.geckolib.util.GeckoLibUtil;

import java.util.function.Consumer;

public class ThornShieldItem extends SimpleItem implements Equipable, GeoItem {

private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);

public ThornShieldItem(Properties properties) {
super(properties);
DispenserBlock.registerBehavior(this, ArmorItem.DISPENSE_ITEM_BEHAVIOR);
}

@Override
public EquipmentSlot getEquipmentSlot() {
return EquipmentSlot.OFFHAND;
}

@Override
public boolean canPerformAction(ItemStack stack, ToolAction toolAction) {
return ToolActions.DEFAULT_SHIELD_ACTIONS.contains(toolAction);
}

@Override
public UseAnim getUseAnimation(ItemStack stack) {
return UseAnim.BLOCK;
}

@Override
public int getUseDuration(ItemStack stack) {
return 72000;
}

@Override
public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand hand) {
ItemStack stack = player.getItemInHand(hand);
player.startUsingItem(hand);
return InteractionResultHolder.consume(stack);
}

@Override
public void registerControllers(AnimatableManager.ControllerRegistrar controllers) {
//nothing atm
}

@Override
public AnimatableInstanceCache getAnimatableInstanceCache() {
return cache;
}

@Override
public void initializeClient(Consumer<IClientItemExtensions> consumer) {
super.initializeClient(consumer);
consumer.accept(new IClientItemExtensions() {
private final ThornShieldRenderer renderer = new ThornShieldRenderer();

@Override
public BlockEntityWithoutLevelRenderer getCustomRenderer() {
return renderer;
}
});
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package com.github.elenterius.biomancy.item.shield;

import net.minecraft.MethodsReturnNonnullByDefault;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"format_version": "1.8.0",
"animations": {
},
"geckolib_format_version": 2
}
Loading

0 comments on commit 17f7be5

Please sign in to comment.