Skip to content

Commit

Permalink
prepare for release (#567)
Browse files Browse the repository at this point in the history
* fix: GT tools don't work for making paths, stripping logs, etc

* fix: distillery recipes.

* fix: use correct PSS casing texture

* fix: forgot hoe tilling

* fix: recipes for PSS components

* chore: changelog & version bump

* chore: update LDlib

* reviews
  • Loading branch information
screret authored Nov 21, 2023
1 parent b157c6a commit e538e6d
Show file tree
Hide file tree
Showing 11 changed files with 268 additions and 21 deletions.
14 changes: 10 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# ChangeLog

Version: 1.0.15.a
Version: 1.0.16

* fix crash on startup due to inaccessible method
* fix circuits in parallel recipes
* update EMI ore processing page
* add power substation
* add ore vein diagram
* add fluid vein diagram
* add man-made compass pages for all tools
* add tests for better quality control in the future
* fix ore processing diagram
* fix GT tools not doing the tooltype-specific things like making paths
* fix small distillery recipes
* fix High Power Casing recipe
143 changes: 138 additions & 5 deletions common/src/main/java/com/gregtechceu/gtceu/api/item/GTToolItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,39 @@
import com.gregtechceu.gtceu.client.renderer.item.ToolItemRenderer;
import com.gregtechceu.gtceu.data.recipe.CustomTags;
import com.lowdragmc.lowdraglib.Platform;
import com.mojang.datafixers.util.Pair;
import dev.architectury.injectables.annotations.ExpectPlatform;
import lombok.Getter;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.client.color.item.ItemColor;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.Tag;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.DiggerItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.*;
import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.CampfireBlock;
import net.minecraft.world.level.block.LevelEvent;
import net.minecraft.world.level.block.RotatedPillarBlock;
import net.minecraft.world.level.block.WeatheringCopper;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.gameevent.GameEvent;

import javax.annotation.ParametersAreNonnullByDefault;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Predicate;

/**
* @author KilaBash
Expand Down Expand Up @@ -102,16 +115,136 @@ public InteractionResult onItemUseFirst(ItemStack itemStack, UseOnContext contex
return InteractionResult.PASS;
}

@Override
public InteractionResult useOn(UseOnContext context) {
if (this.toolType == GTToolType.SHOVEL) {
return useShovelOn(context);
} else if (this.toolType == GTToolType.AXE) {
return useAxeOn(context);
} else if (this.toolType == GTToolType.HOE) {
return useHoeOn(context);
}
return InteractionResult.PASS;
}

public InteractionResult useShovelOn(UseOnContext context) {
Level level = context.getLevel();
BlockPos blockPos = context.getClickedPos();
BlockState blockState = level.getBlockState(blockPos);
if (context.getClickedFace() == Direction.DOWN) {
return InteractionResult.PASS;
} else {
Player player = context.getPlayer();
BlockState blockState2 = ShovelItem.FLATTENABLES.get(blockState.getBlock());
BlockState blockState3 = null;
if (blockState2 != null && level.getBlockState(blockPos.above()).isAir()) {
level.playSound(player, blockPos, SoundEvents.SHOVEL_FLATTEN, SoundSource.BLOCKS, 1.0F, 1.0F);
blockState3 = blockState2;
} else if (blockState.getBlock() instanceof CampfireBlock && blockState.getValue(CampfireBlock.LIT)) {
if (!level.isClientSide()) {
level.levelEvent(null, LevelEvent.SOUND_EXTINGUISH_FIRE, blockPos, 0);
}

CampfireBlock.dowse(context.getPlayer(), level, blockPos, blockState);
blockState3 = blockState.setValue(CampfireBlock.LIT, false);
}

if (blockState3 != null) {
if (!level.isClientSide) {
level.setBlock(blockPos, blockState3, 11);
level.gameEvent(GameEvent.BLOCK_CHANGE, blockPos, GameEvent.Context.of(player, blockState3));
if (player != null) {
context.getItemInHand().hurtAndBreak(1, player, p -> p.broadcastBreakEvent(context.getHand()));
}
}

return InteractionResult.sidedSuccess(level.isClientSide);
} else {
return InteractionResult.PASS;
}
}
}

private Optional<BlockState> getStripped(BlockState unstrippedState) {
return Optional.ofNullable(AxeItem.STRIPPABLES.get(unstrippedState.getBlock()))
.map(block -> block.defaultBlockState().setValue(RotatedPillarBlock.AXIS, unstrippedState.getValue(RotatedPillarBlock.AXIS)));
}

public InteractionResult useAxeOn(UseOnContext context) {
Level level = context.getLevel();
BlockPos blockPos = context.getClickedPos();
Player player = context.getPlayer();
BlockState blockState = level.getBlockState(blockPos);
Optional<BlockState> strippable = getStripped(blockState);
Optional<BlockState> cleanable = WeatheringCopper.getPrevious(blockState);
Optional<BlockState> waxable = Optional.ofNullable(HoneycombItem.WAX_OFF_BY_BLOCK.get().get(blockState.getBlock()))
.map(block -> block.withPropertiesOf(blockState));
ItemStack itemStack = context.getItemInHand();
Optional<BlockState> result = Optional.empty();
if (strippable.isPresent()) {
level.playSound(player, blockPos, SoundEvents.AXE_STRIP, SoundSource.BLOCKS, 1.0F, 1.0F);
result = strippable;
} else if (cleanable.isPresent()) {
level.playSound(player, blockPos, SoundEvents.AXE_SCRAPE, SoundSource.BLOCKS, 1.0F, 1.0F);
level.levelEvent(player, LevelEvent.PARTICLES_SCRAPE, blockPos, 0);
result = cleanable;
} else if (waxable.isPresent()) {
level.playSound(player, blockPos, SoundEvents.AXE_WAX_OFF, SoundSource.BLOCKS, 1.0F, 1.0F);
level.levelEvent(player, LevelEvent.PARTICLES_WAX_OFF, blockPos, 0);
result = waxable;
}

if (result.isPresent()) {
if (player instanceof ServerPlayer) {
CriteriaTriggers.ITEM_USED_ON_BLOCK.trigger((ServerPlayer)player, blockPos, itemStack);
}

level.setBlock(blockPos, result.get(), 11);
level.gameEvent(GameEvent.BLOCK_CHANGE, blockPos, GameEvent.Context.of(player, result.get()));
if (player != null) {
itemStack.hurtAndBreak(1, player, p -> p.broadcastBreakEvent(context.getHand()));
}

return InteractionResult.sidedSuccess(level.isClientSide);
} else {
return InteractionResult.PASS;
}
}


public InteractionResult useHoeOn(UseOnContext context) {
Level level = context.getLevel();
BlockPos blockPos = context.getClickedPos();
Pair<Predicate<UseOnContext>, Consumer<UseOnContext>> pair = HoeItem.TILLABLES.get(level.getBlockState(blockPos).getBlock());
if (pair == null) {
return InteractionResult.PASS;
} else {
Predicate<UseOnContext> predicate = pair.getFirst();
Consumer<UseOnContext> consumer = pair.getSecond();
if (predicate.test(context)) {
Player player = context.getPlayer();
level.playSound(player, blockPos, SoundEvents.HOE_TILL, SoundSource.BLOCKS, 1.0F, 1.0F);
if (!level.isClientSide) {
consumer.accept(context);
if (player != null) {
context.getItemInHand().hurtAndBreak(1, player, p -> p.broadcastBreakEvent(context.getHand()));
}
}

return InteractionResult.sidedSuccess(level.isClientSide);
} else {
return InteractionResult.PASS;
}
}
}

@Override
public String getDescriptionId() {
return toolType.getUnlocalizedName();
}

@Override
public Component getDescription() {
//MutableComponent mat = Component.translatable(getTier().material.getUnlocalizedName());
//GTCEu.LOGGER.info(mat.getString());
//GTCEu.LOGGER.info(Component.translatable(toolType.getUnlocalizedName(), mat).getString());
return Component.translatable(toolType.getUnlocalizedName(), getTier().material.getLocalizedName());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1533,9 +1533,9 @@ public static BiConsumer<ItemStack, List<Component>> createTankTooltips(String n
.where('N', GTMachines.SUBSTATION_ENERGY_INPUT_HATCH[EV], Direction.SOUTH)
.where('O', GTMachines.ENERGY_OUTPUT_HATCH[HV], Direction.SOUTH)
.where('T', GTMachines.SUBSTATION_ENERGY_OUTPUT_HATCH[EV], Direction.SOUTH)
.where('M', () -> ConfigHolder.INSTANCE.machines.enableMaintenance
? GTMachines.MAINTENANCE_HATCH.getBlock()
: CASING_PALLADIUM_SUBSTATION.get());
.where('M', ConfigHolder.INSTANCE.machines.enableMaintenance
? GTMachines.MAINTENANCE_HATCH.getBlock().defaultBlockState().setValue(GTMachines.MAINTENANCE_HATCH.get().getRotationState().property, Direction.SOUTH)
: CASING_PALLADIUM_SUBSTATION.get().defaultBlockState());

GTBlocks.PSS_BATTERIES.entrySet().stream()
// filter out empty batteries in example structures, though they are still
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,14 +448,16 @@ public class GTRecipeTypes {
if (recipeBuilder.data.getBoolean("disable_distillery")) return;
if (recipeBuilder.output.containsKey(FluidRecipeCapability.CAP)) {
long EUt = EURecipeCapability.CAP.of(recipeBuilder.tickInput.get(EURecipeCapability.CAP).get(0).getContent());
FluidIngredient input = FluidRecipeCapability.CAP.of(recipeBuilder.input.get(FluidRecipeCapability.CAP).get(0).getContent());
Content inputContent = recipeBuilder.input.get(FluidRecipeCapability.CAP).get(0);
FluidIngredient input = FluidRecipeCapability.CAP.of(inputContent.getContent());
ItemStack[] outputs = recipeBuilder.output.containsKey(ItemRecipeCapability.CAP) ? ItemRecipeCapability.CAP.of(recipeBuilder.output.get(ItemRecipeCapability.CAP).get(0).getContent()).getItems() : null;
ItemStack outputItem = outputs == null || outputs.length == 0 ? ItemStack.EMPTY : outputs[0];
if (input.isEmpty() || input.getStacks().length == 0) return;
if (input.isEmpty()) return;
List<Content> contents = recipeBuilder.output.get(FluidRecipeCapability.CAP);
for (int i = 0; i < contents.size(); ++i) {
FluidIngredient output = FluidRecipeCapability.CAP.of(contents.get(i).getContent());
if (output.isEmpty() || output.getStacks().length == 0) continue;
Content outputContent = contents.get(i);
FluidIngredient output = FluidRecipeCapability.CAP.of(outputContent.getContent());
if (output.isEmpty()) continue;
GTRecipeBuilder builder = DISTILLERY_RECIPES.recipeBuilder(recipeBuilder.id.getPath() + "_to_" + BuiltInRegistries.FLUID.getKey(output.getStacks()[0].getFluid()).getPath()).EUt(Math.max(1, EUt / 4)).circuitMeta(i + 1);

int ratio = RecipeHelper.getRatioForDistillery(input, output, outputItem);
Expand All @@ -471,15 +473,23 @@ public class GTRecipeTypes {
dividedOutputFluid.setAmount(Math.max(1, dividedOutputFluid.getAmount() / ratio));

if (shouldDivide && fluidsDivisible) {
builder.inputFluids(dividedInputFluid)
builder.chance(inputContent.chance)
.tierChanceBoost(inputContent.tierChanceBoost)
.inputFluids(dividedInputFluid)
.chance(outputContent.chance)
.tierChanceBoost(outputContent.tierChanceBoost)
.outputFluids(dividedOutputFluid)
.duration(Math.max(1, recipeDuration / ratio));
} else if (!shouldDivide) {
if (!outputItem.isEmpty()) {
builder.outputItems(outputItem);
}
builder.conditions.addAll(recipeBuilder.conditions);
builder.inputFluids(input)
builder.chance(inputContent.chance)
.tierChanceBoost(inputContent.tierChanceBoost)
.inputFluids(input)
.chance(outputContent.chance)
.tierChanceBoost(outputContent.tierChanceBoost)
.outputFluids(output)
.duration(recipeDuration)
.save(provider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,8 @@ private static void registerAssemblerRecipes(Consumer<FinishedRecipe> provider)
ASSEMBLER_RECIPES.recipeBuilder("casing_stainless_clean").EUt(16).inputItems(plate, StainlessSteel, 6).inputItems(frameGt, StainlessSteel).circuitMeta(6).outputItems(GTBlocks.CASING_STAINLESS_CLEAN.asStack(2)).duration(50).save(provider);
ASSEMBLER_RECIPES.recipeBuilder("casing_titanium_stable").EUt(16).inputItems(plate, Titanium, 6).inputItems(frameGt, Titanium).circuitMeta(6).outputItems(GTBlocks.CASING_TITANIUM_STABLE.asStack(2)).duration(50).save(provider);
ASSEMBLER_RECIPES.recipeBuilder("casing_hsse_sturdy").EUt(16).inputItems(plate, HSSE, 6).inputItems(frameGt, Europium).circuitMeta(6).outputItems(GTBlocks.CASING_HSSE_STURDY.asStack(2)).duration(50).save(provider);
ASSEMBLER_RECIPES.recipeBuilder("casing_palladium_substation").EUt(16).inputItems(plate, Palladium, 6).inputItems(frameGt, Iridium).circuitMeta(6).outputItems(GTBlocks.CASING_PALLADIUM_SUBSTATION.asStack(2)).duration(50).save(provider);

ASSEMBLER_RECIPES.recipeBuilder("casing_ptfe_inert").EUt(16).inputItems(GTBlocks.CASING_STEEL_SOLID.asStack()).inputFluids(Polytetrafluoroethylene.getFluid(216)).circuitMeta(6).outputItems(GTBlocks.CASING_PTFE_INERT.asStack()).duration(50).save(provider);

ASSEMBLER_RECIPES.recipeBuilder("superconducting_coil_luv").EUt(VA[LuV]).inputItems(wireGtDouble, IndiumTinBariumTitaniumCuprate, 32).inputItems(foil, NiobiumTitanium, 32).inputFluids(Trinium.getFluid(GTValues.L * 24)).outputItems(GTBlocks.SUPERCONDUCTING_COIL.asStack()).duration(100).save(provider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ public static void init(Consumer<FinishedRecipe> provider) {

VanillaRecipeHelper.addShapedRecipe(provider, true, "large_chemical_reactor", GTMachines.LARGE_CHEMICAL_REACTOR.asStack(), "CRC", "PMP", "CHC", 'C', CustomTags.HV_CIRCUITS, 'R', ChemicalHelper.get(TagPrefix.rotor, GTMaterials.StainlessSteel), 'P', ChemicalHelper.get(TagPrefix.pipeLargeFluid, GTMaterials.Polytetrafluoroethylene), 'M', GTItems.ELECTRIC_MOTOR_HV.asStack(), 'H', GTMachines.HULL[HV].asStack());

VanillaRecipeHelper.addShapedRecipe(provider, true, "power_substation", GTMachines.POWER_SUBSTATION.asStack(), "LPL", "CBC", "LPL", 'L', GTItems.LAPOTRON_CRYSTAL, 'P', GTItems.POWER_INTEGRATED_CIRCUIT, 'C', CustomTags.LuV_CIRCUITS, 'B', GTBlocks.CASING_PALLADIUM_SUBSTATION.asStack());

if (ConfigHolder.INSTANCE.machines.doProcessingArray) {
VanillaRecipeHelper.addShapedRecipe(provider, true, "processing_array", GTMachines.PROCESSING_ARRAY[GTValues.IV].asStack(), "COC", "RHR", "CPC", 'C', CustomTags.IV_CIRCUITS, 'O', GTItems.TOOL_DATA_ORB.asStack(), 'R', GTItems.ROBOT_ARM_EV.asStack(), 'P', GTBlocks.FLUID_PIPE_BLOCKS.get(TagPrefix.pipeLargeFluid, GTMaterials.StainlessSteel), 'H', GTMachines.HULL[GTValues.EV].asStack());
VanillaRecipeHelper.addShapedRecipe(provider, true, "advanced_processing_array", GTMachines.PROCESSING_ARRAY[GTValues.LuV].asStack(), "RCR", "SPE", "HNH", 'R', GTItems.ROBOT_ARM_LuV.asStack(), 'C', CustomTags.ZPM_CIRCUITS, 'S', GTItems.SENSOR_LuV, 'P', GTMachines.PROCESSING_ARRAY[IV].asStack(), 'E', GTItems.EMITTER_LuV.asStack(), 'H', new UnificationEntry(TagPrefix.plate, GTMaterials.HSSE), 'N', new UnificationEntry(TagPrefix.pipeLargeFluid, GTMaterials.Naquadah));
Expand Down
Loading

0 comments on commit e538e6d

Please sign in to comment.