Added shapeless recipes for coal and redstone blocks, made coal blocks be usable in furnaces and small UI fix for vanilla

master
Wynd 2024-09-10 14:44:43 +03:00
parent 0f391bb92e
commit 737d8d66f8
3 changed files with 48 additions and 9 deletions

View File

@ -18,14 +18,16 @@ public class MainMod implements ModInitializer {
if (ModConfig.ENABLE_WHITE_WOOL_RECIPE.get()) { if (ModConfig.ENABLE_WHITE_WOOL_RECIPE.get()) {
for (int colorId = 0; colorId < 16; ++colorId) { for (int colorId = 0; colorId < 16; ++colorId) {
WyHelper.addShapelessRecipe(new ItemInstance(Tile.WOOL, 1, 0), new Object[]{ WyHelper.addShapelessRecipe(new ItemInstance(Tile.WOOL, 1, 0), new ItemInstance(Tile.WOOL, 1, WoolTile.method_2(colorId)),
new ItemInstance(Tile.WOOL, 1, WoolTile.method_2(colorId)), new ItemInstance(ItemType.dyePowder, 1, 15)}); new ItemInstance(ItemType.dyePowder, 1, 15));
} }
} }
if (ModConfig.ENABLE_COAL_AND_REDSTONE_BLOCKS_RECIPE.get()) { if (ModConfig.ENABLE_COAL_AND_REDSTONE_BLOCKS_RECIPE.get()) {
WyHelper.addShapedRecipe(new ItemInstance(ModTile.COAL_BLOCK, 1, 0), "###", "###", "###", '#', ItemType.coal); WyHelper.addShapedRecipe(new ItemInstance(ModTile.COAL_BLOCK, 1, 0), "###", "###", "###", '#', ItemType.coal);
WyHelper.addShapelessRecipe(new ItemInstance(ItemType.coal, 9), new ItemInstance(ModTile.COAL_BLOCK, 1));
WyHelper.addShapedRecipe(new ItemInstance(ModTile.REDSTONE_BLOCK, 1, 0), "###", "###", "###", '#', ItemType.redstone); WyHelper.addShapedRecipe(new ItemInstance(ModTile.REDSTONE_BLOCK, 1, 0), "###", "###", "###", '#', ItemType.redstone);
WyHelper.addShapelessRecipe(new ItemInstance(ItemType.redstone, 9), new ItemInstance(ModTile.REDSTONE_BLOCK, 1));
} }
} }
} }

View File

@ -7,6 +7,7 @@ import java.util.HashMap;
import net.minecraft.entity.player.Player; import net.minecraft.entity.player.Player;
import net.minecraft.item.ItemInstance; import net.minecraft.item.ItemInstance;
import net.minecraft.recipe.RecipeRegistry; import net.minecraft.recipe.RecipeRegistry;
import net.minecraft.tile.Tile;
import xyz.pixelatedw.finalbeta.mixin.MinecraftAccessorMixin; import xyz.pixelatedw.finalbeta.mixin.MinecraftAccessorMixin;
import xyz.pixelatedw.finalbeta.mixin.RecipeRegistryAccessorMixin; import xyz.pixelatedw.finalbeta.mixin.RecipeRegistryAccessorMixin;
@ -64,7 +65,7 @@ public class WyHelper {
// player.level.entities.stream().filter(e -> !(e instanceof Player)).forEach((e) -> ((net.minecraft.entity.Entity)e).remove()); // player.level.entities.stream().filter(e -> !(e instanceof Player)).forEach((e) -> ((net.minecraft.entity.Entity)e).remove());
// player.dropItem(new ItemInstance(Tile.LADDER, 64)); player.dropItem(new ItemInstance(Tile.GOLD_ORE, 64));
// player.dropItem(new ItemInstance(ItemType.minecart, 1)); // player.dropItem(new ItemInstance(ItemType.minecart, 1));
// player.dropItem(new ItemInstance(ItemType.minecartFurnace, 1)); // player.dropItem(new ItemInstance(ItemType.minecartFurnace, 1));
// player.dropItem(new ItemInstance(ItemType.coal, 64)); // player.dropItem(new ItemInstance(ItemType.coal, 64));
@ -81,10 +82,10 @@ public class WyHelper {
// player.level.setTile(x + i, y, z, Tile.REDSTONE_TORCH_LIT.id); // player.level.setTile(x + i, y, z, Tile.REDSTONE_TORCH_LIT.id);
// } // }
// player.level.setLevelTime(0); player.level.setLevelTime(0);
// player.level.getProperties().setRaining(false); player.level.getProperties().setRaining(false);
// player.level.getProperties().setRainTime(0); player.level.getProperties().setRainTime(0);
// player.level.getProperties().setThundering(false); player.level.getProperties().setThundering(false);
// player.level.getProperties().setThunderTime(0); player.level.getProperties().setThunderTime(0);
} }
} }

View File

@ -5,15 +5,21 @@ import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.entity.FurnaceEntity; import net.minecraft.entity.FurnaceEntity;
import net.minecraft.item.ItemInstance; import net.minecraft.item.ItemInstance;
import net.minecraft.item.ItemType; import net.minecraft.item.ItemType;
import net.minecraft.util.io.CompoundTag;
import xyz.pixelatedw.finalbeta.ModConfig; import xyz.pixelatedw.finalbeta.ModConfig;
import xyz.pixelatedw.finalbeta.ModTile;
@Mixin(FurnaceEntity.class) @Mixin(FurnaceEntity.class)
public class FurnaceEntityMixin { public class FurnaceEntityMixin {
@Shadow
public int fuelTime;
@Shadow @Shadow
private ItemInstance[] contents; private ItemInstance[] contents;
@ -26,4 +32,34 @@ public class FurnaceEntityMixin {
} }
} }
} }
@Inject(method = "getFuelTime", at = @At("HEAD"), cancellable = true)
private void getFuelTime(ItemInstance stack, CallbackInfoReturnable<Integer> cir) {
if (stack == null) {
cir.setReturnValue(0);
return;
}
if (stack.getType().id == ModTile.COAL_BLOCK.id) {
cir.setReturnValue(16000);
return;
}
}
/*
* Properly saving and loading the fuelTime as otherwise minecraft tries to
* get it from the fuel item slot, which can be empty...and so the fuel time
* defaults to 200. By saving it we make sure the fuel time is always
* correct regardless of the fuel slot contents.
*/
@Inject(method = "writeIdentifyingData", at = @At("TAIL"))
public void writeIdentifyingData(CompoundTag tag, CallbackInfo ci) {
tag.put("FuelTime", this.fuelTime);
}
@Inject(method = "readIdentifyingData", at = @At("TAIL"))
public void readIdentifyingData(CompoundTag tag, CallbackInfo ci) {
this.fuelTime = tag.getInt("FuelTime");
}
} }