-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(mc1.20.6+) Added rule
vaultBlacklistDisabled
resolved #163
- Loading branch information
1 parent
592932a
commit 7a471c7
Showing
10 changed files
with
178 additions
and
0 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
30 changes: 30 additions & 0 deletions
30
src/main/java/carpettisaddition/mixins/rule/vaultBlacklistDisabled/VaultServerDataMixin.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,30 @@ | ||
/* | ||
* This file is part of the Carpet TIS Addition project, licensed under the | ||
* GNU Lesser General Public License v3.0 | ||
* | ||
* Copyright (C) 2024 Fallen_Breath and contributors | ||
* | ||
* Carpet TIS Addition is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Carpet TIS Addition is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with Carpet TIS Addition. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package carpettisaddition.mixins.rule.vaultBlacklistDisabled; | ||
|
||
import carpettisaddition.utils.compat.DummyClass; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
|
||
@Mixin(DummyClass.class) | ||
public abstract class VaultServerDataMixin | ||
{ | ||
// impl in mc1.20.6+ | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/carpettisaddition/mixins/rule/vaultBlacklistDisabled/VaultSharedDataMixin.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,30 @@ | ||
/* | ||
* This file is part of the Carpet TIS Addition project, licensed under the | ||
* GNU Lesser General Public License v3.0 | ||
* | ||
* Copyright (C) 2024 Fallen_Breath and contributors | ||
* | ||
* Carpet TIS Addition is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Carpet TIS Addition is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with Carpet TIS Addition. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package carpettisaddition.mixins.rule.vaultBlacklistDisabled; | ||
|
||
import carpettisaddition.utils.compat.DummyClass; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
|
||
@Mixin(DummyClass.class) | ||
public abstract class VaultSharedDataMixin | ||
{ | ||
// impl in mc1.20.6+ | ||
} |
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
32 changes: 32 additions & 0 deletions
32
.../main/java/carpettisaddition/mixins/rule/vaultBlacklistDisabled/VaultServerDataMixin.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,32 @@ | ||
package carpettisaddition.mixins.rule.vaultBlacklistDisabled; | ||
|
||
import carpettisaddition.CarpetTISAdditionSettings; | ||
import net.minecraft.block.vault.VaultServerData; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(VaultServerData.class) | ||
public abstract class VaultServerDataMixin | ||
{ | ||
@Inject(method = "markPlayerAsRewarded", at = @At("HEAD"), cancellable = true) | ||
private void vaultBlacklistDisabled_dontAddPlayerToTheBlackList(PlayerEntity player, CallbackInfo ci) | ||
{ | ||
if (CarpetTISAdditionSettings.vaultBlacklistDisabled) | ||
{ | ||
ci.cancel(); | ||
} | ||
} | ||
|
||
@Inject(method = "hasRewardedPlayer", at = @At("HEAD"), cancellable = true) | ||
private void vaultBlacklistDisabled_noOneIsInTheBlacklist(CallbackInfoReturnable<Boolean> cir) | ||
{ | ||
if (CarpetTISAdditionSettings.vaultBlacklistDisabled) | ||
{ | ||
cir.setReturnValue(false); | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
.../main/java/carpettisaddition/mixins/rule/vaultBlacklistDisabled/VaultSharedDataMixin.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,33 @@ | ||
package carpettisaddition.mixins.rule.vaultBlacklistDisabled; | ||
|
||
import carpettisaddition.CarpetTISAdditionSettings; | ||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue; | ||
import net.minecraft.block.vault.VaultSharedData; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
|
||
@Mixin(VaultSharedData.class) | ||
public abstract class VaultSharedDataMixin | ||
{ | ||
/** | ||
* By hooking here instead of {@link net.minecraft.block.vault.VaultServerData#getRewardedPlayers}, | ||
* mods who invokes getRewardedPlayers can still get the unmodified result | ||
*/ | ||
@ModifyExpressionValue( | ||
method = "method_56791", // lambda method in updateConnectedPlayers | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Ljava/util/Set;contains(Ljava/lang/Object;)Z", | ||
remap = false | ||
), | ||
remap = true | ||
) | ||
private static boolean vaultBlacklistDisabled_everyoneCanConnectToAndActivateTheVault(boolean contains) | ||
{ | ||
if (CarpetTISAdditionSettings.vaultBlacklistDisabled) | ||
{ | ||
contains = false; | ||
} | ||
return contains; | ||
} | ||
} |
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