From 3a6f01ee89c41c4d8e4a3aa35d6b882406664069 Mon Sep 17 00:00:00 2001 From: KnightMiner Date: Mon, 11 May 2020 01:14:42 -0500 Subject: [PATCH] Update to 1.15.2 --- build.gradle | 6 +- build.properties | 12 +-- .../building/BuildingClientProxy.java | 38 ++++++- .../inspirations/building/BuildingEvents.java | 4 +- .../building/block/BookshelfBlock.java | 33 ++---- .../building/block/EnlightenedBushBlock.java | 7 -- .../building/block/FlowerBlock.java | 6 +- .../building/block/RopeBlock.java | 15 +-- .../building/client/BookshelfModel.java | 8 +- .../inventory/BookshelfContainer.java | 39 ++++--- .../inspirations/common/ClientProxy.java | 15 +-- .../common/datagen/CondRecipe.java | 2 +- .../datagen/InspirationsBlockLootTable.java | 9 +- .../InspirationsBlockTagsProvider.java | 2 +- .../InspirationsLootTableProvider.java | 6 +- .../library/client/ClientUtil.java | 43 +++++--- .../library/util/ReflectionUtil.java | 18 +++- .../inspirations/recipes/RecipesEvents.java | 2 +- .../recipes/block/EnhancedCauldronBlock.java | 11 +- .../recipes/item/SimpleDyedBottleItem.java | 2 +- .../tileentity/CauldronTileEntity.java | 2 +- .../shared/SharedClientProxy.java | 10 +- .../shared/client/TextureModel.java | 102 +++++++++--------- .../inspirations/tools/InspirationsTools.java | 1 + .../inspirations/tools/ToolsClientProxy.java | 2 +- .../inspirations/tools/ToolsEvents.java | 2 +- .../tools/block/RedstoneChargeBlock.java | 3 +- .../tools/client/BarometerPropertyGetter.java | 4 +- .../tools/client/RedstoneArrowRenderer.java | 2 +- .../client/WaypointCompassPropertyGetter.java | 2 +- .../tools/datagen/ToolsRecipeProvider.java | 8 +- .../tools/item/RedstoneChargerItem.java | 11 +- .../tweaks/TweaksClientProxy.java | 18 ++-- .../inspirations/tweaks/TweaksEvents.java | 4 +- .../tweaks/block/WetHopperBlock.java | 1 + .../tweaks/client/PortalColorHandler.java | 6 +- .../tweaks/datagen/TweaksRecipeProvider.java | 35 ++++-- .../utility/block/BricksButtonBlock.java | 17 +-- .../utility/block/CollectorBlock.java | 12 +-- .../inspirations/utility/block/PipeBlock.java | 14 +-- .../utility/block/TorchLevelBlock.java | 7 +- .../utility/block/TorchLeverWallBlock.java | 7 +- .../utility/inventory/CollectorContainer.java | 21 ++-- .../utility/inventory/PipeContainer.java | 24 +++-- .../blockstates/ancient_bookshelf.json | 14 +-- .../inspirations/blockstates/bookshelf.json | 14 +-- .../inspirations/blockstates/cactus.json | 17 ++- .../blockstates/rainbow_bookshelf.json | 14 +-- .../inspirations/blockstates/sugar_cane.json | 17 ++- .../blockstates/tomes_bookshelf.json | 14 +-- 50 files changed, 364 insertions(+), 319 deletions(-) diff --git a/build.gradle b/build.gradle index aeebb97a..3d6acf46 100644 --- a/build.gradle +++ b/build.gradle @@ -137,12 +137,8 @@ dependencies { runtimeOnly fg.deobf("mezz.jei:jei-${config.minecraft_version}:${config.jei_version}") compile fg.deobf("slimeknights.mantle:Mantle:${config.minecraft_version}-${config.mantle_version}") - //deobfCompile "mcp.mobius.waila:Hwyla:${config.hwyla_version}" - //deobfCompile("mcjty.theoneprobe:TheOneProbe-1.12:${config.probe_version}") { - // exclude group: 'cofh' // don't grab redstone flux too, don't use it - //} //deobfCompile curse.resolve("leather-works", "2695934") - //deobfCompile "net.ilexiconn:llibrary:1.7.9-1.12.2" + //deobfCompile "net.ilexiconn:llibrary:1.7.9-1.12.2" //deobfCompile curse.resolve("rats", "2732516") //deobfCompile curse.resolve("the-twilight-forest", "2618264") } diff --git a/build.properties b/build.properties index 98f317b8..57980159 100644 --- a/build.properties +++ b/build.properties @@ -1,11 +1,9 @@ mod_version=1.0.2 -minecraft_version=1.14.4 -minecraft_base_version=1.14 -forge_version=28.1.93 +minecraft_version=1.15.2 +minecraft_base_version=1.15 +forge_version=31.1.0 forge_version_toml=278 -mappings_version=20191128-1.14.3 -mantle_version=1.4.32 +mappings_version=20200328-1.15.1 +mantle_version=1.5.15 jei_version=6.0.+ -hwyla_version=1.10.5-B66_1.14.4 -probe_version=1.4.30-6 diff --git a/src/main/java/knightminer/inspirations/building/BuildingClientProxy.java b/src/main/java/knightminer/inspirations/building/BuildingClientProxy.java index ae7eb34f..821e421c 100644 --- a/src/main/java/knightminer/inspirations/building/BuildingClientProxy.java +++ b/src/main/java/knightminer/inspirations/building/BuildingClientProxy.java @@ -14,6 +14,8 @@ import net.minecraft.block.Blocks; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScreenManager; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.RenderTypeLookup; import net.minecraft.client.renderer.color.BlockColors; import net.minecraft.client.renderer.color.ItemColors; import net.minecraft.client.renderer.model.ModelResourceLocation; @@ -28,6 +30,7 @@ import net.minecraftforge.client.event.ColorHandlerEvent; import net.minecraftforge.client.event.ModelBakeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import java.util.concurrent.CompletableFuture; @@ -35,6 +38,39 @@ public class BuildingClientProxy extends ClientProxy { public static final Minecraft mc = Minecraft.getInstance(); + @SubscribeEvent + public void clientSetup(FMLClientSetupEvent event) { + // set render types + RenderType cutout = RenderType.getCutout(); + RenderType cutoutMipped = RenderType.getCutoutMipped(); + // shelves + RenderTypeLookup.setRenderLayer(InspirationsBuilding.shelf_normal, cutout); + RenderTypeLookup.setRenderLayer(InspirationsBuilding.shelf_rainbow, cutout); + RenderTypeLookup.setRenderLayer(InspirationsBuilding.shelf_tomes, cutout); + RenderTypeLookup.setRenderLayer(InspirationsBuilding.shelf_ancient, cutout); + // ropes + RenderTypeLookup.setRenderLayer(InspirationsBuilding.rope, cutout); + RenderTypeLookup.setRenderLayer(InspirationsBuilding.vine, cutout); + RenderTypeLookup.setRenderLayer(InspirationsBuilding.ironBars, cutoutMipped); + // doors + RenderTypeLookup.setRenderLayer(InspirationsBuilding.glassDoor, cutoutMipped); + RenderTypeLookup.setRenderLayer(InspirationsBuilding.glassTrapdoor, cutoutMipped); + // flower + RenderTypeLookup.setRenderLayer(InspirationsBuilding.flower_cyan, cutout); + RenderTypeLookup.setRenderLayer(InspirationsBuilding.flower_paeonia, cutout); + RenderTypeLookup.setRenderLayer(InspirationsBuilding.flower_rose, cutout); + RenderTypeLookup.setRenderLayer(InspirationsBuilding.flower_syringa, cutout); + RenderTypeLookup.setRenderLayer(InspirationsBuilding.potted_cyan, cutout); + RenderTypeLookup.setRenderLayer(InspirationsBuilding.potted_syringa, cutout); + RenderTypeLookup.setRenderLayer(InspirationsBuilding.potted_paeonia, cutout); + RenderTypeLookup.setRenderLayer(InspirationsBuilding.potted_rose, cutout); + // enlightened bushes + RenderTypeLookup.setRenderLayer(InspirationsBuilding.blueEnlightenedBush, cutoutMipped); + RenderTypeLookup.setRenderLayer(InspirationsBuilding.greenEnlightenedBush, cutoutMipped); + RenderTypeLookup.setRenderLayer(InspirationsBuilding.redEnlightenedBush, cutoutMipped); + RenderTypeLookup.setRenderLayer(InspirationsBuilding.whiteEnlightenedBush, cutoutMipped); + } + @SubscribeEvent public void commonSetup(FMLCommonSetupEvent event) { @@ -186,7 +222,7 @@ private static void replaceBookshelfModel(ModelBakeEvent event, BookshelfBlock s } for(Direction facing : Direction.Plane.HORIZONTAL){ ModelResourceLocation location = new ModelResourceLocation(shelf.getRegistryName(), String.format("facing=%s", facing.getName())); - replaceModel(event, location, BookshelfModel::new); + replaceModel(event, location, (loader, model) -> new BookshelfModel(location, loader, model)); } replaceTexturedModel(event, new ModelResourceLocation(shelf.getRegistryName(), "inventory"), "texture",true); } diff --git a/src/main/java/knightminer/inspirations/building/BuildingEvents.java b/src/main/java/knightminer/inspirations/building/BuildingEvents.java index fdb756f2..5884d3ea 100644 --- a/src/main/java/knightminer/inspirations/building/BuildingEvents.java +++ b/src/main/java/knightminer/inspirations/building/BuildingEvents.java @@ -4,6 +4,8 @@ import knightminer.inspirations.common.Config; import net.minecraft.block.BlockState; import net.minecraft.block.SoundType; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.RenderTypeLookup; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResultType; @@ -47,7 +49,7 @@ public static void toggleRopeLadder(PlayerInteractEvent.RightClickBlock event) { private static boolean removeRopeLadder(World world, BlockPos pos, BlockState state, PlayerEntity player) { // only remove rungs when sneaking - if (!player.isSneaking()) { + if (!player.isCrouching()) { return false; } diff --git a/src/main/java/knightminer/inspirations/building/block/BookshelfBlock.java b/src/main/java/knightminer/inspirations/building/block/BookshelfBlock.java index c91f7166..025c3f2e 100644 --- a/src/main/java/knightminer/inspirations/building/block/BookshelfBlock.java +++ b/src/main/java/knightminer/inspirations/building/block/BookshelfBlock.java @@ -25,7 +25,7 @@ import net.minecraft.state.StateContainer; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.BlockRenderLayer; +import net.minecraft.util.ActionResultType; import net.minecraft.util.Direction; import net.minecraft.util.Hand; import net.minecraft.util.Mirror; @@ -77,13 +77,6 @@ public TileEntity createTileEntity(BlockState state, IBlockReader world) { return new BookshelfTileEntity(); } - @Deprecated - @Nullable - @Override - public TileEntity createNewTileEntity(@Nonnull IBlockReader world) { - return new BookshelfTileEntity(); - } - @Nullable @Override public BlockState getStateForPlacement(BlockItemUseContext context) { @@ -126,40 +119,41 @@ public void fillItemGroup(@Nonnull ItemGroup group, @Nonnull NonNullList type) { diff --git a/src/main/java/knightminer/inspirations/building/block/FlowerBlock.java b/src/main/java/knightminer/inspirations/building/block/FlowerBlock.java index 05bdecbe..5fabfedc 100644 --- a/src/main/java/knightminer/inspirations/building/block/FlowerBlock.java +++ b/src/main/java/knightminer/inspirations/building/block/FlowerBlock.java @@ -21,6 +21,7 @@ import net.minecraft.util.math.shapes.VoxelShapes; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; +import net.minecraft.world.server.ServerWorld; import net.minecraft.world.storage.loot.ConstantRange; import net.minecraft.world.storage.loot.LootPool; import net.minecraft.world.storage.loot.LootTable; @@ -83,10 +84,9 @@ public boolean canGrow(IBlockReader world, BlockPos pos, BlockState state, boole public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, BlockState state) { return true; } - - + @Override - public void grow(World world, Random rand, BlockPos pos, BlockState state) { + public void grow(ServerWorld world, Random rand, BlockPos pos, BlockState state) { // should not happen, but catch anyways if(largePlant == null) { return; diff --git a/src/main/java/knightminer/inspirations/building/block/RopeBlock.java b/src/main/java/knightminer/inspirations/building/block/RopeBlock.java index 144a346a..ef6b6177 100644 --- a/src/main/java/knightminer/inspirations/building/block/RopeBlock.java +++ b/src/main/java/knightminer/inspirations/building/block/RopeBlock.java @@ -21,7 +21,6 @@ import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.tags.BlockTags; import net.minecraft.util.ActionResultType; -import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.Direction; import net.minecraft.util.Hand; import net.minecraft.util.IStringSerializable; @@ -140,16 +139,16 @@ public BlockState updatePostPlacement(@Nonnull BlockState state, Direction facin // right click with a rope to extend downwards @Deprecated @Override - public boolean onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) { + public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) { // no need to check verticals, one is not possible and the other normal block placement if (hit.getFace().getAxis().isVertical()) { - return false; + return ActionResultType.PASS; } ItemStack stack = player.getHeldItem(hand); // check if the item is the same type as us if (Block.getBlockFromItem(stack.getItem()) != this) { - return false; + return ActionResultType.PASS; } // find the first block at the bottom of the rope @@ -167,7 +166,7 @@ public boolean onBlockActivated(BlockState state, World world, BlockPos pos, Pla } } - return true; + return ActionResultType.SUCCESS; } // when breaking, place all items from ropes below at the position of this rope @@ -210,12 +209,6 @@ public boolean isLadder(BlockState state, IWorldReader world, BlockPos pos, Livi return true; } - @Nonnull - @Override - public BlockRenderLayer getRenderLayer() { - return BlockRenderLayer.CUTOUT; - } - /* Bounds */ diff --git a/src/main/java/knightminer/inspirations/building/client/BookshelfModel.java b/src/main/java/knightminer/inspirations/building/client/BookshelfModel.java index f9f7ee21..e683a3d1 100644 --- a/src/main/java/knightminer/inspirations/building/client/BookshelfModel.java +++ b/src/main/java/knightminer/inspirations/building/client/BookshelfModel.java @@ -9,9 +9,9 @@ import net.minecraft.block.BlockState; import net.minecraft.client.renderer.model.BakedQuad; import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.model.IUnbakedModel; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.client.renderer.model.ModelBakery; import net.minecraft.util.Direction; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.data.IModelData; import javax.annotation.Nonnull; @@ -25,8 +25,8 @@ public class BookshelfModel extends TextureModel { /** Book model cache, for internal use only */ public static final Cache BOOK_CACHE = CacheBuilder.newBuilder().maximumSize(30).build(); - public BookshelfModel(IBakedModel standard, IUnbakedModel model) { - super(standard, model, DefaultVertexFormats.BLOCK, "texture", false); + public BookshelfModel(ResourceLocation location, ModelBakery loader, IBakedModel standard) { + super(location, loader, standard, "texture", false); } @Nonnull diff --git a/src/main/java/knightminer/inspirations/building/inventory/BookshelfContainer.java b/src/main/java/knightminer/inspirations/building/inventory/BookshelfContainer.java index d68916a0..6c0359fc 100644 --- a/src/main/java/knightminer/inspirations/building/inventory/BookshelfContainer.java +++ b/src/main/java/knightminer/inspirations/building/inventory/BookshelfContainer.java @@ -13,29 +13,25 @@ import slimeknights.mantle.inventory.MultiModuleContainer; public class BookshelfContainer extends MultiModuleContainer { - public static class Factory implements IContainerFactory { - @Override - public BookshelfContainer create(int windowId, PlayerInventory inv, PacketBuffer data) { - // Create the container on the clientside. - BlockPos pos = data.readBlockPos(); - TileEntity te = inv.player.world.getTileEntity(pos); - if (te instanceof BookshelfTileEntity) { - return new BookshelfContainer(windowId, inv, (BookshelfTileEntity) te); - } - throw new AssertionError(String.format("No bookshelf at %s!", pos)); - } - } - public BookshelfContainer(int winId, PlayerInventory inventoryPlayer, BookshelfTileEntity shelf) { - super(InspirationsBuilding.contBookshelf, winId, shelf); + super(InspirationsBuilding.contBookshelf, winId, inventoryPlayer, shelf); for(int i = 0; i < 7; i++) { this.addSlot(new SlotBookshelf(tile, i, 26 + (i*18), 18)); } for(int i = 0; i < 7; i++) { this.addSlot(new SlotBookshelf(tile, i+7, 26 + (i*18), 44)); } + addInventorySlots(); + } - addPlayerInventory(inventoryPlayer, 8, 74); + @Override + protected int getInventoryXOffset() { + return 8; + } + + @Override + protected int getInventoryYOffset() { + return 74; } public static class SlotBookshelf extends Slot { @@ -52,4 +48,17 @@ public boolean isItemValid(ItemStack stack) { return InspirationsRegistry.isBook(stack); } } + + public static class Factory implements IContainerFactory { + @Override + public BookshelfContainer create(int windowId, PlayerInventory inv, PacketBuffer data) { + // Create the container on the clientside. + BlockPos pos = data.readBlockPos(); + TileEntity te = inv.player.world.getTileEntity(pos); + if (te instanceof BookshelfTileEntity) { + return new BookshelfContainer(windowId, inv, (BookshelfTileEntity) te); + } + throw new AssertionError(String.format("No bookshelf at %s!", pos)); + } + } } diff --git a/src/main/java/knightminer/inspirations/common/ClientProxy.java b/src/main/java/knightminer/inspirations/common/ClientProxy.java index 73030b33..3dc12b85 100644 --- a/src/main/java/knightminer/inspirations/common/ClientProxy.java +++ b/src/main/java/knightminer/inspirations/common/ClientProxy.java @@ -8,14 +8,12 @@ import net.minecraft.client.renderer.color.IItemColor; import net.minecraft.client.renderer.color.ItemColors; import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.model.IUnbakedModel; +import net.minecraft.client.renderer.model.ModelBakery; import net.minecraft.client.renderer.model.ModelResourceLocation; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.item.Item; import net.minecraft.item.Items; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.event.ModelBakeEvent; -import net.minecraftforge.client.model.ModelLoaderRegistry; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; @@ -58,15 +56,10 @@ protected static void registerItemColors(ItemColors itemColors, IItemColor handl } } - protected static void replaceModel(ModelBakeEvent event, ModelResourceLocation location, BiFunction modelMaker) { + protected static void replaceModel(ModelBakeEvent event, ModelResourceLocation location, BiFunction modelMaker) { try { - // model to be retextured - IUnbakedModel model = ModelLoaderRegistry.getModel(location); - // model for rendering properties - IBakedModel standard = event.getModelRegistry().get(location); // model to replace standard - TextureModel finalModel = modelMaker.apply(standard, model); - finalModel.fetchChildren(event.getModelLoader()); + TextureModel finalModel = modelMaker.apply(event.getModelLoader(), event.getModelRegistry().get(location)); event.getModelRegistry().put(location, finalModel); } catch(Exception e) { Inspirations.log.error("Caught exception trying to replace model for " + location, e); @@ -76,7 +69,7 @@ protected static void replaceModel(ModelBakeEvent event, ModelResourceLocation l protected static void replaceTexturedModel(ModelBakeEvent event, ModelResourceLocation location, String key, boolean item) { replaceModel( event, location, - (orig, model) -> new TextureModel(orig, model, item ? DefaultVertexFormats.ITEM : DefaultVertexFormats.BLOCK, key, item) + (loader, model) -> new TextureModel(location, loader, model, key, item) ); } diff --git a/src/main/java/knightminer/inspirations/common/datagen/CondRecipe.java b/src/main/java/knightminer/inspirations/common/datagen/CondRecipe.java index e6dc228c..1e086892 100644 --- a/src/main/java/knightminer/inspirations/common/datagen/CondRecipe.java +++ b/src/main/java/knightminer/inspirations/common/datagen/CondRecipe.java @@ -255,7 +255,7 @@ public CustomBuilder addCondition(ICondition cond) { public void build(@Nonnull Consumer consumer, ResourceLocation path) { // Reuse vanilla's builder - which just writes "type". - CustomRecipeBuilder builder = CustomRecipeBuilder.func_218656_a(serializer); + CustomRecipeBuilder builder = CustomRecipeBuilder.customRecipe(serializer); // Capture the finished recipe in the consumer, then wrap in our own class. builder.build((result) -> diff --git a/src/main/java/knightminer/inspirations/common/datagen/InspirationsBlockLootTable.java b/src/main/java/knightminer/inspirations/common/datagen/InspirationsBlockLootTable.java index b6587d18..0f66d774 100644 --- a/src/main/java/knightminer/inspirations/common/datagen/InspirationsBlockLootTable.java +++ b/src/main/java/knightminer/inspirations/common/datagen/InspirationsBlockLootTable.java @@ -10,6 +10,7 @@ import knightminer.inspirations.tweaks.InspirationsTweaks; import knightminer.inspirations.utility.InspirationsUtility; import knightminer.inspirations.utility.block.CarpetedPressurePlateBlock; +import net.minecraft.advancements.criterion.StatePropertiesPredicate; import net.minecraft.block.Block; import net.minecraft.block.DoorBlock; import net.minecraft.data.loot.BlockLootTables; @@ -82,7 +83,10 @@ private void addBuilding() { this.registerLootTable(InspirationsBuilding.glassDoor, LootTable.builder() .addLootPool(LootPool.builder().addEntry(ItemLootEntry.builder(InspirationsBuilding.glassDoor)) .acceptCondition(BlockStateProperty.builder(InspirationsBuilding.glassDoor) - .with(DoorBlock.HALF, DoubleBlockHalf.LOWER)) + .fromProperties(StatePropertiesPredicate.Builder.newBuilder() + .withProp(DoorBlock.HALF, DoubleBlockHalf.LOWER) + ) + ) .acceptCondition(SILK_TOUCH) ) ); @@ -164,7 +168,8 @@ private LootTable.Builder rope(Block block) { .acceptFunction(SetCount.builder(ConstantRange.of(RopeBlock.RUNG_ITEM_COUNT))) ) .acceptCondition(BlockStateProperty.builder(rope) - .with(RopeBlock.RUNGS, RopeBlock.Rungs.NONE) + .fromProperties(StatePropertiesPredicate.Builder.newBuilder() + .withProp(RopeBlock.RUNGS, RopeBlock.Rungs.NONE)) .inverted() ) )); diff --git a/src/main/java/knightminer/inspirations/common/datagen/InspirationsBlockTagsProvider.java b/src/main/java/knightminer/inspirations/common/datagen/InspirationsBlockTagsProvider.java index a6447a4f..f5a25629 100644 --- a/src/main/java/knightminer/inspirations/common/datagen/InspirationsBlockTagsProvider.java +++ b/src/main/java/knightminer/inspirations/common/datagen/InspirationsBlockTagsProvider.java @@ -71,7 +71,7 @@ private void registerInspTags() { private void registerVanillaTags() { this.getBuilder(BlockTags.LEAVES).add(InspirationsTags.Blocks.ENLIGHTENED_BUSHES); - this.getBuilder(BlockTags.DIRT_LIKE).add(InspirationsTags.Blocks.MULCH); + //this.getBuilder(BlockTags.DIRT_LIKE).add(InspirationsTags.Blocks.MULCH); this.getBuilder(BlockTags.BAMBOO_PLANTABLE_ON).add(InspirationsTags.Blocks.MULCH); this.getBuilder(BlockTags.WOODEN_TRAPDOORS).add(InspirationsTags.Blocks.CARPETED_TRAPDOORS); this.getBuilder(BlockTags.FLOWER_POTS).add(InspirationsTags.Blocks.FLOWER_POTS); diff --git a/src/main/java/knightminer/inspirations/common/datagen/InspirationsLootTableProvider.java b/src/main/java/knightminer/inspirations/common/datagen/InspirationsLootTableProvider.java index 588d13e2..e5f2204a 100644 --- a/src/main/java/knightminer/inspirations/common/datagen/InspirationsLootTableProvider.java +++ b/src/main/java/knightminer/inspirations/common/datagen/InspirationsLootTableProvider.java @@ -10,7 +10,7 @@ import net.minecraft.world.storage.loot.LootParameterSets; import net.minecraft.world.storage.loot.LootTable; import net.minecraft.world.storage.loot.LootTableManager; -import net.minecraft.world.storage.loot.ValidationResults; +import net.minecraft.world.storage.loot.ValidationTracker; import javax.annotation.Nonnull; import java.util.HashMap; @@ -41,8 +41,8 @@ protected List map, ValidationResults validationresults) { - map.forEach((loc, table) -> LootTableManager.func_215302_a(validationresults, loc, table, map::get)); + protected void validate(Map map, ValidationTracker validationtracker) { + map.forEach((loc, table) -> LootTableManager.func_227508_a_(validationtracker, loc, table)); // Remove vanilla's tables, which we also loaded so we can redirect stuff to them. // This ensures the remaining generator logic doesn't write those to files. map.keySet().removeIf((loc) -> !loc.getNamespace().equals(Inspirations.modID)); diff --git a/src/main/java/knightminer/inspirations/library/client/ClientUtil.java b/src/main/java/knightminer/inspirations/library/client/ClientUtil.java index 504e138d..af5efad1 100644 --- a/src/main/java/knightminer/inspirations/library/client/ClientUtil.java +++ b/src/main/java/knightminer/inspirations/library/client/ClientUtil.java @@ -15,13 +15,14 @@ import net.minecraft.client.renderer.texture.MissingTextureSprite; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.inventory.container.PlayerContainer; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IEnviromentBlockReader; +import net.minecraft.world.ILightReader; import net.minecraftforge.client.model.data.EmptyModelData; import org.apache.commons.lang3.math.NumberUtils; import org.apache.commons.lang3.text.WordUtils; @@ -34,6 +35,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; +import java.util.function.Function; public final class ClientUtil { public static final String TAG_TEXTURE_PATH = "texture_path"; @@ -117,24 +119,32 @@ public static void clearCache() { * Gets the sprite for the given texture location, or Missing Texture if no sprite is found */ public static TextureAtlasSprite getSprite(ResourceLocation location) { - AtlasTexture textureMapBlocks = mc.getTextureMap(); + Function textureGetter = mc.getAtlasSpriteGetter(PlayerContainer.LOCATION_BLOCKS_TEXTURE); TextureAtlasSprite sprite = null; if (location != null) { - sprite = textureMapBlocks.getSprite(location); + sprite = textureGetter.apply(location); } if (sprite == null) { - sprite = textureMapBlocks.getSprite(MissingTextureSprite.getLocation()); + sprite = textureGetter.apply(MissingTextureSprite.getLocation()); } return sprite; } + /** + * Used to render fluid sprites in the JEI interface + * @param sprite Sprite to render + * @param x Sprite X position + * @param y Sprite Y position + * @param size Sprite size in pixels + * @param filled Amount of sprite filled in pixels + */ public static void renderFilledSprite(TextureAtlasSprite sprite, final int x, final int y, final int size, final int filled) { - double uMin = sprite.getMinU(); - double uMax = sprite.getMaxU(); - double vMin = sprite.getMinV(); - double vMax = sprite.getMaxV(); - uMax = uMax - (16 - size) / 16.0 * (uMax - uMin); - vMax = vMax - (16 - filled) / 16.0 * (vMax - vMin); + float uMin = sprite.getMinU(); + float uMax = sprite.getMaxU(); + float vMin = sprite.getMinV(); + float vMax = sprite.getMaxV(); + uMax = uMax - (16 - size) / 16.0f * (uMax - uMin); + vMax = vMax - (16 - filled) / 16.0f * (vMax - vMin); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferBuilder = tessellator.getBuffer(); @@ -177,7 +187,7 @@ public static String getTexturePath(TileEntity te) { * @param index Tint index * @return color, or -1 for undefined */ - public static int getStackBlockColorsSafe(ItemStack stack, @Nullable IEnviromentBlockReader world, @Nullable BlockPos pos, int index) { + public static int getStackBlockColorsSafe(ItemStack stack, @Nullable ILightReader world, @Nullable BlockPos pos, int index) { if (stack.isEmpty()) { return -1; } @@ -186,7 +196,7 @@ public static int getStackBlockColorsSafe(ItemStack stack, @Nullable IEnviroment Item item = stack.getItem(); if (!unsafe.contains(item)) { try { - return ClientUtil.getStackBlockColors(stack, world, pos, index); + return getStackBlockColors(stack, world, pos, index); } catch (Exception e) { // catch and log possible exceptions. Most likely exception is ClassCastException if they do not perform safety checks Inspirations.log.error(String.format("Caught exception getting block colors for %s", item.getRegistryName()), e); @@ -206,7 +216,7 @@ public static int getStackBlockColorsSafe(ItemStack stack, @Nullable IEnviroment * @param index Tint index * @return color, or -1 for undefined */ - public static int getStackBlockColors(ItemStack stack, @Nullable IEnviromentBlockReader world, @Nullable BlockPos pos, int index) { + public static int getStackBlockColors(ItemStack stack, @Nullable ILightReader world, @Nullable BlockPos pos, int index) { if (stack.isEmpty() || !(stack.getItem() instanceof BlockItem)) { return -1; } @@ -223,10 +233,11 @@ public static int getStackBlockColors(ItemStack stack, @Nullable IEnviromentBloc * @param color Sprite color * @param level Cauldron level */ + @Deprecated public static void renderJEICauldronFluid(int x, int y, ResourceLocation location, float[] color, int level) { GlStateManager.enableBlend(); - mc.gameRenderer.enableLightmap(); - GlStateManager.color3f(color[0], color[1], color[2]); + //mc.gameRenderer.enableLightmap(); + GlStateManager.color4f(color[0], color[1], color[2], 1); // 0 means JEI ingredient list TextureAtlasSprite sprite = ClientUtil.getSprite(location); if (level == 0) { @@ -235,7 +246,7 @@ public static void renderJEICauldronFluid(int x, int y, ResourceLocation locatio int height = ((10 * level) / InspirationsRegistry.getCauldronMax()); ClientUtil.renderFilledSprite(sprite, x, y, 10, height); } - GlStateManager.color3f(1, 1, 1); + GlStateManager.color4f(1, 1, 1, 1); GlStateManager.disableBlend(); } diff --git a/src/main/java/knightminer/inspirations/library/util/ReflectionUtil.java b/src/main/java/knightminer/inspirations/library/util/ReflectionUtil.java index b50afb02..20bb228c 100644 --- a/src/main/java/knightminer/inspirations/library/util/ReflectionUtil.java +++ b/src/main/java/knightminer/inspirations/library/util/ReflectionUtil.java @@ -28,7 +28,10 @@ private ReflectionUtil() {} @Nullable public static > T getMixPredicateInput(@Nonnull Object mixPredicate) { IRegistryDelegate effect = getPrivateValue(getClass("net.minecraft.potion.PotionBrewing$MixPredicate"), mixPredicate, "field_185198_a"); - return effect.get(); + if (effect != null) { + return effect.get(); + } + return null; } @Nullable @@ -39,7 +42,10 @@ public static Ingredient getMixPredicateReagent(@Nonnull Object mixPredicate) { @Nullable public static > T getMixPredicateOutput(@Nonnull Object mixPredicate) { IRegistryDelegate effect = getPrivateValue(getClass("net.minecraft.potion.PotionBrewing$MixPredicate"), mixPredicate, "field_185200_c"); - return effect.get(); + if (effect != null) { + return effect.get(); + } + return null; } @@ -57,10 +63,11 @@ public static > T getMixPredicateOutput(@Nonnull * @return The return value of the method or null, if it fails or the method is void */ @Nullable + @SuppressWarnings("unchecked") private static T invokeMethod(final Class classToSearch, final Object instance, final String name, final Class[] paramTypes, final Object... params) { try { Method m = METHODS.computeIfAbsent(name, key -> ObfuscationReflectionHelper.findMethod(classToSearch, name, paramTypes)); - return m != null ? (T) m.invoke(instance, params) : null; + return (T) m.invoke(instance, params); } catch(IllegalAccessException | IllegalArgumentException | InvocationTargetException | ClassCastException | UnableToFindMethodException e) { InspirationsRegistry.log.error(e); METHODS.putIfAbsent(name, null); // set cache of method to null if it errors trying to find the method in the first place @@ -75,6 +82,8 @@ private static T invokeMethod(final Class classToSearch, final Object ins * @param className The class name to be searched for * @return The class found or null, if the class is unavailable */ + @Nullable + @SuppressWarnings("unchecked") public static Class getClass(String className) { return (Class) CLASS.computeIfAbsent(className, key -> { try { @@ -98,6 +107,7 @@ public static Class getClass(String className) { * @return The value of the field or null, if it fails */ @Nullable + @SuppressWarnings("unchecked") private static T getPrivateValue(final Class clazz, final Object instance, final String name) { if(clazz == null) { return null; @@ -107,7 +117,7 @@ private static T getPrivateValue(final Class clazz, final Obje } try { Field f = FIELDS.computeIfAbsent(name, key -> ObfuscationReflectionHelper.findField(clazz, name)); - return f != null ? (T) f.get(instance) : null; + return (T) f.get(instance); } catch(IllegalAccessException | UnableToFindFieldException | ClassCastException e) { InspirationsRegistry.log.error(e); FIELDS.putIfAbsent(name, null); // set cache of field to null if it errors trying to find the field in the first place diff --git a/src/main/java/knightminer/inspirations/recipes/RecipesEvents.java b/src/main/java/knightminer/inspirations/recipes/RecipesEvents.java index 9f88331a..730e05c0 100644 --- a/src/main/java/knightminer/inspirations/recipes/RecipesEvents.java +++ b/src/main/java/knightminer/inspirations/recipes/RecipesEvents.java @@ -26,7 +26,7 @@ public static void clickCauldron(RightClickBlock event) { } PlayerEntity player = event.getPlayer(); - if(player.isSneaking()) { + if(player.isCrouching()) { return; } diff --git a/src/main/java/knightminer/inspirations/recipes/block/EnhancedCauldronBlock.java b/src/main/java/knightminer/inspirations/recipes/block/EnhancedCauldronBlock.java index 0fa4fc2e..8e91e2ca 100644 --- a/src/main/java/knightminer/inspirations/recipes/block/EnhancedCauldronBlock.java +++ b/src/main/java/knightminer/inspirations/recipes/block/EnhancedCauldronBlock.java @@ -18,6 +18,7 @@ import net.minecraft.state.IntegerProperty; import net.minecraft.state.StateContainer; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ActionResultType; import net.minecraft.util.Direction; import net.minecraft.util.Hand; import net.minecraft.util.IStringSerializable; @@ -27,6 +28,8 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorld; import net.minecraft.world.World; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.model.data.ModelProperty; import javax.annotation.Nonnull; @@ -158,8 +161,9 @@ public BlockState updatePostPlacement(@Nonnull BlockState state, Direction facin } @Override - public boolean onBlockActivated(@Nonnull BlockState state, @Nonnull World world, @Nonnull BlockPos pos, PlayerEntity player, @Nonnull Hand hand, BlockRayTraceResult ray) { - return true; // all moved to the cauldron registry + public ActionResultType onBlockActivated(@Nonnull BlockState state, @Nonnull World world, @Nonnull BlockPos pos, PlayerEntity player, @Nonnull Hand hand, BlockRayTraceResult ray) { + // all moved to the cauldron registry + return ActionResultType.SUCCESS; } @@ -179,7 +183,8 @@ private static void setBoiling(World world, BlockPos pos, BlockState state) { @Deprecated @Override - public void randomTick(BlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Random rand) { + @OnlyIn(Dist.CLIENT) + public void animateTick(BlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Random rand) { if(!state.get(BOILING)) { return; } diff --git a/src/main/java/knightminer/inspirations/recipes/item/SimpleDyedBottleItem.java b/src/main/java/knightminer/inspirations/recipes/item/SimpleDyedBottleItem.java index d6a89194..3ad41043 100644 --- a/src/main/java/knightminer/inspirations/recipes/item/SimpleDyedBottleItem.java +++ b/src/main/java/knightminer/inspirations/recipes/item/SimpleDyedBottleItem.java @@ -41,7 +41,7 @@ public boolean itemInteractionForEntity(ItemStack stack, PlayerEntity player, Li player.playSound(SoundEvents.ITEM_BOTTLE_EMPTY, 1.0F, 1.0F); // give back bottle; - ItemStack bottle = new ItemStack(getContainerItem()); + ItemStack bottle = stack.getContainerItem(); if (stack.getCount() == 1) { player.setHeldItem(hand, bottle); } else { diff --git a/src/main/java/knightminer/inspirations/recipes/tileentity/CauldronTileEntity.java b/src/main/java/knightminer/inspirations/recipes/tileentity/CauldronTileEntity.java index ddcc9e12..a4a43a08 100644 --- a/src/main/java/knightminer/inspirations/recipes/tileentity/CauldronTileEntity.java +++ b/src/main/java/knightminer/inspirations/recipes/tileentity/CauldronTileEntity.java @@ -409,7 +409,7 @@ public int onEntityCollide(Entity entity, int level, BlockState currentState) { } private void spawnItem(ItemStack stack, ItemEntity base) { - ItemEntity entityItem = new ItemEntity(world, base.posX, base.posY, base.posZ, stack); + ItemEntity entityItem = new ItemEntity(world, base.getPosX(), base.getPosY(), base.getPosZ(), stack); // tag the entity so it does not craft again // prevents something like a water bottle from emptying and filling constantly diff --git a/src/main/java/knightminer/inspirations/shared/SharedClientProxy.java b/src/main/java/knightminer/inspirations/shared/SharedClientProxy.java index 40405067..6ddc64a4 100644 --- a/src/main/java/knightminer/inspirations/shared/SharedClientProxy.java +++ b/src/main/java/knightminer/inspirations/shared/SharedClientProxy.java @@ -5,7 +5,7 @@ import knightminer.inspirations.library.Util; import knightminer.inspirations.library.client.ClientUtil; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.texture.AtlasTexture; +import net.minecraft.inventory.container.PlayerContainer; import net.minecraft.resources.IReloadableResourceManager; import net.minecraft.resources.IResourceManager; import net.minecraftforge.client.event.ModelBakeEvent; @@ -17,7 +17,7 @@ import java.util.concurrent.CompletableFuture; public class SharedClientProxy extends ClientProxy { - + @SubscribeEvent public void setup(FMLCommonSetupEvent event) { // listener to clear color cache from client utils IResourceManager manager = Minecraft.getInstance().getResourceManager(); @@ -45,9 +45,9 @@ public void collectBakeParameters(ModelBakeEvent event) { @SubscribeEvent public void registerTextures(TextureStitchEvent.Pre event) { // ensures the colorless fluid texture is loaded. - if (event.getMap().getBasePath().equals("texture")) { - event.addSprite(Util.getResource("blocks/fluid_colorless")); - event.addSprite(Util.getResource("blocks/fluid_colorless_flow")); + if (PlayerContainer.LOCATION_BLOCKS_TEXTURE.equals(event.getMap().getTextureLocation())) { + event.addSprite(Util.getResource("block/fluid_colorless")); + event.addSprite(Util.getResource("block/fluid_colorless_flow")); } } } diff --git a/src/main/java/knightminer/inspirations/shared/client/TextureModel.java b/src/main/java/knightminer/inspirations/shared/client/TextureModel.java index 1e03f7f9..d193f04b 100644 --- a/src/main/java/knightminer/inspirations/shared/client/TextureModel.java +++ b/src/main/java/knightminer/inspirations/shared/client/TextureModel.java @@ -4,33 +4,33 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; +import com.mojang.datafixers.util.Either; +import com.mojang.datafixers.util.Pair; import knightminer.inspirations.Inspirations; import knightminer.inspirations.library.util.TextureBlockUtil; import knightminer.inspirations.shared.SharedClientProxy; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; -import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.model.BakedQuad; import net.minecraft.client.renderer.model.BlockModel; import net.minecraft.client.renderer.model.BlockPart; import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.client.renderer.model.IUnbakedModel; import net.minecraft.client.renderer.model.ItemOverrideList; +import net.minecraft.client.renderer.model.Material; +import net.minecraft.client.renderer.model.ModelBakery; import net.minecraft.client.renderer.model.ModelRotation; import net.minecraft.client.renderer.model.Variant; import net.minecraft.client.renderer.model.VariantList; import net.minecraft.client.renderer.model.WeightedBakedModel; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.vertex.VertexFormat; import net.minecraft.entity.LivingEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.Direction; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.client.model.BakedModelWrapper; -import net.minecraftforge.client.model.IModel; -import net.minecraftforge.client.model.ModelLoader; +import net.minecraftforge.client.model.ModelLoaderRegistry; import net.minecraftforge.client.model.data.IModelData; import net.minecraftforge.client.model.data.ModelProperty; import slimeknights.mantle.client.ModelHelper; @@ -43,41 +43,42 @@ import java.util.Map; import java.util.Random; import java.util.Set; -import java.util.function.Function; public class TextureModel extends BakedModelWrapper { private final Map cache = new HashMap<>(); + private ResourceLocation location; + private ModelBakery loader; private IUnbakedModel unbakedModel; - private final VertexFormat format; private final String textureKey; private boolean item; - private Map unbakedChildren; - - ModelProperty TEXTURE = TextureBlockUtil.TEXTURE_PROP; + private Map unbakedChildren; + private ModelProperty TEXTURE = TextureBlockUtil.TEXTURE_PROP; /** * Creates a new instance of the unbakedModel + * @param location Location of the model being replaced + * @param loader Model loader instance to rebake models * @param originalModel Original baked unbakedModel - * @param unbakedModel Unbaked, retexturable model - * @param format Model format, either BLOCK or ITEM * @param textureKey Name of the primary key to retexture * @param item If true, add logic to retexture the item model too */ - public TextureModel(IBakedModel originalModel, IUnbakedModel unbakedModel, VertexFormat format, String textureKey, boolean item) { + public TextureModel(ResourceLocation location, ModelBakery loader, IBakedModel originalModel, String textureKey, boolean item) { super(originalModel); - this.unbakedModel = unbakedModel; - this.format = format; + this.location = location; + this.loader = loader; + this.unbakedModel = loader.getUnbakedModel(location); this.textureKey = textureKey; this.item = item; + this.fetchDependents(); } /** - * Fetches all children models required by this unbakedModel. Done because it is bad practice and prone to threading errors if we fetch them at runtime - * @param loader Forge Model Loader + * Ensures parents and children of this model are properly fetched */ - public void fetchChildren(ModelLoader loader) { + protected void fetchDependents() { // needed for getTextures, though we just discard it these are printed elsewhere in loading - Set missingTextures = new HashSet<>(); + Set> missingTextures = Sets.newLinkedHashSet(); + // load the parent of the main model unbakedModel.getTextures(loader::getUnbakedModel, missingTextures); @@ -91,24 +92,24 @@ public void fetchChildren(ModelLoader loader) { } // make an immutable map of all children - ImmutableMap.Builder builder = new ImmutableMap.Builder<>(); + ImmutableMap.Builder builder = new ImmutableMap.Builder<>(); // skip loading the same unbakedModel multiple times, it will fail again Set loaded = new HashSet<>(); for(Variant variant : list.getVariantList()) { - ResourceLocation location = variant.getModelLocation(); - if (loaded.contains(location)) { + ResourceLocation variantLocation = variant.getModelLocation(); + if (loaded.contains(variantLocation)) { continue; } - loaded.add(location); + loaded.add(variantLocation); try { // using getUnbakedModel as its much simplier, and typically the parent is already loaded - IUnbakedModel model = loader.getUnbakedModel(location); + IUnbakedModel model = loader.getUnbakedModel(variantLocation); // run getTextures to ensure the parent is loaded model.getTextures(loader::getUnbakedModel, missingTextures); // store it to fetch when texturing - builder.put(location, model); + builder.put(variantLocation, model); } catch (Exception e) { - Inspirations.log.error("Error loading unbaked model for " + location, e); + Inspirations.log.error("Error loading unbaked model for " + variantLocation, e); } } unbakedChildren = builder.build(); @@ -142,10 +143,12 @@ protected IBakedModel getTexturedModel(ImmutableMap textures) { if (unbakedModel instanceof VariantList) { return retextureVariantList((VariantList)unbakedModel, textures); } - return retexture(unbakedModel, textures).bake( + return retexture(unbakedModel, textures).bakeModel( SharedClientProxy.modelLoader, - (Function) Minecraft.getInstance().getTextureMap()::getSprite, - ModelRotation.X0_Y0, this.format); + loader.getSpriteMap()::getSprite, + ModelRotation.X0_Y0, + this.location + ); } /** @@ -163,11 +166,12 @@ protected IBakedModel getCachedTextureModel(String texture) { * @param textures New textures * @return Retextured unbakedModel */ - private IModel retexture(IModel model, ImmutableMap textures) { + private IUnbakedModel retexture(IUnbakedModel model, ImmutableMap textures) { if (model instanceof BlockModel) { return retextureBlockModel((BlockModel)model, textures); } - return model.retexture(textures); + Inspirations.log.error("Failed to retexture model of class {}", model.getClass()); + return model; } /** @@ -183,7 +187,7 @@ private BlockModel retextureBlockModel(BlockModel model, ImmutableMap remapped = Maps.newHashMap(); - for (Map.Entry e : newModel.textures.entrySet()) { - if (e.getValue().startsWith("#")) { - String key = e.getValue().substring(1); - if (newModel.textures.containsKey(key)) { - remapped.put(e.getKey(), newModel.textures.get(key)); + Map> remapped = Maps.newHashMap(); + for (Map.Entry> e : newModel.textures.entrySet()) { + Either either = e.getValue(); + either.ifRight((path) -> { + if (path.startsWith("#")) { + String key = path.substring(1); + if (newModel.textures.containsKey(key)) { + remapped.put(e.getKey(), newModel.textures.get(key)); + } } - } + }); } - newModel.textures.putAll(remapped); - //Remove any faces that use a null texture, this is for performance reasons, also allows some cool layering stuff. + // Remove any faces that use a null texture, this is for performance reasons, also allows some cool layering stuff. for (BlockPart part : newModel.getElements()) { part.mapFaces.entrySet().removeIf(entry -> removed.contains(entry.getValue().texture)); } @@ -224,7 +230,7 @@ private BlockModel retextureBlockModel(BlockModel model, ImmutableMap textures) { // nothing to do if no variants @@ -234,16 +240,16 @@ private IBakedModel retextureVariantList(VariantList list, ImmutableMap) Minecraft.getInstance().getTextureMap()::getSprite, + loader.getSpriteMap()::getSprite, variant, - this.format - ); + this.location + ); builder.add(ibakedmodel, variant.getWeight()); } diff --git a/src/main/java/knightminer/inspirations/tools/InspirationsTools.java b/src/main/java/knightminer/inspirations/tools/InspirationsTools.java index c898af49..970e61b0 100644 --- a/src/main/java/knightminer/inspirations/tools/InspirationsTools.java +++ b/src/main/java/knightminer/inspirations/tools/InspirationsTools.java @@ -105,6 +105,7 @@ public void registerBlocks(Register event) { } @SubscribeEvent + @SuppressWarnings("deprecation") public void registerItems(Register event) { IForgeRegistry r = event.getRegistry(); diff --git a/src/main/java/knightminer/inspirations/tools/ToolsClientProxy.java b/src/main/java/knightminer/inspirations/tools/ToolsClientProxy.java index a62e5146..c3f2708e 100644 --- a/src/main/java/knightminer/inspirations/tools/ToolsClientProxy.java +++ b/src/main/java/knightminer/inspirations/tools/ToolsClientProxy.java @@ -14,7 +14,7 @@ public class ToolsClientProxy extends ClientProxy { @SubscribeEvent public void clientSetup(FMLClientSetupEvent event) { - RenderingRegistry.registerEntityRenderingHandler(RedstoneArrow.class, RedstoneArrowRenderer::new); + RenderingRegistry.registerEntityRenderingHandler(InspirationsTools.entRSArrow, RedstoneArrowRenderer::new); } @SubscribeEvent diff --git a/src/main/java/knightminer/inspirations/tools/ToolsEvents.java b/src/main/java/knightminer/inspirations/tools/ToolsEvents.java index d029811a..58d4c50e 100644 --- a/src/main/java/knightminer/inspirations/tools/ToolsEvents.java +++ b/src/main/java/knightminer/inspirations/tools/ToolsEvents.java @@ -92,7 +92,7 @@ public static void lockAndUnlock(RightClickBlock event) { event.setCanceled(true); event.setCancellationResult(ActionResultType.SUCCESS); // if the player is not sneaking, just open the chest as normal with the key - } else if(player.isSneaking()) { + } else if(player.isCrouching()) { if(lockable.code != LockCode.EMPTY_CODE) { // if the key matches the lock, take off the lock and give it to the player if(lockable.code.func_219964_a(stack)) { diff --git a/src/main/java/knightminer/inspirations/tools/block/RedstoneChargeBlock.java b/src/main/java/knightminer/inspirations/tools/block/RedstoneChargeBlock.java index 965e4156..c81943ad 100644 --- a/src/main/java/knightminer/inspirations/tools/block/RedstoneChargeBlock.java +++ b/src/main/java/knightminer/inspirations/tools/block/RedstoneChargeBlock.java @@ -24,6 +24,7 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorldReader; import net.minecraft.world.World; +import net.minecraft.world.server.ServerWorld; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -101,7 +102,7 @@ public void onReplaced(BlockState state, @Nonnull World worldIn, @Nonnull BlockP @Deprecated @Override - public void tick(BlockState state, World world, BlockPos pos, Random random) { + public void tick(BlockState state, ServerWorld world, BlockPos pos, Random random) { if (!world.isRemote) { world.removeBlock(pos, false); world.playSound(null, pos, SoundEvents.BLOCK_REDSTONE_TORCH_BURNOUT, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); diff --git a/src/main/java/knightminer/inspirations/tools/client/BarometerPropertyGetter.java b/src/main/java/knightminer/inspirations/tools/client/BarometerPropertyGetter.java index b5e4e2ad..5dd5edad 100644 --- a/src/main/java/knightminer/inspirations/tools/client/BarometerPropertyGetter.java +++ b/src/main/java/knightminer/inspirations/tools/client/BarometerPropertyGetter.java @@ -26,11 +26,11 @@ public float call(ItemStack stack, @Nullable World world, @Nullable LivingEntity } // if negative position, just 0 - if(entity.posY < 0) { + double height = entity.getPosY(); + if(height < 0) { return 0; } - double height = entity.posY; int worldHeight = world.getHeight(); if(height > worldHeight) { return 1; diff --git a/src/main/java/knightminer/inspirations/tools/client/RedstoneArrowRenderer.java b/src/main/java/knightminer/inspirations/tools/client/RedstoneArrowRenderer.java index 2ecef66d..8d08d4e3 100644 --- a/src/main/java/knightminer/inspirations/tools/client/RedstoneArrowRenderer.java +++ b/src/main/java/knightminer/inspirations/tools/client/RedstoneArrowRenderer.java @@ -16,7 +16,7 @@ public RedstoneArrowRenderer(EntityRendererManager renderManager) { } @Override - protected ResourceLocation getEntityTexture(@Nonnull RedstoneArrow entity) { + public ResourceLocation getEntityTexture(@Nonnull RedstoneArrow entity) { return CHARGED_ARROW; } diff --git a/src/main/java/knightminer/inspirations/tools/client/WaypointCompassPropertyGetter.java b/src/main/java/knightminer/inspirations/tools/client/WaypointCompassPropertyGetter.java index 1073b974..3604f956 100644 --- a/src/main/java/knightminer/inspirations/tools/client/WaypointCompassPropertyGetter.java +++ b/src/main/java/knightminer/inspirations/tools/client/WaypointCompassPropertyGetter.java @@ -70,7 +70,7 @@ private double getFrameRotation(ItemFrameEntity frame) { @OnlyIn(Dist.CLIENT) private double posToAngle(BlockPos pos, Entity entity) { - return Math.atan2((double)pos.getZ() + 0.5 - entity.posZ, (double)pos.getX() + 0.5 - entity.posX); + return Math.atan2((double)pos.getZ() + 0.5 - entity.getPosZ(), (double)pos.getX() + 0.5 - entity.getPosX()); } diff --git a/src/main/java/knightminer/inspirations/tools/datagen/ToolsRecipeProvider.java b/src/main/java/knightminer/inspirations/tools/datagen/ToolsRecipeProvider.java index 7d74f655..30ab5f1e 100644 --- a/src/main/java/knightminer/inspirations/tools/datagen/ToolsRecipeProvider.java +++ b/src/main/java/knightminer/inspirations/tools/datagen/ToolsRecipeProvider.java @@ -22,7 +22,7 @@ import net.minecraft.potion.PotionUtils; import net.minecraft.potion.Potions; import net.minecraftforge.common.Tags; -import net.minecraftforge.common.crafting.IngredientNBT; +import net.minecraftforge.common.crafting.NBTIngredient; import net.minecraftforge.common.crafting.conditions.ICondition; import net.minecraftforge.common.crafting.conditions.IConditionBuilder; @@ -57,12 +57,14 @@ protected void registerRecipes(@Nonnull Consumer consumer) { .patternLine(" I ") .build(consumer); + // not using the builder because it lacks potion ItemPredicate hasWater = new ItemPredicate( null, // Tag Items.POTION, MinMaxBounds.IntBound.UNBOUNDED, MinMaxBounds.IntBound.UNBOUNDED, - new EnchantmentPredicate[0], + EnchantmentPredicate.field_226534_b_, + EnchantmentPredicate.field_226534_b_, Potions.WATER, NBTPredicate.ANY ); @@ -71,7 +73,7 @@ protected void registerRecipes(@Nonnull Consumer consumer) { .addCondition(TOOLS) .addCondition(ConfigEnabledCondition.BAROMETER) .addCriterion("has_bottle", hasItem(hasWater)) - .key('W', IngredientNBT.fromStacks(PotionUtils.addPotionToItemStack( + .key('W', NBTIngredient.fromStacks(PotionUtils.addPotionToItemStack( new ItemStack(Items.POTION), Potions.WATER ))) diff --git a/src/main/java/knightminer/inspirations/tools/item/RedstoneChargerItem.java b/src/main/java/knightminer/inspirations/tools/item/RedstoneChargerItem.java index 99276154..dfdf89ce 100644 --- a/src/main/java/knightminer/inspirations/tools/item/RedstoneChargerItem.java +++ b/src/main/java/knightminer/inspirations/tools/item/RedstoneChargerItem.java @@ -4,6 +4,7 @@ import knightminer.inspirations.tools.block.RedstoneChargeBlock; import net.minecraft.advancements.CriteriaTriggers; import net.minecraft.block.BlockState; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.item.DirectionalPlaceContext; import net.minecraft.item.Item; @@ -43,16 +44,15 @@ public ActionResultType onItemUse(ItemUseContext context) { pos = pos.offset(facing); } - ItemStack stack = context.getItem(); - // stop if we cannot edit - if (context.getPlayer() == null || !context.getPlayer().canPlayerEdit(pos, facing, ItemStack.EMPTY)) { + PlayerEntity player = context.getPlayer(); + if (player == null || !player.canPlayerEdit(pos, facing, ItemStack.EMPTY)) { return ActionResultType.FAIL; } BlockState state = InspirationsTools.redstoneCharge.getDefaultState() .with(RedstoneChargeBlock.FACING, facing.getOpposite()) - .with(RedstoneChargeBlock.QUICK, context.isPlacerSneaking()); + .with(RedstoneChargeBlock.QUICK, player.isCrouching()); DirectionalPlaceContext blockContext = new DirectionalPlaceContext(world, pos, facing, ItemStack.EMPTY, facing); @@ -66,12 +66,13 @@ public ActionResultType onItemUse(ItemUseContext context) { } // mark we used the item + ItemStack stack = context.getItem(); if (context.getPlayer() instanceof ServerPlayerEntity) { CriteriaTriggers.PLACED_BLOCK.trigger((ServerPlayerEntity)context.getPlayer(), pos, stack); } // damage it and return - stack.damageItem(1, context.getPlayer(), player -> player.sendBreakAnimation(context.getHand())); + stack.damageItem(1, context.getPlayer(), cPlayer -> cPlayer.sendBreakAnimation(context.getHand())); return ActionResultType.SUCCESS; } diff --git a/src/main/java/knightminer/inspirations/tweaks/TweaksClientProxy.java b/src/main/java/knightminer/inspirations/tweaks/TweaksClientProxy.java index 8c9bc5f0..e190785a 100644 --- a/src/main/java/knightminer/inspirations/tweaks/TweaksClientProxy.java +++ b/src/main/java/knightminer/inspirations/tweaks/TweaksClientProxy.java @@ -5,6 +5,8 @@ import knightminer.inspirations.library.Util; import knightminer.inspirations.tweaks.client.PortalColorHandler; import net.minecraft.block.Blocks; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.RenderTypeLookup; import net.minecraft.client.renderer.color.BlockColors; import net.minecraft.client.renderer.color.ItemColors; import net.minecraft.client.renderer.model.IBakedModel; @@ -26,6 +28,7 @@ import net.minecraftforge.common.util.Constants; import net.minecraftforge.event.entity.player.ItemTooltipEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.registries.ForgeRegistries; import java.util.Map; @@ -37,25 +40,28 @@ public class TweaksClientProxy extends ClientProxy { private static final ResourceLocation FIREWORKS_VANILLA = new ModelResourceLocation("firework_rocket", "inventory"); private static final ResourceLocation FIREWORKS_TINTED = Util.getResource("item/fireworks"); - private static final ResourceLocation PORTAL_EW_VANILLA = new ModelResourceLocation( - "minecraft:nether_portal", "axis=z"); - private static final ResourceLocation PORTAL_NS_VANILLA = new ModelResourceLocation( - "minecraft:nether_portal", "axis=x"); + private static final ResourceLocation PORTAL_EW_VANILLA = new ModelResourceLocation("minecraft:nether_portal", "axis=z"); + private static final ResourceLocation PORTAL_NS_VANILLA = new ModelResourceLocation("minecraft:nether_portal", "axis=x"); private static final ResourceLocation PORTAL_EW_TINTED = Util.getResource("block/nether_portal_tinted_ew"); private static final ResourceLocation PORTAL_NS_TINTED = Util.getResource("block/nether_portal_tinted_ns"); private static final ResourceLocation CAULDRON_MODEL_VANILLA = new ModelResourceLocation("cauldron", "inventory"); private static final ResourceLocation CAULDRON_ITEM_MODEL = new ModelResourceLocation(Util.getResource("cauldron"), "inventory"); + @SubscribeEvent + public void clientSetup(FMLClientSetupEvent event) { + RenderType cutout = RenderType.getCutout(); + RenderTypeLookup.setRenderLayer(InspirationsTweaks.cactus, cutout); + RenderTypeLookup.setRenderLayer(InspirationsTweaks.sugarCane, cutout); + } + @SubscribeEvent public void loadCustomModels(ModelRegistryEvent event) { // Register these models to be loaded in directly. ModelLoader.addSpecialModel(PORTAL_EW_TINTED); ModelLoader.addSpecialModel(PORTAL_NS_TINTED); - ModelLoader.addSpecialModel(ENCHANTED_BOOK_TINTED); ModelLoader.addSpecialModel(FIREWORKS_TINTED); - ModelLoader.addSpecialModel(CAULDRON_ITEM_MODEL); } diff --git a/src/main/java/knightminer/inspirations/tweaks/TweaksEvents.java b/src/main/java/knightminer/inspirations/tweaks/TweaksEvents.java index e9ae3e76..7cf92c0d 100644 --- a/src/main/java/knightminer/inspirations/tweaks/TweaksEvents.java +++ b/src/main/java/knightminer/inspirations/tweaks/TweaksEvents.java @@ -48,13 +48,13 @@ public static void unsaddlePig(EntityInteract event) { PlayerEntity player = event.getPlayer(); ItemStack stack = player.getHeldItem(event.getHand()); // must be sneaking and holding nothing - if(player.isSneaking() && stack.isEmpty()) { + if(player.isCrouching() && stack.isEmpty()) { Entity target = event.getTarget(); if(target instanceof PigEntity) { PigEntity pig = (PigEntity) target; if(pig.getSaddled()) { pig.setSaddled(false); - pig.world.playSound(player, pig.posX, pig.posY, pig.posZ, SoundEvents.ENTITY_PIG_SADDLE, SoundCategory.NEUTRAL, 0.5F, 1.0F); + pig.world.playSound(player, pig.getPosX(), pig.getPosY(), pig.getPosZ(), SoundEvents.ENTITY_PIG_SADDLE, SoundCategory.NEUTRAL, 0.5F, 1.0F); ItemHandlerHelper.giveItemToPlayer(player, new ItemStack(Items.SADDLE), player.inventory.currentItem); event.setCanceled(true); } diff --git a/src/main/java/knightminer/inspirations/tweaks/block/WetHopperBlock.java b/src/main/java/knightminer/inspirations/tweaks/block/WetHopperBlock.java index 2460098d..e576766d 100644 --- a/src/main/java/knightminer/inspirations/tweaks/block/WetHopperBlock.java +++ b/src/main/java/knightminer/inspirations/tweaks/block/WetHopperBlock.java @@ -17,6 +17,7 @@ public WetHopperBlock(Properties props) { super(props); } + @Deprecated @Nonnull @Override public IFluidState getFluidState(BlockState state) { diff --git a/src/main/java/knightminer/inspirations/tweaks/client/PortalColorHandler.java b/src/main/java/knightminer/inspirations/tweaks/client/PortalColorHandler.java index 1d184fc0..385adcc7 100644 --- a/src/main/java/knightminer/inspirations/tweaks/client/PortalColorHandler.java +++ b/src/main/java/knightminer/inspirations/tweaks/client/PortalColorHandler.java @@ -11,7 +11,7 @@ import net.minecraft.client.renderer.chunk.ChunkRenderCache; import net.minecraft.client.renderer.color.IBlockColor; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IEnviromentBlockReader; +import net.minecraft.world.ILightReader; import net.minecraft.world.IWorldReader; import javax.annotation.Nonnull; @@ -30,7 +30,7 @@ public class PortalColorHandler implements IBlockColor { private PortalColorHandler() {} @Override - public int getColor(@Nonnull BlockState state, @Nullable IEnviromentBlockReader world, @Nullable BlockPos pos, int tintValue) { + public int getColor(@Nonnull BlockState state, @Nullable ILightReader world, @Nullable BlockPos pos, int tintValue) { if (!Config.customPortalColor.get()) { return -1; } @@ -67,7 +67,7 @@ public int getColor(@Nonnull BlockState state, @Nullable IEnviromentBlockReader * @param access Block access * @param pos Block pos */ - private static int getColorValue(IEnviromentBlockReader access, BlockPos pos) { + private static int getColorValue(ILightReader access, BlockPos pos) { BlockState state = access.getBlockState(pos); Block block = state.getBlock(); // stained glass diff --git a/src/main/java/knightminer/inspirations/tweaks/datagen/TweaksRecipeProvider.java b/src/main/java/knightminer/inspirations/tweaks/datagen/TweaksRecipeProvider.java index 2a56f768..664b86a6 100644 --- a/src/main/java/knightminer/inspirations/tweaks/datagen/TweaksRecipeProvider.java +++ b/src/main/java/knightminer/inspirations/tweaks/datagen/TweaksRecipeProvider.java @@ -5,8 +5,10 @@ import knightminer.inspirations.common.datagen.CondRecipe; import knightminer.inspirations.tweaks.InspirationsTweaks; import knightminer.inspirations.utility.InspirationsUtility; +import net.minecraft.advancements.criterion.EnchantmentPredicate; import net.minecraft.advancements.criterion.ItemPredicate; import net.minecraft.advancements.criterion.MinMaxBounds; +import net.minecraft.advancements.criterion.NBTPredicate; import net.minecraft.data.DataGenerator; import net.minecraft.data.IFinishedRecipe; import net.minecraft.data.RecipeProvider; @@ -33,7 +35,6 @@ public String getName() { } @Override protected void registerRecipes(@Nonnull Consumer consumer) { - // Since these are mass-production recipes, show them after the user makes // several of the original. CondRecipe.shaped(InspirationsUtility.collector) @@ -41,11 +42,17 @@ protected void registerRecipes(@Nonnull Consumer consumer) { .addCondition(ConfigEnabledCondition.COLLECTOR) .addCondition(TWEAKS) .addCondition(ConfigEnabledCondition.UNSTACKABLE_ALTS) - .addCriterion("many_collectors", hasItem(new ItemPredicate.Builder() - .item(InspirationsUtility.collector) - .count(MinMaxBounds.IntBound.atLeast(5)) - .build() - )) + // builder is missing count, so use ItemPredicate constructor + .addCriterion("many_collectors", hasItem(new ItemPredicate( + null, // tag + InspirationsUtility.collector.asItem(), + MinMaxBounds.IntBound.atLeast(5), + MinMaxBounds.IntBound.UNBOUNDED, + EnchantmentPredicate.field_226534_b_, + EnchantmentPredicate.field_226534_b_, + null, // potion + NBTPredicate.ANY + ))) .key('T', Tags.Items.RODS_WOODEN) .key('S', Tags.Items.STRING) .key('D', Items.DROPPER) @@ -59,11 +66,17 @@ protected void registerRecipes(@Nonnull Consumer consumer) { .addCondition(ConfigEnabledCondition.COLLECTOR) .addCondition(TWEAKS) .addCondition(ConfigEnabledCondition.UNSTACKABLE_ALTS) - .addCriterion("many_collectors", hasItem(new ItemPredicate.Builder() - .item(Items.DISPENSER) - .count(MinMaxBounds.IntBound.atLeast(5)) - .build() - )) + // builder is missing count, so use ItemPredicate constructor + .addCriterion("many_collectors", hasItem(new ItemPredicate( + null, // tag + Items.DISPENSER, + MinMaxBounds.IntBound.atLeast(5), + MinMaxBounds.IntBound.UNBOUNDED, + EnchantmentPredicate.field_226534_b_, + EnchantmentPredicate.field_226534_b_, + null, // potion + NBTPredicate.ANY + ))) .key('T', Tags.Items.RODS_WOODEN) .key('S', Tags.Items.STRING) .key('D', Items.DROPPER) diff --git a/src/main/java/knightminer/inspirations/utility/block/BricksButtonBlock.java b/src/main/java/knightminer/inspirations/utility/block/BricksButtonBlock.java index 1020eae7..10fc0591 100644 --- a/src/main/java/knightminer/inspirations/utility/block/BricksButtonBlock.java +++ b/src/main/java/knightminer/inspirations/utility/block/BricksButtonBlock.java @@ -15,6 +15,7 @@ import net.minecraft.state.DirectionProperty; import net.minecraft.state.StateContainer; import net.minecraft.state.properties.BlockStateProperties; +import net.minecraft.util.ActionResultType; import net.minecraft.util.Direction; import net.minecraft.util.Hand; import net.minecraft.util.Mirror; @@ -29,6 +30,9 @@ import net.minecraft.world.IWorld; import net.minecraft.world.IWorldReader; import net.minecraft.world.World; +import net.minecraft.world.server.ServerWorld; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -108,31 +112,32 @@ public int tickRate(IWorldReader p_149738_1_) { @Deprecated @Override - public boolean onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult trace) { + public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult trace) { // if you did not click the secret button, no button for you if(!getButtonBox(state).contains(trace.getHitVec().subtract(new Vec3d(pos)))) { - return false; + return ActionResultType.PASS; } // if already powered, we done here if (state.get(POWERED)) { - return true; + return ActionResultType.SUCCESS; } world.setBlockState(pos, state.with(POWERED, true), 3); world.playSound(player, pos, SoundEvents.BLOCK_STONE_BUTTON_CLICK_ON, SoundCategory.BLOCKS, 0.3F, 0.6F); world.notifyNeighborsOfStateChange(pos, this); world.getPendingBlockTicks().scheduleTick(pos, this, this.tickRate(world)); - return true; + return ActionResultType.SUCCESS; } @Deprecated @Override - public void randomTick(@Nonnull BlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Random rand) {} + @OnlyIn(Dist.CLIENT) + public void animateTick(@Nonnull BlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Random rand) {} @Deprecated @Override - public void tick(BlockState state, World world, BlockPos pos, Random random) { + public void tick(BlockState state, ServerWorld world, BlockPos pos, Random random) { if (world.isRemote) { return; } diff --git a/src/main/java/knightminer/inspirations/utility/block/CollectorBlock.java b/src/main/java/knightminer/inspirations/utility/block/CollectorBlock.java index a69f4f0b..e9d91dda 100644 --- a/src/main/java/knightminer/inspirations/utility/block/CollectorBlock.java +++ b/src/main/java/knightminer/inspirations/utility/block/CollectorBlock.java @@ -29,6 +29,7 @@ import net.minecraft.world.IWorld; import net.minecraft.world.IWorldReader; import net.minecraft.world.World; +import net.minecraft.world.server.ServerWorld; import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.ItemHandlerHelper; @@ -89,7 +90,8 @@ public BlockState mirror(BlockState state, Mirror mirror) { public BlockState getStateForPlacement(BlockItemUseContext context) { // place opposite since its more useful to face into what you clicked Direction facing = context.getNearestLookingDirection(); - if(context.isPlacerSneaking()) { + PlayerEntity player = context.getPlayer(); + if(player != null && player.isCrouching()) { facing = facing.getOpposite(); } return this.getDefaultState().with(FACING, facing); @@ -109,12 +111,6 @@ public void onReplaced(BlockState state, World world, BlockPos pos, BlockState n /* Tile Entity */ - @Nonnull - @Override - public TileEntity createNewTileEntity(@Nonnull IBlockReader world) { - return new CollectorTileEntity(); - } - @Nonnull @Override public TileEntity createTileEntity(BlockState blockState, IBlockReader iBlockReader) { @@ -179,7 +175,7 @@ public int tickRate(IWorldReader worldIn) { @Deprecated @Override - public void tick(BlockState state, World world, BlockPos pos, Random random) { + public void tick(BlockState state, ServerWorld world, BlockPos pos, Random random) { if (world.isRemote) { return; } diff --git a/src/main/java/knightminer/inspirations/utility/block/PipeBlock.java b/src/main/java/knightminer/inspirations/utility/block/PipeBlock.java index ef535a0b..f95304a3 100644 --- a/src/main/java/knightminer/inspirations/utility/block/PipeBlock.java +++ b/src/main/java/knightminer/inspirations/utility/block/PipeBlock.java @@ -28,6 +28,7 @@ import net.minecraft.state.StateContainer; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ActionResultType; import net.minecraft.util.Direction; import net.minecraft.util.Hand; import net.minecraft.util.Mirror; @@ -169,18 +170,20 @@ public BlockState getStateForPlacement(BlockItemUseContext context) { .with(WEST, canConnectTo(world, pos, facing, Direction.WEST)); } + @Deprecated @Override @Nonnull public IFluidState getFluidState(BlockState state) { return state.get(WATERLOGGED) ? Fluids.WATER.getStillFluidState(false) : super.getFluidState(state); } + @Deprecated @Override - public boolean onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult trace) { + public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult trace) { // return false if holding a pipe to make easier to place Item item = player.getHeldItem(hand).getItem(); if(item == InspirationsUtility.pipe.asItem() || Block.getBlockFromItem(item) instanceof HopperBlock) { - return false; + return ActionResultType.PASS; } return super.onBlockActivated(state, world, pos, player, hand, trace); } @@ -214,13 +217,6 @@ private static boolean canConnectTo(IWorld world, BlockPos pos, Direction facing /* Tile Entity */ - - @Nullable - @Override - public TileEntity createNewTileEntity(@Nonnull IBlockReader world) { - return new PipeTileEntity(); - } - @Nonnull @Override public TileEntity createTileEntity(BlockState state, IBlockReader world) { diff --git a/src/main/java/knightminer/inspirations/utility/block/TorchLevelBlock.java b/src/main/java/knightminer/inspirations/utility/block/TorchLevelBlock.java index 6093ea33..2c3a5d00 100644 --- a/src/main/java/knightminer/inspirations/utility/block/TorchLevelBlock.java +++ b/src/main/java/knightminer/inspirations/utility/block/TorchLevelBlock.java @@ -9,6 +9,7 @@ import net.minecraft.particles.ParticleTypes; import net.minecraft.state.DirectionProperty; import net.minecraft.state.StateContainer; +import net.minecraft.util.ActionResultType; import net.minecraft.util.Direction; import net.minecraft.util.Hand; import net.minecraft.util.SoundCategory; @@ -69,9 +70,9 @@ public void animateTick(BlockState state, @Nonnull World world, BlockPos pos, @N @Deprecated @Override - public boolean onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult trace) { + public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult trace) { if (world.isRemote) { - return true; + return ActionResultType.SUCCESS; } float pitch; @@ -90,7 +91,7 @@ public boolean onBlockActivated(BlockState state, World world, BlockPos pos, Pla world.notifyNeighborsOfStateChange(pos, this); world.notifyNeighborsOfStateChange(pos.down(), this); - return true; + return ActionResultType.SUCCESS; } diff --git a/src/main/java/knightminer/inspirations/utility/block/TorchLeverWallBlock.java b/src/main/java/knightminer/inspirations/utility/block/TorchLeverWallBlock.java index 43d5bc94..56ec19c2 100644 --- a/src/main/java/knightminer/inspirations/utility/block/TorchLeverWallBlock.java +++ b/src/main/java/knightminer/inspirations/utility/block/TorchLeverWallBlock.java @@ -11,6 +11,7 @@ import net.minecraft.state.DirectionProperty; import net.minecraft.state.StateContainer; import net.minecraft.state.properties.BlockStateProperties; +import net.minecraft.util.ActionResultType; import net.minecraft.util.Direction; import net.minecraft.util.Hand; import net.minecraft.util.SoundCategory; @@ -70,9 +71,9 @@ public void animateTick(BlockState state, @Nonnull World world, BlockPos pos, @N @Deprecated @Override - public boolean onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult trace) { + public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult trace) { if (world.isRemote) { - return true; + return ActionResultType.SUCCESS; } // update state @@ -84,7 +85,7 @@ public boolean onBlockActivated(BlockState state, World world, BlockPos pos, Pla // notify update world.notifyNeighborsOfStateChange(pos, this); world.notifyNeighborsOfStateChange(pos.offset(state.get(FACING).getOpposite()), this); - return true; + return ActionResultType.SUCCESS; } diff --git a/src/main/java/knightminer/inspirations/utility/inventory/CollectorContainer.java b/src/main/java/knightminer/inspirations/utility/inventory/CollectorContainer.java index 8e81ff44..dc229b2d 100644 --- a/src/main/java/knightminer/inspirations/utility/inventory/CollectorContainer.java +++ b/src/main/java/knightminer/inspirations/utility/inventory/CollectorContainer.java @@ -11,6 +11,16 @@ import slimeknights.mantle.inventory.MultiModuleContainer; public class CollectorContainer extends MultiModuleContainer { + public CollectorContainer(int winId, PlayerInventory inventoryPlayer, CollectorTileEntity tile) { + super(InspirationsUtility.contCollector, winId, inventoryPlayer, tile); + for(int y = 0; y < 3; y++) { + for(int x = 0; x < 3; x++) { + this.addSlot(new Slot(tile, (x+y*3), 62+(x*18), 17+(y*18))); + } + } + addInventorySlots(); + } + public static class Factory implements IContainerFactory { @Override public CollectorContainer create(int windowId, PlayerInventory inv, PacketBuffer data) { @@ -23,15 +33,4 @@ public CollectorContainer create(int windowId, PlayerInventory inv, PacketBuffer throw new AssertionError(String.format("No collector at %s!", pos)); } } - - public CollectorContainer(int winId, PlayerInventory inventoryPlayer, CollectorTileEntity tile) { - super(InspirationsUtility.contCollector, winId, tile); - for(int y = 0; y < 3; y++) { - for(int x = 0; x < 3; x++) { - this.addSlot(new Slot(tile, (x+y*3), 62+(x*18), 17+(y*18))); - } - } - - addPlayerInventory(inventoryPlayer, 8, 84); - } } diff --git a/src/main/java/knightminer/inspirations/utility/inventory/PipeContainer.java b/src/main/java/knightminer/inspirations/utility/inventory/PipeContainer.java index d44c2a23..d9527969 100644 --- a/src/main/java/knightminer/inspirations/utility/inventory/PipeContainer.java +++ b/src/main/java/knightminer/inspirations/utility/inventory/PipeContainer.java @@ -11,6 +11,22 @@ import slimeknights.mantle.inventory.MultiModuleContainer; public class PipeContainer extends MultiModuleContainer { + public PipeContainer(int winId, PlayerInventory inventoryPlayer, PipeTileEntity tile) { + super(InspirationsUtility.contPipe, winId, inventoryPlayer, tile); + this.addSlot(new Slot(tile, 0, 80, 20)); + addInventorySlots(); + } + + @Override + protected int getInventoryXOffset() { + return 8; + } + + @Override + protected int getInventoryYOffset() { + return 51; + } + public static class Factory implements IContainerFactory { @Override public PipeContainer create(int windowId, PlayerInventory inv, PacketBuffer data) { @@ -23,12 +39,4 @@ public PipeContainer create(int windowId, PlayerInventory inv, PacketBuffer data throw new AssertionError(String.format("No pipe at %s!", pos)); } } - - - public PipeContainer(int winId, PlayerInventory inventoryPlayer, PipeTileEntity tile) { - super(InspirationsUtility.contPipe, winId, tile); - this.addSlot(new Slot(tile, 0, 80, 20)); - - addPlayerInventory(inventoryPlayer, 8, 51); - } } diff --git a/src/main/resources/assets/inspirations/blockstates/ancient_bookshelf.json b/src/main/resources/assets/inspirations/blockstates/ancient_bookshelf.json index 864138a8..4abce38f 100644 --- a/src/main/resources/assets/inspirations/blockstates/ancient_bookshelf.json +++ b/src/main/resources/assets/inspirations/blockstates/ancient_bookshelf.json @@ -1,14 +1,8 @@ { - "forge_marker": 1, - "defaults": { - "model": "inspirations:block/bookshelf/ancient" - }, "variants": { - "facing": { - "south": {}, - "west": { "y": 90 }, - "north": { "y": 180 }, - "east": { "y": 270 } - } + "facing=south": { "model": "inspirations:block/bookshelf/ancient" }, + "facing=west": { "model": "inspirations:block/bookshelf/ancient", "y": 90 }, + "facing=north": { "model": "inspirations:block/bookshelf/ancient", "y": 180 }, + "facing=east": { "model": "inspirations:block/bookshelf/ancient", "y": 270 } } } diff --git a/src/main/resources/assets/inspirations/blockstates/bookshelf.json b/src/main/resources/assets/inspirations/blockstates/bookshelf.json index 8acfd57a..bc67d128 100644 --- a/src/main/resources/assets/inspirations/blockstates/bookshelf.json +++ b/src/main/resources/assets/inspirations/blockstates/bookshelf.json @@ -1,14 +1,8 @@ { - "forge_marker": 1, - "defaults": { - "model": "inspirations:block/bookshelf/normal" - }, "variants": { - "facing": { - "south": {}, - "west": { "y": 90 }, - "north": { "y": 180 }, - "east": { "y": 270 } - } + "facing=south": { "model": "inspirations:block/bookshelf/normal" }, + "facing=west": { "model": "inspirations:block/bookshelf/normal", "y": 90 }, + "facing=north": { "model": "inspirations:block/bookshelf/normal", "y": 180 }, + "facing=east": { "model": "inspirations:block/bookshelf/normal", "y": 270 } } } diff --git a/src/main/resources/assets/inspirations/blockstates/cactus.json b/src/main/resources/assets/inspirations/blockstates/cactus.json index cc688013..826336cf 100644 --- a/src/main/resources/assets/inspirations/blockstates/cactus.json +++ b/src/main/resources/assets/inspirations/blockstates/cactus.json @@ -1,14 +1,11 @@ { - "forge_marker": 1, "variants": { - "age": { - "0": { "model": "inspirations:block/cactus/0" }, - "1": { "model": "inspirations:block/cactus/1" }, - "2": { "model": "inspirations:block/cactus/2" }, - "3": { "model": "inspirations:block/cactus/3" }, - "4": { "model": "inspirations:block/cactus/4" }, - "5": { "model": "inspirations:block/cactus/5" }, - "6": { "model": "inspirations:block/cactus/6" } - } + "age=0": { "model": "inspirations:block/cactus/0" }, + "age=1": { "model": "inspirations:block/cactus/1" }, + "age=2": { "model": "inspirations:block/cactus/2" }, + "age=3": { "model": "inspirations:block/cactus/3" }, + "age=4": { "model": "inspirations:block/cactus/4" }, + "age=5": { "model": "inspirations:block/cactus/5" }, + "age=6": { "model": "inspirations:block/cactus/6" } } } diff --git a/src/main/resources/assets/inspirations/blockstates/rainbow_bookshelf.json b/src/main/resources/assets/inspirations/blockstates/rainbow_bookshelf.json index 8750f576..6f510aca 100644 --- a/src/main/resources/assets/inspirations/blockstates/rainbow_bookshelf.json +++ b/src/main/resources/assets/inspirations/blockstates/rainbow_bookshelf.json @@ -1,14 +1,8 @@ { - "forge_marker": 1, - "defaults": { - "model": "inspirations:block/bookshelf/rainbow" - }, "variants": { - "facing": { - "south": {}, - "west": { "y": 90 }, - "north": { "y": 180 }, - "east": { "y": 270 } - } + "facing=south": { "model": "inspirations:block/bookshelf/rainbow" }, + "facing=west": { "model": "inspirations:block/bookshelf/rainbow", "y": 90 }, + "facing=north": { "model": "inspirations:block/bookshelf/rainbow", "y": 180 }, + "facing=east": { "model": "inspirations:block/bookshelf/rainbow", "y": 270 } } } diff --git a/src/main/resources/assets/inspirations/blockstates/sugar_cane.json b/src/main/resources/assets/inspirations/blockstates/sugar_cane.json index c82b5485..1d4ed953 100644 --- a/src/main/resources/assets/inspirations/blockstates/sugar_cane.json +++ b/src/main/resources/assets/inspirations/blockstates/sugar_cane.json @@ -1,14 +1,11 @@ { - "forge_marker": 1, "variants": { - "age": { - "0": { "model": "inspirations:block/sugar_cane/0" }, - "1": { "model": "inspirations:block/sugar_cane/1" }, - "2": { "model": "inspirations:block/sugar_cane/2" }, - "3": { "model": "inspirations:block/sugar_cane/3" }, - "4": { "model": "inspirations:block/sugar_cane/4" }, - "5": { "model": "inspirations:block/sugar_cane/5" }, - "6": { "model": "inspirations:block/sugar_cane/6" } - } + "age=0": { "model": "inspirations:block/sugar_cane/0" }, + "age=1": { "model": "inspirations:block/sugar_cane/1" }, + "age=2": { "model": "inspirations:block/sugar_cane/2" }, + "age=3": { "model": "inspirations:block/sugar_cane/3" }, + "age=4": { "model": "inspirations:block/sugar_cane/4" }, + "age=5": { "model": "inspirations:block/sugar_cane/5" }, + "age=6": { "model": "inspirations:block/sugar_cane/6" } } } diff --git a/src/main/resources/assets/inspirations/blockstates/tomes_bookshelf.json b/src/main/resources/assets/inspirations/blockstates/tomes_bookshelf.json index 0a391c73..3435db44 100644 --- a/src/main/resources/assets/inspirations/blockstates/tomes_bookshelf.json +++ b/src/main/resources/assets/inspirations/blockstates/tomes_bookshelf.json @@ -1,14 +1,8 @@ { - "forge_marker": 1, - "defaults": { - "model": "inspirations:block/bookshelf/tomes" - }, "variants": { - "facing": { - "south": {}, - "west": { "y": 90 }, - "north": { "y": 180 }, - "east": { "y": 270 } - } + "facing=south": { "model": "inspirations:block/bookshelf/tomes" }, + "facing=west": { "model": "inspirations:block/bookshelf/tomes", "y": 90 }, + "facing=north": { "model": "inspirations:block/bookshelf/tomes", "y": 180 }, + "facing=east": { "model": "inspirations:block/bookshelf/tomes", "y": 270 } } }