Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
Thepigcat76 committed Dec 23, 2024
2 parents 807e030 + 3a8d799 commit fb15c4e
Show file tree
Hide file tree
Showing 16 changed files with 331 additions and 24 deletions.
1 change: 1 addition & 0 deletions src/main/java/com/portingdeadmods/nautec/NautecClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ private void registerBERenderers(EntityRenderersEvent.RegisterRenderers event) {
event.registerBlockEntityRenderer(NTBlockEntityTypes.ANCHOR.get(), AnchorBERenderer::new);
event.registerBlockEntityRenderer(NTBlockEntityTypes.BACTERIAL_ANALYZER.get(), BacterialAnalyzerBERenderer::new);
event.registerBlockEntityRenderer(NTBlockEntityTypes.FISHING_STATION.get(), FishingStationBERenderer::new);

AugmentLayerRenderer.registerRenderer(NTAugments.DOLPHIN_FIN.get(),
ctx -> new SimpleAugmentRenderer<>(DolphinFinModel::new, DolphinFinModel.LAYER_LOCATION, DolphinFinModel.MATERIAL, true, ctx));
AugmentLayerRenderer.registerRenderer(NTAugments.GUARDIAN_EYE.get(), GuardianEyeRenderer::new);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public interface BacteriaStats {
BacteriaStats copy();

List<Component> statsTooltip();
List<Component> statsTooltipWithMutatorValues();

BacteriaStatsSerializer<?> getSerializer();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.portingdeadmods.nautec.client.screen;

import com.portingdeadmods.nautec.NTConfig;
import com.portingdeadmods.nautec.Nautec;
import com.portingdeadmods.nautec.api.client.screen.NTAbstractContainerScreen;
import com.portingdeadmods.nautec.api.menu.NTAbstractContainerMenu;
Expand Down Expand Up @@ -29,8 +30,9 @@ protected void renderBg(GuiGraphics guiGraphics, float delta, int mouseX, int mo

int progress = menu.blockEntity.getProgress();

int j1 = Mth.ceil(((float) progress / BacterialAnalyzerBlockEntity.MAX_PROGRESS) * 72.0F);
guiGraphics.blitSprite(PROGRESS_ARROW, 72, 24, 0, 0, i + 76, j + 29, j1, 24);
int j1 = Mth.ceil(((float) progress / NTConfig.mutatorCraftingSpeed) * 79.0F);

guiGraphics.blitSprite(PROGRESS_ARROW, 79, 24, 0, 0, i + 47, j + 22, j1, 24);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
import com.mojang.serialization.Codec;
import com.mojang.serialization.MapCodec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import com.portingdeadmods.nautec.Nautec;
import com.portingdeadmods.nautec.api.bacteria.BacteriaStats;
import com.portingdeadmods.nautec.api.bacteria.BacteriaStatsSerializer;
import com.portingdeadmods.nautec.utils.ComponentUtils;
import com.portingdeadmods.nautec.utils.MathUtils;
import com.portingdeadmods.nautec.utils.RNGUtils;
import net.minecraft.ChatFormatting;
import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.codec.ByteBufCodecs;
import net.minecraft.network.codec.StreamCodec;

Expand Down Expand Up @@ -60,6 +64,46 @@ public List<Component> statsTooltip() {
);
}

@Override
public List<Component> statsTooltipWithMutatorValues() {
final MutableComponent arrow = ComponentUtils.colored(" -> ", ChatFormatting.YELLOW);

return List.of(
ComponentUtils.countableStatShow("Growth Rate", growthRate, bacteriaGrowthRateCap)
.append(arrow)
.append(ComponentUtils.colored("[", ChatFormatting.GREEN))
.append(ComponentUtils.statRange(
MathUtils.roundToPrecision(growthRate + (-growthRate / (10 * (1 + mutationResistance))), 2),
MathUtils.roundToPrecision(growthRate + (growthRate / (10 * (1 + mutationResistance))), 2),
bacteriaGrowthRateCap))
.append(ComponentUtils.colored("]", ChatFormatting.GREEN)),
ComponentUtils.countableStatShow("Mutation Resistance", mutationResistance, bacteriaMutationResistanceCap)
.append(arrow)
.append(ComponentUtils.colored("[", ChatFormatting.GREEN))
.append(ComponentUtils.statRange(
MathUtils.roundToPrecision(mutationResistance + 0.05f * (1 - mutationResistance / bacteriaMutationResistanceCap), 2),
MathUtils.roundToPrecision(mutationResistance + 0.1f, 2),
bacteriaMutationResistanceCap))
.append(ComponentUtils.colored("]", ChatFormatting.GREEN)),
ComponentUtils.countableStatShow("Production Rate", productionRate, bacteriaProductionRateCap)
.append(arrow)
.append(ComponentUtils.colored("[", ChatFormatting.GREEN))
.append(ComponentUtils.statRange(
MathUtils.roundToPrecision(productionRate + (-productionRate / (10 * (1 + mutationResistance))), 2),
MathUtils.roundToPrecision(productionRate + (productionRate / (10 * (1 + mutationResistance))), 2),
bacteriaProductionRateCap))
.append(ComponentUtils.colored("]", ChatFormatting.GREEN)),
ComponentUtils.countableStatShow("Lifespan", lifespan, bacteriaLifespanCap)
.append(arrow)
.append(ComponentUtils.colored("[", ChatFormatting.GREEN))
.append(ComponentUtils.statRange(
lifespan + (int) (-lifespan / (1 + mutationResistance)),
lifespan + (int) (lifespan / (1 + mutationResistance)),
bacteriaLifespanCap))
.append(ComponentUtils.colored("]", ChatFormatting.GREEN))
);
}

@Override
public BacteriaStatsSerializer<SimpleBacteriaStats> getSerializer() {
return Serializer.INSTANCE;
Expand All @@ -68,21 +112,26 @@ public BacteriaStatsSerializer<SimpleBacteriaStats> getSerializer() {
@Override
public BacteriaStats rollGrowthRate() {
float newGR = growthRate + (RNGUtils.floatInRangeOf(growthRate) / (10 * (1 + mutationResistance)));
newGR = Math.max(newGR, 0);

newGR = Math.min(newGR, bacteriaGrowthRateCap);

return new SimpleBacteriaStats(newGR, mutationResistance, productionRate, lifespan, color);
}

@Override
public BacteriaStats rollMutationResistance() {
float newMR = mutationResistance + RNGUtils.biasedInRange(0, 0.1f, mutationResistance) / 10 * (bacteriaMutationResistanceCap - mutationResistance);
float newMR = mutationResistance + RNGUtils.biasedInRange(0, 0.1f, mutationResistance / bacteriaMutationResistanceCap) / 10 * (bacteriaMutationResistanceCap - mutationResistance);
newMR = Math.max(newMR, 0);

return new SimpleBacteriaStats(growthRate, newMR, productionRate, lifespan, color);
}

@Override
public BacteriaStats rollProductionRate() {
float newPR = productionRate + RNGUtils.floatInRangeOf(productionRate) / 10 * (1 + mutationResistance);
newPR = Math.max(newPR, 0);

newPR = Math.min(newPR, bacteriaProductionRateCap);

return new SimpleBacteriaStats(growthRate, mutationResistance, newPR, lifespan, color);
Expand All @@ -91,6 +140,8 @@ public BacteriaStats rollProductionRate() {
@Override
public BacteriaStats rollLifespan() {
int newLS = lifespan + (int) (RNGUtils.uniformRandInt(-10, 10) / (1 + mutationResistance));
newLS = Math.max(newLS, 0);

newLS = Math.min(newLS, bacteriaLifespanCap);

return new SimpleBacteriaStats(growthRate, mutationResistance, productionRate, newLS, color);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.portingdeadmods.nautec.content.blockentities;

import com.portingdeadmods.nautec.registries.NTBlockEntityTypes;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.neoforged.neoforge.energy.IEnergyStorage;

public class CreativeEnergySourceBlockEntity extends BlockEntity implements IEnergyStorage {
private static final int MAX_ENERGY = Integer.MAX_VALUE;

public CreativeEnergySourceBlockEntity(BlockPos pos, BlockState blockState) {
super(NTBlockEntityTypes.CREATIVE_ENERGY_SOURCE.get(), pos, blockState);
}

@Override
public int receiveEnergy(int toReceive, boolean simulate) {
return 0;
}

@Override
public int extractEnergy(int toExtract, boolean simulate) {
return toExtract;
}

@Override
public int getEnergyStored() {
return MAX_ENERGY;
}

@Override
public int getMaxEnergyStored() {
return MAX_ENERGY;
}

@Override
public boolean canExtract() {
return true;
}

@Override
public boolean canReceive() {
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package com.portingdeadmods.nautec.content.blockentities;

import com.portingdeadmods.nautec.api.blockentities.LaserBlockEntity;
import com.portingdeadmods.nautec.capabilities.IOActions;
import com.portingdeadmods.nautec.registries.NTBlockEntityTypes;
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.world.level.block.state.BlockState;
import net.neoforged.neoforge.capabilities.BlockCapability;
import net.neoforged.neoforge.energy.IEnergyStorage;
import org.jetbrains.annotations.Nullable;

import java.util.Map;

public class EnergyConverterBlockEntity extends LaserBlockEntity implements IEnergyStorage {
private static final int FE_CONVERSION_RATE = 100;
private int feStored = 0;
private static final int MAX_FE = 100000;

public EnergyConverterBlockEntity(BlockPos blockPos, BlockState blockState) {
super(NTBlockEntityTypes.ENERGY_CONVERTER.get(), blockPos, blockState);
}

@Override
public ObjectSet<Direction> getLaserInputs() {
return ObjectSet.of();
}

@Override
public ObjectSet<Direction> getLaserOutputs() {
return ObjectSet.of(Direction.values());
}

@Override
public <T> Map<Direction, Pair<IOActions, int[]>> getSidedInteractions(BlockCapability<T, @Nullable Direction> capability) {
return Map.of();
}

@Override
public void commonTick() {
if (!level.isClientSide) {
Direction[] directions = Direction.values();
for (Direction direction : directions) {
BlockPos pos = worldPosition.relative(direction);
if (level.getBlockEntity(pos) instanceof LaserBlockEntity laserBlockEntity) {
if (laserBlockEntity.getLaserInputs().contains(direction.getOpposite())) {
int energyToConvert = Math.min(FE_CONVERSION_RATE, feStored);
if (energyToConvert > 0) {
transmitPower(energyToConvert);
feStored -= energyToConvert;
}
}
}
}
}
}
@Override
public int receiveEnergy(int maxReceive, boolean simulate) {
int energyReceived = Math.min(MAX_FE - feStored, maxReceive);
if (!simulate) {
feStored += energyReceived;
}
return energyReceived;
}

@Override
public int extractEnergy(int maxExtract, boolean simulate) {
return 0;
}

@Override
public int getEnergyStored() {
return feStored;
}

@Override
public int getMaxEnergyStored() {
return MAX_FE;
}

@Override
public boolean canExtract() {
return false;
}

@Override
public boolean canReceive() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

import com.portingdeadmods.nautec.NTConfig;
import com.portingdeadmods.nautec.api.bacteria.Bacteria;
import com.portingdeadmods.nautec.api.bacteria.BacteriaInstance;
import com.portingdeadmods.nautec.api.blockentities.LaserBlockEntity;
import com.portingdeadmods.nautec.capabilities.IOActions;
import com.portingdeadmods.nautec.capabilities.NTCapabilities;
import com.portingdeadmods.nautec.content.items.PetriDishItem;
import com.portingdeadmods.nautec.content.menus.MutatorMenu;
import com.portingdeadmods.nautec.data.NTDataComponents;
import com.portingdeadmods.nautec.data.components.ComponentBacteriaStorage;
import com.portingdeadmods.nautec.registries.NTBacterias;
import com.portingdeadmods.nautec.registries.NTBlockEntityTypes;
import com.portingdeadmods.nautec.utils.BacteriaHelper;
import it.unimi.dsi.fastutil.Pair;
Expand Down Expand Up @@ -67,15 +67,14 @@ public void commonTick() {

ItemStack result = extracted.copy();

// Bacteria bacteria = BacteriaHelper.getBacteria(getLevel().getServer().registryAccess(), extracted.get(NTDataComponents.BACTERIA).bacteria());
// bacteria.stats().rollStats();
//
// result.set(NTDataComponents.BACTERIA, new ComponentBacteriaStorage(
// NTBacterias.EMPTY,
// 1
// ));
BacteriaInstance instance = result.get(NTDataComponents.BACTERIA).bacteriaInstance();
BacteriaHelper.rollBacteriaStats(instance);

getItemHandler().insertItem(1, result, false);
result.set(NTDataComponents.BACTERIA, new ComponentBacteriaStorage(instance));

forceInsertItem(1, result, false);

progress = 0;
} else {
progress++;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.portingdeadmods.nautec.content.blocks;

import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.Nullable;

public class CreativeEnergySourceBlock extends Block implements EntityBlock {
public CreativeEnergySourceBlock(Properties properties) {
super(properties);
}

@Override
public @Nullable BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
return null;
}

@Override
protected void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean movedByPiston) {
super.onPlace(state, level, pos, oldState, movedByPiston);
level.scheduleTick(pos, this, 1);
}

@Override
protected void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) {
super.tick(state, level, pos, random);
level.scheduleTick(pos,this,1);
}

@Override
protected boolean triggerEvent(BlockState state, Level level, BlockPos pos, int id, int param) {
super.triggerEvent(state, level, pos, id, param);
BlockEntity be = level.getBlockEntity(pos);
return be != null && be.triggerEvent(id, param);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.portingdeadmods.nautec.content.blocks;

import com.portingdeadmods.nautec.content.blockentities.EnergyConverterBlockEntity;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.Nullable;

public class EnergyConverterBlock extends Block implements EntityBlock {
public EnergyConverterBlock(Properties properties) {
super(properties);
}

@Override
public @Nullable BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
return new EnergyConverterBlockEntity(pos,state);
}
}
Loading

0 comments on commit fb15c4e

Please sign in to comment.