Skip to content

Commit

Permalink
ingot yeah ingot yeah yeah
Browse files Browse the repository at this point in the history
  • Loading branch information
Leclowndu93150 committed Oct 12, 2024
1 parent 387051b commit f337faa
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 6 deletions.
12 changes: 9 additions & 3 deletions src/main/java/com/leclowndu93150/carbort/Carbort.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
package com.leclowndu93150.carbort;

import com.leclowndu93150.carbort.content.items.UnstableIngotItem;
import com.leclowndu93150.carbort.registries.*;
import com.mojang.logging.LogUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.world.item.ItemStack;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.ModContainer;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.config.ModConfig;
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
import net.neoforged.neoforge.client.event.ClientTickEvent;
import net.neoforged.neoforge.event.tick.PlayerTickEvent;
import net.neoforged.neoforge.event.tick.ServerTickEvent;
import org.slf4j.Logger;

@Mod(Carbort.MODID)
Expand All @@ -29,8 +35,8 @@ public Carbort(IEventBus modEventBus, ModContainer modContainer) {
modContainer.registerConfig(ModConfig.Type.COMMON, CarbortConfig.SPEC);
}

private void commonSetup(final FMLCommonSetupEvent event)
{
LOGGER.info("[Carbort]: I hope i did things right.");

private void commonSetup(final FMLCommonSetupEvent event) {
LOGGER.info("I hope i did things right.");
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.leclowndu93150.carbort.content.items;

import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component;
import net.minecraft.world.InteractionResult;
Expand All @@ -18,7 +19,6 @@

public class PartyPickaxeItem extends PickaxeItem {
public PartyPickaxeItem(Properties p_42964_) {

super(ToolTiers.PARTY, p_42964_);
}

Expand Down Expand Up @@ -48,6 +48,7 @@ public int getMaxStackSize(ItemStack stack) {
return super.useOn(context);
}


@Override
public void appendHoverText(ItemStack stack, TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) {
super.appendHoverText(stack, context, tooltipComponents, tooltipFlag);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.leclowndu93150.carbort.registries.CBDataComponents;
import com.leclowndu93150.carbort.utils.RandomFunctions;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
Expand Down Expand Up @@ -45,10 +46,18 @@ public void onCraftedBy(ItemStack stack, Level level, Player player) {

@Override
public void inventoryTick(ItemStack stack, Level level, Entity entity, int slotId, boolean isSelected) {
if(entity instanceof Player player){
if(!(player.containerMenu instanceof CraftingMenu)){
stack.set(CBDataComponents.TIMER, 0);
}
}
if (stack.has(CBDataComponents.TIMER)){
stack.set(CBDataComponents.TIMER, stack.get(CBDataComponents.TIMER) - 1);
if (stack.get(CBDataComponents.TIMER) <= 0){
stack.shrink(1);
if(entity instanceof Player player && !player.isCreative() && !level.isClientSide()){
stack.shrink(1);
level.explode(entity, entity.getX(), entity.getY(), entity.getZ(),3, Level.ExplosionInteraction.TNT);
}
}
}
super.inventoryTick(stack, level, entity, slotId, isSelected);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import java.util.concurrent.CompletableFuture;

@EventBusSubscriber(modid = Carbort.MODID)
@EventBusSubscriber(modid = Carbort.MODID, bus = EventBusSubscriber.Bus.MOD)
public final class DataGatherer {
@SubscribeEvent
public static void gatherData(GatherDataEvent event) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.leclowndu93150.carbort.events;

import com.leclowndu93150.carbort.content.items.UnstableIngotItem;
import com.leclowndu93150.carbort.registries.DataComponentRegistry;
import net.minecraft.client.Minecraft;
import net.minecraft.world.item.ItemStack;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.neoforge.client.event.ClientTickEvent;

//@EventBusSubscriber(modid = "carbort", bus = EventBusSubscriber.Bus.GAME, value = Dist.CLIENT)
public class CarbortClientEvents {

}
26 changes: 26 additions & 0 deletions src/main/java/com/leclowndu93150/carbort/events/CarbortEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,29 @@
import com.leclowndu93150.carbort.content.energy.ItemStackEnergyStorage;
import com.leclowndu93150.carbort.content.items.HealingAxeItem;
import com.leclowndu93150.carbort.content.energy.IEnergyItem;
import com.leclowndu93150.carbort.content.items.UnstableIngotItem;
import com.leclowndu93150.carbort.content.screen.ChunkAnalyzerScreen;
import com.leclowndu93150.carbort.networking.ChunkAnalyzerDataPayload;
import com.leclowndu93150.carbort.networking.ChunkAnalyzerTogglePayload;
import com.leclowndu93150.carbort.networking.PayloadActions;
import com.leclowndu93150.carbort.registries.CBDataComponents;
import com.leclowndu93150.carbort.registries.CBMenus;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.monster.Monster;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.CraftingMenu;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.neoforged.bus.api.EventPriority;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.neoforge.capabilities.Capabilities;
import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent;
import net.neoforged.neoforge.client.event.RegisterMenuScreensEvent;
import net.neoforged.neoforge.event.entity.player.AttackEntityEvent;
import net.neoforged.neoforge.event.tick.PlayerTickEvent;
import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent;
import net.neoforged.neoforge.network.registration.PayloadRegistrar;

Expand All @@ -44,6 +50,26 @@ public static void healingAxeHitEntity(AttackEntityEvent event) {
}
}

@SubscribeEvent(priority = EventPriority.LOW)
public static void holdingUnstableIngot(PlayerTickEvent.Post event){
Player player = event.getEntity();
if(player.containerMenu.getCarried().getItem() instanceof UnstableIngotItem && !player.level().isClientSide()){
ItemStack item = player.containerMenu.getCarried();
if(!(player.containerMenu instanceof CraftingMenu)){
item.set(CBDataComponents.TIMER, 0);
}
if(item.has(CBDataComponents.TIMER)){
item.set(CBDataComponents.TIMER, item.get(CBDataComponents.TIMER) - 1);
if(item.get(CBDataComponents.TIMER) <= 0){
if(!player.isCreative()){
item.shrink(1);
player.level().explode(player, player.getX(), player.getY(), player.getZ(),3, Level.ExplosionInteraction.TNT);
}
}
}
}
}

@EventBusSubscriber(modid = Carbort.MODID, bus = EventBusSubscriber.Bus.MOD)
public static class ModEvents {
@SubscribeEvent
Expand Down

0 comments on commit f337faa

Please sign in to comment.