Skip to content

Commit

Permalink
lots of rebalancing
Browse files Browse the repository at this point in the history
  • Loading branch information
Thepigcat76 committed Oct 10, 2024
1 parent cb34a79 commit 32ed9b2
Show file tree
Hide file tree
Showing 14 changed files with 102 additions and 124 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.portingdeadmods.nautec.NTConfig;
import com.portingdeadmods.nautec.content.recipes.ItemTransformationRecipe;
import com.portingdeadmods.nautec.content.recipes.inputs.ItemTransformationRecipeInput;
import com.portingdeadmods.nautec.utils.ParticlesUtils;
import com.portingdeadmods.nautec.utils.ParticleUtils;
import it.unimi.dsi.fastutil.objects.*;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
Expand Down Expand Up @@ -204,7 +204,7 @@ private void processItemCrafting(AABB box, Direction direction) {
iterator.remove();
} else {
activeTransformation.put(cookingItem, cookTime + 1);
ParticlesUtils.spawnParticlesAroundItem(cookingItem, level, ParticleTypes.END_ROD);
ParticleUtils.spawnParticlesAroundItem(cookingItem, level, ParticleTypes.END_ROD);
}
}
}
Expand All @@ -215,7 +215,7 @@ private void processItemCrafting(AABB box, Direction direction) {
BlockPos pos = worldPosition.relative(direction, distance);

Vec3 start = worldPosition.relative(direction).getCenter();
double v = 0.2;
double v = 0.3;
if (direction == Direction.UP || direction == Direction.DOWN) {
start = start.subtract(v, 0, v);
} else if (direction == Direction.NORTH || direction == Direction.SOUTH) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,10 @@

import com.portingdeadmods.nautec.api.augments.Augment;
import com.portingdeadmods.nautec.api.augments.AugmentSlot;
import com.portingdeadmods.nautec.api.augments.AugmentType;
import com.portingdeadmods.nautec.registries.NTAugments;
import com.portingdeadmods.nautec.utils.ParticlesUtils;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.phys.Vec3;
import net.neoforged.neoforge.event.tick.PlayerTickEvent;
import org.jetbrains.annotations.Nullable;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
package com.portingdeadmods.nautec.content.augments;

import com.mojang.blaze3d.platform.InputConstants;
import com.portingdeadmods.nautec.api.augments.Augment;
import com.portingdeadmods.nautec.api.augments.AugmentSlot;
import com.portingdeadmods.nautec.registries.NTAugmentSlots;
import com.portingdeadmods.nautec.registries.NTAugments;
import com.portingdeadmods.nautec.registries.NTKeybinds;
import com.portingdeadmods.nautec.utils.InputUtils;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.phys.Vec3;
import net.neoforged.neoforge.event.tick.PlayerTickEvent;
import org.jetbrains.annotations.Nullable;

import static com.portingdeadmods.nautec.utils.MathUtils.*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
package com.portingdeadmods.nautec.content.augments;

import com.mojang.blaze3d.platform.InputConstants;
import com.portingdeadmods.nautec.Nautec;
import com.portingdeadmods.nautec.api.augments.Augment;
import com.portingdeadmods.nautec.api.augments.AugmentSlot;
import com.portingdeadmods.nautec.content.entites.ThrownBouncingTrident;
import com.portingdeadmods.nautec.network.KeyPressedPayload;
import com.portingdeadmods.nautec.registries.NTAugmentSlots;
import com.portingdeadmods.nautec.registries.NTAugments;
import com.portingdeadmods.nautec.registries.NTKeybinds;
import com.portingdeadmods.nautec.utils.AugmentHelper;
import com.portingdeadmods.nautec.utils.InputUtils;
import net.minecraft.world.item.Items;
import net.neoforged.neoforge.event.tick.PlayerTickEvent;
import net.neoforged.neoforge.network.PacketDistributor;
import org.jetbrains.annotations.Nullable;

// TODO: Implement this
public class ThrowBouncingTridentAugment extends Augment {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package com.portingdeadmods.nautec.content.augments;

import com.mojang.blaze3d.platform.InputConstants;
import com.portingdeadmods.nautec.api.augments.Augment;
import com.portingdeadmods.nautec.api.augments.AugmentSlot;
import com.portingdeadmods.nautec.network.KeyPressedPayload;
import com.portingdeadmods.nautec.registries.NTAugmentSlots;
import com.portingdeadmods.nautec.registries.NTAugments;
import com.portingdeadmods.nautec.registries.NTKeybinds;
import com.portingdeadmods.nautec.utils.InputUtils;
import net.minecraft.core.Holder;
import net.minecraft.world.entity.projectile.ThrownPotion;
import net.minecraft.world.item.ItemStack;
Expand All @@ -17,7 +14,6 @@
import net.minecraft.world.item.alchemy.Potions;
import net.neoforged.neoforge.event.tick.PlayerTickEvent;
import net.neoforged.neoforge.network.PacketDistributor;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
package com.portingdeadmods.nautec.content.blockentities;

import com.portingdeadmods.nautec.Nautec;
import com.portingdeadmods.nautec.api.blockentities.LaserBlockEntity;
import com.portingdeadmods.nautec.api.items.IPowerItem;
import com.portingdeadmods.nautec.capabilities.IOActions;
import com.portingdeadmods.nautec.capabilities.NTCapabilities;
import com.portingdeadmods.nautec.capabilities.power.IPowerStorage;
import com.portingdeadmods.nautec.registries.NTBlockEntityTypes;
import com.portingdeadmods.nautec.utils.ParticlesUtils;
import com.portingdeadmods.nautec.utils.ParticleUtils;
import it.unimi.dsi.fastutil.Pair;
import it.unimi.dsi.fastutil.objects.ObjectSet;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.neoforged.neoforge.capabilities.BlockCapability;
import net.neoforged.neoforge.capabilities.Capabilities;
import net.neoforged.neoforge.items.IItemHandler;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -58,7 +51,7 @@ public void commonTick() {
IPowerStorage powerStorage = itemHandler.getStackInSlot(0).getCapability(NTCapabilities.PowerStorage.ITEM);
if(powerStorage.getPowerStored() < powerStorage.getPowerCapacity()) {
powerStorage.tryFillPower(4, false);
ParticlesUtils.spawnParticlesAroundBlock(getBlockPos(), getLevel(), ParticleTypes.ELECTRIC_SPARK);
ParticleUtils.spawnParticlesAroundBlock(getBlockPos(), getLevel(), ParticleTypes.ELECTRIC_SPARK);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ protected void buildRecipes(@NotNull RecipeOutput pRecipeOutput) {

private static void aquaticCatalystRecipes(@NotNull RecipeOutput pRecipeOutput) {
AquaticCatalystChannelingRecipeBuilder.newRecipe(Ingredient.of(Items.KELP))
.powerAmount(500)
.powerAmount(700)
.purity(0)
.duration(100)
.save(pRecipeOutput);
AquaticCatalystChannelingRecipeBuilder.newRecipe(Ingredient.of(NTTags.Items.CORALS))
.powerAmount(1400)
.powerAmount(2000)
.purity(0.4f)
.duration(200)
.save(pRecipeOutput);
Expand Down
73 changes: 2 additions & 71 deletions src/main/java/com/portingdeadmods/nautec/events/NTEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,16 @@
import com.portingdeadmods.nautec.compat.modonomicon.ModonomiconCompat;
import com.portingdeadmods.nautec.content.commands.arguments.AugmentSlotArgumentType;
import com.portingdeadmods.nautec.content.commands.arguments.AugmentTypeArgumentType;
import com.portingdeadmods.nautec.content.recipes.ItemEtchingRecipe;
import com.portingdeadmods.nautec.data.NTDataAttachments;
import com.portingdeadmods.nautec.data.NTDataComponents;
import com.portingdeadmods.nautec.data.NTDataComponentsUtils;
import com.portingdeadmods.nautec.events.helper.ItemEtching;
import com.portingdeadmods.nautec.events.helper.ItemInfusion;
import com.portingdeadmods.nautec.network.SyncAugmentPayload;
import com.portingdeadmods.nautec.registries.*;
import com.portingdeadmods.nautec.utils.AugmentHelper;
import com.portingdeadmods.nautec.utils.ParticlesUtils;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import net.minecraft.ChatFormatting;
import net.minecraft.core.Registry;
import net.minecraft.core.component.DataComponentType;
import net.minecraft.core.component.DataComponents;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer;
Expand All @@ -38,13 +31,7 @@
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.component.CustomData;
import net.minecraft.world.item.component.ItemContainerContents;
import net.minecraft.world.item.component.SeededContainerLoot;
import net.minecraft.world.item.crafting.RecipeHolder;
import net.minecraft.world.item.crafting.SingleRecipeInput;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.ModList;
import net.neoforged.fml.common.EventBusSubscriber;
Expand All @@ -59,22 +46,20 @@

import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;

public final class NTEvents {

@EventBusSubscriber(modid = Nautec.MODID, bus = EventBusSubscriber.Bus.GAME)
public static class Game {
private static final Object2IntMap<ItemEntity> activeTransformations = new Object2IntOpenHashMap<>();

@SubscribeEvent
public static void onItemEntityTick(EntityTickEvent.Post event) {
if (event.getEntity() instanceof ItemEntity itemEntity) {
Level level = itemEntity.level();

if (itemEntity.isInFluidType(NTFluidTypes.ETCHING_ACID_FLUID_TYPE.get())) {
processItemEtching(itemEntity, level);
ItemEtching.processItemEtching(itemEntity, level);
}

if (itemEntity.isInFluidType(NTFluidTypes.EAS_FLUID_TYPE.get()) || level.getBlockState(itemEntity.blockPosition().below()).getFluidState().is(NTFluids.EAS_SOURCE.get())) {
Expand Down Expand Up @@ -175,60 +160,6 @@ public static void onRightClick(PlayerInteractEvent.RightClickItem event) {
}
}
}

private static void processItemEtching(ItemEntity itemEntity, Level level) {
ItemStack stack = itemEntity.getItem();

if (!activeTransformations.containsKey(itemEntity)) {
Optional<ItemEtchingRecipe> optionalRecipe = getEtchingRecipe(stack, level);
if (optionalRecipe.isPresent()) {
activeTransformations.put(itemEntity, 0);
}
} else {
int etchingTime = activeTransformations.getInt(itemEntity);

if (etchingTime >= 100) {
Optional<ItemEtchingRecipe> optionalRecipe = getEtchingRecipe(stack, level);
if (optionalRecipe.isPresent()) {
transformItem(itemEntity, optionalRecipe.get(), level);
}
activeTransformations.removeInt(itemEntity);
} else {
activeTransformations.put(itemEntity, etchingTime + 1);
// Optionally spawn particles while etching
ParticlesUtils.spawnParticlesAroundItem(itemEntity, level, ParticleTypes.FLAME);
}
}
}

private static Optional<ItemEtchingRecipe> getEtchingRecipe(ItemStack stack, Level level) {
return level.getRecipeManager()
.getRecipeFor(ItemEtchingRecipe.Type.INSTANCE, new SingleRecipeInput(stack), level)
.map(RecipeHolder::value);
}

private static void transformItem(ItemEntity itemEntity, ItemEtchingRecipe recipe, Level level) {
Vec3 position = itemEntity.position();
ItemStack inputStack = itemEntity.getItem();
ItemStack resultStack = recipe.getResultItem(level.registryAccess()).copy();
resultStack.setCount(itemEntity.getItem().getCount());

if(inputStack.is(NTBlocks.RUSTY_CRATE.asItem()) && resultStack.is(NTBlocks.CRATE.asItem())) {
for (DataComponentType<?> type : itemEntity.getItem().getComponents().keySet()) {
Nautec.LOGGER.debug("Type: {}", BuiltInRegistries.DATA_COMPONENT_TYPE.getKey(type));
}
ItemContainerContents value = itemEntity.getItem().copy().get(DataComponents.CONTAINER);
resultStack.set(DataComponents.CONTAINER, value);
SeededContainerLoot value1 = itemEntity.getItem().copy().get(DataComponents.CONTAINER_LOOT);
resultStack.set(DataComponents.CONTAINER_LOOT, value1);
}

itemEntity.discard();

ItemEntity newItemEntity = new ItemEntity(level, position.x, position.y, position.z, resultStack);
level.addFreshEntity(newItemEntity);
}

}

@EventBusSubscriber(modid = Nautec.MODID, bus = EventBusSubscriber.Bus.MOD)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package com.portingdeadmods.nautec.events.helper;

import com.portingdeadmods.nautec.Nautec;
import com.portingdeadmods.nautec.content.recipes.ItemEtchingRecipe;
import com.portingdeadmods.nautec.registries.NTBlocks;
import com.portingdeadmods.nautec.utils.ParticleUtils;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import net.minecraft.core.BlockPos;
import net.minecraft.core.component.DataComponentType;
import net.minecraft.core.component.DataComponents;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.component.ItemContainerContents;
import net.minecraft.world.item.component.SeededContainerLoot;
import net.minecraft.world.item.crafting.RecipeHolder;
import net.minecraft.world.item.crafting.SingleRecipeInput;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;

import java.util.Optional;

public class ItemEtching {
private static final Object2IntMap<ItemEntity> activeEtching = new Object2IntOpenHashMap<>();

public static void processItemEtching(ItemEntity itemEntity, Level level) {
ItemStack stack = itemEntity.getItem();

if (!activeEtching.containsKey(itemEntity)) {
Optional<ItemEtchingRecipe> optionalRecipe = getEtchingRecipe(stack, level);
if (optionalRecipe.isPresent()) {
activeEtching.put(itemEntity, 0);
}
} else {
int etchingTime = activeEtching.getInt(itemEntity);

if (etchingTime >= 100) {
Optional<ItemEtchingRecipe> optionalRecipe = getEtchingRecipe(stack, level);
if (optionalRecipe.isPresent()) {
transformItem(itemEntity, optionalRecipe.get(), level);
}
activeEtching.removeInt(itemEntity);
} else {
activeEtching.put(itemEntity, etchingTime + 1);
// Optionally spawn particles while etching
ParticleUtils.spawnParticlesAroundItem(itemEntity, level, ParticleTypes.FLAME);
}
}
}

private static Optional<ItemEtchingRecipe> getEtchingRecipe(ItemStack stack, Level level) {
return level.getRecipeManager()
.getRecipeFor(ItemEtchingRecipe.Type.INSTANCE, new SingleRecipeInput(stack), level)
.map(RecipeHolder::value);
}

private static void transformItem(ItemEntity itemEntity, ItemEtchingRecipe recipe, Level level) {
BlockPos position = itemEntity.getOnPos();
ItemStack inputStack = itemEntity.getItem();
ItemStack resultStack = recipe.getResultItem(level.registryAccess()).copy();
resultStack.setCount(itemEntity.getItem().getCount());

if (inputStack.is(NTBlocks.RUSTY_CRATE.asItem()) && resultStack.is(NTBlocks.CRATE.asItem())) {
ItemContainerContents value = itemEntity.getItem().copy().get(DataComponents.CONTAINER);
resultStack.set(DataComponents.CONTAINER, value);
SeededContainerLoot value1 = itemEntity.getItem().copy().get(DataComponents.CONTAINER_LOOT);
resultStack.set(DataComponents.CONTAINER_LOOT, value1);
}

itemEntity.discard();

int rand = level.random.nextInt(0, 3);
if (rand == 2) {
level.setBlock(itemEntity.getOnPos(), Blocks.AIR.defaultBlockState(), 11);
}

ItemEntity newItemEntity = new ItemEntity(level, position.getX(), position.getY(), position.getZ(), resultStack);
level.addFreshEntity(newItemEntity);
}

}
Loading

0 comments on commit 32ed9b2

Please sign in to comment.