From 9deaaf9341f5551b2473b2ffb470615028c458c3 Mon Sep 17 00:00:00 2001
From: asie <kontakt@asie.pl>
Date: Wed, 16 Jan 2019 22:41:18 +0100
Subject: [PATCH] 19w03a update

---
 build.gradle                                      |  6 +++---
 .../fabric/entity/FabricEntityTypeBuilder.java    |  9 ++++++++-
 .../fabric/impl/FabricAPIClientInitializer.java   |  2 +-
 .../MixinClientPlayerInteractionManager.java      | 15 ++++++++++-----
 .../fabricmc/fabric/containers/ContainerMod.java  | 14 ++------------
 5 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/build.gradle b/build.gradle
index 87bcc407c..e2a9ad011 100644
--- a/build.gradle
+++ b/build.gradle
@@ -27,7 +27,7 @@ targetCompatibility = 1.8
 archivesBaseName = "fabric"
 
 def baseVersion = "0.1.4"
-def mcVersion = "19w02a"
+def mcVersion = "19w03a"
 
 def ENV = System.getenv()
 version = baseVersion + "." + (ENV.BUILD_NUMBER ?: "local")
@@ -38,8 +38,8 @@ minecraft {
 
 dependencies {
 	minecraft "com.mojang:minecraft:$mcVersion"
-	mappings "net.fabricmc:yarn:$mcVersion.24"
-	modCompile "net.fabricmc:fabric-loader:0.3.2.92"
+	mappings "net.fabricmc:yarn:$mcVersion.3"
+	modCompile "net.fabricmc:fabric-loader:0.3.2.96"
 }
 
 task sourcesJar(type: Jar, dependsOn: classes) {
diff --git a/src/main/java/net/fabricmc/fabric/entity/FabricEntityTypeBuilder.java b/src/main/java/net/fabricmc/fabric/entity/FabricEntityTypeBuilder.java
index 7a67fa4f2..2c015c1c5 100644
--- a/src/main/java/net/fabricmc/fabric/entity/FabricEntityTypeBuilder.java
+++ b/src/main/java/net/fabricmc/fabric/entity/FabricEntityTypeBuilder.java
@@ -32,6 +32,7 @@ public class FabricEntityTypeBuilder<T extends Entity> {
 	private int trackingDistance = -1;
 	private int updateIntervalTicks = -1;
 	private boolean alwaysUpdateVelocity = true;
+	private float width = -1.0f, height = -1.0f;
 
 	protected FabricEntityTypeBuilder(Class<? extends T> entityClass, Function<? super World, ? extends T> function) {
 		this.entityClass = entityClass;
@@ -56,6 +57,12 @@ public class FabricEntityTypeBuilder<T extends Entity> {
 		return this;
 	}
 
+	public FabricEntityTypeBuilder<T> size(float width, float height) {
+		this.width = width;
+		this.height = height;
+		return this;
+	}
+
 	public FabricEntityTypeBuilder<T> trackable(int trackingDistance, int updateIntervalTicks) {
 		return trackable(trackingDistance, updateIntervalTicks, true);
 	}
@@ -78,7 +85,7 @@ public class FabricEntityTypeBuilder<T extends Entity> {
 			// TODO: Flesh out once modded datafixers exist.
 		}
 
-		EntityType<T> type = new EntityType<>(this.entityClass, this.function, this.saveable, this.summonable, null);
+		EntityType<T> type = new EntityType<>(this.entityClass, this.function, this.saveable, this.summonable, null, this.width, this.height);
 		if (trackingDistance != -1) {
 			EntityTrackingRegistry.INSTANCE.register(type, trackingDistance, updateIntervalTicks, alwaysUpdateVelocity);
 		}
diff --git a/src/main/java/net/fabricmc/fabric/impl/FabricAPIClientInitializer.java b/src/main/java/net/fabricmc/fabric/impl/FabricAPIClientInitializer.java
index 3af775235..a94fdd55e 100644
--- a/src/main/java/net/fabricmc/fabric/impl/FabricAPIClientInitializer.java
+++ b/src/main/java/net/fabricmc/fabric/impl/FabricAPIClientInitializer.java
@@ -28,7 +28,7 @@ public class FabricAPIClientInitializer implements ClientModInitializer {
 	public void onInitializeClient() {
 		CustomPayloadPacketRegistry.CLIENT.register(RegistrySyncManager.ID, (ctx, buf) -> {
 			// if not hosting server, apply packet
-			RegistrySyncManager.receivePacket(ctx, buf, !MinecraftClient.getInstance().method_1496());
+			RegistrySyncManager.receivePacket(ctx, buf, !MinecraftClient.getInstance().isInSingleplayer());
 		});
 
 		((GuiProviderImpl)GuiProviderImpl.INSTANCE).init();
diff --git a/src/main/java/net/fabricmc/fabric/mixin/events/playerinteraction/MixinClientPlayerInteractionManager.java b/src/main/java/net/fabricmc/fabric/mixin/events/playerinteraction/MixinClientPlayerInteractionManager.java
index ee9d139dc..ea5d7b8a9 100644
--- a/src/main/java/net/fabricmc/fabric/mixin/events/playerinteraction/MixinClientPlayerInteractionManager.java
+++ b/src/main/java/net/fabricmc/fabric/mixin/events/playerinteraction/MixinClientPlayerInteractionManager.java
@@ -18,6 +18,8 @@ package net.fabricmc.fabric.mixin.events.playerinteraction;
 
 import net.fabricmc.fabric.events.PlayerInteractionEvent;
 import net.fabricmc.fabric.util.HandlerArray;
+import net.minecraft.class_3965;
+import net.minecraft.class_3966;
 import net.minecraft.client.MinecraftClient;
 import net.minecraft.client.network.ClientPlayNetworkHandler;
 import net.minecraft.client.network.ClientPlayerEntity;
@@ -30,7 +32,6 @@ import net.minecraft.server.network.packet.PlayerInteractEntityServerPacket;
 import net.minecraft.server.network.packet.PlayerInteractItemServerPacket;
 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.Direction;
 import net.minecraft.util.math.Vec3d;
@@ -81,9 +82,13 @@ 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, Direction direction, Vec3d vec, Hand hand, CallbackInfoReturnable<ActionResult> info) {
+	public void interactBlock(ClientPlayerEntity player, ClientWorld world, Hand hand, class_3965 blockHitResult, CallbackInfoReturnable<ActionResult> info) {
 		PlayerInteractionEvent.BlockPositioned[] backingArray = ((HandlerArray<PlayerInteractionEvent.BlockPositioned>) PlayerInteractionEvent.INTERACT_BLOCK).getBackingArray();
 		if (backingArray.length > 0) {
+			Vec3d vec = blockHitResult.method_17784();
+			BlockPos pos = blockHitResult.method_17777();
+			Direction direction = blockHitResult.method_17780();
+
 			float hitX = (float) (vec.x - pos.getX());
 			float hitY = (float) (vec.y - pos.getY());
 			float hitZ = (float) (vec.z - pos.getZ());
@@ -92,7 +97,7 @@ public class MixinClientPlayerInteractionManager {
 				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, direction, hand, hitX, hitY, hitZ));
+						this.networkHandler.sendPacket(new PlayerInteractBlockServerPacket(hand, blockHitResult));
 					}
 					info.setReturnValue(result);
 					info.cancel();
@@ -132,9 +137,9 @@ public class MixinClientPlayerInteractionManager {
 	}
 
 	@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;sendPacket(Lnet/minecraft/network/Packet;)V", ordinal = 0), method = "interactEntityAtLocation", cancellable = true)
-	public void interactEntityAtLocation(PlayerEntity player, Entity entity, HitResult hitResult, Hand hand, CallbackInfoReturnable<ActionResult> info) {
+	public void interactEntityAtLocation(PlayerEntity player, Entity entity, class_3966 hitResult, Hand hand, CallbackInfoReturnable<ActionResult> info) {
 		// TODO: Remove double Vec3d creation?
-		Vec3d hitVec = new Vec3d(hitResult.pos.x - entity.x, hitResult.pos.y - entity.y, hitResult.pos.z - entity.z);
+		Vec3d hitVec = hitResult.method_17784().subtract(entity.x, entity.y, entity.z);
 
 		for (PlayerInteractionEvent.EntityPositioned handler : ((HandlerArray<PlayerInteractionEvent.EntityPositioned>) PlayerInteractionEvent.INTERACT_ENTITY_POSITIONED).getBackingArray()) {
 			ActionResult result = handler.interact(player, player.getEntityWorld(), hand, entity, hitVec);
diff --git a/src/test/java/net/fabricmc/fabric/containers/ContainerMod.java b/src/test/java/net/fabricmc/fabric/containers/ContainerMod.java
index 2ad7b818a..44e51b065 100644
--- a/src/test/java/net/fabricmc/fabric/containers/ContainerMod.java
+++ b/src/test/java/net/fabricmc/fabric/containers/ContainerMod.java
@@ -69,17 +69,12 @@ public class ContainerMod implements ModInitializer {
 		BlockPos pos;
 
 		public ExampleContainer(int syncId, BlockPos pos, PlayerEntity playerEntity) {
-			super(syncId);
+			super(null, syncId);
 			this.pos = pos;
 			this.playerInventory = playerEntity.inventory;
 			System.out.println("Opened container, " + pos);
 		}
 
-		@Override
-		public ContainerType<?> getType() {
-			return null;
-		}
-
 		@Override
 		public boolean canUse(PlayerEntity playerEntity) {
 			return true;
@@ -91,7 +86,7 @@ public class ContainerMod implements ModInitializer {
 		BlockPos pos;
 
 		public ExampleInventoryContainer(int syncId, PlayerEntity playerEntity) {
-			super(syncId);
+			super(null, syncId);
 			this.playerInventory = playerEntity.inventory;
 			for(int i = 0; i < 3; ++i) {
 				for(int j = 0; j < 9; ++j) {
@@ -104,11 +99,6 @@ public class ContainerMod implements ModInitializer {
 			}
 		}
 
-		@Override
-		public ContainerType<?> getType() {
-			return null;
-		}
-
 		@Override
 		public boolean canUse(PlayerEntity playerEntity) {
 			return true;