API 0.2.2

This commit is contained in:
Adrian Siekierka 2019-02-20 23:16:40 +01:00
parent b3acb94a6d
commit 57faa8d1bd
35 changed files with 401 additions and 320 deletions

View file

@ -26,8 +26,8 @@ targetCompatibility = 1.8
archivesBaseName = "fabric"
def baseVersion = "0.2.1"
def mcVersion = "19w07a"
def baseVersion = "0.2.2"
def mcVersion = "19w08a"
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.13"
modCompile "net.fabricmc:fabric-loader:0.3.6.107"
mappings "net.fabricmc:yarn:$mcVersion.3"
modCompile "net.fabricmc:fabric-loader:0.3.7.108"
}
task sourcesJar(type: Jar, dependsOn: classes) {

View file

@ -59,6 +59,19 @@ public final class FabricItemGroupBuilder {
return this;
}
/**
*
* This allows for a custom list of items to be displayed in a tab, this enabled tabs to be created with a custom set of items
*
* @param appender Add ItemStack's to this list to show in the ItemGroup
* @return a reference to the FabricItemGroupBuilder
* @deprecated use {@link FabricItemGroupBuilder#appendItems(Consumer)}
*/
@Deprecated
public FabricItemGroupBuilder stacksForDisplay(Consumer<List<ItemStack>> appender) {
return appendItems(appender);
}
/**
*
* This allows for a custom list of items to be displayed in a tab, this enabled tabs to be created with a custom set of items
@ -66,7 +79,7 @@ public final class FabricItemGroupBuilder {
* @param stacksForDisplay Add ItemStack's to this list to show in the ItemGroup
* @return a reference to the FabricItemGroupBuilder
*/
public FabricItemGroupBuilder stacksForDisplay(Consumer<List<ItemStack>> stacksForDisplay){
public FabricItemGroupBuilder appendItems(Consumer<List<ItemStack>> stacksForDisplay) {
this.stacksForDisplay = stacksForDisplay;
return this;
}
@ -92,17 +105,18 @@ public final class FabricItemGroupBuilder {
public ItemGroup build() {
((ItemGroupExtensions) ItemGroup.BUILDING_BLOCKS).fabric_expandArray();
return new ItemGroup(ItemGroup.GROUPS.length - 1, String.format("%s.%s", identifier.getNamespace(), identifier.getPath())) {
public ItemStack getIconItem() {
@Override
public ItemStack createIcon() {
return stackSupplier.get();
}
public void getStacksForDisplay(DefaultedList<ItemStack> stacks) {
@Override
public void appendItems(DefaultedList<ItemStack> stacks) {
if(stacksForDisplay != null){
stacksForDisplay.accept(stacks);
return;
}
super.getStacksForDisplay(stacks);
super.appendItems(stacks);
}
};
}

View file

@ -16,6 +16,7 @@
package net.fabricmc.fabric.api.entity;
import net.minecraft.class_4048;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityCategory;
import net.minecraft.entity.EntityType;
@ -35,24 +36,32 @@ import java.util.function.Function;
public class FabricEntityTypeBuilder<T extends Entity> {
private static final Logger LOGGER = LogManager.getLogger();
private final EntityCategory category;
private final Function<? super World, ? extends T> function;
private final EntityType.class_4049 function;
private boolean saveable = true;
private boolean summonable = true;
private int trackingDistance = -1;
private int updateIntervalTicks = -1;
private boolean alwaysUpdateVelocity = true;
private float width = -1.0f, height = -1.0f;
private class_4048 size = class_4048.method_18385(-1.0f, -1.0f);
protected FabricEntityTypeBuilder(EntityCategory category, Function<? super World, ? extends T> function) {
protected FabricEntityTypeBuilder(EntityCategory category, EntityType.class_4049 function) {
this.category = category;
this.function = function;
}
public static <T extends Entity> FabricEntityTypeBuilder<T> create(EntityCategory category) {
return new FabricEntityTypeBuilder<>(category, (w) -> null);
return new FabricEntityTypeBuilder<>(category, (t, w) -> null);
}
/**
* @deprecated Use {@link FabricEntityTypeBuilder#create(EntityCategory, EntityType.class_4049)}
*/
@Deprecated
public static <T extends Entity> FabricEntityTypeBuilder<T> create(EntityCategory category, Function<? super World, ? extends T> function) {
return create(category, (t, w) -> function.apply(w));
}
public static <T extends Entity> FabricEntityTypeBuilder<T> create(EntityCategory category, EntityType.class_4049 function) {
return new FabricEntityTypeBuilder<>(category, function);
}
@ -66,9 +75,17 @@ public class FabricEntityTypeBuilder<T extends Entity> {
return this;
}
/**
* @deprecated Use {@link FabricEntityTypeBuilder#size(class_4048)}
*/
@Deprecated
public FabricEntityTypeBuilder<T> size(float width, float height) {
this.width = width;
this.height = height;
this.size = class_4048.method_18385(width, height);
return this;
}
public FabricEntityTypeBuilder<T> size(class_4048 size) {
this.size = size;
return this;
}
@ -89,7 +106,7 @@ public class FabricEntityTypeBuilder<T extends Entity> {
// TODO: Flesh out once modded datafixers exist.
}
EntityType<T> type = new EntityType<T>(this.function, this.category, this.saveable, this.summonable, null, this.width, this.height);
EntityType<T> type = new EntityType<T>(this.function, this.category, this.saveable, this.summonable, null, size);
if (trackingDistance != -1) {
EntityTrackingRegistry.INSTANCE.register(type, trackingDistance, updateIntervalTicks, alwaysUpdateVelocity);
}

View file

@ -16,17 +16,16 @@
package net.fabricmc.fabric.api.resource;
import net.fabricmc.loader.ModInfo;
import net.fabricmc.loader.api.metadata.ModMetadata;
import net.minecraft.resource.ResourcePack;
import net.minecraft.resource.ResourceType;
/**
* Interface implemented by mod-provided resource packs.
*/
public interface ModResourcePack extends ResourcePack {
/**
* @return The ModInfo object associated with the mod providing this
* @return The ModMetadata object associated with the mod providing this
* resource pack.
*/
ModInfo getFabricModInfo();
ModMetadata getFabricModMetadata();
}

View file

@ -16,17 +16,19 @@
package net.fabricmc.fabric.api.server;
import net.fabricmc.fabric.impl.server.EntityTrackerStreamAccessor;
import net.fabricmc.fabric.impl.server.EntityTrackerStorageAccessor;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.network.EntityTracker;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerChunkManager;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.server.world.ThreadedAnvilChunkStorage;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraft.world.chunk.ChunkManager;
import net.minecraft.world.chunk.ChunkPos;
import java.util.stream.Stream;
@ -50,15 +52,21 @@ public final class PlayerStream {
}
public static Stream<PlayerEntity> world(World world) {
return world.players.stream();
if (world instanceof ServerWorld) {
// noinspection unchecked
return ((Stream<PlayerEntity>) (Stream) ((ServerWorld) world).method_18456().stream());
} else {
throw new RuntimeException("Only supported on ServerWorld!");
}
}
public static Stream<PlayerEntity> watching(World world, ChunkPos pos) {
if (!(world instanceof ServerWorld)) {
ChunkManager manager = world.getChunkManager();
if (!(manager instanceof ServerChunkManager)) {
throw new RuntimeException("Only supported on ServerWorld!");
} else {
// noinspection unchecked
return ((Stream<PlayerEntity>) (Stream) ((ServerWorld) world).getChunkManager().getPlayersWatchingChunk(pos, false, false));
//noinspection unchecked
return ((Stream<PlayerEntity>) (Stream) ((ServerChunkManager) manager).threadedAnvilChunkStorage.getPlayersWatchingChunk(pos, false));
}
}
@ -69,18 +77,18 @@ public final class PlayerStream {
*/
@SuppressWarnings("JavaDoc")
public static Stream<PlayerEntity> watching(Entity entity) {
World world = entity.getEntityWorld();
ChunkManager manager = entity.getEntityWorld().getChunkManager();
if (world instanceof ServerWorld) {
EntityTracker tracker = ((ServerWorld) world).getEntityTracker();
if (tracker instanceof EntityTrackerStreamAccessor) {
if (manager instanceof ServerChunkManager) {
ThreadedAnvilChunkStorage storage = ((ServerChunkManager) manager).threadedAnvilChunkStorage;
if (storage instanceof EntityTrackerStorageAccessor) {
//noinspection unchecked
return ((Stream<PlayerEntity>) (Stream) ((EntityTrackerStreamAccessor) tracker).fabric_getTrackingPlayers(entity));
return ((Stream<PlayerEntity>) (Stream) ((EntityTrackerStorageAccessor) storage).fabric_getTrackingPlayers(entity));
}
}
// fallback
return watching(world, new ChunkPos((int) (entity.x / 16.0D), (int) (entity.z / 16.0D)));
return watching(entity.getEntityWorld(), new ChunkPos((int) (entity.x / 16.0D), (int) (entity.z / 16.0D)));
}
public static Stream<PlayerEntity> watching(BlockEntity entity) {

View file

@ -29,11 +29,11 @@ public class FabricAPIInitializer implements ModInitializer {
BlockState state = world.getBlockState(pos);
if (state instanceof BlockAttackInteractionAware) {
if (((BlockAttackInteractionAware) state).onAttackInteraction(state, world, pos, player, hand, direction)) {
return ActionResult.FAILURE;
return ActionResult.FAIL;
}
} else if (state.getBlock() instanceof BlockAttackInteractionAware) {
if (((BlockAttackInteractionAware) state.getBlock()).onAttackInteraction(state, world, pos, player, hand, direction)) {
return ActionResult.FAILURE;
return ActionResult.FAIL;
}
}

View file

@ -18,7 +18,7 @@ package net.fabricmc.fabric.impl.client.model;
import com.google.common.collect.Lists;
import net.fabricmc.fabric.api.client.model.*;
import net.fabricmc.loader.launch.common.FabricLauncherBase;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.render.model.ModelLoader;
import net.minecraft.client.render.model.UnbakedModel;
import net.minecraft.client.util.ModelIdentifier;
@ -33,7 +33,7 @@ import java.util.function.Function;
import java.util.stream.Collectors;
public class ModelLoadingRegistryImpl implements ModelLoadingRegistry {
private static final boolean DEBUG_MODEL_LOADING = FabricLauncherBase.getLauncher().isDevelopment()
private static final boolean DEBUG_MODEL_LOADING = FabricLoader.getInstance().isDevelopmentEnvironment()
|| Boolean.valueOf(System.getProperty("fabric.debugModelLoading", "false"));
@FunctionalInterface

View file

@ -45,8 +45,8 @@ public class FabricCreativeGuiComponents {
CreativePlayerInventoryScreen gui;
Type type;
public ItemGroupButtonWidget(int id, int x, int y, Type type, CreativeGuiExtensions extensions) {
super(id, x, y, 10, 11, type.text);
public ItemGroupButtonWidget(int x, int y, Type type, CreativeGuiExtensions extensions) {
super(x, y, 10, 11, type.text);
this.extensions = extensions;
this.type = type;
this.gui = (CreativePlayerInventoryScreen) extensions;

View file

@ -23,7 +23,6 @@ import net.fabricmc.fabric.api.network.PacketContext;
import net.fabricmc.fabric.api.network.ServerSidePacketRegistry;
import net.fabricmc.fabric.api.server.PlayerStream;
import net.fabricmc.fabric.impl.accessors.CustomPayloadC2SPacketAccessor;
import net.fabricmc.loader.FabricLoader;
import net.minecraft.client.network.packet.CustomPayloadS2CPacket;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.network.Packet;
@ -71,20 +70,22 @@ public class ServerSidePacketRegistryImpl extends PacketRegistryImpl implements
@Override
protected void onRegister(Identifier id) {
MinecraftServer server = FabricLoader.INSTANCE.getEnvironmentHandler().getServerInstance();
/* MinecraftServer server = FabricLoader.INSTANCE.getEnvironmentHandler().getServerInstance();
if (server != null) {
Packet<?> packet = createRegisterTypePacket(PacketTypes.REGISTER, Collections.singleton(id));
PlayerStream.all(server).forEach((p) -> sendToPlayer(p, packet));
}
} */
// TODO
}
@Override
protected void onUnregister(Identifier id) {
MinecraftServer server = FabricLoader.INSTANCE.getEnvironmentHandler().getServerInstance();
/* MinecraftServer server = FabricLoader.INSTANCE.getEnvironmentHandler().getServerInstance();
if (server != null) {
Packet<?> packet = createRegisterTypePacket(PacketTypes.UNREGISTER, Collections.singleton(id));
PlayerStream.all(server).forEach((p) -> sendToPlayer(p, packet));
}
} */
// TODO
}
@Override

View file

@ -42,9 +42,9 @@ public class IdListUpdater<K, V> implements RegistryListener<K> {
@Override
public void beforeRegistryCleared(Registry<K> registry) {
mapperCache.clear();
for (Identifier id : registry.keys()) {
for (Identifier id : registry.getIds()) {
int rawId = registry.getRawId(registry.get(id));
V mapper = mappers.getInt(rawId);
V mapper = mappers.get(rawId);
if (mapper != null) {
mapperCache.put(id, mapper);
}

View file

@ -26,9 +26,9 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.Packet;
import net.minecraft.util.Identifier;
import net.minecraft.util.PacketByteBuf;
import net.minecraft.util.registry.IdRegistry;
import net.minecraft.util.registry.ModifiableRegistry;
import net.minecraft.util.registry.MutableRegistry;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.SimpleRegistry;
import java.util.Set;
import java.util.concurrent.ExecutionException;
@ -76,18 +76,18 @@ public final class RegistrySyncManager {
public static CompoundTag toTag(boolean isClientSync) {
CompoundTag mainTag = new CompoundTag();
for (Identifier registryId : Registry.REGISTRIES.keys()) {
for (Identifier registryId : Registry.REGISTRIES.getIds()) {
if (REGISTRY_BLACKLIST.contains(registryId)) {
continue;
} else if (isClientSync && REGISTRY_BLACKLIST_NETWORK.contains(registryId)) {
continue;
}
ModifiableRegistry registry = Registry.REGISTRIES.get(registryId);
if (registry instanceof IdRegistry && registry instanceof RemappableRegistry) {
MutableRegistry registry = Registry.REGISTRIES.get(registryId);
if (registry instanceof SimpleRegistry && registry instanceof RemappableRegistry) {
CompoundTag registryTag = new CompoundTag();
//noinspection unchecked
for (Identifier identifier : (Set<Identifier>) registry.keys()) {
for (Identifier identifier : (Set<Identifier>) registry.getIds()) {
registryTag.putInt(identifier.toString(), registry.getRawId(registry.get(identifier)));
}
mainTag.put(registryId.toString(), registryTag);
@ -104,14 +104,14 @@ public final class RegistrySyncManager {
public static void apply(CompoundTag tag, boolean reallocateMissingEntries) throws RemapException {
CompoundTag mainTag = tag.getCompound("registries");
for (Identifier registryId : Registry.REGISTRIES.keys()) {
for (Identifier registryId : Registry.REGISTRIES.getIds()) {
if (!mainTag.containsKey(registryId.toString())) {
continue;
}
CompoundTag registryTag = mainTag.getCompound(registryId.toString());
ModifiableRegistry registry = Registry.REGISTRIES.get(registryId);
if (registry instanceof IdRegistry && registry instanceof RemappableRegistry) {
MutableRegistry registry = Registry.REGISTRIES.get(registryId);
if (registry instanceof SimpleRegistry && registry instanceof RemappableRegistry) {
Object2IntMap<Identifier> idMap = new Object2IntOpenHashMap<>();
for (String key : registryTag.getKeys()) {
idMap.put(new Identifier(key), registryTag.getInt(key));
@ -122,8 +122,8 @@ public final class RegistrySyncManager {
}
public static void unmap() throws RemapException {
for (Identifier registryId : Registry.REGISTRIES.keys()) {
ModifiableRegistry registry = Registry.REGISTRIES.get(registryId);
for (Identifier registryId : Registry.REGISTRIES.getIds()) {
MutableRegistry registry = Registry.REGISTRIES.get(registryId);
if (registry instanceof RemappableRegistry) {
((RemappableRegistry) registry).unmap();
}

View file

@ -1,61 +0,0 @@
/*
* 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.impl.resources;
import net.fabricmc.fabric.api.resource.ModResourcePack;
import net.fabricmc.loader.ModInfo;
import net.minecraft.resource.DirectoryResourcePack;
import net.minecraft.resource.ResourceNotFoundException;
import java.io.*;
public class ModDirectoryResourcePack extends DirectoryResourcePack implements ModResourcePack {
private final ModInfo info;
public ModDirectoryResourcePack(ModInfo info, File file) {
super(file);
this.info = info;
}
@Override
public String getName() {
return ModResourcePackUtil.getName(info);
}
@Override
protected InputStream openFilename(String filename) throws IOException {
try {
return super.openFilename(filename);
} catch (FileNotFoundException e) {
InputStream stream = ModResourcePackUtil.openDefault(info, filename);
if (stream == null) {
throw new ResourceNotFoundException(this.base, filename);
}
return stream;
}
}
@Override
protected boolean containsFilename(String filename) {
return super.containsFilename(filename) || ModResourcePackUtil.containsDefault(info, filename);
}
@Override
public ModInfo getFabricModInfo() {
return info;
}
}

View file

@ -0,0 +1,182 @@
/*
* 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.impl.resources;
import net.fabricmc.fabric.api.resource.ModResourcePack;
import net.fabricmc.loader.api.metadata.ModMetadata;
import net.minecraft.resource.AbstractFilenameResourcePack;
import net.minecraft.resource.ResourceNotFoundException;
import net.minecraft.resource.ResourceType;
import net.minecraft.util.Identifier;
import net.minecraft.util.InvalidIdentifierException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*;
import java.util.function.Predicate;
import java.util.stream.Collectors;
public class ModNioResourcePack extends AbstractFilenameResourcePack implements ModResourcePack {
private static final Logger LOGGER = LogManager.getLogger();
private final ModMetadata modInfo;
private final Path basePath;
private final boolean cacheable;
private final AutoCloseable closer;
public ModNioResourcePack(ModMetadata modInfo, Path path, AutoCloseable closer) {
super(new File(path.toString()));
this.modInfo = modInfo;
this.basePath = path.toAbsolutePath();
this.cacheable = false; /* TODO */
this.closer = closer;
}
private Path getPath(String filename) {
Path childPath = basePath.resolve(filename.replaceAll("/", basePath.getFileSystem().getSeparator())).toAbsolutePath();
if (childPath.startsWith(basePath) && Files.exists(childPath)) {
return childPath;
} else {
return null;
}
}
@Override
protected InputStream openFilename(String filename) throws IOException {
Path path = getPath(filename);
if (path != null && Files.isRegularFile(path)) {
return Files.newInputStream(path);
}
InputStream stream = ModResourcePackUtil.openDefault(modInfo, filename);
if (stream == null) {
throw new ResourceNotFoundException(this.base, filename);
}
return stream;
}
@Override
protected boolean containsFilename(String filename) {
if (ModResourcePackUtil.containsDefault(modInfo, filename)) {
return true;
}
Path path = getPath(filename);
return path != null && Files.isRegularFile(path);
}
@Override
public Collection<Identifier> findResources(ResourceType type, String path, int depth, Predicate<String> predicate) {
List<Identifier> ids = new ArrayList<>();
String nioPath = path.replaceAll("/", basePath.getFileSystem().getSeparator());
for (String namespace : getNamespaces(type)) {
Path namespacePath = getPath(type.getName() + "/" + namespace);
if (namespacePath != null) {
Path searchPath = namespacePath.resolve(nioPath).toAbsolutePath();
if (Files.exists(searchPath)) {
try {
Files.walk(searchPath, depth)
.filter((p) -> Files.isRegularFile(p))
.filter((p) -> {
String filename = p.getFileName().toString();
return !filename.endsWith(".mcmeta") && predicate.test(filename);
})
.map(namespacePath::relativize)
.map((p) -> p.toString().replaceAll(p.getFileSystem().getSeparator(), "/"))
.forEach((s) -> {
try {
ids.add(new Identifier(namespace, s));
} catch (InvalidIdentifierException e) {
LOGGER.error(e.getMessage());
}
});
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
return ids;
}
private Set<String> namespaceCache;
@Override
public Set<String> getNamespaces(ResourceType type) {
if (namespaceCache != null) {
return namespaceCache;
}
try {
Path typePath = getPath(type.getName());
if (typePath == null) {
return Collections.emptySet();
}
Set<String> namespaces = new HashSet<>();
for (Path path : Files.newDirectoryStream(typePath, (p) -> Files.isDirectory(p))) {
String s = path.getFileName().toString();
if (s.equals(s.toLowerCase(Locale.ROOT))) {
namespaces.add(s);
} else {
this.warnNonLowercaseNamespace(s);
}
}
if (cacheable) {
namespaceCache = namespaces;
}
return namespaces;
} catch (IOException e) {
e.printStackTrace();
return Collections.emptySet();
}
}
@Override
public void close() throws IOException {
if (closer != null) {
try {
closer.close();
} catch (IOException e) {
throw e;
} catch (Exception e) {
throw new IOException(e);
}
}
}
@Override
public ModMetadata getFabricModMetadata() {
return modInfo;
}
@Override
public String getName() {
return ModResourcePackUtil.getName(modInfo);
}
}

View file

@ -26,18 +26,24 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class ModDataPackSupplier implements ResourcePackCreator {
public class ModResourcePackCreator implements ResourcePackCreator {
private final ResourceType type;
public ModResourcePackCreator(ResourceType type) {
this.type = type;
}
@Override
public <T extends ResourcePackContainer> void registerContainer(Map<String, T> map, ResourcePackContainer.Factory<T> factory) {
// TODO: "vanilla" does not emit a message; neither should a modded datapack
List<ResourcePack> packs = new ArrayList<>();
ModResourcePackUtil.appendModResourcePacks(packs, ResourceType.DATA);
ModResourcePackUtil.appendModResourcePacks(packs, type);
for (ResourcePack pack : packs) {
if (!(pack instanceof ModResourcePack)) {
throw new RuntimeException("Not a ModResourcePack!");
}
T var3 = ResourcePackContainer.of("fabric/" + ((ModResourcePack) pack).getFabricModInfo().getId(),
T var3 = ResourcePackContainer.of("fabric/" + ((ModResourcePack) pack).getFabricModMetadata().getId(),
false, () -> pack, factory, ResourcePackContainer.SortingDirection.BOTTOM);
if (var3 != null) {

View file

@ -17,15 +17,19 @@
package net.fabricmc.fabric.impl.resources;
import com.google.common.base.Charsets;
import net.fabricmc.loader.FabricLoader;
import net.fabricmc.loader.ModContainer;
import net.fabricmc.loader.ModInfo;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.ModContainer;
import net.fabricmc.loader.api.metadata.ModMetadata;
import net.minecraft.resource.ResourcePack;
import net.minecraft.resource.ResourceType;
import org.apache.commons.io.IOUtils;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.Locale;
@ -40,35 +44,25 @@ public final class ModResourcePackUtil {
}
public static void appendModResourcePacks(List<ResourcePack> packList, ResourceType type) {
for (ModContainer container : FabricLoader.INSTANCE.getModContainers()) {
File file = container.getOriginFile();
ResourcePack pack = null;
if (file.isDirectory()) {
pack = new ModDirectoryResourcePack(container.getInfo(), file);
} else {
String name = file.getName().toLowerCase(Locale.ROOT);
if (name.endsWith(".zip") || name.endsWith(".jar")) {
pack = new ModZipResourcePack(container.getInfo(), file);
}
}
if (pack != null && !pack.getNamespaces(type).isEmpty()) {
packList.add(pack);
}
for (ModContainer container : FabricLoader.getInstance().getAllMods()) {
Path path = container.getRoot();
ResourcePack pack = new ModNioResourcePack(container.getMetadata(), path, null);
if (!pack.getNamespaces(type).isEmpty()) {
packList.add(pack);
}
}
}
public static boolean containsDefault(ModInfo info, String filename) {
public static boolean containsDefault(ModMetadata info, String filename) {
return "pack.mcmeta".equals(filename) || "pack.png".equals(filename);
}
public static InputStream openDefault(ModInfo info, String filename) {
public static InputStream openDefault(ModMetadata info, String filename) {
switch (filename) {
case "pack.png":
return ModResourcePackUtil.class.getClassLoader().getResourceAsStream("assets/fabric/textures/misc/default_icon.png");
case "pack.mcmeta":
String description = info.getName();
String description = info.getId(); // TODO getName
if (description == null) {
description = "";
} else {
@ -81,10 +75,10 @@ public final class ModResourcePackUtil {
}
}
public static String getName(ModInfo info) {
if (info.getName() != null) {
public static String getName(ModMetadata info) {
/* if (info.getName() != null) {
return info.getName();
} else {
} else */ { // TODO getName
return "Fabric Mod \"" + info.getId() + "\"";
}
}

View file

@ -1,64 +0,0 @@
/*
* 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.impl.resources;
import net.fabricmc.fabric.api.resource.ModResourcePack;
import net.fabricmc.loader.ModInfo;
import net.minecraft.resource.ResourceNotFoundException;
import net.minecraft.resource.ZipResourcePack;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
public class ModZipResourcePack extends ZipResourcePack implements ModResourcePack {
private final ModInfo info;
public ModZipResourcePack(ModInfo info, File file) {
super(file);
this.info = info;
}
@Override
public String getName() {
return ModResourcePackUtil.getName(info);
}
@Override
protected InputStream openFilename(String filename) throws IOException {
try {
return super.openFilename(filename);
} catch (FileNotFoundException e) {
InputStream stream = ModResourcePackUtil.openDefault(info, filename);
if (stream == null) {
throw new ResourceNotFoundException(this.base, filename);
}
return stream;
}
}
@Override
public boolean containsFilename(String filename) {
return super.containsFilename(filename) || ModResourcePackUtil.containsDefault(info, filename);
}
@Override
public ModInfo getFabricModInfo() {
return info;
}
}

View file

@ -21,6 +21,6 @@ import net.minecraft.server.network.ServerPlayerEntity;
import java.util.stream.Stream;
public interface EntityTrackerEntryStreamAccessor {
Stream<ServerPlayerEntity> fabric_getTrackingPlayers();
public interface EntityTrackerStorageAccessor {
Stream<ServerPlayerEntity> fabric_getTrackingPlayers(Entity entity);
}

View file

@ -22,5 +22,5 @@ import net.minecraft.server.network.ServerPlayerEntity;
import java.util.stream.Stream;
public interface EntityTrackerStreamAccessor {
Stream<ServerPlayerEntity> fabric_getTrackingPlayers(Entity entity);
Stream<ServerPlayerEntity> fabric_getTrackingPlayers();
}

View file

@ -117,8 +117,8 @@ public abstract class MixinCreativePlayerInventoryGui extends AbstractPlayerInve
int xpos = left + 170;
int ypos = top + 4;
addButton(new FabricCreativeGuiComponents.ItemGroupButtonWidget(1001, xpos + 10, ypos, FabricCreativeGuiComponents.Type.NEXT, this));
addButton(new FabricCreativeGuiComponents.ItemGroupButtonWidget(1002, xpos, ypos, FabricCreativeGuiComponents.Type.PREVIOUS, this));
addButton(new FabricCreativeGuiComponents.ItemGroupButtonWidget(xpos + 10, ypos, FabricCreativeGuiComponents.Type.NEXT, this));
addButton(new FabricCreativeGuiComponents.ItemGroupButtonWidget(xpos, ypos, FabricCreativeGuiComponents.Type.PREVIOUS, this));
}
@ -154,7 +154,7 @@ public abstract class MixinCreativePlayerInventoryGui extends AbstractPlayerInve
if (FabricCreativeGuiComponents.COMMON_GROUPS.contains(itemGroup)) {
return true;
}
return fabric_currentPage == fabric_getOffsetPage(itemGroup.getId());
return fabric_currentPage == fabric_getOffsetPage(itemGroup.getIndex());
}

View file

@ -27,32 +27,26 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(ItemGroup.class)
public abstract class MixinItemGroup {
@Shadow
public abstract int getId();
public abstract int getIndex();
@Shadow
public abstract boolean isTopRow();
@Shadow
@Final
private int id;
@Inject(method = "isTopRow", cancellable = true, at = @At("HEAD"))
private void isTopRow(CallbackInfoReturnable<Boolean> info) {
if (getId() > 11) {
info.setReturnValue((id - 12) % (12 - FabricCreativeGuiComponents.COMMON_GROUPS.size()) < 4);
if (getIndex() > 11) {
info.setReturnValue((getIndex() - 12) % (12 - FabricCreativeGuiComponents.COMMON_GROUPS.size()) < 4);
}
}
@Inject(method = "getColumn", cancellable = true, at = @At("HEAD"))
private void getColumn(CallbackInfoReturnable<Integer> info) {
if (getId() > 11) {
if (getIndex() > 11) {
if (isTopRow()) {
info.setReturnValue((id - 12) % (12 - FabricCreativeGuiComponents.COMMON_GROUPS.size()));
info.setReturnValue((getIndex() - 12) % (12 - FabricCreativeGuiComponents.COMMON_GROUPS.size()));
} else {
info.setReturnValue((id - 12) % (12 - FabricCreativeGuiComponents.COMMON_GROUPS.size()) - 4);
info.setReturnValue((getIndex() - 12) % (12 - FabricCreativeGuiComponents.COMMON_GROUPS.size()) - 4);
}
}

View file

@ -42,6 +42,6 @@ public class MixinBlockColorMap implements ColorProviderRegistryImpl.ColorMapper
@Override
public BlockColorMapper get(Block block) {
return mappers.getInt(Registry.BLOCK.getRawId(block));
return mappers.get(Registry.BLOCK.getRawId(block));
}
}

View file

@ -43,6 +43,6 @@ public class MixinItemColorMap implements ColorProviderRegistryImpl.ColorMapperH
@Override
public ItemColorMapper get(ItemProvider item) {
return mappers.getInt(Registry.ITEM.getRawId(item.getItem()));
return mappers.get(Registry.ITEM.getRawId(item.getItem()));
}
}

View file

@ -16,48 +16,23 @@
package net.fabricmc.fabric.mixin.entity;
import net.fabricmc.fabric.api.entity.EntityTrackingRegistry;
import net.fabricmc.fabric.impl.server.EntityTrackerEntryStreamAccessor;
import net.fabricmc.fabric.impl.server.EntityTrackerStreamAccessor;
import net.minecraft.entity.Entity;
import net.minecraft.server.network.EntityTracker;
import net.minecraft.server.network.EntityTrackerEntry;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.IntHashMap;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.Set;
import java.util.stream.Stream;
@Mixin(EntityTracker.class)
public abstract class MixinEntityTracker implements EntityTrackerStreamAccessor {
@Mixin(targets = "net.minecraft.server.world.ThreadedAnvilChunkStorage$EntityTracker")
public class MixinEntityTracker implements EntityTrackerStreamAccessor {
@Shadow
private IntHashMap<EntityTrackerEntry> trackedEntitiesById;
@Shadow
public abstract void add(Entity var1, int var2, int var3, boolean var4);
@SuppressWarnings("deprecation")
@Inject(at = @At("HEAD"), method = "add", cancellable = true)
public void add(Entity entity, CallbackInfo info) {
if (entity != null) {
EntityTrackingRegistry.Entry entry = EntityTrackingRegistry.INSTANCE.get(entity.getType());
if (entry != null) {
add(entity, entry.getTrackingDistance(), entry.getUpdateIntervalTicks(), entry.alwaysUpdateVelocity());
info.cancel();
}
}
}
@Final
private Set<ServerPlayerEntity> field_18250;
@Override
public Stream<ServerPlayerEntity> fabric_getTrackingPlayers(Entity entity) {
EntityTrackerEntry entry = trackedEntitiesById.get(entity.getEntityId());
if (entry != null) {
return ((EntityTrackerEntryStreamAccessor) entry).fabric_getTrackingPlayers();
} else {
return Stream.empty();
}
public Stream<ServerPlayerEntity> fabric_getTrackingPlayers() {
return field_18250.stream();
}
}

View file

@ -16,22 +16,27 @@
package net.fabricmc.fabric.mixin.entity;
import net.fabricmc.fabric.impl.server.EntityTrackerEntryStreamAccessor;
import net.minecraft.server.network.EntityTrackerEntry;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import net.fabricmc.fabric.impl.server.EntityTrackerStreamAccessor;
import net.fabricmc.fabric.impl.server.EntityTrackerStorageAccessor;
import net.minecraft.entity.Entity;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ThreadedAnvilChunkStorage;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import java.util.Set;
import java.util.stream.Stream;
@Mixin(EntityTrackerEntry.class)
public class MixinEntityTrackerEntry implements EntityTrackerEntryStreamAccessor {
@Mixin(ThreadedAnvilChunkStorage.class)
public class MixinThreadedAnvilChunkStorage implements EntityTrackerStorageAccessor {
@Shadow
private Set<ServerPlayerEntity> trackingPlayers;
@Final
private Int2ObjectMap<EntityTrackerStreamAccessor> field_18242;
@Override
public Stream<ServerPlayerEntity> fabric_getTrackingPlayers() {
return trackingPlayers.stream();
public Stream<ServerPlayerEntity> fabric_getTrackingPlayers(Entity entity) {
EntityTrackerStreamAccessor accessor = field_18242.get(entity.getEntityId());
return accessor != null ? accessor.fabric_getTrackingPlayers() : Stream.empty();
}
}

View file

@ -29,8 +29,9 @@ import java.util.function.BooleanSupplier;
@Mixin(World.class)
public class MixinWorld {
@Inject(at = @At("RETURN"), method = "tick")
public void tick(BooleanSupplier booleanSupplier, CallbackInfo info) {
// TODO split into ClientWorld/ServerWorld ticks? mmm need more mappings
@Inject(at = @At("RETURN"), method = "method_18471")
public void method_18471(CallbackInfo info) {
WorldTickCallback.EVENT.invoker().tick((World) (Object) this);
}
}

View file

@ -16,11 +16,8 @@
package net.fabricmc.fabric.mixin.misc;
import com.google.common.collect.Lists;
import net.fabricmc.loader.FabricLoader;
import net.fabricmc.loader.ModContainer;
import net.fabricmc.loader.ModInfo;
import net.minecraft.util.SystemUtil;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.ModContainer;
import net.minecraft.util.crash.CrashReport;
import net.minecraft.util.crash.CrashReportSection;
import org.spongepowered.asm.mixin.Mixin;
@ -28,7 +25,6 @@ import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.*;
@ -41,8 +37,10 @@ public abstract class MixinCrashReport {
private void fillSystemDetails(CallbackInfo info) {
getSystemDetailsSection().add("Fabric Mods", () -> {
Map<String, String> mods = new TreeMap<>();
for (ModContainer container : FabricLoader.INSTANCE.getModContainers()) {
mods.put(container.getInfo().getName(), container.getInfo().getVersionString() + " (" + container.getOriginFile().getName() + ")");
for (ModContainer container : FabricLoader.getInstance().getAllMods()) {
// mods.put(container.getInfo().getName(), container.getInfo().getVersionString() + " (" + container.getOriginUrl().getFile() + ")");
// TODO getName, getOriginUrl
mods.put(container.getMetadata().getId(), container.getMetadata().getVersion().getFriendlyString());
}
StringBuilder modString = new StringBuilder();

View file

@ -25,8 +25,8 @@ import net.fabricmc.fabric.impl.registry.RemapException;
import net.fabricmc.fabric.impl.registry.RemappableRegistry;
import net.minecraft.util.Identifier;
import net.minecraft.util.Int2ObjectBiMap;
import net.minecraft.util.registry.DefaultMappedRegistry;
import net.minecraft.util.registry.IdRegistry;
import net.minecraft.util.registry.DefaultedRegistry;
import net.minecraft.util.registry.SimpleRegistry;
import org.apache.logging.log4j.Logger;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@ -38,14 +38,14 @@ import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
@Mixin(IdRegistry.class)
@Mixin(SimpleRegistry.class)
public abstract class MixinIdRegistry<T> implements RemappableRegistry, ListenableRegistry<T>, RegistryListener<T> {
@Shadow
protected static Logger ID_LOGGER;
protected static Logger LOGGER;
@Shadow
protected Int2ObjectBiMap<T> idStore;
protected Int2ObjectBiMap<T> indexedEntries;
@Shadow
protected BiMap<Identifier, T> objectMap;
protected BiMap<Identifier, T> entries;
@Shadow
private int nextId;
@ -67,10 +67,10 @@ public abstract class MixinIdRegistry<T> implements RemappableRegistry, Listenab
@SuppressWarnings({ "unchecked", "ConstantConditions" })
@Inject(method = "set", at = @At("HEAD"))
public void setPre(int id, Identifier identifier, Object object, CallbackInfoReturnable info) {
IdRegistry<Object> registry = (IdRegistry<Object>) (Object) this;
SimpleRegistry<Object> registry = (SimpleRegistry<Object>) (Object) this;
if (listeners != null) {
for (RegistryListener listener : listeners) {
listener.beforeRegistryRegistration(registry, id, identifier, object, !objectMap.containsKey(identifier));
listener.beforeRegistryRegistration(registry, id, identifier, object, !entries.containsKey(identifier));
}
}
}
@ -78,7 +78,7 @@ public abstract class MixinIdRegistry<T> implements RemappableRegistry, Listenab
@SuppressWarnings({ "unchecked", "ConstantConditions" })
@Inject(method = "set", at = @At("RETURN"))
public void setPost(int id, Identifier identifier, Object object, CallbackInfoReturnable info) {
IdRegistry<Object> registry = (IdRegistry<Object>) (Object) this;
SimpleRegistry<Object> registry = (SimpleRegistry<Object>) (Object) this;
if (listeners != null) {
for (RegistryListener listener : listeners) {
listener.afterRegistryRegistration(registry, id, identifier, object);
@ -89,21 +89,21 @@ public abstract class MixinIdRegistry<T> implements RemappableRegistry, Listenab
@Override
public void remap(Object2IntMap<Identifier> idMap, boolean reallocateMissingEntries) throws RemapException {
//noinspection unchecked, ConstantConditions
IdRegistry<Object> registry = (IdRegistry<Object>) (Object) this;
SimpleRegistry<Object> registry = (SimpleRegistry<Object>) (Object) this;
Object defaultValue = null;
//noinspection ConstantConditions
if (registry instanceof DefaultMappedRegistry) {
defaultValue = registry.get(((DefaultMappedRegistry) registry).getDefaultId());
if (registry instanceof DefaultedRegistry) {
defaultValue = registry.get(((DefaultedRegistry<Object>) registry).getDefaultId());
}
if (!reallocateMissingEntries && !idMap.keySet().equals(registry.keys())) {
if (!reallocateMissingEntries && !idMap.keySet().equals(registry.getIds())) {
throw new RemapException("Source and destination keys differ!");
}
if (initialIdMap == null) {
initialIdMap = new Object2IntOpenHashMap<>();
for (Identifier id : registry.keys()) {
for (Identifier id : registry.getIds()) {
//noinspection unchecked
initialIdMap.put(id, registry.getRawId(registry.get(id)));
}
@ -120,9 +120,9 @@ public abstract class MixinIdRegistry<T> implements RemappableRegistry, Listenab
if (v > maxValue) maxValue = v;
}
for (Identifier id : registry.keys()) {
for (Identifier id : registry.getIds()) {
if (!idMap.containsKey(id)) {
ID_LOGGER.warn("Adding " + id + " to registry.");
LOGGER.warn("Adding " + id + " to registry.");
idMap.put(id, ++maxValue);
}
}
@ -134,8 +134,8 @@ public abstract class MixinIdRegistry<T> implements RemappableRegistry, Listenab
}
}
// We don't really need to clear anything but idStore yet.
idStore.clear();
// We don't really need to clear anything but indexedEntries yet.
indexedEntries.clear();
nextId = 0;
List<Identifier> idsInOrder = new ArrayList<>(idMap.keySet());
@ -143,17 +143,17 @@ public abstract class MixinIdRegistry<T> implements RemappableRegistry, Listenab
for (Identifier identifier : idsInOrder) {
int id = idMap.getInt(identifier);
T object = objectMap.get(identifier);
T object = entries.get(identifier);
if (object == null) {
ID_LOGGER.warn(identifier + " missing from registry, but requested!");
LOGGER.warn(identifier + " missing from registry, but requested!");
continue;
//noinspection unchecked, ConstantConditions
// object = (T) defaultValue;
// objectMap.put(identifier, object);
// entries.put(identifier, object);
}
idStore.put(object, id);
indexedEntries.put(object, id);
if (nextId <= id) {
nextId = id + 1;
}

View file

@ -57,7 +57,7 @@ public class MixinItemModelMap implements RegistryListener<Item> {
fabricModelMap = new HashMap<>();
}
for (Identifier id : registry.keys()) {
for (Identifier id : registry.getIds()) {
Item object = registry.get(id);
int rawId = registry.getRawId(object);
ModelIdentifier modelId = modelIds.get(rawId);

View file

@ -53,7 +53,7 @@ public class MixinParticleManager implements RegistryListener<ParticleType> {
fabricFactoryMap = new HashMap<>();
}
for (Identifier id : registry.keys()) {
for (Identifier id : registry.getIds()) {
ParticleType object = registry.get(id);
int rawId = registry.getRawId(object);
ParticleFactory<?> factory = factories.get(rawId);

View file

@ -28,27 +28,39 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import java.util.List;
import java.util.concurrent.CompletableFuture;
@Mixin(MinecraftClient.class)
public class MixinMinecraftGame {
@Shadow
private ReloadableResourceManager resourceManager;
@Inject(method = "reloadResources()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/resource/ReloadableResourceManager;reload(Ljava/util/concurrent/Executor;Ljava/util/concurrent/Executor;Ljava/util/List;Ljava/util/concurrent/CompletableFuture;)Ljava/util/concurrent/CompletableFuture;", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD)
public void reloadResources(CallbackInfo info, List<ResourcePack> list) {
List<ResourcePack> oldList = Lists.newArrayList(list);
list.clear();
for (int i = 0; i < oldList.size(); i++) {
ResourcePack pack = oldList.get(i);
list.add(pack);
private void fabric_modifyResourcePackList(List<ResourcePack> list) {
List<ResourcePack> oldList = Lists.newArrayList(list);
list.clear();
for (int i = 0; i < oldList.size(); i++) {
ResourcePack pack = oldList.get(i);
list.add(pack);
if (pack instanceof DefaultClientResourcePack) {
if (pack instanceof DefaultClientResourcePack) {
ModResourcePackUtil.appendModResourcePacks(list, ResourceType.ASSETS);
}
}
}
@Inject(method = "init", at = @At(value = "INVOKE", target = "Ljava/util/List;iterator()Ljava/util/Iterator;", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD)
public void initResources(CallbackInfo info, List<ResourcePack> list) {
fabric_modifyResourcePackList(list);
}
@Inject(method = "reloadResources", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;method_18502(Lnet/minecraft/class_4071;)V", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD)
public void reloadResources(CallbackInfoReturnable<CompletableFuture> info, CompletableFuture<java.lang.Void> cf, List<ResourcePack> list) {
fabric_modifyResourcePackList(list);
}
}

View file

@ -16,9 +16,10 @@
package net.fabricmc.fabric.mixin.resources;
import net.fabricmc.fabric.impl.resources.ModDataPackSupplier;
import net.fabricmc.fabric.impl.resources.ModResourcePackCreator;
import net.minecraft.resource.ResourcePackContainer;
import net.minecraft.resource.ResourcePackContainerManager;
import net.minecraft.resource.ResourceType;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.level.LevelProperties;
import org.spongepowered.asm.mixin.Mixin;
@ -36,6 +37,6 @@ public class MixinMinecraftServer {
@Inject(method = "method_3800", at = @At(value = "INVOKE", target = "Lnet/minecraft/resource/ResourcePackContainerManager;addCreator(Lnet/minecraft/resource/ResourcePackCreator;)V", ordinal = 1))
public void method_3800(File file, LevelProperties properties, CallbackInfo info) {
field_4595.addCreator(new ModDataPackSupplier());
field_4595.addCreator(new ModResourcePackCreator(ResourceType.DATA));
}
}

View file

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

View file

@ -9,7 +9,7 @@
"commands.MixinServerCommandManager",
"container.MixinServerPlayerEntity",
"entity.MixinEntityTracker",
"entity.MixinEntityTrackerEntry",
"entity.MixinThreadedAnvilChunkStorage",
"events.objectbuilder.MixinBlock",
"events.objectbuilder.MixinItem",
"events.playerinteraction.MixinServerPlayNetworkHandler",

View file

@ -33,8 +33,7 @@ public class ItemGroupMod implements ModInitializer {
//This creates your standard Item Group
ItemGroup group = FabricItemGroupBuilder.build(new Identifier("fabric", "fabric_test_tab"), () -> new ItemStack(Items.IRON_CHESTPLATE));
Item testItem = new Item(new Item.Settings().itemGroup(group));
Registry.ITEM.register(new Identifier("fabric_test", "itemgroup"), testItem);
Registry.ITEM.set(new Identifier("fabric_test", "itemgroup"), testItem);
//Creates a tab with all items (including ones that dont show in search such as the command block)
FabricItemGroupBuilder.create(new Identifier("fabric", "all")).stacksForDisplay(itemStacks -> Registry.ITEM.forEach(item -> itemStacks.add(new ItemStack(item)))).build();

View file

@ -99,12 +99,12 @@ public class ModelModClient implements ClientModInitializer {
@Override
public ModelTransformation getTransformation() {
return ModelTransformation.ORIGIN;
return ModelTransformation.NONE;
}
@Override
public ModelItemPropertyOverrideList getItemPropertyOverrides() {
return ModelItemPropertyOverrideList.ORIGIN;
return ModelItemPropertyOverrideList.EMPTY;
}
};
}