document deprecations, add FabricBlockBuilder.setMaterialColor, add ServerEvent.START

This commit is contained in:
asie 2018-12-07 13:14:27 +01:00
parent dba0d0c2de
commit 75b640e987
5 changed files with 74 additions and 4 deletions

View file

@ -73,6 +73,10 @@ public final class PlayerInteractionEvent {
public static final HandlerRegistry<EntityPositioned> INTERACT_ENTITY_POSITIONED = new HandlerList<>();
public static final HandlerRegistry<Item> INTERACT_ITEM = new HandlerList<>();
/**
* @deprecated Use {@link #ATTACK_BLOCK ATTACK_BLOCK} instead.
*/
@SuppressWarnings("DeprecatedIsStillUsed")
@Deprecated
public static final HandlerRegistry<Block> BREAK_BLOCK = ATTACK_BLOCK;

View file

@ -0,0 +1,33 @@
/*
* 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.events;
import net.fabricmc.fabric.util.HandlerList;
import net.fabricmc.fabric.util.HandlerRegistry;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.Profiler;
import net.minecraft.world.World;
import java.util.function.Consumer;
public final class ServerEvent {
public static final HandlerRegistry<Consumer<MinecraftServer>> START = new HandlerList<>();
private ServerEvent() {
}
}

View file

@ -81,16 +81,32 @@ public class FabricBlockBuilder {
/* DELEGATE WRAPPERS */
public FabricBlockBuilder setMapColor(MaterialColor color) {
public FabricBlockBuilder setMaterialColor(MaterialColor color) {
castDelegate.fabric_setMapColor(color);
return this;
}
public FabricBlockBuilder setMapColor(DyeColor color) {
public FabricBlockBuilder setMaterialColor(DyeColor color) {
castDelegate.fabric_setMapColor(color.getMaterialColor());
return this;
}
/**
* @deprecated Use {@link #setMaterialColor(MaterialColor) setMaterialColor} instead.
*/
@Deprecated
public FabricBlockBuilder setMapColor(MaterialColor color) {
return setMaterialColor(color);
}
/**
* @deprecated Use {@link #setMaterialColor(DyeColor) setMaterialColor} instead.
*/
@Deprecated
public FabricBlockBuilder setMapColor(DyeColor color) {
return setMaterialColor(color);
}
public FabricBlockBuilder setCollidable(boolean value) {
castDelegate.fabric_setCollidable(value);
return this;

View file

@ -16,11 +16,11 @@
package net.fabricmc.fabric.mixin.events;
import net.fabricmc.fabric.events.ServerEvent;
import net.fabricmc.fabric.events.TickEvent;
import net.fabricmc.fabric.util.HandlerList;
import net.minecraft.class_3689;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.Profiler;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
@ -28,12 +28,21 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.function.BooleanSupplier;
import java.util.function.Consumer;
@Mixin(MinecraftServer.class)
public class MixinMinecraftServer {
@Shadow
private class_3689 profiler;
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;method_3791(Lnet/minecraft/server/ServerMetadata;)V", ordinal = 0), method = "run")
public void afterSetupServer(CallbackInfo info) {
for (Object handler : ((HandlerList<Consumer<MinecraftServer>>) ServerEvent.START).getBackingArray()) {
//noinspection unchecked
((Consumer) handler).accept((Object) this);
}
}
@Inject(at = @At("RETURN"), method = "method_3813")
protected void method_3813(BooleanSupplier var1, CallbackInfo info) {
TickEvent.tick(TickEvent.SERVER, (MinecraftServer) (Object) this, this.profiler);

View file

@ -92,11 +92,19 @@ public final class ToolManager {
return entries.computeIfAbsent(block, (bb) -> new EntryImpl());
}
/**
* @deprecated Use {@link net.fabricmc.fabric.helpers.FabricBlockBuilder FabricBlockBuilder} for your own blocks.
* TODO: Add a way to manipulate the values for non-owned blocks.
*/
@Deprecated
public static void registerBreakByHand(Block block, boolean value) {
get(block).breakByHand(value);
}
/**
* @deprecated Use {@link net.fabricmc.fabric.helpers.FabricBlockBuilder FabricBlockBuilder} for your own blocks.
* TODO: Add a way to manipulate the values for non-owned blocks.
*/
@Deprecated
public static void registerBreakByTool(Block block, Tag<Item> tag, int miningLevel) {
get(block).putBreakByTool(tag, miningLevel);