19w03a update

This commit is contained in:
asie 2019-01-16 22:41:18 +01:00
parent dfbf5fe3d0
commit 9deaaf9341
5 changed files with 24 additions and 22 deletions
build.gradle
src
main/java/net/fabricmc/fabric
test/java/net/fabricmc/fabric/containers

View file

@ -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) {

View file

@ -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);
}

View file

@ -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();

View file

@ -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);

View file

@ -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;