Skip to content

Commit 38a82a2

Browse files
committed
允许水晶石矿石被精准采集挖掘,以及通过假玩家挖掘
1 parent bbcbd7c commit 38a82a2

File tree

4 files changed

+53
-30
lines changed

4 files changed

+53
-30
lines changed

src/main/java/github/kasuminova/novaeng/common/handler/OreHandler.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,10 @@
66
import github.kasuminova.novaeng.NovaEngineeringCore;
77
import net.minecraft.block.Block;
88
import net.minecraft.block.state.IBlockState;
9-
import net.minecraft.enchantment.EnchantmentHelper;
10-
import net.minecraft.entity.player.EntityPlayer;
119
import net.minecraft.init.Blocks;
12-
import net.minecraft.init.Enchantments;
1310
import net.minecraft.item.ItemBlock;
1411
import net.minecraft.item.ItemStack;
1512
import net.minecraft.util.ResourceLocation;
16-
import net.minecraftforge.common.util.FakePlayer;
1713
import net.minecraftforge.event.world.BlockEvent;
1814
import net.minecraftforge.fml.common.eventhandler.EventPriority;
1915
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@@ -113,8 +109,6 @@ public void onHarvestDropsEvent(BlockEvent.HarvestDropsEvent event) {
113109
drops.add(ore);
114110
}
115111
return;
116-
} else if (registryName != null && registryName.getNamespace().equals("astralsorcery") && hasSilkTouch(event.getHarvester())) {
117-
return;
118112
}
119113

120114
int fortune = event.getFortuneLevel();
@@ -128,12 +122,6 @@ public void onHarvestDropsEvent(BlockEvent.HarvestDropsEvent event) {
128122
}
129123
}
130124

131-
public static boolean hasSilkTouch(EntityPlayer player) {
132-
if (player instanceof FakePlayer)return false;
133-
ItemStack mainHandStack = player.getHeldItemMainhand();
134-
return EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, mainHandStack) != 0;
135-
}
136-
137125
private final static class OreKey {
138126
private final ResourceLocation rl;
139127
private final int meta;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package github.kasuminova.novaeng.mixin.astralsorcery;
2+
3+
import hellfirepvp.astralsorcery.common.block.BlockCustomOre;
4+
import net.minecraft.block.state.IBlockState;
5+
import net.minecraft.entity.player.EntityPlayer;
6+
import net.minecraft.util.math.BlockPos;
7+
import net.minecraft.world.World;
8+
import org.spongepowered.asm.mixin.Mixin;
9+
import org.spongepowered.asm.mixin.injection.At;
10+
import org.spongepowered.asm.mixin.injection.Inject;
11+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
12+
13+
@Mixin(value = BlockCustomOre.class,remap = false)
14+
public class MixinBlockCustomOre {
15+
16+
@Inject(method = "canSilkHarvest",at = @At("HEAD"), cancellable = true)
17+
public void canSilkHarvest(World world, BlockPos pos, IBlockState state, EntityPlayer player, CallbackInfoReturnable<Boolean> cir) {
18+
cir.setReturnValue(true);
19+
}
20+
21+
@Inject(method = "securityCheck",at = @At("HEAD"), cancellable = true)
22+
private void securityCheck(World world, EntityPlayer player, CallbackInfoReturnable<Boolean> cir) {
23+
cir.setReturnValue(!world.isRemote);
24+
}
25+
26+
@Inject(method = "checkSafety",at = @At("HEAD"), cancellable = true)
27+
private void checkSafety(World world, BlockPos pos, CallbackInfoReturnable<Boolean> cir) {
28+
cir.setReturnValue(true);
29+
}
30+
31+
}

src/main/java/github/kasuminova/novaeng/mixin/minecraft/MixinRecipeBookServer.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@
77
import net.minecraft.stats.RecipeBookServer;
88
import org.spongepowered.asm.mixin.Mixin;
99
import org.spongepowered.asm.mixin.Overwrite;
10+
import org.spongepowered.asm.mixin.injection.At;
11+
import org.spongepowered.asm.mixin.injection.Inject;
12+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
1013

11-
import java.util.ArrayList;
14+
import java.util.Collections;
1215
import java.util.List;
1316

1417
@Mixin(value = RecipeBookServer.class)
@@ -55,9 +58,9 @@ public void read(NBTTagCompound tag) {}
5558
* @author circulation
5659
* @reason 废弃原版配方书
5760
*/
58-
@Overwrite
59-
private List<IRecipe> getRecipes() {
60-
return new ArrayList<>();
61+
@Inject(method = "getRecipes",at = @At("HEAD"), cancellable = true)
62+
public void getRecipes(CallbackInfoReturnable<List<IRecipe>> cir) {
63+
cir.setReturnValue(Collections.emptyList());
6164
}
6265

6366
/**
@@ -66,7 +69,7 @@ private List<IRecipe> getRecipes() {
6669
*/
6770
@Overwrite
6871
private List<IRecipe> getDisplayedRecipes() {
69-
return new ArrayList<>();
72+
return Collections.emptyList();
7073
}
7174

7275
/**
Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
{
2-
"package": "github.kasuminova.novaeng.mixin.astralsorcery",
3-
"refmap": "mixins.novaeng_core.refmap.json",
4-
"target": "@env(DEFAULT)",
5-
"minVersion": "0.8",
6-
"compatibilityLevel": "JAVA_8",
7-
"mixins": [
8-
"MixinPlayerAttributeMap"
9-
],
10-
"server": [
11-
"AccessorResearchManager",
12-
"InvokerPerkEffectHelper",
13-
"MixinPlayerProgress"
14-
]
2+
"package": "github.kasuminova.novaeng.mixin.astralsorcery",
3+
"refmap": "mixins.novaeng_core.refmap.json",
4+
"target": "@env(DEFAULT)",
5+
"minVersion": "0.8",
6+
"compatibilityLevel": "JAVA_8",
7+
"mixins": [
8+
"MixinBlockCustomOre",
9+
"MixinPlayerAttributeMap"
10+
],
11+
"server": [
12+
"AccessorResearchManager",
13+
"InvokerPerkEffectHelper",
14+
"MixinPlayerProgress"
15+
]
1516
}

0 commit comments

Comments
 (0)