update to 19w05a

This commit is contained in:
asie 2019-01-30 19:07:33 +01:00
parent 0beca7f877
commit f1fa5cfd3c
8 changed files with 58 additions and 36 deletions

View file

@ -27,7 +27,7 @@ targetCompatibility = 1.8
archivesBaseName = "fabric"
def baseVersion = "0.1.5"
def mcVersion = "19w04b"
def mcVersion = "19w05a"
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.1"
modCompile "net.fabricmc:fabric-loader:0.3.3.101"
mappings "net.fabricmc:yarn:$mcVersion.3"
modCompile "net.fabricmc:fabric-loader:0.3.4.104"
}
task sourcesJar(type: Jar, dependsOn: classes) {

View file

@ -16,12 +16,12 @@
package net.fabricmc.fabric.api.client.gui;
import net.minecraft.client.gui.ContainerGui;
import net.minecraft.client.gui.ContainerScreen;
import net.minecraft.container.Container;
@FunctionalInterface
public interface GuiFactory<C extends Container> {
ContainerGui create(C container);
ContainerScreen create(C container);
}

View file

@ -19,7 +19,7 @@ package net.fabricmc.fabric.api.client.gui;
import net.fabricmc.fabric.api.container.ContainerFactory;
import net.fabricmc.fabric.api.container.ContainerProviderRegistry;
import net.fabricmc.fabric.impl.client.gui.GuiProviderImpl;
import net.minecraft.client.gui.ContainerGui;
import net.minecraft.client.gui.ContainerScreen;
import net.minecraft.container.Container;
import net.minecraft.util.Identifier;
@ -29,7 +29,7 @@ public interface GuiProviderRegistry {
/**
*
* Register a "Container -> ContainerGui" factory. This is used only on the client side.
* Register a "Container -> ContainerScreen" factory. This is used only on the client side.
*
* @param identifier a shared identifier, this identifier should also be used to register a container using {@link ContainerProviderRegistry}
* @param guiFactory the supplier that should be used to create the new gui
@ -38,12 +38,12 @@ public interface GuiProviderRegistry {
/**
*
* Register a "packet -> ContainerGui" factory. This is used only on the client side, and allows you
* Register a "packet -> ContainerScreen" factory. This is used only on the client side, and allows you
* to override the default behaviour of re-using the existing "packet -> Container" logic.
*
* @param identifier a shared identifier, this identifier should also be used to register a container using {@link ContainerProviderRegistry}
* @param factory the gui factory, this should return a new {@link ContainerGui}
* @param factory the gui factory, this should return a new {@link ContainerScreen}
*/
void registerFactory(Identifier identifier, ContainerFactory<ContainerGui> factory);
void registerFactory(Identifier identifier, ContainerFactory<ContainerScreen> factory);
}

View file

@ -18,7 +18,7 @@ package net.fabricmc.fabric.client.itemgroup;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.ingame.CreativePlayerInventoryGui;
import net.minecraft.client.gui.ingame.CreativePlayerInventoryScreen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.item.ItemGroup;
@ -42,14 +42,14 @@ public class FabricCreativeGuiComponents {
public static class ItemGroupButtonWidget extends ButtonWidget {
CreativeGuiExtensions extensions;
CreativePlayerInventoryGui gui;
CreativePlayerInventoryScreen gui;
Type type;
public ItemGroupButtonWidget(int id, int x, int y, Type type, CreativeGuiExtensions extensions) {
super(id, x, y, 10, 11, type.text);
this.extensions = extensions;
this.type = type;
this.gui = (CreativePlayerInventoryGui) extensions;
this.gui = (CreativePlayerInventoryScreen) extensions;
}
@Override

View file

@ -17,15 +17,19 @@
package net.fabricmc.fabric.entity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityCategory;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.EntityType.Builder;
import net.minecraft.world.World;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.function.Function;
// TODO: javadocs
public class FabricEntityTypeBuilder<T extends Entity> {
private final Class<? extends T> entityClass;
private static final Logger LOGGER = LogManager.getLogger();
private final EntityCategory category;
private final Function<? super World, ? extends T> function;
private boolean saveable = true;
private boolean summonable = true;
@ -34,19 +38,37 @@ public class FabricEntityTypeBuilder<T extends Entity> {
private boolean alwaysUpdateVelocity = true;
private float width = -1.0f, height = -1.0f;
@Deprecated
protected FabricEntityTypeBuilder(Class<? extends T> entityClass, Function<? super World, ? extends T> function) {
this.entityClass = entityClass;
LOGGER.warn("[FabricEntityTypeBuilder] Please specify EntityCategory for " + entityClass.getName() + "!");
this.category = EntityCategory.MISC;
this.function = function;
}
protected FabricEntityTypeBuilder(EntityCategory category, Function<? super World, ? extends T> function) {
this.category = category;
this.function = function;
}
@Deprecated
public static <T extends Entity> FabricEntityTypeBuilder<T> create(Class<? extends T> entityClass) {
return new FabricEntityTypeBuilder<>(entityClass, (w) -> null);
}
@Deprecated
public static <T extends Entity> FabricEntityTypeBuilder<T> create(Class<? extends T> entityClass, Function<? super World, ? extends T> function) {
LOGGER.warn("[FabricEntityTypeBuilder] Please specify EntityCategory for " + entityClass.getName() + "!");
return new FabricEntityTypeBuilder<>(entityClass, function);
}
public static <T extends Entity> FabricEntityTypeBuilder<T> create(EntityCategory category) {
return new FabricEntityTypeBuilder<>(category, (w) -> null);
}
public static <T extends Entity> FabricEntityTypeBuilder<T> create(EntityCategory category, Function<? super World, ? extends T> function) {
return new FabricEntityTypeBuilder<>(category, function);
}
public FabricEntityTypeBuilder<T> disableSummon() {
this.summonable = false;
return this;
@ -85,7 +107,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, this.width, this.height);
EntityType<T> type = new EntityType<T>(this.function, this.category, this.saveable, this.summonable, null, this.width, this.height);
if (trackingDistance != -1) {
EntityTrackingRegistry.INSTANCE.register(type, trackingDistance, updateIntervalTicks, alwaysUpdateVelocity);
}

View file

@ -23,7 +23,7 @@ import net.fabricmc.fabric.api.client.gui.GuiFactory;
import net.fabricmc.fabric.impl.container.ContainerProviderImpl;
import net.fabricmc.fabric.networking.CustomPayloadPacketRegistry;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.ContainerGui;
import net.minecraft.client.gui.ContainerScreen;
import net.minecraft.container.Container;
import net.minecraft.util.Identifier;
import org.apache.logging.log4j.LogManager;
@ -42,9 +42,9 @@ public class GuiProviderImpl implements GuiProviderRegistry {
private static final Logger LOGGER = LogManager.getLogger();
private static final Identifier OPEN_CONTAINER = new Identifier("fabric", "open_container");
private static final Map<Identifier, ContainerFactory<ContainerGui>> FACTORIES = new HashMap<>();
private static final Map<Identifier, ContainerFactory<ContainerScreen>> FACTORIES = new HashMap<>();
public void registerFactory(Identifier identifier, ContainerFactory<ContainerGui> factory) {
public void registerFactory(Identifier identifier, ContainerFactory<ContainerScreen> factory) {
if (FACTORIES.containsKey(identifier)) {
throw new RuntimeException("A factory has already been registered as " + identifier + "!");
}
@ -68,14 +68,14 @@ public class GuiProviderImpl implements GuiProviderRegistry {
Identifier identifier = packetByteBuf.readIdentifier();
int syncId = packetByteBuf.readUnsignedByte();
MinecraftClient.getInstance().execute(() -> {
ContainerFactory<ContainerGui> factory = FACTORIES.get(identifier);
ContainerFactory<ContainerScreen> factory = FACTORIES.get(identifier);
if (factory == null) {
LOGGER.error("No GUI factory found for {}!", identifier.toString());
return;
}
ContainerGui gui = factory.create(syncId, identifier, packetContext.getPlayer(), packetByteBuf);
ContainerScreen gui = factory.create(syncId, identifier, packetContext.getPlayer(), packetByteBuf);
packetContext.getPlayer().container = gui.getContainer();
MinecraftClient.getInstance().openGui(gui);
MinecraftClient.getInstance().openScreen(gui);
});
});
}

View file

@ -18,8 +18,8 @@ package net.fabricmc.fabric.mixin.client.itemgroup;
import net.fabricmc.fabric.client.itemgroup.CreativeGuiExtensions;
import net.fabricmc.fabric.client.itemgroup.FabricCreativeGuiComponents;
import net.minecraft.client.gui.ingame.AbstractPlayerInventoryGui;
import net.minecraft.client.gui.ingame.CreativePlayerInventoryGui;
import net.minecraft.client.gui.ingame.AbstractPlayerInventoryScreen;
import net.minecraft.client.gui.ingame.CreativePlayerInventoryScreen;
import net.minecraft.container.Container;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.ItemGroup;
@ -31,8 +31,8 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(CreativePlayerInventoryGui.class)
public abstract class MixinCreativePlayerInventoryGui extends AbstractPlayerInventoryGui implements CreativeGuiExtensions {
@Mixin(CreativePlayerInventoryScreen.class)
public abstract class MixinCreativePlayerInventoryGui extends AbstractPlayerInventoryScreen implements CreativeGuiExtensions {
public MixinCreativePlayerInventoryGui(Container container_1, PlayerInventory playerInventory_1, TextComponent textComponent_1) {
super(container_1, playerInventory_1, textComponent_1);

View file

@ -19,7 +19,7 @@ package net.fabricmc.fabric.containers;
import com.mojang.blaze3d.platform.GlStateManager;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.gui.GuiProviderRegistry;
import net.minecraft.client.gui.ContainerGui;
import net.minecraft.client.gui.ContainerScreen;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.text.StringTextComponent;
import net.minecraft.util.Identifier;
@ -32,22 +32,22 @@ public class ContainerModClient implements ClientModInitializer {
//Registers a gui factory that opens our example gui, this reads the block pos from the buffer
GuiProviderRegistry.INSTANCE.registerFactory(ContainerMod.EXAMPLE_CONTAINER, (syncId, identifier, player, buf) -> {
BlockPos pos = buf.readBlockPos();
return new ExampleContainerGui(syncId, pos, player);
return new ExampleContainerScreen(syncId, pos, player);
});
//Registers a gui factory that opens our example gui, this uses the container created by ContainerProviderRegistry
GuiProviderRegistry.INSTANCE.registerFactory(ContainerMod.EXAMPLE_CONTAINER_2, ExampleContainerGui2::new);
GuiProviderRegistry.INSTANCE.registerFactory(ContainerMod.EXAMPLE_CONTAINER_2, ExampleContainerScreen2::new);
//Registers a gui factory that opens our example inventory gui
GuiProviderRegistry.INSTANCE.registerFactory(ContainerMod.EXAMPLE_INVENTORY_CONTAINER, ExampleInventoryContainerGui::new);
GuiProviderRegistry.INSTANCE.registerFactory(ContainerMod.EXAMPLE_INVENTORY_CONTAINER, ExampleInventoryContainerScreen::new);
}
//A container gui that shows the block pos that was sent
public static class ExampleContainerGui extends ContainerGui<ContainerMod.ExampleContainer> {
public static class ExampleContainerScreen extends ContainerScreen<ContainerMod.ExampleContainer> {
BlockPos pos;
public ExampleContainerGui(int syncId, BlockPos pos, PlayerEntity playerEntity) {
public ExampleContainerScreen(int syncId, BlockPos pos, PlayerEntity playerEntity) {
super(new ContainerMod.ExampleContainer(syncId, pos, playerEntity), playerEntity.inventory, new StringTextComponent("Example GUI"));
this.pos = pos;
}
@ -60,11 +60,11 @@ public class ContainerModClient implements ClientModInitializer {
//A container gui that shows how you can take in a container provided by a GuiFactory
public static class ExampleContainerGui2 extends ContainerGui<ContainerMod.ExampleContainer> {
public static class ExampleContainerScreen2 extends ContainerScreen<ContainerMod.ExampleContainer> {
BlockPos pos;
public ExampleContainerGui2(ContainerMod.ExampleContainer container) {
public ExampleContainerScreen2(ContainerMod.ExampleContainer container) {
super(container, container.playerInventory, new StringTextComponent("Example GUI 2"));
this.pos = container.pos;
}
@ -76,11 +76,11 @@ public class ContainerModClient implements ClientModInitializer {
}
//A container gui that has the player's inventory
public static class ExampleInventoryContainerGui extends ContainerGui<ContainerMod.ExampleInventoryContainer> {
public static class ExampleInventoryContainerScreen extends ContainerScreen<ContainerMod.ExampleInventoryContainer> {
private static final Identifier BG_TEXTURE = new Identifier("textures/gui/container/horse.png");
public ExampleInventoryContainerGui(ContainerMod.ExampleInventoryContainer container) {
public ExampleInventoryContainerScreen(ContainerMod.ExampleInventoryContainer container) {
super(container, container.playerInventory, new StringTextComponent("Example Inventory GUI"));
}