generated from neoforged/MDK
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tools): added prospecting pick tool
- Added geckolib as dependency - Added prospecting pick resources - Added Custom Class for prospecting pick
- Loading branch information
Showing
13 changed files
with
642 additions
and
321 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/generated/resources/.cache/f9f5b962781cbf5adcc0a5f1bb62946a57aa0390
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
src/main/java/org/darkar/cog_works/item/ProspectingPickItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/org/darkar/cog_works/item/renderer/ProspectingPickItemRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
src/main/resources/assets/cog_works/animations/item/prospecting_pick.animation.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.