fabric-climbable-api-v1 - Re-implementing minecraft:climbable on 1.15 (#558)

This commit is contained in:
Prospector 2020-04-22 01:41:13 -07:00 committed by GitHub
parent ea0c4fa998
commit ea4672f136
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 120 additions and 1 deletions

View file

@ -12,7 +12,7 @@ plugins {
def ENV = System.getenv()
class Globals {
static def baseVersion = "0.6.0"
static def baseVersion = "0.7.0"
static def mcVersion = "1.15.2"
static def yarnVersion = "+build.1"
}

View file

@ -0,0 +1,7 @@
archivesBaseName = "fabric-climbable-api-v1"
version = getSubprojectVersion(project, "1.0.0")
dependencies {
compile project(path: ':fabric-api-base', configuration: 'dev')
compile project(path: ':fabric-tag-extensions-v0', configuration: 'dev')
}

View file

@ -0,0 +1,30 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.fabricmc.fabric.impl.climbable;
import net.minecraft.block.Block;
import net.minecraft.tag.Tag;
import net.minecraft.util.Identifier;
import net.fabricmc.fabric.api.tag.TagRegistry;
public class FabricClimbableImpl {
public static final Tag<Block> CLIMBABLE = TagRegistry.block(new Identifier("minecraft", "climbable"));
private FabricClimbableImpl() {
}
}

View file

@ -0,0 +1,43 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.fabricmc.fabric.mixin.climbable;
import net.fabricmc.fabric.impl.climbable.FabricClimbableImpl;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.world.World;
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.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
@Mixin(LivingEntity.class)
public abstract class MixinLivingEntity extends Entity {
public MixinLivingEntity(EntityType<?> type, World world) {
super(type, world);
}
@Inject(method = "isClimbing", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;getBlock()Lnet/minecraft/block/Block;"), cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD)
public void onIsClimbing(CallbackInfoReturnable<Boolean> info, BlockState state) {
if (state.matches(FabricClimbableImpl.CLIMBABLE)) {
info.setReturnValue(true);
}
}
}

View file

@ -0,0 +1,11 @@
{
"required": true,
"package": "net.fabricmc.fabric.mixin.climbable",
"compatibilityLevel": "JAVA_8",
"mixins": [
"MixinLivingEntity"
],
"injectors": {
"defaultRequire": 1
}
}

View file

@ -0,0 +1,27 @@
{
"schemaVersion": 1,
"id": "fabric-climbable-api-v1",
"name": "Fabric Climbable API (v1)",
"version": "${version}",
"environment": "*",
"license": "Apache-2.0",
"icon": "assets/fabric-climbable-api-v1/icon.png",
"contact": {
"homepage": "https://fabricmc.net",
"irc": "irc://irc.esper.net:6667/fabric",
"issues": "https://github.com/FabricMC/fabric/issues",
"sources": "https://github.com/FabricMC/fabric"
},
"authors": [
"FabricMC"
],
"depends": {
"fabricloader": ">=0.4.0",
"fabric-tag-extensions-v0": ">=0.1.3",
"minecraft": "<1.16-"
},
"description": "Re-implements the minecraft:climbable tag from 1.16+ back in 1.15",
"mixins": [
"fabric-climbable-api-v1.mixins.json"
]
}

View file

@ -16,6 +16,7 @@ include 'fabric-api-base'
include 'fabric-biomes-v1'
include 'fabric-blockrenderlayer-v1'
include 'fabric-climbable-api-v1'
include 'fabric-commands-v0'
include 'fabric-containers-v0'
include 'fabric-content-registries-v0'