mirror of
https://github.com/FabricMC/fabric.git
synced 2025-03-21 20:50:28 -04:00
update to 18w47a, add FabricBlockBuilder
This commit is contained in:
parent
9273c32d4b
commit
88abb5f006
5 changed files with 236 additions and 3 deletions
|
@ -30,8 +30,8 @@ minecraft {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:18w46a"
|
||||
mappings "net.fabricmc:pomf:18w46a.6"
|
||||
minecraft "com.mojang:minecraft:18w47a"
|
||||
mappings "net.fabricmc:pomf:18w47a.2"
|
||||
modCompile "net.fabricmc:fabric-loader:18w44a-0.1.0.46"
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,137 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2017, 2018 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.helpers;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.util.DyeColor;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.MapColor;
|
||||
import net.minecraft.world.loot.LootTables;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public class FabricBlockBuilder {
|
||||
public interface Delegate {
|
||||
void fabric_setMapColor(MapColor color);
|
||||
void fabric_setCollidable(boolean value);
|
||||
void fabric_setSoundGroup(BlockSoundGroup group);
|
||||
void fabric_setLuminance(int value);
|
||||
void fabric_setHardness(float value);
|
||||
void fabric_setResistance(float value);
|
||||
void fabric_setRandomTicks(boolean value);
|
||||
void fabric_setFriction(float value);
|
||||
void fabric_setDropTable(Identifier id);
|
||||
}
|
||||
|
||||
private final Block.Builder delegate;
|
||||
private final FabricBlockBuilder.Delegate castDelegate;
|
||||
|
||||
protected FabricBlockBuilder(Material material) {
|
||||
delegate = Block.Builder.create(material);
|
||||
castDelegate = (FabricBlockBuilder.Delegate) delegate;
|
||||
}
|
||||
|
||||
protected FabricBlockBuilder(Block base) {
|
||||
delegate = Block.Builder.copy(base);
|
||||
castDelegate = (FabricBlockBuilder.Delegate) delegate;
|
||||
}
|
||||
|
||||
public static FabricBlockBuilder create(Material material) {
|
||||
return new FabricBlockBuilder(material);
|
||||
}
|
||||
|
||||
public static FabricBlockBuilder copy(Block base) {
|
||||
return new FabricBlockBuilder(base);
|
||||
}
|
||||
|
||||
public FabricBlockBuilder setMapColor(MapColor color) {
|
||||
castDelegate.fabric_setMapColor(color);
|
||||
return this;
|
||||
}
|
||||
|
||||
public FabricBlockBuilder setMapColor(DyeColor color) {
|
||||
castDelegate.fabric_setMapColor(color.getMapColor());
|
||||
return this;
|
||||
}
|
||||
|
||||
public FabricBlockBuilder setCollidable(boolean value) {
|
||||
castDelegate.fabric_setCollidable(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public FabricBlockBuilder setSoundGroup(BlockSoundGroup group) {
|
||||
castDelegate.fabric_setSoundGroup(group);
|
||||
return this;
|
||||
}
|
||||
|
||||
public FabricBlockBuilder acceptRandomTicks() {
|
||||
castDelegate.fabric_setRandomTicks(true);
|
||||
return this;
|
||||
}
|
||||
|
||||
public FabricBlockBuilder setLuminance(int value) {
|
||||
castDelegate.fabric_setLuminance(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public FabricBlockBuilder setHardness(float value) {
|
||||
castDelegate.fabric_setHardness(value);
|
||||
castDelegate.fabric_setResistance(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public FabricBlockBuilder setResistance(float value) {
|
||||
castDelegate.fabric_setResistance(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public FabricBlockBuilder setStrength(float hardness, float resistance) {
|
||||
castDelegate.fabric_setHardness(hardness);
|
||||
castDelegate.fabric_setResistance(resistance);
|
||||
return this;
|
||||
}
|
||||
|
||||
public FabricBlockBuilder noDropTable() {
|
||||
castDelegate.fabric_setDropTable(LootTables.EMPTY);
|
||||
return this;
|
||||
}
|
||||
|
||||
public FabricBlockBuilder copyDropTable(Block block) {
|
||||
castDelegate.fabric_setDropTable(block.getDropTableId());
|
||||
return this;
|
||||
}
|
||||
|
||||
public FabricBlockBuilder setDropTable(Identifier id) {
|
||||
castDelegate.fabric_setDropTable(id);
|
||||
return this;
|
||||
}
|
||||
|
||||
public FabricBlockBuilder setFrictionCoefficient(float value) {
|
||||
castDelegate.fabric_setFriction(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Block.Builder build() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
public <T> T build(Function<Block.Builder, T> function) {
|
||||
return function.apply(delegate);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2017, 2018 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.helpers;
|
||||
|
||||
import net.fabricmc.fabric.helpers.FabricBlockBuilder;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.MapColor;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(Block.Builder.class)
|
||||
public class MixinBlockBuilder implements FabricBlockBuilder.Delegate {
|
||||
@Shadow
|
||||
private Material material;
|
||||
@Shadow
|
||||
private MapColor mapColor;
|
||||
@Shadow
|
||||
private boolean collidable;
|
||||
@Shadow
|
||||
private BlockSoundGroup soundGroup;
|
||||
@Shadow
|
||||
private int luminance;
|
||||
@Shadow
|
||||
private float resistance;
|
||||
@Shadow
|
||||
private float hardness;
|
||||
@Shadow
|
||||
private boolean randomTicks;
|
||||
@Shadow
|
||||
private float friction;
|
||||
@Shadow
|
||||
private Identifier dropTableId;
|
||||
|
||||
@Override
|
||||
public void fabric_setMapColor(MapColor color) {
|
||||
mapColor = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fabric_setCollidable(boolean value) {
|
||||
collidable = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fabric_setSoundGroup(BlockSoundGroup group) {
|
||||
soundGroup = group;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fabric_setLuminance(int value) {
|
||||
luminance = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fabric_setHardness(float value) {
|
||||
hardness = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fabric_setResistance(float value) {
|
||||
resistance = Math.max(0.0f, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fabric_setRandomTicks(boolean value) {
|
||||
randomTicks = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fabric_setFriction(float value) {
|
||||
friction = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fabric_setDropTable(Identifier id) {
|
||||
dropTableId = id;
|
||||
}
|
||||
}
|
|
@ -91,7 +91,7 @@ public abstract class MixinIdRegistry<T> implements RemappableRegistry, Listenab
|
|||
Object defaultValue = null;
|
||||
//noinspection ConstantConditions
|
||||
if (registry instanceof DefaultMappedRegistry) {
|
||||
defaultValue = registry.get(((DefaultMappedRegistry) registry).method_10137());
|
||||
defaultValue = registry.get(((DefaultMappedRegistry) registry).getDefaultId());
|
||||
}
|
||||
|
||||
if (!reallocateMissingEntries && !idMap.keySet().equals(registry.keys())) {
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
"compatibilityLevel": "JAVA_8",
|
||||
"mixins": [
|
||||
"commands.MixinServerCommandManager",
|
||||
"helpers.MixinBlockBuilder",
|
||||
"networking.MixinServerPlayNetworkHandler",
|
||||
"networking.MixinSPacketCustomPayload",
|
||||
"registry.MixinBootstrap",
|
||||
|
|
Loading…
Reference in a new issue