Skip to content

Commit

Permalink
feat(tools): added prospecting pick tool
Browse files Browse the repository at this point in the history
- Added geckolib as dependency
- Added prospecting pick resources
- Added Custom Class for prospecting pick
  • Loading branch information
D4RKAR117 committed Jun 2, 2024
1 parent 6ca4a83 commit 1996ce7
Show file tree
Hide file tree
Showing 13 changed files with 642 additions and 321 deletions.
14 changes: 13 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ group = mod_group_id

repositories {
mavenLocal()
maven {
name = 'GeckoLib'
url 'https://dl.cloudsmith.io/public/geckolib3/geckolib/maven/'
content {
includeGroup("software.bernie.geckolib")
}
}
}

base {
Expand Down Expand Up @@ -101,6 +108,9 @@ dependencies {
// The group id is ignored when searching -- in this case, it is "blank"
// implementation "blank:coolmod-${mc_version}:${coolmod_version}"

//GeckoLib
implementation "software.bernie.geckolib:geckolib-neoforge-${minecraft_version}:${gecko_lib_version}"

// Example mod dependency using a file as dependency
// implementation files("libs/coolmod-${mc_version}-${coolmod_version}.jar")

Expand Down Expand Up @@ -128,7 +138,9 @@ tasks.withType(ProcessResources).configureEach {
mod_license : mod_license,
mod_version : mod_version,
mod_authors : mod_authors,
mod_description : mod_description
mod_description : mod_description,
gecko_lib_version : gecko_lib_version,
gecko_lib_version_range: gecko_lib_version_range
]
inputs.properties replaceProperties

Expand Down
10 changes: 8 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ minecraft_version=1.20.6
# as they do not follow standard versioning conventions.
minecraft_version_range=[1.20.6,1.21)
# The Neo version must agree with the Minecraft version to get a valid artifact
neo_version=20.6.72-beta
neo_version=20.6.100-beta
# The Neo version range can use any version of Neo as bounds
neo_version_range=[20.6,)
# The loader version range can only use the major version of FML as bounds
Expand All @@ -32,7 +32,7 @@ mod_name=Cog Works Engineering
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=PolyFormPerimeter-1.0
# The mod version. See https://semver.org/
mod_version=0.2.0
mod_version=0.3.0
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
Expand All @@ -41,3 +41,9 @@ mod_group_id=org.darkar.cog_works
mod_authors=D4RKAR117
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list.
mod_description=Elevate your Minecraft experience with Cog Works Engineering, a mod that adds a variety of\n new machines and tools to the game.

## Dependencies

# Gecko Lib
gecko_lib_version=4.5.3
gecko_lib_version_range=[4.5.3,)
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// 1.20.6 2024-05-21T19:36:40.8796163 Languages: en_us for mod: cog_works
ea8464eff1b916d7708dec4c78a9b5bccdd7fa6b assets/cog_works/lang/en_us.json
// 1.20.6 2024-06-01T23:30:49.1563185 Languages: en_us for mod: cog_works
f0204be40d756208deb6105e589e693518b05c9f assets/cog_works/lang/en_us.json
3 changes: 2 additions & 1 deletion src/generated/resources/assets/cog_works/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@
"block.cog_works.tungsten_ore": "Tungsten Ore",
"block.cog_works.uranium_ore": "Uranium Ore",
"block.cog_works.vanadium_ore": "Vanadium Ore",
"block.cog_works.zinc_ore": "Zinc Ore"
"block.cog_works.zinc_ore": "Zinc Ore",
"item.cog_works.prospecting_pick": "Prospecting Pick"
}
411 changes: 96 additions & 315 deletions src/main/java/org/darkar/cog_works/Registry.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,7 @@ protected void addTranslations() {
addBlock(Registry.Blocks.DEEPSLATE_VANADIUM_ORE, "Deepslate Vanadium Ore");
addBlock(Registry.Blocks.ZINC_ORE, "Zinc Ore");
addBlock(Registry.Blocks.DEEPSLATE_ZINC_ORE, "Deepslate Zinc Ore");

addItem(Registry.Items.PROSPECTING_PICK, "Prospecting Pick");
}
}
88 changes: 88 additions & 0 deletions src/main/java/org/darkar/cog_works/item/ProspectingPickItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package org.darkar.cog_works.item;

import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerLevel;
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;
import net.minecraft.world.level.block.state.BlockState;
import net.neoforged.neoforge.common.extensions.IItemExtension;
import org.darkar.cog_works.item.renderer.ProspectingPickItemRenderer;
import software.bernie.geckolib.animatable.GeoItem;
import software.bernie.geckolib.animatable.SingletonGeoAnimatable;
import software.bernie.geckolib.animatable.client.GeoRenderProvider;
import software.bernie.geckolib.animatable.instance.AnimatableInstanceCache;
import software.bernie.geckolib.animation.AnimatableManager;
import software.bernie.geckolib.animation.AnimationController;
import software.bernie.geckolib.animation.PlayState;
import software.bernie.geckolib.animation.RawAnimation;
import software.bernie.geckolib.util.GeckoLibUtil;

import java.util.function.Consumer;

public class ProspectingPickItem extends Item implements GeoItem, IItemExtension {

private static final RawAnimation DIG_SAMPLE = RawAnimation.begin().thenPlay("animation.prospecting_pick.dig_sample");
private static final RawAnimation COLLECT_SAMPLE = RawAnimation.begin().thenPlay("animation.prospecting_pick.collect_sample");
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
private static final Properties itemProperties = new Properties().stacksTo(1)
.durability(128);

public ProspectingPickItem() {
super(itemProperties);
SingletonGeoAnimatable.registerSyncedAnimatable(this);
}

@Override
public void createGeoRenderer(Consumer<GeoRenderProvider> consumer) {
consumer.accept(new GeoRenderProvider() {
private ProspectingPickItemRenderer renderer;

@Override
public BlockEntityWithoutLevelRenderer getGeoItemRenderer() {
if (renderer == null) {
renderer = new ProspectingPickItemRenderer();
}

return this.renderer;
}
});
}

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

@Override
public void registerControllers(AnimatableManager.ControllerRegistrar controllers) {
controllers.add(new AnimationController<>(this, "dig_sample_controller", 20, state -> PlayState.STOP).triggerableAnim("dig_sample", DIG_SAMPLE));

controllers.add(new AnimationController<>(this, "collect_sample_controller", 20, state -> PlayState.STOP).triggerableAnim("collect_sample", COLLECT_SAMPLE));
}

@Override
public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand hand) {
if (level instanceof ServerLevel serverLevel)
triggerAnim(player, GeoItem.getOrAssignId(player.getItemInHand(hand), serverLevel),
"collect_sample_controller", "collect_sample");
return super.use(level, player, hand);
}

@Override
public boolean canAttackBlock(BlockState blockState, Level level, BlockPos blockPos, Player player) {
var name = blockState.getBlock().getName().getString();
if(level instanceof ServerLevel serverLevel) {
player.sendSystemMessage(Component.literal("Can attack block: " + name));
triggerAnim(player, GeoItem.getOrAssignId(player.getItemInHand(InteractionHand.MAIN_HAND), serverLevel),
"dig_sample_controller", "dig_sample");
}

return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.darkar.cog_works.item.renderer;

import net.minecraft.resources.ResourceLocation;
import org.darkar.cog_works.item.ProspectingPickItem;
import software.bernie.geckolib.model.DefaultedItemGeoModel;
import software.bernie.geckolib.renderer.GeoItemRenderer;

import static org.darkar.cog_works.CogWorks.MOD_ID;

public class ProspectingPickItemRenderer extends GeoItemRenderer<ProspectingPickItem> {


public ProspectingPickItemRenderer() {
super(new DefaultedItemGeoModel<>(new ResourceLocation(MOD_ID, "prospecting_pick")));
}
}
8 changes: 8 additions & 0 deletions src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ description='''${mod_description}'''
ordering="NONE"
side="BOTH"

# GeckoLib
[[dependencies.${mod_id}]]
modId="geckolib"
type="required"
versionRange="${gecko_lib_version_range}"
ordering="NONE"
side="BOTH"

# Features are specific properties of the game environment, that you may want to declare you require. This example declares
# that your mod requires GL version 3.2 or higher. Other features will be added. They are side aware so declaring this won't
# stop your mod loading on the server for example.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"format_version": "1.8.0",
"animations": {
"animation.prospecting_pick.dig_sample": {
"animation_length": 1.75,
"bones": {
"handle": {
"rotation": {
"0.0": {
"vector": [0, 0, 0]
},
"0.5": {
"vector": [-65, 0, 0],
"easing": "easeInCubic"
},
"0.75": {
"vector": [-35, 0, 0],
"easing": "easeInOutQuart"
},
"1.0": {
"vector": [-65, 0, 0],
"easing": "easeInOutQuart"
},
"1.25": {
"vector": [-35, 0, 0],
"easing": "easeOutQuart"
},
"1.75": {
"vector": [0, 0, 0],
"easing": "easeOutCirc"
}
}
}
}
},
"animation.prospecting_pick.collect_sample": {
"animation_length": 2.5,
"bones": {
"handle": {
"rotation": {
"0.0": {
"vector": [0, 0, 0]
},
"0.5": {
"vector": [0, 180, 0],
"easing": "easeInCubic"
},
"0.875": {
"vector": [65, 180, 0],
"easing": "easeInOutQuart"
},
"1.125": {
"vector": [30, 180, 0],
"easing": "easeInOutQuart"
},
"1.375": {
"vector": [65, 180, 0],
"easing": "easeInOutQuart"
},
"1.625": {
"vector": [30, 180, 0],
"easing": "easeInOutQuart"
},
"1.875": {
"vector": [30, 180, 0],
"easing": "easeInOutQuart"
},
"2.2083": {
"vector": [0, 180, 0],
"easing": "easeOutCubic"
},
"2.5": {
"vector": [0, 0, 0],
"easing": "easeOutQuad"
}
}
}
}
}
}
}
Loading

0 comments on commit 1996ce7

Please sign in to comment.