mark 0.1.5, compilation fixes, naming tweaks

This commit is contained in:
asie 2019-01-25 23:58:04 +01:00
parent b88969cf13
commit 833a3e9fb3
11 changed files with 37 additions and 32 deletions

View file

@ -26,8 +26,8 @@ targetCompatibility = 1.8
archivesBaseName = "fabric" archivesBaseName = "fabric"
def baseVersion = "0.1.4" def baseVersion = "0.1.5"
def mcVersion = "19w04a" def mcVersion = "19w04b"
def ENV = System.getenv() def ENV = System.getenv()
version = baseVersion + "." + (ENV.BUILD_NUMBER ?: "local") version = baseVersion + "." + (ENV.BUILD_NUMBER ?: "local")

View file

@ -17,12 +17,12 @@
package net.fabricmc.fabric.api.registry; package net.fabricmc.fabric.api.registry;
import net.fabricmc.fabric.api.util.Item2ObjectMap; import net.fabricmc.fabric.api.util.Item2ObjectMap;
import net.fabricmc.fabric.impl.item.CompostingChanceRegistryImpl; import net.fabricmc.fabric.impl.registry.CompostingChanceRegistryImpl;
/** /**
* Registry of items to 0.0-1.0 values, defining the chance of a given item * Registry of items to 0.0-1.0 values, defining the chance of a given item
* increasing the Composter block's level * increasing the Composter block's level
*/ */
public interface CompostingChanceRegistry extends Item2ObjectMap<Float> { public interface CompostingChanceRegistry extends Item2ObjectMap<Float> {
public static final CompostingChanceRegistry INSTANCE = new CompostingChanceRegistryImpl(); final CompostingChanceRegistry INSTANCE = new CompostingChanceRegistryImpl();
} }

View file

@ -17,11 +17,11 @@
package net.fabricmc.fabric.api.registry; package net.fabricmc.fabric.api.registry;
import net.fabricmc.fabric.api.util.Item2ObjectMap; import net.fabricmc.fabric.api.util.Item2ObjectMap;
import net.fabricmc.fabric.impl.item.FuelRegistryImpl; import net.fabricmc.fabric.impl.registry.FuelRegistryImpl;
/** /**
* Registry of items to 0-32767 fuel burn time values, in in-game ticks. * Registry of items to 0-32767 fuel burn time values, in in-game ticks.
*/ */
public interface FuelRegistry extends Item2ObjectMap<Integer> { public interface FuelRegistry extends Item2ObjectMap<Integer> {
public static final FuelRegistry INSTANCE = new FuelRegistryImpl(); final FuelRegistry INSTANCE = FuelRegistryImpl.INSTANCE;
} }

View file

@ -14,24 +14,24 @@
* limitations under the License. * limitations under the License.
*/ */
package net.fabricmc.fabric.api.loot; package net.fabricmc.fabric.api.registry;
import net.fabricmc.fabric.impl.loot.LootEntryRegistryImpl; import net.fabricmc.fabric.impl.registry.LootEntryTypeRegistryImpl;
import net.minecraft.world.loot.entry.LootEntry; import net.minecraft.world.loot.entry.LootEntry;
/** /**
* Fabric's extensions to {@code net.minecraft.world.loot.entry.LootEntries} for registering * Fabric's extensions to {@code net.minecraft.world.loot.entry.LootEntries} for registering
* custom loot entry types. * custom loot entry types.
* *
* @see #registerType * @see #register
*/ */
public interface LootEntryRegistry { public interface LootEntryTypeRegistry {
LootEntryRegistry INSTANCE = LootEntryRegistryImpl.INSTANCE; final LootEntryTypeRegistry INSTANCE = LootEntryTypeRegistryImpl.INSTANCE;
/** /**
* Registers a loot entry type by its serializer. * Registers a loot entry type by its serializer.
* *
* @param serializer the loot entry serializer * @param serializer the loot entry serializer
*/ */
void registerType(LootEntry.Serializer<?> serializer); void register(LootEntry.Serializer<?> serializer);
} }

View file

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package net.fabricmc.fabric.impl.item; package net.fabricmc.fabric.impl.registry;
import net.fabricmc.fabric.api.registry.CompostingChanceRegistry; import net.fabricmc.fabric.api.registry.CompostingChanceRegistry;
import net.minecraft.block.ComposterBlock; import net.minecraft.block.ComposterBlock;

View file

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package net.fabricmc.fabric.impl.item; package net.fabricmc.fabric.impl.registry;
import it.unimi.dsi.fastutil.objects.Object2IntLinkedOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2IntLinkedOpenHashMap;
import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.Object2IntMap;
@ -30,6 +30,7 @@ import java.util.Map;
// TODO: Clamp values to 32767 (+ add hook for mods which extend the limit to disable the check?) // TODO: Clamp values to 32767 (+ add hook for mods which extend the limit to disable the check?)
public class FuelRegistryImpl implements FuelRegistry { public class FuelRegistryImpl implements FuelRegistry {
public static final FuelRegistryImpl INSTANCE = new FuelRegistryImpl();
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogManager.getLogger();
private final Object2IntMap<ItemProvider> itemCookTimes = new Object2IntLinkedOpenHashMap<>(); private final Object2IntMap<ItemProvider> itemCookTimes = new Object2IntLinkedOpenHashMap<>();
private final Object2IntMap<Tag<Item>> tagCookTimes = new Object2IntLinkedOpenHashMap<>(); private final Object2IntMap<Tag<Item>> tagCookTimes = new Object2IntLinkedOpenHashMap<>();
@ -40,7 +41,7 @@ public class FuelRegistryImpl implements FuelRegistry {
@Override @Override
public Integer get(ItemProvider item) { public Integer get(ItemProvider item) {
return AbstractFurnaceBlockEntity.createBurnableMap().get(item.getItem()); return AbstractFurnaceBlockEntity.createFuelTimeMap().get(item.getItem());
} }
@Override @Override
@ -48,7 +49,7 @@ public class FuelRegistryImpl implements FuelRegistry {
if (cookTime > 32767) { if (cookTime > 32767) {
LOGGER.warn("Tried to register an overly high cookTime: " + cookTime + " > 32767! (" + item + ")"); LOGGER.warn("Tried to register an overly high cookTime: " + cookTime + " > 32767! (" + item + ")");
} }
itemCookTimes.put(item, cookTime); itemCookTimes.put(item, cookTime.intValue());
} }
@Override @Override
@ -56,7 +57,7 @@ public class FuelRegistryImpl implements FuelRegistry {
if (cookTime > 32767) { if (cookTime > 32767) {
LOGGER.warn("Tried to register an overly high cookTime: " + cookTime + " > 32767! (" + tag.getId() + ")"); LOGGER.warn("Tried to register an overly high cookTime: " + cookTime + " > 32767! (" + tag.getId() + ")");
} }
tagCookTimes.put(tag, cookTime); tagCookTimes.put(tag, cookTime.intValue());
} }
@Override @Override

View file

@ -14,31 +14,31 @@
* limitations under the License. * limitations under the License.
*/ */
package net.fabricmc.fabric.impl.loot; package net.fabricmc.fabric.impl.registry;
import net.fabricmc.fabric.api.loot.LootEntryRegistry; import net.fabricmc.fabric.api.registry.LootEntryTypeRegistry;
import net.minecraft.world.loot.entry.LootEntries; import net.minecraft.world.loot.entry.LootEntries;
import net.minecraft.world.loot.entry.LootEntry; import net.minecraft.world.loot.entry.LootEntry;
import java.util.function.Consumer; import java.util.function.Consumer;
public final class LootEntryRegistryImpl implements LootEntryRegistry { public final class LootEntryTypeRegistryImpl implements LootEntryTypeRegistry {
private static Consumer<LootEntry.Serializer<?>> registerFunction; private static Consumer<LootEntry.Serializer<?>> registerFunction;
public static final LootEntryRegistryImpl INSTANCE = new LootEntryRegistryImpl(); public static final LootEntryTypeRegistryImpl INSTANCE = new LootEntryTypeRegistryImpl();
static { static {
loadLootEntries(); loadLootEntries();
} }
private LootEntryRegistryImpl() {} private LootEntryTypeRegistryImpl() {}
@Override @Override
public void registerType(LootEntry.Serializer<?> serializer) { public void register(LootEntry.Serializer<?> serializer) {
registerFunction.accept(serializer); registerFunction.accept(serializer);
} }
public static void setRegisterFunction(Consumer<LootEntry.Serializer<?>> registerFunction) { public static void setRegisterFunction(Consumer<LootEntry.Serializer<?>> registerFunction) {
LootEntryRegistryImpl.registerFunction = registerFunction; LootEntryTypeRegistryImpl.registerFunction = registerFunction;
} }
private static void loadLootEntries() { private static void loadLootEntries() {

View file

@ -16,7 +16,7 @@
package net.fabricmc.fabric.mixin.item; package net.fabricmc.fabric.mixin.item;
import net.fabricmc.fabric.impl.item.FuelRegistryImpl; import net.fabricmc.fabric.impl.registry.FuelRegistryImpl;
import net.minecraft.block.entity.AbstractFurnaceBlockEntity; import net.minecraft.block.entity.AbstractFurnaceBlockEntity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
@ -28,8 +28,8 @@ import java.util.Map;
@Mixin(AbstractFurnaceBlockEntity.class) @Mixin(AbstractFurnaceBlockEntity.class)
public class MixinAbstractFurnaceBlockEntity { public class MixinAbstractFurnaceBlockEntity {
@Inject(at = @At("RETURN"), method = "getBurnTimeMap") @Inject(at = @At("RETURN"), method = "createFuelTimeMap")
private static void burnTimeMapHook(CallbackInfoReturnable<Map<Item, Integer>> info) { private static void fuelTimeMapHook(CallbackInfoReturnable<Map<Item, Integer>> info) {
FuelRegistryImpl.INSTANCE.apply(info.getReturnValue()); FuelRegistryImpl.INSTANCE.apply(info.getReturnValue());
} }
} }

View file

@ -16,7 +16,7 @@
package net.fabricmc.fabric.mixin.loot; package net.fabricmc.fabric.mixin.loot;
import net.fabricmc.fabric.impl.loot.LootEntryRegistryImpl; import net.fabricmc.fabric.impl.registry.LootEntryTypeRegistryImpl;
import net.minecraft.world.loot.entry.LootEntries; import net.minecraft.world.loot.entry.LootEntries;
import net.minecraft.world.loot.entry.LootEntry; import net.minecraft.world.loot.entry.LootEntry;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
@ -32,6 +32,6 @@ public class MixinLootEntries {
@Inject(method = "<clinit>", at = @At("RETURN")) @Inject(method = "<clinit>", at = @At("RETURN"))
private static void onClinit(CallbackInfo info) { private static void onClinit(CallbackInfo info) {
LootEntryRegistryImpl.setRegisterFunction(MixinLootEntries::register); LootEntryTypeRegistryImpl.setRegisterFunction(MixinLootEntries::register);
} }
} }

View file

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

View file

@ -20,21 +20,25 @@ import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializationContext;
import net.fabricmc.api.ModInitializer; import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.loot.LootEntryRegistry; import net.fabricmc.fabric.api.registry.LootEntryTypeRegistry;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.JsonHelper; import net.minecraft.util.JsonHelper;
import net.minecraft.world.loot.LootChoice;
import net.minecraft.world.loot.condition.LootCondition; import net.minecraft.world.loot.condition.LootCondition;
import net.minecraft.world.loot.context.LootContext;
import net.minecraft.world.loot.entry.LootEntry; import net.minecraft.world.loot.entry.LootEntry;
import net.minecraft.world.loot.entry.TagEntry; import net.minecraft.world.loot.entry.TagEntry;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import java.util.function.Consumer;
public class LootEntryMod implements ModInitializer { public class LootEntryMod implements ModInitializer {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogManager.getLogger();
@Override @Override
public void onInitialize() { public void onInitialize() {
LootEntryRegistry.INSTANCE.registerType(new TestSerializer()); LootEntryTypeRegistry.INSTANCE.register(new TestSerializer());
} }
private static class TestSerializer extends LootEntry.Serializer<TagEntry> { private static class TestSerializer extends LootEntry.Serializer<TagEntry> {