mirror of
https://github.com/FabricMC/fabric.git
synced 2025-03-25 22:39:50 -04:00
[#177] add FabricMaterialBuilder
This commit is contained in:
parent
76d184ea21
commit
9fe2f882de
4 changed files with 125 additions and 1 deletions
fabric-object-builders-v0
|
@ -1,5 +1,5 @@
|
|||
archivesBaseName = "fabric-object-builders"
|
||||
version = getSubprojectVersion(project, "0.1.0")
|
||||
version = getSubprojectVersion(project, "0.1.1")
|
||||
|
||||
dependencies {
|
||||
compile project(path: ':fabric-api-base', configuration: 'dev')
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* 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.api.block;
|
||||
|
||||
import net.fabricmc.fabric.mixin.builders.MaterialBuilderHooks;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.block.MaterialColor;
|
||||
import net.minecraft.block.piston.PistonBehavior;
|
||||
import net.minecraft.util.DyeColor;
|
||||
|
||||
public class FabricMaterialBuilder extends Material.Builder {
|
||||
public FabricMaterialBuilder(MaterialColor color) {
|
||||
super(color);
|
||||
}
|
||||
|
||||
public FabricMaterialBuilder(DyeColor color) {
|
||||
this(color.getMaterialColor());
|
||||
}
|
||||
|
||||
@Override
|
||||
public FabricMaterialBuilder burnable() {
|
||||
super.burnable();
|
||||
return this;
|
||||
}
|
||||
|
||||
public FabricMaterialBuilder pistonBehavior(PistonBehavior behavior) {
|
||||
((MaterialBuilderHooks) this).setPistonBehavior(behavior);
|
||||
return this;
|
||||
}
|
||||
|
||||
public FabricMaterialBuilder lightPassesThrough() {
|
||||
((MaterialBuilderHooks) this).invokeLightPassesThrough();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FabricMaterialBuilder destroyedByPiston() {
|
||||
super.destroyedByPiston();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FabricMaterialBuilder blocksPistons() {
|
||||
super.blocksPistons();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FabricMaterialBuilder allowsMovement() {
|
||||
super.allowsMovement();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FabricMaterialBuilder liquid() {
|
||||
super.liquid();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material.Builder notSolid() {
|
||||
super.notSolid();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FabricMaterialBuilder replaceable() {
|
||||
super.replaceable();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FabricMaterialBuilder requiresTool() {
|
||||
super.requiresTool();
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* 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.builders;
|
||||
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.block.piston.PistonBehavior;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
@Mixin(Material.Builder.class)
|
||||
public interface MaterialBuilderHooks {
|
||||
@Accessor
|
||||
void setPistonBehavior(PistonBehavior behavior);
|
||||
|
||||
@Invoker
|
||||
Material.Builder invokeLightPassesThrough();
|
||||
}
|
|
@ -4,6 +4,7 @@
|
|||
"compatibilityLevel": "JAVA_8",
|
||||
"mixins": [
|
||||
"BlockSettingsHooks",
|
||||
"MaterialBuilderHooks",
|
||||
"MixinBlock",
|
||||
"MixinItem"
|
||||
],
|
||||
|
|
Loading…
Add table
Reference in a new issue