diff --git a/src/main/java/appeng/core/AERecipeType.java b/core/src/main/java/appeng/core/AERecipeType.java similarity index 100% rename from src/main/java/appeng/core/AERecipeType.java rename to core/src/main/java/appeng/core/AERecipeType.java diff --git a/core/src/main/java/appeng/core/AppEng.java b/core/src/main/java/appeng/core/AppEng.java index 26c601c8c..b47d2babc 100644 --- a/core/src/main/java/appeng/core/AppEng.java +++ b/core/src/main/java/appeng/core/AppEng.java @@ -96,7 +96,6 @@ public interface AppEng { // modEventBus.addGenericListener(ParticleType.class, registration::registerParticleTypes); // modEventBus.addGenericListener(BlockEntityType.class, registration::registerTileEntities); // modEventBus.addGenericListener(ScreenHandlerType.class, registration::registerContainerTypes); -// modEventBus.addGenericListener(RecipeSerializer.class, registration::registerRecipeSerializers); // modEventBus.addGenericListener(Feature.class, registration::registerWorldGen); // modEventBus.addGenericListener(Biome.class, registration::registerBiomes); // modEventBus.addGenericListener(ModDimension.class, registration::registerModDimension); diff --git a/core/src/main/java/appeng/core/AppEngBase.java b/core/src/main/java/appeng/core/AppEngBase.java index af7732867..09bc78ca1 100644 --- a/core/src/main/java/appeng/core/AppEngBase.java +++ b/core/src/main/java/appeng/core/AppEngBase.java @@ -14,8 +14,12 @@ import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.network.TargetPoint; import appeng.hooks.ToolItemHook; import appeng.mixins.CriteriaRegisterMixin; +import appeng.recipes.handlers.*; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.recipe.Recipe; +import net.minecraft.recipe.RecipeType; +import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; import net.minecraft.world.World; @@ -42,6 +46,8 @@ public abstract class AppEngBase implements AppEng { registerTileEntities(); registerParticleTypes(); + registerRecipeTypes(); + registerRecipeSerializers(); setupInternalRegistries(); @@ -80,12 +86,32 @@ public abstract class AppEngBase implements AppEng { Registry.register(Registry.PARTICLE_TYPE, AppEng.makeId("vibrant_fx"), ParticleTypes.VIBRANT); } - public void registerTileEntities() { + private void registerTileEntities() { final ApiDefinitions definitions = Api.INSTANCE.definitions(); definitions.getRegistry().getBootstrapComponents(ITileEntityRegistrationComponent.class) .forEachRemaining(ITileEntityRegistrationComponent::register); } + private static > RecipeType registerRecipeType(String id) { + Identifier fullId = AppEng.makeId(id); + return Registry.register(Registry.RECIPE_TYPE, fullId, new AERecipeType<>(fullId)); + } + + private void registerRecipeTypes() { + GrinderRecipe.TYPE = registerRecipeType("grinder"); + InscriberRecipe.TYPE = registerRecipeType("inscriber"); + } + + private void registerRecipeSerializers() { + Registry.register(Registry.RECIPE_SERIALIZER, AppEng.makeId("quartz_knife"), QuartzKnifeRecipeSerializer.INSTANCE); + Registry.register(Registry.RECIPE_SERIALIZER, AppEng.makeId("grinder"), GrinderRecipeSerializer.INSTANCE); + Registry.register(Registry.RECIPE_SERIALIZER, AppEng.makeId("inscriber"), InscriberRecipeSerializer.INSTANCE); + + // FIXME FABRIC FacadeItem facadeItem = (FacadeItem) Api.INSTANCE.definitions().items().facade().item(); + // FIXME FABRIC r.registerAll(DisassembleRecipe.SERIALIZER, + // FIXME FABRIC FacadeRecipe.getSerializer(facadeItem)); + } + @Override public void sendToAllNearExcept(final PlayerEntity p, final double x, final double y, final double z, final double dist, final World w, final BasePacket packet) { diff --git a/core/src/main/java/appeng/core/api/definitions/ApiItems.java b/core/src/main/java/appeng/core/api/definitions/ApiItems.java index 9ec000e4d..764ba94f4 100644 --- a/core/src/main/java/appeng/core/api/definitions/ApiItems.java +++ b/core/src/main/java/appeng/core/api/definitions/ApiItems.java @@ -20,11 +20,14 @@ package appeng.core.api.definitions; import appeng.api.definitions.IItemDefinition; import appeng.api.definitions.IItems; +import appeng.api.features.AEFeature; import appeng.api.util.AEColoredItemDefinition; import appeng.bootstrap.FeatureFactory; import appeng.bootstrap.IItemRendering; import appeng.bootstrap.ItemRenderingCustomizer; import appeng.fluids.items.FluidDummyItem; +import appeng.items.tools.quartz.*; +import net.minecraft.item.ItemGroup; /** * Internal implementation for the API items @@ -93,57 +96,57 @@ public final class ApiItems implements IItems { private IItemDefinition dummyFluidItem; public ApiItems(FeatureFactory registry, ApiMaterials materials) { -// FeatureFactory certusTools = registry.features(AEFeature.CERTUS_QUARTZ_TOOLS); -// this.certusQuartzAxe = certusTools -// .item("certus_quartz_axe", props -> new QuartzAxeItem(props, AEFeature.CERTUS_QUARTZ_TOOLS)) -// .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_AXE).build(); -// this.certusQuartzHoe = certusTools -// .item("certus_quartz_hoe", props -> new QuartzHoeItem(props, AEFeature.CERTUS_QUARTZ_TOOLS)) -// .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_HOE).build(); -// this.certusQuartzShovel = certusTools -// .item("certus_quartz_shovel", props -> new QuartzSpadeItem(props, AEFeature.CERTUS_QUARTZ_TOOLS)) -// .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_SPADE).build(); -// this.certusQuartzPick = certusTools -// .item("certus_quartz_pickaxe", props -> new QuartzPickaxeItem(props, AEFeature.CERTUS_QUARTZ_TOOLS)) -// .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_PICKAXE).build(); -// this.certusQuartzSword = certusTools -// .item("certus_quartz_sword", props -> new QuartzSwordItem(props, AEFeature.CERTUS_QUARTZ_TOOLS)) -// .itemGroup(ItemGroup.COMBAT).addFeatures(AEFeature.QUARTZ_SWORD).build(); -// this.certusQuartzWrench = certusTools.item("certus_quartz_wrench", QuartzWrenchItem::new) -// .itemGroup(ItemGroup.TOOLS).props(props -> props.maxStackSize(1)).addFeatures(AEFeature.QUARTZ_WRENCH) -// .build(); -// this.certusQuartzKnife = certusTools -// .item("certus_quartz_cutting_knife", -// props -> new QuartzCuttingKnifeItem(props, AEFeature.CERTUS_QUARTZ_TOOLS)) -// .itemGroup(ItemGroup.TOOLS).props(props -> props.maxStackSize(1).maxDamage(50).setNoRepair()) -// .addFeatures(AEFeature.QUARTZ_KNIFE).build(); -// -// FeatureFactory netherTools = registry.features(AEFeature.NETHER_QUARTZ_TOOLS); -// this.netherQuartzAxe = netherTools -// .item("nether_quartz_axe", props -> new QuartzAxeItem(props, AEFeature.NETHER_QUARTZ_TOOLS)) -// .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_AXE).build(); -// this.netherQuartzHoe = netherTools -// .item("nether_quartz_hoe", props -> new QuartzHoeItem(props, AEFeature.NETHER_QUARTZ_TOOLS)) -// .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_HOE).build(); -// this.netherQuartzShovel = netherTools -// .item("nether_quartz_shovel", props -> new QuartzSpadeItem(props, AEFeature.NETHER_QUARTZ_TOOLS)) -// .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_SPADE).build(); -// this.netherQuartzPick = netherTools -// .item("nether_quartz_pickaxe", props -> new QuartzPickaxeItem(props, AEFeature.NETHER_QUARTZ_TOOLS)) -// .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_PICKAXE).build(); -// this.netherQuartzSword = netherTools -// .item("nether_quartz_sword", props -> new QuartzSwordItem(props, AEFeature.NETHER_QUARTZ_TOOLS)) -// .itemGroup(ItemGroup.COMBAT).addFeatures(AEFeature.QUARTZ_SWORD).build(); -// this.netherQuartzWrench = netherTools.item("nether_quartz_wrench", QuartzWrenchItem::new) -// .itemGroup(ItemGroup.TOOLS).props(props -> props.maxStackSize(1)).addFeatures(AEFeature.QUARTZ_WRENCH) -// .build(); -// this.netherQuartzKnife = netherTools -// .item("nether_quartz_cutting_knife", -// props -> new QuartzCuttingKnifeItem(props, AEFeature.NETHER_QUARTZ_TOOLS)) -// .itemGroup(ItemGroup.TOOLS).props(props -> props.maxStackSize(1).maxDamage(50).setNoRepair()) -// .addFeatures(AEFeature.QUARTZ_KNIFE).build(); -// -// Consumer chargedDefaults = props -> props.maxStackSize(1).maxDamage(32).setNoRepair(); + FeatureFactory certusTools = registry.features(AEFeature.CERTUS_QUARTZ_TOOLS); + this.certusQuartzAxe = certusTools + .item("certus_quartz_axe", props -> new QuartzAxeItem(props, AEFeature.CERTUS_QUARTZ_TOOLS)) + .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_AXE).build(); + this.certusQuartzHoe = certusTools + .item("certus_quartz_hoe", props -> new QuartzHoeItem(props, AEFeature.CERTUS_QUARTZ_TOOLS)) + .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_HOE).build(); + this.certusQuartzShovel = certusTools + .item("certus_quartz_shovel", props -> new QuartzSpadeItem(props, AEFeature.CERTUS_QUARTZ_TOOLS)) + .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_SPADE).build(); + this.certusQuartzPick = certusTools + .item("certus_quartz_pickaxe", props -> new QuartzPickaxeItem(props, AEFeature.CERTUS_QUARTZ_TOOLS)) + .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_PICKAXE).build(); + this.certusQuartzSword = certusTools + .item("certus_quartz_sword", props -> new QuartzSwordItem(props, AEFeature.CERTUS_QUARTZ_TOOLS)) + .itemGroup(ItemGroup.COMBAT).addFeatures(AEFeature.QUARTZ_SWORD).build(); + this.certusQuartzWrench = certusTools.item("certus_quartz_wrench", QuartzWrenchItem::new) + .itemGroup(ItemGroup.TOOLS).props(props -> props.maxCount(1)).addFeatures(AEFeature.QUARTZ_WRENCH) + .build(); + this.certusQuartzKnife = certusTools + .item("certus_quartz_cutting_knife", + props -> new QuartzCuttingKnifeItem(props, AEFeature.CERTUS_QUARTZ_TOOLS)) + .itemGroup(ItemGroup.TOOLS).props(props -> props.maxCount(1).maxDamage(50)) + .addFeatures(AEFeature.QUARTZ_KNIFE).build(); + + FeatureFactory netherTools = registry.features(AEFeature.NETHER_QUARTZ_TOOLS); + this.netherQuartzAxe = netherTools + .item("nether_quartz_axe", props -> new QuartzAxeItem(props, AEFeature.NETHER_QUARTZ_TOOLS)) + .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_AXE).build(); + this.netherQuartzHoe = netherTools + .item("nether_quartz_hoe", props -> new QuartzHoeItem(props, AEFeature.NETHER_QUARTZ_TOOLS)) + .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_HOE).build(); + this.netherQuartzShovel = netherTools + .item("nether_quartz_shovel", props -> new QuartzSpadeItem(props, AEFeature.NETHER_QUARTZ_TOOLS)) + .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_SPADE).build(); + this.netherQuartzPick = netherTools + .item("nether_quartz_pickaxe", props -> new QuartzPickaxeItem(props, AEFeature.NETHER_QUARTZ_TOOLS)) + .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_PICKAXE).build(); + this.netherQuartzSword = netherTools + .item("nether_quartz_sword", props -> new QuartzSwordItem(props, AEFeature.NETHER_QUARTZ_TOOLS)) + .itemGroup(ItemGroup.COMBAT).addFeatures(AEFeature.QUARTZ_SWORD).build(); + this.netherQuartzWrench = netherTools.item("nether_quartz_wrench", QuartzWrenchItem::new) + .itemGroup(ItemGroup.TOOLS).props(props -> props.maxCount(1)).addFeatures(AEFeature.QUARTZ_WRENCH) + .build(); + this.netherQuartzKnife = netherTools + .item("nether_quartz_cutting_knife", + props -> new QuartzCuttingKnifeItem(props, AEFeature.NETHER_QUARTZ_TOOLS)) + .itemGroup(ItemGroup.TOOLS).props(props -> props.maxCount(1).maxDamage(50)) + .addFeatures(AEFeature.QUARTZ_KNIFE).build(); + +// Consumer chargedDefaults = props -> props.maxCount(1).maxDamage(32).setNoRepair(); // // FeatureFactory powerTools = registry.features(AEFeature.POWERED_TOOLS); // this.entropyManipulator = powerTools.item("entropy_manipulator", EntropyManipulatorItem::new) @@ -162,19 +165,19 @@ public final class ApiItems implements IItems { // .rendering(new ColorApplicatorItemRendering()).build(); // // this.biometricCard = registry.item("biometric_card", BiometricCardItem::new) -// .props(props -> props.maxStackSize(1)).features(AEFeature.SECURITY).build(); -// this.memoryCard = registry.item("memory_card", MemoryCardItem::new).props(props -> props.maxStackSize(1)) +// .props(props -> props.maxCount(1)).features(AEFeature.SECURITY).build(); +// this.memoryCard = registry.item("memory_card", MemoryCardItem::new).props(props -> props.maxCount(1)) // .features(AEFeature.MEMORY_CARD).build(); // this.networkTool = registry.item("network_tool", NetworkToolItem::new) -// .props(props -> props.maxStackSize(1).addToolType(FabricToolTags.get("wrench"), 0)) +// .props(props -> props.maxCount(1).addToolType(FabricToolTags.get("wrench"), 0)) // .features(AEFeature.NETWORK_TOOL).build(); // // this.cellCreative = registry.item("creative_storage_cell", CreativeStorageCellItem::new) -// .props(props -> props.maxStackSize(1)).features(AEFeature.STORAGE_CELLS, AEFeature.CREATIVE).build(); -// this.viewCell = registry.item("view_cell", ViewCellItem::new).props(props -> props.maxStackSize(1)) +// .props(props -> props.maxCount(1)).features(AEFeature.STORAGE_CELLS, AEFeature.CREATIVE).build(); +// this.viewCell = registry.item("view_cell", ViewCellItem::new).props(props -> props.maxCount(1)) // .features(AEFeature.VIEW_CELL).build(); // -// Consumer storageCellProps = p -> p.maxStackSize(1); +// Consumer storageCellProps = p -> p.maxCount(1); // // FeatureFactory storageCells = registry.features(AEFeature.STORAGE_CELLS); // this.cell1k = storageCells @@ -243,7 +246,7 @@ public final class ApiItems implements IItems { // // // rv1 // this.encodedPattern = registry.item("encoded_pattern", EncodedPatternItem::new) -// .props(props -> props.maxStackSize(1)).features(AEFeature.PATTERNS).build(); +// .props(props -> props.maxCount(1)).features(AEFeature.PATTERNS).build(); // // this.coloredPaintBall = createPaintBalls(registry, "_paint_ball", false); // this.coloredLumenPaintBall = createPaintBalls(registry, "_lumen_paint_ball", true); diff --git a/core/src/main/java/appeng/core/sync/packets/SpawnEntityPacket.java b/core/src/main/java/appeng/core/sync/packets/SpawnEntityPacket.java index 1686e9ba3..4e29b3eac 100644 --- a/core/src/main/java/appeng/core/sync/packets/SpawnEntityPacket.java +++ b/core/src/main/java/appeng/core/sync/packets/SpawnEntityPacket.java @@ -93,6 +93,8 @@ public class SpawnEntityPacket extends BasePacket { if (entity != null) { entity.updateTrackedPosition(x, y, z); + // NOTE: Vanilla doesn't do this for all spawned entities, but why transfer the velocity??? + entity.setVelocityClient(velocityX, velocityY, velocityZ); entity.refreshPositionAfterTeleport(x, y, z); entity.pitch = (float)(pitch * 360) / 256.0F; entity.yaw = (float)(yaw * 360) / 256.0F; diff --git a/src/main/java/appeng/items/tools/quartz/QuartzAxeItem.java b/core/src/main/java/appeng/items/tools/quartz/QuartzAxeItem.java similarity index 88% rename from src/main/java/appeng/items/tools/quartz/QuartzAxeItem.java rename to core/src/main/java/appeng/items/tools/quartz/QuartzAxeItem.java index db6d649f0..95018d624 100644 --- a/src/main/java/appeng/items/tools/quartz/QuartzAxeItem.java +++ b/core/src/main/java/appeng/items/tools/quartz/QuartzAxeItem.java @@ -21,7 +21,7 @@ package appeng.items.tools.quartz; import net.minecraft.item.AxeItem; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemTier; +import net.minecraft.item.ToolMaterials; import appeng.api.features.AEFeature; import appeng.util.Platform; @@ -30,12 +30,12 @@ public class QuartzAxeItem extends AxeItem { private final AEFeature type; public QuartzAxeItem(Item.Settings props, final AEFeature type) { - super(ItemTier.IRON, 6.0F, -3.1F, props); + super(ToolMaterials.IRON, 6.0F, -3.1F, props); this.type = type; } @Override - public boolean getIsRepairable(final ItemStack a, final ItemStack b) { + public boolean canRepair(final ItemStack a, final ItemStack b) { return Platform.canRepair(this.type, a, b); } } diff --git a/src/main/java/appeng/items/tools/quartz/QuartzCuttingKnifeItem.java b/core/src/main/java/appeng/items/tools/quartz/QuartzCuttingKnifeItem.java similarity index 58% rename from src/main/java/appeng/items/tools/quartz/QuartzCuttingKnifeItem.java rename to core/src/main/java/appeng/items/tools/quartz/QuartzCuttingKnifeItem.java index f17f722ff..e01ca0a89 100644 --- a/src/main/java/appeng/items/tools/quartz/QuartzCuttingKnifeItem.java +++ b/core/src/main/java/appeng/items/tools/quartz/QuartzCuttingKnifeItem.java @@ -18,10 +18,10 @@ package appeng.items.tools.quartz; +import appeng.mixins.RemainderSetter; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUsageContext; import net.minecraft.util.TypedActionResult; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; @@ -31,11 +31,7 @@ import net.minecraft.world.World; import appeng.api.features.AEFeature; import appeng.api.implementations.guiobjects.IGuiItem; import appeng.api.implementations.guiobjects.IGuiItemObject; -import appeng.container.ContainerLocator; -import appeng.container.ContainerOpener; -import appeng.container.implementations.QuartzKnifeContainer; import appeng.items.AEBaseItem; -import appeng.items.contents.QuartzKnifeObj; import appeng.util.Platform; public class QuartzCuttingKnifeItem extends AEBaseItem implements IGuiItem { @@ -44,48 +40,24 @@ public class QuartzCuttingKnifeItem extends AEBaseItem implements IGuiItem { public QuartzCuttingKnifeItem(Item.Settings props, final AEFeature type) { super(props); this.type = type; + // See below for reasoning + ((RemainderSetter)this).setRecipeRemainder(this); } @Override - public ActionResult onItemUse(ItemUsageContext context) { - PlayerEntity player = context.getPlayer(); - if (Platform.isServer() && player != null) { - ContainerOpener.openContainer(QuartzKnifeContainer.TYPE, context.getPlayer(), - ContainerLocator.forItemUseContext(context)); - } - return ActionResult.SUCCESS; - } - - @Override - public TypedActionResult onItemRightClick(final World w, final PlayerEntity p, final Hand hand) { + public TypedActionResult use(final World w, final PlayerEntity p, final Hand hand) { if (Platform.isServer()) { - ContainerOpener.openContainer(QuartzKnifeContainer.TYPE, p, ContainerLocator.forHand(p, hand)); + // FIXME FABRIC ContainerOpener.openContainer(QuartzKnifeContainer.TYPE, p, ContainerLocator.forHand(p, hand)); + throw new IllegalStateException(); } - p.swingArm(hand); + p.swingHand(hand); return new TypedActionResult<>(ActionResult.SUCCESS, p.getStackInHand(hand)); } - @Override - public boolean getIsRepairable(final ItemStack a, final ItemStack b) { - return Platform.canRepair(this.type, a, b); - } - - @Override - public ItemStack getRecipeRemainder(final ItemStack itemStack) { - ItemStack copy = itemStack.copy(); - copy.setDamage(itemStack.getDamage() + 1); - - return copy; - } - - @Override - public boolean hasRecipeRemainder(final ItemStack stack) { - return true; - } - @Override public IGuiItemObject getGuiObject(final ItemStack is, int playerInventorySlot, final World world, final BlockPos pos) { - return new QuartzKnifeObj(is); + // FIXME FABRIC return new QuartzKnifeObj(is); + throw new IllegalStateException(); } } diff --git a/src/main/java/appeng/items/tools/quartz/QuartzHoeItem.java b/core/src/main/java/appeng/items/tools/quartz/QuartzHoeItem.java similarity index 88% rename from src/main/java/appeng/items/tools/quartz/QuartzHoeItem.java rename to core/src/main/java/appeng/items/tools/quartz/QuartzHoeItem.java index cf81d171b..ff8811628 100644 --- a/src/main/java/appeng/items/tools/quartz/QuartzHoeItem.java +++ b/core/src/main/java/appeng/items/tools/quartz/QuartzHoeItem.java @@ -21,7 +21,7 @@ package appeng.items.tools.quartz; import net.minecraft.item.HoeItem; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemTier; +import net.minecraft.item.ToolMaterials; import appeng.api.features.AEFeature; import appeng.util.Platform; @@ -30,12 +30,12 @@ public class QuartzHoeItem extends HoeItem { private final AEFeature type; public QuartzHoeItem(Item.Settings props, final AEFeature type) { - super(ItemTier.IRON, -1.0F, props); + super(ToolMaterials.IRON, -2, -1.0F, props); this.type = type; } @Override - public boolean getIsRepairable(final ItemStack a, final ItemStack b) { + public boolean canRepair(final ItemStack a, final ItemStack b) { return Platform.canRepair(this.type, a, b); } diff --git a/src/main/java/appeng/items/tools/quartz/QuartzPickaxeItem.java b/core/src/main/java/appeng/items/tools/quartz/QuartzPickaxeItem.java similarity index 88% rename from src/main/java/appeng/items/tools/quartz/QuartzPickaxeItem.java rename to core/src/main/java/appeng/items/tools/quartz/QuartzPickaxeItem.java index 5827c6ab0..ef78165c9 100644 --- a/src/main/java/appeng/items/tools/quartz/QuartzPickaxeItem.java +++ b/core/src/main/java/appeng/items/tools/quartz/QuartzPickaxeItem.java @@ -20,7 +20,7 @@ package appeng.items.tools.quartz; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemTier; +import net.minecraft.item.ToolMaterials; import net.minecraft.item.PickaxeItem; import appeng.api.features.AEFeature; @@ -30,12 +30,12 @@ public class QuartzPickaxeItem extends PickaxeItem { private final AEFeature type; public QuartzPickaxeItem(Item.Settings props, final AEFeature type) { - super(ItemTier.IRON, 1, -2.8F, props); + super(ToolMaterials.IRON, 1, -2.8F, props); this.type = type; } @Override - public boolean getIsRepairable(final ItemStack a, final ItemStack b) { + public boolean canRepair(final ItemStack a, final ItemStack b) { return Platform.canRepair(this.type, a, b); } } diff --git a/src/main/java/appeng/items/tools/quartz/QuartzSpadeItem.java b/core/src/main/java/appeng/items/tools/quartz/QuartzSpadeItem.java similarity index 88% rename from src/main/java/appeng/items/tools/quartz/QuartzSpadeItem.java rename to core/src/main/java/appeng/items/tools/quartz/QuartzSpadeItem.java index 9579bd259..1f0d060fa 100644 --- a/src/main/java/appeng/items/tools/quartz/QuartzSpadeItem.java +++ b/core/src/main/java/appeng/items/tools/quartz/QuartzSpadeItem.java @@ -20,7 +20,7 @@ package appeng.items.tools.quartz; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemTier; +import net.minecraft.item.ToolMaterials; import net.minecraft.item.ShovelItem; import appeng.api.features.AEFeature; @@ -30,12 +30,12 @@ public class QuartzSpadeItem extends ShovelItem { private final AEFeature type; public QuartzSpadeItem(Item.Settings props, final AEFeature type) { - super(ItemTier.IRON, 1.5F, -3.0F, props); + super(ToolMaterials.IRON, 1.5F, -3.0F, props); this.type = type; } @Override - public boolean getIsRepairable(final ItemStack a, final ItemStack b) { + public boolean canRepair(final ItemStack a, final ItemStack b) { return Platform.canRepair(this.type, a, b); } } diff --git a/src/main/java/appeng/items/tools/quartz/QuartzSwordItem.java b/core/src/main/java/appeng/items/tools/quartz/QuartzSwordItem.java similarity index 88% rename from src/main/java/appeng/items/tools/quartz/QuartzSwordItem.java rename to core/src/main/java/appeng/items/tools/quartz/QuartzSwordItem.java index 22d1346cb..ddc0d4245 100644 --- a/src/main/java/appeng/items/tools/quartz/QuartzSwordItem.java +++ b/core/src/main/java/appeng/items/tools/quartz/QuartzSwordItem.java @@ -20,7 +20,7 @@ package appeng.items.tools.quartz; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemTier; +import net.minecraft.item.ToolMaterials; import net.minecraft.item.SwordItem; import appeng.api.features.AEFeature; @@ -30,12 +30,12 @@ public class QuartzSwordItem extends SwordItem { private final AEFeature type; public QuartzSwordItem(Item.Settings props, AEFeature type) { - super(ItemTier.IRON, 3, -2.4F, props); + super(ToolMaterials.IRON, 3, -2.4F, props); this.type = type; } @Override - public boolean getIsRepairable(final ItemStack a, final ItemStack b) { + public boolean canRepair(final ItemStack a, final ItemStack b) { return Platform.canRepair(this.type, a, b); } } diff --git a/src/main/java/appeng/items/tools/quartz/QuartzWrenchItem.java b/core/src/main/java/appeng/items/tools/quartz/QuartzWrenchItem.java similarity index 93% rename from src/main/java/appeng/items/tools/quartz/QuartzWrenchItem.java rename to core/src/main/java/appeng/items/tools/quartz/QuartzWrenchItem.java index dd412cb81..ac712eedd 100644 --- a/src/main/java/appeng/items/tools/quartz/QuartzWrenchItem.java +++ b/core/src/main/java/appeng/items/tools/quartz/QuartzWrenchItem.java @@ -18,6 +18,7 @@ package appeng.items.tools.quartz; +import appeng.hooks.AEToolItem; import net.minecraft.block.Block; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; @@ -32,7 +33,7 @@ import appeng.block.AEBaseBlock; import appeng.items.AEBaseItem; import appeng.util.Platform; -public class QuartzWrenchItem extends AEBaseItem implements IAEWrench { +public class QuartzWrenchItem extends AEBaseItem implements IAEWrench, AEToolItem { public QuartzWrenchItem(Item.Settings props) { super(props); @@ -52,8 +53,8 @@ public class QuartzWrenchItem extends AEBaseItem implements IAEWrench { } AEBaseBlock aeBlock = (AEBaseBlock) block; - if (aeBlock.rotateAroundFaceAxis(context.getWorld(), context.getBlockPos(), context.getFace())) { - context.getPlayer().swingArm(context.getHand()); + if (aeBlock.rotateAroundFaceAxis(context.getWorld(), context.getBlockPos(), context.getSide())) { + context.getPlayer().swingHand(context.getHand()); return !context.getWorld().isClient ? ActionResult.SUCCESS : ActionResult.FAIL; } } diff --git a/core/src/main/java/appeng/mixins/RecipeManagerMixin.java b/core/src/main/java/appeng/mixins/RecipeManagerMixin.java new file mode 100644 index 000000000..ee52e415e --- /dev/null +++ b/core/src/main/java/appeng/mixins/RecipeManagerMixin.java @@ -0,0 +1,19 @@ +package appeng.mixins; + +import net.minecraft.inventory.Inventory; +import net.minecraft.recipe.Recipe; +import net.minecraft.recipe.RecipeManager; +import net.minecraft.recipe.RecipeType; +import net.minecraft.util.Identifier; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + +import java.util.Map; + +@Mixin(RecipeManager.class) +public interface RecipeManagerMixin { + + @Invoker + > Map> callGetAllOfType(RecipeType type); + +} diff --git a/core/src/main/java/appeng/mixins/RemainderSetter.java b/core/src/main/java/appeng/mixins/RemainderSetter.java new file mode 100644 index 000000000..c758b2f4f --- /dev/null +++ b/core/src/main/java/appeng/mixins/RemainderSetter.java @@ -0,0 +1,11 @@ +package appeng.mixins; + +import net.minecraft.item.Item; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(Item.class) +public interface RemainderSetter { + @Accessor("recipeRemainder") + void setRecipeRemainder(Item item); +} diff --git a/core/src/main/java/appeng/mixins/ShapelessRecipeMixin.java b/core/src/main/java/appeng/mixins/ShapelessRecipeMixin.java new file mode 100644 index 000000000..e89fc35fb --- /dev/null +++ b/core/src/main/java/appeng/mixins/ShapelessRecipeMixin.java @@ -0,0 +1,13 @@ +package appeng.mixins; + +import net.minecraft.recipe.ShapelessRecipe; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(ShapelessRecipe.class) +public interface ShapelessRecipeMixin { + + @Accessor("group") + String getGroup(); + +} diff --git a/src/main/java/appeng/recipes/handlers/GrinderOptionalResult.java b/core/src/main/java/appeng/recipes/handlers/GrinderOptionalResult.java similarity index 100% rename from src/main/java/appeng/recipes/handlers/GrinderOptionalResult.java rename to core/src/main/java/appeng/recipes/handlers/GrinderOptionalResult.java diff --git a/src/main/java/appeng/recipes/handlers/GrinderRecipe.java b/core/src/main/java/appeng/recipes/handlers/GrinderRecipe.java similarity index 89% rename from src/main/java/appeng/recipes/handlers/GrinderRecipe.java rename to core/src/main/java/appeng/recipes/handlers/GrinderRecipe.java index 275950ad6..3f3ea4812 100644 --- a/src/main/java/appeng/recipes/handlers/GrinderRecipe.java +++ b/core/src/main/java/appeng/recipes/handlers/GrinderRecipe.java @@ -44,7 +44,7 @@ public class GrinderRecipe implements Recipe { @Override public boolean matches(Inventory inv, World worldIn) { - return this.ingredient.test(inv.getStackInSlot(0)); + return this.ingredient.test(inv.getStack(0)); } @Override @@ -54,12 +54,12 @@ public class GrinderRecipe implements Recipe { } @Override - public boolean canFit(int width, int height) { + public boolean fits(int width, int height) { return true; } @Override - public ItemStack getRecipeOutput() { + public ItemStack getOutput() { return result; } @@ -91,8 +91,8 @@ public class GrinderRecipe implements Recipe { } @Override - public DefaultedList getIngredients() { - DefaultedList nonnulllist = DefaultedList.create(); + public DefaultedList getPreviewInputs() { + DefaultedList nonnulllist = DefaultedList.of(); nonnulllist.add(this.ingredient); return nonnulllist; } diff --git a/src/main/java/appeng/recipes/handlers/GrinderRecipeSerializer.java b/core/src/main/java/appeng/recipes/handlers/GrinderRecipeSerializer.java similarity index 71% rename from src/main/java/appeng/recipes/handlers/GrinderRecipeSerializer.java rename to core/src/main/java/appeng/recipes/handlers/GrinderRecipeSerializer.java index 6ba2bbc60..2f4e3675f 100644 --- a/src/main/java/appeng/recipes/handlers/GrinderRecipeSerializer.java +++ b/core/src/main/java/appeng/recipes/handlers/GrinderRecipeSerializer.java @@ -13,40 +13,33 @@ import com.google.gson.JsonObject; import net.minecraft.item.ItemStack; import net.minecraft.recipe.Ingredient; import net.minecraft.recipe.RecipeSerializer; -import net.minecraft.item.crafting.ShapedRecipe; +import net.minecraft.recipe.ShapedRecipe; import net.minecraft.network.PacketByteBuf; import net.minecraft.util.Identifier; -import net.minecraft.util.JSONUtils; -import net.minecraftforge.registries.ForgeRegistryEntry; +import net.minecraft.util.JsonHelper; import appeng.core.AEConfig; -import appeng.core.AppEng; -public class GrinderRecipeSerializer extends ForgeRegistryEntry> - implements RecipeSerializer { +public class GrinderRecipeSerializer implements RecipeSerializer { public static final GrinderRecipeSerializer INSTANCE = new GrinderRecipeSerializer(); - static { - INSTANCE.setRegistryName(AppEng.MOD_ID, "grinder"); - } - private GrinderRecipeSerializer() { } @Override public GrinderRecipe read(Identifier recipeId, JsonObject json) { - String group = JSONUtils.getString(json, "group", ""); - JsonObject inputObj = JSONUtils.getJsonObject(json, "input"); - Ingredient ingredient = Ingredient.deserialize(inputObj); + String group = JsonHelper.getString(json, "group", ""); + JsonObject inputObj = JsonHelper.getObject(json, "input"); + Ingredient ingredient = Ingredient.fromJson(inputObj); int ingredientCount = 1; if (inputObj.has("count")) { ingredientCount = inputObj.get("count").getAsInt(); } - JsonObject result = JSONUtils.getJsonObject(json, "result"); - ItemStack primaryResult = ShapedRecipe.deserializeItem(JSONUtils.getJsonObject(result, "primary")); - JsonArray optionalResultsJson = JSONUtils.getJsonArray(result, "optional", null); + JsonObject result = JsonHelper.getObject(json, "result"); + ItemStack primaryResult = ShapedRecipe.getItemStack(JsonHelper.getObject(result, "primary")); + JsonArray optionalResultsJson = JsonHelper.getArray(result, "optional", null); List optionalResults = Collections.emptyList(); if (optionalResultsJson != null) { optionalResults = new ArrayList<>(optionalResultsJson.size()); @@ -54,14 +47,14 @@ public class GrinderRecipeSerializer extends ForgeRegistryEntry optionalResults = recipe.getOptionalResults(); buffer.writeVarInt(optionalResults.size()); diff --git a/src/main/java/appeng/recipes/handlers/GrinderRecipes.java b/core/src/main/java/appeng/recipes/handlers/GrinderRecipes.java similarity index 52% rename from src/main/java/appeng/recipes/handlers/GrinderRecipes.java rename to core/src/main/java/appeng/recipes/handlers/GrinderRecipes.java index 3b4ad7cb3..4933ec982 100644 --- a/src/main/java/appeng/recipes/handlers/GrinderRecipes.java +++ b/core/src/main/java/appeng/recipes/handlers/GrinderRecipes.java @@ -1,12 +1,11 @@ package appeng.recipes.handlers; -import javax.annotation.Nullable; - -import net.minecraft.inventory.Inventory; import net.minecraft.item.ItemStack; -import net.minecraft.recipe.Recipe; import net.minecraft.world.World; +import javax.annotation.Nullable; +import java.util.List; + public final class GrinderRecipes { private GrinderRecipes() { @@ -18,10 +17,11 @@ public final class GrinderRecipes { */ @Nullable public static GrinderRecipe findForInput(World world, ItemStack input) { - for (Recipe recipe : world.getRecipeManager().getRecipes(GrinderRecipe.TYPE).values()) { - GrinderRecipe grinderRecipe = (GrinderRecipe) recipe; - if (grinderRecipe.getIngredient().test(input) && input.getCount() >= grinderRecipe.getIngredientCount()) { - return grinderRecipe; + // FIXME: this is slow, this creates a full copy of the list everytime + List grinderRecipes = world.getRecipeManager().method_30027(GrinderRecipe.TYPE); + for (GrinderRecipe recipe : grinderRecipes) { + if (recipe.getIngredient().test(input) && input.getCount() >= recipe.getIngredientCount()) { + return recipe; } } return null; @@ -32,9 +32,10 @@ public final class GrinderRecipes { * disregarding its current size. */ public static boolean isValidIngredient(World world, ItemStack stack) { - for (Recipe recipe : world.getRecipeManager().getRecipes(GrinderRecipe.TYPE).values()) { - GrinderRecipe grinderRecipe = (GrinderRecipe) recipe; - if (grinderRecipe.getIngredient().test(stack)) { + // FIXME: this is slow, this creates a full copy of the list everytime + List grinderRecipes = world.getRecipeManager().method_30027(GrinderRecipe.TYPE); + for (GrinderRecipe recipe : grinderRecipes) { + if (recipe.getIngredient().test(stack)) { return true; } } diff --git a/src/main/java/appeng/recipes/handlers/InscriberRecipe.java b/core/src/main/java/appeng/recipes/handlers/InscriberRecipe.java similarity index 90% rename from src/main/java/appeng/recipes/handlers/InscriberRecipe.java rename to core/src/main/java/appeng/recipes/handlers/InscriberRecipe.java index e5c786815..0b46718ff 100644 --- a/src/main/java/appeng/recipes/handlers/InscriberRecipe.java +++ b/core/src/main/java/appeng/recipes/handlers/InscriberRecipe.java @@ -46,12 +46,12 @@ public class InscriberRecipe implements Recipe { } @Override - public boolean canFit(int width, int height) { + public boolean fits(int width, int height) { return true; } @Override - public ItemStack getRecipeOutput() { + public ItemStack getOutput() { return output; } @@ -71,8 +71,8 @@ public class InscriberRecipe implements Recipe { } @Override - public DefaultedList getIngredients() { - DefaultedList nonnulllist = DefaultedList.create(); + public DefaultedList getPreviewInputs() { + DefaultedList nonnulllist = DefaultedList.of(); nonnulllist.add(this.topOptional); nonnulllist.add(this.middleInput); nonnulllist.add(this.bottomOptional); @@ -83,10 +83,6 @@ public class InscriberRecipe implements Recipe { return middleInput; } - public ItemStack getOutput() { - return output; - } - public Ingredient getTopOptional() { return topOptional; } diff --git a/src/main/java/appeng/recipes/handlers/InscriberRecipeSerializer.java b/core/src/main/java/appeng/recipes/handlers/InscriberRecipeSerializer.java similarity index 60% rename from src/main/java/appeng/recipes/handlers/InscriberRecipeSerializer.java rename to core/src/main/java/appeng/recipes/handlers/InscriberRecipeSerializer.java index ac662f8f4..256dd8eb6 100644 --- a/src/main/java/appeng/recipes/handlers/InscriberRecipeSerializer.java +++ b/core/src/main/java/appeng/recipes/handlers/InscriberRecipeSerializer.java @@ -7,29 +7,22 @@ import com.google.gson.JsonObject; import net.minecraft.item.ItemStack; import net.minecraft.recipe.Ingredient; import net.minecraft.recipe.RecipeSerializer; -import net.minecraft.item.crafting.ShapedRecipe; +import net.minecraft.recipe.ShapedRecipe; import net.minecraft.network.PacketByteBuf; import net.minecraft.util.Identifier; -import net.minecraft.util.JSONUtils; -import net.minecraftforge.registries.ForgeRegistryEntry; +import net.minecraft.util.JsonHelper; import appeng.api.features.InscriberProcessType; -import appeng.core.AppEng; -public class InscriberRecipeSerializer extends ForgeRegistryEntry> - implements RecipeSerializer { +public class InscriberRecipeSerializer implements RecipeSerializer { public static final InscriberRecipeSerializer INSTANCE = new InscriberRecipeSerializer(); - static { - INSTANCE.setRegistryName(AppEng.MOD_ID, "inscriber"); - } - private InscriberRecipeSerializer() { } private static InscriberProcessType getMode(JsonObject json) { - String mode = JSONUtils.getString(json, "mode", "inscribe"); + String mode = JsonHelper.getString(json, "mode", "inscribe"); switch (mode) { case "inscribe": return InscriberProcessType.INSCRIBE; @@ -46,19 +39,19 @@ public class InscriberRecipeSerializer extends ForgeRegistryEntry getSerializer() { + return QuartzKnifeRecipeSerializer.INSTANCE; + } + + @Override + public DefaultedList getRemainingStacks(CraftingInventory inventory) { + DefaultedList defaultedList = DefaultedList.ofSize(inventory.size(), ItemStack.EMPTY); + + for (int i = 0; i < defaultedList.size(); ++i) { + ItemStack stack = inventory.getStack(i); + Item item = stack.getItem(); + if (item instanceof QuartzCuttingKnifeItem) { + // If it still has durability left, put a more damaged one back, otherwise consume + int newDamage = stack.getDamage() + 1; + if (newDamage < stack.getMaxDamage()) { + stack = stack.copy(); + stack.setDamage(newDamage); + defaultedList.set(i, stack); + } + } else if (item.hasRecipeRemainder()) { + defaultedList.set(i, new ItemStack(item.getRecipeRemainder())); + } + } + + return defaultedList; + } + +} diff --git a/core/src/main/java/appeng/recipes/handlers/QuartzKnifeRecipeSerializer.java b/core/src/main/java/appeng/recipes/handlers/QuartzKnifeRecipeSerializer.java new file mode 100644 index 000000000..f0577032b --- /dev/null +++ b/core/src/main/java/appeng/recipes/handlers/QuartzKnifeRecipeSerializer.java @@ -0,0 +1,22 @@ +package appeng.recipes.handlers; + +import com.google.gson.JsonObject; +import net.minecraft.network.PacketByteBuf; +import net.minecraft.recipe.ShapelessRecipe; +import net.minecraft.util.Identifier; + +public class QuartzKnifeRecipeSerializer extends ShapelessRecipe.Serializer { + + public static final QuartzKnifeRecipeSerializer INSTANCE = new QuartzKnifeRecipeSerializer(); + + @Override + public ShapelessRecipe read(Identifier identifier, JsonObject jsonObject) { + return new QuartzKnifeRecipe(super.read(identifier, jsonObject)); + } + + @Override + public ShapelessRecipe read(Identifier identifier, PacketByteBuf packetByteBuf) { + return new QuartzKnifeRecipe(super.read(identifier, packetByteBuf)); + } + +} diff --git a/core/src/main/resources/appliedenergistics2.mixins.json b/core/src/main/resources/appliedenergistics2.mixins.json index 1d27e061c..c589f7772 100644 --- a/core/src/main/resources/appliedenergistics2.mixins.json +++ b/core/src/main/resources/appliedenergistics2.mixins.json @@ -4,7 +4,9 @@ "package": "appeng.mixins", "compatibilityLevel": "JAVA_8", "mixins": [ - "CriteriaRegisterMixin" + "CriteriaRegisterMixin", + "RemainderSetter", + "ShapelessRecipeMixin" ], "client": [ "ModelsReloadMixin" diff --git a/core/src/main/resources/data/appliedenergistics2/recipes/network/parts/cable_anchor.json b/core/src/main/resources/data/appliedenergistics2/recipes/network/parts/cable_anchor.json index 15d0510d9..a4106933a 100644 --- a/core/src/main/resources/data/appliedenergistics2/recipes/network/parts/cable_anchor.json +++ b/core/src/main/resources/data/appliedenergistics2/recipes/network/parts/cable_anchor.json @@ -1,5 +1,5 @@ { - "type": "minecraft:crafting_shapeless", + "type": "appliedenergistics2:quartz_knife", "result": { "item": "appliedenergistics2:cable_anchor", "count": 3 diff --git a/core/src/main/resources/data/appliedenergistics2/tags/items/metal_ingots.json b/core/src/main/resources/data/appliedenergistics2/tags/items/metal_ingots.json index cd352b2e1..40290e097 100644 --- a/core/src/main/resources/data/appliedenergistics2/tags/items/metal_ingots.json +++ b/core/src/main/resources/data/appliedenergistics2/tags/items/metal_ingots.json @@ -1,3 +1,3 @@ { - "values": ["#forge:ingots/gold", "#forge:ingots/iron"] + "values": ["minecraft:gold_ingot", "minecraft:iron_ingot"] } diff --git a/src/main/java/appeng/client/render/crafting/EncodedPatternModelLoader.java b/src/main/java/appeng/client/render/crafting/EncodedPatternModelLoader.java index f558f9385..1f67c272b 100644 --- a/src/main/java/appeng/client/render/crafting/EncodedPatternModelLoader.java +++ b/src/main/java/appeng/client/render/crafting/EncodedPatternModelLoader.java @@ -5,7 +5,7 @@ import com.google.gson.JsonObject; import net.minecraft.resources.IResourceManager; import net.minecraft.util.Identifier; -import net.minecraft.util.JSONUtils; +import net.minecraft.util.JsonHelper; import net.minecraftforge.client.model.IModelLoader; /** @@ -23,7 +23,7 @@ public class EncodedPatternModelLoader implements IModelLoader(JSONUtils.getFloat(object, "sky", 0), JSONUtils.getFloat(object, "block", 0)); + return new ImmutablePair<>(JsonHelper.getFloat(object, "sky", 0), JsonHelper.getFloat(object, "block", 0)); } } diff --git a/src/main/java/appeng/container/implementations/UpgradeableContainer.java b/src/main/java/appeng/container/implementations/UpgradeableContainer.java index e68080a2e..58acdb2ca 100644 --- a/src/main/java/appeng/container/implementations/UpgradeableContainer.java +++ b/src/main/java/appeng/container/implementations/UpgradeableContainer.java @@ -113,7 +113,7 @@ public class UpgradeableContainer extends AEBaseContainer implements IOptionalSl final Inventory pi = this.getPlayerInv(); for (int x = 0; x < pi.size(); x++) { - final ItemStack pii = pi.getStackInSlot(x); + final ItemStack pii = pi.getStack(x); if (!pii.isEmpty() && pii.getItem() instanceof NetworkToolItem) { this.lockPlayerInventorySlot(x); this.tbSlot = x; diff --git a/src/main/java/appeng/core/FacadeItemGroup.java b/src/main/java/appeng/core/FacadeItemGroup.java index a488a7001..e68ca13b1 100644 --- a/src/main/java/appeng/core/FacadeItemGroup.java +++ b/src/main/java/appeng/core/FacadeItemGroup.java @@ -73,7 +73,7 @@ public final class FacadeItemGroup extends ItemGroup { Item blockItem = b.asItem(); if (blockItem != Items.AIR && blockItem.getGroup() != null) { - final DefaultedList tmpList = DefaultedList.create(); + final DefaultedList tmpList = DefaultedList.of(); b.appendStacks(blockItem.getGroup(), tmpList); for (final ItemStack l : tmpList) { final ItemStack facade = itemFacade.createFacadeForItem(l, false); diff --git a/src/main/java/appeng/core/Registration.java b/src/main/java/appeng/core/Registration.java index e6b8d248c..46aa952a1 100644 --- a/src/main/java/appeng/core/Registration.java +++ b/src/main/java/appeng/core/Registration.java @@ -277,17 +277,6 @@ final class Registration { return type; } - public void registerRecipeSerializers(RegistryEvent.Register> event) { - IForgeRegistry> r = event.getRegistry(); - - GrinderRecipe.TYPE = new AERecipeType<>(GrinderRecipeSerializer.INSTANCE.getRegistryName()); - InscriberRecipe.TYPE = new AERecipeType<>(InscriberRecipeSerializer.INSTANCE.getRegistryName()); - - FacadeItem facadeItem = (FacadeItem) Api.INSTANCE.definitions().items().facade().item(); - r.registerAll(DisassembleRecipe.SERIALIZER, GrinderRecipeSerializer.INSTANCE, - InscriberRecipeSerializer.INSTANCE, FacadeRecipe.getSerializer(facadeItem)); - } - // FIXME LATER public static void postInit() { final IRegistryContainer registries = AEApi.instance().registries(); diff --git a/src/main/java/appeng/debug/ItemGenBlockEntity.java b/src/main/java/appeng/debug/ItemGenBlockEntity.java index a96d8aa2d..0561ee0ac 100644 --- a/src/main/java/appeng/debug/ItemGenBlockEntity.java +++ b/src/main/java/appeng/debug/ItemGenBlockEntity.java @@ -62,7 +62,7 @@ public class ItemGenBlockEntity extends AEBaseBlockEntity { continue; } - final DefaultedList list = DefaultedList.create(); + final DefaultedList list = DefaultedList.of(); mi.appendStacks(mi.getGroup(), list); POSSIBLE_ITEMS.addAll(list); } diff --git a/src/main/java/appeng/debug/MeteoritePlacerItem.java b/src/main/java/appeng/debug/MeteoritePlacerItem.java index 67c3c5f4f..b437e58ba 100644 --- a/src/main/java/appeng/debug/MeteoritePlacerItem.java +++ b/src/main/java/appeng/debug/MeteoritePlacerItem.java @@ -51,7 +51,7 @@ public class MeteoritePlacerItem extends AEBaseItem { } @Override - public TypedActionResult onItemRightClick(World world, PlayerEntity player, Hand hand) { + public TypedActionResult use(World world, PlayerEntity player, Hand hand) { if (world.isClient()) { return TypedActionResult.resultPass(player.getStackInHand(hand)); } @@ -74,7 +74,7 @@ public class MeteoritePlacerItem extends AEBaseItem { return TypedActionResult.resultSuccess(itemStack); } - return super.onItemRightClick(world, player, hand); + return super.use(world, player, hand); } @Override diff --git a/src/main/java/appeng/hooks/MatterCannonDispenseItemBehavior.java b/src/main/java/appeng/hooks/MatterCannonDispenseItemBehavior.java index b206499fd..b141a55d6 100644 --- a/src/main/java/appeng/hooks/MatterCannonDispenseItemBehavior.java +++ b/src/main/java/appeng/hooks/MatterCannonDispenseItemBehavior.java @@ -57,7 +57,7 @@ public final class MatterCannonDispenseItemBehavior extends ItemDispenserBehavio p.updatePosition(p.getX() + dir.xOffset, p.getY() + dir.yOffset, p.getZ() + dir.zOffset); - dispensedItem = tm.onItemRightClick(w, p, null).getResult(); + dispensedItem = tm.use(w, p, null).getResult(); } } return dispensedItem; diff --git a/src/main/java/appeng/integration/modules/jei/FacadeRegistryPlugin.java b/src/main/java/appeng/integration/modules/jei/FacadeRegistryPlugin.java index c01273fef..2ca6357ef 100644 --- a/src/main/java/appeng/integration/modules/jei/FacadeRegistryPlugin.java +++ b/src/main/java/appeng/integration/modules/jei/FacadeRegistryPlugin.java @@ -23,7 +23,7 @@ import java.util.List; import net.minecraft.item.ItemStack; import net.minecraft.recipe.Ingredient; -import net.minecraft.item.crafting.ShapedRecipe; +import net.minecraft.recipe.ShapedRecipe; import net.minecraft.util.Identifier; import net.minecraft.util.collection.DefaultedList; diff --git a/src/main/java/appeng/integration/modules/jei/GrinderRecipeCategory.java b/src/main/java/appeng/integration/modules/jei/GrinderRecipeCategory.java index 6bd7e1731..3d6f2c1be 100644 --- a/src/main/java/appeng/integration/modules/jei/GrinderRecipeCategory.java +++ b/src/main/java/appeng/integration/modules/jei/GrinderRecipeCategory.java @@ -99,7 +99,7 @@ class GrinderRecipeCategory implements IRecipeCategory { public void setIngredients(GrinderRecipe recipe, IIngredients ingredients) { ingredients.setInputIngredients(Collections.singletonList(recipe.getIngredient())); List outputs = new ArrayList<>(3); - outputs.add(recipe.getRecipeOutput()); + outputs.add(recipe.getOutput()); for (GrinderOptionalResult optionalResult : recipe.getOptionalResults()) { outputs.add(optionalResult.getResult()); } diff --git a/src/main/java/appeng/items/misc/EncodedPatternItem.java b/src/main/java/appeng/items/misc/EncodedPatternItem.java index 013abafaf..83d69b62e 100644 --- a/src/main/java/appeng/items/misc/EncodedPatternItem.java +++ b/src/main/java/appeng/items/misc/EncodedPatternItem.java @@ -57,7 +57,7 @@ public class EncodedPatternItem extends AEBaseItem implements ICraftingPatternIt } @Override - public TypedActionResult onItemRightClick(final World w, final PlayerEntity player, final Hand hand) { + public TypedActionResult use(final World w, final PlayerEntity player, final Hand hand) { this.clearPattern(player.getStackInHand(hand), player); return new TypedActionResult<>(ActionResult.SUCCESS, player.getStackInHand(hand)); diff --git a/src/main/java/appeng/items/storage/AbstractStorageCell.java b/src/main/java/appeng/items/storage/AbstractStorageCell.java index 03eb0ac11..48addb89f 100644 --- a/src/main/java/appeng/items/storage/AbstractStorageCell.java +++ b/src/main/java/appeng/items/storage/AbstractStorageCell.java @@ -140,7 +140,7 @@ public abstract class AbstractStorageCell> extends AEBaseI } @Override - public TypedActionResult onItemRightClick(final World world, final PlayerEntity player, final Hand hand) { + public TypedActionResult use(final World world, final PlayerEntity player, final Hand hand) { this.disassembleDrive(player.getStackInHand(hand), world, player); return new TypedActionResult<>(ActionResult.SUCCESS, player.getStackInHand(hand)); } diff --git a/src/main/java/appeng/items/tools/BiometricCardItem.java b/src/main/java/appeng/items/tools/BiometricCardItem.java index 946e206b3..098b91fca 100644 --- a/src/main/java/appeng/items/tools/BiometricCardItem.java +++ b/src/main/java/appeng/items/tools/BiometricCardItem.java @@ -50,10 +50,10 @@ public class BiometricCardItem extends AEBaseItem implements IBiometricCard { } @Override - public TypedActionResult onItemRightClick(final World w, final PlayerEntity p, final Hand hand) { + public TypedActionResult use(final World w, final PlayerEntity p, final Hand hand) { if (p.isInSneakingPose()) { this.encode(p.getStackInHand(hand), p); - p.swingArm(hand); + p.swingHand(hand); return TypedActionResult.resultSuccess(p.getStackInHand(hand)); } @@ -68,7 +68,7 @@ public class BiometricCardItem extends AEBaseItem implements IBiometricCard { is = player.getStackInHand(hand); } this.encode(is, (PlayerEntity) target); - player.swingArm(hand); + player.swingHand(hand); return true; } return false; diff --git a/src/main/java/appeng/items/tools/MemoryCardItem.java b/src/main/java/appeng/items/tools/MemoryCardItem.java index 634a2de99..3bea90d3b 100644 --- a/src/main/java/appeng/items/tools/MemoryCardItem.java +++ b/src/main/java/appeng/items/tools/MemoryCardItem.java @@ -173,14 +173,14 @@ public class MemoryCardItem extends AEBaseItem implements IMemoryCard { } @Override - public TypedActionResult onItemRightClick(World w, PlayerEntity player, Hand hand) { + public TypedActionResult use(World w, PlayerEntity player, Hand hand) { if (player.isInSneakingPose()) { if (!w.isClient) { this.clearCard(player, w, hand); } } - return super.onItemRightClick(w, player, hand); + return super.use(w, player, hand); } @Override diff --git a/src/main/java/appeng/items/tools/NetworkToolItem.java b/src/main/java/appeng/items/tools/NetworkToolItem.java index f7d132df0..31bc4cae1 100644 --- a/src/main/java/appeng/items/tools/NetworkToolItem.java +++ b/src/main/java/appeng/items/tools/NetworkToolItem.java @@ -72,7 +72,7 @@ public class NetworkToolItem extends AEBaseItem implements IGuiItem, IAEWrench { } @Override - public TypedActionResult onItemRightClick(final World w, final PlayerEntity p, final Hand hand) { + public TypedActionResult use(final World w, final PlayerEntity p, final Hand hand) { if (Platform.isClient()) { final HitResult mop = AppEng.proxy.getRTR(); @@ -133,7 +133,7 @@ public class NetworkToolItem extends AEBaseItem implements IGuiItem, IAEWrench { if (!(te instanceof IGridHost)) { if (bs.rotate(w, pos, Rotation.CLOCKWISE_90) != bs) { bs.neighborUpdate(w, pos, Blocks.AIR, pos, false); - p.swingArm(hand); + p.swingHand(hand); return !w.isClient; } } diff --git a/src/main/java/appeng/items/tools/powered/EntropyManipulatorItem.java b/src/main/java/appeng/items/tools/powered/EntropyManipulatorItem.java index a2df35462..467a7478d 100644 --- a/src/main/java/appeng/items/tools/powered/EntropyManipulatorItem.java +++ b/src/main/java/appeng/items/tools/powered/EntropyManipulatorItem.java @@ -204,7 +204,7 @@ public class EntropyManipulatorItem extends AEBasePoweredItem implements IBlockT // Overridden to allow use of the item on WATER and LAVA which are otherwise not // considered for onItemUse @Override - public TypedActionResult onItemRightClick(final World w, final PlayerEntity p, final Hand hand) { + public TypedActionResult use(final World w, final PlayerEntity p, final Hand hand) { final HitResult target = rayTrace(w, p, RayTraceContext.FluidHandling.ANY); if (target.getType() != HitResult.Type.BLOCK) { diff --git a/src/main/java/appeng/items/tools/powered/MatterCannonItem.java b/src/main/java/appeng/items/tools/powered/MatterCannonItem.java index 4b9093c16..c83ddd482 100644 --- a/src/main/java/appeng/items/tools/powered/MatterCannonItem.java +++ b/src/main/java/appeng/items/tools/powered/MatterCannonItem.java @@ -105,7 +105,7 @@ public class MatterCannonItem extends AEBasePoweredItem implements IStorageCell< } @Override - public TypedActionResult onItemRightClick(final World w, final PlayerEntity p, final @Nullable Hand hand) { + public TypedActionResult use(final World w, final PlayerEntity p, final @Nullable Hand hand) { if (this.getAECurrentPower(p.getStackInHand(hand)) > ENERGY_PER_SHOT) { int shots = 1; diff --git a/src/main/java/appeng/items/tools/powered/PortableCellItem.java b/src/main/java/appeng/items/tools/powered/PortableCellItem.java index 024bf1ac8..2a3f7510d 100644 --- a/src/main/java/appeng/items/tools/powered/PortableCellItem.java +++ b/src/main/java/appeng/items/tools/powered/PortableCellItem.java @@ -61,7 +61,7 @@ public class PortableCellItem extends AEBasePoweredItem implements IStorageCell< } @Override - public TypedActionResult onItemRightClick(final World w, final PlayerEntity player, final Hand hand) { + public TypedActionResult use(final World w, final PlayerEntity player, final Hand hand) { ContainerOpener.openContainer(MEPortableCellContainer.TYPE, player, ContainerLocator.forHand(player, hand)); return new TypedActionResult<>(ActionResult.SUCCESS, player.getStackInHand(hand)); } diff --git a/src/main/java/appeng/items/tools/powered/WirelessTerminalItem.java b/src/main/java/appeng/items/tools/powered/WirelessTerminalItem.java index 265822b2e..b1cdf8d18 100644 --- a/src/main/java/appeng/items/tools/powered/WirelessTerminalItem.java +++ b/src/main/java/appeng/items/tools/powered/WirelessTerminalItem.java @@ -53,7 +53,7 @@ public class WirelessTerminalItem extends AEBasePoweredItem implements IWireless } @Override - public TypedActionResult onItemRightClick(final World w, final PlayerEntity player, final Hand hand) { + public TypedActionResult use(final World w, final PlayerEntity player, final Hand hand) { AEApi.instance().registries().wireless().openWirelessTerminalGui(player.getStackInHand(hand), w, player, hand); return new TypedActionResult<>(ActionResult.SUCCESS, player.getStackInHand(hand)); } diff --git a/src/main/java/appeng/parts/PartPlacement.java b/src/main/java/appeng/parts/PartPlacement.java index e5e068907..cdb0afac3 100644 --- a/src/main/java/appeng/parts/PartPlacement.java +++ b/src/main/java/appeng/parts/PartPlacement.java @@ -126,7 +126,7 @@ public class PartPlacement { } } } else { - player.swingArm(hand); + player.swingHand(hand); NetworkHandler.instance() .sendToServer(new PartPlacementPacket(pos, side, getEyeOffset(player), hand)); } @@ -169,7 +169,7 @@ public class PartPlacement { } } } else { - player.swingArm(hand); + player.swingHand(hand); NetworkHandler.instance() .sendToServer(new PartPlacementPacket(pos, side, getEyeOffset(player), hand)); return ActionResult.SUCCESS; @@ -252,7 +252,7 @@ public class PartPlacement { pass = PlaceType.INTERACT_SECOND_PASS; } else { - player.swingArm(hand); + player.swingHand(hand); NetworkHandler.instance() .sendToServer(new PartPlacementPacket(pos, side, getEyeOffset(player), hand)); return ActionResult.SUCCESS; @@ -319,7 +319,7 @@ public class PartPlacement { } } } else { - player.swingArm(hand); + player.swingHand(hand); } return ActionResult.SUCCESS; } diff --git a/src/main/java/appeng/recipes/game/DisassembleRecipe.java b/src/main/java/appeng/recipes/game/DisassembleRecipe.java index e3c61c0b9..cc0ee0d1f 100644 --- a/src/main/java/appeng/recipes/game/DisassembleRecipe.java +++ b/src/main/java/appeng/recipes/game/DisassembleRecipe.java @@ -92,7 +92,7 @@ public final class DisassembleRecipe extends SpecialRecipe { ItemStack output = MISMATCHED_STACK; for (int slotIndex = 0; slotIndex < inventory.size(); slotIndex++) { - final ItemStack stackInSlot = inventory.getStackInSlot(slotIndex); + final ItemStack stackInSlot = inventory.getStack(slotIndex); if (!stackInSlot.isEmpty()) { // needs a single input in the recipe itemCount++; diff --git a/src/main/java/appeng/recipes/game/FacadeRecipe.java b/src/main/java/appeng/recipes/game/FacadeRecipe.java index 41c062022..9bc33c31d 100644 --- a/src/main/java/appeng/recipes/game/FacadeRecipe.java +++ b/src/main/java/appeng/recipes/game/FacadeRecipe.java @@ -56,11 +56,11 @@ public final class FacadeRecipe extends SpecialRecipe { @Nonnull private ItemStack getOutput(final Inventory inv, final boolean createFacade) { - if (inv.getStackInSlot(0).isEmpty() && inv.getStackInSlot(2).isEmpty() && inv.getStackInSlot(6).isEmpty() - && inv.getStackInSlot(8).isEmpty()) { - if (this.anchor.isSameAs(inv.getStackInSlot(1)) && this.anchor.isSameAs(inv.getStackInSlot(3)) - && this.anchor.isSameAs(inv.getStackInSlot(5)) && this.anchor.isSameAs(inv.getStackInSlot(7))) { - final ItemStack facades = this.facade.createFacadeForItem(inv.getStackInSlot(4), !createFacade); + if (inv.getStack(0).isEmpty() && inv.getStack(2).isEmpty() && inv.getStack(6).isEmpty() + && inv.getStack(8).isEmpty()) { + if (this.anchor.isSameAs(inv.getStack(1)) && this.anchor.isSameAs(inv.getStack(3)) + && this.anchor.isSameAs(inv.getStack(5)) && this.anchor.isSameAs(inv.getStack(7))) { + final ItemStack facades = this.facade.createFacadeForItem(inv.getStack(4), !createFacade); if (!facades.isEmpty() && createFacade) { facades.setCount(4); } diff --git a/src/main/java/appeng/tile/grindstone/GrinderBlockEntity.java b/src/main/java/appeng/tile/grindstone/GrinderBlockEntity.java index 9f1782c0d..92dbb1699 100644 --- a/src/main/java/appeng/tile/grindstone/GrinderBlockEntity.java +++ b/src/main/java/appeng/tile/grindstone/GrinderBlockEntity.java @@ -127,7 +127,7 @@ public class GrinderBlockEntity extends AEBaseInvBlockEntity implements ICrankab this.points = 0; final InventoryAdaptor sia = new AdaptorFixedInv(new RangedWrapper(this.inv, 3, 6)); - this.addItem(sia, r.getRecipeOutput()); + this.addItem(sia, r.getOutput()); for (GrinderOptionalResult optionalResult : r.getOptionalResults()) { final float chance = (Platform.getRandomInt() % 2000) / 2000.0f;