Update to 18w50a

This commit is contained in:
asie 2018-12-12 18:32:59 +01:00
parent 51ad71a355
commit fd8e0b688d
14 changed files with 48 additions and 41 deletions

View file

@ -23,7 +23,7 @@ sourceCompatibility = 1.8
targetCompatibility = 1.8
archivesBaseName = "fabric"
version = "0.1.0"
version = "0.1.1"
def ENV = System.getenv()
version = version + "." + (ENV.BUILD_NUMBER ?: "local")
@ -33,9 +33,9 @@ minecraft {
}
dependencies {
minecraft "com.mojang:minecraft:18w49a"
mappings "net.fabricmc:yarn:18w49a.11"
modCompile "net.fabricmc:fabric-loader:0.2.0.62"
minecraft "com.mojang:minecraft:18w50a"
mappings "net.fabricmc:yarn:18w50a.2"
modCompile "net.fabricmc:fabric-loader:0.2.0.64"
}
apply from: 'https://github.com/FabricMC/fabric-docs/raw/master/gradle/maven.gradle'

View file

@ -25,7 +25,6 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Facing;
import net.minecraft.world.World;
import java.util.List;
@ -33,14 +32,14 @@ import java.util.List;
public class FabricAPI implements ModInitializer {
@Override
public void onInitialize() {
PlayerInteractionEvent.BREAK_BLOCK.register((player, world, hand, pos, facing) -> {
PlayerInteractionEvent.BREAK_BLOCK.register((player, world, hand, pos, direction) -> {
BlockState state = world.getBlockState(pos);
if (state instanceof BreakInteractable) {
if (((BreakInteractable) state).onBreakInteract(state, world, pos, player, hand, facing)) {
if (((BreakInteractable) state).onBreakInteract(state, world, pos, player, hand, direction)) {
return ActionResult.FAILURE;
}
} else if (state.getBlock() instanceof BreakInteractable) {
if (((BreakInteractable) state.getBlock()).onBreakInteract(state, world, pos, player, hand, facing)) {
if (((BreakInteractable) state.getBlock()).onBreakInteract(state, world, pos, player, hand, direction)) {
return ActionResult.FAILURE;
}
}

View file

@ -20,7 +20,7 @@ import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Facing;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
/**
@ -30,5 +30,5 @@ public interface BreakInteractable {
/**
* @return True if the block accepted the interaction and it should no longer be processed.
*/
boolean onBreakInteract(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, Facing facing);
boolean onBreakInteract(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, Direction direction);
}

View file

@ -21,6 +21,7 @@ import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.texture.TextureManager;
import net.minecraft.entity.Entity;
import net.minecraft.resource.ReloadableResourceManager;
import java.util.HashMap;
import java.util.Map;
@ -38,11 +39,13 @@ public class EntityRendererRegistry {
public static final class Context {
private final TextureManager textureManager;
private final ReloadableResourceManager resourceManager;
private final ItemRenderer itemRenderer;
private final Map<Class<? extends Entity>, EntityRenderer<? extends Entity>> rendererMap;
private Context(TextureManager textureManager, ItemRenderer itemRenderer, Map<Class<? extends Entity>, EntityRenderer<? extends Entity>> rendererMap) {
private Context(TextureManager textureManager, ReloadableResourceManager resourceManager, ItemRenderer itemRenderer, Map<Class<? extends Entity>, EntityRenderer<? extends Entity>> rendererMap) {
this.textureManager = textureManager;
this.resourceManager = resourceManager;
this.itemRenderer = itemRenderer;
this.rendererMap = rendererMap;
}
@ -51,6 +54,10 @@ public class EntityRendererRegistry {
return textureManager;
}
public ReloadableResourceManager getResourceManager() {
return resourceManager;
}
public ItemRenderer getItemRenderer() {
return itemRenderer;
}
@ -64,13 +71,13 @@ public class EntityRendererRegistry {
}
public void initialize(EntityRenderDispatcher manager, TextureManager textureManager, ItemRenderer itemRenderer, Map<Class<? extends Entity>, EntityRenderer<? extends Entity>> map) {
public void initialize(EntityRenderDispatcher manager, TextureManager textureManager, ReloadableResourceManager resourceManager, ItemRenderer itemRenderer, Map<Class<? extends Entity>, EntityRenderer<? extends Entity>> map) {
synchronized (renderSupplierMap) {
if (renderManagerMap.containsKey(manager)) {
return;
}
Context context = new Context(textureManager, itemRenderer, map);
Context context = new Context(textureManager, resourceManager, itemRenderer, map);
renderManagerMap.put(manager, context);
for (Class<? extends Entity> c : renderSupplierMap.keySet()) {
map.put(c, renderSupplierMap.get(c).create(manager, context));

View file

@ -22,7 +22,7 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Facing;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
@ -40,7 +40,7 @@ import net.minecraft.world.World;
public final class PlayerInteractionEvent {
@FunctionalInterface
public interface Block {
ActionResult interact(PlayerEntity player, World world, Hand hand, BlockPos pos, Facing facing);
ActionResult interact(PlayerEntity player, World world, Hand hand, BlockPos pos, Direction direction);
}
@FunctionalInterface
@ -50,7 +50,7 @@ public final class PlayerInteractionEvent {
@FunctionalInterface
public interface BlockPositioned {
ActionResult interact(PlayerEntity player, World world, Hand hand, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ);
ActionResult interact(PlayerEntity player, World world, Hand hand, BlockPos pos, Direction direction, float hitX, float hitY, float hitZ);
}
@FunctionalInterface

View file

@ -22,6 +22,7 @@ import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.texture.TextureManager;
import net.minecraft.entity.Entity;
import net.minecraft.resource.ReloadableResourceManager;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
@ -35,8 +36,8 @@ public class MixinEntityRenderManager {
@Shadow
private Map<Class<? extends Entity>, EntityRenderer<? extends Entity>> renderers;
@Inject(method = "<init>(Lnet/minecraft/client/texture/TextureManager;Lnet/minecraft/client/render/item/ItemRenderer;)V", at = @At("RETURN"))
public void init(TextureManager textureManager, ItemRenderer itemRenderer, CallbackInfo info) {
EntityRendererRegistry.INSTANCE.initialize((EntityRenderDispatcher) (Object) this, textureManager, itemRenderer, renderers);
@Inject(method = "<init>(Lnet/minecraft/client/texture/TextureManager;Lnet/minecraft/client/render/item/ItemRenderer;Lnet/minecraft/resource/ReloadableResourceManager;)V", at = @At("RETURN"), require = 0)
public void init(TextureManager textureManager,ItemRenderer itemRenderer, ReloadableResourceManager manager, CallbackInfo info) {
EntityRendererRegistry.INSTANCE.initialize((EntityRenderDispatcher) (Object) this, textureManager, manager, itemRenderer, renderers);
}
}

View file

@ -30,7 +30,7 @@ import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.HitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Facing;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.GameMode;
import net.minecraft.world.World;
@ -51,9 +51,9 @@ public class MixinClientPlayerInteractionManager {
private GameMode gameMode;
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/world/GameMode;isCreative()Z", ordinal = 0), method = "attackBlock", cancellable = true)
public void attackBlock(BlockPos pos, Facing facing, CallbackInfoReturnable<Boolean> info) {
public void attackBlock(BlockPos pos, Direction direction, CallbackInfoReturnable<Boolean> info) {
for (PlayerInteractionEvent.Block handler : ((HandlerList<PlayerInteractionEvent.Block>) PlayerInteractionEvent.ATTACK_BLOCK).getBackingArray()) {
ActionResult result = handler.interact(client.player, client.world, Hand.MAIN, pos, facing);
ActionResult result = handler.interact(client.player, client.world, Hand.MAIN, pos, direction);
if (result != ActionResult.PASS) {
info.setReturnValue(result == ActionResult.SUCCESS);
info.cancel();
@ -63,13 +63,13 @@ public class MixinClientPlayerInteractionManager {
}
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/world/GameMode;isCreative()Z", ordinal = 0), method = "method_2902", cancellable = true)
public void method_2902(BlockPos pos, Facing facing, CallbackInfoReturnable<Boolean> info) {
public void method_2902(BlockPos pos, Direction direction, CallbackInfoReturnable<Boolean> info) {
if (!gameMode.isCreative()) {
return;
}
for (PlayerInteractionEvent.Block handler : ((HandlerList<PlayerInteractionEvent.Block>) PlayerInteractionEvent.ATTACK_BLOCK).getBackingArray()) {
ActionResult result = handler.interact(client.player, client.world, Hand.MAIN, pos, facing);
ActionResult result = handler.interact(client.player, client.world, Hand.MAIN, pos, direction);
if (result != ActionResult.PASS) {
info.setReturnValue(result == ActionResult.SUCCESS);
info.cancel();
@ -79,7 +79,7 @@ public class MixinClientPlayerInteractionManager {
}
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;getStackInHand(Lnet/minecraft/util/Hand;)Lnet/minecraft/item/ItemStack;", ordinal = 0), method = "interactBlock", cancellable = true)
public void interactBlock(ClientPlayerEntity player, ClientWorld world, BlockPos pos, Facing facing, Vec3d vec, Hand hand, CallbackInfoReturnable<ActionResult> info) {
public void interactBlock(ClientPlayerEntity player, ClientWorld world, BlockPos pos, Direction direction, Vec3d vec, Hand hand, CallbackInfoReturnable<ActionResult> info) {
PlayerInteractionEvent.BlockPositioned[] backingArray = ((HandlerList<PlayerInteractionEvent.BlockPositioned>) PlayerInteractionEvent.INTERACT_BLOCK).getBackingArray();
if (backingArray.length > 0) {
float hitX = (float) (vec.x - pos.getX());
@ -87,10 +87,10 @@ public class MixinClientPlayerInteractionManager {
float hitZ = (float) (vec.z - pos.getZ());
for (PlayerInteractionEvent.BlockPositioned handler : backingArray) {
ActionResult result = handler.interact(player, world, hand, pos, facing, hitX, hitY, hitZ);
ActionResult result = handler.interact(player, world, hand, pos, direction, hitX, hitY, hitZ);
if (result != ActionResult.PASS) {
if (result == ActionResult.SUCCESS) {
this.networkHandler.sendPacket(new PlayerInteractBlockServerPacket(pos, facing, hand, hitX, hitY, hitZ));
this.networkHandler.sendPacket(new PlayerInteractBlockServerPacket(pos, direction, hand, hitX, hitY, hitZ));
}
info.setReturnValue(result);
info.cancel();

View file

@ -26,7 +26,7 @@ import net.minecraft.server.network.ServerPlayerInteractionManager;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Facing;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@ -43,9 +43,9 @@ public class MixinServerPlayerInteractionManager {
public ServerPlayerEntity player;
@Inject(at = @At("HEAD"), method = "method_14263", cancellable = true)
public void startBlockBreak(BlockPos pos, Facing facing, CallbackInfo info) {
public void startBlockBreak(BlockPos pos, Direction direction, CallbackInfo info) {
for (PlayerInteractionEvent.Block handler : ((HandlerList<PlayerInteractionEvent.Block>) PlayerInteractionEvent.ATTACK_BLOCK).getBackingArray()) {
ActionResult result = handler.interact(player, world, Hand.MAIN, pos, facing);
ActionResult result = handler.interact(player, world, Hand.MAIN, pos, direction);
if (result != ActionResult.PASS) {
// The client might have broken the block on its side, so make sure to let it know.
this.player.networkHandler.sendPacket(new BlockUpdateClientPacket(world, pos));
@ -56,9 +56,9 @@ public class MixinServerPlayerInteractionManager {
}
@Inject(at = @At("HEAD"), method = "interactBlock", cancellable = true)
public void interactBlock(PlayerEntity player, World world, ItemStack stack, Hand hand, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, CallbackInfoReturnable<ActionResult> info) {
public void interactBlock(PlayerEntity player, World world, ItemStack stack, Hand hand, BlockPos pos, Direction direction, float hitX, float hitY, float hitZ, CallbackInfoReturnable<ActionResult> info) {
for (PlayerInteractionEvent.BlockPositioned handler : ((HandlerList<PlayerInteractionEvent.BlockPositioned>) PlayerInteractionEvent.INTERACT_BLOCK).getBackingArray()) {
ActionResult result = handler.interact(player, world, hand, pos, facing, hitX, hitY, hitZ);
ActionResult result = handler.interact(player, world, hand, pos, direction, hitX, hitY, hitZ);
if (result != ActionResult.PASS) {
info.setReturnValue(result);
info.cancel();

View file

@ -48,10 +48,10 @@ public class MixinBootstrap {
Object o3 = Fluids.EMPTY;
Object o2 = Items.AIR;
((ListenableRegistry<Biome>) Registry.BIOMES).registerListener(new BootstrapBiomeRegistryListener());
((ListenableRegistry<Block>) Registry.BLOCKS).registerListener(new BootstrapBlockRegistryListener());
((ListenableRegistry<Fluid>) Registry.FLUIDS).registerListener(new BootstrapFluidRegistryListener());
((ListenableRegistry<Item>) Registry.ITEMS).registerListener(new BootstrapItemRegistryListener());
((ListenableRegistry<Biome>) Registry.BIOME).registerListener(new BootstrapBiomeRegistryListener());
((ListenableRegistry<Block>) Registry.BLOCK).registerListener(new BootstrapBlockRegistryListener());
((ListenableRegistry<Fluid>) Registry.FLUID).registerListener(new BootstrapFluidRegistryListener());
((ListenableRegistry<Item>) Registry.ITEM).registerListener(new BootstrapItemRegistryListener());
// The packet code is not side-specific, so this is fine!
CustomPayloadPacketRegistry.CLIENT.register(RegistrySyncManager.ID, RegistrySyncManager::receivePacket);

View file

@ -36,7 +36,7 @@ public class MixinBlockColorMap implements IdListUpdater.Container<BlockColorMap
@Inject(method = "create", at = @At("RETURN"))
private static void create(CallbackInfoReturnable<BlockColorMap> info) {
((ListenableRegistry) Registry.BLOCKS).registerListener(new IdListUpdater<Block, BlockColorMapper>((IdListUpdater.Container<BlockColorMapper>) (Object) info.getReturnValue()));
((ListenableRegistry) Registry.BLOCK).registerListener(new IdListUpdater<Block, BlockColorMapper>((IdListUpdater.Container<BlockColorMapper>) (Object) info.getReturnValue()));
}
@Override

View file

@ -37,7 +37,7 @@ public class MixinItemColorMap implements IdListUpdater.Container<ItemColorMappe
@Inject(method = "method_1706", at = @At("RETURN"))
private static void method_1706(BlockColorMap blockMap, CallbackInfoReturnable<ItemColorMap> info) {
((ListenableRegistry) Registry.ITEMS).registerListener(new IdListUpdater<Item, ItemColorMapper>((IdListUpdater.Container<ItemColorMapper>) (Object) info.getReturnValue()));
((ListenableRegistry) Registry.ITEM).registerListener(new IdListUpdater<Item, ItemColorMapper>((IdListUpdater.Container<ItemColorMapper>) (Object) info.getReturnValue()));
}
@Override

View file

@ -47,7 +47,7 @@ public class MixinItemModelMap implements RegistryListener<Item> {
@Inject(method = "<init>", at = @At("RETURN"))
public void onInit(BakedModelManager bakedModelManager, CallbackInfo info) {
((ListenableRegistry<Item>) Registry.ITEMS).registerListener(this);
((ListenableRegistry<Item>) Registry.ITEM).registerListener(this);
}
@Override

View file

@ -33,7 +33,7 @@ public class BootstrapBlockRegistryListener implements RegistryListener<Block> {
public void beforeRegistryRegistration(Registry<Block> registry, int id, Identifier identifier, Block object, boolean isNew) {
// refer net.minecraft.block.Blocks
for (BlockState state : object.getStateFactory().getStates()) {
state.method_11590();
state.initShapeCache();
Block.STATE_IDS.add(state);
}
}

View file

@ -1,7 +1,7 @@
{
"id": "fabric",
"name": "Fabric API",
"version": "0.0.2",
"version": "0.1.1",
"side": "universal",
"description": "Core API module providing key hooks and intercompatibility features.",
"license": "Apache-2.0",