From b0a45b4f7d637c4872e17c144dcb13b5af5ca23d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Vo=C3=9F?= Date: Tue, 26 Jan 2021 12:44:24 +0100 Subject: [PATCH] backport to 1.15 #10 --- gradle.properties | 8 ++-- .../block/AbstractSolarCookerBlock.java | 11 +++--- .../solarcooker/block/ReflectorBlock.java | 2 +- .../solarcooker/block/SolarCookerBlock.java | 4 +- .../solarcooker/client/SolarCookerScreen.java | 38 +++++++++++++------ .../client/SolarCookerTileEntityRenderer.java | 3 +- .../solarcooker/jei/SolarCookerJEIPlugin.java | 6 +-- .../AbstractSolarCookerTileEntity.java | 14 +++---- .../resources/META-INF/accesstransformer.cfg | 1 + src/main/resources/META-INF/mods.toml | 8 ++-- 10 files changed, 56 insertions(+), 39 deletions(-) diff --git a/gradle.properties b/gradle.properties index 668ae48..533e4a5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,9 +4,9 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false mod_version=0.3.0 -minecraft_version=1.16.1+ +minecraft_version=1.15.2 -forge_version=1.16.1-32.0.70 -forge_mappings=20200707-1.16.1 +forge_version=1.15.2-31.2.47 +forge_mappings=20210125-1.15.1 -jei_version=1.16.1:7.+ \ No newline at end of file +jei_version=1.15.2:6.0.0.2+ \ No newline at end of file diff --git a/src/main/java/cech12/solarcooker/block/AbstractSolarCookerBlock.java b/src/main/java/cech12/solarcooker/block/AbstractSolarCookerBlock.java index 4593bf7..4738494 100644 --- a/src/main/java/cech12/solarcooker/block/AbstractSolarCookerBlock.java +++ b/src/main/java/cech12/solarcooker/block/AbstractSolarCookerBlock.java @@ -1,7 +1,7 @@ package cech12.solarcooker.block; import cech12.solarcooker.tileentity.AbstractSolarCookerTileEntity; -import net.minecraft.block.AbstractBlock; +//import net.minecraft.block.AbstractBlock; //1.16 import net.minecraft.block.Block; import net.minecraft.block.BlockRenderType; import net.minecraft.block.BlockState; @@ -25,9 +25,10 @@ import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.util.math.Vec3d; //1.15 import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.vector.Vector3d; +//import net.minecraft.util.math.vector.Vector3d; //1.16 import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraftforge.common.ToolType; @@ -42,7 +43,7 @@ public abstract class AbstractSolarCookerBlock extends ContainerBlock { protected static final VoxelShape SHAPE_OPEN = Block.makeCuboidShape(1.0D, 0.0D, 1.0D, 15.0D, 10.0D, 15.0D); protected static final VoxelShape SHAPE_CLOSED = Block.makeCuboidShape(1.0D, 0.0D, 1.0D, 15.0D, 14.0D, 15.0D); - protected AbstractSolarCookerBlock(AbstractBlock.Properties properties) { + protected AbstractSolarCookerBlock(Block.Properties properties) { //1.15 super(properties); this.setDefaultState(this.stateContainer.getBaseState().with(FACING, Direction.NORTH).with(SUNLIT, false).with(BURNING, false)); } @@ -90,11 +91,11 @@ public void onBlockPlacedBy(@Nonnull World worldIn, @Nonnull BlockPos pos, @Nonn @Override @Deprecated public void onReplaced(BlockState state, @Nonnull World worldIn, @Nonnull BlockPos pos, BlockState newState, boolean isMoving) { - if (!state.isIn(newState.getBlock())) { + if (state.getBlock() != newState.getBlock()) { //1.15 TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof AbstractSolarCookerTileEntity) { InventoryHelper.dropInventoryItems(worldIn, pos, (AbstractSolarCookerTileEntity)tileentity); - ((AbstractSolarCookerTileEntity)tileentity).func_235640_a_(worldIn, Vector3d.func_237489_a_(pos)); + ((AbstractSolarCookerTileEntity)tileentity).func_235640_a_(worldIn, new Vec3d(pos.getX(), pos.getY(), pos.getZ())); //1.15 worldIn.updateComparatorOutputLevel(pos, this); } diff --git a/src/main/java/cech12/solarcooker/block/ReflectorBlock.java b/src/main/java/cech12/solarcooker/block/ReflectorBlock.java index 1fa8be4..472344b 100644 --- a/src/main/java/cech12/solarcooker/block/ReflectorBlock.java +++ b/src/main/java/cech12/solarcooker/block/ReflectorBlock.java @@ -40,7 +40,7 @@ public boolean isToolEffective(BlockState state, ToolType tool) { @Override public void addInformation(@Nonnull ItemStack stack, @Nullable IBlockReader worldIn, @Nonnull List tooltip, @Nonnull ITooltipFlag flagIn) { super.addInformation(stack, worldIn, tooltip, flagIn); - tooltip.add(new TranslationTextComponent("item.solarcooker.reflector.description").func_240701_a_(TextFormatting.BLUE)); + tooltip.add(new TranslationTextComponent("item.solarcooker.reflector.description").applyTextStyle(TextFormatting.BLUE)); //1.15 } @Override diff --git a/src/main/java/cech12/solarcooker/block/SolarCookerBlock.java b/src/main/java/cech12/solarcooker/block/SolarCookerBlock.java index 2d7de34..b3bf136 100644 --- a/src/main/java/cech12/solarcooker/block/SolarCookerBlock.java +++ b/src/main/java/cech12/solarcooker/block/SolarCookerBlock.java @@ -5,7 +5,7 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.model.ItemCameraTransforms; +//import net.minecraft.client.renderer.model.ItemCameraTransforms; //1.16 import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.entity.player.PlayerEntity; @@ -74,7 +74,7 @@ public void setISTER(Item.Properties props) { @Override //render - public void func_239207_a_(@Nonnull ItemStack stack, @Nonnull ItemCameraTransforms.TransformType transformType, @Nonnull MatrixStack matrix, @Nonnull IRenderTypeBuffer buffer, int x, int y) { + public void render(@Nonnull ItemStack stack, @Nonnull MatrixStack matrix, @Nonnull IRenderTypeBuffer buffer, int x, int y) { //1.15 if (tile == null) { tile = new SolarCookerTileEntity(); } diff --git a/src/main/java/cech12/solarcooker/client/SolarCookerScreen.java b/src/main/java/cech12/solarcooker/client/SolarCookerScreen.java index b0d9723..0f7aae8 100644 --- a/src/main/java/cech12/solarcooker/client/SolarCookerScreen.java +++ b/src/main/java/cech12/solarcooker/client/SolarCookerScreen.java @@ -2,7 +2,7 @@ import cech12.solarcooker.SolarCookerMod; import cech12.solarcooker.inventory.SolarCookerContainer; -import com.mojang.blaze3d.matrix.MatrixStack; +//import com.mojang.blaze3d.matrix.MatrixStack; //1.16 import net.minecraft.client.gui.screen.inventory.ContainerScreen; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.util.ResourceLocation; @@ -10,7 +10,7 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import javax.annotation.Nonnull; +//import javax.annotation.Nonnull; //1.16 @OnlyIn(Dist.CLIENT) public class SolarCookerScreen extends ContainerScreen { @@ -20,38 +20,52 @@ public SolarCookerScreen(SolarCookerContainer screenContainer, PlayerInventory i super(screenContainer, inv, titleIn); } + @Override public void init() { super.init(); - this.field_238742_p_ = (this.xSize - this.font.func_238414_a_(this.title)) / 2; + //this.field_238742_p_ = (this.xSize - this.font.func_238414_a_(this.title)) / 2; //1.16 } - public void render(@Nonnull MatrixStack p_230430_1_, int p_230430_2_, int p_230430_3_, float p_230430_4_) { - this.renderBackground(p_230430_1_); - super.render(p_230430_1_, p_230430_2_, p_230430_3_, p_230430_4_); - this.func_230459_a_(p_230430_1_, p_230430_2_, p_230430_3_); + /** + * 1.15 + */ + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + String s = this.title.getFormattedText(); + this.font.drawString(s, (float)(this.xSize / 2 - this.font.getStringWidth(s) / 2), 6.0F, 4210752); + this.font.drawString(this.playerInventory.getDisplayName().getFormattedText(), 8.0F, (float)(this.ySize - 96 + 2), 4210752); } - protected void func_230450_a_(@Nonnull MatrixStack p_230450_1_, float p_230450_2_, int p_230450_3_, int p_230450_4_) { + @Override + public void render(int p_230430_2_, int p_230430_3_, float p_230430_4_) { //1.15 + this.renderBackground(); //1.15 + super.render( p_230430_2_, p_230430_3_, p_230430_4_); //1.15 + this.renderHoveredToolTip(p_230430_2_, p_230430_3_); //1.15 + } + + @Override + protected void drawGuiContainerBackgroundLayer(float p_230450_2_, int p_230450_3_, int p_230450_4_) { //1.15 if (this.minecraft != null) { this.minecraft.getTextureManager().bindTexture(guiTexture); //draw gui int left = this.guiLeft; int top = this.guiTop; - this.blit(p_230450_1_, left, top, 0, 0, this.xSize, this.ySize); + this.blit(left, top, 0, 0, this.xSize, this.ySize); //1.15 //draw flame if (this.container.isBurning()) { - this.blit(p_230450_1_, left + 56, top + 36, 176, 0, 14, 14); + this.blit(left + 56, top + 36, 176, 0, 14, 14); //1.15 } //draw progress int progress = this.container.getCookProgressionScaled(); - this.blit(p_230450_1_, left + 79, top + 34, 176, 14, progress + 1, 16); + this.blit(left + 79, top + 34, 176, 14, progress + 1, 16); //1.15 //draw sun if (this.container.isSunlit()) { - this.blit(p_230450_1_, left + 55, top + 52, 176, 31, 18, 18); + this.blit(left + 55, top + 52, 176, 31, 18, 18); //1.15 } } } + @Override protected boolean hasClickedOutside(double mouseX, double mouseY, int guiLeftIn, int guiTopIn, int mouseButton) { return mouseX < (double)guiLeftIn || mouseY < (double)guiTopIn || mouseX >= (double)(guiLeftIn + this.xSize) || mouseY >= (double)(guiTopIn + this.ySize); } diff --git a/src/main/java/cech12/solarcooker/client/SolarCookerTileEntityRenderer.java b/src/main/java/cech12/solarcooker/client/SolarCookerTileEntityRenderer.java index e762caf..85363d7 100644 --- a/src/main/java/cech12/solarcooker/client/SolarCookerTileEntityRenderer.java +++ b/src/main/java/cech12/solarcooker/client/SolarCookerTileEntityRenderer.java @@ -12,6 +12,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.Vector3f; //1.15 import net.minecraft.client.renderer.model.ItemCameraTransforms; import net.minecraft.client.renderer.model.ModelRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; @@ -19,7 +20,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.Direction; import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.vector.Vector3f; +//import net.minecraft.util.math.vector.Vector3f; //1.16 import net.minecraft.world.World; import javax.annotation.Nonnull; diff --git a/src/main/java/cech12/solarcooker/jei/SolarCookerJEIPlugin.java b/src/main/java/cech12/solarcooker/jei/SolarCookerJEIPlugin.java index 5a35f57..d310d05 100644 --- a/src/main/java/cech12/solarcooker/jei/SolarCookerJEIPlugin.java +++ b/src/main/java/cech12/solarcooker/jei/SolarCookerJEIPlugin.java @@ -34,12 +34,12 @@ public void registerRecipes(@Nonnull IRecipeRegistration registration) { ClientPlayerEntity player = Minecraft.getInstance().player; if (player != null) { RecipeManager manager = player.connection.getRecipeManager(); - registration.addRecipes(manager.func_241447_a_(RecipeTypes.SOLAR_COOKING), RecipeTypes.SOLAR_COOKING_ID); + registration.addRecipes(manager.getRecipes(RecipeTypes.SOLAR_COOKING).values(), RecipeTypes.SOLAR_COOKING_ID); //1.15 if (ServerConfig.VANILLA_RECIPES_ENABLED.get()) { - registration.addRecipes(manager.func_241447_a_(ServerConfig.getRecipeType()).stream() + registration.addRecipes(manager.getRecipes(ServerConfig.getRecipeType()).values().stream() //1.15 .filter(recipe -> ServerConfig.isRecipeNotBlacklisted(recipe.getId())) - .map(SolarCookingRecipe::convert) + .map(recipe -> SolarCookingRecipe.convert((SolarCookingRecipe) recipe)) //1.15 .collect(Collectors.toList()), RecipeTypes.SOLAR_COOKING_ID); } } diff --git a/src/main/java/cech12/solarcooker/tileentity/AbstractSolarCookerTileEntity.java b/src/main/java/cech12/solarcooker/tileentity/AbstractSolarCookerTileEntity.java index 26c92a4..b53c6d6 100644 --- a/src/main/java/cech12/solarcooker/tileentity/AbstractSolarCookerTileEntity.java +++ b/src/main/java/cech12/solarcooker/tileentity/AbstractSolarCookerTileEntity.java @@ -34,7 +34,7 @@ import net.minecraft.util.SoundEvents; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.util.math.Vec3d; //1.15 import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -84,7 +84,7 @@ public AbstractSolarCookerTileEntity(TileEntityType tileTypeIn, public boolean isSunlit() { if (this.world != null) { if (!this.world.isRemote) { - return this.world.func_230315_m_().hasSkyLight() + return this.world.getDimension().hasSkyLight() //1.15 && this.world.isDaytime() && !this.world.isRaining() && this.world.canSeeSky(this.pos.up()); @@ -105,8 +105,8 @@ public int getCookTimeTotal() { } @Override - public void read(@Nonnull BlockState stateIn, @Nonnull CompoundNBT nbtIn) { - super.read(stateIn, nbtIn); + public void read(@Nonnull CompoundNBT nbtIn) { //1.15 + super.read(nbtIn); //1.15 this.items = NonNullList.withSize(this.getSizeInventory(), ItemStack.EMPTY); ItemStackHelper.loadAllItems(nbtIn, this.items); this.cookTime = nbtIn.getInt("CookTime"); @@ -137,7 +137,7 @@ public SUpdateTileEntityPacket getUpdatePacket() { @Override public void onDataPacket(NetworkManager net, SUpdateTileEntityPacket pkt) { - this.read(this.getBlockState(), pkt.getNbtCompound()); + this.read(pkt.getNbtCompound()); //1.15 } @Override @@ -495,7 +495,7 @@ public void func_235645_d_(PlayerEntity p_235645_1_) { this.usedRecipes.clear(); } - public List> func_235640_a_(World p_235640_1_, Vector3d p_235640_2_) { + public List> func_235640_a_(World p_235640_1_, Vec3d p_235640_2_) { //1.15 List> list = Lists.newArrayList(); for(Object2IntMap.Entry entry : this.usedRecipes.object2IntEntrySet()) { @@ -508,7 +508,7 @@ public List> func_235640_a_(World p_235640_1_, Vector3d p_235640_2_) return list; } - private static void func_235641_a_(World p_235641_0_, Vector3d p_235641_1_, int p_235641_2_, float p_235641_3_) { + private static void func_235641_a_(World p_235641_0_, Vec3d p_235641_1_, int p_235641_2_, float p_235641_3_) { //1.15 int i = MathHelper.floor((float)p_235641_2_ * p_235641_3_); float f = MathHelper.frac((float)p_235641_2_ * p_235641_3_); if (f != 0.0F && Math.random() < (double)f) { diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index 3a8b7af..63e1f2d 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -1 +1,2 @@ public net.minecraft.item.crafting.CookingRecipeSerializer$IFactory +public net.minecraft.item.crafting.RecipeManager func_215366_a(Lnet/minecraft/item/crafting/IRecipeType;)Ljava/util/Map; #getRecipes 1.15 diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 03507ed..14cfd52 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -1,5 +1,5 @@ modLoader="javafml" -loaderVersion="[32,)" +loaderVersion="[31,)" issueTrackerURL="https://github.com/cech12/BrickShears/issues" license="The MIT License (MIT)" [[mods]] @@ -15,18 +15,18 @@ license="The MIT License (MIT)" [[dependencies.solarcooker]] modId="forge" mandatory=true - versionRange="[32.0.70,)" + versionRange="[31.2.47,)" ordering="NONE" side="BOTH" [[dependencies.solarcooker]] modId="minecraft" mandatory=true - versionRange="[1.16.1,)" + versionRange="[1.15.2,)" ordering="NONE" side="BOTH" [[dependencies.solarcooker]] modId="jei" mandatory=false - versionRange="[7.0.0.0,)" + versionRange="[6.0.0.2,)" ordering="NONE" side="BOTH" \ No newline at end of file