-
-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
1,071 additions
and
1 deletion.
There are no files selected for viewing
Submodule SpongeAPI
updated
2 files
+1 −0 | build.gradle.kts | |
+79 −0 | src/main/java/org/spongepowered/api/event/lifecycle/RegisterTagEvent.java |
73 changes: 73 additions & 0 deletions
73
forge/src/mixins/java/org/spongepowered/forge/mixin/core/tags/TagLoaderMixin_Forge.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,73 @@ | ||
/* | ||
* This file is part of Sponge, licensed under the MIT License (MIT). | ||
* | ||
* Copyright (c) SpongePowered <https://www.spongepowered.org> | ||
* Copyright (c) contributors | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
package org.spongepowered.forge.mixin.core.tags; | ||
|
||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation; | ||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; | ||
import com.llamalad7.mixinextras.sugar.Local; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.tags.TagEntry; | ||
import net.minecraft.tags.TagLoader; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Coerce; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import org.spongepowered.common.bridge.tags.TagLoaderBridge; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.function.Consumer; | ||
|
||
@Mixin(TagLoader.class) | ||
public abstract class TagLoaderMixin_Forge<T> implements TagLoaderBridge<T> { | ||
|
||
@WrapOperation(method = "build(Lnet/minecraft/tags/TagEntry$Lookup;Ljava/util/List;)Lcom/mojang/datafixers/util/Either;", | ||
at = @At(value = "INVOKE", target = "Lnet/minecraft/tags/TagEntry;build(Lnet/minecraft/tags/TagEntry$Lookup;Ljava/util/function/Consumer;)Z")) | ||
protected boolean forge$onBuildTag(final TagEntry instance, final TagEntry.Lookup<T> lookup, final Consumer<T> consumer, final Operation<Boolean> original, | ||
final TagEntry.Lookup<T> $$0, final List<TagLoader.EntryWithSource> $$1, final @Local TagLoader.EntryWithSource entry) { | ||
if (entry.remove()) { | ||
return original.call(instance, lookup, consumer); | ||
} | ||
return this.bridge$acceptTag(instance, lookup, consumer, original::call, $$1, entry); | ||
} | ||
|
||
@Inject(method = "lambda$build$6", at = @At("HEAD")) | ||
private void forge$onStartBuildingTag(final TagEntry.Lookup<T> $$0x, final Map<ResourceLocation, Collection<T>> $$1x, final ResourceLocation $$2x, | ||
final @Coerce Object $$3x, final CallbackInfo ci) { | ||
this.bridge$buildingTagKey($$2x); | ||
} | ||
|
||
@Inject(method = "lambda$build$6", at = @At("RETURN")) | ||
private void forge$onDoneBuildingTag(final CallbackInfo ci) { | ||
this.bridge$buildingTagKey(null); | ||
} | ||
|
||
@Override | ||
public boolean bridge$isAdd(final TagLoader.EntryWithSource entry) { | ||
return !entry.remove(); | ||
} | ||
} |
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
73 changes: 73 additions & 0 deletions
73
...e/src/mixins/java/org/spongepowered/neoforge/mixin/core/tags/TagLoaderMixin_NeoForge.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,73 @@ | ||
/* | ||
* This file is part of Sponge, licensed under the MIT License (MIT). | ||
* | ||
* Copyright (c) SpongePowered <https://www.spongepowered.org> | ||
* Copyright (c) contributors | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
package org.spongepowered.neoforge.mixin.core.tags; | ||
|
||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation; | ||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; | ||
import com.llamalad7.mixinextras.sugar.Local; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.tags.TagEntry; | ||
import net.minecraft.tags.TagLoader; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Coerce; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import org.spongepowered.common.bridge.tags.TagLoaderBridge; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.function.Consumer; | ||
|
||
@Mixin(TagLoader.class) | ||
public abstract class TagLoaderMixin_NeoForge<T> implements TagLoaderBridge<T> { | ||
|
||
@WrapOperation(method = "build(Lnet/minecraft/tags/TagEntry$Lookup;Ljava/util/List;)Lcom/mojang/datafixers/util/Either;", | ||
at = @At(value = "INVOKE", target = "Lnet/minecraft/tags/TagEntry;build(Lnet/minecraft/tags/TagEntry$Lookup;Ljava/util/function/Consumer;)Z")) | ||
protected boolean neo$onBuildTag(final TagEntry instance, final TagEntry.Lookup<T> lookup, final Consumer<T> consumer, final Operation<Boolean> original, | ||
final TagEntry.Lookup<T> $$0, final List<TagLoader.EntryWithSource> $$1, final @Local TagLoader.EntryWithSource entry) { | ||
if (entry.remove()) { | ||
return original.call(instance, lookup, consumer); | ||
} | ||
return this.bridge$acceptTag(instance, lookup, consumer, original::call, $$1, entry); | ||
} | ||
|
||
@Inject(method = "lambda$build$6", at = @At("HEAD")) | ||
private void neo$onStartBuildingTag(final TagEntry.Lookup<T> $$0x, final Map<ResourceLocation, Collection<T>> $$1x, final ResourceLocation $$2x, | ||
final @Coerce Object $$3x, final CallbackInfo ci) { | ||
this.bridge$buildingTagKey($$2x); | ||
} | ||
|
||
@Inject(method = "lambda$build$6", at = @At("RETURN")) | ||
private void neo$onDoneBuildingTag(final CallbackInfo ci) { | ||
this.bridge$buildingTagKey(null); | ||
} | ||
|
||
@Override | ||
public boolean bridge$isAdd(final TagLoader.EntryWithSource entry) { | ||
return !entry.remove(); | ||
} | ||
} |
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
38 changes: 38 additions & 0 deletions
38
src/accessors/java/org/spongepowered/common/accessor/tags/TagEntryAccessor.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,38 @@ | ||
/* | ||
* This file is part of Sponge, licensed under the MIT License (MIT). | ||
* | ||
* Copyright (c) SpongePowered <https://www.spongepowered.org> | ||
* Copyright (c) contributors | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
package org.spongepowered.common.accessor.tags; | ||
|
||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.tags.TagEntry; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Accessor; | ||
|
||
@Mixin(TagEntry.class) | ||
public interface TagEntryAccessor { | ||
|
||
@Accessor("id") ResourceLocation accessor$id(); | ||
|
||
@Accessor("tag") boolean accessor$tag(); | ||
} |
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
34 changes: 34 additions & 0 deletions
34
...in/java/org/spongepowered/common/bridge/server/packs/resources/ResourceManagerBridge.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,34 @@ | ||
/* | ||
* This file is part of Sponge, licensed under the MIT License (MIT). | ||
* | ||
* Copyright (c) SpongePowered <https://www.spongepowered.org> | ||
* Copyright (c) contributors | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
package org.spongepowered.common.bridge.server.packs.resources; | ||
|
||
import org.spongepowered.common.tag.SpongePluginTags; | ||
|
||
public interface ResourceManagerBridge { | ||
|
||
void bridge$pluginProvidedTags(SpongePluginTags pluginTags); | ||
|
||
SpongePluginTags bridge$pluginProvidedTags(); | ||
} |
52 changes: 52 additions & 0 deletions
52
src/main/java/org/spongepowered/common/bridge/tags/TagLoaderBridge.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,52 @@ | ||
/* | ||
* This file is part of Sponge, licensed under the MIT License (MIT). | ||
* | ||
* Copyright (c) SpongePowered <https://www.spongepowered.org> | ||
* Copyright (c) contributors | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
package org.spongepowered.common.bridge.tags; | ||
|
||
import net.minecraft.core.RegistryAccess; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.tags.TagEntry; | ||
import net.minecraft.tags.TagLoader; | ||
import org.checkerframework.checker.nullness.qual.Nullable; | ||
|
||
import java.util.List; | ||
import java.util.function.Consumer; | ||
|
||
public interface TagLoaderBridge<T> { | ||
|
||
void bridge$registryEntry(RegistryAccess.RegistryEntry<T> registryEntry); | ||
|
||
void bridge$buildingTagKey(@Nullable ResourceLocation key); | ||
|
||
default boolean bridge$isAdd(final TagLoader.EntryWithSource entry) { | ||
return true; | ||
} | ||
|
||
boolean bridge$acceptTag(TagEntry instance, TagEntry.Lookup<T> lookup, Consumer<T> consumer, | ||
final AcceptTag<T> original, List<TagLoader.EntryWithSource> tags, TagLoader.EntryWithSource entry); | ||
|
||
interface AcceptTag<T> { | ||
boolean accept(TagEntry instance, TagEntry.Lookup<T> lookup, Consumer<T> consumer); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/org/spongepowered/common/bridge/tags/TagLoader_EntryWithSourceBridge.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,37 @@ | ||
/* | ||
* This file is part of Sponge, licensed under the MIT License (MIT). | ||
* | ||
* Copyright (c) SpongePowered <https://www.spongepowered.org> | ||
* Copyright (c) contributors | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
package org.spongepowered.common.bridge.tags; | ||
|
||
import org.checkerframework.checker.nullness.qual.Nullable; | ||
import org.spongepowered.common.tag.SpongePluginTagPredicate; | ||
|
||
import java.util.Set; | ||
|
||
public interface TagLoader_EntryWithSourceBridge { | ||
|
||
void bridge$predicates(Set<SpongePluginTagPredicate<?>> predicates); | ||
|
||
@Nullable Set<SpongePluginTagPredicate<?>> bridge$predicates(); | ||
} |
Oops, something went wrong.