-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
forge still not working for some stupid reason
- Loading branch information
1 parent
745f89e
commit bf8a3b7
Showing
13 changed files
with
175 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
common/src/main/java/net/anawesomguy/breakingbedrock/BedrockBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package net.anawesomguy.breakingbedrock; | ||
|
||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.TieredItem; | ||
import net.minecraft.world.level.BlockGetter; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
|
||
import static net.anawesomguy.breakingbedrock.BreakingBedrock.getBedrockDestroyTime; | ||
import static net.anawesomguy.breakingbedrock.BreakingBedrock.getBedrockExplosionResist; | ||
|
||
public class BedrockBlock extends Block { | ||
public BedrockBlock(Properties properties) { | ||
super(properties.strength(getBedrockDestroyTime(), getBedrockExplosionResist())); | ||
} | ||
|
||
@Override @SuppressWarnings("deprecation") | ||
public float getDestroyProgress(BlockState state, Player player, BlockGetter level, BlockPos pos) { | ||
return player.getInventory().getSelected().getItem() instanceof TieredItem item && item.getTier().getLevel() > 3 ? | ||
player.getDestroySpeed(state) / state.getDestroySpeed(level, pos) / 100F : | ||
0F; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 7 additions & 11 deletions
18
common/src/main/java/net/anawesomguy/breakingbedrock/mixin/BlocksMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,18 @@ | ||
package net.anawesomguy.breakingbedrock.mixin; | ||
|
||
import net.anawesomguy.breakingbedrock.BreakingBedrock; | ||
import net.anawesomguy.breakingbedrock.BedrockBlock; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.Blocks; | ||
import net.minecraft.world.level.block.state.BlockBehaviour.Properties; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Constant; | ||
import org.spongepowered.asm.mixin.injection.ModifyConstant; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
import org.spongepowered.asm.mixin.injection.Slice; | ||
|
||
@Mixin(Blocks.class) | ||
public abstract class BlocksMixin { | ||
@ModifyConstant(method = "<clinit>", constant = @Constant(floatValue = -1F, ordinal = 0), slice = @Slice(from = @At(value = "FIELD", target = "Lnet/minecraft/world/level/block/Blocks;BEDROCK:Lnet/minecraft/world/level/block/Block;"))) | ||
private static float bedrockBreaking$modifyBedrockDestroyTime(float constant) { | ||
return BreakingBedrock.getBedrockDestroyTime(); | ||
} | ||
|
||
@ModifyConstant(method = "<clinit>", constant = @Constant(floatValue = -1F, ordinal = 1), slice = @Slice(from = @At(value = "FIELD", target = "Lnet/minecraft/world/level/block/Blocks;BEDROCK:Lnet/minecraft/world/level/block/Block;"))) | ||
private static float bedrockBreaking$modifyBedrockExplosionResist(float constant) { | ||
return BreakingBedrock.getBedrockExplosionResist(); | ||
@Redirect(method = "<clinit>", at = @At(value = "NEW", target = "(Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)Lnet/minecraft/world/level/block/Block;"), slice = @Slice(from = @At(value = "CONSTANT", args = "stringValue=bedrock"))) | ||
private static Block breakingbedrock$replaceBedrock(Properties properties) { | ||
return new BedrockBlock(properties); | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 3 additions & 58 deletions
61
fabric/src/main/java/net/anawesomguy/breakingbedrock/fabric/BreakingBedrockImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,11 @@ | ||
package net.anawesomguy.breakingbedrock.fabric; | ||
|
||
import net.anawesomguy.breakingbedrock.BreakingBedrock; | ||
import net.fabricmc.loader.api.FabricLoader; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
import java.util.Properties; | ||
import java.nio.file.Path; | ||
|
||
public final class BreakingBedrockImpl { | ||
public static final float BEDROCK_DESTROY_TIME; | ||
public static final float BEDROCK_EXPLOSION_RESIST; | ||
|
||
static { | ||
File configFile = FabricLoader.getInstance().getConfigDir().resolve(BreakingBedrock.MOD_ID + ".properties").toFile(); | ||
Properties properties = new Properties(); | ||
float destroyTime, explosionResist; | ||
try { | ||
Properties temp = new Properties(); | ||
temp.load(new FileInputStream(configFile)); | ||
String time = temp.getProperty("bedrockDestroyTime"), | ||
resist = temp.getProperty("bedrockExplosionResist"); | ||
destroyTime = Float.parseFloat(time); | ||
explosionResist = Float.parseFloat(resist); | ||
boolean timeBounds = !(destroyTime > -1) || Float.isInfinite(destroyTime), | ||
resistBounds = !(explosionResist > 0) || Float.isInfinite(destroyTime); | ||
if (timeBounds) { | ||
properties.setProperty("bedrockDestroyTime", "60"); | ||
destroyTime = 60; | ||
} else properties.setProperty("bedrockDestroyTime", time); | ||
if (resistBounds) { | ||
properties.setProperty("bedrockDestroyTime", "3600000"); | ||
explosionResist = 3600000; | ||
} else properties.setProperty("bedrockDestroyTime", resist); | ||
} catch (IOException | IllegalArgumentException e) { | ||
BreakingBedrock.LOGGER.info("Could not read config file (likely corrupted or missing)! Attempting to (re)create it."); | ||
properties.setProperty("bedrockDestroyTime", "60"); | ||
properties.setProperty("bedrockExplosionResist", "3600000"); | ||
explosionResist = 60; | ||
destroyTime = 3600000; | ||
} | ||
|
||
BEDROCK_EXPLOSION_RESIST = explosionResist; | ||
BEDROCK_DESTROY_TIME = destroyTime; | ||
|
||
try { | ||
properties.store(new FileOutputStream(configFile), | ||
""" | ||
bedrockDestroyTime: The destroy time for bedrock, allows decimals. (obsidian is 50, stone is 1.5, use -1 to make it indestructible) | ||
bedrockExplosionResist: The explosion resistance for bedrock, allows decimals. (stone is 6, glass is 0.3) | ||
"""); | ||
} catch (IOException e) { | ||
BreakingBedrock.LOGGER.error("Unable to create/modify config file!", e); | ||
} | ||
} | ||
|
||
public static float getBedrockDestroyTime() { | ||
return BEDROCK_DESTROY_TIME; | ||
} | ||
|
||
public static float getBedrockExplosionResist() { | ||
return BEDROCK_EXPLOSION_RESIST; | ||
public static Path configDir() { | ||
return FabricLoader.getInstance().getConfigDir(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,6 @@ | |
], | ||
"depends": { | ||
"fabric": "*", | ||
"minecraft": ">=20w12a" | ||
"minecraft": ">=1.16-alpha.20.12.a" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 5 additions & 26 deletions
31
forge/src/main/java/net/anawesomguy/breakingbedrock/forge/BreakingBedrockImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,14 @@ | ||
package net.anawesomguy.breakingbedrock.forge; | ||
|
||
import net.anawesomguy.breakingbedrock.BreakingBedrock; | ||
import net.minecraftforge.common.ForgeConfigSpec; | ||
import net.minecraftforge.fml.ModLoadingContext; | ||
import net.minecraftforge.fml.common.Mod; | ||
import net.minecraftforge.fml.config.ModConfig; | ||
import net.minecraftforge.fml.loading.FMLPaths; | ||
|
||
import java.nio.file.Path; | ||
|
||
@Mod(BreakingBedrock.MOD_ID) | ||
public final class BreakingBedrockImpl { | ||
public static final ForgeConfigSpec CONFIG_SPEC; | ||
public static final ForgeConfigSpec.DoubleValue BEDROCK_DESTROY_TIME; | ||
public static final ForgeConfigSpec.DoubleValue BEDROCK_EXPLOSION_RESIST; | ||
|
||
static { | ||
ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder(); | ||
BEDROCK_DESTROY_TIME = builder.comment("The destroy time for bedrock, allows decimals. (obsidian is 50, stone is 1.5, use -1 to make it indestructible)") | ||
.defineInRange("bedrockDestroyTime", 60, -1, Float.MAX_VALUE); | ||
BEDROCK_EXPLOSION_RESIST = builder.comment("The explosion resistance for bedrock, allows decimals. (stone is 6, glass is 0.3)") | ||
.defineInRange("bedrockExplosionResist", 3600000, 0, Float.MAX_VALUE); | ||
CONFIG_SPEC = builder.build(); | ||
} | ||
|
||
public BreakingBedrockImpl() { | ||
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, CONFIG_SPEC); | ||
} | ||
|
||
public static float getBedrockDestroyTime() { | ||
return BEDROCK_DESTROY_TIME.get().floatValue(); | ||
} | ||
|
||
public static float getBedrockExplosionResist() { | ||
return BEDROCK_EXPLOSION_RESIST.get().floatValue(); | ||
public static Path configDir() { | ||
return FMLPaths.CONFIGDIR.get(); | ||
} | ||
} |
5 changes: 0 additions & 5 deletions
5
forge/src/main/resources/data/forge/tags/items/needs_netherite_tool.json
This file was deleted.
Oops, something went wrong.