Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create 0.5.1 - 1.19.2 #14

Open
wants to merge 2 commits into
base: 1.19
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ apply plugin: 'net.minecraftforge.gradle'
// MixinGradle:
apply plugin: 'org.spongepowered.mixin'

version = '1.1.6'
version = '1.1.7'
group = 'com.latenighters.infinidrill' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'infinidrill'

Expand Down Expand Up @@ -181,8 +181,9 @@ dependencies {
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html

implementation fg.deobf("curse.maven:create-328085:4371809")

implementation fg.deobf("com.simibubi.create:create-1.19.2:0.5.1.b-30:slim") { transitive = false }
implementation fg.deobf("com.jozufozu.flywheel:flywheel-forge-1.19.2:0.6.8.a-14")
implementation fg.deobf("com.tterrag.registrate:Registrate:MC1.19-1.1.5")
}

// Example for how to get properties into the manifest for reading at runtime.
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/com/latenighters/infinidrill/InfiniDrillConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class InfiniDrillConfig{
public static final ForgeConfigSpec GENERAL_SPEC;
private static ForgeConfigSpec.IntValue infiniteOreThreshold;
private static ForgeConfigSpec.IntValue searchRadius;
private static ForgeConfigSpec.ConfigValue<String> canBeInfiniteTag;
private static ForgeConfigSpec.ConfigValue<List<? extends String>> blacklistedOreNames;
private static ForgeConfigSpec.ConfigValue<List<? extends String>> equivalentOres;

Expand All @@ -38,6 +39,10 @@ public class InfiniDrillConfig{
}

private static void setupConfig(ForgeConfigSpec.Builder builder) {
canBeInfiniteTag = builder
.comment("Block tag that can be drilled infinitely.",
"It is assumed to always be ores, but you can set it to any block tag you want and it will work.")
.define("can_be_infinite_tag", "forge:ores");
infiniteOreThreshold = builder
.comment("When the number of ores in a 5x5 chunk goes above this number, the vein is infinite")
.defineInRange("infinite_ore_threshold", 6000, 0, 1000000);
Expand Down Expand Up @@ -117,6 +122,11 @@ public static List<TagKey<Block>> getTagsFor(BlockState blockState){
return retval;
}

public static boolean canBeInfinite(BlockState state) {
String tagString = canBeInfiniteTag.get();
return tagString.contains(":") && state.is(BlockTags.create(new ResourceLocation(tagString)));
}

public static Integer getInfiniteOreThreshold() {
return infiniteOreThreshold.get();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.latenighters.infinidrill.capabilities;

import com.latenighters.infinidrill.InfiniDrillConfig;
import com.latenighters.infinidrill.network.PacketHandler;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
Expand All @@ -9,7 +10,6 @@
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraftforge.common.Tags;
import net.minecraftforge.common.util.INBTSerializable;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.event.level.BlockEvent;
Expand Down Expand Up @@ -62,7 +62,7 @@ public void markOrePlaced(BlockPos pos) {
@SubscribeEvent
public static void onBlockPlace(BlockEvent.EntityPlaceEvent event){
//if(event.getWorld().isClientSide()) return;
if(!event.getPlacedBlock().is(Tags.Blocks.ORES)) return;
if(!InfiniDrillConfig.canBeInfinite(event.getPlacedBlock())) return;

ServerLevel level = (ServerLevel) event.getLevel();
LevelChunk chunk = level.getChunkAt(event.getPos());
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/latenighters/infinidrill/mixin/MixinDrill.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.latenighters.infinidrill.InfiniDrillConfig;
import com.latenighters.infinidrill.capabilities.CapabilityOreCounter;
import com.simibubi.create.content.contraptions.components.actors.BlockBreakingKineticTileEntity;
import com.simibubi.create.content.contraptions.components.actors.DrillTileEntity;
import com.simibubi.create.content.kinetics.base.BlockBreakingKineticBlockEntity;
import com.simibubi.create.content.kinetics.drill.DrillBlockEntity;
import com.simibubi.create.foundation.item.TooltipHelper;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.VecHelper;
Expand All @@ -29,8 +29,8 @@
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;

@Mixin(DrillTileEntity.class)
public abstract class MixinDrill extends BlockBreakingKineticTileEntity {
@Mixin(DrillBlockEntity.class)
public abstract class MixinDrill extends BlockBreakingKineticBlockEntity {

private Boolean isInfiniteState;

Expand All @@ -50,7 +50,7 @@ public boolean addToGoggleTooltip(List<Component> tooltip, boolean isPlayerSneak
this.isInfinite().ifPresent(isCurrentlyInfinite->{
if(isCurrentlyInfinite)
TooltipHelper.addHint(tooltip, "hint.infinite_drill");
if(isPlayerSneaking && level.getBlockState(this.breakingPos).is(Tags.Blocks.ORES)){
if(isPlayerSneaking && InfiniDrillConfig.canBeInfinite(level.getBlockState(this.breakingPos))){
this.containedChunk().getCapability(CapabilityOreCounter.COUNTER).ifPresent(oreCap -> {

Block target = level.getBlockState(this.breakingPos).getBlock();
Expand Down Expand Up @@ -139,7 +139,7 @@ private LazyOptional<Boolean> isInfinite(){
else if(InfiniDrillConfig.getBlacklistedOres().contains(this.level.getBlockState(this.breakingPos).getBlock()))
infinite.set(LazyOptional.of(()->false));

else if(!this.level.getBlockState(this.breakingPos).is(Tags.Blocks.ORES))
else if(!InfiniDrillConfig.canBeInfinite(this.level.getBlockState(this.breakingPos)))
infinite.set(LazyOptional.of(()->false));

else{
Expand Down