Skip to content

Commit

Permalink
backport to 1.15 #10
Browse files Browse the repository at this point in the history
  • Loading branch information
cech12 committed Jan 26, 2021
1 parent ec198c5 commit b0a45b4
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 39 deletions.
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.+
jei_version=1.15.2:6.0.0.2+
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -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));
}
Expand Down Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cech12/solarcooker/block/ReflectorBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public boolean isToolEffective(BlockState state, ToolType tool) {
@Override
public void addInformation(@Nonnull ItemStack stack, @Nullable IBlockReader worldIn, @Nonnull List<ITextComponent> 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
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/cech12/solarcooker/block/SolarCookerBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
Expand Down
38 changes: 26 additions & 12 deletions src/main/java/cech12/solarcooker/client/SolarCookerScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

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;
import net.minecraft.util.text.ITextComponent;
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<SolarCookerContainer> {
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
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;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand All @@ -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");
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -495,7 +495,7 @@ public void func_235645_d_(PlayerEntity p_235645_1_) {
this.usedRecipes.clear();
}

public List<IRecipe<?>> func_235640_a_(World p_235640_1_, Vector3d p_235640_2_) {
public List<IRecipe<?>> func_235640_a_(World p_235640_1_, Vec3d p_235640_2_) { //1.15
List<IRecipe<?>> list = Lists.newArrayList();

for(Object2IntMap.Entry<ResourceLocation> entry : this.usedRecipes.object2IntEntrySet()) {
Expand All @@ -508,7 +508,7 @@ public List<IRecipe<?>> 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) {
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/META-INF/accesstransformer.cfg
Original file line number Diff line number Diff line change
@@ -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
8 changes: 4 additions & 4 deletions src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
modLoader="javafml"
loaderVersion="[32,)"
loaderVersion="[31,)"
issueTrackerURL="https://github.com/cech12/BrickShears/issues"
license="The MIT License (MIT)"
[[mods]]
Expand All @@ -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"

0 comments on commit b0a45b4

Please sign in to comment.